From patchwork Mon Jan 8 09:53:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 25267 Received: (qmail 124198 invoked by alias); 8 Jan 2018 09:53:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 124163 invoked by uid 89); 8 Jan 2018 09:53:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 Jan 2018 09:53:53 +0000 Received: by mail-wr0-f176.google.com with SMTP id 60so1028566wrl.5 for ; Mon, 08 Jan 2018 01:53:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=cS8A3Zt+KUaVqhiGB1kd99VBONJYMhLcUjHI+ozOYNU=; b=kJgOgDZ5sBR0g6Aym9u2r2JN9v0JCiXVQQ02ZPNw56p63rUb3BIryeYkb0qqaZ61aO 0sNjvYqUnoBoyrvfX/ptBxFcStOJLxXaZQFMdFrzbwlwl19ncnQP5r4gLASVMtyffhdQ aBBl4Ev5kgLuhA88XJq9bsPT3JTkVaD42mAU4l6qW/4LK7TS+rSiW4EThQkN66ZcwwUm A1QH3H+xuIsRidFsGCryjmLKw+2UpkcXDw44JnmXdNAccLNZ6IR+dz7aVd0JJ4B4BWWx c8x+wLndSSLGFlsl+LuAX/atAVvQLFiwa4tCZ1jI6i4kKs1AGl6ueciUJEocbOxC2AvJ 8hUA== X-Gm-Message-State: AKGB3mJ1CGtqOdgsT9FH/bmSQF/QFYN573bYs97kqr/FqOC7X51bwEzS x386GK0r0SdbShw40hn0NZ7eQQ== X-Google-Smtp-Source: ACJfBovnTQF35D62Ls0ttent5av31CjNq5DuOysQx22EbFFb07INQvpa9iqMHH5efOwvYpU5bRR1nQ== X-Received: by 10.223.128.34 with SMTP id 31mr10611605wrk.248.1515405230995; Mon, 08 Jan 2018 01:53:50 -0800 (PST) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id c53sm24665062wrg.10.2018.01.08.01.53.49 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 08 Jan 2018 01:53:50 -0800 (PST) From: Yao Qi To: Simon Marchi Cc: Subject: Re: [PATCH 1/2 master/8.1] Fix GDB build failure when $development is false References: <1515148494-21578-1-git-send-email-yao.qi@linaro.org> <84552133-c6d7-3fd8-de88-bdbf5f7d6e1f@ericsson.com> Date: Mon, 08 Jan 2018 09:53:45 +0000 In-Reply-To: <84552133-c6d7-3fd8-de88-bdbf5f7d6e1f@ericsson.com> (Simon Marchi's message of "Sat, 6 Jan 2018 12:08:47 -0500") Message-ID: <86fu7ghe1i.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Simon Marchi writes: > Otherwise, the patch LGTM. > > Here's a fixup patch that does this, feel free to use it if you like the > idea. Just as a sanity check, I added an assert in unittest.exp to make sure > that when tests are ran, we run at least one test. It is good to make the output more explicit. I take your fixup patch in, and I'll push the patch below in. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index c0486c4..17b71c6 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1050,7 +1050,6 @@ COMMON_SFILES = \ remote-notif.c \ reverse.c \ rust-lang.c \ - selftest-arch.c \ sentinel-frame.c \ ser-event.c \ serial.c \ @@ -1139,7 +1138,6 @@ SFILES = \ common/ptid.c \ common/rsp-low.c \ common/run-time-clock.c \ - common/selftest.c \ common/signals.c \ common/signals-state-save-restore.c \ common/vec.c \ @@ -1555,7 +1553,6 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ ptid.o \ rsp-low.o \ run-time-clock.o \ - selftest.o \ signals.o \ signals-state-save-restore.o \ vec.o \ diff --git a/gdb/configure b/gdb/configure index 7b25007..db610f3 100755 --- a/gdb/configure +++ b/gdb/configure @@ -17599,8 +17599,8 @@ if $development; then $as_echo "#define GDB_SELF_TEST 1" >>confdefs.h - CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS)" - CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS)" + CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest.o selftest-arch.o" + CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) common/selftest.c selftest-arch.c" fi diff --git a/gdb/configure.ac b/gdb/configure.ac index 3e073b5..3db44ae 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -2293,8 +2293,8 @@ AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8", if $development; then AC_DEFINE(GDB_SELF_TEST, 1, [Define if self-testing features should be enabled]) - CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS)" - CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS)" + CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest.o selftest-arch.o" + CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) common/selftest.c selftest-arch.c" fi GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME]) diff --git a/gdb/maint.c b/gdb/maint.c index a924f83..70e0011 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -939,16 +939,26 @@ show_per_command_cmd (const char *args, int from_tty) static void maintenance_selftest (const char *args, int from_tty) { +#if GDB_SELF_TEST selftests::run_tests (args); +#else + printf_filtered (_("\ +Selftests are not available in a non-development build.\n")); +#endif } static void maintenance_info_selftests (const char *arg, int from_tty) { +#if GDB_SELF_TEST printf_filtered ("Registered selftests:\n"); selftests::for_each_selftest ([] (const std::string &name) { printf_filtered (" - %s\n", name.c_str ()); }); +#else + printf_filtered (_("\ +Selftests are not available in a non-development build.\n")); +#endif } diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp index 44e9329..1c83585 100644 --- a/gdb/testsuite/gdb.gdb/unittest.exp +++ b/gdb/testsuite/gdb.gdb/unittest.exp @@ -16,7 +16,18 @@ set do_xml_test [expr ![gdb_skip_xml_test]] gdb_start -gdb_test "maintenance selftest" "Ran $decimal unit tests, 0 failed" + +set test "maintenance selftest" +gdb_test_multiple $test $test { + -re "Ran ($decimal) unit tests, 0 failed\r\n$gdb_prompt $" { + set num_ran $expect_out(1,string) + gdb_assert "$num_ran > 0" $test + } + + -re "Selftests are not available in a non-development build.\r\n$gdb_prompt $" { + unsupported $test + } +} if { ![is_remote host] && $do_xml_test } { gdb_test "maintenance check xml-descriptions ${srcdir}/../features" \