aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2007-02-22 13:01:24 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2007-02-22 13:01:24 +0000
commit87f50a0d0933b3a61e5f48b7683f92cb4478dfd2 (patch)
treef0b06fdaf572f232edb7071a49f24d9abebb3a56
parentf3234ef5dcce7d8998bbc77e3ac9f7f87ef0e952 (diff)
downloadrpm-setup-87f50a0d0933b3a61e5f48b7683f92cb4478dfd2.tar
rpm-setup-87f50a0d0933b3a61e5f48b7683f92cb4478dfd2.tar.gz
rpm-setup-87f50a0d0933b3a61e5f48b7683f92cb4478dfd2.tar.bz2
rpm-setup-87f50a0d0933b3a61e5f48b7683f92cb4478dfd2.tar.xz
rpm-setup-87f50a0d0933b3a61e5f48b7683f92cb4478dfd2.zip
- add regression tests
-rw-r--r--Makefile.am11
-rw-r--r--configure.ac7
-rw-r--r--rpmeval.c25
-rwxr-xr-xtests.sh18
-rwxr-xr-xtests/macros.sh28
5 files changed, 88 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 3a4270b..a7dd254 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,6 +38,12 @@ BUILT_SOURCES = macros-perarch make_macrosfiles.sh
pkglibdir = @RPMVENDORDIR@
+bin_PROGRAMS = rpmeval
+
+rpmeval_SOURCES = rpmeval.c
+
+rpmeval_LDFLAGS = -lrpm
+
pkglib_DATA = \
$(pkg_data) \
$(pkg_gdata)
@@ -75,12 +81,15 @@ install-data-local: $(macrosfiles)
$(install_sh_DATA) $${i}.macros $(DESTDIR)$(RPMVENDORDIR)/$${i}-$(RPMOS)/macros; \
done
-.PHONY: ChangeLog
+.PHONY: ChangeLog test
ChangeLog:
LC_ALL=C svn2cl --accum
rm -f *.bak
+test: $(pkg_gdata) $(pkg_gscripts) $(macrosfiles)
+ sh tests.sh
+
CLEANFILES = $(pkg_gdata) $(pkg_gscripts) $(macrosfiles) \
macros-perarch \
make_macrosfiles.sh
diff --git a/configure.ac b/configure.ac
index bce1b20..d7374e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,11 +10,17 @@ AM_INIT_AUTOMAKE(1.9)
AC_CONFIG_SRCDIR
# Checks for programs.
+AC_PROG_CC
AC_PROG_INSTALL
+AC_PROG_LIBTOOL
AC_CONFIG_FILES([
Makefile
])
+AC_CHECK_LIB([rpmio], [rpmLoadMacroFile])
+AC_HEADER_STDC
+AC_CHECK_HEADERS([string.h rpm/rpmmacros.h rpm/rpmlib.h])
+
case "${target_cpu}" in
*86|athlon|k6)
RPMALLARCH="i386 i486 i586 i686 k6 athlon pentium3 pentium4"
@@ -99,4 +105,5 @@ if test $with_rpmsysconfdir; then
fi
AC_SUBST(RPMSYSCONFDIR)
+
AC_OUTPUT
diff --git a/rpmeval.c b/rpmeval.c
new file mode 100644
index 0000000..c377dec
--- /dev/null
+++ b/rpmeval.c
@@ -0,0 +1,25 @@
+/* $Id$ */
+
+#include <rpm/rpmlib.h>
+#include <rpm/rpmmacro.h>
+
+int main(int argc, char **argv)
+{
+ int rc;
+ char *results;
+ if (argc != 3) {
+ fprintf(stdout, "Not enough argument: %d\n", argc);
+ return 1;
+ }
+ if (rc = rpmReadConfigFiles(NULL, NULL)) {
+ fprintf(stderr, "Cannot load configuration\n");
+ return rc;
+ }
+ if (rc = rpmLoadMacroFile(rpmGlobalMacroContext, argv[1])) {
+ fprintf(stderr, "Cannot read %s\n", argv[1]);
+ return rc;
+ }
+ results = rpmExpand(argv[2], NULL);
+ fprintf(stdout, "%s\n", results);
+ return 0;
+}
diff --git a/tests.sh b/tests.sh
new file mode 100755
index 0000000..99c333b
--- /dev/null
+++ b/tests.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# $Id$
+
+allerrs=0
+
+for i in tests/*.sh; do
+ /bin/sh ${i}
+ err=$?
+ if [ $err -ne 0 ]; then
+ echo "${i}: $err test(s) failed"
+ allerrs=$[ $allerrs + $err ]
+ else
+ echo "${i}: All test succefully passed"
+ fi
+done
+
+exit $allerrs
diff --git a/tests/macros.sh b/tests/macros.sh
new file mode 100755
index 0000000..519e7b4
--- /dev/null
+++ b/tests/macros.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# $Id$
+
+RPMEVAL=./rpmeval
+
+err=0
+
+mcheck() {
+ macro=$1
+ is=$2
+ echo -n "${macro}... "
+ res=`$RPMEVAL macros ${macro}`
+ if [ "X${res}" != "X${is}" ]; then
+ echo "give ${res} not ${is}"
+ err=$[ $err + 1]
+ else
+ echo "OK"
+ fi
+}
+
+mcheck %_var /var
+mcheck %_localstatedir /var/lib
+mcheck %_bindir /usr/bin
+mcheck %_sbindir /usr/sbin
+mcheck %_prefix /usr
+
+exit $err