Commit e776cded authored by Loïc Minier's avatar Loïc Minier

pbuilder-selftest: run tests after install

parent b4b19c40
......@@ -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))
......
#!/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
......@@ -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() {
......
#!/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 "" \
......
#!/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"
......
#!/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
......
......@@ -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
......
#!/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() {
......
#!/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
......
#!/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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment