blob: 6f8df5b4fc4a62476032591bcbaf4c75a143ff3a (
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
#!/bin/bash
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
# apply eclass globals to test version parsing
TOOLCHAIN_GCC_PV=11.3.0
PR=r0
source tests-common.sh || exit
source version-funcs.sh || exit
EAPI=7 inherit toolchain
# Ignore actually running version of gcc and fake new version
# to force downgrade test on all conditions below.
gcc-version() {
echo "99.99"
}
test_downgrade_arch_flags() {
local exp msg ret=0 ver
ver=${1}
exp=${2}
shift 2
CFLAGS=${@}
tbegin "downgrade_arch_flags: ${ver} ${CFLAGS} => ${exp}"
CHOST=x86_64 # needed for tc-arch
downgrade_arch_flags ${ver}
if [[ ${CFLAGS} != ${exp} ]]; then
msg="Failure - Expected: \"${exp}\" Got: \"${CFLAGS}\" Ver: ${ver}"
ret=1
fi
tend ${ret} ${msg}
}
# ver expected given
test_downgrade_arch_flags 10 "-march=haswell" "-march=haswell"
test_downgrade_arch_flags 4.9 "-march=haswell" "-march=haswell"
test_downgrade_arch_flags 4.8 "-march=core-avx2" "-march=haswell"
test_downgrade_arch_flags 4.7 "-march=core-avx2" "-march=haswell"
test_downgrade_arch_flags 4.6 "-march=core-avx-i" "-march=haswell"
test_downgrade_arch_flags 4.5 "-march=core2" "-march=haswell"
test_downgrade_arch_flags 4.4 "-march=core2" "-march=haswell"
test_downgrade_arch_flags 4.3 "-march=core2" "-march=haswell"
test_downgrade_arch_flags 4.2 "-march=nocona" "-march=haswell"
test_downgrade_arch_flags 4.1 "-march=nocona" "-march=haswell"
test_downgrade_arch_flags 4.0 "-march=nocona" "-march=haswell"
test_downgrade_arch_flags 3.4 "-march=nocona" "-march=haswell"
test_downgrade_arch_flags 3.3 "-march=nocona" "-march=haswell"
test_downgrade_arch_flags 4.9 "-march=bdver4" "-march=bdver4"
test_downgrade_arch_flags 4.8 "-march=bdver3" "-march=bdver4"
test_downgrade_arch_flags 4.7 "-march=bdver2" "-march=bdver4"
test_downgrade_arch_flags 4.6 "-march=bdver1" "-march=bdver4"
test_downgrade_arch_flags 4.5 "-march=amdfam10" "-march=bdver4"
test_downgrade_arch_flags 4.4 "-march=amdfam10" "-march=bdver4"
test_downgrade_arch_flags 4.3 "-march=amdfam10" "-march=bdver4"
test_downgrade_arch_flags 4.2 "-march=k8" "-march=bdver4"
test_downgrade_arch_flags 4.1 "-march=k8" "-march=bdver4"
test_downgrade_arch_flags 4.0 "-march=k8" "-march=bdver4"
test_downgrade_arch_flags 3.4 "-march=k8" "-march=bdver4"
test_downgrade_arch_flags 3.3 "-march=x86-64" "-march=bdver4"
test_downgrade_arch_flags 3.4 "-march=c3-2" "-march=c3-2"
test_downgrade_arch_flags 3.3 "-march=c3" "-march=c3-2"
test_downgrade_arch_flags 4.5 "-march=garbage" "-march=garbage"
test_downgrade_arch_flags 10 "-mtune=intel" "-mtune=intel"
test_downgrade_arch_flags 4.9 "-mtune=intel" "-mtune=intel"
test_downgrade_arch_flags 4.8 "-mtune=generic" "-mtune=intel"
test_downgrade_arch_flags 3.4 "" "-mtune=generic"
test_downgrade_arch_flags 3.4 "" "-mtune=x86-64"
test_downgrade_arch_flags 3.3 "" "-mtune=anything"
test_downgrade_arch_flags 4.5 "-march=amdfam10 -mtune=generic" "-march=btver2 -mtune=generic"
test_downgrade_arch_flags 3.3 "-march=k6-2" "-march=geode -mtune=barcelona"
test_downgrade_arch_flags 3.4 "-march=k8" "-march=btver2 -mtune=generic"
test_downgrade_arch_flags 10 "-march=native" "-march=native"
test_downgrade_arch_flags 8 "-march=znver1" "-march=znver2"
test_downgrade_arch_flags 4.2 "-march=native" "-march=native"
test_downgrade_arch_flags 4.1 "-march=nocona" "-march=native"
test_downgrade_arch_flags 9 "-march=znver2" "-march=znver3"
test_downgrade_arch_flags 10 "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
test_downgrade_arch_flags 4.9 "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
test_downgrade_arch_flags 4.8 "-march=foo -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
test_downgrade_arch_flags 4.7 "-march=foo -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
test_downgrade_arch_flags 4.6 "-march=foo -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
test_downgrade_arch_flags 4.3 "-march=foo -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
test_downgrade_arch_flags 4.2 "-march=foo" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
test_downgrade_arch_flags 4.4 "-O2 -march=core2 -ffoo -fblah" "-O2 -march=atom -mno-sha -ffoo -mno-rtm -fblah"
# basic version parsing tests in preparation to eapi7-ver switch
test_tc_version_is_at_least() {
local exp msg ret=0 want mine res
want=${1}
mine=${2}
exp=${3}
tbegin "tc_version_is_at_least: ${want} ${mine} => ${exp}"
tc_version_is_at_least ${want} ${mine}
res=$?
if [[ ${res} -ne ${exp} ]]; then
msg="Failure - Expected: \"${exp}\" Got: \"${res}\""
ret=1
fi
tend ${ret} ${msg}
}
# want mine expect
test_tc_version_is_at_least 12 '' 1
test_tc_version_is_at_least 11.4 '' 1
test_tc_version_is_at_least 10 '' 0
test_tc_version_is_at_least 10 '' 0
test_tc_version_is_at_least ${TOOLCHAIN_GCC_PV} '' 0
test_tc_version_is_at_least 10 11 0
test_tc_version_is_between() {
local exp msg ret=0 lo hi res
lo=${1}
hi=${2}
exp=${3}
tbegin "tc_version_is_between: ${lo} ${hi} => ${exp}"
tc_version_is_between ${lo} ${hi}
res=$?
if [[ ${res} -ne ${exp} ]]; then
msg="Failure - Expected: \"${exp}\" Got: \"${res}\""
ret=1
fi
tend ${ret} ${msg}
}
# lo hi expect
test_tc_version_is_between 1 0 1
test_tc_version_is_between 1 2 1
test_tc_version_is_between 11 12 0
test_tc_version_is_between ${TOOLCHAIN_GCC_PV} 12 0
test_tc_version_is_between ${TOOLCHAIN_GCC_PV} ${TOOLCHAIN_GCC_PV} 1
test_tc_version_is_between 10 ${TOOLCHAIN_GCC_PV} 1
test_tc_version_is_between 12 13 1
# eclass has a few critical global variables worth not breaking
test_var_assert() {
local var_name exp
var_name=${1}
exp=${2}
tbegin "assert variable value: ${var_name} => ${exp}"
if [[ ${!var_name} != ${exp} ]]; then
msg="Failure - Expected: \"${exp}\" Got: \"${!var_name}\""
ret=1
fi
tend ${ret} ${msg}
}
# TODO: convert these globals to helpers to ease testing against multiple
# ${TOOLCHAIN_GCC_PV} vaues.
test_var_assert GCC_PV 11.3.0
test_var_assert GCC_PVR 11.3.0
test_var_assert GCC_RELEASE_VER 11.3.0
test_var_assert GCC_BRANCH_VER 11.3
test_var_assert GCCMAJOR 11
test_var_assert GCCMINOR 3
test_var_assert GCCMICRO 0
test_var_assert GCC_CONFIG_VER 11.3.0
test_var_assert PREFIX /usr
texit
|