def setUp(self): self.assignments = grader.assignments self.baseline_assignments = grader.baseline_assignments grader.baseline_assignments = [ # capture index in closure with python default value of lambda Assignment(a.name, a.lecture, a.category, a.description, lambda i=i: self.check_baseline_assignment_mock(i)) for i, a in enumerate(grader.baseline_assignments) ] grader.assignments = [ Assignment(a.name, a.lecture, a.category, a.description, self.check_assignment_mock) for a in grader.assignments ] self.count = 0
check_hypster_execution('shared-heap.c', 42, 'heap data is shared for threads on HYPSTER') def check_treiber_stack() -> List[Check]: return check_riscv_instruction(LR_INSTRUCTION, 'load-reserved.c') + \ check_riscv_instruction(SC_INSTRUCTION, 'store-conditional.c') + \ check_execution('./selfie -c treiber-stack.c <assignment>stack-push.c -m 128', 'all pushed elements are actually in the treiber-stack', success_criteria=lambda code, out: is_permutation_of(out, [0, 1, 2, 3, 4, 5, 6, 7])) + \ check_execution('./selfie -c treiber-stack.c <assignment>stack-pop.c -m 128', 'all treiber-stack elements can be popped ', success_criteria=lambda code, out: is_permutation_of(out, [0, 1, 2, 3, 4, 5, 6, 7])) baseline_assignment = Assignment('self-compile', 'General', '', '', check_self_compilation) assignments: Set[Assignment] = { baseline_assignment, Assignment( 'print-your-name', 'General', '', REPO_BLOB_BASE_URI + 'grader/compiler-assignments.md#assignment-print-your-name', check_print_your_name), Assignment( 'hex-literal', 'Compiler', 'hex-literal', REPO_BLOB_BASE_URI + 'grader/compiler-assignments.md#assignment-hex-literal', check_hex_literal), Assignment( 'bitwise-shift-compilation', 'Compiler', 'bitwise-shift', REPO_BLOB_BASE_URI + 'grader/compiler-assignments.md#assignment-bitwise-shift-compilation',
def check(a: Assignment): return list(map(execute_with_output, a.create_checks()))
check_hypster_execution('shared-heap.c', 42, 'heap data is shared for threads on HYPSTER') def check_treiber_stack() -> List[Check]: return check_riscv_instruction(LR_INSTRUCTION, 'load-reserved.c') + \ check_riscv_instruction(SC_INSTRUCTION, 'store-conditional.c') + \ check_execution('./selfie -c treiber-stack.c <assignment>stack-push.c -m 128', 'all pushed elements are actually in the treiber-stack', success_criteria=lambda code, out: is_permutation_of(out, [0, 1, 2, 3, 4, 5, 6, 7])) + \ check_execution('./selfie -c treiber-stack.c <assignment>stack-pop.c -m 128', 'all treiber-stack elements can be popped ', success_criteria=lambda code, out: is_permutation_of(out, [0, 1, 2, 3, 4, 5, 6, 7])) baseline_assignment = Assignment('self-compile', 'General', '', check_self_compilation) assignments: Set[Assignment] = { baseline_assignment, Assignment('print-name', 'General', '', check_print_name), Assignment('hex-literal', 'Compiler', 'hex-literal', check_hex_literal), Assignment('bitwise-shift-compilation', 'Compiler', 'bitwise-shift', check_bitwise_shift_compilation), Assignment('bitwise-shift-execution', 'Compiler', 'bitwise-shift', check_bitwise_shift_execution), Assignment('bitwise-and-or-not', 'Compiler', 'bitwise-logic', check_bitwise_and_or_not), Assignment('for-loop', 'Compiler', 'for-loop', check_for_loop), Assignment('array', 'Compiler', 'array', check_array), Assignment('array-multidimensional', 'Compiler', 'array', check_multidimensional_array),