public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] make abicompat test happy
@ 2021-11-08  2:00 tangmeng
  2021-11-09 11:30 ` Dodji Seketeli
  0 siblings, 1 reply; 3+ messages in thread
From: tangmeng @ 2021-11-08  2:00 UTC (permalink / raw)
  To: libabigail; +Cc: tangmeng

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] make abicompat test happy
  2021-11-08  2:00 [PATCH v2] make abicompat test happy tangmeng
@ 2021-11-09 11:30 ` Dodji Seketeli
  2021-11-09 12:38   ` 汤孟
  0 siblings, 1 reply; 3+ messages in thread
From: Dodji Seketeli @ 2021-11-09 11:30 UTC (permalink / raw)
  To: tangmeng; +Cc: libabigail

Hello,

tangmeng <tangmeng@uniontech.com> a écrit:

[...]

> +
> +      if (is_ok)
> +        {
> +          cout << "\e[1;33mTest PASSED: \033[0m" << cmd << "\n";

Hehe, bells and whistles ... :-)

I'd prefer to have the escape sequences be "self-documented" so that the
intent is clear enough.  For instance:

#define BRIGHT_YELLOW_COLOR "\a1;33m"
#define DEFAULT_TERMINAL_COLOR "\033[0m"

and then you'd you'd emit colored messages like:

cout << BRIGHT_YELLOW_COLOR
     << "Test Passed:"
     << DEFAULT_TERMINAL_COLOR
     << cmd
     << std::endl;

I believe that is more self explanatory for someone who reads the code.

Could you please use that kind of style ?

Thanks a lot for your work, by the way, it's highly appreciated!

Cheers,

-- 
		Dodji

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] make abicompat test happy
  2021-11-09 11:30 ` Dodji Seketeli
@ 2021-11-09 12:38   ` 汤孟
  0 siblings, 0 replies; 3+ messages in thread
From: 汤孟 @ 2021-11-09 12:38 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: libabigail

Hello, Dodji&gt;Hehe, bells and whistles ... :-) &gt; &gt;I'd prefer to have the escape sequences &gt;be "self-documented" so that the &gt;intent is clear enough.  For instance: &gt; &gt;#define BRIGHT_YELLOW_COLOR &gt;"\a1;33m" &gt;#define DEFAULT_TERMINAL_COLOR &gt;"\033[0m" &gt; &gt;and then you'd you'd emit colored &gt;messages like: &gt; &gt;cout << BRIGHT_YELLOW_COLOR &gt;     << "Test Passed:" &gt;     << DEFAULT_TERMINAL_COLOR &gt;     << cmd &gt;    << std::endl; &gt; &gt;I believe that is more self explanatory for &gt;someone who reads the code. &gt; &gt;Could you please use that kind of style ?
Thank you for your suggestions, I have reflected your suggestions in the v3 version of the patch.
&nbsp;
I put it in test-utils.h, because I also found this kind of problem in other test cases.&nbsp;
I will modify other use cases in the next time
--&nbsp;
Regards,
tangmeng
------------------&nbsp;Original&nbsp;------------------
From: &nbsp;"Dodji Seketeli"<dodji@seketeli.org&gt;;
Date: &nbsp;Tue, Nov 9, 2021 07:30 PM
To: &nbsp;"tangmeng"<tangmeng@uniontech.com&gt;; 
Cc: &nbsp;"libabigail"<libabigail@sourceware.org&gt;; 
Subject: &nbsp;Re: [PATCH v2] make abicompat test happy

&nbsp;

Hello,

tangmeng <tangmeng@uniontech.com&gt; a écrit:

[...]

&gt; +
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (is_ok)
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout << "\e[1;33mTest PASSED: \033[0m" << cmd << "\n";

Hehe, bells and whistles ... :-)

I'd prefer to have the escape sequences be "self-documented" so that the
intent is clear enough.&nbsp; For instance:

#define BRIGHT_YELLOW_COLOR "\a1;33m"
#define DEFAULT_TERMINAL_COLOR "\033[0m"

and then you'd you'd emit colored messages like:

cout << BRIGHT_YELLOW_COLOR
&nbsp;&nbsp;&nbsp;&nbsp; << "Test Passed:"
&nbsp;&nbsp;&nbsp;&nbsp; << DEFAULT_TERMINAL_COLOR
&nbsp;&nbsp;&nbsp;&nbsp; << cmd
&nbsp;&nbsp;&nbsp;&nbsp; << std::endl;

I believe that is more self explanatory for someone who reads the code.

Could you please use that kind of style ?

Thanks a lot for your work, by the way, it's highly appreciated!

Cheers,

-- 
		Dodji

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-09 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08  2:00 [PATCH v2] make abicompat test happy tangmeng
2021-11-09 11:30 ` Dodji Seketeli
2021-11-09 12:38   ` 汤孟

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).