git.fiddlerwoaroof.com
Browse code

additional log test coverage

Greg Wiley authored on 05/04/2017 22:14:46
Showing 2 changed files
1 1
Binary files a/logging_test and b/logging_test differ
... ...
@@ -1,8 +1,10 @@
1 1
 #include <stdio.h>
2
+#include <string.h>
2 3
 
3 4
 #include "dc_syslog.h"
4 5
 #include "logging.h"
5 6
 
7
+
6 8
 void dc_syslog(int priority, const char *message, ...) {
7 9
 }
8 10
 
... ...
@@ -10,25 +12,28 @@ void dc_closelog(void) {
10 12
 }
11 13
 
12 14
 int opened_facility = -1000;
13
-void dc_openlog(const char * ident, int logopt, int facility) {
15
+const char *opened_program_name = "";
16
+void dc_openlog(const char *ident, int logopt, int facility) {
14 17
     opened_facility = facility;
18
+    opened_program_name = ident;
15 19
 }
16 20
 
17 21
 
18
-int test_log_success_facility_authpriv() {
22
+int test_log_success() {
19 23
     // given
20 24
     opened_facility = -1000;
25
+    opened_program_name = "";
21 26
 
22 27
     // when
23 28
     log_success();
24 29
 
25 30
     // then
26
-    return opened_facility == LOG_AUTHPRIV;
31
+    return opened_facility == LOG_AUTHPRIV && !strcmp(opened_program_name, "pam_dual_control");
27 32
 }
28 33
 
29 34
 
30 35
 int main(int numargs, char **args) {
31
-    if(test_log_success_facility_authpriv()) {
36
+    if(test_log_success()) {
32 37
         fprintf(stderr, "Success!\n");
33 38
         return 0;
34 39
     } else {