From patchwork Mon Nov 8 02:00:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tangmeng X-Patchwork-Id: 47195 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 7F2AE3858401 for ; Mon, 8 Nov 2021 02:00:50 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from smtpbg156.qq.com (smtpbg156.qq.com [15.184.82.18]) by sourceware.org (Postfix) with ESMTPS id 4E71E3858401 for ; Mon, 8 Nov 2021 02:00:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E71E3858401 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: bizesmtp38t1636336826tiu5ljy5 Received: from localhost.localdomain (unknown [58.240.82.166]) by esmtp6.qq.com (ESMTP) with id ; Mon, 08 Nov 2021 10:00:19 +0800 (CST) X-QQ-SSF: 0140000000000040C000B00A0000000 X-QQ-FEAT: FCUjxTjsuSIWzekOo5it0U/SiIonEJREhpw1NrnkrMi/a8woJoSfxvCs1t1wL NeFkDC2mR+a7e1JoTN4noMIagAInSagMAuKH5fNPF3X0lUiFzP8aW30UqJdEf5rFzSwKOop YExdUbOxiaxOgTDEE9d0GCPSyrjAvkXGvQ5RDLTHj/TomfNjXMbJlzawq7tFK4PWYvEELHO CDrcvb87l6nQEYKxGZePLwFHqAUDIR9XZoB//Mb4N4luPFYklG3jqJCd3G0cDr5dzPb+Zyc lOsoHFxZeAk4coScCMnl6uvEYaWUcB0doZBwxW+iZu025X7keDR9CXKzavjnYkMh5N16x0+ J5k+KALugop/15GbaFyOFTgrOewNA== X-QQ-GoodBg: 2 From: tangmeng To: libabigail@sourceware.org Subject: [PATCH v2] make abicompat test happy Date: Mon, 8 Nov 2021 10:00:17 +0800 Message-Id: <20211108020017.26436-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, 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 | 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; }