1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate# quickie tests to see if h2ph actually runs and does more or less what is 4*0Sstevel@tonic-gate# expected 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gateBEGIN { 7*0Sstevel@tonic-gate chdir 't' if -d 't'; 8*0Sstevel@tonic-gate @INC = '../lib'; 9*0Sstevel@tonic-gate} 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gatemy $extracted_program = '../utils/h2ph'; # unix, nt, ... 12*0Sstevel@tonic-gateif ($^O eq 'VMS') { $extracted_program = '[-.utils]h2ph.com'; } 13*0Sstevel@tonic-gateif (!(-e $extracted_program)) { 14*0Sstevel@tonic-gate print "1..0 # Skip: $extracted_program was not built\n"; 15*0Sstevel@tonic-gate exit 0; 16*0Sstevel@tonic-gate} 17*0Sstevel@tonic-gate 18*0Sstevel@tonic-gateprint "1..2\n"; 19*0Sstevel@tonic-gate 20*0Sstevel@tonic-gate# quickly compare two text files 21*0Sstevel@tonic-gatesub txt_compare { 22*0Sstevel@tonic-gate local ($/, $A, $B); 23*0Sstevel@tonic-gate for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ } 24*0Sstevel@tonic-gate $A cmp $B; 25*0Sstevel@tonic-gate} 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate# does it run? 28*0Sstevel@tonic-gate$ok = system("$^X \"-I../lib\" $extracted_program -d. \"-Q\" lib/h2ph.h"); 29*0Sstevel@tonic-gateprint(($ok == 0 ? "" : "not "), "ok 1\n"); 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate# does it work? well, does it do what we expect? :-) 32*0Sstevel@tonic-gate$ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht"); 33*0Sstevel@tonic-gateprint(($ok == 0 ? "" : "not "), "ok 2\n"); 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate# cleanup - should this be in an END block? 36*0Sstevel@tonic-gateunlink("lib/h2ph.ph"); 37*0Sstevel@tonic-gateunlink("_h2ph_pre.ph"); 38