]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: drop logging suspension
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 9 Mar 2021 11:34:41 +0000 (12:34 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 11 Mar 2021 10:47:31 +0000 (11:47 +0100)
Instead of selectively suspending logging by redirecting messages to
/dev/null, increase the default minimum log severity to FATAL. In the
debug mode, all messages are printed.

test/unit/ntp_auth.c
test/unit/ntp_core.c
test/unit/test.c
test/unit/test.h
test/unit/util.c

index 5be74370d5484c41660fa8224d3cb46308c9f02a..5c4b25558a469f1422aa006704f56ee6dbfb18b8 100644 (file)
@@ -141,11 +141,7 @@ test_unit(void)
     CNF_ParseLine(NULL, i + 1, conf[i]);
 
   LCL_Initialise();
-
-  TST_SuspendLogging();
   KEY_Initialise();
-  TST_ResumeLogging();
-
   NSD_Initialise();
   NNS_Initialise();
 
@@ -153,8 +149,6 @@ test_unit(void)
   nts_addr.port = 0;
 
   for (i = 0; i < 1000; i++) {
-    TST_SuspendLogging();
-
     key_id = INACTIVE_AUTHKEY;
 
     switch (i % 5) {
@@ -202,8 +196,6 @@ test_unit(void)
         assert(0);
     }
 
-    TST_ResumeLogging();
-
     DEBUG_LOG("iteration %d auth=%d key_id=%d", i, (int)mode, (int)key_id);
 
     prepare_packet(mode, &req, &req_info, 1);
@@ -218,7 +210,6 @@ test_unit(void)
         NAU_ChangeAddress(inst, &nts_addr.ip_addr);
 
       if (inst->mode == NTP_AUTH_NTS) {
-        TST_SuspendLogging();
         for (j = random() % 5; j > 0; j--)
 #ifdef FEAT_NTS
           TEST_CHECK(!NAU_PrepareRequestAuth(inst));
@@ -226,7 +217,6 @@ test_unit(void)
           TEST_CHECK(NAU_PrepareRequestAuth(inst));
 #endif
         TEST_CHECK(!NAU_GenerateRequestAuth(inst, &req, &req_info));
-        TST_ResumeLogging();
       } else if (can_auth_req) {
         TEST_CHECK(NAU_PrepareRequestAuth(inst));
         TEST_CHECK(NAU_GenerateRequestAuth(inst, &req, &req_info));
index b5c148a319da75f4ae3546af927253b7a8da59ee..9aac5d632a7b28b0a235c7fdf0c36689abf52a18 100644 (file)
@@ -360,10 +360,7 @@ test_unit(void)
   NIO_Initialise();
   NCR_Initialise();
   REF_Initialise();
-
-  TST_SuspendLogging();
   KEY_Initialise();
-  TST_ResumeLogging();
 
   CNF_SetupAccessRestrictions();
 
index 482d83f551fb401515464050ba5e90a0946b7145..0f5638d8ed09f5f541780dac6090aa7ed319d1c5 100644 (file)
@@ -43,6 +43,7 @@ TST_Skip(int line)
 int
 main(int argc, char **argv)
 {
+  LOG_Severity log_severity;
   char *test_name, *s;
   int i, seed = 0;
   struct timeval tv;
@@ -55,9 +56,11 @@ main(int argc, char **argv)
   if (s)
     test_name = s + 1;
 
+  log_severity = LOGS_FATAL;
+
   for (i = 1; i < argc; i++) {
     if (!strcmp(argv[i], "-d")) {
-      LOG_SetMinSeverity(LOGS_DEBUG);
+      log_severity = LOGS_DEBUG;
     } else if (!strcmp(argv[i], "-s") && i + 1 < argc) {
       seed = atoi(argv[++i]);
     } else {
@@ -73,6 +76,7 @@ main(int argc, char **argv)
   fflush(stdout);
 
   LOG_Initialise();
+  LOG_SetMinSeverity(log_severity);
 
   test_unit();
 
@@ -83,16 +87,6 @@ main(int argc, char **argv)
   return 0;
 }
 
-void TST_SuspendLogging(void)
-{
-  LOG_OpenFileLog("/dev/null");
-}
-
-void TST_ResumeLogging(void)
-{
-  LOG_OpenFileLog(NULL);
-}
-
 double
 TST_GetRandomDouble(double min, double max)
 {
index 2d3637b581535a6c7760a7bf0dd02306de06fc40..00d261d60ec1b86404ecf899384897031dbe5445 100644 (file)
@@ -44,9 +44,6 @@ extern void test_unit(void);
 extern void TST_Fail(int line);
 extern void TST_Skip(int line);
 
-extern void TST_SuspendLogging(void);
-extern void TST_ResumeLogging(void);
-
 extern double TST_GetRandomDouble(double min, double max);
 extern void TST_GetRandomAddress(IPAddr *ip, int family, int bits);
 extern void TST_SwapAddressBit(IPAddr *ip, unsigned int b);
index e5c9b082337394a488baab2bc63dbf93ef66a527..be599062e8e781b3da61813b2a37165424b72705 100644 (file)
@@ -603,12 +603,10 @@ test_unit(void)
 
   TEST_CHECK(UTI_CreateDirAndParents("testdir", 0700, uid, gid));
 
-  TST_SuspendLogging();
   TEST_CHECK(UTI_CheckDirPermissions("testdir", 0700, uid, gid));
   TEST_CHECK(!UTI_CheckDirPermissions("testdir", 0300, uid, gid));
   TEST_CHECK(!UTI_CheckDirPermissions("testdir", 0700, uid + 1, gid));
   TEST_CHECK(!UTI_CheckDirPermissions("testdir", 0700, uid, gid + 1));
-  TST_ResumeLogging();
 
   umask(0);