| .. | .. |
|---|
| 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 | 92 | # Get all TARGETS from selftests Makefile |
|---|
| 93 | 93 | targets=$(egrep "^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 | 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 | # gpio, memfd and others use pkg-config to find mount and fuse libs |
|---|
| .. | .. |
|---|
| 140 | 146 | # VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null) |
|---|
| 141 | 147 | |
|---|
| 142 | 148 | l3_tests=$(grep -r --include=Makefile "^VAR_LDLIBS" | \ |
|---|
| 143 | | - grep -v "pkg-config" | awk -F: '{print $1}') |
|---|
| 149 | + grep -v "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq) |
|---|
| 144 | 150 | |
|---|
| 145 | | -#echo $l1_tests |
|---|
| 146 | | -#echo $l2_1_tests |
|---|
| 147 | | -#echo $l3_tests |
|---|
| 151 | +# Level 4 |
|---|
| 152 | +# some tests may fall back to default using `|| echo -l<libname>` |
|---|
| 153 | +# if pkg-config doesn't find the libs, instead of using VAR_LDLIBS |
|---|
| 154 | +# as per level 3 checks. |
|---|
| 155 | +# e.g: |
|---|
| 156 | +# netfilter/Makefile |
|---|
| 157 | +# LDLIBS += $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl) |
|---|
| 158 | +l4_tests=$(grep -r --include=Makefile "^LDLIBS" | \ |
|---|
| 159 | + grep "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq) |
|---|
| 160 | + |
|---|
| 161 | +# Level 5 |
|---|
| 162 | +# some tests may use IOURING_EXTRA_LIBS to add extra libs to LDLIBS, |
|---|
| 163 | +# which in turn may be defined in a sub-Makefile |
|---|
| 164 | +# e.g.: |
|---|
| 165 | +# mm/Makefile |
|---|
| 166 | +# $(OUTPUT)/gup_longterm: LDLIBS += $(IOURING_EXTRA_LIBS) |
|---|
| 167 | +l5_tests=$(grep -r --include=Makefile "LDLIBS +=.*\$(IOURING_EXTRA_LIBS)" | \ |
|---|
| 168 | + awk -F: '{print $1}' | uniq) |
|---|
| 169 | + |
|---|
| 170 | +#echo l1_tests $l1_tests |
|---|
| 171 | +#echo l2_tests $l2_tests |
|---|
| 172 | +#echo l3_tests $l3_tests |
|---|
| 173 | +#echo l4_tests $l4_tests |
|---|
| 174 | +#echo l5_tests $l5_tests |
|---|
| 148 | 175 | |
|---|
| 149 | 176 | all_tests |
|---|
| 150 | 177 | print_results $1 $2 |
|---|
| .. | .. |
|---|
| 166 | 193 | for test in $l3_tests; do |
|---|
| 167 | 194 | l3_test $test |
|---|
| 168 | 195 | done |
|---|
| 196 | + |
|---|
| 197 | + for test in $l4_tests; do |
|---|
| 198 | + l4_test $test |
|---|
| 199 | + done |
|---|
| 200 | + |
|---|
| 201 | + for test in $l5_tests; do |
|---|
| 202 | + l5_test $test |
|---|
| 203 | + done |
|---|
| 169 | 204 | } |
|---|
| 170 | 205 | |
|---|
| 171 | 206 | # Use same parsing used for l1_tests and pick libraries this time. |
|---|
| 172 | 207 | l1_test() |
|---|
| 173 | 208 | { |
|---|
| 174 | 209 | test_libs=$(grep --include=Makefile "^LDLIBS" $test | \ |
|---|
| 175 | | - grep -v "VAR_LDLIBS" | \ |
|---|
| 210 | + grep -v "$filter" | \ |
|---|
| 176 | 211 | sed -e 's/\:/ /' | \ |
|---|
| 177 | 212 | sed -e 's/+/ /' | cut -d "=" -f 2) |
|---|
| 178 | 213 | |
|---|
| 179 | 214 | check_libs $test $test_libs |
|---|
| 180 | 215 | } |
|---|
| 181 | 216 | |
|---|
| 182 | | -# Use same parsing used for l2__tests and pick libraries this time. |
|---|
| 217 | +# Use same parsing used for l2_tests and pick libraries this time. |
|---|
| 183 | 218 | l2_test() |
|---|
| 184 | 219 | { |
|---|
| 185 | 220 | test_libs=$(grep --include=Makefile ": LDLIBS" $test | \ |
|---|
| 186 | | - grep -v "VAR_LDLIBS" | \ |
|---|
| 221 | + grep -v "$filter" | \ |
|---|
| 187 | 222 | sed -e 's/\:/ /' | sed -e 's/+/ /' | \ |
|---|
| 188 | 223 | cut -d "=" -f 2) |
|---|
| 189 | 224 | |
|---|
| .. | .. |
|---|
| 199 | 234 | check_libs $test $test_libs |
|---|
| 200 | 235 | } |
|---|
| 201 | 236 | |
|---|
| 237 | +l4_test() |
|---|
| 238 | +{ |
|---|
| 239 | + test_libs=$(grep --include=Makefile "^VAR_LDLIBS\|^LDLIBS" $test | \ |
|---|
| 240 | + grep "\(pkg-config\|PKG_CONFIG\).*|| echo " | \ |
|---|
| 241 | + sed -e 's/.*|| echo //' | sed -e 's/)$//') |
|---|
| 242 | + |
|---|
| 243 | + check_libs $test $test_libs |
|---|
| 244 | +} |
|---|
| 245 | + |
|---|
| 246 | +l5_test() |
|---|
| 247 | +{ |
|---|
| 248 | + tests=$(find $(dirname "$test") -type f -name "*.mk") |
|---|
| 249 | + test_libs=$(grep "^IOURING_EXTRA_LIBS +\?=" $tests | \ |
|---|
| 250 | + cut -d "=" -f 2) |
|---|
| 251 | + |
|---|
| 252 | + check_libs $test $test_libs |
|---|
| 253 | +} |
|---|
| 254 | + |
|---|
| 202 | 255 | check_libs() |
|---|
| 203 | 256 | { |
|---|
| 204 | 257 | |
|---|