From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7897) id 6F9D43852219; Fri, 18 Nov 2022 10:31:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F9D43852219 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668767510; bh=skjbIFlkhZwjgwPe0cpGyBC2GKEqKg1AuhJ1oL5lzhk=; h=From:To:Subject:Date:From; b=kFVS6SkxD0zs0hcTXhzRCaJ+ezJf3fQEqi5q5NGe5OUgW9fllxzIXBTreQlFvE1+C emXmd8Je+LqHOLwEAzlODHyMenUrk1KoGCCmbVu/OeY7Wkr5xll8kuQ3UUGkumAmkg xbyxK1xRSw4lzWJDnMD3EoA789hWBwzA7PjL6ogM= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Torbjorn Svensson To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4140] testsuite: Verify that module-mapper is available X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= X-Git-Refname: refs/heads/master X-Git-Oldrev: 33de7b37463fd3b846f76e86ed55aaa46870f92e X-Git-Newrev: 20d2a8c24f3ca487ffd35fefcc9b1562bb10b609 Message-Id: <20221118103150.6F9D43852219@sourceware.org> Date: Fri, 18 Nov 2022 10:31:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:20d2a8c24f3ca487ffd35fefcc9b1562bb10b609 commit r13-4140-g20d2a8c24f3ca487ffd35fefcc9b1562bb10b609 Author: Torbjörn SVENSSON Date: Thu Sep 22 22:14:24 2022 +0200 testsuite: Verify that module-mapper is available For some test cases, it's required that the optional module mapper "g++-mapper-server" is built. As the server is not required, the test cases will fail if it can't be found. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_is_prog_name_available): New. * lib/target-supports-dg.exp (dg-require-prog-name-available): New. * g++.dg/modules/modules.exp: Verify avilability of module mapper. Signed-off-by: Torbjörn SVENSSON Diff: --- gcc/testsuite/g++.dg/modules/modules.exp | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/lib/target-supports-dg.exp | 15 +++++++++++++++ gcc/testsuite/lib/target-supports.exp | 15 +++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/gcc/testsuite/g++.dg/modules/modules.exp b/gcc/testsuite/g++.dg/modules/modules.exp index afb323d0efd..4784803742a 100644 --- a/gcc/testsuite/g++.dg/modules/modules.exp +++ b/gcc/testsuite/g++.dg/modules/modules.exp @@ -279,6 +279,29 @@ proc module-init { src } { return $option_list } +# Return 1 if requirements are met +proc module-check-requirements { tests } { + foreach test $tests { + set tmp [dg-get-options $test] + foreach op $tmp { + switch [lindex $op 0] { + "dg-additional-options" { + # Example strings to match: + # -fmodules-ts -fmodule-mapper=|@g++-mapper-server\\ -t\\ [srcdir]/inc-xlate-1.map + # -fmodules-ts -fmodule-mapper=|@g++-mapper-server + if [regexp -- {(^| )-fmodule-mapper=\|@([^\\ ]*)} [lindex $op 2] dummy dummy2 prog] { + verbose "Checking that mapper exist: $prog" + if { ![ check_is_prog_name_available $prog ] } { + return 0 + } + } + } + } + } + } + return 1 +} + # cleanup any detritus from previous run cleanup_module_files [find $DEFAULT_REPO *.gcm] @@ -307,6 +330,14 @@ foreach src [lsort [find $srcdir/$subdir {*_a.[CHX}]] { set tests [lsort [find [file dirname $src] \ [regsub {_a.[CHX]$} [file tail $src] {_[a-z].[CHX]}]]] + if { ![module-check-requirements $tests] } { + set testcase [regsub {_a.[CH]} $src {}] + set testcase \ + [string range $testcase [string length "$srcdir/"] end] + unsupported $testcase + continue + } + set std_list [module-init $src] foreach std $std_list { set mod_files {} diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp index aa2164bc789..6ce3b2b1a1b 100644 --- a/gcc/testsuite/lib/target-supports-dg.exp +++ b/gcc/testsuite/lib/target-supports-dg.exp @@ -683,3 +683,18 @@ proc dg-require-symver { args } { set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] } } + +# If this target does not provide prog named "$args", skip this test. + +proc dg-require-prog-name-available { args } { + # The args are within another list; pull them out. + set args [lindex $args 0] + + set prog [lindex $args 1] + + if { ![ check_is_prog_name_available $prog ] } { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + } +} + diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index c7f583d6d14..01cf17ea44a 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -12157,3 +12157,18 @@ main: .byte 0 } ""] } + +# Return 1 if this target has prog named "$prog", 0 otherwise. + +proc check_is_prog_name_available { prog } { + global tool + + set options [list "additional_flags=-print-prog-name=$prog"] + set output [lindex [${tool}_target_compile "" "" "none" $options] 0] + + if { $output == $prog } { + return 0 + } + + return 1 +}