Browse code
refactor testing
Showing 2 changed files
... | ... |
@@ -19,6 +19,14 @@ void dc_openlog(const char *ident, int logopt, int facility) { |
19 | 19 |
} |
20 | 20 |
|
21 | 21 |
|
22 |
+#define check(assertion, msg) \ |
|
23 |
+ if (!(assertion)) { \ |
|
24 |
+ fprintf(stderr, "assertion failed %s\n", msg); \ |
|
25 |
+ return 0; \ |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+#define succeed() return 1 |
|
29 |
+ |
|
22 | 30 |
int test_log_success() { |
23 | 31 |
// given |
24 | 32 |
opened_facility = -1000; |
... | ... |
@@ -28,7 +36,10 @@ int test_log_success() { |
28 | 36 |
log_success(); |
29 | 37 |
|
30 | 38 |
// then |
31 |
- return opened_facility == LOG_AUTHPRIV && !strcmp(opened_program_name, "pam_dual_control"); |
|
39 |
+ check(opened_facility == LOG_AUTHPRIV, "facility should be authpriv"); |
|
40 |
+ check(!strcmp(opened_program_name, "pam_dual_control"), "incorrect program name"); |
|
41 |
+ |
|
42 |
+ succeed(); |
|
32 | 43 |
} |
33 | 44 |
|
34 | 45 |
|