public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: tangmeng <tangmeng@uniontech.com>
To: libabigail@sourceware.org
Cc: tangmeng <tangmeng@uniontech.com>
Subject: [PATCH v2] make abicompat test happy
Date: Mon,  8 Nov 2021 10:00:17 +0800	[thread overview]
Message-ID: <20211108020017.26436-1-tangmeng@uniontech.com> (raw)

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.
3. The runtestabicompat command itself is executed successfully, so it
should return 0, which should be distinguished from the test result.

                * test/test-abicompat.cc (main): make test happy.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
 tests/test-abicompat.cc | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/tests/test-abicompat.cc b/tests/test-abicompat.cc
index 49f1d5d4..ffcf345b 100644
--- a/tests/test-abicompat.cc
+++ b/tests/test-abicompat.cc
@@ -27,6 +27,7 @@
 
 using std::string;
 using std::cerr;
+using std::cout;
 
 struct InOutSpec
 {
@@ -206,9 +207,10 @@ main()
   using abigail::tools_utils::ensure_parent_dir_created;
   using abigail::tools_utils::abidiff_status;
 
+  unsigned int cnt_total = 0, cnt_passed = 0, cnt_failed = 0;
   bool is_ok = true;
   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)
     {
@@ -253,13 +255,29 @@ 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 << "\e[1;33mTest PASSED: \033[0m" << cmd << "\n";
+	  cnt_passed++;
+	}
+      else
+        {
+          cout << "\e[1;31mTest FAILED: \033[0m" << cmd << "\n";
+	  cnt_failed++;
+	}
+      cnt_total++;
     }
+  cout << "Summary: " << cnt_total << " tested!"
+       << " Test PASSED: " << cnt_passed
+       << ", Test FAILED: " << cnt_failed
+       << ".\n";
 
-  return !is_ok;
+  return 0;
 }
-- 
2.20.1




             reply	other threads:[~2021-11-08  2:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08  2:00 tangmeng [this message]
2021-11-09 11:30 ` Dodji Seketeli
2021-11-09 12:38   ` 汤孟

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211108020017.26436-1-tangmeng@uniontech.com \
    --to=tangmeng@uniontech.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).