File indexing completed on 2024-05-19 04:32:47

0001 #!/bin/sh 
0002 # -xvf
0003 #
0004 
0005 VALGRIND=
0006 
0007 if [ "x$1" == "x-v" ]; then
0008         VALGRIND="valgrind -v --tool=memcheck --num-callers=25";
0009 fi
0010 
0011 if [ "x$1" == "x-t" ]; then
0012         VALGRIND="valgrind -v --tool=helgrind --num-callers=25";
0013 fi
0014 
0015 
0016 ######### All settings are above this line
0017 
0018 CONSOLELOG=`mktemp /tmp/Kst_ConsoleLog.XXXXXX` || exit 4
0019 echo Logging to $CONSOLELOG
0020 
0021 $VALGRIND kst --nq >$CONSOLELOG 2>&1 &
0022 
0023 DCOP="dcop kst-$! KstIface"
0024 QUIT="dcop kst-$! MainApplication-Interface quit"
0025 
0026 TMPFILE=`mktemp /tmp/Kst_TestSuite.XXXXXX` || exit 3
0027 
0028 
0029 doExit() {
0030         $QUIT
0031         rm $TMPFILE
0032         rm $TESTFILE
0033         rm -f $KSTFILE
0034         exit $1;
0035 }
0036 
0037 checkEmptyResponse() {
0038         if [ ! -s "$TMPFILE" ]; then
0039                 echo "Test $1 failed.  Response was non-empty. [" `cat $TMPFILE` "]"
0040                 return;
0041         fi
0042 
0043         echo -ne "Test $1 passed.\r"
0044 }
0045 
0046 checkArraySize() {
0047         LEN=`wc -l < $TMPFILE`
0048         if test ! "x$LEN" = "x$2"; then
0049                 echo "Test $1 failed.  Expected [$2] entries, received [$LEN]."
0050                 return;
0051         fi
0052 
0053         echo -ne "Test $1 passed.\r"
0054 }
0055 
0056 checkStringResponse() {
0057         TESTSTR=`cat $TMPFILE | tr -d '\n'`
0058         if test ! "x$2" = "x$TESTSTR"; then
0059                 echo "Test $1 failed.  Expected [$2], received [$TESTSTR]."
0060                 return;
0061         fi
0062 
0063         echo -ne "Test $1 passed.\r"
0064 }
0065 
0066 
0067 echo -n "Waiting for Kst launch completely."
0068 while [ 0 ]; do
0069         $DCOP >/dev/null 2>&1
0070         if [ $? -eq 0 ]; then
0071                 break;
0072         fi
0073         echo -n "."
0074         sleep 1;
0075 done
0076 echo ""
0077 
0078 
0079 declare -i cnt=0
0080 
0081 #####  All lists are empty to start
0082 $DCOP curveList >$TMPFILE
0083 checkEmptyResponse 1
0084 
0085 $DCOP plotList >$TMPFILE
0086 checkEmptyResponse 2
0087 
0088 $DCOP objectList >$TMPFILE
0089 checkEmptyResponse 3
0090 
0091 $DCOP vectorList >$TMPFILE
0092 checkEmptyResponse 4
0093 
0094 $DCOP scalarList >$TMPFILE
0095 checkEmptyResponse 5
0096 
0097 #####  Scalars
0098 $DCOP generateScalar "Scalar Test 1" 3.14159265358979 >$TMPFILE
0099 checkStringResponse 30 "Scalar Test 1"
0100 
0101 $DCOP scalar "Scalar Test 1" >$TMPFILE
0102 checkStringResponse 31 "3.141593"
0103 
0104 $DCOP generateScalar "Scalar Test 1" 0.000000000 >$TMPFILE
0105 checkStringResponse 32 "Scalar Test 1'"
0106 
0107 $DCOP scalar "Scalar Test 1'" >$TMPFILE
0108 checkStringResponse 33 "0.000000"
0109 
0110 $DCOP generateScalar "Scalar Test 1" "-33.5e+23" >$TMPFILE
0111 checkStringResponse 34 "Scalar Test 1''"
0112 
0113 $DCOP scalar "Scalar Test 1''" >$TMPFILE
0114 checkStringResponse 35 "-3349999999999999970639872.000000"
0115 
0116 $DCOP scalarList >$TMPFILE
0117 checkArraySize 36 25 
0118 
0119 #####  Vectors
0120 $DCOP generateVector "Vector Test 1" -10 10 21 >$TMPFILE
0121 checkStringResponse 100 "Vector Test 1"
0122 
0123 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0124 checkStringResponse 101 "21"
0125 
0126 # tests 102-122
0127 cnt=0
0128 while [ $cnt -lt 21 ]; do
0129         $DCOP vector "Vector Test 1" $cnt >$TMPFILE
0130         declare -i j=-10+$cnt
0131         declare -i n=102+$cnt
0132         checkStringResponse $n "$j.000000"
0133         cnt=$cnt+1;
0134 done
0135 
0136 $DCOP vector "Vector Test 1" -1 >$TMPFILE
0137 checkStringResponse 123 "0.000000"
0138 
0139 $DCOP vector "Vector Test 1" 21 >$TMPFILE
0140 checkStringResponse 124 "0.000000"
0141 
0142 $DCOP generateVector "Vector Test 2" -10 10 1 >$TMPFILE
0143 checkStringResponse 125 "Vector Test 2"
0144 
0145 # vectors must have at least 2 entries
0146 $DCOP vectorSize "Vector Test 2" >$TMPFILE
0147 checkStringResponse 126 "2"
0148 
0149 $DCOP vector "Vector Test 2" 0 >$TMPFILE
0150 checkStringResponse 127 "-10.000000"
0151 
0152 $DCOP vector "Vector Test 2" 1 >$TMPFILE
0153 checkStringResponse 128 "10.000000"
0154 
0155 $DCOP generateVector "Vector Test 3" -10 10 0 >$TMPFILE
0156 checkStringResponse 129 "Vector Test 3"
0157 
0158 $DCOP vectorSize "Vector Test 3" >$TMPFILE
0159 checkStringResponse 130 "2"
0160 
0161 $DCOP vector "Vector Test 3" 0 >$TMPFILE
0162 checkStringResponse 131 "-10.000000"
0163 
0164 $DCOP vector "Vector Test 3" 1 >$TMPFILE
0165 checkStringResponse 132 "10.000000"
0166 
0167 $DCOP generateVector "Vector Test 4" -10 10 -987 >$TMPFILE
0168 checkStringResponse 133 "Vector Test 4"
0169 
0170 $DCOP vectorSize "Vector Test 4" >$TMPFILE
0171 checkStringResponse 134 "2"
0172 
0173 $DCOP vector "Vector Test 4" 0 >$TMPFILE
0174 checkStringResponse 135 "-10.000000"
0175 
0176 $DCOP vector "Vector Test 4" 1 >$TMPFILE
0177 checkStringResponse 136 "10.000000"
0178 
0179 $DCOP generateVector "Vector Test 5" -1 -1 44 >$TMPFILE
0180 checkStringResponse 137 "Vector Test 5"
0181 
0182 $DCOP vectorSize "Vector Test 5" >$TMPFILE
0183 checkStringResponse 138 "44"
0184 
0185 $DCOP vector "Vector Test 5" 33 >$TMPFILE
0186 checkStringResponse 139 "-0.923256"
0187 
0188 $DCOP vector "Vector Test 5" 2 >$TMPFILE
0189 checkStringResponse 140 "-0.995349"
0190 
0191 $DCOP vectorList >$TMPFILE
0192 checkArraySize 141 5
0193 
0194 $DCOP clearVector "Vector Test 1" >$TMPFILE
0195 checkStringResponse 142 "true"
0196 
0197 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0198 checkStringResponse 143 "21"
0199 
0200 # tests 144-164
0201 cnt=0
0202 while [ $cnt -lt 21 ]; do
0203         $DCOP vector "Vector Test 1" $cnt >$TMPFILE
0204         declare -i n=144+$cnt
0205         checkStringResponse $n "0.000000"
0206         cnt=$cnt+1;
0207 done
0208 
0209 $DCOP resizeVector "Vector Test 1" 5 >$TMPFILE
0210 checkStringResponse 165 "true"
0211 
0212 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0213 checkStringResponse 166 "5"
0214 
0215 $DCOP resizeVector "Vector Test 1" 2 >$TMPFILE
0216 checkStringResponse 167 "true"
0217 
0218 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0219 checkStringResponse 168 "2"
0220 
0221 $DCOP resizeVector "Vector Test 1" 1 >$TMPFILE
0222 checkStringResponse 169 "true"
0223 
0224 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0225 checkStringResponse 170 "1"
0226 
0227 $DCOP resizeVector "Vector Test 1" 0 >$TMPFILE
0228 checkStringResponse 171 "false"
0229 
0230 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0231 checkStringResponse 172 "1"
0232 
0233 $DCOP resizeVector "Vector Test 1" -4 >$TMPFILE
0234 checkStringResponse 173 "false"
0235 
0236 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0237 checkStringResponse 174 "1"
0238 
0239 $DCOP resizeVector "Vector Test 1" 3 >$TMPFILE
0240 checkStringResponse 175 "true"
0241 
0242 $DCOP setVector "Vector Test 1" -1 42 >$TMPFILE
0243 checkStringResponse 176 "false"
0244 
0245 $DCOP setVector "Vector Test 1" -2 42 >$TMPFILE
0246 checkStringResponse 177 "false"
0247 
0248 $DCOP setVector "Vector Test 1" 0 42 >$TMPFILE
0249 checkStringResponse 178 "true"
0250 
0251 $DCOP setVector "Vector Test 1" 1 42.42 >$TMPFILE
0252 checkStringResponse 179 "true"
0253 
0254 $DCOP setVector "Vector Test 1" 2 42.4242 >$TMPFILE
0255 checkStringResponse 180 "true"
0256 
0257 $DCOP vector "Vector Test 1" 0 >$TMPFILE
0258 checkStringResponse 181 "42.000000"
0259 
0260 $DCOP vector "Vector Test 1" 1 >$TMPFILE
0261 checkStringResponse 182 "42.420000"
0262 
0263 $DCOP vector "Vector Test 1" 2 >$TMPFILE
0264 checkStringResponse 183 "42.424200"
0265 
0266 $DCOP setVector "Vector Test 1" 3 42.424242 >$TMPFILE
0267 checkStringResponse 184 "false"
0268 
0269 $DCOP vectorSize "Vector Test 1" >$TMPFILE
0270 checkStringResponse 185 "3"
0271 
0272 $DCOP resizeVector "Vector Test 1" 5 >$TMPFILE
0273 checkStringResponse 186 "true"
0274 
0275 $DCOP vector "Vector Test 1" 0 >$TMPFILE
0276 checkStringResponse 187 "42.000000"
0277 
0278 $DCOP vector "Vector Test 1" 1 >$TMPFILE
0279 checkStringResponse 188 "42.420000"
0280 
0281 $DCOP vector "Vector Test 1" 2 >$TMPFILE
0282 checkStringResponse 189 "42.424200"
0283 
0284 $DCOP vector "Vector Test 1" 3 >$TMPFILE
0285 checkStringResponse 190 "0.000000"
0286 
0287 $DCOP vector "Vector Test 1" 4 >$TMPFILE
0288 checkStringResponse 191 "0.000000"
0289 
0290 $DCOP setVector "Vector Test 1" 3 42.424242 >$TMPFILE
0291 checkStringResponse 192 "true"
0292 
0293 $DCOP setVector "Vector Test 1" 4 42424242.42 >$TMPFILE
0294 checkStringResponse 193 "true"
0295 
0296 $DCOP vector "Vector Test 1" 3 >$TMPFILE
0297 checkStringResponse 194 "42.424242"
0298 
0299 $DCOP vector "Vector Test 1" 4 >$TMPFILE
0300 checkStringResponse 195 "42424242.420000"
0301 
0302 $DCOP saveVector "Vector Test 1" "" >$TMPFILE
0303 checkStringResponse 196 "false"
0304 
0305 VTMPFILE=`mktemp /tmp/Kst_Vector.XXXXXX` || exit 3
0306 $DCOP saveVector "Vector Test 1" $VTMPFILE >$TMPFILE
0307 checkStringResponse 197 "true"
0308 
0309         LEN=`wc -l < $VTMPFILE`
0310         if test ! "x$LEN" = "x7"; then
0311                 echo "Test 198 failed.  Expected [7] entries, received [$LEN].";
0312         fi
0313 
0314         echo -ne "Test 198 passed.\r"
0315         rm $VTMPFILE
0316 
0317 #####  Plots
0318 
0319 $DCOP generateVector "plotinput1" 0 1000 10000 >$TMPFILE
0320 checkStringResponse 500 "plotinput1"
0321 
0322 $DCOP generateVector "plotinput2" 0 100 10000 >$TMPFILE
0323 checkStringResponse 501 "plotinput2"
0324 
0325 $DCOP createCurve "curve-ramp" "plotinput1" "plotinput2" "" "" >$TMPFILE
0326 checkStringResponse 502 "curve-ramp"
0327 
0328 $DCOP createCurve "curve-ramp2" "plotinput2" "plotinput1" "" "" >$TMPFILE
0329 checkStringResponse 503 "curve-ramp2"
0330 
0331 $DCOP createPlot "P0" >$TMPFILE
0332 checkStringResponse 504 "P0"
0333 
0334 $DCOP addCurveToPlot "P0" "curve-ramp" >$TMPFILE
0335 checkStringResponse 505 "true"
0336 
0337 $DCOP createPlot "P1" >$TMPFILE
0338 checkStringResponse 506 "P1"
0339 
0340 $DCOP addCurveToPlot "P1" "curve-ramp2" >$TMPFILE
0341 checkStringResponse 507 "true"
0342 
0343 $DCOP createPlot "P2" >$TMPFILE
0344 checkStringResponse 508 "P2"
0345 
0346 $DCOP plotEquation "plotinput1" "2*sin(x)*cos(x^2)" "P2" >$TMPFILE
0347 checkStringResponse 509 "true"
0348 
0349 VTMPFILE=`mktemp /tmp/Kst_TestPrintOut1.png.XXXXXX` || exit 3
0350 echo "Writing printout image [P0,P1,P2] to $VTMPFILE"
0351 $DCOP printImage $VTMPFILE >$TMPFILE
0352 checkStringResponse 510 "true"
0353 
0354 VTMPFILE=`mktemp /tmp/Kst_TestPrintOut1.ps.XXXXXX` || exit 3
0355 echo "Writing printout postscript [P0,P1,P2] to $VTMPFILE"
0356 $DCOP printPostScript $VTMPFILE >$TMPFILE
0357 checkStringResponse 511 "true"
0358 
0359 $DCOP deletePlot "P1" >$TMPFILE
0360 checkStringResponse 512 "true"
0361 
0362 $DCOP deletePlot "P0" >$TMPFILE
0363 checkStringResponse 513 "true"
0364 
0365 $DCOP deletePlot "P2" >$TMPFILE
0366 checkStringResponse 514 "true"
0367 
0368 VTMPFILE=`mktemp /tmp/Kst_TestPrintOut1.png.XXXXXX` || exit 3
0369 echo "Writing printout image [blank] to $VTMPFILE"
0370 $DCOP printImage $VTMPFILE >$TMPFILE
0371 checkStringResponse 515 "true"
0372 
0373 VTMPFILE=`mktemp /tmp/Kst_TestPrintOut1.ps.XXXXXX` || exit 3
0374 echo "Writing printout postscript [blank] to $VTMPFILE"
0375 $DCOP printPostScript $VTMPFILE >$TMPFILE
0376 checkStringResponse 516 "true"
0377 
0378 echo -ne "Generating a test file.\r"
0379 
0380 TESTFILE=`mktemp /tmp/Kst_TestData.XXXXXX` || exit 3
0381 declare -i ln=0
0382 while [ $ln -lt 1000 ]; do
0383   echo $ln | awk "{print $ln, sin($ln/10), ($ln/100)^2, cos($ln/10)}" >>$TESTFILE
0384   declare -i ln=1+$ln;
0385 done
0386 
0387 echo -ne "                       \r"
0388 
0389 # Must clear out the generated vectors because they don't save properly FIXME
0390 # 599
0391 $DCOP newFile >$TMPFILE
0392 
0393 # Read in the vectors
0394 $DCOP loadVector $TESTFILE INDEX >$TMPFILE
0395 VINDEX=`cat $TMPFILE | tr -d '\n'`
0396 checkEmptyResponse 600
0397 
0398 $DCOP loadVector $TESTFILE 2 >$TMPFILE
0399 V2=`cat $TMPFILE | tr -d '\n'`
0400 checkEmptyResponse 601
0401 
0402 $DCOP loadVector $TESTFILE 3 >$TMPFILE
0403 V3=`cat $TMPFILE | tr -d '\n'`
0404 checkEmptyResponse 602
0405 
0406 $DCOP loadVector $TESTFILE 4 >$TMPFILE
0407 V4=`cat $TMPFILE | tr -d '\n'`
0408 checkEmptyResponse 603
0409 
0410 $DCOP createCurve "firstCurve" $VINDEX $V2 "" "" >$TMPFILE
0411 CURVE1=`cat $TMPFILE | tr -d '\n'`
0412 checkEmptyResponse 604
0413 
0414 $DCOP createPlot "firstPlot" >$TMPFILE
0415 PLOT1=`cat $TMPFILE | tr -d '\n'`
0416 checkEmptyResponse 605
0417 
0418 $DCOP addCurveToPlot $PLOT1 $CURVE1 >$TMPFILE
0419 checkStringResponse 606 "true"
0420 
0421 $DCOP createCurve "secondCurve" $VINDEX $V4 "" "" >$TMPFILE
0422 CURVE2=`cat $TMPFILE | tr -d '\n'`
0423 checkEmptyResponse 607
0424 
0425 $DCOP addCurveToPlot $PLOT1 $CURVE2 >$TMPFILE
0426 checkStringResponse 608 "true"
0427 
0428 $DCOP createPlot "secondPlot" >$TMPFILE
0429 PLOT2=`cat $TMPFILE | tr -d '\n'`
0430 checkEmptyResponse 609
0431 
0432 $DCOP createCurve "thirdCurve" $VINDEX $V3 "" "" >$TMPFILE
0433 CURVE3=`cat $TMPFILE | tr -d '\n'`
0434 checkEmptyResponse 610
0435 
0436 $DCOP addCurveToPlot $PLOT2 $CURVE3 >$TMPFILE
0437 checkStringResponse 611 "true"
0438 
0439 KSTFILE=`mktemp /tmp/Kst_TestFile.XXXXXX` || exit 3
0440 rm $KSTFILE
0441 
0442 $DCOP saveAs $KSTFILE >$TMPFILE
0443 checkStringResponse 612 "true"
0444 
0445 # 613
0446 $DCOP newFile >$TMPFILE
0447 
0448 $DCOP curveList >$TMPFILE
0449 checkEmptyResponse 614
0450 
0451 # crashes Kst generally, bypassed with #599
0452 $DCOP open $KSTFILE >$TMPFILE
0453 checkStringResponse 620 "true"
0454 
0455 rm -f $KSTFILE
0456 
0457 $DCOP save >$TMPFILE
0458 checkStringResponse 621 "true"
0459 
0460 $DCOP open $KSTFILE >$TMPFILE
0461 checkStringResponse 622 "true"
0462 
0463 $DCOP save >$TMPFILE
0464 checkStringResponse 623 "true"
0465 
0466 echo ""
0467 doExit 0
0468 
0469 
0470 #
0471 # Things to test still
0472 # --------------------
0473 #
0474 # Vector/scalar namespace
0475 # Object namespace
0476 # Plot content manipulations
0477 # Error vectors
0478 # PSDs
0479 # Histograms
0480 # Equations with variables
0481 # Plugins
0482 # Labels
0483 # Data vectors
0484 # Plot scales
0485 # Saving and loading
0486 # Scalars generated for vectors
0487 #
0488 
0489