File: safe_to_xml.sh

package info (click to toggle)
geos 3.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 28,996 kB
  • sloc: cpp: 157,310; xml: 53,816; ansic: 6,956; sh: 302; makefile: 30
file content (143 lines) | stat: -rwxr-xr-x 3,116 bytes parent folder | download | duplicates (2)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh

#######################################################################
#
# GEOS - Geometry Engine Open Source
# http://geos.osgeo.org
#
# Copyright (C) 2009 Sandro Santilli <strk@kbt.io>
#
# This is free software; you can redistribute and/or modify it under
# the terms of the GNU Lesser General Public Licence as published
# by the Free Software Foundation. 
# See the COPYING file for more information.
#
#######################################################################
#
# This script is an utility to convert SAFE Software testcases to
# the format accepted by XMLTester
#
#######################################################################

if ! test -n "$1"; then
	echo "Usage: $0 <testno>"
	exit 1
fi

SAFETESTNO="$1"

SAFEIN=${SAFETESTNO}_input.txt
SAFEPARAMS=${SAFETESTNO}_params.txt

if ! test -e ${SAFEIN}; then echo "Missing ${SAFEIN}"; exit 1; fi
#if ! test -e ${SAFEOUT_LEFT}; then echo "Missing ${SAFEOUT_LEFT}"; exit 1; fi
#if ! test -e ${SAFEOUT_RIGHT}; then echo "Missing ${SAFEOUT_RIGHT}"; exit 1; fi
if ! test -e ${SAFEOUT_PARAMS}; then echo "Missing ${SAFEOUT_PARAMS}"; exit 1; fi


exec 4< ${SAFEIN}

#exec 5< ${SAFEOUT_LEFT}
#exec 6< ${SAFEOUT_LEFT}

#echo '<run>'
#echo '<precisionModel type="FLOATING" />'

# Parse parameters/tests
TESTS=${SAFEIN}_tests
exec 7< ${SAFEPARAMS}
exec 8> ${TESTS}
arg2=na
style=na
opname=na
while read line <&7; do

	# end of test
	if test -z "${line}"; then
		testline="<op name='buffersinglesided' arg1='a' arg2='${arg2}' arg3='4' arg4='${style}'>|${opname}"
		echo ${testline} >&8
	fi

	lbl=`echo ${line} | cut -d: -f1`
	val=`echo ${line} | cut -d: -f2`

	if test "${lbl}" = "Buffer Amount"; then

		arg2=${val}

	elif test "${lbl}" = "Buffer Style"; then

      # No quotes around ${val} is intentional, to trim blanks
		if test ${val} = "RIGHT_SIDE_ONLY"; then
			style=right
		else
			style=left
		fi

	elif test "${lbl}" = "Interpolation Angle"; then

		continue

	else

		opname=`echo ${lbl} | cut -d' ' -f 2 | tr '[A-Z]' ['a-z']`
		if test "${opname}" = 'left' -o "${opname}" = 'right'; then
			opname="_${opname}"
		fi

	fi
		
done

testline="<op name='buffersinglesided' arg1='a' arg2='${arg2}' arg3='4' arg4='${style}'>|${opname}"
echo ${testline} >&8

echo '<run>'
echo '<precisionModel type="FLOATING" />'

# A case each input
caseno=1
while read inp <&4; do

	echo "<case><desc>SAFE test ${SAFETESTNO} line ${caseno}</desc>"
	echo '<a>'

	# hack until GEOS supports proper OGC WKT: POINT Z (0 0)
	inp=`echo "${inp}" | sed -e 's/ Z //'`
	echo ${inp}
	echo '</a>'


	# A test each param
	exec 9< ${TESTS}
	while read testspec <&9; do

		test=`echo "${testspec}" | cut -d'|' -f1`
		out=`echo "${testspec}" | cut -d'|' -f2`

		echo '<test>'
		echo '  '${test}

		# read line from line ${caseno} of ${SAFEOUT}
		SAFEOUT=${SAFETESTNO}_output${out}.txt
		expout=`head -${caseno} ${SAFEOUT} | tail -1`

		# hack until GEOS supports proper OGC WKT: POINT Z (0 0)
		expout=`echo "${expout}" | sed -e 's/ Z //'`

		echo ${expout}

		echo '  </op>'
		echo '</test>'

	done


	echo '</case>'

	caseno=$((caseno+1))


done

echo '</run>'