コード例 #1
0
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')
コード例 #2
0
ファイル: runtest.py プロジェクト: ksarada/NyuziProcessor
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')
コード例 #3
0
ファイル: runtest.py プロジェクト: FulcronZ/NyuziProcessor
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')
コード例 #4
0
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
コード例 #5
0
ファイル: runtest.py プロジェクト: FulcronZ/NyuziProcessor
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
コード例 #6
0
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')
コード例 #7
0
ファイル: runtest.py プロジェクト: FulcronZ/NyuziProcessor
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')
コード例 #8
0
ファイル: runtest.py プロジェクト: ksarada/NyuziProcessor
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)
コード例 #9
0
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')
コード例 #10
0
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)
コード例 #11
0
ファイル: runtest.py プロジェクト: ForrestBlue/NyuziProcessor
# 
# 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'
コード例 #12
0
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')
コード例 #13
0
ファイル: runtest.py プロジェクト: ForrestBlue/NyuziProcessor
				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)
コード例 #14
0
ファイル: runtest.py プロジェクト: FulcronZ/NyuziProcessor
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')
コード例 #15
0
ファイル: runtest.py プロジェクト: ForrestBlue/NyuziProcessor
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"
コード例 #16
0
ファイル: runtest.py プロジェクト: xhy20070406/NyuziProcessor
def run_emulator_test(source_file):
	test_harness.compile_test(source_file, optlevel='3')
	result = test_harness.run_emulator()
	check_result(source_file, result)
コード例 #17
0
ファイル: runtest.py プロジェクト: ksarada/NyuziProcessor
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')
コード例 #18
0
ファイル: runtest.py プロジェクト: FulcronZ/NyuziProcessor
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)
コード例 #19
0
ファイル: runtest.py プロジェクト: ksarada/NyuziProcessor
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)