def check_bitwise_and_or_not() -> List[Check]: 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) return list(flatmap(check_instruction, [AND_INSTRUCTION, OR_INSTRUCTION, NOT_INSTRUCTION])) + \ check_mipster_execution('precedence.c', 42, 'bitwise and, or & not ' + ' operators respect the precedence of the C operators: &,|,~') + \ check_mipster_execution('precedence2.c', 42, 'bitwise and, or & not ' + ' operators respect the precedence of the C operators: +,-')
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_instruction(direction: str, instruction: Tuple[str, Any]) -> List[Check]: literal_file = instruction[0] + '-with-literals.c' variable_file = instruction[0] + '-with-variables.c' return check_riscv_instruction(instruction, literal_file) + \ check_riscv_instruction(instruction, variable_file) + \ check_mipster_execution(literal_file, 42, 'bitwise-' + direction + '-shift operator calculates the right result for literals when executed with MIPSTER') + \ check_mipster_execution(variable_file, 42, 'bitwise-' + direction + '-shift operator calculates the right result for variables when executed with MIPSTER')
def check_fork_wait_exit() -> List[Check]: return 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_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_threads() -> List[Check]: return check_execution('./selfie -c <assignment>syscalls.c -m 128', 'creates a thread, where the parent can join the thread with MIPSTER', success_criteria=70) + \ check_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) + \ check_mipster_execution('shared-data.c', 42, 'data section is shared for threads on MIPSTER') + \ check_hypster_execution('shared-data.c', 42, 'data section is shared for threads on HYPSTER') + \ check_mipster_execution('shared-heap.c', 42, 'heap data is shared for threads on MIPSTER') + \ check_hypster_execution('shared-heap.c', 42, 'heap data is shared for threads on HYPSTER')
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_threads() -> List[Check]: return check_execution('./selfie -c <assignment>syscalls.c -m 128', 'creates a thread, where the parent can join the thread with MIPSTER', success_criteria=70) + \ check_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) + \ check_mipster_execution('shared-data.c', 42, 'data section is shared for threads on MIPSTER') + \ check_hypster_execution('shared-data.c', 42, 'data section is shared for threads on HYPSTER') + \ check_mipster_execution('shared-heap.c', 42, 'heap data is shared for threads on MIPSTER') + \ check_hypster_execution('shared-heap.c', 42, 'heap data is shared for threads on HYPSTER') + \ check_mipster_execution('sum-integer-dekker.c', 210, 'two threads correctly calculate the sum from 1 to 20 with Dekker\'s algorithm on MIPSTER') +\ check_hypster_execution('sum-integer-dekker.c', 210, 'two threads correctly calculate the sum from 1 to 20 with Dekker\'s algorithm on HYPSTER')
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_bitwise_shift_execution() -> List[Check]: def check_instruction(direction: str, instruction: Tuple[str, Any]) -> List[Check]: literal_file = instruction[0] + '-with-literals.c' variable_file = instruction[0] + '-with-variables.c' return check_riscv_instruction(instruction, literal_file) + \ check_riscv_instruction(instruction, variable_file) + \ check_mipster_execution(literal_file, 42, 'bitwise-' + direction + '-shift operator calculates the right result for literals when executed with MIPSTER') + \ check_mipster_execution(variable_file, 42, 'bitwise-' + direction + '-shift operator calculates the right result for variables when executed with MIPSTER') instructions = [('right', SRL_INSTRUCTION), ('left', SLL_INSTRUCTION)] return list(flatmap(lambda i: check_instruction(i[0], i[1]), instructions)) + \ check_mipster_execution('precedence.c', 42, 'bitwise shift operators respect the precedence of the C operators: <<, >>')
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')