| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# testsuite to test pbuilder-satisfydepends-funcs. |
| 4 |
|
| 5 |
TD="$(dirname "$0")" |
| 6 |
. "$TD/testlib.sh" |
| 7 |
if [ -n "$PBUILDER_CHECKOUT" ]; then |
| 8 |
. "$PBUILDER_CHECKOUT/pbuilder-satisfydepends-funcs" |
| 9 |
else |
| 10 |
. "$PBUILDER_TEST_PKGLIBDIR/pbuilder-satisfydepends-funcs" |
| 11 |
fi |
| 12 |
|
| 13 |
DEBIAN_CONTROL="" |
| 14 |
|
| 15 |
cleanup() { |
| 16 |
if [ -n "$DEBIAN_CONTROL" ]; then |
| 17 |
rm -f "$DEBIAN_CONTROL" |
| 18 |
fi |
| 19 |
} |
| 20 |
|
| 21 |
test_get_build_deps() { |
| 22 |
local BINARY_ARCH |
| 23 |
|
| 24 |
BINARY_ARCH="$1" |
| 25 |
|
| 26 |
cat <<EOF >"$DEBIAN_CONTROL" |
| 27 |
Source: amule |
| 28 |
XXXX: |
| 29 |
Build-Depends: |
| 30 |
autotools-dev ( >= 1.2 ) , |
| 31 |
debhelper , |
| 32 |
quilt(<<12:0), |
| 33 |
## |
| 34 |
libwxgtk2.8-dev |
| 35 |
Build-Depends-Indep: test [ amd64 i386 ], test1, |
| 36 |
test2[!i386 ! amd64], test3 | |
| 37 |
test4, test5 |
| 38 |
Misc: test |
| 39 |
Build-Depends-Arch: foo1, foo2 , foo3 (<< 12.23.34-5), |
| 40 |
bar4 [!amd64] <notest>, foobar [i386], gnagna [ !s390x ] |
| 41 |
|
| 42 |
Build-Depends: wrong build depends, line |
| 43 |
Description: test |
| 44 |
other things |
| 45 |
wow |
| 46 |
# EOL comment |
| 47 |
EOF |
| 48 |
get_build_deps |
| 49 |
} |
| 50 |
|
| 51 |
test_get_build_deps_source_para_only() { |
| 52 |
local BINARY_ARCH="$1" |
| 53 |
cat <<EOF >"$DEBIAN_CONTROL" |
| 54 |
Source: foo |
| 55 |
Build-Depends: bar |
| 56 |
EOF |
| 57 |
get_build_deps |
| 58 |
} |
| 59 |
|
| 60 |
test_get_build_deps_comment_between_lines() { |
| 61 |
local BINARY_ARCH="$1" |
| 62 |
cat <<EOF >"$DEBIAN_CONTROL" |
| 63 |
Source: foo |
| 64 |
# foo |
| 65 |
Build-Depends: bar |
| 66 |
EOF |
| 67 |
get_build_deps |
| 68 |
} |
| 69 |
|
| 70 |
test_get_build_deps_one_line_preceding_comment() { |
| 71 |
local BINARY_ARCH="all" |
| 72 |
cat << EOF >"$DEBIAN_CONTROL" |
| 73 |
# Preceding comment |
| 74 |
Build-Depends: blabla |
| 75 |
EOF |
| 76 |
get_build_deps |
| 77 |
} |
| 78 |
|
| 79 |
test_get_build_deps_one_line_trailing_comment() { |
| 80 |
local BINARY_ARCH="all" |
| 81 |
cat << EOF >"$DEBIAN_CONTROL" |
| 82 |
Build-Depends: blabla |
| 83 |
# EOL comment |
| 84 |
EOF |
| 85 |
get_build_deps |
| 86 |
} |
| 87 |
|
| 88 |
test_get_build_deps_one_line_preceding_blank() { |
| 89 |
local BINARY_ARCH="all" |
| 90 |
cat << EOF >"$DEBIAN_CONTROL" |
| 91 |
|
| 92 |
Build-Depends: blabla |
| 93 |
EOF |
| 94 |
get_build_deps |
| 95 |
} |
| 96 |
|
| 97 |
test_get_build_deps_dsc() { |
| 98 |
cat <<EOF >"$DEBIAN_CONTROL" |
| 99 |
-----BEGIN PGP SIGNED MESSAGE----- |
| 100 |
Hash: SHA256 |
| 101 |
|
| 102 |
Format: 1.0 |
| 103 |
Source: hello-debhelper |
| 104 |
Build-Depends: debhelper (>= 7) |
| 105 |
Checksums-Sha1: |
| 106 |
fcbf0264928900adf03a7797474375e1a6fa3836 499638 hello-debhelper_2.4.orig.tar.gz |
| 107 |
0ea70eb46b4c90a8dbefbe60bebe4b9f9abb2733 5308 hello-debhelper_2.4-3.diff.gz |
| 108 |
|
| 109 |
|
| 110 |
-----BEGIN PGP SIGNATURE----- |
| 111 |
Version: GnuPG v1.4.9 (GNU/Linux) |
| 112 |
|
| 113 |
iQEcBAEBCAAGBQJKml74AAoJEEHOfwufG4sysC4H/26EikyIgIqRuSXMiykc1hmd |
| 114 |
97id9nWl+QzgCpUEg/+uDqEW+Bl6291FstGvzTFCwmB5JjH9ErH1LsyG1OLXbFUb |
| 115 |
H89Em7qkl4o2ACTh255oM7FhVweof3UEaLCZMH+HZVVpHXNpEnhrfDvpTBbPGjUi |
| 116 |
-----END PGP SIGNATURE----- |
| 117 |
EOF |
| 118 |
get_build_deps |
| 119 |
} |
| 120 |
|
| 121 |
test_get_parsed_build_deps_dsc() { |
| 122 |
local ARCH="amd64" |
| 123 |
local BINARY_ARCH="any" |
| 124 |
|
| 125 |
cat "$TESTDATA_DIR/dsc1" > "$DEBIAN_CONTROL" |
| 126 |
get_build_deps | filter_arch_deps "$ARCH" | filter_restriction_deps "$DEB_BUILD_PROFILES" |
| 127 |
} |
| 128 |
|
| 129 |
test_get_source_control_field_with_comments() { |
| 130 |
cat <<EOF >"$DEBIAN_CONTROL" |
| 131 |
# This is a comment |
| 132 |
|
| 133 |
# So is this, but with a blank line above me |
| 134 |
Format: 1.0 |
| 135 |
Source: something-funny |
| 136 |
Build-Depends: debhelper, something-else |
| 137 |
|
| 138 |
EOF |
| 139 |
get_source_control_field "Source" |
| 140 |
} |
| 141 |
|
| 142 |
trap cleanup sigpipe sighup exit |
| 143 |
|
| 144 |
# TODO move to build dir |
| 145 |
DEBIAN_CONTROL="$(mktemp)" |
| 146 |
|
| 147 |
expect_output "autotools-dev (>= 1.2), debhelper, quilt (<< 12:0), libwxgtk2.8-dev, test [amd64 i386], test1, test2 [!i386 !amd64], test3 | test4, test5, foo1, foo2, foo3 (<< 12.23.34-5), bar4 [!amd64] <notest>, foobar [i386], gnagna [!s390x]" \ |
| 148 |
test_get_build_deps "any" |
| 149 |
expect_output "autotools-dev (>= 1.2), debhelper, quilt (<< 12:0), libwxgtk2.8-dev, foo1, foo2, foo3 (<< 12.23.34-5), bar4 [!amd64] <notest>, foobar [i386], gnagna [!s390x]" \ |
| 150 |
test_get_build_deps "binary" |
| 151 |
expect_output "autotools-dev (>= 1.2), debhelper, quilt (<< 12:0), libwxgtk2.8-dev, test [amd64 i386], test1, test2 [!i386 !amd64], test3 | test4, test5" \ |
| 152 |
test_get_build_deps "all" |
| 153 |
expect_output "bar" test_get_build_deps_source_para_only "any" |
| 154 |
expect_output "bar" test_get_build_deps_comment_between_lines "any" |
| 155 |
expect_output "blabla" test_get_build_deps_one_line_preceding_comment |
| 156 |
expect_output "blabla" test_get_build_deps_one_line_trailing_comment |
| 157 |
expect_output "blabla" test_get_build_deps_one_line_preceding_blank |
| 158 |
|
| 159 |
|
| 160 |
# return FALSE on INSTALL |
| 161 |
expect_fail checkbuilddep_archdeps "foo [amd64]" "amd64" |
| 162 |
expect_success checkbuilddep_archdeps "foo [i386]" "amd64" |
| 163 |
expect_fail checkbuilddep_archdeps "foo [i386 amd64]" "amd64" |
| 164 |
expect_success checkbuilddep_archdeps "foo [!amd64]" "amd64" |
| 165 |
expect_success checkbuilddep_archdeps "foo [!i386 !amd64]" "amd64" |
| 166 |
# the -classic satisfydep does odd bash-y things, and changes all spaces to / |
| 167 |
# so it can then more easily iterate over the , |
| 168 |
expect_success checkbuilddep_archdeps "foo/[ia64/arm]" "armhf" |
| 169 |
expect_fail checkbuilddep_archdeps "foo/[!i386/!x32]" "amd64" |
| 170 |
|
| 171 |
test_filter_arch_deps() { |
| 172 |
echo "$1" | filter_arch_deps "$2" |
| 173 |
} |
| 174 |
|
| 175 |
expect_output "foo" test_filter_arch_deps "foo" "amd64" |
| 176 |
expect_output "foo" test_filter_arch_deps "foo [amd64]" "amd64" |
| 177 |
expect_output "bar, foo" test_filter_arch_deps "bar, foo [amd64]" "amd64" |
| 178 |
expect_output "bar | foo" test_filter_arch_deps "bar | foo [amd64]" "amd64" |
| 179 |
expect_output "bar" test_filter_arch_deps "bar | foo [amd64]" "i386" |
| 180 |
|
| 181 |
expect_fail checkbuilddep_restrictiondeps "foo <!stage1>" "" |
| 182 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1>" "stage1" |
| 183 |
expect_fail checkbuilddep_restrictiondeps "foo <!stage1>" "notest" |
| 184 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1>" "stage1 notest" |
| 185 |
|
| 186 |
expect_success checkbuilddep_restrictiondeps "foo <stage1>" "" |
| 187 |
expect_fail checkbuilddep_restrictiondeps "foo <stage1>" "stage1" |
| 188 |
expect_success checkbuilddep_restrictiondeps "foo <stage1>" "notest" |
| 189 |
expect_fail checkbuilddep_restrictiondeps "foo <stage1>" "stage1 notest" |
| 190 |
|
| 191 |
expect_fail checkbuilddep_restrictiondeps "foo <!stage1 !notest>" "" |
| 192 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1 !notest>" "stage1" |
| 193 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1 !notest>" "notest" |
| 194 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1 !notest>" "stage1 notest" |
| 195 |
|
| 196 |
expect_success checkbuilddep_restrictiondeps "foo <stage1 notest>" "" |
| 197 |
expect_success checkbuilddep_restrictiondeps "foo <stage1 notest>" "stage1" |
| 198 |
expect_success checkbuilddep_restrictiondeps "foo <stage1 notest>" "notest" |
| 199 |
expect_fail checkbuilddep_restrictiondeps "foo <stage1 notest>" "stage1 notest" |
| 200 |
|
| 201 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1 notest>" "" |
| 202 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1 notest>" "stage1" |
| 203 |
expect_fail checkbuilddep_restrictiondeps "foo <!stage1 notest>" "notest" |
| 204 |
expect_success checkbuilddep_restrictiondeps "foo <!stage1 notest>" "stage1 notest" |
| 205 |
# the -classic satisfydep does odd bash-y things, and changes all spaces to / |
| 206 |
# so it can then more easily iterate over the , |
| 207 |
expect_success checkbuilddep_restrictiondeps "foo/<!stage1/notest>" "" |
| 208 |
expect_success checkbuilddep_restrictiondeps "foo/<!stage1/notest>" "stage1" |
| 209 |
expect_fail checkbuilddep_restrictiondeps "foo/<!stage1/notest>" "notest" |
| 210 |
expect_success checkbuilddep_restrictiondeps "foo/<!stage1/notest>" "stage1 notest" |
| 211 |
|
| 212 |
expect_success checkbuilddep_restrictiondeps "foo <stage1 !notest>" "" |
| 213 |
expect_fail checkbuilddep_restrictiondeps "foo <stage1 !notest>" "stage1" |
| 214 |
expect_success checkbuilddep_restrictiondeps "foo <stage1 !notest>" "notest" |
| 215 |
expect_success checkbuilddep_restrictiondeps "foo <stage1 !notest>" "stage1 notest" |
| 216 |
|
| 217 |
test_filter_restriction_deps() { |
| 218 |
echo "$1" | filter_restriction_deps "$2" |
| 219 |
} |
| 220 |
|
| 221 |
expect_output "foo" test_filter_restriction_deps "foo <!stage1>" "" |
| 222 |
expect_output "" test_filter_restriction_deps "foo <!stage1>" "stage1" |
| 223 |
expect_output "foo" test_filter_restriction_deps "foo <stage1>" "stage1" |
| 224 |
expect_output "bar, foo" test_filter_restriction_deps "bar, foo <stage1>" "stage1" |
| 225 |
expect_output "bar | foo" test_filter_restriction_deps "bar | foo <stage1>" "stage1" |
| 226 |
expect_output "bar" test_filter_restriction_deps "bar | foo <!stage1>" "stage1" |
| 227 |
expect_output "foo" test_filter_restriction_deps "foo <a> <b>" "a" |
| 228 |
expect_output "foo" test_filter_restriction_deps "foo <a> <b>" "b" |
| 229 |
expect_output "foo" test_filter_restriction_deps "foo <!a> <!b>" "a" |
| 230 |
expect_output "foo" test_filter_restriction_deps "foo <!a> <!b>" "b" |
| 231 |
expect_output "" test_filter_restriction_deps "foo <a b>" "a" |
| 232 |
expect_output "" test_filter_restriction_deps "foo <a b>" "b" |
| 233 |
expect_output "" test_filter_restriction_deps "foo <!a !b>" "a" |
| 234 |
expect_output "" test_filter_restriction_deps "foo <!a !b>" "b" |
| 235 |
expect_output "" test_filter_restriction_deps "foo <!a !b>" "a b" |
| 236 |
expect_output "foo" test_filter_restriction_deps "foo <a b>" "a b" |
| 237 |
expect_output "foo" test_filter_restriction_deps "foo <a b>" "b a" |
| 238 |
|
| 239 |
test_filter_arch_restriction_deps() { |
| 240 |
echo "$1" | filter_arch_deps "$2" | filter_restriction_deps "$3" |
| 241 |
} |
| 242 |
|
| 243 |
expect_output "foo" test_filter_arch_restriction_deps "foo [amd64] <!stage1>" "amd64" "" |
| 244 |
expect_output "" test_filter_arch_restriction_deps "foo [amd64] <stage1>" "amd64" "" |
| 245 |
expect_output "foo" test_filter_arch_restriction_deps "foo [amd64] <!stage1>" "amd64" "" |
| 246 |
expect_output "" test_filter_arch_restriction_deps "foo [i386] <stage1>" "amd64" "stage1" |
| 247 |
|
| 248 |
test_filter_version_restriction_deps() { |
| 249 |
echo "$1" | filter_restriction_deps "$2" |
| 250 |
} |
| 251 |
|
| 252 |
# just to make sure the build profile parser doesn't trip over << |
| 253 |
expect_output "foo (<< 2:8)" test_filter_version_restriction_deps "foo (<< 2:8)" "whatever" |
| 254 |
expect_output "foo (<< 2:8)" test_filter_version_restriction_deps "foo (<< 2:8) <!a> <!b>" "" |
| 255 |
expect_output "" test_filter_version_restriction_deps "foo (<< 2:8) <!a !b>" "b" |
| 256 |
expect_output "foo (<< 2:8)" test_filter_version_restriction_deps "foo (<< 2:8) <!a> <!b>" "b" |
| 257 |
expect_output "" test_filter_version_restriction_deps "foo (<< 2:8) <!a> <!b>" "a b" |
| 258 |
|
| 259 |
expect_output "debhelper (>= 7)" test_get_build_deps_dsc |
| 260 |
expect_output "debhelper (>= 9), haskell-devscripts (>= 0.8.15), cdbs, ghc, ghc-prof, libghc-hashable-dev (<< 1.3), libghc-hashable-prof (<< 1.3), ghc-doc, libghc-hashable-doc (<< 1.3)" test_get_parsed_build_deps_dsc |
| 261 |
|
| 262 |
expect_output "something-funny" test_get_source_control_field_with_comments |
| 263 |
|
| 264 |
testlib_summary |