From 7850874b1ef1b18de585be108e3be899d95a3a2a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 18 Jun 2014 12:07:09 -0400 Subject: Fix quoting around variables, especially arrays. Other than pure quoting, this involved: - swapping */@ for array access in a few places - fiddling with printf in a pipeline - replacing `$(echo ${array[@]})` with `${array[*]}` - replacing `echo $(...)` with `...` When searching for these things, I used the command: grep -Prn --exclude-dir=.git '(?/dev/null 2>&1 && fail "db-update should fail when a split package is missing!" - for arch in ${arches[@]}; do + for arch in "${arches[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" done } -- cgit v1.2.3-54-g00ecf From db673811e674dc246fefa432d205f67ef3c56dbc Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 17 May 2015 18:02:50 -0400 Subject: test/: Make which architectures to build for configurable. --- config.testing | 5 +++++ test/lib/common.inc | 16 ++++++++++------ test/test.d/create-filelists.sh | 20 ++++++++------------ test/test.d/db-move.sh | 22 +++++++++------------- test/test.d/db-remove.sh | 14 ++++++-------- test/test.d/db-repo-add.sh | 10 ++++------ test/test.d/db-repo-remove.sh | 14 ++++++-------- test/test.d/db-update.sh | 15 ++++++--------- test/test.d/ftpdir-cleanup.sh | 21 +++++++++------------ test/test.d/sourceballs.sh | 11 ++++------- 10 files changed, 67 insertions(+), 81 deletions(-) (limited to 'test/test.d/db-update.sh') diff --git a/config.testing b/config.testing index a7ec4d1..24c2283 100644 --- a/config.testing +++ b/config.testing @@ -1,5 +1,10 @@ #!/hint/bash +# The host architecture +ARCH_HOST=$(uname -m) +# Which architectures should we test building for? +ARCH_BUILD=("$ARCH_HOST"); if [[ $ARCH_HOST == x86_64 ]]; then ARCH_BUILD+=("i686"); fi + # override the default TMPDIR [[ -n $MASTER_TMPDIR ]] || export MASTER_TMPDIR="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" TMPDIR=$MASTER_TMPDIR diff --git a/test/lib/common.inc b/test/lib/common.inc index 9a7e4d9..5b06616 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -48,13 +48,17 @@ oneTimeSetUp() { sudo extra-x86_64-build || die 'extra-x86_64-build failed' else for a in "${pkgarch[@]}"; do - sudo "extra-${a}-build" || die "extra-${a}-build failed" + if in_array "$a" "${ARCH_BUILD[@]}"; then + sudo "extra-${a}-build" || die "extra-${a}-build failed" + fi done fi for a in "${pkgarch[@]}"; do - for p in "${pkgname[@]}"; do - cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}" - done + if in_array "$a" "${ARCH_BUILD[@]}"; then + for p in "${pkgname[@]}"; do + cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}" + done + fi done fi popd >/dev/null @@ -160,7 +164,7 @@ checkAnyPackageDB() { [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" fi - for arch in i686 x86_64; do + for arch in "${ARCH_BUILD[@]}"; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} is not a symlink" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" @@ -267,7 +271,7 @@ checkRemovedAnyPackageDB() { local db for db in "${DBEXT}" "${FILESEXT}"; do - for arch in i686 x86_64; do + for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index e3a30d1..e16a8d1 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -4,20 +4,19 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testCreateSimpleFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgbase}"; then fail "usr/bin/${pkgbase} not found in ${arch}/extra${FILESEXT}" fi @@ -26,7 +25,6 @@ testCreateSimpleFileLists() { } testCreateAnyFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase local arch @@ -37,7 +35,7 @@ testCreateAnyFileLists() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/share/${pkgbase}/test"; then fail "usr/share/${pkgbase}/test not found in ${arch}/extra${FILESEXT}" fi @@ -46,7 +44,6 @@ testCreateAnyFileLists() { } testCreateSplitFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase @@ -55,7 +52,7 @@ testCreateSplitFileLists() { local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -64,7 +61,7 @@ testCreateSplitFileLists() { for pkgbase in "${pkgs[@]}"; do pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) for pkgname in "${pkgnames[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgname}"; then fail "usr/bin/${pkgname} not found in ${arch}/extra${FILESEXT}" fi @@ -75,23 +72,22 @@ testCreateSplitFileLists() { testCleanupFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-a done - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-b"; then fail "usr/bin/pkg-simple-b not found in ${arch}/extra${FILESEXT}" fi diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index e3207b6..410e222 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testMoveSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -19,7 +18,7 @@ testMoveSimplePackages() { ../db-move testing extra pkg-simple-a - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" checkRemovedPackage testing "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" @@ -28,13 +27,12 @@ testMoveSimplePackages() { } testMoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -44,7 +42,7 @@ testMoveMultiplePackages() { ../db-move testing extra pkg-simple-a pkg-simple-b for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" checkRemovedPackage testing "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done @@ -52,13 +50,12 @@ testMoveMultiplePackages() { } testMoveEpochPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -67,7 +64,7 @@ testMoveEpochPackages() { ../db-move testing extra pkg-simple-epoch - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" checkRemovedPackage testing "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" done @@ -90,14 +87,13 @@ testMoveAnyPackages() { } testMoveSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage testing "${pkgbase}" "${arch}" done done @@ -105,12 +101,12 @@ testMoveSplitPackages() { ../db-update ../db-move testing extra pkg-split-a - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/pkg-split-a"/*-"${arch}"${PKGEXT}; do checkPackage extra "${pkg##*/}" "${arch}" done done - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/pkg-split-b"/*-"${arch}"${PKGEXT}; do checkPackage testing "${pkg##*/}" "${arch}" done diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index fca480c..4fd5548 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testRemovePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -18,38 +17,37 @@ testRemovePackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" "${pkgbase}" done done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackage extra "${pkgbase}" "${arch}" done done } testRemoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" "${pkgs[@]}" done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackage extra "${pkgbase}" "${arch}" done done diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh index 3d83007..776c0a2 100755 --- a/test/test.d/db-repo-add.sh +++ b/test/test.d/db-repo-add.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testAddSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" @@ -20,19 +19,18 @@ testAddSimplePackages() { done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } testAddMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do add_pkgs=() for pkgbase in "${pkgs[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" @@ -45,7 +43,7 @@ testAddMultiplePackages() { done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh index ce13280..fd69fa7 100755 --- a/test/test.d/db-repo-remove.sh +++ b/test/test.d/db-repo-remove.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testRemovePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -18,38 +17,37 @@ testRemovePackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-repo-remove extra "${arch}" "${pkgbase}" done done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done } testRemoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-repo-remove extra "${arch}" "${pkgs[@]}" done for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index c83d51b..48c243d 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testAddSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -18,7 +17,7 @@ testAddSimplePackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done @@ -52,14 +51,13 @@ testAddAnyPackages() { } testAddSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -67,7 +65,7 @@ testAddSplitPackages() { ../db-update for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/${pkgbase}"/*-"${arch}"${PKGEXT}; do checkPackage extra "${pkg##*/}" "${arch}" done @@ -141,12 +139,11 @@ testUpdateSameAnyPackageToDifferentRepositories() { testAddIncompleteSplitPackage() { - local arches=('i686' 'x86_64') local repo='extra' local pkgbase='pkg-split-a' local arch - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage "${repo}" "${pkgbase}" "${arch}" done @@ -155,7 +152,7 @@ testAddIncompleteSplitPackage() { ../db-update >/dev/null 2>&1 && fail "db-update should fail when a split package is missing!" - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 1b075da..6902b9b 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -4,26 +4,25 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testCleanupSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-a done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-a' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" @@ -35,26 +34,25 @@ testCleanupSimplePackages() { } testCleanupEpochPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-epoch done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do local pkg1="pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" checkRemovedPackage extra 'pkg-simple-epoch' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" @@ -85,27 +83,26 @@ testCleanupAnyPackages() { } testCleanupSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" "${pkgs[0]}" done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do for pkg in "${pkgdir}/${pkgs[0]}"/*-"${arch}"${PKGEXT}; do checkRemovedPackage extra "${pkgs[0]}" "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 1097ae0..561169e 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -4,13 +4,12 @@ curdir=$(readlink -e "$(dirname "$0")") . "${curdir}/../lib/common.inc" testSourceballs() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -38,14 +37,13 @@ testAnySourceballs() { } testSplitSourceballs() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done @@ -59,20 +57,19 @@ testSplitSourceballs() { } testSourceballsCleanup() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch for pkgbase in "${pkgs[@]}"; do - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for arch in "${arches[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do ../db-remove extra "${arch}" pkg-simple-a done -- cgit v1.2.3-54-g00ecf From 8700e09c4d2ff0a20d5fa3789a6309078bc1ccb6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 17 Apr 2016 12:18:02 -0400 Subject: Use `grep &>/dev/null` instead of `grep -q` when operating on piped stdin. `grep -q` may exit as soon as it finds a match; this is a good optimization for when the input is a file. However, if the input is the output of another program, then that other program will receive SIGPIPE, and further writes will fail. When this happens, it might (bsdtar does) print a message about a "write error" to stderr. Which is going to confuse and alarm the user. I'll add that this is not purely hypothetical--it has happened to me while running the test suite. --- db-functions | 2 +- test/lib/common.inc | 8 ++++---- test/test.d/create-filelists.sh | 10 +++++----- test/test.d/db-update.sh | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'test/test.d/db-update.sh') diff --git a/db-functions b/db-functions index 5fe86b6..4eebf4a 100644 --- a/db-functions +++ b/db-functions @@ -364,7 +364,7 @@ check_pkgfile() { in_array "${pkgarch}" "${ARCHES[@]}" 'any' || return 1 - if echo "${pkgfile##*/}" | grep -q "${pkgname}-${pkgver}-${pkgarch}"; then + if echo "${pkgfile##*/}" | grep "${pkgname}-${pkgver}-${pkgarch}" &>/dev/null; then return 0 else return 1 diff --git a/test/lib/common.inc b/test/lib/common.inc index 5b06616..83c54bd 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -177,7 +177,7 @@ checkAnyPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done @@ -221,7 +221,7 @@ checkPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -247,7 +247,7 @@ checkRemovedPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -273,7 +273,7 @@ checkRemovedAnyPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index e16a8d1..be66fc2 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -17,7 +17,7 @@ testCreateSimpleFileLists() { for pkgbase in "${pkgs[@]}"; do for arch in "${ARCH_BUILD[@]}"; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgbase}"; then + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep "usr/bin/${pkgbase}" &>/dev/null; then fail "usr/bin/${pkgbase} not found in ${arch}/extra${FILESEXT}" fi done @@ -36,7 +36,7 @@ testCreateAnyFileLists() { for pkgbase in "${pkgs[@]}"; do for arch in "${ARCH_BUILD[@]}"; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/share/${pkgbase}/test"; then + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep "usr/share/${pkgbase}/test" &>/dev/null; then fail "usr/share/${pkgbase}/test not found in ${arch}/extra${FILESEXT}" fi done @@ -62,7 +62,7 @@ testCreateSplitFileLists() { pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) for pkgname in "${pkgnames[@]}"; do for arch in "${ARCH_BUILD[@]}"; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgname}"; then + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep "usr/bin/${pkgname}" &>/dev/null; then fail "usr/bin/${pkgname} not found in ${arch}/extra${FILESEXT}" fi done @@ -88,10 +88,10 @@ testCleanupFileLists() { done for arch in "${ARCH_BUILD[@]}"; do - if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-b"; then + if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep "usr/bin/pkg-simple-b" &>/dev/null; then fail "usr/bin/pkg-simple-b not found in ${arch}/extra${FILESEXT}" fi - if bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-a"; then + if bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep "usr/bin/pkg-simple-a" &>/dev/null; then fail "usr/bin/pkg-simple-a still found in ${arch}/extra${FILESEXT}" fi done diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 48c243d..9e44970 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -132,7 +132,7 @@ testUpdateSameAnyPackageToDifferentRepositories() { local arch for arch in i686 x86_64; do ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" done } @@ -154,7 +154,7 @@ testAddIncompleteSplitPackage() { for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" done } -- cgit v1.2.3-54-g00ecf From e4e5a028843316edf73cae4ac70d9df3cf8e1565 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 17 Jun 2014 23:47:21 -0400 Subject: Consistently use "$(dirname "$(readlink -e "$0")")" This does correct handling of - executing a program by symlink - any weird characters in the full path - I'm sure there's another case I thought about when I originally did this. --- cron-jobs/ftpdir-cleanup | 4 ++-- cron-jobs/integrity-check | 2 +- cron-jobs/update-web-db | 4 ++-- db-move | 4 ++-- db-remove | 4 ++-- db-repo-add | 4 ++-- db-repo-remove | 4 ++-- db-update | 4 ++-- test/test.d/create-filelists.sh | 2 +- test/test.d/db-move.sh | 2 +- test/test.d/db-remove.sh | 2 +- test/test.d/db-repo-add.sh | 2 +- test/test.d/db-repo-remove.sh | 2 +- test/test.d/db-update.sh | 2 +- test/test.d/ftpdir-cleanup.sh | 2 +- test/test.d/packages.sh | 2 +- test/test.d/signed-packages.sh | 2 +- test/test.d/sourceballs.sh | 2 +- test/test.d/testing2x.sh | 2 +- testing2x | 6 +++--- 20 files changed, 29 insertions(+), 29 deletions(-) (limited to 'test/test.d/db-update.sh') diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index f6487cf..4063c09 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/../config" -. "$(dirname "$0")/../db-functions" +. "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" clean_pkg() { local pkg diff --git a/cron-jobs/integrity-check b/cron-jobs/integrity-check index 677c0d3..7459380 100755 --- a/cron-jobs/integrity-check +++ b/cron-jobs/integrity-check @@ -1,6 +1,6 @@ #!/bin/bash -dirname="$(dirname "$0")" +dirname="$(dirname "$(readlink -e "$0")")" . "${dirname}/../config" . "${dirname}/../db-functions" diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db index 88bf464..c8bf74a 100755 --- a/cron-jobs/update-web-db +++ b/cron-jobs/update-web-db @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/../config" -. "$(dirname "$0")/../db-functions" +. "$(dirname "$(readlink -e "$0")")/../config" +. "$(dirname "$(readlink -e "$0")")/../db-functions" # setup paths SPATH="/srv/http/archweb" diff --git a/db-move b/db-move index b589bca..a55dd50 100755 --- a/db-move +++ b/db-move @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s ..." "${0##*/}" diff --git a/db-remove b/db-remove index ca56ecc..7e7fcb8 100755 --- a/db-remove +++ b/db-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s ..." "${0##*/}" diff --git a/db-repo-add b/db-repo-add index 09ce865..4611bdf 100755 --- a/db-repo-add +++ b/db-repo-add @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s ..." "${0##*/}" diff --git a/db-repo-remove b/db-repo-remove index 97a671b..aadc4ce 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: %s ..." "${0##*/}" diff --git a/db-update b/db-update index 9fa9c1b..358c534 100755 --- a/db-update +++ b/db-update @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -ge 1 ]; then warning "Calling %s with a specific repository is no longer supported" "${0##*/}" diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index be66fc2..20dafc6 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testCreateSimpleFileLists() { diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 410e222..4b4120e 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testMoveSimplePackages() { diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index 4fd5548..a391197 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testRemovePackages() { diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh index 776c0a2..266a696 100755 --- a/test/test.d/db-repo-add.sh +++ b/test/test.d/db-repo-add.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSimplePackages() { diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh index fd69fa7..727188d 100755 --- a/test/test.d/db-repo-remove.sh +++ b/test/test.d/db-repo-remove.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testRemovePackages() { diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index 9e44970..540eccf 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSimplePackages() { diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 6902b9b..5a7afea 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testCleanupSimplePackages() { diff --git a/test/test.d/packages.sh b/test/test.d/packages.sh index 1a31a41..18266eb 100755 --- a/test/test.d/packages.sh +++ b/test/test.d/packages.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testPackages() { diff --git a/test/test.d/signed-packages.sh b/test/test.d/signed-packages.sh index 4eccb41..3ffe146 100755 --- a/test/test.d/signed-packages.sh +++ b/test/test.d/signed-packages.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSignedPackage() { diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 561169e..81c9265 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testSourceballs() { diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index 3bbd353..c611ce4 100755 --- a/test/test.d/testing2x.sh +++ b/test/test.d/testing2x.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e "$(dirname "$0")") +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testTesting2xAnyPackage() { diff --git a/testing2x b/testing2x index e269248..901c1b0 100755 --- a/testing2x +++ b/testing2x @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$0")/config" -. "$(dirname "$0")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 1 ]; then msg "usage: %s ..." "${0##*/}" @@ -54,7 +54,7 @@ for repo in "${STABLE_REPOS[@]}"; do repo_unlock "${repo}" "${pkgarch}" done if [ -n "${pkgs[${repo}]}" ]; then - "$(dirname "$0")/db-move" "${TESTING_REPO}" "${repo}" "${pkgs[${repo}]}" + "$(dirname "$(readlink -e "$0")")/db-move" "${TESTING_REPO}" "${repo}" "${pkgs[${repo}]}" fi done -- cgit v1.2.3-54-g00ecf