Index: /trunk/Ohana/src/opihi/cmd.basic/test/module.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/module.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/module.sh	(revision 16056)
@@ -0,0 +1,16 @@
+
+list tests
+ test1
+end
+
+# Test if the $MODULES list is available
+macro test1
+
+ $PASS = 1
+
+ if ($?MODULES:0 != 1)
+  $PASS = 0
+  echo "Modules list not loaded!"
+ end
+
+end
Index: /trunk/Ohana/src/opihi/cmd.data/test/applyfit2d.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/applyfit2d.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/applyfit2d.sh	(revision 16056)
@@ -0,0 +1,55 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if applyfit2d works
+macro test1
+
+ $PASS = 1
+
+ $Cnn = 2
+ $CX0Y0 = 1
+ $CX1Y0 = -4
+ $CX2Y0 = 2
+ $CX1Y1 = -3
+ $CX0Y1 = 1.5
+ $CX0Y2 = -2.5
+
+ create x 0 5 0.01
+ set y = 3*cos(2*3.14159*x/2.25)
+
+ applyfit2d x y z
+
+ if (abs(z[300]-12.625) > 0.001)
+  $PASS = 0
+  echo "Value mismatch: z[300]"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  applyfit2d x y z
+ 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/book.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/book.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/book.sh	(revision 16056)
@@ -0,0 +1,111 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test book commands
+macro test1
+
+ $PASS = 1
+
+ local bname01 bname02 pcheck pname01 pname02 tword01 tword02 wcheck
+
+ book create testb01
+ book create testb02
+ book getbook 0 -var bname01
+ book getbook 1 -var bname02
+
+ if (("$bname01" != "testb01") || ("$bname02" != "testb02"))
+  $PASS = 0
+  echo "Books not created/listed correctly!"
+ end
+
+ #break
+
+ book newpage testb01 tpage01
+ book newpage testb01 tpage02
+ book npages testb01 -var pcheck
+ 
+ if ($pcheck != 2)
+  $PASS = 0
+  echo "Book pages not added/recorded correctly!"
+ end
+
+ book getpage testb01 0 -var pname01
+ book getpage testb01 1 -var pname02
+
+ if (("$pname01" != "tpage01") || ("$pname02" != "tpage02"))
+  $PASS = 0
+  echo "Pages not created/listed correctly!"
+ end
+
+ book setword testb01 tpage01 w01 tword01
+ book setword testb01 tpage01 w02 tword02
+ book getword testb01 tpage01 w01 -var wcheck
+
+ if ("$wcheck" != "tword01")
+  $PASS = 0
+  echo "Words not created/listed correctly!"
+ end
+
+ book delpage testb01 tpage02
+ book getpage testb01 1 -var pcheck
+
+ if ("$pcheck" != "NULL")
+  $PASS = 0
+  echo "Book pages not deleted correctly (by delpage)!"
+ end
+
+ book init testb01
+ book getpage testb01 0 -var pcheck
+
+ if ("$pcheck" != "NULL")
+  $PASS = 0
+  echo "Book pages not deleted correctly (by init)!"
+ end
+
+ book delete testb01
+ book delete testb02
+
+# delete bname01 bname02 pcheck pname01 pname02 tword01 tword02 wcheck
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i bcheck pcheck wcheck
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  book create testb
+  book getbook 0 -var bcheck
+  book newpage testb testp1
+  book newpage testb testp2
+  book npages testb -var pcheck
+  book getpage testb 0 -var pcheck
+  book setword testb testp1 testw tada
+  book getword testb testp1 testw -var wcheck
+  book delpage testb testp2
+  book init testb
+  book delete testb
+ 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
+
+#delete i bcheck pcheck wcheck
+
+end
Index: /trunk/Ohana/src/opihi/cmd.data/test/cut.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/cut.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/cut.sh	(revision 16056)
@@ -0,0 +1,38 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if cut works
+macro test1
+
+ $PASS = 1
+
+ mcreate tim 100 10
+ zap tim 0 0 100 10 -v 10
+
+ cut tim xdir imx X 40 4 60 6
+ cut tim ydir imy Y 40 4 60 6
+
+ if (xdir[] != 60)
+  $PASS = 0
+ end
+ if (imx[] != 60)
+  $PASS = 0
+ end
+
+ if (ydir[] != 6)
+  $PASS = 0
+ end
+ if (imy[] != 6)
+  $PASS = 0
+ end
+
+ if (imx[0] != 10*6)
+  $PASS = 0
+ end
+ if (imy[0] != 10*60)
+  $PASS = 0
+ end
+end
Index: /trunk/Ohana/src/opihi/cmd.data/test/dimendown.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/dimendown.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/dimendown.sh	(revision 16056)
@@ -0,0 +1,60 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if dimendown works
+macro test1
+
+ $PASS = 1
+
+ mcreate timg 100 10
+ zap timg 0 0 100 10 -v 10
+ dimendown timg val
+ dimendown timg xc -x
+ dimendown timg yc -y
+
+ if (val[777] != 10)
+  $PASS = 0
+  echo "Value mismatch: val[777] (should be 10)"
+ end
+
+ if (xc[777] != 77)
+  $PASS = 0
+  echo "X Coord mismatch: xc[777] (should be 77)"
+ end
+
+ if (yc[777] != 7)
+  $PASS = 0
+  echo "Y Coord mismatch: yc[77] (should be 7)"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  dimendown timg val
+  dimendown timg xc -x
+  dimendown timg yc -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/dimenup.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/dimenup.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/dimenup.sh	(revision 16056)
@@ -0,0 +1,48 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if dimendown works
+macro test1
+
+ $PASS = 1
+
+ create tvec 0 1000
+
+ dimenup tvec timg 10 100
+
+ stats -q timg 6 34 1 1
+
+ if ($MEAN != 346)
+  $PASS = 0
+  echo "Value mismatch: $MEAN (should be 346)"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  dimenup tvec timg 10 100
+ 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 16055)
+++ /trunk/Ohana/src/opihi/cmd.data/test/fit2d.sh	(revision 16056)
@@ -3,206 +3,116 @@
  test1
  test2
- test3
- test4
- test5
- test6
- test7
- test8
+ memtest1
 end
 
-# fit a line without errors
+# fit a function 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
+ create x 0 5 0.01
+ set y = sin((2*3.14159*x)/2)
+ set z = 5-4*x+x^2-3*y+6*x*y-2*y^2
 
- if ($Cn != 1)
+ fit2d -q x y z 2
+
+ if ($Cnn != 2)
    $PASS = 0
+   echo "Function Order Incorrect!"
  end
- if (abs($C0 - 3) > 1e-5)
+ if (abs($CX0Y0 - 5) > 1e-5)
    $PASS = 0
+   echo "Term CX0Y0 Incorrect!"
  end
- if (abs($C1 - 5) > 1e-5)
+ if (abs($CX1Y0 + 4) > 1e-5)
    $PASS = 0
+   echo "Term CX1Y0 Incorrect!"
+ end
+ if (abs($CX2Y0 - 1) > 1e-5)
+   $PASS = 0
+   echo "Term CX2Y0 Incorrect!"
+ end
+ if (abs($CX0Y1 + 3) > 1e-5)
+   $PASS = 0
+   echo "Term CX0Y1 Incorrect!"
+ end
+ if (abs($CX1Y1 - 6) > 1e-5)
+   $PASS = 0
+   echo "Term CX1Y1 Incorrect!"
+ end
+ if (abs($CX0Y2 + 2) > 1e-5)
+   $PASS = 0
+   echo "Term CX0Y2 Incorrect!"
  end
 end
 
-# fit a line with errors
+# fit a function 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
+ create x 0 5 0.01
+ set y = sin((2*3.14159*x)/2)
+ set dz = 0.1*rnd(x) - 0.05
+ set z = 5-4*x+x^2-3*y+6*x*y-2*y^2+dz
 
- if ($Cn != 1)
+ fit2d -q x y z 2
+
+ if ($Cnn != 2)
    $PASS = 0
+   echo "Function Order Incorrect!"
  end
- if (abs($C0 - 3) > 0.01)
+ if (abs($CX0Y0 - 5) > 0.01)
    $PASS = 0
+   echo "Term CX0Y0 Incorrect!"
  end
- if (abs($C1 - 5) > 0.01)
+ if (abs($CX1Y0 + 4) > 0.01)
    $PASS = 0
+   echo "Term CX1Y0 Incorrect!"
+ end
+ if (abs($CX2Y0 - 1) > 0.01)
+   $PASS = 0
+   echo "Term CX2Y0 Incorrect!"
+ end
+ if (abs($CX0Y1 + 3) > 0.01)
+   $PASS = 0
+   echo "Term CX0Y1 Incorrect!"
+ end
+ if (abs($CX1Y1 - 6) > 0.01)
+   $PASS = 0
+   echo "Term CX1Y1 Incorrect!"
+ end
+ if (abs($CX0Y2 + 2) > 0.01)
+   $PASS = 0
+   echo "Term CX0Y2 Incorrect!"
  end
 end
 
-# fit a line with errors and weights
-macro test3
+# Memory Test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ create x 0 5 0.01
+ set y = sin((2*3.14159*x)/2)
+ set dz = 0.1*rnd(x) - 0.05
+ set z = 5-4*x+x^2-3*y+6*x*y-2*y^2+dz
+
+ for i 0 1000
+  fit2d -q x y z 2
+ end
+  
+ list word -x "ps -p $PID -o rss"
+ $endmem = $word:1
+
  $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)
+ if ($endmem - $startmem > 10)
    $PASS = 0
- end
- if (abs($C0 - 3) > 0.02)
-   $PASS = 0
- end
- if (abs($C1 - 5) > 0.02)
-   $PASS = 0
+   echo "growth: {$endmem-$startmem}"
+   echo "kB/loop: {($endmem-$startmem)/1000}"
  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/gaussj.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/gaussj.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/gaussj.sh	(revision 16056)
@@ -0,0 +1,128 @@
+
+list tests
+ test1
+ test2
+end
+
+macro test1
+ $PASS = 1
+ break -auto off
+
+ mcreate A 3 3
+ create B 0 3
+
+ A[0][0] = 2
+ A[1][1] = 2
+ A[2][2] = 2
+
+ A[0][1] = -1
+ A[1][2] = -1
+ A[1][0] = -1
+ A[2][1] = -1
+
+ gaussj A B
+
+ if (abs(A[0][0] - 0.75) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[0][1] - 0.50) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[0][2] - 0.25) > 0.01)
+  $PASS = 0
+ end
+
+ if (abs(A[1][0] - 0.50) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[1][1] - 1.00) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[1][2] - 0.50) > 0.01)
+  $PASS = 0
+ end
+
+ if (abs(A[2][0] - 0.25) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[2][1] - 0.50) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[2][2] - 0.75) > 0.01)
+  $PASS = 0
+ end
+
+ if (abs(B[0] - 1.00) > 0.01)
+  $PASS = 0
+ end
+ if (abs(B[1] - 2.00) > 0.01)
+  $PASS = 0
+ end
+ if (abs(B[2] - 2.00) > 0.01)
+  $PASS = 0
+ end
+end
+
+macro test2
+ $PASS = 1
+ break -auto off
+
+ mcreate A 3 3
+ create B 0 3
+
+ A[0][1] = 2
+ A[1][0] = 2
+ A[2][2] = 2
+
+ A[0][0] = -1
+ A[1][2] = -1
+ A[1][1] = -1
+ A[2][0] = -1
+
+ gaussj A B
+
+ # echo A[0][0] A[0][1] A[0][2]
+ # echo A[1][0] A[1][1] A[1][2]
+ # echo A[2][0] A[2][1] A[2][2]
+
+ if (abs(A[1][0] - 0.75) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[1][1] - 0.50) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[1][2] - 0.25) > 0.01)
+  $PASS = 0
+ end
+
+ if (abs(A[0][0] - 0.50) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[0][1] - 1.00) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[0][2] - 0.50) > 0.01)
+  $PASS = 0
+ end
+
+ if (abs(A[2][0] - 0.25) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[2][1] - 0.50) > 0.01)
+  $PASS = 0
+ end
+ if (abs(A[2][2] - 0.75) > 0.01)
+  $PASS = 0
+ end
+
+ if (abs(B[1] - 1.00) > 0.01)
+  $PASS = 0
+ end
+ if (abs(B[0] - 2.00) > 0.01)
+  $PASS = 0
+ end
+ if (abs(B[2] - 2.00) > 0.01)
+  $PASS = 0
+ end
+end
+
Index: /trunk/Ohana/src/opihi/cmd.data/test/histogram.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/histogram.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/histogram.sh	(revision 16056)
@@ -0,0 +1,52 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if histogram works
+macro test1
+
+ $PASS = 1
+
+ local i
+
+ create x 0 10 0.1
+
+ for i 45 55
+  x[$i] = 4.5
+ end
+
+ histogram x xhis 0 10 0.1
+
+ if ((xhis[10] != 1) || (xhis[45] != 10))
+  $PASS = 0
+  echo "Value mismatch: xhis[10] xhis[45] (should be 1,10)"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  histogram x xhis 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/imhist.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/imhist.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/imhist.sh	(revision 16056)
@@ -0,0 +1,58 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if imhist works
+macro test1
+
+ $PASS = 1
+
+ local i
+
+ mcreate buff 100 10
+
+ zap buff 40 0 10 10 -v 17
+ zap buff 60 5 5 2 -v 6
+
+ imhist buff xvec yvec
+
+ if ((xvec[1024] != 17) || (yvec[1024] != 100))
+  $PASS = 0
+  echo "Value mismatch: xvec[1024] yvec[1024] (should be 17,100)"
+ end
+
+ imhist buff xvec yvec -region 40 0 25 10 -range 0 10
+
+ if ((xvec[1024] != 10) || (yvec[1024] != 100))
+  $PASS = 0
+  echo "Value mismatch: xvec[1024] yvec[1024] (should be 10,100)"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  imhist buff xvec yvec -region 40 0 25 10 -range 0 10
+ 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/imsmooth.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/imsmooth.sh	(revision 16056)
+++ /trunk/Ohana/src/opihi/cmd.data/test/imsmooth.sh	(revision 16056)
@@ -0,0 +1,59 @@
+
+list tests
+ test1
+ memtest1
+end
+
+# Test if imsmooth works
+macro test1
+
+ $PASS = 1
+
+ local i j
+
+ mcreate buff 100 100
+
+ for i 0 99
+  for j 0 99
+   zap buff $i $j 1 1 -v {100*rnd($i)}
+  end
+ end
+
+ stats -q buff
+ $s1 = $SIGMA
+
+ imsmooth buff 10
+ stats -q buff
+ $s2 = $SIGMA
+
+ if ($s2/$s1 >= 0.1)
+  $PASS = 0
+  echo "Inadequate noise reduction: {$s2/$s1*100}\% (should be less than 10%)"
+ end
+
+end
+
+
+# Memory test
+macro memtest1
+
+ local i
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  imsmooth buff 10
+ 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/integrate.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/integrate.sh	(revision 16055)
+++ /trunk/Ohana/src/opihi/cmd.data/test/integrate.sh	(revision 16056)
@@ -15,5 +15,5 @@
  integrate x y 1 5
 
- if (($sum-152) > 0.5)
+ if (abs ($sum-152) > 0.5)
   $PASS = 0
   echo "Inaccurate result (should be 152): $sum"
Index: /trunk/Ohana/src/opihi/cmd.data/test/interpolate.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/interpolate.sh	(revision 16055)
+++ /trunk/Ohana/src/opihi/cmd.data/test/interpolate.sh	(revision 16056)
@@ -16,5 +16,5 @@
  integrate x1 y1 1 5
 
- if (($sum-152) > 0.08)
+ if (abs ($sum-152) > 0.08)
   $PASS = 0
   echo "Inaccurate result (should be 152): $sum"
Index: /trunk/Ohana/src/opihi/cmd.data/test/periodogram.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/test/periodogram.sh	(revision 16055)
+++ /trunk/Ohana/src/opihi/cmd.data/test/periodogram.sh	(revision 16056)
@@ -4,4 +4,5 @@
  test2
  test3
+ memtest1
 end
 
@@ -100,2 +101,33 @@
  end
 end
+
+# Memory test
+macro memtest1
+
+ local i
+ local P PI
+ $PI = 3.14159265359
+ $P  = 15.0
+
+ create x 500 800
+ set t = 300 * rnd(x) + 500
+ set f = sin(2*$PI*t/$P)
+
+ list word -x "ps -p $PID -o rss"
+ $startmem = $word:1
+
+ for i 0 1000
+  periodogram t f 2 30 period power
+ 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
