예제 #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')
예제 #2
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]))
예제 #3
0
 def test_permutation_detection(self):
     self.assertTrue(is_permutation_of('1 2 3', [1, 2, 3])[0])
     self.assertTrue(is_permutation_of('3 1 2', [1, 2, 3])[0])
     self.assertTrue(is_permutation_of('1 6 7', [6, 1, 7])[0])
     self.assertFalse(is_permutation_of('1', [1, 2])[0])
     self.assertFalse(is_permutation_of('1 2 3', [1, 2])[0])
     self.assertFalse(is_permutation_of('1 2 4', [1, 2, 3])[0])
     self.assertTrue(is_permutation_of('1 2 3\n', [1, 2, 3])[0], 'should ignore newlines')
예제 #4
0
 def test_permutation_detection(self):
     self.assertTrue(is_permutation_of('123', [1, 2, 3]))
     self.assertTrue(is_permutation_of('312', [1, 2, 3]))
     self.assertTrue(is_permutation_of('167', [6, 1, 7]))
     self.assertFalse(is_permutation_of('1', [1, 2])[0])
     self.assertFalse(is_permutation_of('123', [1, 2])[0])
     self.assertFalse(is_permutation_of('124', [1, 2, 3])[0])