1 #!/bin/bash
  2 # --verbose  print as lines are read
  3 
  4 # $Revision: 1.4 $  $Author: schwehr $  $Date: 2004/11/03 00:42:35 $
  5 
  6 ##############################################################################
  7 #     Copyright (C) 2004  Kurt Schwehr
  8 #
  9 #     This program is free software; you can redistribute it and/or modify
 10 #     it under the terms of the GNU General Public License as published by
 11 #     the Free Software Foundation; either version 2 of the License, or
 12 #     (at your option) any later version.
 13 #
 14 #     This program is distributed in the hope that it will be useful,
 15 #     but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17 #     GNU General Public License for more details.
 18 #
 19 #     You should have received a copy of the GNU General Public License
 20 #     along with this program; if not, write to the Free Software
 21 #     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 22 ###############################################################################
 23 
 24 # This should become a variety of tests that make sure that all the
 25 # programs are working ok from the outside.  The code regression tests
 26 # can not see the outside picture.
 27 
 28 
 29 export PATH=${PATH}:.
 30 cells=80
 31 draw=10000
 32 declare -r w=0.5
 33 declare -r boundaries="-x -${w} -X ${w} -y -${w} -Y ${w} -z -${w} -Z ${w}"
 34 declare -r debug_level=2
 35 
 36 declare -i testno=1  # Increment this to track which test we are one.
 37 
 38 make targets-no-test
 39 
 40 ######################################################################
 41 # Make sure that we can get back the same value from the cell
 42 
 43 #echo Starting test number: $testno
 44 echo "0.01 0.01 0.01" > $testno.xyz
 45 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
 46 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
 47 count=`xyzvol_cmp -d $testno.vol $range $testno.xyz --out=- | awk '{print $6}'`
 48 if [ 1 != $count ]; then
 49     echo "  Test number $testno:    FAILED"
 50     exit 1
 51 else 
 52     echo "  Test number $testno:    ok."
 53 fi
 54 testno=$[testno+1]
 55 
 56 
 57 echo "0.99 0.01 0.01" > $testno.xyz
 58 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
 59 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
 60 count=`xyzvol_cmp -d $testno.vol $range $testno.xyz --out=- | awk '{print $6}'`
 61 if [ 1 != $count ]; then
 62     echo "  Test number $testno:    FAILED"
 63     exit 1
 64 else 
 65     echo "  Test number $testno:    ok."
 66 fi
 67 testno=$[testno+1]
 68 
 69 
 70 echo "0.01 0.01 0.99" > $testno.xyz
 71 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
 72 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
 73 count=`xyzvol_cmp -d $testno.vol $range $testno.xyz  --out=- | awk '{print $6}'`
 74 if [ 1 != $count ]; then
 75     echo "  Test number $testno:    FAILED"
 76     exit 1
 77 else 
 78     echo "  Test number $testno:    ok."
 79 fi
 80 testno=$[testno+1]
 81 
 82 
 83 echo "0.01 0.01 0.99" > $testno.xyz
 84 echo "0.01 0.99 0.99" > $testno-b.xyz
 85 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
 86 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
 87 count=`xyzvol_cmp -d $testno.vol $range $testno-b.xyz  --out=- | awk '{print $6}'`
 88 if [ 0 != $count ]; then
 89     echo "  Test number $testno:    FAILED"
 90     exit 1
 91 else 
 92     echo "  Test number $testno:    ok."
 93 fi
 94 testno=$[testno+1]
 95 
 96 
 97 echo "0.01 0.99 0.99" > $testno.xyz
 98 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
 99 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
100 count=`xyzvol_cmp -d $testno.vol $range $testno.xyz  --out=- | awk '{print $6}'`
101 if [ 1 != $count ]; then
102     echo "  Test number $testno:    FAILED"
103     exit 1
104 else 
105     echo "  Test number $testno:    ok."
106 fi
107 testno=$[testno+1]
108 
109 
110 
111 echo "0.99 0.01 0.99" > $testno.xyz
112 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
113 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
114 count=`xyzvol_cmp -d $testno.vol $range $testno.xyz  --out=- | awk '{print $6}'`
115 if [ 1 != $count ]; then
116     echo "  Test number $testno:    FAILED"
117     exit 1
118 else 
119     echo "  Test number $testno:    ok."
120 fi
121 testno=$[testno+1]
122 
123 
124 echo "0.99 0.99 0.99" > $testno.xyz
125 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
126 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
127 count=`xyzvol_cmp -d $testno.vol $range $testno.xyz  --out=- | awk '{print $6}'`
128 if [ 1 != $count ]; then
129     echo "  Test number $testno:    FAILED"
130     exit 1
131 else 
132     echo "  Test number $testno:    ok."
133 fi
134 testno=$[testno+1]
135 
136 
137 
138 echo "0.5 0.5 0.5" > $testno.xyz
139 range="--xmin=0. --xmax=1. --ymin=0. --ymax=1. --zmin=0. --zmax=1."
140 xyzdensity --out=$testno.vol --pack=1 $range -b 8 -w 10 -t 10 -d 10 $testno.xyz
141 count=`xyzvol_cmp -d $testno.vol $range $testno.xyz  --out=- | awk '{print $6}'`
142 if [ 1 != $count ]; then
143     echo "  Test number $testno:    FAILED"
144     exit 1
145 else 
146     echo "  Test number $testno:    ok."
147 fi
148 testno=$[testno+1]
149 
150 
151 
152 ######################################################################
153 # Make sure that s_bootstrap returns the same value if sigma is zero.
154 
155 tail -1 as2-slump.s | awk '{print $1,$2,$3,$4,$5,$6,0.}' > $testno.s
156 s_bootstrap $testno.s -f xyz -n 1 --out $testno-boot.xyz -d 1 -p
157 s_eigs < $testno.s > $testno.eigs
158 eigs2xyz.py $testno.eigs > $testno.xyz
159 declare -a a=( `cat $testno.xyz` )
160 declare -a b=( `cat $testno-boot.xyz`  )
161 
162 is_Equal  ${a[0]} ${b[0]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
163 is_Equal  ${a[1]} ${b[1]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
164 is_Equal  ${a[2]} ${b[2]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
165 is_Equal  ${a[3]} ${b[3]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
166 is_Equal  ${a[4]} ${b[4]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
167 is_Equal  ${a[5]} ${b[5]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
168 is_Equal  ${a[6]} ${b[6]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
169 is_Equal  ${a[7]} ${b[7]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
170 is_Equal  ${a[8]} ${b[8]} 0.001 || (echo "Test number $testno:    FAILED";exit 1)
171 
172 testno=$[testno+1]
173 
174 ######################################################################
175 # make sure that vmin and vmax are getting written out correctly
176 # len(vmin) < len(vmax)
177 # for the 3 file output from s_bootstrap
178 
179 head -1 as2-slump.s > $testno.s
180 s_bootstrap $testno.s -f xyz -n 3 --out $testno.xyz. -d 1 -p
181 declare -a vmin=( `cat $testno.xyz.3.vmin` )
182 declare -a vint=( `cat $testno.xyz.2.vint` )
183 declare -a vmax=( `cat $testno.xyz.1.vmax` )
184 vminlen=`echo "${vmin[0]}  ${vmin[1]}  ${vmin[2]}"  |  awk '{print sqrt($1*$1 + $2*$2 + $3*$3)}'`
185 vintlen=`echo "${vint[0]}  ${vint[1]}  ${vint[2]}"  |  awk '{print sqrt($1*$1 + $2*$2 + $3*$3)}'`
186 vmaxlen=`echo "${vmax[0]}  ${vmax[1]}  ${vmax[2]}"  |  awk '{print sqrt($1*$1 + $2*$2 + $3*$3)}'`
187 
188 unset vmin vint vmax
189 
190 t=`echo $vminlen $vintlen | awk '{if ($1>$2) print 0; else print 1}' `
191 if [ 0 == $t ]; then echo "Test number $testno:    FAILED 1";exit 1; fi
192 t=`echo $vminlen $vmaxlen | awk '{if ($1>$2) print 0; else print 1}' `
193 if [ 0 == $t ]; then echo "Test number $testno:    FAILED 2";exit 1; fi
194 t=`echo $vintlen $vmaxlen | awk '{if ($1>$2) print 0; else print 1}' `
195 if [ 0 == $t ]; then echo "Test number $testno:    FAILED 3";exit 1; fi
196 
197 testno=$[testno+1]
198 
199 # for the 1 file output from s_bootstrap
200 # Make sure that things all come out in the right order
201 
202 head -1 as2-slump.s > $testno.s
203 s_bootstrap $testno.s -f xyz -n 1 --out $testno.xyz -d 1 -p
204 declare -a v=( `cat $testno.xyz` )
205 vminlen=`echo "${v[0]}  ${v[1]}  ${v[2]}"  |  awk '{print sqrt($1*$1 + $2*$2 + $3*$3)}'`
206 vintlen=`echo "${v[3]}  ${v[4]}  ${v[5]}"  |  awk '{print sqrt($1*$1 + $2*$2 + $3*$3)}'`
207 vmaxlen=`echo "${v[6]}  ${v[7]}  ${v[8]}"  |  awk '{print sqrt($1*$1 + $2*$2 + $3*$3)}'`
208 
209 #echo min = $vminlen int = $vintlen max = $vmaxlen
210 unset v
211 
212 t=`echo $vminlen $vintlen | awk '{if ($1>$2) print 0; else print 1}' `
213 if [ 0 == $t ]; then echo "Test number $testno:    FAILED 1";exit 1; fi
214 t=`echo $vminlen $vmaxlen | awk '{if ($1>$2) print 0; else print 1}' `
215 if [ 0 == $t ]; then echo "Test number $testno:    FAILED 2";exit 1; fi
216 t=`echo $vintlen $vmaxlen | awk '{if ($1>$2) print 0; else print 1}' `
217 if [ 0 == $t ]; then echo "Test number $testno:    FAILED 3";exit 1; fi
218 
219 testno=$[testno+1]


syntax highlighted by Code2HTML, v. 0.9.1