|
@@ -6,7 +6,7 @@
|
6
|
6
|
|
7
|
7
|
pyfcgi_conf_logger_t *conf = &PyFCGI_conf.logs;
|
8
|
8
|
|
9
|
|
-char tmpdir[] = "./tmp_PyFCGI_checksXXXXXX";
|
|
9
|
+char tmpdir[] = "/tmp/tmp_PyFCGI_checksXXXXXX";
|
10
|
10
|
|
11
|
11
|
/*
|
12
|
12
|
TC logger init
|
|
@@ -58,11 +58,16 @@ END_TEST
|
58
|
58
|
START_TEST(test_logger_add)
|
59
|
59
|
{
|
60
|
60
|
char tmplog[128];
|
61
|
|
- char logfmt[] = "{level} {ident} {msg}";
|
|
61
|
+ char logfmt[] = "{level} {ident} {pid} {msg}";
|
|
62
|
+ char expected[] = " Alert 0000 Hello world ! foobar 04\n";
|
62
|
63
|
int ret;
|
63
|
64
|
pyfcgi_conf_logger_t *conf;
|
64
|
65
|
pyfcgi_logger_t *logger;
|
65
|
66
|
pyfcgi_logger_format_t *fmt;
|
|
67
|
+ char buf[128];
|
|
68
|
+ size_t sz;
|
|
69
|
+
|
|
70
|
+ memset(buf, 0, 128);
|
66
|
71
|
|
67
|
72
|
pyfcgi_logger_init();
|
68
|
73
|
|
|
@@ -77,11 +82,17 @@ START_TEST(test_logger_add)
|
77
|
82
|
fmt = &(conf->formats[logger->fmt_id]);
|
78
|
83
|
ck_assert_str_eq(fmt->fmt, logfmt);
|
79
|
84
|
|
80
|
|
- pyfcgi_log(LOG_ALERT, "Hello world ! %s\n", tmplog);
|
|
85
|
+ pyfcgi_log(LOG_ALERT, "Hello world ! %s %02d", "foobar", 4);
|
|
86
|
+ //pyfcgi_log(LOG_DEBUG, "Hello world 2 %s\n", tmplog);
|
81
|
87
|
|
82
|
88
|
pyfcgi_logger_stop();
|
83
|
89
|
|
84
|
|
- //unlink(tmplog);
|
|
90
|
+ ret = open(tmplog, O_RDONLY);
|
|
91
|
+ sz = read(ret, buf, 128);
|
|
92
|
+
|
|
93
|
+ ck_assert_str_eq(expected, buf);
|
|
94
|
+
|
|
95
|
+ unlink(tmplog);
|
85
|
96
|
|
86
|
97
|
}
|
87
|
98
|
END_TEST
|
|
@@ -582,7 +593,7 @@ int main(void)
|
582
|
593
|
nfailed = srunner_ntests_failed(sr);
|
583
|
594
|
srunner_free(sr);
|
584
|
595
|
|
585
|
|
- //rmdir(tmpdir);
|
|
596
|
+ rmdir(tmpdir);
|
586
|
597
|
|
587
|
598
|
return (!nfailed)?EXIT_SUCCESS:EXIT_FAILURE;
|
588
|
599
|
}
|