File: run_tests.sh

package info (click to toggle)
virtuoso-opensource 7.2.12%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 299,780 kB
  • sloc: ansic: 655,047; sql: 508,209; xml: 269,573; java: 84,064; javascript: 79,847; cpp: 37,662; sh: 32,429; cs: 25,702; php: 12,690; yacc: 11,661; lex: 7,933; makefile: 7,309; jsp: 4,523; awk: 1,719; perl: 1,013; ruby: 1,003; python: 326
file content (269 lines) | stat: -rwxr-xr-x 7,039 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/bin/sh
#
#  $Id$
#
#  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
#  project.
#
#  Copyright (C) 1998-2024 OpenLink Software
#
#  This project 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; only version 2 of the License, dated June 1991.
#
#  This program is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

# ----------------------------------------------------------------------
#  Fix issues with LOCALE
# ----------------------------------------------------------------------
LANG=C
LC_ALL=POSIX
export LANG LC_ALL


SERVER=${SERVER-virtuoso}
THOST=${THOST-localhost}
TPORT=${TPORT-8440}
PORT=${PORT-1940}
URLSIMU=$HOME/binsrc/tests/urlsimu
SUITE_LISTFILE=${SUITE_LISTFILE-$1}

HOST_OS=`uname -s | grep WIN`
if [ "x$HOST_OS" != "x" ]
then
TEMPFILE="`cygpath -m $TMP/isql.$$`"
if [ "x$SRC" != "x" ]
then
HOME=$SRC
else
HOME="`cygpath -m $HOME`"
fi
LN="cp -rf"
RM="rm -rf"
else
TEMPFILE=/tmp/isql.$$
LN="ln -fs"
RM="rm -f"
fi

if [ -f /usr/xpg4/bin/rm ]
then
  myrm=/usr/xpg4/bin/rm
else
  myrm=rm
fi

if [ -f /usr/xpg4/bin/grep ]
then
  mygrep=/usr/xpg4/bin/grep
else
  mygrep=grep
fi


if [ -f /usr/xpg4/bin/awk ]
then
  myawk=/usr/xpg4/bin/awk
else
  myawk=awk
fi

if [ "x$HOST_OS" != "x" ]
then
  URLSIMU=../urlsimu.exe
  . ../suite/test_fn.sh
else
. $HOME/binsrc/tests/suite/test_fn.sh
fi

http_get() {
  file=$1
  if [ "$2" -gt "0" ]
  then
    pipeline="-P -c $2"
  else
    pipeline=""
  fi
  user=${3-dba}
  pass=${4-dba}
  $URLSIMU $file $pipeline -u $user -p $pass
}

do_command() {
  _dsn=$1
  command=$2
  shift
  shift
  echo "+ " $ISQL $_dsn dba dba ERRORS=STDOUT VERBOSE=OFF PROMPT=OFF "EXEC=$command" $*		>> $LOGFILE
  $ISQL $_dsn dba dba ERRORS=STDOUT VERBOSE=OFF PROMPT=OFF "EXEC=$command" $* >> $LOGFILE
  if test $? -ne 0
  then
    LOG "***FAILED: $command"
  else
    LOG "PASSED: $command"
  fi
}

process_commands() {
  echo "process_commands - $1"
  urlsimu_cmd="urlsimu.cmd"
  urlsimu_out="urlsimu.output"
  list_file=$1
  total=0
  total_failed=0
  cmdfile=""
  check=""
  failed=0
  oldIFS=IFS
  IFS='\
'
  for line in `cat $list_file`
  do

    if echo "$line" | $mygrep -e "^#" >/dev/null
    then
      # Comment
      continue
    fi
    if echo "$line" | $mygrep -e "^$" >/dev/null
    then
      # Empy line
      continue
    fi
    if echo "$line" | $mygrep -e "^RUN" >/dev/null
    then
      if [ $total -ne 0 ]
      then
        if [ $failed -ne 0 ]
        then
          total_failed=`expr $total_failed + 1`
          cp "$urlsimu_out" "$urlsimu_out"_"$total".error
          LOG "***FAILED: $run_cmd, $check"
        else
          LOG "PASSED: $run_cmd"
        fi
      fi
      run_cmd="$line"
      failed=0
      total=`expr $total + 1`
      cmdfile=`echo "$line" | $myawk '{print $2}'`
      # Create command file for urlsimu
      $myawk -v server="$THOST" -v port="$TPORT" -f filter.awk "$cmdfile" > "$urlsimu_cmd"
      # Execute it
      http_get "$urlsimu_cmd" 0 > "$urlsimu_out"
      continue
    fi
    if echo "$line" | $mygrep -e 'CHECK_EXISTS' >/dev/null
    then
      cmdline=`echo "$line" | $myawk ' BEGIN {ORS=" "} {for(k=2; k<NF; k++) {print $k} {ORS=""} {print $NF}}'`
      if $mygrep "$cmdline" "$urlsimu_out" >/dev/null
	then
	    echo >/dev/null
	else
        check=$line
        failed=1
      fi
      continue
    fi
    if echo "$line" | $mygrep -e 'CHECK_NOTEXISTS' >/dev/null
    then
      cmdline=`echo "$line" | $myawk ' BEGIN {ORS=" "} {for(k=2; k<NF; k++) {print $k} {ORS=""} {print $NF}}'`
      if $mygrep "$cmdline" "$urlsimu_out" >/dev/null
      then
        check=$line
        failed=1
      fi
      continue
    fi
    if echo "$line" | $mygrep -e 'SQL' >/dev/null
    then
      check=$line
      cmdfile=`echo "$line" | $myawk ' BEGIN {ORS=" "} {for(k=2; k<NF; k++) {print $k} {ORS=""} {print $NF}}'`
      cmdline=`cat $cmdfile`
      do_command $DSN "$cmdline"
      continue
    fi
    if echo "$line" | $mygrep -e 'XPATH_EXISTS' >/dev/null
    then
      expr=`echo "$line" | $myawk ' BEGIN {ORS=" "} {for(k=2; k<NF; k++) {print $k} {ORS=""} {print $NF}}'`
      sqlcmd="foreach blob in $urlsimu_out select DB.DBA.sys_xpath_localfile_eval(?, '$expr')"
      echo "NULL" >./xpath_result
      $ISQL $DSN dba dba ERRORS=STDOUT VERBOSE=OFF PROMPT=OFF "EXEC=$sqlcmd" >./xpath_result
      xpath_result=`$myawk 'BEGIN {ORS=""} {if(NR==1){print $0}}' < ./xpath_result`
      if [ -z "$xpath_result" ]
      then
        check=$line
        LOG "***Invalid XPATH expression:"
        LOG `cat ./xpath_result`
        failed=1
        continue
      fi
      if [ NULL = "$xpath_result" ]
      then
        check=$line
        failed=1
      fi
      continue
    fi
    if echo "$line" | $mygrep -e 'XPATH_NOTEXISTS' >/dev/null
    then
      expr=`echo "$line" | $myawk ' BEGIN {ORS=" "} {for(k=2; k<NF; k++) {print $k} {ORS=""} {print $NF}}'`
      sqlcmd="foreach blob in $urlsimu_out select DB.DBA.sys_xpath_localfile_eval(?, '$expr')"
      echo "NULL" >./xpath_result
      $ISQL $DSN dba dba ERRORS=STDOUT VERBOSE=OFF PROMPT=OFF "EXEC=$sqlcmd" >./xpath_result
      xpath_result=`$myawk 'BEGIN {ORS=""} {if(NR==1){print $0}}' < ./xpath_result`
      if [ -z "$xpath_result" ]
      then
        check=$line
        LOG "***Invalid XPATH expression:"
        LOG `cat ./xpath_result`
        failed=1
        continue
      fi
      if [ NULL != "$xpath_result" ]
      then
        check=$line
        failed=1
      fi
      continue
    fi
  done
  if [ $total -ne 0 ]
  then
    if [ $failed -ne 0 ]
    then
      total_failed=`expr $total_failed + 1`
      cp "$urlsimu_out" "$urlsimu_out"_"$total".error
      LOG "***FAILED: $run_cmd, $check"
    else
      LOG "PASSED: $run_cmd"
    fi
  fi
  IFS="$oldIFS"
  passed=`expr $total - $total_failed`
  LOG ""
  LOG "------------------------ RESULTS ------------------------"
  LOG "--                                                       "
  LOG "-- TOTAL: $total                                         "
  LOG "--                                                       "
  LOG "-- PASSED: $passed                                       "
  LOG "--                                                       "
  LOG "-- FAILED: $total_failed                                 "
  LOG "--                                                       "
  LOG "------------------------ RESULTS ------------------------"
  LOG ""
  $myrm urlsimu.cmd 2>/dev/null
  $myrm xpath_result 2>/dev/null
  $myrm urlsimu.output 2>/dev/null
}

process_commands $SUITE_LISTFILE