def check_multidimensional_array() -> List[Check]: return check_compilable('multidimensional.c', 'multidimensional array declarations do compile') + \ check_mipster_execution('multidimensional.c', 42, 'multidimensional arrays assignments are implemented with the right semantics') + \ check_compilable('access-order.c', 'access to start-address of multidimensional is possible') + \ check_mipster_execution('access-order.c', 0, 'access to multidimensional arrays is implemented in row-major order')
def check_struct_declaration() -> List[Check]: return check_compilable('declaration.c', 'empty struct declarations compiled') + \ check_compilable('definition.c', 'struct definition with global and local scope compiled') + \ check_compilable('member-declaration.c', 'struct declaration with trivial members compiled') + \ check_compilable('nested-declaration.c', 'struct declaration with struct members compiled')
def check_direction(direction: str) -> List[Check]: literal_file = direction + '-shift-with-literals.c' variable_file = direction + '-shift-with-variables.c' invalid_file = 'invalid-' + direction + '-shift.c' return check_compilable(literal_file, 'bitwise-' + direction + '-shift operator with literals does compile') + \ check_compilable(variable_file, 'bitwise-' + direction + '-shift operator with variables does compile') + \ check_compilable(invalid_file, 'bitwise-' + direction + '-shift operator with invalid syntax does not compile', should_succeed=False)
def check_hex_literal() -> List[Check]: return check_compilable('all-digit-characters.c', 'hex integer literal with all characters compiled') + \ check_mipster_execution('all-digit-characters.c', 42, 'hex integer literal with all characters has the right value') + \ check_compilable('max-value.c', 'maximum hex integer literal compiled') + \ check_mipster_execution('max-value.c', 42, 'maximum hex integer literal has the right value') + \ check_compilable('min-value.c', 'minimum hex integer literal compiled') + \ check_mipster_execution('min-value.c', 42, 'minimum hex integer literal has the right value')
def check_array() -> List[Check]: return check_compilable('global-declaration.c', 'array declaration do compile') + \ check_compilable('assignment.c', 'assignments on arrays do compile') + \ check_compilable('invalid-assignment.c', 'invalid assignments to an array do not compile', should_succeed=False) + \ check_compilable('call-by-reference.c', 'arrays in the function signature do compile') + \ check_mipster_execution('assignment.c', 42, 'arrays assignments are implemented with the right semantics') + \ check_mipster_execution('call-by-reference.c', 42, 'array assignments in functions are implemented with the right semantics')
def check_struct_execution() -> List[Check]: return check_compilable('initialization.c', 'empty struct with initialization compiled') + \ check_compilable('member-initialization.c', 'initialization of trivial struct members compiled') + \ check_mipster_execution('member-initialization.c', 42, 'read and write operations of trivial struct member works when executed with MIPSTER') + \ check_compilable('nested-initialization.c', 'struct initialization with struct members compiled') + \ check_mipster_execution('nested-initialization.c', 42, 'read and write operations of nested struct member works when executed with MIPSTER') + \ check_compilable('as-parameter.c', 'struct as function parameter compiled') + \ check_mipster_execution('as-parameter.c', 42, 'read and write operations of structs as parameter work when executed with MIPSTER')
def check_for_loop() -> List[Check]: return check_compilable('missing-assignment.c', 'for loop with missing assignment do not compile', should_succeed=False) + \ check_compilable('single-statement.c', 'for loop with one statement do compile') + \ check_compilable('multiple-statements.c', 'for loop with multiple statements do compile') + \ check_compilable('nested.c', 'nested for loops do compile') + \ check_mipster_execution('single-statement.c', 42, 'for loop with one statement are implement with the right semantics') + \ check_mipster_execution('multiple-statements.c', 42, 'for loop with multiple statements are implemented with the right semantics') + \ check_mipster_execution('nested.c', 42, 'nested for loops are implemented with the right semantics')
def check_instruction(instruction) -> List[Check]: operation = instruction[0] literal_file = operation + '-with-literals.c' variable_file = operation + '-with-variables.c' invalid_file = 'invalid-' + operation + '.c' return check_compilable(literal_file, operation + ' operator with literals does compile') + \ check_compilable(variable_file, operation + ' operator with variables does compile') + \ check_compilable(invalid_file, operation + ' operator with invalid syntax does not compile', should_succeed=False) + \ check_mipster_execution(literal_file, 42, operation + ' operator calculates the right result for literals when executed with MIPSTER') + \ check_mipster_execution(variable_file, 42, operation + ' operator calculates the right result for variables when executed with MIPSTER') + \ check_riscv_instruction(instruction, literal_file) + \ check_riscv_instruction(instruction, variable_file)
def check_fork_and_wait() -> List[Check]: return check_compilable('parallel-print.c', 'fork and wait compiled') + \ check_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') + \ check_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')
def check_fork_wait_exit() -> List[Check]: return check_compilable('sum-exit-code.c', 'fork and wait compiled') + \ check_mipster_execution('sum-exit-code.c', 28, 'exit code is returned as status parameter from wait with MIPSTER') + \ check_hypster_execution('sum-exit-code.c', 28, 'exit code is returned as status parameter from wait with HYPSTER') + \ check_mipster_execution('unmapped-page-wait.c', 42, 'wait system call maps page to unmapped virtual address') + \ check_mipster_execution('invalid-address.c', 42, 'wait system call correctly handles invalid addresses') + \ check_mipster_execution('null-ptr.c', 42, 'wait system call returns PID when NULL is passed');
def check_fork_wait_exit() -> List[Check]: return check_compilable('sum-exit-code.c', 'fork and wait compiled') + \ check_mipster_execution('sum-exit-code.c', 28, 'exit code is returned as status parameter from wait with MIPSTER') + \ check_hypster_execution('sum-exit-code.c', 28, 'exit code is returned as status parameter from wait with HYPSTER')