How to use erase method in autotest

Best Python code snippet using autotest_python

programmer_xmega.py

Source:programmer_xmega.py Github

copy

Full Screen

...151 return data, t152 #No known chip found?153 logging.debug("Detected unknown XMEGA: %02x %02x %02x"%(data[0], data[1], data[2]))154 return data, None155 def erase(self, memtype="chip"):156 if memtype == "app":157 self.eraseApp()158 elif memtype == "chip":159 self.eraseChip()160 else:161 raise ValueError("Invalid memtype: %s" % memtype)162 def autoProgram(self, hexfile, erase=True, verify=True, logfunc=print_fun, waitfunc=None):163 """Helper funciton for GUI, auto-programs XMEGA device while printing messages to different options. Returns true/false."""164 status = "FAILED"165 fname = hexfile166 if logfunc: logfunc("***Starting FLASH program process at %s***" % datetime.now().strftime('%H:%M:%S'))167 if waitfunc: waitfunc()168 if os.path.isfile(fname):169 if logfunc: logfunc("File %s last changed on %s" % (fname, time.ctime(os.path.getmtime(fname))))170 try:171 if logfunc: logfunc("Entering Programming Mode")172 if waitfunc: waitfunc()173 self.find()174 if erase:175 try:176 self.erase()177 except IOError:178 if logfunc: logfunc("**chip-erase timeout, erasing application only**")179 if waitfunc: waitfunc()180 self.enablePDI(False)181 self.enablePDI(True)182 self.erase("app")183 if waitfunc: waitfunc()184 self.program(hexfile, memtype="flash", verify=verify, logfunc=logfunc, waitfunc=waitfunc)185 if waitfunc: waitfunc()186 if logfunc: logfunc("Exiting programming mode")187 self.close()188 if waitfunc: waitfunc()189 status = "SUCCEEDED"190 except IOError, e:191 if logfunc: logfunc("FAILED: %s" % str(e))192 try:193 self.close()194 except IOError:195 pass196 else:...

Full Screen

Full Screen

test_core0_flash_erase_region.py

Source:test_core0_flash_erase_region.py Github

copy

Full Screen

1#! /usr/bin/env python2# Copyright (c) 2014 Freescale Semiconductor, Inc.3# All rights reserved.4#5# Redistribution and use in source and binary forms, with or without modification,6# are permitted provided that the following conditions are met:7#8# o Redistributions of source code must retain the above copyright notice, this list9# of conditions and the following disclaimer.10#11# o Redistributions in binary form must reproduce the above copyright notice, this12# list of conditions and the following disclaimer in the documentation and/or13# other materials provided with the distribution.14#15# o Neither the name of Freescale Semiconductor, Inc. nor the names of its16# contributors may be used to endorse or promote products derived from this17# software without specific prior written permission.18#19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND20# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED21# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE22# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR23# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES24# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;25# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON26# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29import pytest30import os31import sys32import random33filePath = os.path.abspath(os.path.dirname(__file__)).replace('\\', '/')34mainPath = os.path.abspath(os.path.join(filePath, '..')).replace('\\', '/')35sys.path.append(mainPath) # add application path to env36from fsl import bootloader37from common import common_util38from common import flash_erase_region39#############################################################################################################40#41# Erase reserved flash/ram region with core 0.42#43############################################################################################################## 44class TestCore0EraseReservedMemory:45 @pytest.fixture(autouse = True)46 def setup(self, request, bl):47 common_util.setup_test_environment(bl, bootCore = 'core0', needFlashEraseAll = False)48 49 def teardown():50 pass51 request.addfinalizer(teardown)52 53 def test_core0_erase_reserved_ram(self, bl):54 flash_erase_region.erase_reserved_memory_region(bl, memType = 'ram')55 56 def test_core0_erase_reserved_flash(self, bl):57 flash_erase_region.erase_reserved_memory_region(bl, memType = 'flash')58#############################################################################################################59#60# Erase Flash 0 with core 0.61#62############################################################################################################# 63class TestCore0EraseFlash0:64 @pytest.fixture(autouse = True)65 def setup(self, request, bl):66 self.bootCore = 'core0'67 self.memType = 'flash'68 self.memIndex = 069 common_util.setup_test_environment(bl, bootCore = self.bootCore, needFlashEraseAll=True)70 71 def teardown():72 pass73 request.addfinalizer(teardown)74 def test_core0_erase_start_available_flash0_1_sector(self, bl):75 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=1)76 77 def test_core0_erase_start_available_flash0_2_sectors(self, bl):78 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=2) 79 80 def test_core0_erase_start_available_flash0_3_sectors(self, bl):81 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=3)82 83 def test_core0_erase_start_available_flash0_4_sectors(self, bl):84 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=4) 85 86 def test_core0_erase_half_of_available_flash0(self, bl): 87 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, 'halfOfAvailableMemory')88 89 def test_core0_erase_all_of_available_flash0(self, bl): 90 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, 'allOfAvailableMemory')91 def test_core0_erase_flash0_unaligned_address(self, bl):92 flash_erase_region.erase_unaligned_memory_address(bl, self.memType, self.memIndex)93 def test_core0_erase_flash0_unaligned_byte_length(self, bl): 94 flash_erase_region.erase_unaligned_bytes_length(bl, self.memType, self.memIndex)95 def test_core0_erase_out_of_flash0(self, bl):96 flash_erase_region.erase_out_of_memory_range(bl, self.memType, self.memIndex)97#############################################################################################################98#99# Erase Flash 1 with core 0.100#101############################################################################################################# 102class TestCore0EraseFlash1:103 @pytest.fixture(autouse = True)104 def setup(self, request, bl):105 self.bootCore = 'core0'106 self.memType = 'flash'107 self.memIndex = 1108 if(self.memIndex >= bl.target.maxFlashIndex):109 pytest.skip("No FLASH 1 region!")110 common_util.setup_test_environment(bl, bootCore = self.bootCore, needFlashEraseAll=True)111 112 def teardown():113 pass114 request.addfinalizer(teardown)115 def test_core0_erase_start_available_flash1_1_sector(self, bl):116 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=1)117 118 def test_core0_erase_start_available_flash1_2_sectors(self, bl):119 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=2) 120 121 def test_core0_erase_start_available_flash1_3_sectors(self, bl):122 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=3)123 124 def test_core0_erase_start_available_flash1_4_sectors(self, bl):125 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, sectorsNumber=4) 126 127 def test_core0_erase_half_of_available_flash1(self, bl): 128 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, 'halfOfAvailableMemory')129 130 def test_core0_erase_all_of_available_flash1(self, bl): 131 flash_erase_region.erase_sectors_at_start_of_available_region(bl, self.memType, self.memIndex, 'allOfAvailableMemory')132 def test_core0_erase_flash1_unaligned_address(self, bl):133 flash_erase_region.erase_unaligned_memory_address(bl, self.memType, self.memIndex)134 def test_core0_erase_flash1_unaligned_byte_length(self, bl): 135 flash_erase_region.erase_unaligned_bytes_length(bl, self.memType, self.memIndex)136 def test_core0_erase_out_of_flash1(self, bl):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful