コード例 #1
0
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]))
コード例 #2
0
    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')
コード例 #3
0
    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)