make abicompat test happy

Message ID 20211105033253.21879-1-tangmeng@uniontech.com
State New
Headers
Series make abicompat test happy |

Commit Message

tangmeng Nov. 5, 2021, 3:32 a.m. UTC
  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 | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
  

Patch

diff --git a/tests/test-abicompat.cc b/tests/test-abicompat.cc
index 49f1d5d4..0b214d0e 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
 {
@@ -208,7 +209,7 @@  main()
 
   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 +254,18 @@  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 << "Test PASS by run: " << cmd << "\n";
+      else
+        cout << "Test FAILED by run: " << cmd << "\n";
     }
 
-  return !is_ok;
+  return 0;
 }