test: initial testsuite

cute-signatures
Natanael Copa 2010-06-15 13:30:12 +00:00
parent ec6359732d
commit 83d859286d
17 changed files with 422 additions and 0 deletions

4
test/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
src
pkg
*.apk
*.tar.gz

59
test/Makefile Normal file
View File

@ -0,0 +1,59 @@
repos := repo1 repo2
tmproot := /tmp/apk-test
testroot = $(tmproot)/$(basename $@)
SUDO := sudo
APK := ../src/apk --keys-dir /etc/apk/keys
#SYSREPO ?= http://alpinelinux.org/cgi-bin/dl.cgi/edge/main
SYSREPO ?= http://192.168.8.4/main
LD_LIBRARY_PATH = ../src
export LD_LIBRARY_PATH SYSREPO
all: tests
$(repos):
@echo "Building $@"
@rm -f repos.out
@cd $@ &&\
for i in */APKBUILD; do\
( cd $${i%/*} && \
PKGDEST="$$PWD/.." abuild -R ) >> ../repos.out 2>&1 || exit 1;\
done
@cd $@ &&\
( apk index -o APKINDEX.tar.gz *.apk &&\
abuild-sign APKINDEX.tar.gz ) >> ../repos.out 2>&1
clean:
$(SUDO) rm -rf $(addsuffix /*.apk,$(repos)) $(tmproot) *.ok *.out *.stamp
repos: repos.stamp
repos.stamp: $(repos)
@touch $@
%.ok: %.sh
@echo -n "$<"; \
rm -rf "$(testroot)" ;\
mkdir -p "$(testroot)"; \
if ! APK="$(APK)" ROOT="$(testroot)" SYSREPO="$(SYSREPO)" sh -e $< > $(basename $@).out 2>&1; then\
echo " FAIL";\
exit 1;\
fi ;\
echo " OK" ;\
$(SUDO) rm -rf $(testroot); \
touch $@
tests: repos.stamp
@echo "== Testing `$(APK) --version` =="
@for i in test*.sh; do \
rm -f $${i%.sh}.ok ;\
$(SUDO) $(MAKE) --no-print-directory $${i%.sh}.ok SYSREPO=$(SYSREPO); \
done
.PHONY: $(repos)

View File

@ -0,0 +1,38 @@
# Contributor:
# Maintainer:
pkgname=test-a
pkgver=1.0
pkgrel=0
pkgdesc="Package A for apk-tools testsuite"
url="http://alpinelinux.org"
license="GPL"
depends=
makedepends=
install=
subpackages=
source=""
# append extra dependencies to -dev subpackage
# remove if not used.
# depends_dev="somepackage-dev"
_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
mkdir -p "$_builddir"
}
build() {
cd "$_builddir"
cat > $pkgname << __EOF__
#!/bin/sh
echo "hello from $pkgname-$pkgver"
__EOF__
}
package() {
cd "$_builddir"
install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}
md5sums="" #generate with 'abuild checksum'

View File

@ -0,0 +1,38 @@
# Contributor:
# Maintainer:
pkgname=test-b
pkgver=1.0
pkgrel=0
pkgdesc="Package A for apk-tools testsuite"
url="http://alpinelinux.org"
license="GPL"
depends=test-a
makedepends=
install=
subpackages=
source=""
# append extra dependencies to -dev subpackage
# remove if not used.
# depends_dev="somepackage-dev"
_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
mkdir -p "$_builddir"
}
build() {
cd "$_builddir"
cat > $pkgname << __EOF__
#!/bin/sh
echo "hello from $pkgname-$pkgver"
__EOF__
}
package() {
cd "$_builddir"
install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}
md5sums="" #generate with 'abuild checksum'

View File

@ -0,0 +1,38 @@
# Contributor:
# Maintainer:
pkgname=test-c
pkgver=1.0
pkgrel=0
pkgdesc="Package C for apk-tools testsuite - pre-install"
url="http://alpinelinux.org"
license="GPL"
depends=
makedepends=
install="test-c.pre-install"
subpackages=
source=""
# append extra dependencies to -dev subpackage
# remove if not used.
# depends_dev="somepackage-dev"
_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
mkdir -p "$_builddir"
}
build() {
cd "$_builddir"
cat > $pkgname << __EOF__
#!/bin/sh
echo "hello from $pkgname-$pkgver"
__EOF__
}
package() {
cd "$_builddir"
install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}
md5sums="" #generate with 'abuild checksum'

View File

@ -0,0 +1,14 @@
#!/bin/sh
echo "$@" > /pre-install
if [ -n "$WAS_EXPORTED" ]; then
touch /was-exported
fi
if [ -f /should-fail ]; then
exit 1
fi
exit 0

View File

@ -0,0 +1,38 @@
# Contributor:
# Maintainer:
pkgname=test-d
pkgver=1.0
pkgrel=0
pkgdesc="Package D for apk-tools testsuite - post-install"
url="http://alpinelinux.org"
license="GPL"
depends=
makedepends=
install="$pkgname.post-install"
subpackages=
source=""
# append extra dependencies to -dev subpackage
# remove if not used.
# depends_dev="somepackage-dev"
_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
mkdir -p "$_builddir"
}
build() {
cd "$_builddir"
cat > $pkgname << __EOF__
#!/bin/sh
echo "hello from $pkgname-$pkgver"
__EOF__
}
package() {
cd "$_builddir"
install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}
md5sums="" #generate with 'abuild checksum'

View File

@ -0,0 +1,14 @@
#!/bin/sh
echo "$@" > /post-install
if [ -n "$WAS_EXPORTED" ]; then
touch /was-exported
fi
if [ -f /should-fail ]; then
exit 1
fi
exit 0

View File

@ -0,0 +1,33 @@
# Contributor:
# Maintainer:
pkgname=test-a
pkgver=1.1
pkgrel=0
pkgdesc="Package A for apk-tools testsuite"
url="http://alpinelinux.org"
license="GPL"
depends=
makedepends=
install=
subpackages=
source=""
_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
mkdir -p "$_builddir"
}
build() {
cd "$_builddir"
cat > $pkgname << __EOF__
#!/bin/sh
echo "hello from $pkgname-$pkgver"
__EOF__
}
package() {
cd "$_builddir"
install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}
md5sums="" #generate with 'abuild checksum'

View File

@ -0,0 +1,38 @@
# Contributor:
# Maintainer:
pkgname=test-b
pkgver=1.0
pkgrel=0
pkgdesc="Package A for apk-tools testsuite"
url="http://alpinelinux.org"
license="GPL"
depends=test-a
makedepends=
install=
subpackages=
source=""
# append extra dependencies to -dev subpackage
# remove if not used.
# depends_dev="somepackage-dev"
_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
mkdir -p "$_builddir"
}
build() {
cd "$_builddir"
cat > $pkgname << __EOF__
#!/bin/sh
echo "hello from $pkgname-$pkgver"
__EOF__
}
package() {
cd "$_builddir"
install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}
md5sums="" #generate with 'abuild checksum'

15
test/test1.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
# desc: test if basic add/del/upgrade works
$APK add --root $ROOT --initdb --repository $PWD/repo1 test-a
test "$($ROOT/usr/bin/test-a)" = "hello from test-a-1.0"
$APK upgrade --root $ROOT --repository $PWD/repo2
test "$($ROOT/usr/bin/test-a)" = "hello from test-a-1.1"
$APK del --root $ROOT test-a
[ -x "$ROOT/usr/bin/test-a" ] || true

23
test/test2.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
# desc: test if dependencies works
# test-b depends on test-a
$APK add --root $ROOT --initdb --repository $PWD/repo1 test-b
# check if test-a was installed
test "$($ROOT/usr/bin/test-a)" = "hello from test-a-1.0"
# run an upgrade
$APK upgrade --root $ROOT --repository $PWD/repo2
# test if test-a was upgraded
test "$($ROOT/usr/bin/test-a)" = "hello from test-a-1.1"
# remove test-b
$APK del --root $ROOT test-b
# test if the dependency was removed too
if [ -x "$ROOT/usr/bin/test-a" ]; then
exit 1
fi

12
test/test3.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# desc: test successful pre-install
$APK add --root $ROOT --initdb --repository $PWD/repo1 --repository $SYSREPO \
-U test-c
# check that package was installed
$APK info --root $ROOT -e test-c
# check if pre-install was executed
test -f $ROOT/pre-install

17
test/test4.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
# desc: test failing pre-install
# pre-install script will fail if should-fail file exists
mkdir -p "$ROOT"
touch "$ROOT"/should-fail
! $APK add --root $ROOT --initdb --repository $PWD/repo1 --repository $SYSREPO \
-U test-c
# check that pre-install was executed
test -f $ROOT/pre-install
# check that package was not installed
! $APK info --root $ROOT -e test-c

9
test/test5.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# desc: test post-install script
$APK add --root $ROOT --initdb -U --repository $PWD/repo1 \
--repository $SYSREPO test-d
test -f "$ROOT"/post-install

11
test/test6.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# desc: test triggers in kernel package
$APK add --root $ROOT --initdb -U --repository $PWD/repo1 \
--repository $SYSREPO linux-grsec
test -L "$ROOT"/boot/vmlinuz-grsec
test -L "$ROOT"/boot/initramfs-grsec

21
test/test7.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
# desc: test triggers in busybox package
# we had a bug that caused apk fix --reinstall to segfault every second time
$APK add --root $ROOT --initdb -U --repository $PWD/repo1 \
--repository $SYSREPO busybox
for i in 0 1 2 3; do
# delete wget symlink
rm -f "$ROOT"/usr/bin/wget
# re-install so we run the trigger again
$APK fix --root $ROOT --repository $SYSREPO --reinstall busybox
# verify wget symlink is there
test -L "$ROOT"/usr/bin/wget
done