From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35752 invoked by alias); 2 Jun 2016 20:41:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 35708 invoked by uid 89); 2 Jun 2016 20:41:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3963, risk, registration, surprise X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 02 Jun 2016 20:41:04 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6340933BCFA for ; Thu, 2 Jun 2016 20:41:03 +0000 (UTC) Received: from c64.redhat.com (vpn-237-222.phx2.redhat.com [10.3.237.222]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u52Kf2Ws007154; Thu, 2 Jun 2016 16:41:02 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: Bernd Schmidt , Jeff Law , David Malcolm Subject: [PATCH 00/16] v6 of -fself-test/unit-testing patch Date: Thu, 02 Jun 2016 20:41:00 -0000 Message-Id: <1464901625-54547-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1464874868.11895.41.camel@redhat.com> References: <1464874868.11895.41.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00210.txt.bz2 Given that we're now using an "abort on first failure" model, I renamed all of the EXPECT_ macros to ASSERT_ (for consistency with GTest). As per Bernd's suggestions I eliminated the runner class and moved to a more function-based rather than class-based approach. At this point, the only reasons left for "class test" were auto-registration, and giving names to tests. So I tried removing it, and invoking tests manually. I like the resulting code; it seems much simpler and clearer, with very little "magic". The following is an updated version of the patch kit that uses this simpler approach. In theory there's a slight risk to the manual-invocation approach. If you forget a test within a file, the compiler tells you: ../../src/gcc/vec.c:204:1: warning: ‘void test_quick_push()’ defined but not used [-Wunused-function] but if you forget to call the file from selftests.c, there's no warning. I believe that adding a new test file will be a rare event, so this kind of mistake will (I hope) be unlikely. I've verified that the pass count before/after the change matches up. By constrast, the auto-registration approach put us at the mercy of the implementation of C++ global constructors, and I ran into at least one surprise with that ( https://sourceware.org/bugzilla/show_bug.cgi?id=20152 ). I've added the wide-int tests back. These are parametrized by type, and it was fairly easy to do this manually using templates once I eliminated test registration. I also added some new tests to diagnostic-show-locus.c. Although I'm posted this as a patch kit, it would be applied in one commit: the initial patch makes reference to tests added in later patches. I split it up so that each test file is in its own patch, to make review easier (I hope). As in v5, the tests are run in gcc/Makefile.in at each stage of a bootstrap: $ grep "fself-test:" test/experiment/x86_64-pc-linux-gnu/build/make.log -fself-test: 621 pass(es) in 0.013000 seconds -fself-test: 621 pass(es) in 0.006000 seconds -fself-test: 621 pass(es) in 0.007000 seconds Successfully bootstrapped®ression tested on x86_64-pc-linux-gnu. A test against all configurations using contrib/config-list.mk is in progress. OK for trunk? David Malcolm (16): Core of selftest framework (v6) diagnostic-show-locus.c: add selftests spellcheck.c: convert Levenshtein test from a plugin to a selftest bitmap.c: add selftests tree-cfg.c: add selftests et-forest.c: add selftests fold-const.c: add selftests Add function-tests.c gimple.c: add selftests Add hash-map-tests.c Add hash-set-tests.c input.c: add selftests Add rtl-tests.c tree.c: add selftests vec.c: add selftests wide-int.cc: add selftests gcc/Makefile.in | 31 +- gcc/bitmap.c | 110 ++++ gcc/common.opt | 4 + gcc/diagnostic-show-locus.c | 156 ++++++ gcc/et-forest.c | 112 ++++ gcc/fold-const.c | 75 +++ gcc/function-tests.c | 639 +++++++++++++++++++++++ gcc/gimple.c | 119 +++++ gcc/hash-map-tests.c | 88 ++++ gcc/hash-set-tests.c | 64 +++ gcc/input.c | 112 ++++ gcc/rtl-tests.c | 108 ++++ gcc/selftest-run-tests.c | 77 +++ gcc/selftest.c | 49 ++ gcc/selftest.h | 153 ++++++ gcc/spellcheck.c | 45 ++ gcc/testsuite/gcc.dg/plugin/levenshtein-test-1.c | 9 - gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c | 64 --- gcc/testsuite/gcc.dg/plugin/plugin.exp | 1 - gcc/toplev.c | 26 + gcc/toplev.h | 2 + gcc/tree-cfg.c | 277 ++++++++++ gcc/tree.c | 60 +++ gcc/vec.c | 162 ++++++ gcc/wide-int.cc | 152 ++++++ 25 files changed, 2616 insertions(+), 79 deletions(-) create mode 100644 gcc/function-tests.c create mode 100644 gcc/hash-map-tests.c create mode 100644 gcc/hash-set-tests.c create mode 100644 gcc/rtl-tests.c create mode 100644 gcc/selftest-run-tests.c create mode 100644 gcc/selftest.c create mode 100644 gcc/selftest.h delete mode 100644 gcc/testsuite/gcc.dg/plugin/levenshtein-test-1.c delete mode 100644 gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c -- 1.8.5.3