46
46
print_targets=0
47
47
48
48
while getopts " p" arg; do
49
- case $arg in
50
- p)
49
+ case $arg in
50
+ p)
51
51
print_targets=1
52
52
shift ;;
53
- esac
53
+ esac
54
54
done
55
55
56
56
if [ $# -eq 0 ]
@@ -92,6 +92,10 @@ pass_cnt=0
92
92
# Get all TARGETS from selftests Makefile
93
93
targets=$( grep -E " ^TARGETS +|^TARGETS =" Makefile | cut -d " =" -f2)
94
94
95
+ # Initially, in LDLIBS related lines, the dep checker needs
96
+ # to ignore lines containing the following strings:
97
+ filter=" \$ (VAR_LDLIBS)\|pkg-config\|PKG_CONFIG\|IOURING_EXTRA_LIBS"
98
+
95
99
# Single test case
96
100
if [ $# -eq 2 ]
97
101
then
100
104
l1_test $test
101
105
l2_test $test
102
106
l3_test $test
107
+ l4_test $test
108
+ l5_test $test
103
109
104
110
print_results $1 $2
105
111
exit $?
113
119
# Append space at the end of the list to append more tests.
114
120
115
121
l1_tests=$( grep -r --include=Makefile " ^LDLIBS" | \
116
- grep -v " VAR_LDLIBS " | awk -F: ' {print $1}' )
122
+ grep -v " $filter " | awk -F: ' {print $1}' | uniq )
117
123
118
124
# Level 2: LDLIBS set dynamically.
119
125
#
@@ -126,7 +132,7 @@ l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \
126
132
# Append space at the end of the list to append more tests.
127
133
128
134
l2_tests=$( grep -r --include=Makefile " : LDLIBS" | \
129
- grep -v " VAR_LDLIBS " | awk -F: ' {print $1}' )
135
+ grep -v " $filter " | awk -F: ' {print $1}' | uniq )
130
136
131
137
# Level 3
132
138
# memfd and others use pkg-config to find mount and fuse libs
@@ -138,11 +144,32 @@ l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \
138
144
# VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null)
139
145
140
146
l3_tests=$( grep -r --include=Makefile " ^VAR_LDLIBS" | \
141
- grep -v " pkg-config" | awk -F: ' {print $1}' )
147
+ grep -v " pkg-config\|PKG_CONFIG " | awk -F: ' {print $1}' | uniq )
142
148
143
- # echo $l1_tests
144
- # echo $l2_1_tests
145
- # echo $l3_tests
149
+ # Level 4
150
+ # some tests may fall back to default using `|| echo -l<libname>`
151
+ # if pkg-config doesn't find the libs, instead of using VAR_LDLIBS
152
+ # as per level 3 checks.
153
+ # e.g:
154
+ # netfilter/Makefile
155
+ # LDLIBS += $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl)
156
+ l4_tests=$( grep -r --include=Makefile " ^LDLIBS" | \
157
+ grep " pkg-config\|PKG_CONFIG" | awk -F: ' {print $1}' | uniq)
158
+
159
+ # Level 5
160
+ # some tests may use IOURING_EXTRA_LIBS to add extra libs to LDLIBS,
161
+ # which in turn may be defined in a sub-Makefile
162
+ # e.g.:
163
+ # mm/Makefile
164
+ # $(OUTPUT)/gup_longterm: LDLIBS += $(IOURING_EXTRA_LIBS)
165
+ l5_tests=$( grep -r --include=Makefile " LDLIBS +=.*\$ (IOURING_EXTRA_LIBS)" | \
166
+ awk -F: ' {print $1}' | uniq)
167
+
168
+ # echo l1_tests $l1_tests
169
+ # echo l2_tests $l2_tests
170
+ # echo l3_tests $l3_tests
171
+ # echo l4_tests $l4_tests
172
+ # echo l5_tests $l5_tests
146
173
147
174
all_tests
148
175
print_results $1 $2
@@ -164,24 +191,32 @@ all_tests()
164
191
for test in $l3_tests ; do
165
192
l3_test $test
166
193
done
194
+
195
+ for test in $l4_tests ; do
196
+ l4_test $test
197
+ done
198
+
199
+ for test in $l5_tests ; do
200
+ l5_test $test
201
+ done
167
202
}
168
203
169
204
# Use same parsing used for l1_tests and pick libraries this time.
170
205
l1_test ()
171
206
{
172
207
test_libs=$( grep --include=Makefile " ^LDLIBS" $test | \
173
- grep -v " VAR_LDLIBS " | \
208
+ grep -v " $filter " | \
174
209
sed -e ' s/\:/ /' | \
175
210
sed -e ' s/+/ /' | cut -d " =" -f 2)
176
211
177
212
check_libs $test $test_libs
178
213
}
179
214
180
- # Use same parsing used for l2__tests and pick libraries this time.
215
+ # Use same parsing used for l2_tests and pick libraries this time.
181
216
l2_test ()
182
217
{
183
218
test_libs=$( grep --include=Makefile " : LDLIBS" $test | \
184
- grep -v " VAR_LDLIBS " | \
219
+ grep -v " $filter " | \
185
220
sed -e ' s/\:/ /' | sed -e ' s/+/ /' | \
186
221
cut -d " =" -f 2)
187
222
@@ -197,6 +232,24 @@ l3_test()
197
232
check_libs $test $test_libs
198
233
}
199
234
235
+ l4_test ()
236
+ {
237
+ test_libs=$( grep --include=Makefile " ^VAR_LDLIBS\|^LDLIBS" $test | \
238
+ grep " \(pkg-config\|PKG_CONFIG\).*|| echo " | \
239
+ sed -e ' s/.*|| echo //' | sed -e ' s/)$//' )
240
+
241
+ check_libs $test $test_libs
242
+ }
243
+
244
+ l5_test ()
245
+ {
246
+ tests=$( find $( dirname " $test " ) -type f -name " *.mk" )
247
+ test_libs=$( grep " ^IOURING_EXTRA_LIBS +\?=" $tests | \
248
+ cut -d " =" -f 2)
249
+
250
+ check_libs $test $test_libs
251
+ }
252
+
200
253
check_libs ()
201
254
{
202
255
0 commit comments