Index: /trunk/Ohana/src/opihi/cmd.basic/test/cd.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/cd.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/cd.sh	(revision 10311)
@@ -2,4 +2,5 @@
 list tests
  test1
+ test2
 end
 
@@ -21,3 +22,13 @@
 end
 
-# i have no idea how to test pwd automatically
+# test that pwd output is correct
+macro test2
+ $PASS = 1
+ exec touch foo.test
+ pwd -var testdir
+ file $testdir\/foo.test exists
+ if ($exists != 1)
+  $PASS = 0
+ end
+ exec rm foo.test
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/date.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/date.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/date.sh	(revision 10311)
@@ -8,5 +8,5 @@
 macro test1
  $PASS = 1
- date var
+ date -var var
  if ($STATUS == 0)
    $PASS = 0
@@ -17,5 +17,5 @@
 macro test2
  $PASS = 1
- date date1
+ date -var date1
  $date2 = `date`
  list w1 -split $date1
Index: /trunk/Ohana/src/opihi/cmd.basic/test/echo.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/echo.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/echo.sh	(revision 10311)
@@ -4,5 +4,5 @@
 end
 
-# test that config does not return an error
+# test that echo actually echoes
 macro test1
  $PASS = 1
Index: /trunk/Ohana/src/opihi/cmd.basic/test/for.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/for.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/for.sh	(revision 10311)
@@ -98,4 +98,6 @@
    end
   end    
+
+  $PASS = 1
   
   if (($i != 30) || ($N != 31))
@@ -151,4 +153,6 @@
  $endmem = $word:1
 
+ $PASS = 1
+
  if ($endmem - $startmem > 10)
    $PASS = 0
@@ -182,4 +186,6 @@
  $endmem = $word:1
 
+ $PASS = 1
+
  if ($i != 9999)
    $PASS = 0
Index: /trunk/Ohana/src/opihi/cmd.basic/test/fprintf.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/fprintf.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/fprintf.sh	(revision 10311)
@@ -75,8 +75,10 @@
  $endmem = $word:1
 
- if ("$endmem - $startmem" < 10)
+ if ($endmem - $startmem < 10)
    $PASS = 1
  else
    $PASS = 0
+   echo growth: {$endmem - $startmem}
+   echo kB/loop: {($endmem - $startmem)/1000}
  end
 end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/getchr.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/getchr.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/getchr.sh	(revision 10311)
@@ -5,5 +5,5 @@
 end
 
-# test that config does not return an error
+# index test
 macro test1
  $PASS = 1
@@ -14,9 +14,9 @@
 end
 
-# test that config does not return an error
+# null test
 macro test2
  $PASS = 1
- getchr "a long string.string" a var
- if ($var != 0)
+ getchr "a long string.string" x var
+ if ($var != -1)
    $PASS = 0
  end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/if.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/if.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/if.sh	(revision 10311)
@@ -12,4 +12,7 @@
  test10
  test11
+ test12
+ test13
+ test14
 end
 
@@ -168,6 +171,37 @@
 
 
+# basic logical test
+macro test11
+
+ local a b
+
+ $a = 1
+ $b = 2
+
+ if (($a <= 0) || ($b >= 3))
+   $PASS = 0
+ else
+   $PASS = 1
+ end
+end
+
+
+# basic logical test
+macro test12
+
+ local a
+
+ $a = 1
+
+ if ($a != 1)
+   $PASS = 0
+ else
+   $PASS = 1
+ end
+end
+
+
 # check memleaks
-macro test11
+macro test13
 
  local a b i N
@@ -197,2 +231,33 @@
  end
 end
+
+# memory test using break
+macro test14
+
+ local a b i N
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ output /dev/null
+ $a = 1
+ $b = 2
+ for i 0 10000
+   if (($a == 1) && ($b == 2))
+    break
+    echo "run"    
+   end
+ end    
+ output stdout
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ if ({$endmem - $startmem} < 10)
+   $PASS = 1
+ else
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
+ end
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/list.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/list.sh	(revision 10311)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/list.sh	(revision 10311)
@@ -0,0 +1,176 @@
+list tests
+ test1
+ test2
+ test3
+ test4
+ memtest2
+ memtest3
+ memtest4
+end
+
+list check
+  this
+  is
+  a
+  list
+end
+
+# Does list work?
+macro test1
+ $PASS = 1
+ if ($check:n != 4)
+  $PASS = 0
+  echo "Number of list elements: $check:n"
+ end
+ if (("$check:0" != "this") || ("$check:1" != "is") || ("$check:2" != "a") || ("$check:3" != "list"))
+  $PASS = 0
+  echo "List element does not return correctly!"
+ end
+end
+
+# Test split option
+macro test2
+ $PASS = 1
+ list check2 -split This is a list
+ if ($check2:n != 4)
+  $PASS = 0
+  echo "Number of list elements: $check2:n"
+ end
+ if (("$check2:0" != "This") || ("$check2:1" != "is") || ("$check2:2" != "a") || ("$check2:3" != "list"))
+  $PASS = 0
+  echo "List element does not return correctly!"
+ end
+end
+
+# Test -x option for the ls command
+macro test3
+ $PASS = 1
+ list check3 -x "ls /dev/null"
+ if ($check3:n != 1)
+  $PASS = 0
+  echo "Number of list elements: $check3:n"
+ end
+ if ("$check3:0" != "/dev/null")
+  $PASS = 0
+  echo "List element does not return correctly!"
+ end
+end
+
+# Test -x for files
+macro test4
+ $PASS = 1
+ file list_test.txt fchk
+ if ($fchk)
+  exec rm list_test.txt
+ end
+ output list_test.txt
+ echo This
+ echo is
+ echo a
+ echo list
+ output stdout
+ list check4 -x "cat list_test.txt"
+ if ($check4:n != 4)
+  $PASS = 0
+  echo "Number of list elements: $check4:n"
+ end
+ if (("$check4:0" != "This ") || ("$check4:1" != "is ") || ("$check4:2" != "a ") || ("$check4:3" != "list "))
+  $PASS = 0
+  echo "List element does not return correctly!"
+ end
+ if ($PASS)
+  exec rm list_test.txt
+ end
+end
+
+# Memory test for list -split
+macro memtest2
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+  list check2 -split This is a list
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ $PASS = 1
+
+ if ($endmem - $startmem > 10)
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
+ end
+
+end
+
+# Memory test for list -x
+macro memtest3
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 100
+  list check3 -x "ls /etc"
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ $PASS = 1
+
+ if ($endmem - $startmem > 10)
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/1000}"
+ end
+
+end
+
+# Memory test for list -x
+# XXX these need to be cleaned up to use the actual 
+# size of the list to calculate leakage...
+macro memtest4
+
+ file list_test.txt fchk
+ if ($fchk)
+  exec rm list_test.txt
+ end
+ output list_test.txt
+ echo This
+ echo is
+ echo a
+ echo list
+ output stdout
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 100
+  list check4 -x "cat list_test.txt"
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ $PASS = 1
+
+ if ($endmem - $startmem > 10)
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/1000}"
+ end
+
+ if ($PASS)
+  exec rm list_test.txt
+ end
+
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/macro.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/macro.sh	(revision 10311)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/macro.sh	(revision 10311)
@@ -0,0 +1,48 @@
+list tests
+ test_prep
+ test1
+ memtest1
+end
+
+# Is the macro working?
+macro test_prep
+ $test_var1 = check1
+ $test_var2 = check2
+ $var_count = $0
+end
+
+macro test1
+ $PASS = 1
+ $var_count = 0
+ $test_var1 = blank
+ $test_var2 = blank
+ test_prep var1 var2 var3
+ if ($var_count != 4)
+  $PASS = 0
+  echo "Number of parameters (should be 4): $var_count"
+ end
+ if (("$test_var1" != "check1") || ("$test_var2" != "check2"))
+  $PASS = 0
+  echo "Paramaters not assigned correctly!: $test_var1 $test_var2"
+ end
+end
+
+# Memory Test for macro
+macro memtest1
+ $PASS = 1
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+  test_prep
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ if ($endmem - $startmem > 10)
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
+ end
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/math.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/math.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/math.sh	(revision 10311)
@@ -2,4 +2,5 @@
 list tests
  test1
+ test2
  testmem1
  testmem2
@@ -8,6 +9,8 @@
 end
 
+# test subtraction
 macro test1
 
+  $PASS = 1
   local i
 
@@ -26,7 +29,25 @@
 end
 
+# test addition, division, and multiplication
+macro test2
+
+ $PASS = 1
+ local a b c
+
+ $a = {2 + 4}
+ $b = {12 / 2}
+ $c = {2 * 3}
+
+ if (($a != 6) || ($b != 6) || ($c != 6))
+   $PASS = 0
+   echo "ALL VALUES NOT 6: a=$a\ b=$b\ c=$c\"
+ end
+
+end
+
 # check memleaks (set global)
 macro testmem1
 
+ $PASS = 1
  local i
 
@@ -53,4 +74,5 @@
 macro testmem2
 
+ $PASS = 1
  local i N
 
@@ -61,4 +83,7 @@
  for i 0 10000
    $N = 99 - 98
+   $N = 1 + 1
+   $N = 2 * 2
+   $N = 22/7
  end    
  output stdout
@@ -77,4 +102,5 @@
 macro testmem3
 
+ $PASS = 1
  local i N
 
@@ -101,4 +127,5 @@
 macro testmem4
 
+ $PASS = 1
  local i N
 
Index: /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh	(revision 10311)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh	(revision 10311)
@@ -0,0 +1,117 @@
+list tests
+ test1
+ memtest1
+ memtest2
+end
+
+# Does scan work?
+macro test1
+ $PASS = 1
+ file test_file.txt fchk
+ if ($fchk)
+  exec rm test_file.txt
+ end
+ output test_file.txt
+ echo This
+ echo is
+ echo a
+ echo test
+ echo file
+ output stdout
+ scan test_file.txt fscan
+ if ("$fscan" != "This ")
+  $PASS = 0
+  echo "Default not working!"
+ end
+ scan test_file.txt fscan 4
+ if ("$fscan" != "test ")
+  $PASS = 0
+  echo "Scan failure!"
+ end
+ if ($PASS)
+  exec rm test_file.txt
+ end
+end
+
+# Memory test for scan (default)
+macro memtest1
+
+ file test_file.txt fchk
+ if ($fchk)
+  exec rm test_file.txt
+ end
+ output test_file.txt
+ echo This
+ echo is
+ echo a
+ echo test
+ echo file
+ output stdout
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+  scan test_file.txt fscan
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ $PASS = 1
+
+ if ($endmem - $startmem > 10)
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
+ end
+
+ if ($PASS)
+  exec rm test_file.txt
+ end
+
+end
+
+
+# Memory test for scan (specified)
+macro memtest2
+
+ file test_file.txt fchk
+ if ($fchk)
+  exec rm test_file.txt
+ end
+ output test_file.txt
+ echo This
+ echo is
+ echo a
+ echo test
+ echo file
+ output stdout
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+  scan test_file.txt fscan 5
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ $PASS = 1
+
+ if ($endmem - $startmem > 10)
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
+ end
+
+ if ($PASS)
+  exec rm test_file.txt
+ end
+
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/sleep.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/sleep.sh	(revision 10311)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/sleep.sh	(revision 10311)
@@ -0,0 +1,25 @@
+list tests
+ test1
+end
+
+# Does sleep work?
+macro test1
+ $PASS = 1
+
+ list tstart -x "date +%S"
+
+ sleep 10
+
+ list tend -x "date +%S"
+
+ if ($tstart:0 >= 50)
+  $tend:0 = $tend:0 + 60
+ end
+
+ $diff = abs (10 - abs($tstart:0 - $tend:0))
+
+ if ($diff > 1.1)
+  $PASS = 0
+ end
+
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/sprintf.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/sprintf.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/sprintf.sh	(revision 10311)
@@ -1,43 +1,43 @@
-
 list tests
  test1
- test2
- test3
- test4
+ memtest1
 end
 
+# Does sprintf work?
 macro test1
- sprintf line "test %03d" 50
- if ("$line" == "test 050")
-   $PASS = 1
- else
-   $PASS = 0
+ $PASS = 1
+
+ local test_var
+
+ sprint test_var "%7s %5.2f %9.3e" float 34.5 12630000
+
+ if ("$test_var" != "  float 34.50 1.263e+07")
+  $PASS = 0
  end
+
 end
 
-macro test2
- sprintf line "test %6.3f" 123.45678
- if ("$line" == "test 123.457")
-   $PASS = 1
- else
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+  sprint test_var "%7s %5.2f %9.3e" float 34.5 12630000
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ $PASS = 1
+
+ if ($endmem - $startmem > 10)
    $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
  end
+
 end
-
-macro test3
- sprintf line "test %x" 32
- if ("$line" == "test 20")
-   $PASS = 1
- else
-   $PASS = 0
- end
-end
-
-macro test4
- sprintf line "test %10s" foobar
- if ("$line" == "test     foobar")
-   $PASS = 1
- else
-   $PASS = 0
- end
-end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/strlen.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/strlen.sh	(revision 10311)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/strlen.sh	(revision 10311)
@@ -0,0 +1,47 @@
+list tests
+ test1
+ memtest1
+end
+
+# Does strlen work?
+macro test1
+ 
+ $PASS = 1
+
+ $tstr = "Test string"
+
+ strlen $tstr len
+
+ if ($len != 11)
+  $PASS = 0
+  echo "Incorrect length: $len"
+ end
+
+end
+
+# Memory Test
+macro memtest1
+
+ local i
+
+ $tstr = "Test string"
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+  strlen $tstr len
+ end    
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
+ $PASS = 1
+
+ if ($endmem - $startmem > 10)
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
+ end
+
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/variable.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/variable.sh	(revision 10310)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/variable.sh	(revision 10311)
@@ -14,4 +14,5 @@
  test12
  test13
+ test14
  testmem1
  testmem2
@@ -41,5 +42,5 @@
 end
 
-# 
+# do math expressions assign the correct value (test2 -> test8)
 macro test2
 
@@ -57,5 +58,4 @@
 end
 
-# do we loop up in small steps correctly?
 macro test3
 
@@ -73,5 +73,4 @@
 end
 
-# do we loop down in small steps correctly?
 macro test4
 
@@ -89,5 +88,4 @@
 end
 
-# do we loop down in small steps correctly?
 macro test5
 
@@ -105,5 +103,4 @@
 end
 
-# do we loop down in small steps correctly?
 macro test6
 
@@ -121,12 +118,29 @@
 end
 
-# do we loop down in small steps correctly?
+# testing operation priority
 macro test7
 
-  local i
+  local i j
 
   $i = 2 - 3*2
-
- if ($i == -4)
+  $j = 10/2*5+5
+
+ if (($i == -4) && ($j == 30))
+   $PASS = 1
+ else
+   $PASS = 0
+   echo "i: $i\ j: $j"
+ end
+
+end
+
+# testing math on negative numbers
+macro test8
+
+  local i
+
+  $i = -2 - -3
+
+ if ($i == 1)
    $PASS = 1
  else
@@ -137,21 +151,5 @@
 end
 
-# do we loop down in small steps correctly?
-macro test8
-
-  local i
-
-  $i = -2 - -3
-
- if ($i == 1)
-   $PASS = 1
- else
-   $PASS = 0
-   echo "i: $i"
- end
-
-end
-
-# do we loop down in small steps correctly?
+# testing the existance of variables
 macro test9
 
@@ -237,4 +235,14 @@
 end
 
+# test local variables
+macro test14
+
+ $PASS = 1
+
+ if (($?i == 1) || ($?N == 1))
+  $PASS = 0
+ end
+end
+
 # check memleaks (set global)
 macro testmem1
@@ -495,3 +503,2 @@
  end
 end
-
Index: /trunk/Ohana/src/opihi/cmd.basic/test/while.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/while.sh	(revision 10311)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/while.sh	(revision 10311)
@@ -0,0 +1,18 @@
+list tests
+ test1
+end
+
+# Does while work?
+macro test1
+ $PASS = 1
+ local i
+ $i = 0
+ while ($i <= 10)
+  if ($i == 11)
+   $PASS = 0
+   echo "While loop failure!"
+   break
+  end
+  $i++
+ end
+end
