File: testerrors.test

package info (click to toggle)
libfyaml 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,328 kB
  • sloc: ansic: 62,193; asm: 8,692; sh: 1,628; makefile: 581; python: 23
file content (55 lines) | stat: -rwxr-xr-x 973 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
#!/usr/bin/env bash

count=0
for dir in "${SRCDIR}"/test-errors/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do
	count=`expr $count + 1`
done

# output plan
echo 1..$count

i=0
for dir in "${SRCDIR}"/test-errors/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do

	i=`expr $i + 1`
	desctxt=`cat 2>/dev/null "$dir/==="`
	tdir=`basename $dir`

	t=`mktemp`

	res="not ok"

	pass_yaml=0
	${TOP_BUILDDIR}/src/fy-tool --dump --no-streaming -r "$dir/in.yaml" >"$t" 2>&1
	if [ $? -eq 0 ]; then
		pass_yaml=1
	fi

	errmsg=`cat "$t" | head -n1 | sed -e 's/^[^:]*//'`
	echo "errmsg: $errmsg"

	# replace with error message
	echo "$errmsg" >"$t"

	# all errors test are expected to fail
	if [ "$pass_yaml" == "0" ]; then
		res="ok"

		# diff is pointless under valgrind
		if [ "x$USE_VALGRIND" == "x" ]; then
			diff_err=0
			diff -u "$dir/test.error" "$t"
			if [ $? -eq 0 ]; then
				res="ok"
			else
				res="not ok"
			fi
		fi
	else
		res="not ok"
	fi

	rm -f "$t"

	echo "$res $i $tdir - $desctxt"
done