Index: /trunk/Ohana/src/opihi/cmd.basic/test/for.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/for.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/for.sh	(revision 14176)
@@ -8,5 +8,4 @@
  memtest1
  memtest2
- memtest2a
  memtest3
 end
@@ -15,4 +14,6 @@
 macro test1
 
+  $PASS = 0
+
   local i
 
@@ -31,4 +32,6 @@
 macro test2
 
+  $PASS = 0
+
   local i
 
@@ -47,4 +50,6 @@
 # do we loop up in small steps correctly?
 macro test3
+
+  $PASS = 0
 
   local i N
@@ -68,4 +73,6 @@
 macro test4
 
+  $PASS = 0
+
   local i N
 
@@ -87,4 +94,6 @@
 # do we break from a loop correctly
 macro test5
+
+  $PASS = 0
 
   break -auto off
@@ -112,4 +121,6 @@
 macro memtest1
 
+ $PASS = 0
+
  local i N
 
@@ -136,4 +147,6 @@
 macro memtest2
 
+ $PASS = 0
+
  local i N
 
@@ -163,60 +176,8 @@
 end
 
-# check memleaks with many loop lines
-macro memtest2a
-
- local i N
-
- list word -x "ps -p $PID -o rss"
- $startmem = $word:1
-
- output /dev/null
- for i 0 10000
-  echo "test line in loop"
-  echo "test line in loop"
- end    
- output stdout
-  
- 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
-
-# check memleaks with many loop lines
-macro memtest2b
-
- local i N
-
- list word -x "ps -p $PID -o rss"
- $startmem = $word:1
-
- output /dev/null
- for i 0 1000
-  exec echo "test line in loop" > /dev/null
-  exec echo "test line in loop" > /dev/null
- end    
- output stdout
-  
- 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
-
 # check memleaks on break
 macro memtest3
+
+ $PASS = 0
 
  local i N
@@ -254,3 +215,2 @@
  end
 end
-
Index: /trunk/Ohana/src/opihi/cmd.basic/test/if.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/if.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/if.sh	(revision 14176)
@@ -14,5 +14,5 @@
  test12
  test13
- test14
+# test14
 end
 
Index: /trunk/Ohana/src/opihi/cmd.basic/test/list.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/list.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/list.sh	(revision 14176)
@@ -92,31 +92,6 @@
  $startmem = $word:1
 
- for i 0 10000
+ for i 0 1000
   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    
   
@@ -135,6 +110,29 @@
 
 # Memory test for list -x
-# XXX these need to be cleaned up to use the actual 
-# size of the list to calculate leakage...
+macro memtest3
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  list check3 -x "ls /dev/null"
+ 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
 macro memtest4
 
@@ -155,5 +153,5 @@
  $startmem = $word:1
 
- for i 0 100
+ for i 0 1000
   list check4 -x "cat list_test.txt"
  end    
Index: /trunk/Ohana/src/opihi/cmd.basic/test/local.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/local.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/local.sh	(revision 14176)
@@ -0,0 +1,51 @@
+list tests
+ test1
+ memtest1
+end
+
+# Does local work?
+macro test1
+
+ $PASS = 1
+
+ local lvar
+
+ $lvar = 5
+
+ if ($?lvar != 1)
+  $PASS = 0
+  echo "Local variable failed to be created!"
+ end
+
+ if ($lvar != 5)
+  $PASS = 0
+  echo "Local variable value not assigned!"
+ end
+
+end
+
+
+# Memory test for local
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  local lvar2
+  $lvar2 = 9
+ 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
Index: /trunk/Ohana/src/opihi/cmd.basic/test/output.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/output.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/output.sh	(revision 14176)
@@ -0,0 +1,63 @@
+
+list tests
+ test1
+ testmem1
+end
+
+# test subtraction
+macro test1
+
+ $PASS = 1
+
+ output testout.txt
+
+ file testout.txt fchk
+ output stdout
+ if ($fchk != 1)
+  $PASS = 0
+  echo "Output did not create test file!"
+ end
+
+ output testout.txt
+ echo "This is a test."
+ output stdout
+ $line = `cat testout.txt`
+ if ("$line" == "This is a test. ")
+   $PASS = 1
+ else
+   $PASS = 0
+   echo "Output: $line"
+ end
+
+ exec rm testout.txt
+
+end
+
+
+# check memleaks
+macro testmem1
+
+ $PASS = 1
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ output /dev/null
+ for i 0 1000
+  output testout.txt
+  echo "This is a test."
+  output stdout
+  exec rm testout.txt
+ end    
+ output stdout
+  
+ 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)/1000}"
+ end
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh	(revision 14176)
@@ -54,5 +54,5 @@
  $startmem = $word:1
 
- for i 0 10000
+ for i 0 1000
   scan test_file.txt fscan
  end    
@@ -66,5 +66,5 @@
    $PASS = 0
    echo "growth: {$endmem-$startmem}"
-   echo "kB/loop: {($endmem-$startmem)/10000}"
+   echo "kB/loop: {($endmem-$startmem)/1000}"
  end
 
@@ -96,5 +96,5 @@
  $startmem = $word:1
 
- for i 0 10000
+ for i 0 1000
   scan test_file.txt fscan 5
  end    
@@ -108,5 +108,5 @@
    $PASS = 0
    echo "growth: {$endmem-$startmem}"
-   echo "kB/loop: {($endmem-$startmem)/10000}"
+   echo "kB/loop: {($endmem-$startmem)/1000}"
  end
 
Index: /trunk/Ohana/src/opihi/cmd.basic/test/sleep.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/sleep.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/sleep.sh	(revision 14176)
@@ -9,13 +9,13 @@
  list tstart -x "date +%S"
 
- sleep 10
+ sleep 3
 
  list tend -x "date +%S"
 
- if ($tstart:0 >= 50)
+ if ($tstart:0 >= 57)
   $tend:0 = $tend:0 + 60
  end
 
- $diff = abs (10 - abs($tstart:0 - $tend:0))
+ $diff = abs (3 - abs($tstart:0 - $tend:0))
 
  if ($diff > 1.1)
Index: /trunk/Ohana/src/opihi/cmd.basic/test/strlen.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/strlen.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/strlen.sh	(revision 14176)
@@ -30,5 +30,5 @@
  $startmem = $word:1
 
- for i 0 10000
+ for i 0 1000
   strlen $tstr len
  end    
@@ -42,5 +42,5 @@
    $PASS = 0
    echo "growth: {$endmem-$startmem}"
-   echo "kB/loop: {($endmem-$startmem)/10000}"
+   echo "kB/loop: {($endmem-$startmem)/1000}"
  end
 
Index: /trunk/Ohana/src/opihi/cmd.basic/test/strpop.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/strpop.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/strpop.sh	(revision 14176)
@@ -0,0 +1,105 @@
+list tests
+ test1
+ test2
+ memtest1
+ memtest2
+end
+
+# Does strpop work with variables?
+macro test1
+
+ $PASS = 1
+
+ $tstr = a test string
+
+ local a b c
+
+ strpop tstr a
+ strpop tstr b
+ strpop tstr c
+
+ if (("$a" != "a") || ("$b" != "test") || ("$c" != "string"))
+  $PASS = 0
+  echo "Incorrect value returned!"
+ end
+end
+
+
+# Does strpop work with lists?
+macro test2
+
+ $PASS = 1
+
+ list tlis -split list of strings
+
+ local a b c
+
+ strpop tlis:0 a
+ strpop tlis:1 b
+ strpop tlis:2 c
+
+ if (("$a" != "list") || ("$b" != "of") || ("$c" != "strings"))
+  $PASS = 0
+  echo "Incorrect value returned!"
+ end
+end
+
+
+# Memory test for variables
+macro memtest1
+
+ local i tstr a b c d
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  $tstr = one two three
+  strlen tstr a
+  strlen tstr b
+  strlen tstr c
+  strlen tstr d
+ 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 lists
+macro memtest2
+
+ local i tstr a b c d
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  list tstr -split one two three
+  strlen tstr:0 a
+  strlen tstr:1 b
+  strlen tstr:2 c
+  strlen tstr:0 d
+ 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
Index: /trunk/Ohana/src/opihi/cmd.basic/test/substr.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/substr.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/substr.sh	(revision 14176)
@@ -0,0 +1,49 @@
+list tests
+ test1
+ memtest1
+end
+
+# Does substr work?
+macro test1
+
+ $PASS = 1
+
+ local tstr ss
+
+ $tstr = "riddle me this"
+
+ substr $tstr 4 8 ss
+
+ if ("$ss" != "le me th")
+  $PASS = 0
+  echo "Incorrect substring returned!"
+ end
+end
+
+
+# Memory test
+macro memtest1
+
+ local i tstr ss
+
+ $tstr = "riddle me this"
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+  substr $tstr 4 8 ss
+ 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/usleep.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/usleep.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/usleep.sh	(revision 14176)
@@ -0,0 +1,25 @@
+list tests
+ test1
+end
+
+# Does usleep work?
+macro test1
+ $PASS = 1
+
+ list tstart -x "date +%S"
+
+ usleep 3000000
+
+ list tend -x "date +%S"
+
+ if ($tstart:0 >= 57)
+  $tend:0 = $tend:0 + 60
+ end
+
+ $diff = abs (3 - abs($tstart:0 - $tend:0))
+
+ if ($diff > 1.1)
+  $PASS = 0
+ end
+
+end
Index: /trunk/Ohana/src/opihi/cmd.basic/test/while.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/while.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/while.sh	(revision 14176)
@@ -12,4 +12,5 @@
    $PASS = 0
    echo "While loop failure!"
+   echo "i: $i"
    break
   end
Index: /trunk/Ohana/src/opihi/cmd.data/test/applyfit.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/applyfit.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/applyfit.sh	(revision 14176)
@@ -0,0 +1,51 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if applyfit works
+macro test1
+
+ $PASS = 1
+
+ $Cn = 2
+ $C0 = 4
+ $C1 = -2
+ $C2 = 1
+
+ create x 0 10
+
+ applyfit x y
+
+ if (y[5] != 19)
+  $PASS = 0
+  echo "Value mismatch: y[5]"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  applyfit x y
+ 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
Index: /trunk/Ohana/src/opihi/cmd.data/test/concat.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/concat.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/concat.sh	(revision 14176)
@@ -0,0 +1,48 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Does concat work?
+macro test1
+
+ $PASS = 1
+
+ create a 0 10
+ set b = a
+
+ concat a b
+
+ if ((b[] != 20) || (b[10] != 0))
+  $PASS = 0
+  echo "Concat failed!: nelements: b[] b(10)= b[10]"
+ end
+end
+
+
+# Memory Test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  create a 0 10
+  set b = a
+  concat a b
+ 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
Index: /trunk/Ohana/src/opihi/cmd.data/test/create.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/create.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/create.sh	(revision 14176)
@@ -0,0 +1,44 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test create function
+macro test1
+ 
+ $PASS = 1
+
+ create x 0 10 0.5
+
+ if ((x[1] != 0.5) || (x[9] != 4.5))
+  $PASS = 0
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  create y 0 10 0.1
+ 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
Index: /trunk/Ohana/src/opihi/cmd.data/test/cumulative.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/cumulative.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/cumulative.sh	(revision 14176)
@@ -0,0 +1,46 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Does cumulative work?
+macro test1
+
+ $PASS = 1
+
+ create a 5 15
+
+ cumulative a acum
+
+ if (acum[5] != 45)
+  $PASS = 0
+  echo "Cumulative failed!: nelements: acum[] acum(5)= acum[5]"
+ end
+end
+
+
+# Memory Test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  create a 5 15
+  cumulative a acum
+ 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
Index: /trunk/Ohana/src/opihi/cmd.data/test/delete.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/delete.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/delete.sh	(revision 14176)
@@ -0,0 +1,50 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test delete
+macro test1
+
+ $PASS = 1
+
+ $v = 7
+
+# create v 0 10
+
+ delete v
+
+ if ($?v != 0)
+  $PASS = 0
+  echo "Variable not deleted!"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  $u = testing
+  delete u
+ 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
Index: /trunk/Ohana/src/opihi/cmd.data/test/fit2d.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/fit2d.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/fit2d.sh	(revision 14176)
@@ -0,0 +1,208 @@
+
+list tests
+ test1
+ test2
+ test3
+ test4
+ test5
+ test6
+ test7
+ test8
+end
+
+# fit a line without errors
+macro test1
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ create y 0 100
+ set z = 3 + 5*x + 3*y
+ fit -q x y z 1
+
+ if ($Cn != 1)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 1e-5)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 1e-5)
+   $PASS = 0
+ end
+end
+
+# fit a line with errors
+macro test2
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ set dy = 0.1*rnd(x) - 0.05
+ set y = 3 + 5*x + dy
+ fit -q x y 1
+
+ if ($Cn != 1)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 0.01)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 0.01)
+   $PASS = 0
+ end
+end
+
+# fit a line with errors and weights
+macro test3
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ set dy = 0.1*rnd(x) - 0.05
+ set y = 3 + 5*x + dy
+ set dy = 0.1 + zero(x)
+ fit -q x y 1 -dy dy
+
+ if ($Cn != 1)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 0.02)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 0.02)
+   $PASS = 0
+ end
+end
+
+# fit a line with errors, weights, and outliers 
+macro test4
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ set dy = 0.1*rnd(x) - 0.05
+ set y = 3 + 5*x + dy
+ set dy = 0.1 + zero(x)
+ y[5] = 23
+ y[20] = -10
+ y[50] = 0.0
+ fit -q x y 1 -dy dy -clip 3 3
+
+ if ($Cn != 1)
+   $PASS = 0
+ end
+ if ($Cnv != 97)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 0.02)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 0.02)
+   $PASS = 0
+ end
+end
+
+# fit a quadratic without errors
+macro test5
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ set y = 3 + 5*x - 4*x^2
+ fit -q x y 2
+
+ if ($Cn != 2)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 1e-5)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 1e-5)
+   $PASS = 0
+ end
+ if (abs($C2 + 4) > 1e-5)
+   $PASS = 0
+ end
+end
+
+# fit a quadratic with errors
+macro test6
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ set dy = 0.1*rnd(x) - 0.05
+ set y = 3 + 5*x - 4*x^2 + dy
+ fit -q x y 2
+
+ if ($Cn != 2)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 0.05)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 0.05)
+   $PASS = 0
+ end
+ if (abs($C2 + 4) > 0.05)
+   $PASS = 0
+ end
+end
+
+# fit a quadratic with errors and weights
+macro test7
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ set dy = 0.1*rnd(x) - 0.05
+ set y = 3 + 5*x - 4*x^2 + dy
+ set dy = 0.1 + zero(x)
+ fit -q x y 2 -dy dy
+
+ if ($Cn != 2)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 0.05)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 0.05)
+   $PASS = 0
+ end
+ if (abs($C2 + 4) > 0.05)
+   $PASS = 0
+ end
+end
+
+# fit a quadratic with errors, weights, and outliers 
+macro test8
+ $PASS = 1
+ break -auto off
+
+ create x 0 100
+ set dy = 0.1*rnd(x) - 0.05
+ set y = 3 + 5*x - 4*x^2 + dy
+ set dy = 0.1 + zero(x)
+ y[5] = 23
+ y[20] = -10
+ y[50] = 0.0
+
+ # it takes 4 iterations to successfully reject the outliers above...
+ fit -q x y 2 -dy dy -clip 3 4
+
+ if ($Cn != 2)
+   $PASS = 0
+ end
+ if ($Cnv != 97)
+   $PASS = 0
+ end
+ if (abs($C0 - 3) > 0.05)
+   $PASS = 0
+ end
+ if (abs($C1 - 5) > 0.05)
+   $PASS = 0
+ end
+ if (abs($C2 + 4) > 0.05)
+   $PASS = 0
+ end
+end
Index: /trunk/Ohana/src/opihi/cmd.data/test/integrate.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/integrate.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/integrate.sh	(revision 14176)
@@ -0,0 +1,47 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if integrate works
+macro test1
+
+ $PASS = 1
+
+ create x 0 10 0.01
+ set y = 1+2*x+3*x^2
+
+ integrate x y 1 5
+
+ if (($sum-152) > 0.5)
+  $PASS = 0
+  echo "Inaccurate result (should be 152): $sum"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  integrate x y 1 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)/1000}"
+ end
+end
Index: /trunk/Ohana/src/opihi/cmd.data/test/interpolate.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/interpolate.sh	(revision 14176)
+++ /trunk/Ohana/src/opihi/cmd.data/test/interpolate.sh	(revision 14176)
@@ -0,0 +1,48 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if interpolate works
+macro test1
+
+ $PASS = 1
+
+ create x0 0 10 0.1
+ set y0 = 1+2*x0+3*x0^2
+ create x1 0 10 0.001
+ interpolate x0 y0 x1 y1
+ integrate x1 y1 1 5
+
+ if (($sum-152) > 0.08)
+  $PASS = 0
+  echo "Inaccurate result (should be 152): $sum"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  interpolate x0 y0 x1 y1
+ 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
Index: /trunk/Ohana/src/opihi/cmd.data/test/peak.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/peak.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.data/test/peak.sh	(revision 14176)
@@ -4,6 +4,5 @@
  test2
  test3
- test4
- test5
+ testmem1
 end
 
@@ -77,43 +76,28 @@
 
 # test memory usage
-macro test4
- $PASS = 1
+macro testmem1
  break -auto off
 
- create x 0 100
+ create x 0 1000
  set y = zero (x)
- y[60] = 2
- y[50] = 1
- y[40] = 2
+ y[500] = 100
 
- echo "peak:"
- exec ps aux | grep mana | grep -v grep
- for i 0 100000
-   peak -q x y 45 55
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 10000
+   peak -q x y 400 600
  end
- exec ps aux | grep mana | grep -v grep
+ 
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
 
- ## HOW do we test this?
+ if ({$endmem - $startmem} < 10)
+   $PASS = 1
+ else
+   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/10000}"
+ end
+
 end
-
-# test memory usage
-macro test5
- $PASS = 1
- break -auto off
-
- create x 0 100
- set y = zero (x)
- y[60] = 2
- y[50] = 1
- y[40] = 2
-
- echo "peak:"
- exec ps aux | grep mana | grep -v grep
- for i 0 1000
-   peak x y 45 55
- end
- exec ps aux | grep mana | grep -v grep
-
- ## HOW do we test this?
-end
-
Index: /trunk/Ohana/src/opihi/cmd.data/test/periodogram.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/periodogram.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.data/test/periodogram.sh	(revision 14176)
@@ -23,4 +23,5 @@
  if (abs ($peakpos - $P) > 0.5)
    $PASS = 0
+   echo "OFFSET: {$peakpos - $P}"
  end
 end
@@ -90,6 +91,6 @@
  periodogram t f 2 30 period power
 
-  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
-  lim -n 1 period power; clear; box; plot period power
+#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
+#  lim -n 1 period power; clear; box; plot period power
 
  peak -q period power
Index: /trunk/Ohana/src/opihi/cmd.data/test/queues.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/queues.sh	(revision 14175)
+++ /trunk/Ohana/src/opihi/cmd.data/test/queues.sh	(revision 14176)
@@ -21,5 +21,5 @@
 # test queueinit
 macro test1
-
+ $PASS = 1
  queueinit dummy
  queuesize dummy -var N
@@ -30,7 +30,7 @@
 end
 
-# test queueinit
+# test queueinit memory
 macro testmem1
-
+ $PASS = 1
  list word -x "ps -p $PID -o rss"
  $startmem = $word:1
@@ -54,5 +54,5 @@
 # test queuesize
 macro test2
-
+ $PASS = 1
  queueinit dummy
  queuepush dummy foobar
@@ -64,7 +64,7 @@
 end
 
-# test queuesize
+# test queuesize memory
 macro testmem2
-
+ $PASS = 1
  queueinit dummy
  queuepush dummy foobar
@@ -91,5 +91,5 @@
 # test queuedelete
 macro test3
-
+ $PASS = 1
  queueinit dummy
  queuepush dummy foobar
@@ -106,7 +106,7 @@
 end
 
-# test queuedelete
+# test queuedelete memory
 macro testmem3
-
+ $PASS = 1
  list word -x "ps -p $PID -o rss"
  $startmem = $word:1
@@ -132,5 +132,5 @@
 # test queuepush / queuepop
 macro test4
-
+ $PASS = 1
  queueinit dummy
  queuepush dummy foobar
@@ -144,5 +144,5 @@
 # test queuepush / queuepop
 macro test4.1
-
+ $PASS = 1
  queueinit dummy
  queuepush dummy foo1
@@ -168,7 +168,7 @@
 end
 
-# test queuedelete
+# test queuepush / queuepop memory
 macro testmem4.0
-
+ $PASS = 1
  list word -x "ps -p $PID -o rss"
  $startmem = $word:1
@@ -192,7 +192,7 @@
 end
 
-# test queuedelete
+# test queuepush / queuepop memory
 macro testmem4.1
-
+ $PASS = 1
  list word -x "ps -p $PID -o rss"
  $startmem = $word:1
@@ -216,30 +216,30 @@
 end
 
-# test queuedelete
+# test queuepush / queuepop memory
 macro testmem4.2
-
- list word -x "ps -p $PID -o rss"
- $startmem = $word:1
-
- output /dev/null
- for i 0 10000
-   queueinit dummy
-   queuepush dummy foobar
- end
- output stdout
-
- 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
-
-# test queuedelete
+ $PASS = 1
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ output /dev/null
+ for i 0 10000
+   queueinit dummy
+   queuepush dummy foobar
+ end
+ output stdout
+
+ 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
+
+# test queuepush / queuepop memory
 macro testmem4.3
-
+ $PASS = 1
  list word -x "ps -p $PID -o rss"
  $startmem = $word:1
@@ -266,5 +266,5 @@
 # test queuepush / queuepop with keys
 macro test5
-
+ $PASS = 1
  queueinit dummy
  queuepush dummy "test 1 word"
@@ -278,7 +278,7 @@
 end
 
-# test queuepush / queuepop
+# test queuepush / queuepop with keys
 macro test5.1
-
+ $PASS = 1
  queueinit dummy
  queuepush dummy "test 1 word"
@@ -292,7 +292,7 @@
 end
 
-# test queuedelete
+# memory test for queuepush / queuepop with keys
 macro testmem5.0
-
+ $PASS = 1
  queueinit dummy
 
@@ -322,7 +322,7 @@
 end
 
-# test queuedelete
+# memory test for queuepush / queuepop with keys
 macro testmem5.1
-
+ $PASS = 1
  queueinit dummy
 
@@ -346,3 +346,2 @@
  end
 end
-
