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
-
