Beispiel #1
0
def test_fork_and_wait():
    test_compilable('parallel-print.c', 'fork and wait compiled')
    test_mipster_execution('parallel-print.c',
                   lambda code, out: is_permutation_of(out, [0, 1, 2, 3, 4, 5, 6, 7]),
                   'fork creates a child process, where the parent can wait for the child process with MIPSTER')
    test_hypster_execution('parallel-print.c',
                   lambda code, out: is_permutation_of(out, [0, 1, 2, 3, 4, 5, 6, 7]),
                   'fork creates a child process, where the parent can wait for the child process with HYPSTER')
Beispiel #2
0
def test_multidimensional_array():
    test_compilable('multidimensional.c',
                    'multidimensional array declarations do compile')
    test_mipster_execution('multidimensional.c', 42,
                           'multidimensional arrays assignments are implemented with the right semantics')
    test_compilable('access-order.c',
                    'access to start-address of multidimensional is possible')
    test_mipster_execution('access-order.c', 0,
                           'access to multidimensional arrays is implemented in row-major order')
Beispiel #3
0
def test_thread():
    test_execution('./selfie -c <assignment>syscalls.c -m 128',
                   'creates a thread, where the parent can join the thread with MIPSTER', success_criteria=70)
    test_execution('./selfie -c selfie.c -m 128 -c <assignment>syscalls.c -y 64',
                   'creates a thread, where the parent can join the thread with HYPSTER', success_criteria=70)
    test_mipster_execution('shared-data.c', 42,
                           'data section is shared for threads on MIPSTER')
    test_hypster_execution('shared-data.c', 42,
                           'data section is shared for threads on HYPSTER')
    test_mipster_execution('shared-heap.c', 42,
                           'heap data is shared for threads on MIPSTER')
    test_hypster_execution('shared-heap.c', 42,
                           'heap data is shared for threads on HYPSTER')
Beispiel #4
0
def test_array():
    test_compilable('global-declaration.c',
                    'array declaration do compile')
    test_compilable('assignment.c',
                    'assignments on arrays do compile')
    test_compilable('invalid-assignment.c',
                    'invalid assignments to an array do not compile', should_succeed=False)
    test_compilable('call-by-reference.c',
                    'arrays in the function signature do compile')
    test_mipster_execution('assignment.c', 42,
                           'arrays assignments are implemented with the right semantics')
    test_mipster_execution('call-by-reference.c', 42,
                           'array assignments in functions are implemented with the right semantics')
Beispiel #5
0
def test_bitwise_and_or_not():
    for instruction in [AND_INSTRUCTION, OR_INSTRUCTION, NOT_INSTRUCTION]:
        operation = instruction[0]

        literal_file = operation + '-with-literals.c'
        variable_file = operation + '-with-variables.c'
        invalid_file = 'invalid-' + operation + '.c'

        test_compilable(literal_file,
                        operation + ' operator with literals does compile')
        test_compilable(variable_file,
                        operation + ' operator with variables does compile')
        test_compilable(invalid_file,
                        operation + ' operator with invalid syntax does not compile', should_succeed=False)
        test_mipster_execution(literal_file, 42,
                               operation + ' operator calculates the right result for literals when executed with MIPSTER')
        test_mipster_execution(variable_file, 42,
                               operation + ' operator calculates the right result for variables when executed with MIPSTER')
        test_riscv_instruction(instruction, literal_file)
        test_riscv_instruction(instruction, variable_file)

    test_mipster_execution('precedence.c', 42,
                           'bitwise and, or & not ' + ' operators respect the precedence of the C operators: &,|,~')
    test_mipster_execution('precedence2.c', 42,
                           'bitwise and, or & not ' + ' operators respect the precedence of the C operators: +,-')
Beispiel #6
0
def test_hex_literal():
    test_compilable('all-digit-characters.c',
                    'hex integer literal with all characters compiled')
    test_mipster_execution('all-digit-characters.c', 42,
                           'hex integer literal with all characters has the right value')
    test_compilable('max-value.c',
                    'maximum hex integer literal compiled')
    test_mipster_execution('max-value.c', 42,
                           'maximum hex integer literal has the right value')
    test_compilable('min-value.c',
                    'minimum hex integer literal compiled')
    test_mipster_execution('min-value.c', 42,
                           'minimum hex integer literal has the right value')
Beispiel #7
0
def test_bitwise_shift_execution():
    for direction, instruction in [('right', SRL_INSTRUCTION), ('left', SLL_INSTRUCTION)]:

        literal_file = instruction[0] + '-with-literals.c'
        variable_file = instruction[0] + '-with-variables.c'

        test_riscv_instruction(instruction, literal_file)
        test_riscv_instruction(instruction, variable_file)
        test_mipster_execution(literal_file, 42,
                               'bitwise-' + direction + '-shift operator calculates the right result for literals when executed with MIPSTER')
        test_mipster_execution(variable_file, 42,
                               'bitwise-' + direction + '-shift operator calculates the right result for variables when executed with MIPSTER')

    test_mipster_execution('precedence.c', 42,
                           'bitwise shift operators respect the precedence of the C operators: <<, >>')
Beispiel #8
0
def test_struct_execution():
    test_compilable('initialization.c',
                    'empty struct with initialization compiled')
    test_compilable('member-initialization.c',
                    'initialization of trivial struct members compiled')
    test_mipster_execution('member-initialization.c', 42,
                           'read and write operations of trivial struct member works when executed with MIPSTER')
    test_compilable('nested-initialization.c',
                    'struct initialization with struct members compiled')
    test_mipster_execution('nested-initialization.c', 42,
                           'read and write operations of nested struct member works when executed with MIPSTER')
    test_compilable('as-parameter.c',
                    'struct as function parameter compiled')
    test_mipster_execution('as-parameter.c', 42,
                           'read and write operations of structs as parameter work when executed with MIPSTER')
Beispiel #9
0
def test_for_loop():
    test_compilable('missing-assignment.c',
                    'for loop with missing assignment do not compile', should_succeed=False)
    test_compilable('single-statement.c',
                    'for loop with one statement do compile')
    test_compilable('multiple-statements.c',
                    'for loop with multiple statements do compile')
    test_compilable('nested.c',
                    'nested for loops do compile')
    test_mipster_execution('single-statement.c', 42,
                           'for loop with one statement are implement with the right semantics')
    test_mipster_execution('multiple-statements.c', 42,
                           'for loop with multiple statements are implemented with the right semantics')
    test_mipster_execution('nested.c', 42,
                           'nested for loops are implemented with the right semantics')
Beispiel #10
0
def test_fork_wait_exit():
    test_compilable('sum-exit-code.c', 'fork and wait compiled')
    test_mipster_execution('sum-exit-code.c', 28,
                           'exit code is returned as status parameter from wait with MIPSTER')
    test_hypster_execution('sum-exit-code.c', 28,
                           'exit code is returned as status parameter from wait with HYPSTER')