]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test: write log file to current directory
authorKefu Chai <kchai@redhat.com>
Wed, 26 Dec 2018 04:58:08 +0000 (12:58 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 26 Dec 2018 05:08:47 +0000 (13:08 +0800)
instead of writing log files to '/tmp', write them to current directory.

by default, ctest runs the tests in ${CMAKE_CURRENT_BINARY_DIR}, so, in
this case, the log files are located in build/src/test/. this ensure
that current user has enough previledge to remove the log files.

this also allows multiple instances of 'unittest_log' to run in parallel.

See-also: http://tracker.ceph.com/issues/36737
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/log/test.cc

index 76f7f78e4b7604f9089bbf9157c40c0fe779ea37..52fbb284c9ca77ba80cb437875e7f4a51396665f 100644 (file)
@@ -30,7 +30,7 @@ TEST(Log, Simple)
   Log log(&subs);
   log.start();
  
-  log.set_log_file("/tmp/foo");
+  log.set_log_file("foo");
   log.reopen_log_file();
 
   log.set_stderr_level(5, -1);
@@ -59,7 +59,7 @@ TEST(Log, ReuseBad)
   subs.set_gather_level(1, 1);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/foo");
+  log.set_log_file("foo");
   log.reopen_log_file();
 
   const int l = 0;
@@ -91,7 +91,7 @@ TEST(Log, ManyNoGather)
   subs.set_gather_level(1, 1);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/big");
+  log.set_log_file("big");
   log.reopen_log_file();
   for (int i=0; i<many; i++) {
     int l = 10;
@@ -110,7 +110,7 @@ TEST(Log, ManyGatherLog)
   subs.set_gather_level(1, 10);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/big");
+  log.set_log_file("big");
   log.reopen_log_file();
   for (int i=0; i<many; i++) {
     int l = 10;
@@ -131,7 +131,7 @@ TEST(Log, ManyGatherLogStackSpillover)
   subs.set_gather_level(1, 10);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/big");
+  log.set_log_file("big");
   log.reopen_log_file();
   for (int i=0; i<many; i++) {
     int l = 10;
@@ -154,7 +154,7 @@ TEST(Log, ManyGather)
   subs.set_gather_level(1, 1);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/big");
+  log.set_log_file("big");
   log.reopen_log_file();
   for (int i=0; i<many; i++) {
     int l = 10;
@@ -172,7 +172,7 @@ void do_segv()
   subs.set_gather_level(1, 1);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/big");
+  log.set_log_file("big");
   log.reopen_log_file();
 
   log.inject_segv();
@@ -198,7 +198,7 @@ TEST(Log, LargeLog)
   subs.set_gather_level(1, 10);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/big");
+  log.set_log_file("big");
   log.reopen_log_file();
   int l = 10;
   {
@@ -218,7 +218,7 @@ TEST(Log, LargeFromSmallLog)
   subs.set_gather_level(1, 10);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/big");
+  log.set_log_file("big");
   log.reopen_log_file();
   int l = 10;
   {
@@ -242,7 +242,7 @@ TEST(Log, TimeSwitch)
   subs.set_gather_level(1, 10);
   Log log(&subs);
   log.start();
-  log.set_log_file("/tmp/time_switch_log");
+  log.set_log_file("time_switch_log");
   log.reopen_log_file();
   int l = 10;
   bool coarse = true;
@@ -343,7 +343,7 @@ TEST(Log, Speed_nogather)
 
 TEST(Log, GarbleRecovery)
 {
-  static const char* test_file="/tmp/log_for_moment";
+  static const char* test_file="log_for_moment";
 
   Log* saved = g_ceph_context->_log;
   Log log(&g_ceph_context->_conf->subsys);