1
verify_test_context() {
2
if [ -z "$TEST_NAME" -a ! "$USING_TET" ]; then
3
echo "A test context must be established with 'test_start <name>'!"
8
## record the test a name.
15
if [ $USING_TET ]; then
16
tet_infoline $TEST_NAME
19
echo -n "[`date`] $TEST_NAME: "
26
FAIL_MESSAGE="$FAIL_MESSAGE\n$*"
27
if [ "$USING_TET" ] ; then
38
## provide a nice way to document the test purpose
41
# TODO: generate a manpage or something.
45
# TODO: generate even more docs.
48
## Used for setup/dependency verification.
58
## Called after test_init()
61
## Make sure nothing screwed up in initilization
62
if [ "$TEST_STATUS" != "PASS" ]; then
63
# Something failed before we could get to the test.
65
test_result NORESULT "Initilization failed!"
69
## Must be within test_procedure
72
if [ "$TEST_STATUS" == FAIL ] ; then
78
## Report the test's result.
82
# Set status appropriately
83
if [ ! -z "$1" ]; then
86
if [ "$TEST_STATUS" = "FAIL" ] ; then
90
# if we have a message, save it
91
if [ ! -z "$2" ]; then
94
if [ "$USING_TET" ]; then
95
tet_result $TEST_STATUS
97
# not using tet, so print nice explanation
99
[ -z "$USING_TET" ] && echo -n "$TEST_STATUS"
101
## Result codes MUST agree with tet_codes
102
## for LSB/tet integration.
103
case "$TEST_STATUS" in
107
[ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
110
[ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
113
[ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
116
[ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
119
[ -z "$USING_TET" ] && echo -ne " - UNKNOWN STATUS\n$FAIL_MESSAGE"
123
[ -z "$USING_TET" ] && echo ""
132
if [ $# -lt 2 ] ; then
133
echo "TEST SYNTAX ERROR: use_file must have two arguments" >&2
139
outfile="xdgtestdata-$XDG_TEST_ID-$file"
140
eval "$varname=$outfile"
142
cp "$src" "$XDG_TEST_TMPDIR/$outfile"
148
if [ -z "$varname" ] ; then
149
echo "TEST SYNAX ERROR: get_unique_name requries a variable name"
153
outfile="xdgtestdata-$XDG_TEST_ID-$file"
154
eval "$varname=$outfile"
163
if [ $# -lt 3 ] ; then
164
echo "TEST SYNTAX ERROR: edit_file must have at least 3 arguments."
170
if [ -z "$newstr" ] ; then
171
newstr="xdgtestdata-$XDG_TEST_ID-$origstr"
174
eval "$varname=\"$newstr\""
176
sed -i -e "s|$origstr|$newstr|g" "$file"