mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2025-04-21 12:27:27 +03:00
qpkg: added regression test harness and a few tests
- Makefile (test, tests, valgrind): new targets to run regression tests - test/Common: test harness (adapted from fped) - test/minpkg: test minimum package definition - test/prereq: test basic prerequisite queries
This commit is contained in:
79
qpkg/test/Common
Executable file
79
qpkg/test/Common
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Common - Elements shared by all regression tests for qpkg
|
||||
#
|
||||
# Written 2010 by Werner Almesberger
|
||||
# Copyright 2010 Werner Almesberger
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
|
||||
|
||||
qpkg()
|
||||
{
|
||||
echo -n "$1: " 1>&2
|
||||
shift
|
||||
cat >_in
|
||||
$VALGRIND ${QPKG:-../qpkg} _in "$@" >_out 2>&1 || {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _out
|
||||
rm -f _in _out
|
||||
exit 1
|
||||
}
|
||||
rm -f _in
|
||||
}
|
||||
|
||||
|
||||
qpkg_fail()
|
||||
{
|
||||
echo -n "$1: " 1>&2
|
||||
shift
|
||||
cat >_in
|
||||
$VALGRIND ${QPKG:-../qpkg} _in "$@" >_out 2>&1 && {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _out
|
||||
rm -f _in _out
|
||||
exit 1
|
||||
}
|
||||
rm -f _in
|
||||
}
|
||||
|
||||
|
||||
expect()
|
||||
{
|
||||
diff -u - "$@" _out >_diff || {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _diff 1>&2
|
||||
rm -f _out _diff
|
||||
exit 1
|
||||
}
|
||||
echo PASSED 1>&2
|
||||
rm -f _out _diff
|
||||
passed=`expr ${passed:-0} + 1`
|
||||
}
|
||||
|
||||
|
||||
expect_grep()
|
||||
{
|
||||
grep "$1" <_out >_tmp || exit 1
|
||||
mv _tmp _out
|
||||
shift
|
||||
expect "$@"
|
||||
}
|
||||
|
||||
|
||||
expect_sed()
|
||||
{
|
||||
sed "$1" <_out >_tmp || exit 1
|
||||
mv _tmp _out
|
||||
shift
|
||||
expect "$@"
|
||||
}
|
||||
|
||||
|
||||
if [ ! -z "$CWD_PREFIX" -a ! -z "$QPKG" -a "$QPKG" = "${QPKG#/}" ]; then
|
||||
QPKG="$CWD_PREFIX/$QPKG"
|
||||
fi
|
||||
Reference in New Issue
Block a user