Changeset 10311
- Timestamp:
- Nov 30, 2006, 9:02:30 AM (20 years ago)
- Location:
- trunk/Ohana/src/opihi/cmd.basic/test
- Files:
-
- 6 added
- 10 edited
-
cd.sh (modified) (2 diffs)
-
date.sh (modified) (2 diffs)
-
echo.sh (modified) (1 diff)
-
for.sh (modified) (3 diffs)
-
fprintf.sh (modified) (1 diff)
-
getchr.sh (modified) (2 diffs)
-
if.sh (modified) (3 diffs)
-
list.sh (added)
-
macro.sh (added)
-
math.sh (modified) (7 diffs)
-
scan.sh (added)
-
sleep.sh (added)
-
sprintf.sh (modified) (1 diff)
-
strlen.sh (added)
-
variable.sh (modified) (10 diffs)
-
while.sh (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.basic/test/cd.sh
r6265 r10311 2 2 list tests 3 3 test1 4 test2 4 5 end 5 6 … … 21 22 end 22 23 23 # i have no idea how to test pwd automatically 24 # test that pwd output is correct 25 macro test2 26 $PASS = 1 27 exec touch foo.test 28 pwd -var testdir 29 file $testdir\/foo.test exists 30 if ($exists != 1) 31 $PASS = 0 32 end 33 exec rm foo.test 34 end -
trunk/Ohana/src/opihi/cmd.basic/test/date.sh
r6265 r10311 8 8 macro test1 9 9 $PASS = 1 10 date var10 date -var var 11 11 if ($STATUS == 0) 12 12 $PASS = 0 … … 17 17 macro test2 18 18 $PASS = 1 19 date date119 date -var date1 20 20 $date2 = `date` 21 21 list w1 -split $date1 -
trunk/Ohana/src/opihi/cmd.basic/test/echo.sh
r6265 r10311 4 4 end 5 5 6 # test that config does not return an error6 # test that echo actually echoes 7 7 macro test1 8 8 $PASS = 1 -
trunk/Ohana/src/opihi/cmd.basic/test/for.sh
r9472 r10311 98 98 end 99 99 end 100 101 $PASS = 1 100 102 101 103 if (($i != 30) || ($N != 31)) … … 151 153 $endmem = $word:1 152 154 155 $PASS = 1 156 153 157 if ($endmem - $startmem > 10) 154 158 $PASS = 0 … … 182 186 $endmem = $word:1 183 187 188 $PASS = 1 189 184 190 if ($i != 9999) 185 191 $PASS = 0 -
trunk/Ohana/src/opihi/cmd.basic/test/fprintf.sh
r9197 r10311 75 75 $endmem = $word:1 76 76 77 if ( "$endmem - $startmem"< 10)77 if ($endmem - $startmem < 10) 78 78 $PASS = 1 79 79 else 80 80 $PASS = 0 81 echo growth: {$endmem - $startmem} 82 echo kB/loop: {($endmem - $startmem)/1000} 81 83 end 82 84 end -
trunk/Ohana/src/opihi/cmd.basic/test/getchr.sh
r6265 r10311 5 5 end 6 6 7 # test that config does not return an error7 # index test 8 8 macro test1 9 9 $PASS = 1 … … 14 14 end 15 15 16 # test that config does not return an error16 # null test 17 17 macro test2 18 18 $PASS = 1 19 getchr "a long string.string" avar20 if ($var != 0)19 getchr "a long string.string" x var 20 if ($var != -1) 21 21 $PASS = 0 22 22 end -
trunk/Ohana/src/opihi/cmd.basic/test/if.sh
r9197 r10311 12 12 test10 13 13 test11 14 test12 15 test13 16 test14 14 17 end 15 18 … … 168 171 169 172 173 # basic logical test 174 macro test11 175 176 local a b 177 178 $a = 1 179 $b = 2 180 181 if (($a <= 0) || ($b >= 3)) 182 $PASS = 0 183 else 184 $PASS = 1 185 end 186 end 187 188 189 # basic logical test 190 macro test12 191 192 local a 193 194 $a = 1 195 196 if ($a != 1) 197 $PASS = 0 198 else 199 $PASS = 1 200 end 201 end 202 203 170 204 # check memleaks 171 macro test1 1205 macro test13 172 206 173 207 local a b i N … … 197 231 end 198 232 end 233 234 # memory test using break 235 macro test14 236 237 local a b i N 238 239 list word -x "ps -p $PID -o rss" 240 $startmem = $word:1 241 242 output /dev/null 243 $a = 1 244 $b = 2 245 for i 0 10000 246 if (($a == 1) && ($b == 2)) 247 break 248 echo "run" 249 end 250 end 251 output stdout 252 253 list word -x "ps -p $PID -o rss" 254 $endmem = $word:1 255 256 if ({$endmem - $startmem} < 10) 257 $PASS = 1 258 else 259 $PASS = 0 260 echo "growth: {$endmem-$startmem}" 261 echo "kB/loop: {($endmem-$startmem)/10000}" 262 end 263 end -
trunk/Ohana/src/opihi/cmd.basic/test/math.sh
r9360 r10311 2 2 list tests 3 3 test1 4 test2 4 5 testmem1 5 6 testmem2 … … 8 9 end 9 10 11 # test subtraction 10 12 macro test1 11 13 14 $PASS = 1 12 15 local i 13 16 … … 26 29 end 27 30 31 # test addition, division, and multiplication 32 macro test2 33 34 $PASS = 1 35 local a b c 36 37 $a = {2 + 4} 38 $b = {12 / 2} 39 $c = {2 * 3} 40 41 if (($a != 6) || ($b != 6) || ($c != 6)) 42 $PASS = 0 43 echo "ALL VALUES NOT 6: a=$a\ b=$b\ c=$c\" 44 end 45 46 end 47 28 48 # check memleaks (set global) 29 49 macro testmem1 30 50 51 $PASS = 1 31 52 local i 32 53 … … 53 74 macro testmem2 54 75 76 $PASS = 1 55 77 local i N 56 78 … … 61 83 for i 0 10000 62 84 $N = 99 - 98 85 $N = 1 + 1 86 $N = 2 * 2 87 $N = 22/7 63 88 end 64 89 output stdout … … 77 102 macro testmem3 78 103 104 $PASS = 1 79 105 local i N 80 106 … … 101 127 macro testmem4 102 128 129 $PASS = 1 103 130 local i N 104 131 -
trunk/Ohana/src/opihi/cmd.basic/test/sprintf.sh
r6231 r10311 1 2 1 list tests 3 2 test1 4 test2 5 test3 6 test4 3 memtest1 7 4 end 8 5 6 # Does sprintf work? 9 7 macro test1 10 sprintf line "test %03d" 50 11 if ("$line" == "test 050") 12 $PASS = 1 13 else 14 $PASS = 0 8 $PASS = 1 9 10 local test_var 11 12 sprint test_var "%7s %5.2f %9.3e" float 34.5 12630000 13 14 if ("$test_var" != " float 34.50 1.263e+07") 15 $PASS = 0 15 16 end 17 16 18 end 17 19 18 macro test2 19 sprintf line "test %6.3f" 123.45678 20 if ("$line" == "test 123.457") 21 $PASS = 1 22 else 20 # Memory test 21 macro memtest1 22 23 local i 24 25 list word -x "ps -p $PID -o rss" 26 $startmem = $word:1 27 28 for i 0 10000 29 sprint test_var "%7s %5.2f %9.3e" float 34.5 12630000 30 end 31 32 list word -x "ps -p $PID -o rss" 33 $endmem = $word:1 34 35 $PASS = 1 36 37 if ($endmem - $startmem > 10) 23 38 $PASS = 0 39 echo "growth: {$endmem-$startmem}" 40 echo "kB/loop: {($endmem-$startmem)/10000}" 24 41 end 42 25 43 end 26 27 macro test328 sprintf line "test %x" 3229 if ("$line" == "test 20")30 $PASS = 131 else32 $PASS = 033 end34 end35 36 macro test437 sprintf line "test %10s" foobar38 if ("$line" == "test foobar")39 $PASS = 140 else41 $PASS = 042 end43 end -
trunk/Ohana/src/opihi/cmd.basic/test/variable.sh
r9197 r10311 14 14 test12 15 15 test13 16 test14 16 17 testmem1 17 18 testmem2 … … 41 42 end 42 43 43 # 44 # do math expressions assign the correct value (test2 -> test8) 44 45 macro test2 45 46 … … 57 58 end 58 59 59 # do we loop up in small steps correctly?60 60 macro test3 61 61 … … 73 73 end 74 74 75 # do we loop down in small steps correctly?76 75 macro test4 77 76 … … 89 88 end 90 89 91 # do we loop down in small steps correctly?92 90 macro test5 93 91 … … 105 103 end 106 104 107 # do we loop down in small steps correctly?108 105 macro test6 109 106 … … 121 118 end 122 119 123 # do we loop down in small steps correctly?120 # testing operation priority 124 121 macro test7 125 122 126 local i 123 local i j 127 124 128 125 $i = 2 - 3*2 129 130 if ($i == -4) 126 $j = 10/2*5+5 127 128 if (($i == -4) && ($j == 30)) 129 $PASS = 1 130 else 131 $PASS = 0 132 echo "i: $i\ j: $j" 133 end 134 135 end 136 137 # testing math on negative numbers 138 macro test8 139 140 local i 141 142 $i = -2 - -3 143 144 if ($i == 1) 131 145 $PASS = 1 132 146 else … … 137 151 end 138 152 139 # do we loop down in small steps correctly? 140 macro test8 141 142 local i 143 144 $i = -2 - -3 145 146 if ($i == 1) 147 $PASS = 1 148 else 149 $PASS = 0 150 echo "i: $i" 151 end 152 153 end 154 155 # do we loop down in small steps correctly? 153 # testing the existance of variables 156 154 macro test9 157 155 … … 237 235 end 238 236 237 # test local variables 238 macro test14 239 240 $PASS = 1 241 242 if (($?i == 1) || ($?N == 1)) 243 $PASS = 0 244 end 245 end 246 239 247 # check memleaks (set global) 240 248 macro testmem1 … … 495 503 end 496 504 end 497
Note:
See TracChangeset
for help on using the changeset viewer.
