Beispiel #1
0
def random_access_mmu_stress(_, target):
    test_harness.build_program(['random_access.S'])
    test_harness.run_program(
        target=target,
        dump_file='obj/vmem.bin',
        dump_base=DUMP_BASE,
        dump_length=MEMORY_SIZE * NUM_THREADS,
        timeout=240,
        flush_l2=True)

    # Check that threads have written proper values
    with open('obj/vmem.bin', 'rb') as memfile:
        for page_num in range(int(MEMORY_SIZE / PAGE_SIZE)):
            for thread_id in range(NUM_THREADS):
                for page_offset in range(0, PAGE_SIZE, 4):
                    val = memfile.read(4)
                    if len(val) < 4:
                        raise test_harness.TestException(
                            'output file is truncated')

                    num_val, = struct.unpack('<L', val)
                    va = page_num * PAGE_SIZE + \
                        page_offset + int(DUMP_BASE / 4)
                    expected = (thread_id << 24) | va
                    if num_val != expected:
                        raise test_harness.TestException(
                            'FAIL: mismatch @{:x} : got {:x} expected {:x}'.format((page_num * 4 + thread_id) * PAGE_SIZE,
                                                                                   num_val, expected))
Beispiel #2
0
def random_access_mmu_stress(_, target):
    hex_file = test_harness.build_program(['random_access.S'])
    test_harness.run_program(hex_file,
                             target,
                             dump_file=MEM_DUMP_FILE,
                             dump_base=DUMP_BASE,
                             dump_length=MEMORY_SIZE * NUM_THREADS,
                             timeout=240,
                             flush_l2=True)

    # Check that threads have written proper values
    with open(MEM_DUMP_FILE, 'rb') as memfile:
        for page_num in range(int(MEMORY_SIZE / PAGE_SIZE)):
            for thread_id in range(NUM_THREADS):
                for page_offset in range(0, PAGE_SIZE, 4):
                    val = memfile.read(4)
                    if len(val) < 4:
                        raise test_harness.TestException(
                            'output file is truncated')

                    num_val, = struct.unpack('<L', val)
                    va = page_num * PAGE_SIZE + \
                        page_offset + int(DUMP_BASE / 4)
                    expected = (thread_id << 24) | va
                    if num_val != expected:
                        raise test_harness.TestException(
                            'FAIL: mismatch @{:x} : got {:x} expected {:x}'.
                            format((page_num * 4 + thread_id) * PAGE_SIZE,
                                   num_val, expected))
Beispiel #3
0
def sdmmc_read(name, target):
    # Create random file
    with open(SOURCE_BLOCK_DEV, 'wb') as randfile:
        randfile.write(os.urandom(FILE_SIZE))

    test_harness.build_program(['sdmmc_read.c'])
    test_harness.run_program(target=target,
                             block_device=SOURCE_BLOCK_DEV,
                             dump_file=MEMDUMP,
                             dump_base=0x200000,
                             dump_length=FILE_SIZE,
                             flush_l2=True)

    test_harness.assert_files_equal(SOURCE_BLOCK_DEV, MEMDUMP, 'file mismatch')
Beispiel #4
0
def sdmmc_read(name, target):
    # Create random file
    with open(SOURCE_BLOCK_DEV, 'wb') as randfile:
        randfile.write(os.urandom(FILE_SIZE))

    test_harness.build_program(['sdmmc_read.c'])
    test_harness.run_program(
        target=target,
        block_device=SOURCE_BLOCK_DEV,
        dump_file=MEMDUMP,
        dump_base=0x200000,
        dump_length=FILE_SIZE,
        flush_l2=True)

    test_harness.assert_files_equal(SOURCE_BLOCK_DEV, MEMDUMP, 'file mismatch')
Beispiel #5
0
def sdmmc_read(name):
    # Create random file
    with open(SOURCE_BLOCK_DEV, 'wb') as randfile:
        randfile.write(os.urandom(FILE_SIZE))

    test_harness.build_program(['sdmmc_read.c'])
    test_harness.run_program(
        environment='emulator' if name.endswith('_emulator') else 'verilator',
        block_device=SOURCE_BLOCK_DEV,
        dump_file=MEMDUMP,
        dump_base=0x200000,
        dump_length=FILE_SIZE,
        flush_l2=True)

    test_harness.assert_files_equal(SOURCE_BLOCK_DEV, MEMDUMP, 'file mismatch')
Beispiel #6
0
def sdmmc_read(name):
    # Create random file
    with open(SOURCE_BLOCK_DEV, 'wb') as randfile:
        randfile.write(os.urandom(FILE_SIZE))

    test_harness.build_program(['sdmmc_read.c'])
    test_harness.run_program(
        environment='emulator' if name.endswith('_emulator') else 'verilator',
        block_device=SOURCE_BLOCK_DEV,
        dump_file=MEMDUMP,
        dump_base=0x200000,
        dump_length=FILE_SIZE,
        flush_l2=True)

    test_harness.assert_files_equal(SOURCE_BLOCK_DEV, MEMDUMP, 'file mismatch')
Beispiel #7
0
def run_io_interrupt(_, target):
    hex_file = test_harness.build_program(['io_interrupt.S'])
    result = test_harness.run_program(hex_file, target)
    lines = result.split('\n')
    output = None

    for line in lines:
        start = line.find('!')
        if start != -1:
            output = line[start + 1:]

    if output is None:
        raise test_harness.TestException(
            'Could not find output string:\n' + result)

    # Make sure enough interrupts were triggered
    if output.count('*') < 2:
        raise test_harness.TestException(
            'Not enough interrupts triggered:\n' + result)

    # Make sure we see at least some of the base string printed after an
    # interrupt
    if output.find('*') >= len(output) - 1:
        raise test_harness.TestException(
            'No instances of interrupt return:\n' + result)

    # Remove all asterisks (interrupts) and make sure string is intact
    stripped = output.replace('*', '')
    if stripped != '0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`' \
            'abcdefghijklmnopqrstuvwxyz' * 10:
        raise test_harness.TestException(
            'Base string does not match:\n' + stripped)
Beispiel #8
0
def sdmmc_write(_, target):
    with open(SOURCE_BLOCK_DEV, 'wb') as fsimage:
        fsimage.write(b'\xcc' * 1536)

    test_harness.build_program(['sdmmc_write.c'])
    result = test_harness.run_program(target=target,
                                      block_device=SOURCE_BLOCK_DEV)
    if 'FAIL' in result:
        raise test_harness.TestException('Test failed ' + result)

    with open(SOURCE_BLOCK_DEV, 'rb') as fsimage:
        end_contents = fsimage.read()

    # Check contents. First block is not modified
    for index in range(512):
        if end_contents[index] != 0xcc:
            raise test_harness.TestException(
                'mismatch at {} expected 0xcc got 0x{:02x}'.format(
                    index, end_contents[index]))

    # Second block has a pattern in it
    for index in range(512):
        expected = (index ^ (index >> 3)) & 0xff
        if end_contents[index + 512] != expected:
            raise test_harness.TestException(
                'mismatch at {} expected 0x{:02x} got 0x{:02x}'.format(
                    index + 512, expected, end_contents[index + 512]))

    # Third block is not modified
    for index in range(512):
        if end_contents[index + 1024] != 0xcc:
            raise test_harness.TestException(
                'mismatch at {} expected 0xcc got 0x{:02x}'.format(
                    index + 1024, end_contents[index + 1024]))
Beispiel #9
0
def sdmmc_write(_, target):
    with open(SOURCE_BLOCK_DEV, 'wb') as fsimage:
        fsimage.write(b'\xcc' * 1536)

    test_harness.build_program(['sdmmc_write.c'])
    result = test_harness.run_program(
        target=target,
        block_device=SOURCE_BLOCK_DEV)
    if 'FAIL' in result:
        raise test_harness.TestException('Test failed ' + result)

    with open(SOURCE_BLOCK_DEV, 'rb') as fsimage:
        end_contents = fsimage.read()

    # Check contents. First block is not modified
    for index in range(512):
        if end_contents[index] != 0xcc:
            raise test_harness.TestException('mismatch at {} expected 0xcc got 0x{:02x}'
                .format(index, end_contents[index]))

    # Second block has a pattern in it
    for index in range(512):
        expected = (index ^ (index >> 3)) & 0xff
        if end_contents[index + 512] != expected:
            raise test_harness.TestException('mismatch at {} expected 0x{:02x} got 0x{:02x}'
                .format(index + 512, expected, end_contents[index + 512]))

    # Third block is not modified
    for index in range(512):
        if end_contents[index + 1024] != 0xcc:
            raise test_harness.TestException('mismatch at {} expected 0xcc got 0x{:02x}'
                .format(index + 1024, end_contents[index + 1024]))
Beispiel #10
0
def atomic(_, target):
    test_harness.build_program(['atomic.S'])
    test_harness.run_program(target=target,
                             dump_file=test_harness.WORK_DIR + '/vmem.bin',
                             dump_base=0x100000,
                             dump_length=0x800,
                             flush_l2=True)

    with open(test_harness.WORK_DIR + '/vmem.bin', 'rb') as memfile:
        for _ in range(512):
            val = memfile.read(4)
            if len(val) < 4:
                raise test_harness.TestException('output file is truncated')

            num_val, = struct.unpack('<L', val)
            if num_val != 10:
                raise test_harness.TestException('FAIL: mismatch: ' +
                                                 str(num_val))
Beispiel #11
0
def dflush(_):
    test_harness.build_program(['dflush.S'])
    test_harness.run_program(
        environment='verilator',
        dump_file='obj/vmem.bin',
        dump_base=BASE_ADDRESS,
        dump_length=0x40000)
    with open('obj/vmem.bin', 'rb') as memfile:
        for index in range(4096):
            val = memfile.read(4)
            if len(val) < 4:
                raise test_harness.TestException('output file is truncated')

            num_val, = struct.unpack('<L', val)
            expected = 0x1f0e6231 + (index // 16)
            if num_val != expected:
                raise test_harness.TestException('FAIL: mismatch at ' + hex(
                    BASE_ADDRESS + (index * 4)) + ' want ' + str(expected) + ' got ' + str(num_val))
Beispiel #12
0
def dflush(_, target):
    test_harness.build_program(['dflush.S'])
    test_harness.run_program(
        target=target,
        dump_file='obj/vmem.bin',
        dump_base=BASE_ADDRESS,
        dump_length=0x40000)
    with open('obj/vmem.bin', 'rb') as memfile:
        for index in range(4096):
            val = memfile.read(4)
            if len(val) < 4:
                raise test_harness.TestException('output file is truncated')

            num_val, = struct.unpack('<L', val)
            expected = 0x1f0e6231 + (index // 16)
            if num_val != expected:
                raise test_harness.TestException('FAIL: mismatch at ' + hex(
                    BASE_ADDRESS + (index * 4)) + ' want ' + str(expected) + ' got ' + str(num_val))
def run_compiler_test(source_file, target):
    if target == 'host':
        subprocess.check_call(['cc', source_file, '-o', 'obj/a.out'],
                              stderr=subprocess.STDOUT)
        result = subprocess.check_output('obj/a.out')
        test_harness.check_result(source_file, result.decode())
    else:
        test_harness.build_program([source_file])
        result = test_harness.run_program(target)
        test_harness.check_result(source_file, result)
Beispiel #14
0
def run_compiler_test(source_file, target):
    if target == 'host':
        subprocess.check_call(['cc', source_file, '-o', HOST_EXE_FILE],
                              stderr=subprocess.STDOUT)
        result = subprocess.check_output(HOST_EXE_FILE)
        test_harness.check_result(source_file, result.decode())
    else:
        hex_file = test_harness.build_program([source_file])
        result = test_harness.run_program(hex_file, target)
        test_harness.check_result(source_file, result)
Beispiel #15
0
def run_compiler_test(source_file, target):
    if target == 'host':
        subprocess.check_call(['cc', source_file, '-o', 'obj/a.out'],
                              stderr=subprocess.STDOUT)
        result = subprocess.check_output('obj/a.out')
        test_harness.check_result(source_file, result.decode())
    else:
        test_harness.build_program([source_file])
        result = test_harness.run_program(target)
        test_harness.check_result(source_file, result)
Beispiel #16
0
def dflush(_, target):
    hex_file = test_harness.build_program(['dflush.S'])
    test_harness.run_program(hex_file,
                             target,
                             dump_file=MEM_DUMP_FILE,
                             dump_base=BASE_ADDRESS,
                             dump_length=0x40000)
    with open(MEM_DUMP_FILE, 'rb') as memfile:
        for index in range(4096):
            val = memfile.read(4)
            if len(val) < 4:
                raise test_harness.TestException('output file is truncated')

            num_val, = struct.unpack('<L', val)
            expected = 0x1f0e6231 + (index // 16)
            if num_val != expected:
                raise test_harness.TestException(
                    'FAIL: mismatch at 0x{:x} want {} got {}'.format(
                        BASE_ADDRESS + (index * 4), expected, num_val))
Beispiel #17
0
def dflush(_, target):
    hex_file = test_harness.build_program(['dflush.S'])
    test_harness.run_program(
        hex_file,
        target,
        dump_file=MEM_DUMP_FILE,
        dump_base=BASE_ADDRESS,
        dump_length=0x40000)
    with open(MEM_DUMP_FILE, 'rb') as memfile:
        for index in range(4096):
            val = memfile.read(4)
            if len(val) < 4:
                raise test_harness.TestException('output file is truncated')

            num_val, = struct.unpack('<L', val)
            expected = 0x1f0e6231 + (index // 16)
            if num_val != expected:
                raise test_harness.TestException('FAIL: mismatch at 0x{:x} want {} got {}'.format(
                    BASE_ADDRESS + (index * 4), expected, num_val))
Beispiel #18
0
def atomic(_, target):
    test_harness.build_program(['atomic.S'])
    test_harness.run_program(
        target=target,
        dump_file=test_harness.WORK_DIR + '/vmem.bin',
        dump_base=0x100000,
        dump_length=0x800,
        flush_l2=True)

    with open(test_harness.WORK_DIR + '/vmem.bin', 'rb') as memfile:
        for _ in range(512):
            val = memfile.read(4)
            if len(val) < 4:
                raise test_harness.TestException('output file is truncated')

            num_val, = struct.unpack('<L', val)
            if num_val != 10:
                raise test_harness.TestException(
                    'FAIL: mismatch: ' + str(num_val))
Beispiel #19
0
def profile(*unused):
    hexfile = test_harness.build_program(['test_program.c'])

    # XXX hack: this is currently not returned from build_program, but I
    # know what the name is.
    elffile = hexfile.replace('.hex', '.elf')
    profile_file = os.path.join(test_harness.WORK_DIR, 'profile.out')

    test_harness.run_program(hexfile, 'verilator', profile_file=profile_file)

    symbol_file = os.path.join(test_harness.WORK_DIR, 'symbols.txt')
    objdump_args = [
        os.path.join(test_harness.COMPILER_BIN_DIR, 'llvm-objdump'),
        '-t', elffile
    ]
    symbols = subprocess.check_output(objdump_args)
    with open(symbol_file, 'w') as f:
        f.write(symbols.decode())

    profile_args = [
        os.path.join(test_harness.TOOL_BIN_DIR, 'profile.py'),
        symbol_file,
        profile_file
    ]
    profile_output = subprocess.check_output(' '.join(profile_args), shell=True)
    profile_lines = profile_output.decode().split('\n')
    profile_tuples = [line.split() for line in profile_lines if line]
    profile_map = {func: int(count) for count, _, func in profile_tuples}

    # These tests don't end up being exactly 2x the number of samples. Because
    # the system samples randomly, it can vary. I could have ran the test longer
    # to get more samples, but this is really just a smoke test and I didn't want
    # to bloat the test time unnecessarily.
    loop5k = profile_map['loop5000']
    loop10k = profile_map['loop10000']
    loop20k = profile_map['loop20000']
    test_harness.assert_greater(loop5k, 0)
    test_harness.assert_greater(loop10k, loop5k * 1.75)
    test_harness.assert_greater(loop20k, loop10k * 1.75)
Beispiel #20
0
def run_csmith_test(_, target):
    # Find version of csmith
    result = subprocess.check_output(['csmith', '-v']).decode()
    got = VERSION_RE.search(result)
    if not got:
        raise test_harness.TestException(
            'Could not determine csmith version ' + result)

    version_str = got.group('version')
    csmith_include = '-I/usr/local/include/csmith-' + version_str

    for x in range(100):
        source_file = 'test%04d.c' % x
        print('running ' + source_file)

        # Disable packed structs because we don't support unaligned accesses.
        # Disable longlong to avoid incompatibilities between 32-bit Nyuzi
        # and 64-bit hosts.
        subprocess.check_call([
            'csmith', '-o', source_file, '--no-longlong', '--no-packed-struct'
        ])

        # Compile and run on host
        subprocess.check_call([
            'cc', '-w', source_file, '-o', test_harness.WORK_DIR + '/a.out',
            csmith_include
        ])
        result = subprocess.check_output(test_harness.WORK_DIR +
                                         '/a.out').decode()

        got = CHECKSUM_RE.search(result)
        if not got:
            raise test_harness.TestException('no checksum in host output')

        host_checksum = int(got.group('checksum'), 16)
        print('host checksum %08x' % host_checksum)

        # Compile and run under emulator
        test_harness.build_program([source_file], cflags=[csmith_include])
        result = test_harness.run_program(target)
        got = CHECKSUM_RE.search(result)
        if not got:
            raise test_harness.TestException('no checksum in host output')

        emulator_checksum = int(got.group('checksum'), 16)
        print('emulator checksum %08x' % emulator_checksum)
        if host_checksum != emulator_checksum:
            raise test_harness.TestException('checksum mismatch')

        print('PASS')
Beispiel #21
0
def filesystem(_, target):
    '''
    Filesystem tests. This creates a filesystem image with the test file fstest.txt
    in it, the compiles the program fs.c to perform operations on it. The program
    will print 'PASS' if it is successful.
    '''

    test_harness.build_program(['fs.c'])
    subprocess.check_output(
        [test_harness.BIN_DIR + 'mkfs', test_harness.WORK_DIR + '/fsimage.bin',
         'fstest.txt'], stderr=subprocess.STDOUT)
    result = test_harness.run_program(target=target,
                                      block_device=test_harness.WORK_DIR + '/fsimage.bin')
    if 'PASS' not in result or 'FAIL' in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #22
0
def filesystem(_):
    '''
    Filesystem tests. This creates a filesystem image with the test file fstest.txt
    in it, the compiles the program fs.c to perform operations on it. The program
    will print 'PASS' if it is successful.
    '''

    test_harness.build_program(['fs.c'])
    subprocess.check_output(
        [test_harness.PROJECT_TOP + '/bin/mkfs', 'obj/fsimage.bin',
         'fstest.txt'], stderr=subprocess.STDOUT)
    result = test_harness.run_program(environment='emulator',
                                      block_device='obj/fsimage.bin')
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #23
0
def run_csmith_test(_, target):
    # Find version of csmith
    result = subprocess.check_output(['csmith', '-v']).decode()
    got = VERSION_RE.search(result)
    if not got:
        raise test_harness.TestException(
            'Could not determine csmith version ' + result)

    version_str = got.group('version')
    csmith_include = '-I/usr/local/include/csmith-' + version_str

    for x in range(100):
        source_file = 'test%04d.c' % x
        print('running ' + source_file)

        # Disable packed structs because we don't support unaligned accesses.
        # Disable longlong to avoid incompatibilities between 32-bit Nyuzi
        # and 64-bit hosts.
        subprocess.check_call(['csmith', '-o', source_file, '--no-longlong',
                               '--no-packed-struct'])

        # Compile and run on host
        subprocess.check_call(
            ['cc', '-w', source_file, '-o', test_harness.WORK_DIR + '/a.out', csmith_include])
        result = subprocess.check_output(
            test_harness.WORK_DIR + '/a.out').decode()

        got = CHECKSUM_RE.search(result)
        if not got:
            raise test_harness.TestException('no checksum in host output')

        host_checksum = int(got.group('checksum'), 16)
        print('host checksum %08x' % host_checksum)

        # Compile and run under emulator
        test_harness.build_program([source_file], cflags=[csmith_include])
        result = test_harness.run_program(target)
        got = CHECKSUM_RE.search(result)
        if not got:
            raise test_harness.TestException('no checksum in host output')

        emulator_checksum = int(got.group('checksum'), 16)
        print('emulator checksum %08x' % emulator_checksum)
        if host_checksum != emulator_checksum:
            raise test_harness.TestException('checksum mismatch')

        print('PASS')
Beispiel #24
0
def filesystem(_):
    '''
    Filesystem tests. This creates a filesystem image with the test file fstest.txt
    in it, the compiles the program fs.c to perform operations on it. The program
    will print 'PASS' if it is successful.
    '''

    test_harness.build_program(['fs.c'])
    subprocess.check_output([
        test_harness.PROJECT_TOP + '/bin/mkfs', 'obj/fsimage.bin', 'fstest.txt'
    ],
                            stderr=subprocess.STDOUT)
    result = test_harness.run_program(environment='emulator',
                                      block_device='obj/fsimage.bin')
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #25
0
def filesystem(_, target):
    """Test the filesystem implementation in libos.

    This creates a filesystem image with the test file fstest.txt
    in it, the compiles the program fs.c to perform operations on it. The program
    will print 'PASS' if it is successful.
    """

    test_harness.build_program(['fs.c'])
    subprocess.check_output(
        [test_harness.BIN_DIR + 'mkfs', test_harness.WORK_DIR + '/fsimage.bin',
         'fstest.txt'], stderr=subprocess.STDOUT)
    result = test_harness.run_program(target=target,
                                      block_device=test_harness.WORK_DIR + '/fsimage.bin')
    if 'PASS' not in result or 'FAIL' in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #26
0
def run_csmith_test(_):
    # Find version of csmith
    result = subprocess.check_output(['csmith', '-v']).decode()
    got = VERSION_RE.search(result)
    if not got:
        raise test_harness.TestException(
            'Could not determine csmith version ' + result)

    version_str = got.group('version')
    csmith_include = '-I/usr/local/include/csmith-' + version_str

    for x in range(100):
        source_file = 'test%04x.c' % x
        print('running ' + source_file)

        subprocess.check_call(['csmith', '-o', source_file])

        # Compile and run on host
        subprocess.check_call(
            ['cc', '-w', source_file, '-o', 'obj/a.out', csmith_include])
        result = subprocess.check_output('obj/a.out').decode()

        got = CHECKSUM_RE.search(result)
        if not got:
            raise test_harness.TestException('no checksum in host output')

        host_checksum = int(got.group('checksum'), 16)
        print('host checksum %08x' % host_checksum)

        # Compile and run under emulator
        test_harness.build_program([source_file], cflags=[csmith_include])
        result = test_harness.run_program(environment='emulator')
        got = CHECKSUM_RE.search(result)
        if not got:
            raise test_harness.TestException('no checksum in host output')

        emulator_checksum = int(got.group('checksum'), 16)
        print('emulator checksum %08x' % emulator_checksum)
        if host_checksum != emulator_checksum:
            raise test_harness.TestException('checksum mismatch')

        print('PASS')
Beispiel #27
0
def filesystem(_, target):
    """Test the filesystem implementation in libos.

    This creates a filesystem image with the test file fstest.txt
    in it, the compiles the program fs.c to perform operations on it. The program
    will print 'PASS' if it is successful.
    """

    hex_file = test_harness.build_program(['fs.c'])
    subprocess.check_output([
        os.path.join(test_harness.TOOL_BIN_DIR, 'mkfs'), FS_IMAGE_PATH,
        'fstest.txt'
    ],
                            stderr=subprocess.STDOUT)
    result = test_harness.run_program(hex_file,
                                      target,
                                      block_device=FS_IMAGE_PATH)
    if 'PASS' not in result or 'FAIL' in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #28
0
def dinvalidate(_, target):
    test_harness.build_program(['dinvalidate.S'])
    result = test_harness.run_program(target=target,
                                      dump_file=MEM_DUMP_FILE,
                                      dump_base=0x2000,
                                      dump_length=4,
                                      flush_l2=True,
                                      trace=True)

    # 1. Check that the proper value was read into s2
    if '02 deadbeef' not in result:
        raise test_harness.TestException('incorrect value was written back ' +
                                         result)

    # 2. Read the memory dump to ensure the proper value is flushed from the
    # L2 cache
    with open(MEM_DUMP_FILE, 'rb') as memfile:
        num_val, = struct.unpack('<L', memfile.read(4))
        if num_val != 0xdeadbeef:
            raise test_harness.TestException(
                'memory contents were incorrect: ' + hex(num_val))
Beispiel #29
0
def dinvalidate(_):
    test_harness.build_program(['dinvalidate.S'])
    result = test_harness.run_program(
        environment='verilator',
        dump_file='obj/vmem.bin',
        dump_base=0x2000,
        dump_length=4,
        flush_l2=True,
        trace=True)

    # 1. Check that the proper value was read into s2
    if '02 deadbeef' not in result:
        raise test_harness.TestException(
            'incorrect value was written back ' + result)

    # 2. Read the memory dump to ensure the proper value is flushed from the
    # L2 cache
    with open('obj/vmem.bin', 'rb') as memfile:
        num_val, = struct.unpack('<L', memfile.read(4))
        if num_val != 0xdeadbeef:
            raise test_harness.TestException(
                'memory contents were incorrect: ' + hex(num_val))
Beispiel #30
0
def dinvalidate(_, target):
    hex_file = test_harness.build_program(['dinvalidate.S'])
    result = test_harness.run_program(
        hex_file,
        target,
        dump_file=MEM_DUMP_FILE,
        dump_base=0x2000,
        dump_length=4,
        flush_l2=True,
        trace=True)

    # 1. Check that the proper value was read into s2
    if '02 deadbeef' not in result:
        raise test_harness.TestException(
            'incorrect value was written back ' + result)

    # 2. Read the memory dump to ensure the proper value is flushed from the
    # L2 cache
    with open(MEM_DUMP_FILE, 'rb') as memfile:
        num_val, = struct.unpack('<L', memfile.read(4))
        if num_val != 0xdeadbeef:
            raise test_harness.TestException(
                'memory contents were incorrect: 0x{:x}'.format(num_val))
Beispiel #31
0
def verilator_timeout(_):
    test_harness.build_program(['timeout.c'])
    test_harness.run_program(environment='verilator', timeout=3)
Beispiel #32
0
def verilator_timeout(_):
    test_harness.build_program(['timeout.c'])
    test_harness.run_program(environment='verilator', timeout=3)
Beispiel #33
0
def timeout(_, target):
    hex_file = test_harness.build_program(['timeout.c'])
    test_harness.run_program(hex_file, target, timeout=3)
Beispiel #34
0
def run_emulator_test(source_file):
    test_harness.build_program([source_file])
    result = test_harness.run_program(environment='emulator')
    test_harness.check_result(source_file, result)
Beispiel #35
0
def perf_counters(_):
    test_harness.build_program(['perf_counters.c'])
    result = test_harness.run_program(environment='verilator')
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #36
0
def timeout(_, target):
    test_harness.build_program(['timeout.c'])
    test_harness.run_program(target=target, timeout=3)
Beispiel #37
0
def multicore(_):
    test_harness.build_program(['multicore.c'])
    result = test_harness.run_program(environment='verilator')
    if '012345678910111213141516171819202122232425262728293031' not in result.replace('\n', ''):
        raise test_harness.TestException('Output mismatch:\n' + result)
Beispiel #38
0
def dflush_wait(_):
    test_harness.build_program(['dflush_wait.S'])
    output = test_harness.run_program(environment='verilator')
    if 'PASS' not in output:
        raise test_harness.TestException('Test did not signal pass: ' + output)
Beispiel #39
0
def run_test(source_file, target):
    test_harness.build_program([source_file])
    result = test_harness.run_program(target)
    test_harness.check_result(source_file, result)
Beispiel #40
0
def ps2(_, target):
    hex_file = test_harness.build_program(['ps2.c'])
    result = test_harness.run_program(hex_file, target)
    if 'PASS' not in result:
        raise test_harness.TestException(
            'program did not indicate pass\n' + result)
Beispiel #41
0
def uart(_):
    test_harness.build_program(['uart.c'])
    result = test_harness.run_program(environment='verilator')
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test did not indicate pass\n' + result)
Beispiel #42
0
def iinvalidate(_):
    test_harness.build_program(['iinvalidate.S'])
    output = test_harness.run_program(environment='verilator')
    if 'PASS' not in output:
        raise test_harness.TestException('Test did not signal pass: ' + output)
Beispiel #43
0
def uart(_, target):
    test_harness.build_program(['uart.c'])
    result = test_harness.run_program(target)
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test did not indicate pass\n' + result)
Beispiel #44
0
def multicore(_, target):
    hex_file = test_harness.build_program(['multicore.S'])
    result = test_harness.run_program(hex_file, target)
    if 'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`' not in result:
        raise test_harness.TestException('Output mismatch:\n' + result)
Beispiel #45
0
def dflush_wait(_, target):
    test_harness.build_program(['dflush_wait.S'])
    output = test_harness.run_program(target)
    if 'PASS' not in output:
        raise test_harness.TestException('Test did not signal pass: ' + output)
Beispiel #46
0
def uart_hw_test(*unused):
    hex_file = test_harness.build_program(['uart_hw_test.c'])
    result = test_harness.run_program(hex_file, 'verilator')
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test did not indicate pass\n' + result)
Beispiel #47
0
def iinvalidate(_):
    test_harness.build_program(['iinvalidate.S'])
    output = test_harness.run_program(environment='verilator')
    if 'PASS' not in output:
        raise test_harness.TestException('Test did not signal pass: ' + output)
Beispiel #48
0
def run_test(source_file, target):
    test_harness.build_program([source_file])
    result = test_harness.run_program(target)
    test_harness.check_result(source_file, result)
Beispiel #49
0
def uart_hw_test(*unused):
    test_harness.build_program(['uart_hw_test.c'])
    result = test_harness.run_program(target='verilator')
    if 'PASS' not in result:
        raise test_harness.TestException('test did not indicate pass\n' +
                                         result)
Beispiel #50
0
def timeout(_, target):
    hex_file = test_harness.build_program(['timeout.c'])
    test_harness.run_program(hex_file, target, timeout=3)
Beispiel #51
0
def perf_counters(_, target):
    test_harness.build_program(['perf_counters.c'])
    result = test_harness.run_program(target)
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #52
0
def iinvalidate(_, target):
    hex_file = test_harness.build_program(['iinvalidate.S'])
    output = test_harness.run_program(hex_file, target)
    if 'PASS' not in output:
        raise test_harness.TestException('Test did not signal pass: ' + output)
Beispiel #53
0
def ps2(_, target):
    test_harness.build_program(['ps2.c'])
    result = test_harness.run_program(target)
    if 'PASS' not in result:
        raise test_harness.TestException('program did not indicate pass\n' +
                                         result)
Beispiel #54
0
def uart(_):
    test_harness.build_program(['uart.c'])
    result = test_harness.run_program(environment='verilator')
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test did not indicate pass\n' + result)
Beispiel #55
0
def run_emulator_test(source_file):
    test_harness.build_program([source_file])
    result = test_harness.run_program(environment='emulator')
    test_harness.check_result(source_file, result)
Beispiel #56
0
def perf_counters(_):
    test_harness.build_program(['perf_counters.c'])
    result = test_harness.run_program(environment='verilator')
    if 'PASS' not in result:
        raise test_harness.TestException(
            'test program did not indicate pass\n' + result)
Beispiel #57
0
def dflush_wait(_, target):
    hex_file = test_harness.build_program(['dflush_wait.S'])
    output = test_harness.run_program(hex_file, target)
    if 'PASS' not in output:
        raise test_harness.TestException('Test did not signal pass: ' + output)
Beispiel #58
0
def iinvalidate(_, target):
    test_harness.build_program(['iinvalidate.S'])
    output = test_harness.run_program(target)
    if 'PASS' not in output:
        raise test_harness.TestException('Test did not signal pass: ' + output)