| 1 |
greg |
1.1 |
#!/usr/bin/ruby
|
| 2 |
|
|
|
| 3 |
|
|
# Radiance test library
|
| 4 |
|
|
|
| 5 |
|
|
# Use with cmake build system deployed by NREL
|
| 6 |
|
|
# Run from [build]/resources
|
| 7 |
|
|
# usage: [ruby]test_lib[.rb] (runs all tests with all available cores passed to radiance MP tools)
|
| 8 |
|
|
# usage: [ruby]test_lib[.rb] -n [n] -t ['testname', 'all']
|
| 9 |
|
|
|
| 10 |
|
|
|
| 11 |
|
|
$stderr.sync = true
|
| 12 |
|
|
require 'optparse'
|
| 13 |
|
|
require 'etc'
|
| 14 |
|
|
# default options
|
| 15 |
|
|
flag = false
|
| 16 |
|
|
tst = "all"
|
| 17 |
|
|
|
| 18 |
|
|
tproc = Etc.nprocessors
|
| 19 |
|
|
nproc = tproc / 2 # half cores by default, override with -n
|
| 20 |
|
|
list = ["x", "y", "z"]
|
| 21 |
|
|
|
| 22 |
|
|
# parse arguments
|
| 23 |
|
|
file = __FILE__
|
| 24 |
|
|
ARGV.options do |opts|
|
| 25 |
|
|
opts.on("-t", "--test=val", String) { |val| tst = val }
|
| 26 |
|
|
opts.on("-n", "--nproc=val", Integer) { |val| nproc = val }
|
| 27 |
|
|
opts.parse!
|
| 28 |
|
|
end
|
| 29 |
|
|
|
| 30 |
|
|
# print opts
|
| 31 |
|
|
warn "ARGV: #{ARGV.inspect}"
|
| 32 |
|
|
warn "test: #{tst.inspect}"
|
| 33 |
|
|
warn "cores: #{nproc.inspect} (of #{tproc} total)"
|
| 34 |
|
|
|
| 35 |
|
|
test_in = tst
|
| 36 |
|
|
|
| 37 |
|
|
test_total = 0
|
| 38 |
|
|
@test_pass = 0
|
| 39 |
|
|
@test_fail = 0
|
| 40 |
|
|
|
| 41 |
|
|
all_tests = [
|
| 42 |
|
|
'test_xform' , 'test_rad' , 'test_rtrace' , 'test_vwright' , 'test_rcollate' , 'test_dctimestep',
|
| 43 |
|
|
'test_getinfo' , 'test_rmtxop' , 'test_oconv' , 'test_rfluxmtx' , 'test_dielectric_def' ,
|
| 44 |
|
|
'test_dielectric_fish', 'test_replmarks', 'test_gensky', 'test_gendaymtx','test_genbox',
|
| 45 |
|
|
'test_genrev', 'test_genworm', 'test_genprism', 'test_gensurf', 'test_cnt', 'test_rcalc',
|
| 46 |
|
|
'test_total', 'test_histo', 'test_rlam'
|
| 47 |
|
|
]
|
| 48 |
|
|
|
| 49 |
|
|
def rcpf
|
| 50 |
|
|
if $?.exitstatus == 0
|
| 51 |
|
|
@test_pass +=1
|
| 52 |
|
|
|
| 53 |
|
|
puts "test: PASS"
|
| 54 |
|
|
else
|
| 55 |
|
|
@test_fail +=1
|
| 56 |
|
|
puts "test: FAIL"
|
| 57 |
|
|
end
|
| 58 |
|
|
end
|
| 59 |
|
|
|
| 60 |
|
|
# Number of processes to use on tests that run multi-core
|
| 61 |
|
|
NPROC = nproc
|
| 62 |
|
|
|
| 63 |
|
|
# Image reduction for comparisons
|
| 64 |
|
|
RDU_PFILT = "pfilt -1 -r 1 -x 128 -y 128 -pa 1"
|
| 65 |
|
|
|
| 66 |
|
|
# Image comparison command
|
| 67 |
|
|
IMG_CMP = "radcompare -v -rms 0.07 -max 1.5"
|
| 68 |
|
|
|
| 69 |
|
|
## tests from test/util
|
| 70 |
|
|
|
| 71 |
|
|
def test_vwright
|
| 72 |
|
|
|
| 73 |
|
|
Dir.chdir('../test/util') do
|
| 74 |
|
|
# generate test input
|
| 75 |
|
|
cmd = "vwright -vf test.vf 3.5 > vwright.txt"
|
| 76 |
|
|
system(cmd)
|
| 77 |
|
|
|
| 78 |
|
|
# compare to reference
|
| 79 |
|
|
cmd = "radcompare -v ref/vwright.txt vwright.txt"
|
| 80 |
|
|
system(cmd)
|
| 81 |
|
|
|
| 82 |
|
|
# report pass/fail
|
| 83 |
|
|
rcpf
|
| 84 |
|
|
|
| 85 |
|
|
# cleanup
|
| 86 |
|
|
# File.delete("vwright.mtx")
|
| 87 |
|
|
end
|
| 88 |
|
|
|
| 89 |
|
|
end
|
| 90 |
|
|
|
| 91 |
|
|
def make_test_mtx
|
| 92 |
|
|
|
| 93 |
|
|
Dir.chdir('../test/util') do
|
| 94 |
|
|
|
| 95 |
|
|
cmd = "rcollate -t ../renders/ref/rfmirror.mtx > test.mtx"
|
| 96 |
|
|
system(cmd)
|
| 97 |
|
|
|
| 98 |
|
|
end
|
| 99 |
|
|
|
| 100 |
|
|
end
|
| 101 |
|
|
|
| 102 |
|
|
def test_rcollate
|
| 103 |
|
|
|
| 104 |
|
|
make_test_mtx if !File.exist?("../test/util/test.mtx")
|
| 105 |
|
|
|
| 106 |
|
|
Dir.chdir('../test/util') do
|
| 107 |
|
|
cmd = "radcompare -v ref/test.mtx test.mtx"
|
| 108 |
|
|
system(cmd)
|
| 109 |
|
|
end
|
| 110 |
|
|
|
| 111 |
|
|
rcpf
|
| 112 |
|
|
|
| 113 |
|
|
#File.delete("#{t}/test.mtx")
|
| 114 |
|
|
|
| 115 |
|
|
end
|
| 116 |
|
|
|
| 117 |
|
|
def test_dctimestep
|
| 118 |
|
|
|
| 119 |
|
|
make_test_mtx if !File.exist?("../test/util/test.mtx")
|
| 120 |
|
|
|
| 121 |
|
|
Dir.chdir('../test/util') do
|
| 122 |
|
|
cmd = "gensky 3 21 10:15PST +s -g .3 -g 2.5 -a 36 -o 124 | genskyvec -m 1 -c .92 1.03 1.2 | dctimestep '!rmtxop -ff -t test.mtx' > dctimestep.mtx"
|
| 123 |
|
|
system(cmd)
|
| 124 |
|
|
cmd = "radcompare -v ref/dctimestep.mtx dctimestep.mtx"
|
| 125 |
|
|
system(cmd)
|
| 126 |
|
|
end
|
| 127 |
|
|
|
| 128 |
|
|
rcpf
|
| 129 |
|
|
|
| 130 |
|
|
#File.delete("#{t}/dctimestep.mtx")
|
| 131 |
|
|
|
| 132 |
|
|
end
|
| 133 |
|
|
|
| 134 |
|
|
def test_getinfo
|
| 135 |
|
|
|
| 136 |
|
|
make_test_mtx if !File.exist?("../test/util/test.mtx")
|
| 137 |
|
|
|
| 138 |
|
|
Dir.chdir('../test/util') do
|
| 139 |
|
|
cmd = "getinfo -a Guppies 'Fredo the Frog' < test.mtx | getinfo > getinfo.txt"
|
| 140 |
|
|
system(cmd)
|
| 141 |
|
|
cmd = "radcompare -v ref/getinfo.txt getinfo.txt"
|
| 142 |
|
|
system(cmd)
|
| 143 |
|
|
end
|
| 144 |
|
|
|
| 145 |
|
|
rcpf
|
| 146 |
|
|
|
| 147 |
|
|
#File.delete("#{t}/getinfo.txt")
|
| 148 |
|
|
|
| 149 |
|
|
end
|
| 150 |
|
|
|
| 151 |
|
|
def test_rmtxop
|
| 152 |
|
|
|
| 153 |
|
|
make_test_mtx if !File.exist?("../test/util/test.mtx")
|
| 154 |
|
|
|
| 155 |
|
|
Dir.chdir('../test/util') do
|
| 156 |
|
|
cmd = "rmtxop -ff -c .3 .9 .2 test.mtx -c .7 .2 .3 -t test.mtx > rmtxop.mtx"
|
| 157 |
|
|
puts("command: #{cmd}")
|
| 158 |
|
|
system(cmd)
|
| 159 |
|
|
cmd = "radcompare -v ref/rmtxop.mtx rmtxop.mtx"
|
| 160 |
|
|
puts("command: #{cmd}")
|
| 161 |
|
|
system(cmd)
|
| 162 |
|
|
end
|
| 163 |
|
|
|
| 164 |
|
|
rcpf
|
| 165 |
|
|
#File.delete("#{t}/rmtxop.mtx")
|
| 166 |
|
|
|
| 167 |
|
|
end
|
| 168 |
|
|
|
| 169 |
|
|
### END test/util ###
|
| 170 |
|
|
|
| 171 |
|
|
|
| 172 |
|
|
### test/renders ###
|
| 173 |
|
|
|
| 174 |
|
|
def inst_oct
|
| 175 |
|
|
Dir.chdir('../test/renders') do
|
| 176 |
|
|
cmd = "rad -v 0 inst.rif"
|
| 177 |
|
|
puts("command: #{cmd}")
|
| 178 |
|
|
system(cmd)
|
| 179 |
|
|
end
|
| 180 |
|
|
end
|
| 181 |
|
|
|
| 182 |
|
|
def test_xform
|
| 183 |
|
|
combined_rad if !File.exist?("../test/renders/combined.rad")
|
| 184 |
|
|
Dir.chdir('../test/renders') do
|
| 185 |
|
|
cmd = "radcompare -v -max 0.04 ref/combined.rad combined.rad"
|
| 186 |
|
|
puts("command: #{cmd}")
|
| 187 |
|
|
system(cmd)
|
| 188 |
|
|
rcpf
|
| 189 |
|
|
end
|
| 190 |
|
|
end
|
| 191 |
|
|
|
| 192 |
|
|
def combined_rad
|
| 193 |
|
|
Dir.chdir('../test/renders') do
|
| 194 |
|
|
cmd = "xform -f combined_scene.rad | grep -v '^[ ]*#' > combined.rad"
|
| 195 |
|
|
puts("command: #{cmd}")
|
| 196 |
|
|
system(cmd)
|
| 197 |
|
|
end
|
| 198 |
|
|
end
|
| 199 |
|
|
|
| 200 |
|
|
def test_rad
|
| 201 |
|
|
Dir.chdir('../test/renders') do
|
| 202 |
|
|
cmd = 'rad -n -s -e inst.rif > inst_rad.txt'
|
| 203 |
|
|
system(cmd)
|
| 204 |
|
|
cmd = 'radcompare -v ref/inst_rad.txt inst_rad.txt'
|
| 205 |
|
|
puts("command: #{cmd}")
|
| 206 |
|
|
system(cmd)
|
| 207 |
|
|
rcpf
|
| 208 |
|
|
end
|
| 209 |
|
|
end
|
| 210 |
|
|
|
| 211 |
|
|
def test_oconv
|
| 212 |
|
|
inst_oct if !File.exist?("../test/renders/inst.oct")
|
| 213 |
|
|
Dir.chdir('../test/renders') do
|
| 214 |
|
|
cmd="radcompare -v ref/inst.oct inst.oct"
|
| 215 |
|
|
system(cmd)
|
| 216 |
|
|
end
|
| 217 |
|
|
rcpf
|
| 218 |
|
|
end
|
| 219 |
|
|
|
| 220 |
|
|
def gen_rtmirror_fish_hdr
|
| 221 |
|
|
Dir.chdir('../test/renders') do
|
| 222 |
|
|
puts "generating input file: rtmirror_fish.hdr"
|
| 223 |
|
|
cmd = "rad -v 0 mirror.rif OPT=mirror.opt"
|
| 224 |
|
|
system(cmd)
|
| 225 |
|
|
cmd = "vwrays -ff -vf fish.vf -x 2048 -y 2048 | rtrace -n #{NPROC} @mirror.opt -ffc -x 2048 -y 2048 mirror.oct | pfilt -1 -e +3 -r .6 -x /2 -y /2 > rtmirror_fish.hdr"
|
| 226 |
|
|
# rm -f mirror.opt
|
| 227 |
|
|
puts("command: #{cmd}")
|
| 228 |
|
|
system(cmd)
|
| 229 |
|
|
end
|
| 230 |
|
|
end
|
| 231 |
|
|
|
| 232 |
|
|
def test_rtrace
|
| 233 |
|
|
gen_rtmirror_fish_hdr if !File.exist?("../test/renders/rtmirror_fish.hdr")
|
| 234 |
|
|
Dir.chdir('../test/renders') do
|
| 235 |
|
|
cmd = "#{RDU_PFILT} rtmirror_fish.hdr | #{IMG_CMP} -h ref/mirror_fish.hdr -"
|
| 236 |
|
|
puts("command: #{cmd}")
|
| 237 |
|
|
system(cmd)
|
| 238 |
|
|
rcpf
|
| 239 |
|
|
end
|
| 240 |
|
|
end
|
| 241 |
|
|
|
| 242 |
|
|
def test_rfluxmtx
|
| 243 |
|
|
gen_rfmirror_mtx if !File.exist?("../test/renders/rfmirror.mtx")
|
| 244 |
|
|
Dir.chdir('../test/renders') do
|
| 245 |
|
|
cmd = 'radcompare -v -max .4 -rms .05 ref/rfmirror.mtx rfmirror.mtx'
|
| 246 |
|
|
puts("command: #{cmd}")
|
| 247 |
|
|
system(cmd)
|
| 248 |
|
|
rcpf
|
| 249 |
|
|
end
|
| 250 |
|
|
end
|
| 251 |
|
|
|
| 252 |
|
|
def gen_rfmirror_mtx
|
| 253 |
|
|
Dir.chdir('../test/renders') do
|
| 254 |
|
|
cmd = "rfluxmtx -n #{NPROC} -ab 2 -lw 1e-4 mirror.rad dummysky.rad basic.mat diorama_walls.rad closed_end.rad front_cap.rad glass_pane.rad antimatter_portal.rad > rfmirror.mtx"
|
| 255 |
|
|
puts("command: #{cmd}")
|
| 256 |
|
|
system(cmd)
|
| 257 |
|
|
end
|
| 258 |
|
|
end
|
| 259 |
|
|
|
| 260 |
|
|
def gen_dielectric_oct
|
| 261 |
|
|
Dir.chdir('../test/renders') do
|
| 262 |
|
|
cmd = 'rad -v 0 dielectric.rif'
|
| 263 |
|
|
puts("command: #{cmd}")
|
| 264 |
|
|
system(cmd)
|
| 265 |
|
|
end
|
| 266 |
|
|
end
|
| 267 |
|
|
|
| 268 |
|
|
def test_dielectric_def #ref/dielectric_def.hdr dielectric_def.hdr
|
| 269 |
|
|
gen_dielectric_def if !File.exist?("../test/renders/dielectric_def.hdr")
|
| 270 |
|
|
gen_dielectric_def_ref if !File.exist?("../test/renders/ref/dielectric_def.hdr")
|
| 271 |
|
|
Dir.chdir('../test/renders') do
|
| 272 |
|
|
cmd = "#{RDU_PFILT} dielectric_def.hdr | #{IMG_CMP} ref/dielectric_def.hdr -"
|
| 273 |
|
|
puts("command: #{cmd}")
|
| 274 |
|
|
system(cmd)
|
| 275 |
|
|
rcpf
|
| 276 |
|
|
end
|
| 277 |
|
|
end
|
| 278 |
|
|
|
| 279 |
|
|
def gen_dielectric_def_ref
|
| 280 |
|
|
gen_dielectric_def if !File.exist?('../test/renders/dielectric_def.hdr')
|
| 281 |
|
|
Dir.chdir('../test/renders') do
|
| 282 |
|
|
cmd = '#{RDU_PFILT} dielectric_def.hdr > ref/dielectric_def.hdr'
|
| 283 |
|
|
puts("command: #{cmd}")
|
| 284 |
|
|
system(cmd)
|
| 285 |
|
|
end
|
| 286 |
|
|
end
|
| 287 |
|
|
|
| 288 |
|
|
def gen_dielectric_def #dielectric.oct
|
| 289 |
|
|
gen_dielectric_oct if !File.exist?('../test/renders/dielectric.oct')
|
| 290 |
|
|
Dir.chdir('../test/renders') do
|
| 291 |
|
|
cmd = 'rad -v def dielectric.rif'
|
| 292 |
|
|
puts("command: #{cmd}")
|
| 293 |
|
|
system(cmd)
|
| 294 |
|
|
end
|
| 295 |
|
|
end
|
| 296 |
|
|
|
| 297 |
|
|
|
| 298 |
|
|
### Reference and test for dielectric view fish ###
|
| 299 |
|
|
|
| 300 |
|
|
def test_dielectric_fish # ref/dielectric_fish.hdr dielectric_fish.hdr
|
| 301 |
|
|
gen_dielectric_fish_hdr if !File.exist?('../test/renders/dielectric_fish.hdr')
|
| 302 |
|
|
gen_ref_dielectric_fish_hdr if !File.exist?('../test/renders/ref/dielectric_fish.hdr')
|
| 303 |
|
|
Dir.chdir('../test/renders') do
|
| 304 |
|
|
cmd = "#{RDU_PFILT} dielectric_fish.hdr | #{IMG_CMP} ref/dielectric_fish.hdr -"
|
| 305 |
|
|
puts("command: #{cmd}")
|
| 306 |
|
|
system(cmd)
|
| 307 |
|
|
rcpf
|
| 308 |
|
|
end
|
| 309 |
|
|
end
|
| 310 |
|
|
|
| 311 |
|
|
def gen_ref_dielectric_fish_hdr #dielectric.oct
|
| 312 |
|
|
gen_dielectric_fish_hdr if !File.exist?('../test/renders/dielectric_fish.hdr')
|
| 313 |
|
|
Dir.chdir('../test/renders') do
|
| 314 |
|
|
cmd = "#{RDU_PFILT} dielectric_fish.hdr > ref/dielectric_fish.hdr"
|
| 315 |
|
|
puts("command: #{cmd}")
|
| 316 |
|
|
system(cmd)
|
| 317 |
|
|
end
|
| 318 |
|
|
end
|
| 319 |
|
|
|
| 320 |
|
|
def gen_dielectric_fish_hdr
|
| 321 |
|
|
gen_dielectric_oct if !File.exist?('../test/renders/dielectric.oct')
|
| 322 |
|
|
Dir.chdir('../test/renders') do
|
| 323 |
|
|
cmd = 'rad -v fish dielectric.rif'
|
| 324 |
|
|
puts("command: #{cmd}")
|
| 325 |
|
|
system(cmd)
|
| 326 |
|
|
end
|
| 327 |
|
|
end
|
| 328 |
|
|
|
| 329 |
|
|
### End dielectric-fish tests
|
| 330 |
|
|
|
| 331 |
|
|
|
| 332 |
|
|
### END test/renders ###
|
| 333 |
|
|
|
| 334 |
|
|
|
| 335 |
|
|
### test/gen ###
|
| 336 |
|
|
|
| 337 |
|
|
def test_replmarks
|
| 338 |
|
|
Dir.chdir('../test/gen') do
|
| 339 |
|
|
cmd = "replmarks -s 1 -x dummy.rad rmod markers.rad | grep -v '^[ ]*#' > replmarks.rad"
|
| 340 |
|
|
puts("command: #{cmd}")
|
| 341 |
|
|
system(cmd)
|
| 342 |
|
|
|
| 343 |
|
|
rcpf
|
| 344 |
|
|
end
|
| 345 |
|
|
#rm -f replmarks.rad
|
| 346 |
|
|
end
|
| 347 |
|
|
|
| 348 |
|
|
|
| 349 |
|
|
def test_gensky
|
| 350 |
|
|
Dir.chdir('../test/gen') do
|
| 351 |
|
|
cmd = 'gensky 11 15 14:21EST +s -g .25 -t 3.5 -a 40.7128 -o 74.006 > NYC11-15-14-21.rad'
|
| 352 |
|
|
puts("command: #{cmd}")
|
| 353 |
|
|
system(cmd)
|
| 354 |
|
|
|
| 355 |
|
|
cmd = 'radcompare ref/NYC11-15-14-21.rad NYC11-15-14-21.rad'
|
| 356 |
|
|
puts("command: #{cmd}")
|
| 357 |
|
|
system(cmd)
|
| 358 |
|
|
|
| 359 |
|
|
rcpf
|
| 360 |
|
|
end
|
| 361 |
|
|
#rm -f NYC11-15-14-21.rad
|
| 362 |
|
|
end
|
| 363 |
|
|
|
| 364 |
|
|
|
| 365 |
|
|
def test_gendaymtx
|
| 366 |
|
|
Dir.chdir('../test/gen') do
|
| 367 |
|
|
cmd = 'gendaymtx -r 90 -m 1 -g .3 .2 .1 -c .9 .9 1.2 test.wea > test.smx'
|
| 368 |
|
|
puts("command: #{cmd}")
|
| 369 |
|
|
system(cmd)
|
| 370 |
|
|
|
| 371 |
|
|
cmd = 'radcompare ref/test.smx test.smx'
|
| 372 |
|
|
puts("command: #{cmd}")
|
| 373 |
|
|
system(cmd)
|
| 374 |
|
|
|
| 375 |
|
|
rcpf
|
| 376 |
|
|
end
|
| 377 |
|
|
#rm -f test.smx
|
| 378 |
|
|
end
|
| 379 |
|
|
|
| 380 |
|
|
def test_genbox
|
| 381 |
|
|
Dir.chdir('../test/gen') do
|
| 382 |
|
|
cmd = 'genbox tmat tbox 1 2 3 -i -b .1 > genbox.rad'
|
| 383 |
|
|
puts("command: #{cmd}")
|
| 384 |
|
|
system(cmd)
|
| 385 |
|
|
|
| 386 |
|
|
cmd = 'radcompare ref/genbox.rad genbox.rad'
|
| 387 |
|
|
puts("command: #{cmd}")
|
| 388 |
|
|
system(cmd)
|
| 389 |
|
|
|
| 390 |
|
|
rcpf
|
| 391 |
|
|
end
|
| 392 |
|
|
#rm -f genbox.rad
|
| 393 |
|
|
end
|
| 394 |
|
|
|
| 395 |
|
|
def test_genrev
|
| 396 |
|
|
Dir.chdir('../test/gen') do
|
| 397 |
|
|
cmd = "genrev tmat trev 'sin(2*PI*t)' '2+cos(2*PI*t)' 16 -s > genrev.rad"
|
| 398 |
|
|
puts("command: #{cmd}")
|
| 399 |
|
|
system(cmd)
|
| 400 |
|
|
|
| 401 |
|
|
cmd = 'radcompare ref/genrev.rad genrev.rad'
|
| 402 |
|
|
puts("command: #{cmd}")
|
| 403 |
|
|
system(cmd)
|
| 404 |
|
|
|
| 405 |
|
|
rcpf
|
| 406 |
|
|
end
|
| 407 |
|
|
#rm -f genrev.rad
|
| 408 |
|
|
end
|
| 409 |
|
|
|
| 410 |
|
|
def test_genworm
|
| 411 |
|
|
Dir.chdir('../test/gen') do
|
| 412 |
|
|
cmd = "genworm tmat tworm '0' '5*sin(t)' '5*cos(t)' '.4-(.5-t)*(.5-t)' 8 > genworm.rad"
|
| 413 |
|
|
puts("command: #{cmd}")
|
| 414 |
|
|
system(cmd)
|
| 415 |
|
|
|
| 416 |
|
|
cmd = 'radcompare ref/genworm.rad genworm.rad'
|
| 417 |
|
|
puts("command: #{cmd}")
|
| 418 |
|
|
system(cmd)
|
| 419 |
|
|
|
| 420 |
|
|
rcpf
|
| 421 |
|
|
end
|
| 422 |
|
|
#rm -f genworm.rad
|
| 423 |
|
|
end
|
| 424 |
|
|
|
| 425 |
|
|
def test_genprism
|
| 426 |
|
|
Dir.chdir('../test/gen') do
|
| 427 |
|
|
cmd = "genprism tmat tprism 8 0 5 4 5 4 4 24.5 4 24.5 3 30 1.5 30 22 0 22 -l 0 0 -1.5 -r .2 > genprism.rad"
|
| 428 |
|
|
puts("command: #{cmd}")
|
| 429 |
|
|
system(cmd)
|
| 430 |
|
|
|
| 431 |
|
|
cmd = 'radcompare ref/genprism.rad genprism.rad'
|
| 432 |
|
|
puts("command: #{cmd}")
|
| 433 |
|
|
system(cmd)
|
| 434 |
|
|
|
| 435 |
|
|
rcpf
|
| 436 |
|
|
end
|
| 437 |
|
|
#rm -f genprism.rad
|
| 438 |
|
|
end
|
| 439 |
|
|
|
| 440 |
|
|
def test_gensurf
|
| 441 |
|
|
Dir.chdir('../test/gen') do
|
| 442 |
|
|
cmd = "gensurf tmat tsurf '15.5+x(theta(s),phi(t))' '10.5+y(theta(s),phi(t))' '30.75+z(theta(s),phi(t))' 4 15 -f basin.cal -s > gensurf.rad"
|
| 443 |
|
|
puts("command: #{cmd}")
|
| 444 |
|
|
system(cmd)
|
| 445 |
|
|
|
| 446 |
|
|
cmd = 'radcompare ref/gensurf.rad gensurf.rad'
|
| 447 |
|
|
puts("command: #{cmd}")
|
| 448 |
|
|
system(cmd)
|
| 449 |
|
|
|
| 450 |
|
|
rcpf
|
| 451 |
|
|
end
|
| 452 |
|
|
#rm -f gensurf.rad
|
| 453 |
|
|
end
|
| 454 |
|
|
|
| 455 |
|
|
|
| 456 |
|
|
### END test/gen ###
|
| 457 |
|
|
|
| 458 |
|
|
|
| 459 |
|
|
### test/cal ###
|
| 460 |
|
|
|
| 461 |
|
|
def test_cnt
|
| 462 |
|
|
gen_cnt_txt if !File.exist?('../test/cal/cnt.txt')
|
| 463 |
|
|
Dir.chdir('../test/cal') do
|
| 464 |
|
|
cmd = 'radcompare ref/cnt.txt cnt.txt'
|
| 465 |
|
|
puts("command: #{cmd}")
|
| 466 |
|
|
system(cmd)
|
| 467 |
|
|
|
| 468 |
|
|
rcpf
|
| 469 |
|
|
end
|
| 470 |
|
|
end
|
| 471 |
|
|
|
| 472 |
|
|
def gen_cnt_txt
|
| 473 |
|
|
Dir.chdir('../test/cal') do
|
| 474 |
|
|
cmd = 'cnt 5 3 2 > cnt.txt'
|
| 475 |
|
|
puts("command: #{cmd}")
|
| 476 |
|
|
system(cmd)
|
| 477 |
|
|
end
|
| 478 |
|
|
end
|
| 479 |
|
|
|
| 480 |
|
|
def gen_rcalc_txt
|
| 481 |
|
|
Dir.chdir('../test/cal') do
|
| 482 |
|
|
cmd = "rcalc -o 'Test $${v1} $$(s1) $${v2}' -e 'v1=$$1*$$2;v2=($$2-$$1)*exp($$3)' -s s1=HEY cnt.txt > rcalc.txt"
|
| 483 |
|
|
puts("command: #{cmd}")
|
| 484 |
|
|
system(cmd)
|
| 485 |
|
|
end
|
| 486 |
|
|
end
|
| 487 |
|
|
|
| 488 |
|
|
def test_rcalc
|
| 489 |
|
|
gen_rcalc_txt if !File.exist?('../test/cal/rcalc.txt')
|
| 490 |
|
|
Dir.chdir('../test/cal') do
|
| 491 |
|
|
cmd = 'radcompare ref/rcalc.txt rcalc.txt'
|
| 492 |
|
|
puts("command: #{cmd}")
|
| 493 |
|
|
system(cmd)
|
| 494 |
|
|
|
| 495 |
|
|
rcpf
|
| 496 |
|
|
end
|
| 497 |
|
|
end
|
| 498 |
|
|
|
| 499 |
|
|
def gen_total_txt
|
| 500 |
|
|
gen_cnt_txt if !File.exist?('../test/cal/cnt.txt')
|
| 501 |
|
|
Dir.chdir('../test/cal') do
|
| 502 |
|
|
build = [
|
| 503 |
|
|
'total cnt.txt > total.txt',
|
| 504 |
|
|
'total -l cnt.txt >> total.txt',
|
| 505 |
|
|
'total -u cnt.txt >> total.txt',
|
| 506 |
|
|
'total -m cnt.txt >> total.txt',
|
| 507 |
|
|
'total -s2.5 cnt.txt >> total.txt',
|
| 508 |
|
|
'total -3 -r cnt.txt >> total.txt'
|
| 509 |
|
|
]
|
| 510 |
|
|
build.each do |cmd|
|
| 511 |
|
|
system(cmd)
|
| 512 |
|
|
end
|
| 513 |
|
|
end
|
| 514 |
|
|
end
|
| 515 |
|
|
|
| 516 |
|
|
def test_total
|
| 517 |
|
|
gen_total_txt if !File.exist?('../test/cal/total.txt')
|
| 518 |
|
|
Dir.chdir('../test/cal') do
|
| 519 |
|
|
cmd = 'radcompare ref/total.txt total.txt'
|
| 520 |
|
|
puts("command: #{cmd}")
|
| 521 |
|
|
system(cmd)
|
| 522 |
|
|
|
| 523 |
|
|
rcpf
|
| 524 |
|
|
end
|
| 525 |
|
|
end
|
| 526 |
|
|
|
| 527 |
|
|
def gen_histo_txt
|
| 528 |
|
|
gen_total_txt if !File.exist?('../test/cal/total.txt')
|
| 529 |
|
|
Dir.chdir('../test/cal') do
|
| 530 |
|
|
cmd = 'histo 0 60 5 < total.txt > histo.txt'
|
| 531 |
|
|
puts("command: #{cmd}")
|
| 532 |
|
|
system(cmd)
|
| 533 |
|
|
|
| 534 |
|
|
end
|
| 535 |
|
|
end
|
| 536 |
|
|
|
| 537 |
|
|
def test_histo
|
| 538 |
|
|
gen_histo_txt if !File.exist?('../test/cal/histo.txt')
|
| 539 |
|
|
Dir.chdir('../test/cal') do
|
| 540 |
|
|
cmd = 'radcompare ref/histo.txt histo.txt'
|
| 541 |
|
|
puts("command: #{cmd}")
|
| 542 |
|
|
system(cmd)
|
| 543 |
|
|
|
| 544 |
|
|
rcpf
|
| 545 |
|
|
end
|
| 546 |
|
|
end
|
| 547 |
|
|
|
| 548 |
|
|
def gen_rlam_txt
|
| 549 |
|
|
gen_total_txt if !File.exist?('../test/cal/total.txt')
|
| 550 |
|
|
gen_cnt_txt if !File.exist?('../test/cal/cnt.txt')
|
| 551 |
|
|
gen_histo_txt if !File.exist?('../test/cal/histo.txt')
|
| 552 |
|
|
|
| 553 |
|
|
Dir.chdir('../test/cal') do
|
| 554 |
|
|
cmd = 'rlam -in 5 total.txt cnt.txt histo.txt > rlam.txt'
|
| 555 |
|
|
puts("command: #{cmd}")
|
| 556 |
|
|
system(cmd)
|
| 557 |
|
|
|
| 558 |
|
|
end
|
| 559 |
|
|
end
|
| 560 |
|
|
|
| 561 |
|
|
def test_rlam
|
| 562 |
|
|
gen_rlam_txt if !File.exist?('../test/cal/rlam.txt')
|
| 563 |
|
|
Dir.chdir('../test/cal') do
|
| 564 |
|
|
cmd = 'radcompare ref/rlam.txt rlam.txt'
|
| 565 |
|
|
puts("command: #{cmd}")
|
| 566 |
|
|
system(cmd)
|
| 567 |
|
|
|
| 568 |
|
|
rcpf
|
| 569 |
|
|
end
|
| 570 |
|
|
end
|
| 571 |
|
|
|
| 572 |
|
|
|
| 573 |
|
|
### END test/cal ###
|
| 574 |
|
|
|
| 575 |
|
|
### END test methods ###
|
| 576 |
|
|
|
| 577 |
|
|
# call the test already
|
| 578 |
|
|
|
| 579 |
|
|
if test_in == "all"
|
| 580 |
|
|
all_tests.each do |test_in|
|
| 581 |
|
|
test_total += 1
|
| 582 |
|
|
puts "running test: #{test_in}"
|
| 583 |
|
|
method(test_in).call
|
| 584 |
|
|
puts ''
|
| 585 |
|
|
end
|
| 586 |
|
|
else
|
| 587 |
|
|
test_total += 1
|
| 588 |
|
|
puts "running test: #{test_in}"
|
| 589 |
|
|
method(test_in).call
|
| 590 |
|
|
puts ''
|
| 591 |
|
|
end
|
| 592 |
|
|
|
| 593 |
|
|
puts "### Total tests: #{test_total} (Passed: #{@test_pass} Failed: #{@test_fail}) ###"
|
| 594 |
|
|
|
| 595 |
|
|
# do some cleanup
|
| 596 |
|
|
# rm...
|
| 597 |
|
|
# or not |