aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib/modules.exp
blob: cba6341fdb3082928d59536f1d12bbba8e43750b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#   Copyright (C) 1997-2025 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3.  If not see
# <http://www.gnu.org/licenses/>.

# Verify various kinds of gcov output: line counts, branch percentages,
# and call return percentages.  None of this is language-specific.

load_lib "target-supports.exp"

#
# clean-p1689-file -- delete a working file the compiler creates for p1689
#
# TESTCASE is the name of the test.
# SUFFIX is file suffix

proc clean-p1689-file { testcase suffix } {
    set basename [file tail $testcase]
    set base [file rootname $basename]
    remote_file host delete $base.$suffix
}

#
# clean-p1689 -- delete the working files the compiler creates for p1689
#
# TESTCASE is the name of the test.
#
proc clean-p1689 { testcase } {
    clean-p1689-file $testcase "d"
    clean-p1689-file $testcase "ddi"
}

# Call by dg-final to check a P1689 dependency file

proc run-check-p1689-valid { depfile template } {
    global srcdir subdir
    # Extract the test file name from the arguments.
    set testcase [file rootname [file tail $depfile]]

    verbose "Running P1689 validation for $testcase in $srcdir/$subdir" 2
    set testcase [remote_download host $testcase]

    set pytest_script "test-p1689.py"
    if { ![check_effective_target_recent_python3] } {
      unsupported "$pytest_script python3 is missing"
      return
    }

    verbose "running script" 1
    spawn -noecho python3 $srcdir/$subdir/$pytest_script --all --actual $depfile --expect $srcdir/$subdir/$template

    expect {
      -re "ERROR: (\[^\r\n\]*)" {
       fail $expect_out(0,string)
       exp_continue
      }
    }

    clean-p1689 $testcase
}

proc run-check-module-dep { depfile flag expected } {
    global srcdir subdir
    # Extract the test file name from the arguments.
    set testcase [file rootname [file tail $depfile]]

    verbose "Verifying dependencies for $testcase in $srcdir/$subdir" 2
    set testcase [remote_download host $testcase]

    set pytest_script "test-depfile.py"
    if { ![check_effective_target_recent_python3] } {
      unsupported "$pytest_script python3 is missing"
      return
    }

    verbose "running script test-depfile.py" 1
    spawn -noecho python3 $srcdir/$subdir/$pytest_script --all --depfile $depfile $flag $expected

    expect {
      -re "ERROR: (\[^\r\n\]*)" {
       fail $expect_out(0,string)
       exp_continue
      }
    }
}

proc run-check-module-dep-expect-input { depfile expected } {
    run-check-module-dep $depfile "--expect-input" $expected
}