aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rwxr-xr-xpbuilder-selftest14
-rwxr-xr-xtest_pbuilder-apt-config25
-rwxr-xr-xtest_pbuilder-checkparams26
-rwxr-xr-xtest_pbuilder-modules14
-rwxr-xr-xtest_pbuilder-satisfydepends-checkparams23
-rwxr-xr-xtest_pbuilder-satisfydepends-classic22
-rwxr-xr-xtest_pbuilder-satisfydepends-funcs16
-rwxr-xr-xtest_testlib.sh9
-rw-r--r--testlib.sh42
10 files changed, 162 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index 02522ff..36f310c 100644
--- a/Makefile
+++ b/Makefile
@@ -56,6 +56,7 @@ PKGLIB_SCRIPTS += \
pbuilder-satisfydepends-experimental \
pbuilder-satisfydepends-funcs \
pbuilder-satisfydepends-gdebi \
+ pbuilder-selftest \
pbuilder-uml-checkparams \
pbuilder-updatebuildenv \
pdebuild-checkparams \
@@ -177,6 +178,7 @@ CHECK_SCRIPTS += $(foreach d,$(ALLDIRS),$($(d)_SCRIPTS))
all:
+check: export PBUILDER_CHECKOUT := $(CURDIR)
check:
# syntax check
$(foreach script,$(CHECK_SCRIPTS),bash -n $(script)$(newline))
diff --git a/pbuilder-selftest b/pbuilder-selftest
new file mode 100755
index 0000000..348c595
--- /dev/null
+++ b/pbuilder-selftest
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ PBUILDER_TESTS_DIR="$PBUILDER_CHECKOUT"
+else
+ PBUILDER_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ PBUILDER_TESTS_DIR="$PBUILDER_PKGLIBDIR"
+fi
+
+for t in "$PBUILDER_TESTS_DIR"/test_*; do
+ "$t"
+done
diff --git a/test_pbuilder-apt-config b/test_pbuilder-apt-config
index 07de2c7..dd529cb 100755
--- a/test_pbuilder-apt-config
+++ b/test_pbuilder-apt-config
@@ -4,7 +4,22 @@ set -e
self="$(basename "$0")"
-. ./testlib.sh
+# if this is set, use pbuilder files from this location; otherwise, use
+# installed files (from PBUILDER_TEST_ROOT, which is a copy of PBUILDER_ROOT)
+PBUILDER_CHECKOUT="${PBUILDER_CHECKOUT:-}"
+
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ . "$PBUILDER_CHECKOUT/testlib.sh"
+
+ PBUILDER_APT_CONFIG="$PBUILDER_CHECKOUT/pbuilder-apt-config"
+else
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh"
+
+ PBUILDER_APT_CONFIG="$PBUILDER_TEST_PKGLIBDIR/pbuilder-apt-config"
+fi
mirror_map=""
@@ -29,15 +44,15 @@ debian-archive
EOF
run_suite_mode() {
- ./pbuilder-apt-config --mirror-map="$mirror_map" --with-sources=no --mirror mirror --suite suite --components component apt-sources "$@"
+ "$PBUILDER_APT_CONFIG" --mirror-map="$mirror_map" --with-sources=no --mirror mirror --suite suite --components component apt-sources "$@"
}
debootstrap_suite() {
- ./pbuilder-apt-config --mirror-map="$mirror_map" --with-sources=no --mirror mirror --components component debootstrap-suite "$@"
+ "$PBUILDER_APT_CONFIG" --mirror-map="$mirror_map" --with-sources=no --mirror mirror --components component debootstrap-suite "$@"
}
debootstrap_mirror() {
- ./pbuilder-apt-config --mirror-map="$mirror_map" --with-sources=no --components component debootstrap-mirror "$@"
+ "$PBUILDER_APT_CONFIG" --mirror-map="$mirror_map" --with-sources=no --components component debootstrap-mirror "$@"
}
test_components() {
@@ -66,7 +81,7 @@ strip_mirror() {
test_profile() {
local profile="$1"
- ./pbuilder-apt-config --with-sources=no --profile "$profile" --components comp1 apt-sources | strip_mirror
+ "$PBUILDER_APT_CONFIG" --with-sources=no --profile "$profile" --components comp1 apt-sources | strip_mirror
}
test_fail() {
diff --git a/test_pbuilder-checkparams b/test_pbuilder-checkparams
index 1089319..cc1af9e 100755
--- a/test_pbuilder-checkparams
+++ b/test_pbuilder-checkparams
@@ -1,18 +1,32 @@
#!/bin/bash
-. ./testlib.sh
-
# testsuite for pbuilder-checkparams
-test_debuildopts() {
- . ./pbuilder-checkparams
- echo "$DEBBUILDOPTS"
-}
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ . "$PBUILDER_CHECKOUT/testlib.sh"
+else
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh"
+fi
# setup a fake installed environment
trap testlib_cleanup_env sigpipe sighup exit
testlib_setup_env
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ PBUILDER_CHECKPARAMS="$PBUILDER_CHECKOUT/pbuilder-checkparams"
+else
+ export PBUILDER_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ PBUILDER_CHECKPARAMS="$PBUILDER_PKGLIBDIR/pbuilder-checkparams"
+fi
+
+test_debuildopts() {
+ . "$PBUILDER_CHECKPARAMS"
+ echo "$DEBBUILDOPTS"
+}
+
expect_output "" \
test_debuildopts foo.dsc
expect_output "" \
diff --git a/test_pbuilder-modules b/test_pbuilder-modules
index 402c424..bec24e1 100755
--- a/test_pbuilder-modules
+++ b/test_pbuilder-modules
@@ -1,7 +1,17 @@
#!/bin/bash
-. ./testlib.sh
-. ./pbuilder-modules
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ . "$PBUILDER_CHECKOUT/testlib.sh"
+
+ . "$PBUILDER_CHECKOUT/pbuilder-modules"
+else
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh"
+
+ . "$PBUILDER_TEST_PKGLIBDIR/pbuilder-modules"
+fi
function test_information() {
log "I: test"
diff --git a/test_pbuilder-satisfydepends-checkparams b/test_pbuilder-satisfydepends-checkparams
index 1c4d65d..036a048 100755
--- a/test_pbuilder-satisfydepends-checkparams
+++ b/test_pbuilder-satisfydepends-checkparams
@@ -1,6 +1,17 @@
#!/bin/bash
-. ./testlib.sh
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ . "$PBUILDER_CHECKOUT/testlib.sh"
+
+ PBUILDER_SATISFYDEPENDS_CHECKPARAMS="$PBUILDER_CHECKOUT/pbuilder-satisfydepends-checkparams"
+else
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh"
+
+ PBUILDER_SATISFYDEPENDS_CHECKPARAMS="$PBUILDER_TEST_PKGLIBDIR/pbuilder-satisfydepends-checkparams"
+fi
# testsuite to test pbuilder-satisfydepends-checkparams.
@@ -11,32 +22,32 @@ checkbuilddep_internal() {
test_chrootexec2() {
set -- --internal-chrootexec 'chroot /tmp-hoge ' --chroot /tmp
- . ./pbuilder-satisfydepends-checkparams
+ . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
}
expect_fail test_chrootexec2
test_chrootexec1() {
set -- --chroot /tmp --internal-chrootexec 'chroot /tmp-hoge '
- . ./pbuilder-satisfydepends-checkparams
+ . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
}
expect_success test_chrootexec1
test_chrootexec_echo() {
set -- --echo --chroot /tmp
- . ./pbuilder-satisfydepends-checkparams
+ . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
}
expect_fail test_chrootexec_echo
test_chrootexec_echo2() {
set -- --chroot /tmp --echo
- . ./pbuilder-satisfydepends-checkparams
+ . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
echo $CHROOTEXEC
}
expect_output "echo chroot /tmp" test_chrootexec_echo2
test_chrootexec_expect() {
set -- --chroot /tmp --internal-chrootexec 'chroot /tmp-hoge '
- . ./pbuilder-satisfydepends-checkparams
+ . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
echo $CHROOTEXEC
}
expect_output "chroot /tmp-hoge" test_chrootexec_expect
diff --git a/test_pbuilder-satisfydepends-classic b/test_pbuilder-satisfydepends-classic
index c97c3d1..c70c778 100755
--- a/test_pbuilder-satisfydepends-classic
+++ b/test_pbuilder-satisfydepends-classic
@@ -3,7 +3,18 @@
# (. ./pbuilder-satisfydepends-"$flavour")
#done
-. ./testlib.sh
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ . "$PBUILDER_CHECKOUT/testlib.sh"
+
+ PBUILDER_SATISFYDEPENDS_CLASSIC="$PBUILDER_CHECKOUT/pbuilder-satisfydepends-classic"
+else
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh"
+
+ PBUILDER_SATISFYDEPENDS_CLASSIC="$PBUILDER_TEST_PKGLIBDIR/pbuilder-satisfydepends-classic"
+fi
DEBIAN_CONTROL=""
@@ -19,9 +30,16 @@ trap cleanup sigpipe sighup exit
# setup a fake installed environment
testlib_setup_env
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ PBUILDER_SATISFYDEPENDS_CLASSIC="$PBUILDER_CHECKOUT/pbuilder-satisfydepends-classic"
+else
+ export PBUILDER_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ PBUILDER_SATISFYDEPENDS_CLASSIC="$PBUILDER_PKGLIBDIR/pbuilder-satisfydepends-classic"
+fi
+
set -- --echo --control "$DEBIAN_CONTROL"
# this is just to source the functions
-. ./pbuilder-satisfydepends-classic >/dev/null 2>&1 || true
+. "$PBUILDER_SATISFYDEPENDS_CLASSIC" >/dev/null 2>&1 || true
DEBIAN_CONTROL="`mktemp -t`"
cat >"$DEBIAN_CONTROL" <<EOF
diff --git a/test_pbuilder-satisfydepends-funcs b/test_pbuilder-satisfydepends-funcs
index b713f56..b4854fc 100755
--- a/test_pbuilder-satisfydepends-funcs
+++ b/test_pbuilder-satisfydepends-funcs
@@ -1,10 +1,20 @@
#!/bin/bash
-. ./testlib.sh
-. ./pbuilder-satisfydepends-funcs
-
# testsuite to test pbuilder-satisfydepends-funcs.
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ . "$PBUILDER_CHECKOUT/testlib.sh"
+
+ . "$PBUILDER_CHECKOUT/pbuilder-satisfydepends-funcs"
+else
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh"
+
+ . "$PBUILDER_TEST_PKGLIBDIR/pbuilder-satisfydepends-funcs"
+fi
+
DEBIAN_CONTROL=""
cleanup() {
diff --git a/test_testlib.sh b/test_testlib.sh
index 7642aaa..be20c58 100755
--- a/test_testlib.sh
+++ b/test_testlib.sh
@@ -1,7 +1,14 @@
#!/bin/bash
# testsuite for testlib
-. ./testlib.sh
+if [ -n "$PBUILDER_CHECKOUT" ]; then
+ . "$PBUILDER_CHECKOUT/testlib.sh"
+else
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ . "$PBUILDER_TEST_PKGLIBDIR/testlib.sh"
+fi
test_success() {
exit 0
diff --git a/testlib.sh b/testlib.sh
index 2c01739..77943fb 100644
--- a/testlib.sh
+++ b/testlib.sh
@@ -1,10 +1,30 @@
#!/bin/bash
# 2008 Junichi Uekawa <dancer@debian.org>
-set -e
+set -e
# library for functional unit-testing in bash.
+# WARNING: this file locates files differently from the other pbuilder
+# functions:
+# - if PBUILDER_CHECKOUT is set, it is assumed that testlib.sh is sourced from
+# a pbuilder checkout (e.g. from the upstream Makefile or Debian build)
+# - otherwise, PBUILDER_TEST_ROOT or PBUILDER_TEST_*DIR should be used to
+# locate files instead of PBUILDER_ROOT and PBUILDER_*DIR since
+# testlib_setup_env() overrides these vars to run the other pbuilder modules
+# with a fake environment
+
+# if this is set, use pbuilder files from this location; otherwise, use
+# installed files (from PBUILDER_TEST_ROOT, which is a copy of PBUILDER_ROOT)
+PBUILDER_CHECKOUT="${PBUILDER_CHECKOUT:-}"
+
+if [ -z "$PBUILDER_CHECKOUT" ]; then
+ # these currently don't need to be exported
+ PBUILDER_TEST_ROOT="${PBUILDER_ROOT:-}"
+ PBUILDER_TEST_PKGLIBDIR="${PBUILDER_PKGLIBDIR:-$PBUILDER_ROOT/usr/lib/pbuilder}"
+ PBUILDER_TEST_PKGDATADIR="${PBUILDER_PKGDATADIR:-$PBUILDER_ROOT/usr/share/pbuilder}"
+fi
+
TESTLIB_FAILS=0
TESTLIB_TESTS=0
@@ -40,9 +60,7 @@ testlib_summary() {
# this is where the env actually lives
testlib_env_root=""
testlib_setup_env() {
- local pbuilder_checkout abs_pbuilder_checkout r
- pbuilder_checkout="${1:-.}"
- abs_pbuilder_checkout="`cd $pbuilder_checkout; pwd`"
+ local abs_pbuilder_checkout r
if [ -n "$testlib_env_root" ]; then
echo "testlib_setup_env called twice without testlib_cleanup_env" >&2
@@ -50,6 +68,10 @@ testlib_setup_env() {
exit 1
fi
+ if [ -n "$PBUILDER_CHECKOUT" ]; then
+ abs_pbuilder_checkout="`cd $PBUILDER_CHECKOUT; pwd`"
+ fi
+
# backup env vars
testlib_env_oldhome="$HOME"
testlib_env_oldroot="$PBUILDER_ROOT"
@@ -61,9 +83,17 @@ testlib_setup_env() {
mkdir "$r"/etc
touch "$r"/etc/pbuilderrc
mkdir -p "$r"/usr/share/pbuilder
- cp "$pbuilder_checkout"/pbuilderrc "$r"/usr/share/pbuilder
+ if [ -n "$PBUILDER_CHECKOUT" ]; then
+ cp "$PBUILDER_CHECKOUT"/pbuilderrc "$r"/usr/share/pbuilder
+ else
+ cp "$PBUILDER_TEST_PKGDATADIR"/pbuilderrc "$r"/usr/share/pbuilder
+ fi
mkdir -p "$r"/usr/lib
- ln -s "$abs_pbuilder_checkout" "$r"/usr/lib/pbuilder
+ if [ -n "$PBUILDER_CHECKOUT" ]; then
+ ln -s "$abs_pbuilder_checkout" "$r"/usr/lib/pbuilder
+ else
+ ln -s "$PBUILDER_TEST_PKGLIBDIR" "$r"/usr/lib/pbuilder
+ fi
export PBUILDER_ROOT="$r"
# when running the testsuite within pbuilder, these env vars will have been
# set by regular pbuilder commands, so we need to unset them as to allow