| 1 |
# Copyright (C) 1997-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with GCC; see the file COPYING3. If not see |
| 15 |
# <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
# Verify various kinds of gcov output: line counts, branch percentages, |
| 18 |
# and call return percentages. None of this is language-specific. |
| 19 |
|
| 20 |
load_lib "target-supports.exp" |
| 21 |
|
| 22 |
# |
| 23 |
# clean-p1689-file -- delete a working file the compiler creates for p1689 |
| 24 |
# |
| 25 |
# TESTCASE is the name of the test. |
| 26 |
# SUFFIX is file suffix |
| 27 |
|
| 28 |
proc clean-p1689-file { testcase suffix } { |
| 29 |
set basename [file tail $testcase] |
| 30 |
set base [file rootname $basename] |
| 31 |
remote_file host delete $base.$suffix |
| 32 |
} |
| 33 |
|
| 34 |
# |
| 35 |
# clean-p1689 -- delete the working files the compiler creates for p1689 |
| 36 |
# |
| 37 |
# TESTCASE is the name of the test. |
| 38 |
# |
| 39 |
proc clean-p1689 { testcase } { |
| 40 |
clean-p1689-file $testcase "d" |
| 41 |
clean-p1689-file $testcase "ddi" |
| 42 |
} |
| 43 |
|
| 44 |
# Call by dg-final to check a P1689 dependency file |
| 45 |
|
| 46 |
proc run-check-p1689-valid { depfile template } { |
| 47 |
global srcdir subdir |
| 48 |
# Extract the test file name from the arguments. |
| 49 |
set testcase [file rootname [file tail $depfile]] |
| 50 |
|
| 51 |
verbose "Running P1689 validation for $testcase in $srcdir/$subdir" 2 |
| 52 |
set testcase [remote_download host $testcase] |
| 53 |
|
| 54 |
set pytest_script "test-p1689.py" |
| 55 |
if { ![check_effective_target_recent_python3] } { |
| 56 |
unsupported "$pytest_script python3 is missing" |
| 57 |
return |
| 58 |
} |
| 59 |
|
| 60 |
verbose "running script" 1 |
| 61 |
spawn -noecho python3 $srcdir/$subdir/$pytest_script --all --actual $depfile --expect $srcdir/$subdir/$template |
| 62 |
|
| 63 |
expect { |
| 64 |
-re "ERROR: (\[^\r\n\]*)" { |
| 65 |
fail $expect_out(0,string) |
| 66 |
exp_continue |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
clean-p1689 $testcase |
| 71 |
} |
| 72 |
|
| 73 |
proc run-check-module-dep { depfile flag expected } { |
| 74 |
global srcdir subdir |
| 75 |
# Extract the test file name from the arguments. |
| 76 |
set testcase [file rootname [file tail $depfile]] |
| 77 |
|
| 78 |
verbose "Verifying dependencies for $testcase in $srcdir/$subdir" 2 |
| 79 |
set testcase [remote_download host $testcase] |
| 80 |
|
| 81 |
set pytest_script "test-depfile.py" |
| 82 |
if { ![check_effective_target_recent_python3] } { |
| 83 |
unsupported "$pytest_script python3 is missing" |
| 84 |
return |
| 85 |
} |
| 86 |
|
| 87 |
verbose "running script test-depfile.py" 1 |
| 88 |
spawn -noecho python3 $srcdir/$subdir/$pytest_script --all --depfile $depfile $flag $expected |
| 89 |
|
| 90 |
expect { |
| 91 |
-re "ERROR: (\[^\r\n\]*)" { |
| 92 |
fail $expect_out(0,string) |
| 93 |
exp_continue |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
proc run-check-module-dep-expect-input { depfile expected } { |
| 99 |
run-check-module-dep $depfile "--expect-input" $expected |
| 100 |
} |