[cowdancer] 02/04: Use automake for tests
James Clarke
jrtc27 at moszumanska.debian.org
Fri Jan 13 19:37:45 UTC 2017
This is an automated email from the git hooks/post-receive script.
jrtc27 pushed a commit to branch master
in repository cowdancer.
commit 2dd84e16775c4c87b5d0f83e8ae2a11a673b6540
Author: James Clarke <jrtc27 at jrtc27.com>
Date: Fri Jan 13 15:38:43 2017 +0000
Use automake for tests
---
Makefile.am | 94 ++++++++++++++++++++++++++-----------------
configure.ac | 4 +-
tests/002_test_open.sh | 4 +-
tests/003_test_fopen.sh | 4 +-
tests/004_test_fopen64.sh | 5 +--
tests/012_test_chown.sh | 6 +--
tests/013_test_chmod.sh | 5 +--
tests/014_ilistdump_test.sh | 0
tests/015_test_ilistdelete.sh | 7 +---
tests/018_testcxx.sh | 5 +--
tests/020_test_lchown.sh | 6 +--
tests/021_test_open.sh | 5 +--
tests/022_kernel_waitpid.sh | 5 +--
tests/run_c.sh | 16 --------
tests/run_cxx.sh | 16 --------
15 files changed, 75 insertions(+), 107 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 0a3128c..7b75430 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,15 +10,56 @@ sbin_PROGRAMS = cowbuilder
man_MANS = cow-shell.1 cowdancer-ilistcreate.1 cowdancer-ilistdump.1 cowbuilder.8
bashcompletion_DATA = bash-completion/cowbuilder
+FAST_TESTS = test_cowbuilder \
+ test_cowbuilder_util \
+ test_file \
+ test_forkexec \
+ test_ilistcreate \
+ test_parameter
+
+SLOW_TESTS = tests/000_test_basic.sh \
+ tests/001_test_symlink.sh \
+ tests/002_test_open.sh \
+ tests/003_test_fopen.sh \
+ tests/004_test_fopen64.sh \
+ tests/010_test_noilistfile.sh \
+ tests/012_test_chown.sh \
+ tests/013_test_chmod.sh \
+ tests/014_ilistdump_test.sh \
+ tests/015_test_ilistdelete.sh \
+ tests/016_memleakcheck.sh \
+ tests/017_tempfilecheck.sh \
+ tests/018_testcxx.sh \
+ tests/019_test_filename_with_space.sh \
+ tests/020_test_lchown.sh \
+ tests/021_test_open.sh \
+ tests/022_kernel_waitpid.sh \
+ tests/102_test_cowbuilder_debbuildopts.sh
+
if QEMUBUILDER
QEMUBUILDER = yes
sbin_PROGRAMS += qemubuilder
man_MANS += qemubuilder.8
bashcompletion_DATA += bash-completion/qemubuilder
+FAST_TESTS += test_qemuarch test_qemuipsanitize
+SLOW_TESTS += tests/101_test_qemubuilder_dumpconfig.sh
else
QEMUBUILDER = no
endif
+TESTS = $(FAST_TESTS) $(SLOW_TESTS)
+check_PROGRAMS = $(FAST_TESTS) \
+ tests/002_test_open \
+ tests/003_test_fopen \
+ tests/004_test_fopen64 \
+ tests/012_test_chown \
+ tests/013_test_chmod \
+ tests/015_test_ilistdelete \
+ tests/016_memleakcheck \
+ tests/018_testcxx \
+ tests/021_test_open \
+ tests/022_kernel_waitpid
+
AM_CFLAGS = -fno-strict-aliasing -DCOWDANCER_SO="\"$(pkglibdir)/libcowdancer.so\""
libcowdancer_la_SOURCES = cowdancer.c ilistcreate.c log.c
@@ -35,41 +76,22 @@ cowbuilder_SOURCES = cowbuilder.c parameter.c forkexec.c ilistcreate.c main.c co
qemubuilder_SOURCES = qemubuilder.c parameter.c forkexec.c qemuipsanitize.c qemuarch.c file.c main.c log.c
qemubuilder_CFLAGS = $(shell getconf LFS_CFLAGS) $(AM_CFLAGS)
-export srcdir
-
-tests/log:
- mkdir -p $@
-
-fastcheck: tests/log
- set -e; set -o pipefail; for A in $(srcdir)/test_*.c; do \
- echo $$A; \
- if [ "x$(QEMUBUILDER)" = "xno" -a "x$${A:$${#srcdir}+1:9}" == "xtest_qemu" ]; then \
- echo "Skipping (qemubuilder is only supported on linux-any)"; \
- else \
- $(srcdir)/tests/run_c.sh $$A 2>&1; \
- fi | \
- tee tests/log/$${A/*\//}.log; done
-
-if QEMUBUILDER
-slowcheck: tests/log cowdancer-ilistdump qemubuilder cow-shell
-else
-slowcheck: tests/log cowdancer-ilistdump cow-shell
-endif
- ## FIXME: The tests are running installed cowdancer, not the just-built
- set -e; set -o pipefail; for A in $(srcdir)/tests/[0-9][0-9][0-9]_*.sh; do \
- echo $$A; \
- if [ "x$(QEMUBUILDER)" = "xno" -a "x$${A:$${#srcdir}+1:40}" == "xtests/101_test_qemubuilder_dumpconfig.sh" ]; then \
- echo "Skipping (qemubuilder is only supported on linux-any)"; \
- else \
- PATH="$(abs_builddir):$(abs_builddir)/@objdir@:$(abs_srcdir)/tests:/usr/bin/:/bin" \
- COWDANCER_SO=$(abs_builddir)/@objdir@/libcowdancer.so \
- bash $$A 2>&1 | \
- sed -e's,/tmp/[^/]*,/tmp/XXXX,g' \
- -e "s,^Current time:.*,Current time: TIME," \
- -e "s,^pbuilder-time-stamp: .*,pbuilder-time-stamp: XXXX," \
- -e "s,^Fetched .*B in .*s (.*B/s),Fetched XXXB in Xs (XXXXXB/s),"; \
- fi | tee tests/log/$${A/*\//}.log; done
+test_cowbuilder_SOURCES = test_cowbuilder.c cowbuilder.c parameter.c forkexec.c ilistcreate.c cowbuilder_util.c log.c
+test_cowbuilder_util_SOURCES = test_cowbuilder_util.c cowbuilder_util.c log.c
+test_file_SOURCES = test_file.c file.c forkexec.c log.c
+test_forkexec_SOURCES = test_forkexec.c forkexec.c log.c
+test_ilistcreate_SOURCES = test_ilistcreate.c ilistcreate.c log.c
+test_parameter_SOURCES = test_parameter.c parameter.c log.c
+test_qemuarch_SOURCES = test_qemuarch.c qemuarch.c file.c log.c
+test_qemuipsanitize_SOURCES = test_qemuipsanitize.c qemuipsanitize.c log.c
-check-local: fastcheck slowcheck
+tests_004_test_fopen64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
+tests_015_test_ilistdelete_CPPFLAGS = $(AM_CPPFLAGS) -pthread
+tests_015_test_ilistdelete_LDFLAGS = $(AM_LDFLAGS) -pthread
+tests_016_memleakcheck_CFLAGS = $(AM_CFLAGS) -g
+tests_018_testcxx_SOURCES = tests/018_testcxx.cc
-.PHONY: check-local fastcheck slowcheck
+AM_TESTS_ENVIRONMENT = COWDANCER_SO=$(abs_builddir)/@objdir@/libcowdancer.so; \
+ export COWDANCER_SO; \
+ PATH="$(abs_builddir):$(abs_builddir)/@objdir@:$(abs_srcdir)/tests:$$PATH"; \
+ export PATH;
diff --git a/configure.ac b/configure.ac
index 760f706..cc153e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_INIT([cowdancer], m4_esyscmd_s([dpkg-parsechangelog -S version]))
AC_PREREQ([2.68])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([subdir-objects])
LT_INIT
AM_MAINTAINER_MODE
@@ -11,6 +11,8 @@ dnl Check this is the right directory
AC_CONFIG_SRCDIR([cowdancer.c])
AC_PROG_CC
+dnl Only needed for a single test
+AC_PROG_CXX
AC_CHECK_LIB([ncurses],
[setupterm],
diff --git a/tests/002_test_open.sh b/tests/002_test_open.sh
index 7657fb3..e870806 100755
--- a/tests/002_test_open.sh
+++ b/tests/002_test_open.sh
@@ -4,8 +4,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/002_test_open.c)
-RUNC=$(readlink -f tests/run_c.sh)
cd ${TESTDIR}
mkdir 1/
@@ -20,7 +18,7 @@ cp -al 1/ 2
echo " 2/ before"
ls -li 2/
-cow-shell $RUNC $TESTCODE 2/a 2/b 2/c
+cow-shell 002_test_open 2/a 2/b 2/c
echo " 2/ after"
ls -li 2/
diff --git a/tests/003_test_fopen.sh b/tests/003_test_fopen.sh
index fa127c1..1e473ba 100755
--- a/tests/003_test_fopen.sh
+++ b/tests/003_test_fopen.sh
@@ -3,8 +3,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/003_test_fopen.c)
-RUNC=$(readlink -f tests/run_c.sh)
cd ${TESTDIR}
mkdir 1/
@@ -20,7 +18,7 @@ cp -al 1/ 2
echo " 2/ before"
ls -li 2/
-cow-shell $RUNC $TESTCODE 2/a 2/b 2/c
+cow-shell 003_test_fopen 2/a 2/b 2/c
echo " 2/ after"
ls -li 2/
diff --git a/tests/004_test_fopen64.sh b/tests/004_test_fopen64.sh
index 5e4df69..3ce93ff 100755
--- a/tests/004_test_fopen64.sh
+++ b/tests/004_test_fopen64.sh
@@ -3,9 +3,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/004_test_fopen64.c)
-RUNC=$(readlink -f tests/run_c.sh)
-
cd ${TESTDIR}
mkdir 1/
@@ -20,7 +17,7 @@ cp -al 1/ 2
echo " 2/ before"
ls -li 2/
-cow-shell $RUNC $TESTCODE 2/a 2/b 2/c
+cow-shell 004_test_fopen64 2/a 2/b 2/c
echo " 2/ after"
ls -li 2/
diff --git a/tests/012_test_chown.sh b/tests/012_test_chown.sh
index c9690ac..124a49d 100755
--- a/tests/012_test_chown.sh
+++ b/tests/012_test_chown.sh
@@ -3,8 +3,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/012_test_chown.c)
-RUNC=$(readlink -f tests/run_c.sh)
set -- $(id -G)
#export COWDANCER_DEBUG=yes
@@ -15,7 +13,7 @@ NEWID=$2
if (( $# < 3 )); then
echo "W: Needs multiple groups for user $(id) for this test to succeed, test skipped"
- exit 0
+ exit 77
fi
cd ${TESTDIR}
@@ -33,7 +31,7 @@ cp -al 1/ 2
echo " 2/ before"
ls -li 2/
-cow-shell $RUNC $TESTCODE $NEWID 2/a 2/b 2/c
+cow-shell 012_test_chown $NEWID 2/a 2/b 2/c
echo " 2/ after"
ls -li 2/
diff --git a/tests/013_test_chmod.sh b/tests/013_test_chmod.sh
index c1c0fd5..2507a73 100755
--- a/tests/013_test_chmod.sh
+++ b/tests/013_test_chmod.sh
@@ -3,9 +3,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/013_test_chmod.c)
-RUNC=$(readlink -f tests/run_c.sh)
-
cd ${TESTDIR}
mkdir 1/
@@ -21,7 +18,7 @@ cp -al 1/ 2
echo " 2/ before"
ls -li 2/
-cow-shell $RUNC $TESTCODE 2/a 2/b
+cow-shell 013_test_chmod 2/a 2/b
echo " 2/ after"
ls -li 2/
diff --git a/tests/014_ilistdump_test.sh b/tests/014_ilistdump_test.sh
old mode 100644
new mode 100755
diff --git a/tests/015_test_ilistdelete.sh b/tests/015_test_ilistdelete.sh
old mode 100644
new mode 100755
index 21a4a64..5b076a0
--- a/tests/015_test_ilistdelete.sh
+++ b/tests/015_test_ilistdelete.sh
@@ -4,9 +4,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/015_test_ilistdelete.c)
-RUNC=$(readlink -f tests/run_c.sh)
-
(
cd ${TESTDIR}
mkdir 1/
@@ -15,9 +12,9 @@ RUNC=$(readlink -f tests/run_c.sh)
cp -al 1 2
dd if=/dev/zero of=1/e bs=512 count=2
- cow-shell $RUNC $TESTCODE
+ cow-shell 015_test_ilistdelete
)
RET=$?
rm -rf ${TESTDIR}
-exit $RET
\ No newline at end of file
+exit $RET
diff --git a/tests/018_testcxx.sh b/tests/018_testcxx.sh
index 94a9655..57823c5 100755
--- a/tests/018_testcxx.sh
+++ b/tests/018_testcxx.sh
@@ -3,9 +3,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/018_testcxx.cc)
-RUNCXX=$(readlink -f tests/run_cxx.sh)
-
(
set -ex
cd ${TESTDIR}
@@ -13,7 +10,7 @@ RUNCXX=$(readlink -f tests/run_cxx.sh)
touch 1/a 1/b 1/c 1/d
dd if=/dev/zero of=1/e bs=512 count=2
cp -al 1 0
- cow-shell $RUNCXX $TESTCODE
+ cow-shell 018_testcxx
cat 1/a
cat 0/a
! diff -u 1/a 0/a
diff --git a/tests/020_test_lchown.sh b/tests/020_test_lchown.sh
index e96a6ae..338171f 100755
--- a/tests/020_test_lchown.sh
+++ b/tests/020_test_lchown.sh
@@ -3,8 +3,6 @@
set -ex
TESTDIR=$(mktemp -d )
-TESTCODE=$(readlink -f tests/012_test_chown.c)
-RUNC=$(readlink -f tests/run_c.sh)
set -- $(id -G)
# assumes that this user has multiple groups.
@@ -13,7 +11,7 @@ NEWID=$2
if (( $# < 3 )); then
echo "W: Needs multiple groups for user $(id) for this test to succeed, test skipped"
- exit 0
+ exit 77
fi
cd ${TESTDIR}
@@ -34,7 +32,7 @@ cp -al 1/ 2
echo " 2/ before"
ls -li 2/
-cow-shell $RUNC $TESTCODE $NEWID 2/f 2/b 2/g
+cow-shell 012_test_chown $NEWID 2/f 2/b 2/g
echo " 2/ after"
ls -li 2/
diff --git a/tests/021_test_open.sh b/tests/021_test_open.sh
index 2a45268..4ea4e75 100755
--- a/tests/021_test_open.sh
+++ b/tests/021_test_open.sh
@@ -4,7 +4,6 @@ set -ex
TESTDIR=$(mktemp -d )
TESTCODE=$(readlink -f tests/021_test_open.c)
-RUNC=$(readlink -f tests/run_c.sh)
cd "${TESTDIR}"
mkdir 1/
@@ -14,9 +13,9 @@ ln -s a 1/f
ln -s b 1/g
cp -al 1/ 2
# first, exclude non-cowdancer problem
-"$RUNC" "${TESTCODE}" "${TESTCODE}"
+021_test_open "${TESTCODE}"
#check that cowdancer works.
-cow-shell "$RUNC" "${TESTCODE}" "${TESTCODE}"
+cow-shell 021_test_open "${TESTCODE}"
RET=$?
echo $RET
diff --git a/tests/022_kernel_waitpid.sh b/tests/022_kernel_waitpid.sh
index 9f8d3cb..771a5fe 100755
--- a/tests/022_kernel_waitpid.sh
+++ b/tests/022_kernel_waitpid.sh
@@ -2,7 +2,4 @@
# just test kernel functionality on waitpid.
set -ex
-TESTCODE=$(readlink -f tests/022_kernel_waitpid.c)
-RUNC=$(readlink -f tests/run_c.sh)
-
-$RUNC $TESTCODE
+022_kernel_waitpid
diff --git a/tests/run_c.sh b/tests/run_c.sh
deleted file mode 100755
index 0555e46..0000000
--- a/tests/run_c.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-# Run C program which might be ran with binfmtc
-
-# parameter parsing
-
-SOURCEFILE="$1"
-CMDOPTS=$(head -1 "${SOURCEFILE}" | sed -n 's,/[*]BINFMTC: ,,p')
-DEFAULT=" -O2 -Wall "
-TEMPFILE=$(tempfile -m 700)
-shift
-
-gcc ${DEFAULT} ${CMDOPTS} "${SOURCEFILE}" -o ${TEMPFILE}
-${TEMPFILE} "$@"
-RET=$?
-rm -f ${TEMPFILE}
-exit ${RET}
\ No newline at end of file
diff --git a/tests/run_cxx.sh b/tests/run_cxx.sh
deleted file mode 100755
index 6f568af..0000000
--- a/tests/run_cxx.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-# Run C program which might be ran with binfmtc
-
-# parameter parsing
-
-SOURCEFILE="$1"
-CMDOPTS=$(head -1 "${SOURCEFILE}" | sed -n 's,/[*]BINFMTCXX: ,,p')
-DEFAULT=" -O2 -Wall "
-TEMPFILE=$(tempfile -m 700)
-shift
-
-g++ ${DEFAULT} ${CMDOPTS} "${SOURCEFILE}" -o ${TEMPFILE}
-${TEMPFILE} "$@"
-RET=$?
-rm -f ${TEMPFILE}
-exit ${RET}
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/cowdancer.git
More information about the Pbuilder-maint
mailing list