File: Common

package info (click to toggle)
fped 0.0%2Br5986-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 900 kB
  • sloc: ansic: 12,009; yacc: 1,088; sh: 688; lex: 197; makefile: 132
file content (85 lines) | stat: -rwxr-xr-x 1,327 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
#
# Common - Elements shared by all regression tests for fped
#
# 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.
#


fped()
{
    echo -n "$1: " 1>&2
    shift
    cat >_in
    $VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 || {
	echo FAILED "($SCRIPT)" 1>&2
	cat _out
	rm -f _in _out
	exit 1
    }
    rm -f _in
}


fped_dump()
{
	fped "$@" -T
}


fped_fail()
{
    echo -n "$1: " 1>&2
    shift
    cat >_in
    $VALGRIND ${FPED:-../fped} -T _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 "$FPED" -a "$FPED" = "${FPED#/}" ]; then
    FPED="$CWD_PREFIX/$FPED"
fi