aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2010-06-15 13:30:12 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2010-06-15 13:31:20 +0000
commit83d859286db8a184054a5e05f707953634c82604 (patch)
treed7224227db27abba7a9d21e1c2f074c0d7541f9a
parentec6359732dec5651567f593d07871b5b7997c91d (diff)
downloadaports-83d859286db8a184054a5e05f707953634c82604.tar.gz
aports-83d859286db8a184054a5e05f707953634c82604.tar.bz2
aports-83d859286db8a184054a5e05f707953634c82604.tar.xz
test: initial testsuite
-rw-r--r--test/.gitignore4
-rw-r--r--test/Makefile59
-rw-r--r--test/repo1/test-a/APKBUILD38
-rw-r--r--test/repo1/test-b/APKBUILD38
-rw-r--r--test/repo1/test-c/APKBUILD38
-rw-r--r--test/repo1/test-c/test-c.pre-install14
-rw-r--r--test/repo1/test-d/APKBUILD38
-rw-r--r--test/repo1/test-d/test-d.post-install14
-rw-r--r--test/repo2/test-a/APKBUILD33
-rw-r--r--test/repo2/test-b/APKBUILD38
-rwxr-xr-xtest/test1.sh15
-rwxr-xr-xtest/test2.sh23
-rwxr-xr-xtest/test3.sh12
-rwxr-xr-xtest/test4.sh17
-rwxr-xr-xtest/test5.sh9
-rwxr-xr-xtest/test6.sh11
-rwxr-xr-xtest/test7.sh21
17 files changed, 422 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000000..1480a738c0
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1,4 @@
+src
+pkg
+*.apk
+*.tar.gz
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000000..23f3183ed1
--- /dev/null
+++ b/test/Makefile
@@ -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)
diff --git a/test/repo1/test-a/APKBUILD b/test/repo1/test-a/APKBUILD
new file mode 100644
index 0000000000..6acc20dc5e
--- /dev/null
+++ b/test/repo1/test-a/APKBUILD
@@ -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'
diff --git a/test/repo1/test-b/APKBUILD b/test/repo1/test-b/APKBUILD
new file mode 100644
index 0000000000..17568277c8
--- /dev/null
+++ b/test/repo1/test-b/APKBUILD
@@ -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'
diff --git a/test/repo1/test-c/APKBUILD b/test/repo1/test-c/APKBUILD
new file mode 100644
index 0000000000..41228bf737
--- /dev/null
+++ b/test/repo1/test-c/APKBUILD
@@ -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'
diff --git a/test/repo1/test-c/test-c.pre-install b/test/repo1/test-c/test-c.pre-install
new file mode 100644
index 0000000000..c75c644296
--- /dev/null
+++ b/test/repo1/test-c/test-c.pre-install
@@ -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
+
diff --git a/test/repo1/test-d/APKBUILD b/test/repo1/test-d/APKBUILD
new file mode 100644
index 0000000000..905e123b87
--- /dev/null
+++ b/test/repo1/test-d/APKBUILD
@@ -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'
diff --git a/test/repo1/test-d/test-d.post-install b/test/repo1/test-d/test-d.post-install
new file mode 100644
index 0000000000..0e14f2a802
--- /dev/null
+++ b/test/repo1/test-d/test-d.post-install
@@ -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
+
diff --git a/test/repo2/test-a/APKBUILD b/test/repo2/test-a/APKBUILD
new file mode 100644
index 0000000000..693cf61bcd
--- /dev/null
+++ b/test/repo2/test-a/APKBUILD
@@ -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'
diff --git a/test/repo2/test-b/APKBUILD b/test/repo2/test-b/APKBUILD
new file mode 100644
index 0000000000..17568277c8
--- /dev/null
+++ b/test/repo2/test-b/APKBUILD
@@ -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'
diff --git a/test/test1.sh b/test/test1.sh
new file mode 100755
index 0000000000..ce28a0585b
--- /dev/null
+++ b/test/test1.sh
@@ -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
diff --git a/test/test2.sh b/test/test2.sh
new file mode 100755
index 0000000000..f0ba463ea8
--- /dev/null
+++ b/test/test2.sh
@@ -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
diff --git a/test/test3.sh b/test/test3.sh
new file mode 100755
index 0000000000..994d54d11a
--- /dev/null
+++ b/test/test3.sh
@@ -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
diff --git a/test/test4.sh b/test/test4.sh
new file mode 100755
index 0000000000..8132c607b5
--- /dev/null
+++ b/test/test4.sh
@@ -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
+
diff --git a/test/test5.sh b/test/test5.sh
new file mode 100755
index 0000000000..ab9643a624
--- /dev/null
+++ b/test/test5.sh
@@ -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
+
diff --git a/test/test6.sh b/test/test6.sh
new file mode 100755
index 0000000000..dff4ee966d
--- /dev/null
+++ b/test/test6.sh
@@ -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
+
diff --git a/test/test7.sh b/test/test7.sh
new file mode 100755
index 0000000000..a742fbcab0
--- /dev/null
+++ b/test/test7.sh
@@ -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
+
+