]> sourceware.org Git - libabigail.git/commitdiff
test-abicompat: Make the test output more pleasant
authortangmeng <tangmeng@uniontech.com>
Tue, 9 Nov 2021 12:27:59 +0000 (20:27 +0800)
committerDodji Seketeli <dodji@redhat.com>
Tue, 9 Nov 2021 14:35:19 +0000 (15:35 +0100)
When testing with runtestabicompat, the following problems were found:
1. abicompat tested multiple scenarios, but the last result was used
as the basis for the return value of the command.
2. For multiple test scenarios, the execution results cannot be known
after the test, which is easy to cause confusion.

* test/test-abicompat.cc (main): make test output more pleasant.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
tests/test-abicompat.cc
tests/test-utils.h

index 49f1d5d457b4a56511081680e513292c5e2ff072..a1339eef7db84c70f2e4afd978fc9a6bfa718f71 100644 (file)
@@ -27,6 +27,7 @@
 
 using std::string;
 using std::cerr;
+using std::cout;
 
 struct InOutSpec
 {
@@ -206,12 +207,13 @@ main()
   using abigail::tools_utils::ensure_parent_dir_created;
   using abigail::tools_utils::abidiff_status;
 
-  bool is_ok = true;
+  unsigned int cnt_total = 0, cnt_passed = 0, cnt_failed = 0;
   string in_app_path, in_lib1_path, in_lib2_path, suppression_path,
-    abicompat_options, ref_report_path, out_report_path, abicompat, cmd;
+    abicompat_options, ref_report_path, out_report_path, abicompat, cmd, diffcmd;
 
   for (InOutSpec* s = in_out_specs; s->in_app_path; ++s)
     {
+      bool is_ok = true;
       in_app_path = string(get_src_dir()) + "/tests/" + s->in_app_path;
       in_lib1_path = string(get_src_dir()) + "/tests/" + s->in_lib1_path;
       if (s->in_lib2_path && strcmp(s->in_lib2_path, ""))
@@ -253,13 +255,37 @@ main()
 
       if (abicompat_ok)
        {
-         cmd = "diff -u " + ref_report_path + " " + out_report_path;
-         if (system(cmd.c_str()))
+         diffcmd = "diff -u " + ref_report_path + " " + out_report_path;
+         if (system(diffcmd.c_str()))
            is_ok = false;
        }
       else
        is_ok = false;
+
+      if (is_ok)
+        {
+         cout << BRIGHT_YELLOW_COLOR
+               << "Test Passed:"
+               << DEFAULT_TERMINAL_COLOR
+               << cmd
+               << std::endl;
+         cnt_passed++;
+       }
+      else
+        {
+         cout << BRIGHT_RED_COLOR
+               << "Test Failed:"
+               << DEFAULT_TERMINAL_COLOR
+               << cmd
+               << std::endl;
+         cnt_failed++;
+       }
+      cnt_total++;
     }
+  cout << "Summary: " << cnt_total << " tested!"
+       << " Test Passed: " << cnt_passed
+       << ", Test Failed: " << cnt_failed
+       << ".\n";
 
-  return !is_ok;
+  return cnt_failed;
 }
index 46d9b78510bf797ec8943ccc25d86ee1dc5983e7..5596edc61e692f32cfa46257bf44027fd58c8b61 100644 (file)
@@ -9,6 +9,10 @@
 #include "config.h"
 #include <string>
 
+#define BRIGHT_YELLOW_COLOR "\e[1;33m"
+#define BRIGHT_RED_COLOR "\e[1;31m"
+#define DEFAULT_TERMINAL_COLOR "\033[0m"
+
 namespace abigail
 {
 namespace tests
This page took 0.034334 seconds and 5 git commands to generate.