[v2] make abicompat test happy
Commit Message
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(-)
Comments
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,
Hello, Dodji>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 ?
Thank you for your suggestions, I have reflected your suggestions in the v3 version of the patch.
I put it in test-utils.h, because I also found this kind of problem in other test cases.
I will modify other use cases in the next time
--
Regards,
tangmeng
------------------ Original ------------------
From: "Dodji Seketeli"<dodji@seketeli.org>;
Date: Tue, Nov 9, 2021 07:30 PM
To: "tangmeng"<tangmeng@uniontech.com>;
Cc: "libabigail"<libabigail@sourceware.org>;
Subject: Re: [PATCH v2] make abicompat test happy
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,
@@ -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;
}