This patch replaces the calls to OSv specific debug() with
standard printf(). These makes these 3 unit tests compilable
and runnable on Linux and allows for verification if these tests
pass on Linux.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
 tests/tst-except.cc  |  8 ++++----
 tests/tst-readdir.cc | 12 ++++++++----
 tests/tst-sleep.cc   | 10 +++++-----
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/tests/tst-except.cc b/tests/tst-except.cc
index 55380c1f..e34a7b7b 100644
--- a/tests/tst-except.cc
+++ b/tests/tst-except.cc
@@ -5,7 +5,7 @@
  * BSD license as described in the LICENSE file in the top-level directory.
  */
 
-#include <osv/debug.hh>
+#include <cstdio>
 #include <exception>
 #include <setjmp.h>
 #include <memory>
@@ -16,14 +16,14 @@ static void report(bool ok, const char* msg)
 {
     ++tests;
     fails += !ok;
-    debug("%s: %s\n", (ok ? "PASS" : "FAIL"), msg);
+    printf("%s: %s\n", (ok ? "PASS" : "FAIL"), msg);
 }
 
 jmp_buf env;
 static bool saw_unhandled = false;
 void myterminate()
 {
-    debug("caught unhandled exception\n");
+    printf("caught unhandled exception\n");
     saw_unhandled = true;
     longjmp(env, 1);
 }
@@ -78,6 +78,6 @@ int main(int ac, char** av)
     std::set_terminate(old);
 
 
-    debug("SUMMARY: %d tests, %d failures\n", tests, fails);
+    printf("SUMMARY: %d tests, %d failures\n", tests, fails);
 
 }
diff --git a/tests/tst-readdir.cc b/tests/tst-readdir.cc
index 717065b6..9154d252 100644
--- a/tests/tst-readdir.cc
+++ b/tests/tst-readdir.cc
@@ -10,8 +10,12 @@
 #include <dirent.h>
 #include <string.h>
 #include <fcntl.h>
+#include <unistd.h>
 
-#include <osv/debug.hh>
+#include <cstdio>
+#include <cerrno>
+#include <cstdlib>
+#include <string>
 
 #if defined(READ_ONLY_FS)
 #define SUBDIR "rofs"
@@ -30,7 +34,7 @@ static void report(bool ok, const char* msg)
 
 int main(int argc, char **argv)
 {
-    debug("Testing readdir() and related functions\n");
+    printf("Testing readdir() and related functions\n");
 #if defined(READ_ONLY_FS)
     report(mkdir("/rofs/tst-readdir-empty2", 0777) == -1 && errno == EROFS, 
"mkdir");
 #else
@@ -190,9 +194,9 @@ int main(int argc, char **argv)
     struct dirent **namelist;
     int count = scandir("/tmp/tst-readdir", &namelist, NULL, alphasort);
     report(count == 6, "scandir return 4 entries");
-    debug("count = %d\n", count);
+    printf("count = %d\n", count);
     for (int i = 0; i < count; i++) {
-        debug("namelist[%d] = %s\n", i, namelist[i]->d_name);
+        printf("namelist[%d] = %s\n", i, namelist[i]->d_name);
     }
     report(count > 0 && !strcmp(namelist[0]->d_name,"."), "scandir return .");
     report(count > 1 && !strcmp(namelist[1]->d_name,".."), "scandir return 
..");
diff --git a/tests/tst-sleep.cc b/tests/tst-sleep.cc
index 1492d9f8..32695c9a 100644
--- a/tests/tst-sleep.cc
+++ b/tests/tst-sleep.cc
@@ -1,6 +1,6 @@
-#include <osv/debug.hh>
-
 #include <chrono>
+#include <cstdio>
+#include <unistd.h>
 
 int tests = 0, fails = 0;
 
@@ -8,12 +8,12 @@ static void report(bool ok, const char* msg)
 {
     ++tests;
     fails += !ok;
-    debug("%s: %s\n", (ok ? "PASS" : "FAIL"), msg);
+    printf("%s: %s\n", (ok ? "PASS" : "FAIL"), msg);
 }
 
 int main(int ac, char** av)
 {
-    debug("starting sleep test\n");
+    printf("starting sleep test\n");
     auto start = std::chrono::system_clock::now();
     int r = sleep(2);
     auto end = std::chrono::system_clock::now();
@@ -21,5 +21,5 @@ int main(int ac, char** av)
     report(r == 0, "sleep 2 seconds finished successfully");
     report(sec >= 1.5 && sec < 2.5, "and slept for roughly 2 seconds");
 
-    debug("SUMMARY: %d tests, %d failures\n", tests, fails);
+    printf("SUMMARY: %d tests, %d failures\n", tests, fails);
 }
-- 
2.31.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20211119042423.55832-3-jwkozaczuk%40gmail.com.

Reply via email to