From patchwork Tue Nov 9 12:27:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tangmeng X-Patchwork-Id: 47279 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 823BD385843D for ; Tue, 9 Nov 2021 12:28:23 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) by sourceware.org (Postfix) with ESMTPS id B5B493858D39 for ; Tue, 9 Nov 2021 12:28:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B5B493858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=uniontech.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=uniontech.com X-QQ-mid: bizesmtp36t1636460886t1rg3joj Received: from localhost.localdomain (unknown [58.240.82.166]) by esmtp6.qq.com (ESMTP) with id ; Tue, 09 Nov 2021 20:28:00 +0800 (CST) X-QQ-SSF: 0140000000200040C000000C0000000 X-QQ-FEAT: K4bWFj5sOHU9bt/bhKx+NeU9o0zHVo/yS85PwM11EM96PtiZJl9jlq+BfJ7oL /ExB5lBdrsAuVASe8wouiVk8ntYZuGLeIHvtcKtg/GxjQSGyd/2x8YjU4XzMV0/9BDpVJgc wgY22ifwZ8/Y6bcWPQi83aM7vbv7fKRUMbEITnl/AXydjctcFwz8AHBN79FOL/GihM01H2m 7bfYWqCx7pyvTpNBsLTFx/0ZNe5uUtt83d6UzfXEZvoA7S4RZ3ZLX5LiVol8h73Ls3F0U+Y OCZOY6OMWcjA8SpHLBNj99nji/0cvhPwBP2GHgwqfeHYHqKnLU5aett+uwDNxqbhAslyIE5 E6dQP6VWy8kYwALmO0RdUC731GU0J2G3NPbBzap X-QQ-GoodBg: 2 From: tangmeng To: libabigail@sourceware.org Subject: [PATCH v3] make abicompat test happy Date: Tue, 9 Nov 2021 20:27:59 +0800 Message-Id: <20211109122759.23613-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign7 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Cc: tangmeng Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" 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 --- tests/test-abicompat.cc | 36 +++++++++++++++++++++++++++++++----- tests/test-utils.h | 4 ++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/tests/test-abicompat.cc b/tests/test-abicompat.cc index 49f1d5d4..0e61b35f 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,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 0; } diff --git a/tests/test-utils.h b/tests/test-utils.h index 46d9b785..5596edc6 100644 --- a/tests/test-utils.h +++ b/tests/test-utils.h @@ -9,6 +9,10 @@ #include "config.h" #include +#define BRIGHT_YELLOW_COLOR "\e[1;33m" +#define BRIGHT_RED_COLOR "\e[1;31m" +#define DEFAULT_TERMINAL_COLOR "\033[0m" + namespace abigail { namespace tests