Line data Source code
1 : #include "test.h"
2 :
3 1 : TEST(print_info) {
4 : int st, fd[2];
5 : pid_t pid;
6 :
7 1 : pipe(fd);
8 1 : if ((pid = fork()) == 0) {
9 1 : DUP_ALL_OUTPUTS(fd);
10 1 : m_info("Test");
11 1 : exit(0);
12 : } else {
13 1 : WAIT_AND_CLOSE(pid, st, fd);
14 : }
15 1 : return TEST_SUCCESS;
16 : }
17 :
18 1 : TEST(print_warning) {
19 : int st, fd[2];
20 : pid_t pid;
21 :
22 1 : pipe(fd);
23 1 : if ((pid = fork()) == 0) {
24 1 : DUP_ALL_OUTPUTS(fd);
25 1 : m_warning("Test");
26 1 : exit(0);
27 : } else {
28 1 : WAIT_AND_CLOSE(pid, st, fd);
29 : }
30 1 : return TEST_SUCCESS;
31 : }
32 :
33 1 : TEST(print_error) {
34 : int st, fd[2];
35 : pid_t pid;
36 :
37 1 : pipe(fd);
38 1 : if ((pid = fork()) == 0) {
39 1 : DUP_ALL_OUTPUTS(fd);
40 1 : m_error("Test");
41 1 : exit(0);
42 : } else {
43 1 : WAIT_AND_CLOSE(pid, st, fd);
44 : }
45 1 : return TEST_SUCCESS;
46 : }
47 :
48 1 : TEST(print_panic) {
49 : int st, fd[2];
50 : pid_t pid;
51 :
52 1 : pipe(fd);
53 1 : if ((pid = fork()) == 0) {
54 1 : DUP_ALL_OUTPUTS(fd);
55 1 : m_panic("Test");
56 0 : exit(0);
57 : } else {
58 1 : WAIT_AND_CLOSE(pid, st, fd);
59 : }
60 1 : return TEST_SUCCESS;
61 : }
62 :
63 1 : void register_print_tests(void) {
64 1 : reg_test("mprint", print_info);
65 1 : reg_test("mprint", print_warning);
66 1 : reg_test("mprint", print_error);
67 1 : reg_test("mprint", print_panic);
68 1 : }
|