From patchwork Fri Feb 7 14:59:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahab Vahedi X-Patchwork-Id: 37733 Received: (qmail 81852 invoked by alias); 7 Feb 2020 15:01:05 -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 81331 invoked by uid 89); 7 Feb 2020 15:00:50 -0000 Authentication-Results: sourceware.org; auth=none 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.1 spammy=fake, 1655, mi-break.exp, mibreakexp X-HELO: mail-lj1-f170.google.com Received: from mail-lj1-f170.google.com (HELO mail-lj1-f170.google.com) (209.85.208.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Feb 2020 15:00:48 +0000 Received: by mail-lj1-f170.google.com with SMTP id f25so2445497ljg.12 for ; Fri, 07 Feb 2020 07:00:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ygSbe+ezdCAlZ7SR5QcHVyK1kQlNK98bMd57k3oOWdM=; b=f3ARbBPM2jfZen1DENfTGVnit4fCS1a2hg/p6BJjWLCMzl8QR1ieJWgt/usGbMahKj kzFrN4YUuc702wybznzGpVt2ZaakDxYljyz3L/7f+rguy7p1LV0zzJpa4SO/fLnLS4SK h+KTCejsWfkbu3fjnJJNyYXBgFhiFl8EM1NatIczPSdnqTJ3my8xA6pPywiM7BagdZd9 bzb2remAZz0bVS0j+zMX42ays8Y/U1iSg5/dOs5qYeih5TfBBXYHySi/Ch9jkKuK7Lb7 lyPg3IKptL8pH7JnXx7wT66jDrZXWArM+gIi3+6BBwxgTDQzUGToTnAF5pkBypMPAyfn jPGQ== Return-Path: Received: from archie.internal.synopsys.com ([2a03:1b20:6:f011::2d]) by smtp.gmail.com with ESMTPSA id p136sm1184412lfa.8.2020.02.07.07.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 07:00:43 -0800 (PST) From: Shahab Vahedi To: gdb-patches@sourceware.org Cc: Shahab Vahedi , Shahab Vahedi , Francois Bedard , Anton Kolesov Subject: [PATCH 04/14] gdb/testsuite: Avoid fake failures when exit is unreliable Date: Fri, 7 Feb 2020 15:59:53 +0100 Message-Id: <20200207150003.8383-5-shahab.vahedi@gmail.com> In-Reply-To: <20200207150003.8383-1-shahab.vahedi@gmail.com> References: <20200207150003.8383-1-shahab.vahedi@gmail.com> MIME-Version: 1.0 From: Anton Kolesov Tests that run in background will not run properly with targets that doesn't have a proper "exit" function. For example, gdb.base/hook-stop expects that after hook will resume inferior in background, there would be a message "exited normally", however such a message will appear only for targets with a proper exit(), while others will, for example, spin in the infinite loop. Test gdb.base/nextoverexit expects message "inferior exited normally", which is present only when exit() actually halts the target. Some tests in gdb.base/commands.exp has a flow that expects that application can exit itself, which is not true when exit() function is not reliable. This patch makes those tests conditional - they run only if exit is reliable. gdb/testsuite/ChangeLog: 2016-07-13 Anton Kolesov * gdb.base/callexit.exp: Expect an "exit()" only if "exit_is_reliable" says so. * gdb.base/commands.exp: Likewise. * gdb.base/ena-dis-br.exp: Likewise. * gdb.base/hook-stop.exp: Likewise. * gdb.base/nextoverexit.exp: Likewise. * gdb.mi/mi-break.exp: Likewise. * gdb.mi/mi-exit-code.exp: Likewise. * gdb.mi/mi-simplerun.exp: Likewise. Signed-off-by: Anton Kolesov --- gdb/testsuite/gdb.base/callexit.exp | 7 +++++++ gdb/testsuite/gdb.base/commands.exp | 14 ++++++++++++++ gdb/testsuite/gdb.base/ena-dis-br.exp | 18 +++++++++++------- gdb/testsuite/gdb.base/hook-stop.exp | 12 +++++++++++- gdb/testsuite/gdb.base/nextoverexit.exp | 7 +++++++ gdb/testsuite/gdb.mi/mi-break.exp | 5 +++++ gdb/testsuite/gdb.mi/mi-exit-code.exp | 5 +++++ gdb/testsuite/gdb.mi/mi-simplerun.exp | 5 +++++ 8 files changed, 65 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.base/callexit.exp b/gdb/testsuite/gdb.base/callexit.exp index 67ff48283646..4fc2d5a2669a 100644 --- a/gdb/testsuite/gdb.base/callexit.exp +++ b/gdb/testsuite/gdb.base/callexit.exp @@ -28,6 +28,13 @@ if [target_info exists gdb,cannot_call_functions] { continue } +# Some targets (for example baremetal ones) doesn't have exit() that actually +# exits anywhere. +if ![exit_is_reliable] { + unsupported "This target doesn't have reliable exit() function." + continue +} + # Start with a fresh gdb. clean_restart ${binfile} diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index 869d0a81a4a7..fd92b3fa3111 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -694,6 +694,13 @@ proc_with_prefix deprecated_command_test {} { proc_with_prefix bp_deleted_in_command_test {} { global gdb_prompt + # Flow of this test assumes that application will halt after reaching the + # exit() function. + if ![exit_is_reliable] { + unsupported "Function exit() is not reliable on this board." + return 0 + } + delete_breakpoints # Create a breakpoint, and associate a command-list to it, with @@ -736,6 +743,13 @@ proc_with_prefix bp_deleted_in_command_test {} { } proc_with_prefix temporary_breakpoint_commands {} { + # Flow of this test assumes that application will halt after reaching the + # exit() function. + if ![exit_is_reliable] { + unsupported "Function exit() is not reliable on this board." + return 0 + } + delete_breakpoints # Create a temporary breakpoint, and associate a commands list to it. diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index c338a0d51fa9..bf670cbae948 100644 --- a/gdb/testsuite/gdb.base/ena-dis-br.exp +++ b/gdb/testsuite/gdb.base/ena-dis-br.exp @@ -295,13 +295,17 @@ gdb_test "continue 2" \ gdb_test "next" ".*$bp_location11\[ \t\]*marker1.*" \ "step after continue with ignore count" -set test "continue with ignore count, not stopped at bpt" -gdb_test_multiple "continue 2" "$test" { - -re "Not stopped at any breakpoint; argument ignored.*$gdb_prompt $" { - pass "$test" - } - -re "No breakpoint number -1.*$gdb_prompt $" { - kfail gdb/1689 "$test" +# Application is expected to reach an exit() here, so this can't be run if exit +# is not working. +if [exit_is_reliable] { + set test "continue with ignore count, not stopped at bpt" + gdb_test_multiple "continue 2" "$test" { + -re "Not stopped at any breakpoint; argument ignored.*$gdb_prompt $" { + pass "$test" + } + -re "No breakpoint number -1.*$gdb_prompt $" { + kfail gdb/1689 "$test" + } } } diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp index 6b49e39b7380..c9bc3d3b6438 100644 --- a/gdb/testsuite/gdb.base/hook-stop.exp +++ b/gdb/testsuite/gdb.base/hook-stop.exp @@ -165,5 +165,15 @@ proc hook_stop_next {} { hook_stop_before_frame hook_stop_kill hook_stop_continue_fg -hook_stop_continue_bg + +# Tests that run in background will not run properly with targets that +# doesn't have a proper "exit" function. For example, this particular +# test expects that after hook will resume inferior in background, there +# would be a message "exited normally", however such a message will +# appear only for targets with a proper # exit(), while others will, for +# example, spin in the infinite loop. +if [exit_is_reliable] { + hook_stop_continue_bg +} + hook_stop_next diff --git a/gdb/testsuite/gdb.base/nextoverexit.exp b/gdb/testsuite/gdb.base/nextoverexit.exp index 30eafef675ff..fcea35762b00 100644 --- a/gdb/testsuite/gdb.base/nextoverexit.exp +++ b/gdb/testsuite/gdb.base/nextoverexit.exp @@ -14,6 +14,13 @@ standard_testfile +# This tests expects message "inferior exited normally", which is present only +# when exit() actually halts the target. +if ![exit_is_reliable] { + unsupported "Function exit() is not reliable on this board." + return 0 +} + if {[prepare_for_testing "failed to prepare" $testfile $testfile.c]} { return -1 } diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index 1149bb34c8dc..acec246f52ee 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -244,6 +244,11 @@ proc test_disabled_creation {} { proc test_breakpoint_commands {} { global line_callee2_body + if ![exit_is_reliable] { + unsupported "This test requires working exit() function." + return 0 + } + set bp_no_script \ [mi_create_breakpoint "basics.c:callee2" \ "breakpoint commands: insert breakpoint at basics.c:callee2" \ diff --git a/gdb/testsuite/gdb.mi/mi-exit-code.exp b/gdb/testsuite/gdb.mi/mi-exit-code.exp index f10b49cee0f8..fb5c693597da 100644 --- a/gdb/testsuite/gdb.mi/mi-exit-code.exp +++ b/gdb/testsuite/gdb.mi/mi-exit-code.exp @@ -23,6 +23,11 @@ if [mi_gdb_start] { standard_testfile +if ![exit_is_reliable] { + unsupported "Function exit() is not reliable on this board." + return 0 +} + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { untested "failed to compile" return -1 diff --git a/gdb/testsuite/gdb.mi/mi-simplerun.exp b/gdb/testsuite/gdb.mi/mi-simplerun.exp index 20a079ead896..ce19122803da 100644 --- a/gdb/testsuite/gdb.mi/mi-simplerun.exp +++ b/gdb/testsuite/gdb.mi/mi-simplerun.exp @@ -177,6 +177,11 @@ proc test_program_termination {} { # -exec-abort # (normal termination of inferior) + if ![exit_is_reliable] { + unsupported "Function exit() is not reliable on this board." + return + } + mi_execute_to "exec-continue" "exited-normally" "" "" "" "" "" "continue to end" }