def test_emulator(name): test_harness.run_emulator(block_device=SOURCE_BLOCK_DEV, dump_file=EMULATOR_OUTPUT, dump_base=0x200000, dump_length=FILE_SIZE) test_harness.assert_files_equal(SOURCE_BLOCK_DEV, EMULATOR_OUTPUT, 'file mismatch')
def fs_test(name): test_harness.compile_test('fs.c') subprocess.check_output( ['../../../bin/mkfs', 'obj/fsimage.bin', 'test.txt'], stderr=subprocess.STDOUT) result = test_harness.run_emulator(block_device='obj/fsimage.bin') if result.find('PASS') == -1: raise TestException('test program did not indicate pass')
def test_alias_emulator(name): test_harness.compile_test(['alias.c', 'identity_tlb_miss_handler.s']) result = test_harness.run_emulator(dump_file=DUMP_FILE, dump_base=0x100000, dump_length=32) if result.find('read 00900000 "Test String"') == -1: raise test_harness.TestException('did not get correct read string:\n' + result) with open(DUMP_FILE, 'rb') as f: if f.read(len(EXPECT_STRING)) != EXPECT_STRING: raise test_harness.TestException('memory contents did not match')
def emulator_crash(name): test_harness.compile_test('crash.c') try: result = test_harness.run_emulator() # The test program deliberately crashes. If the harness doesn't throw # an exception, that is a failure. raise TestException('Did not catch crash') except: # ...and vice versa pass
def emulator_crash(name): test_harness.compile_test('crash.c') try: result = test_harness.run_emulator() # The test program deliberately crashes. If the harness doesn't throw # an exception, that is a failure. raise test_harness.TestException('Did not catch crash') except: # ...and vice versa pass
def test_io_map_emulator(name): test_harness.compile_test(['io_map.c']) result = test_harness.run_emulator(dump_file=DUMP_FILE, dump_base=0x100000, dump_length=32) # Check value printed via virtual serial port if result.find('jabberwocky') == -1: raise test_harness.TestException('did not get correct read string:\n' + result) # Check value written to memory with open(DUMP_FILE, 'rb') as f: if f.read(len('galumphing')) != bytearray('galumphing', 'ascii'): raise test_harness.TestException('memory contents did not match')
def run_test(name): if name.endswith('_emulator'): basename = name[0:-len('_emulator')] isverilator = False elif name.endswith('_verilator'): basename = name[0:-len('_verilator')] isverilator = True test_harness.compile_test([basename + '.c']) if isverilator: result = test_harness.run_verilator() else: result = test_harness.run_emulator() test_harness.check_result(basename + '.c', result)
def run_generic_test(name): if name.endswith('_emulator'): basename = name[0:-len('_emulator')] isverilator = False elif name.endswith('_verilator'): basename = name[0:-len('_verilator')] isverilator = True test_harness.compile_test([basename + '.c']) if isverilator: result = test_harness.run_verilator() else: result = test_harness.run_emulator() test_harness.check_result(basename + '.c', result)
# # Copyright 2011-2015 Jeff Bush # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import sys import subprocess sys.path.insert(0, '../..') import test_harness test_harness.compile_test('fs.c') subprocess.check_call(['../../../bin/mkfs', 'obj/fsimage.bin', 'test.txt']) result = test_harness.run_emulator(block_device='obj/fsimage.bin') if result.find('PASS') == -1: print 'FAIL' sys.exit(1) else: print 'PASS'
def test_fill_emulator(name): test_harness.compile_test(['fill_test.c', 'wrap_tlb_miss_handler.s']) result = test_harness.run_emulator() if result.find('FAIL') != -1 or result.find('PASS') == -1: raise test_harness.TestException(result + '\ntest did not signal pass')
print 'FAIL' else: print 'PASS' except KeyboardInterrupt: sys.exit(1) except: print 'FAIL' failing_tests += 1 else: # Emulator for source_file in files: for optlevel in ['s', '0', '3']: print 'Testing ' + source_file + ' at -O' + optlevel + ' (emulator)', try: test_harness.compile_test(source_file, optlevel=optlevel) result = test_harness.run_emulator() if not check_result(source_file, result): failing_tests += 1 print 'FAIL' else: print 'PASS' except KeyboardInterrupt: sys.exit(1) except: print 'FAIL' failing_tests += 1 print 'total tests', len(files) print 'failed', failing_tests if failing_tests > 0: sys.exit(1)
import test_harness FILE_SIZE = 8192 SOURCE_BLOCK_DEV = "obj/bdevimage.bin" EMULATOR_OUTPUT = "obj/emumem.bin" VERILATOR_OUTPUT = "obj/verimem.bin" test_harness.compile_test("sdmmc.c") # Create random file with open(SOURCE_BLOCK_DEV, "wb") as f: f.write(os.urandom(FILE_SIZE)) print "testing in emulator" test_harness.run_emulator( block_device=SOURCE_BLOCK_DEV, dump_file=EMULATOR_OUTPUT, dump_base=0x200000, dump_length=FILE_SIZE ) if not test_harness.assert_files_equal(SOURCE_BLOCK_DEV, EMULATOR_OUTPUT): print "FAIL: simulator final memory contents do not match" sys.exit(1) print "testing in verilator" test_harness.run_verilator( block_device=SOURCE_BLOCK_DEV, dump_file=VERILATOR_OUTPUT, dump_base=0x200000, dump_length=FILE_SIZE, extra_args=["+autoflushl2=1"], ) if not test_harness.assert_files_equal(SOURCE_BLOCK_DEV, VERILATOR_OUTPUT): print "FAIL: verilator final memory contents do not match"
def run_emulator_test(source_file): test_harness.compile_test(source_file, optlevel='3') result = test_harness.run_emulator() check_result(source_file, result)
def fs_test(name): test_harness.compile_test('fs.c') subprocess.check_output(['../../../bin/mkfs', 'obj/fsimage.bin', 'test.txt'], stderr=subprocess.STDOUT) result = test_harness.run_emulator(block_device='obj/fsimage.bin') if result.find('PASS') == -1: raise TestException('test program did not indicate pass')
def test_fill_emulator(name): test_harness.compile_test(['fill_test.c', 'wrap_tlb_miss_handler.s']) result = test_harness.run_emulator() if result.find('FAIL') != -1 or result.find('PASS') == -1: raise test_harness.TestException(result + '\ntest did not signal pass\n' + result)
def run_emulator_test(source_file): test_harness.compile_test(source_file, optlevel='3') result = test_harness.run_emulator() test_harness.check_result(source_file, result)