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