Line data Source code
1 : /* Inception BWAAAAAAH */
2 :
3 : #include "test.h"
4 :
5 1 : TEST(test_all_empty) {
6 : int st, fd[2];
7 : pid_t pid;
8 :
9 1 : pipe(fd);
10 1 : if ((pid = fork()) == 0) {
11 1 : DUP_ALL_OUTPUTS(fd);
12 1 : test_free();
13 1 : test_all();
14 1 : exit(0);
15 : } else {
16 1 : WAIT_AND_CLOSE(pid, st, fd);
17 : }
18 1 : return TEST_SUCCESS;
19 :
20 : }
21 :
22 1 : TEST(test_group_unknown) {
23 : int st, fd[2];
24 : pid_t pid;
25 :
26 1 : pipe(fd);
27 1 : if ((pid = fork()) == 0) {
28 1 : DUP_ALL_OUTPUTS(fd);
29 1 : test_group("Unknown");
30 1 : exit(0);
31 : } else {
32 1 : WAIT_AND_CLOSE(pid, st, fd);
33 : }
34 1 : return TEST_SUCCESS;
35 : }
36 :
37 1 : TEST(test_result) {
38 : int st, fd[2];
39 : pid_t pid;
40 :
41 1 : pipe(fd);
42 1 : if ((pid = fork()) == 0) {
43 1 : DUP_ALL_OUTPUTS(fd);
44 1 : print_result("Test", 10, 0);
45 1 : print_result("Test", 9, 1);
46 1 : print_result("Test", 0, 10);
47 1 : exit(0);
48 : } else {
49 1 : WAIT_AND_CLOSE(pid, st, fd);
50 : }
51 1 : return TEST_SUCCESS;
52 : }
53 :
54 1 : TEST(test_false) {
55 1 : TEST_ASSERT(false, "Nope.");
56 : return TEST_SUCCESS;
57 : }
58 :
59 1 : TEST(test_group_fail) {
60 : int st, fd[2];
61 : pid_t pid;
62 :
63 1 : pipe(fd);
64 1 : if ((pid = fork()) == 0) {
65 1 : DUP_ALL_OUTPUTS(fd);
66 1 : reg_test("group_fail", test_false);
67 1 : test_all();
68 1 : test_free();
69 1 : exit(0);
70 : } else {
71 1 : WAIT_AND_CLOSE(pid, st, fd);
72 : }
73 1 : return TEST_SUCCESS;
74 : }
75 :
76 1 : void register_tests_tests(void) {
77 1 : test_test_all_empty();
78 1 : test_test_group_unknown();
79 1 : test_test_result();
80 1 : test_test_group_fail();
81 1 : }
|