Annotation of embedaddon/lrzsz/testsuite/lib/lrzsz.exp, revision 1.1
1.1 ! misho 1: # change to tmp dir
! 2:
! 3: set z8_test_files ""
! 4: set z_test_files ""
! 5: set y_test_files ""
! 6: set x_test_files ""
! 7: set objdir [absolute $objdir]
! 8: set srcdir [absolute $srcdir]
! 9:
! 10: set srcdir2 [exec sh -c "cd $srcdir/.. && pwd"]
! 11: set objdir2 [exec sh -c "cd $objdir/.. && pwd"]
! 12:
! 13: set SZBUFSIZE "-B 524288"
! 14: set RZBUFSIZE "-B 524288"
! 15: set env(LANG) C
! 16: #puts "LANG=$env(LANG)"
! 17:
! 18: foreach i [glob -nocomplain $srcdir/../src/l?z.c] {
! 19: set z_test_files "$z_test_files $i"
! 20: set x_test_files "$x_test_files $i"
! 21: }
! 22: foreach i [glob -nocomplain $objdir/../src/l?z] {
! 23: set z_test_files "$z_test_files $i"
! 24: set y_test_files "$y_test_files $i"
! 25: }
! 26: foreach i [glob -nocomplain /pub/gnu/emacs-*.tar.gz] {
! 27: set z8_test_files "$z8_test_files $i"
! 28: }
! 29: #puts "objdir=$objdir\n"
! 30: #puts "srcdir=$srcdir\n"
! 31: #puts "x_test_files=$x_test_files\n"
! 32: #puts "y_test_files=$y_test_files\n"
! 33: #puts "z_test_files=$z_test_files\n"
! 34: #puts "z8_test_files=$z8_test_files\n"
! 35:
! 36: # change to tmp dir
! 37: set TMPDIR [getenv TMPDIR]
! 38: #puts "T=$TMPDIR\n"
! 39: if [string compare "x$TMPDIR" "x"] then {
! 40: set MYTEMP "$TMPDIR"
! 41: } else {
! 42: set MYTEMP "/tmp"
! 43: }
! 44: set OLDDIR [pwd]
! 45: set testdir "$MYTEMP/test.lrzsz"
! 46: exec rm -rf $testdir
! 47: exec mkdir $testdir
! 48: exec sh -c "mkfifo $testdir/pipe || mknod $testdir/pipe p"
! 49:
! 50: proc runthem_internal { name sz szopts rz rzopts files flags up} {
! 51: global MYTEMP
! 52: global OLDDIR
! 53: global testdir
! 54: global verbose
! 55: global fail_is_ok
! 56: upvar $up up_p
! 57: if {[string match "*mkdir*" $flags] == 1} {
! 58: exec mkdir $testdir/$name
! 59: }
! 60: set fails 0
! 61: cd $MYTEMP
! 62: catch "exec sh -c \"($sz $szopts $files) <$testdir/pipe | \
! 63: (cd $testdir/$name ; exec $rz $rzopts >>../pipe)\"" dummy
! 64: set up_p $dummy
! 65: foreach i $files {
! 66: set bn [file tail $i]
! 67: set v $verbose
! 68: if {[string match "*compare*" $flags] == 1} {
! 69: set res [catch "exec cmp $i $testdir/$name/$bn" dummy]
! 70: set verbose $v
! 71: if {$res == 0} {
! 72: if {[string match "*delete*" $flags] == 1} {
! 73: catch "file delete $testdir/$name/$bn" dummy
! 74: }
! 75: } else {
! 76: send_log "$i: not identical: cmp told\n"
! 77: send_log "$dummy\n"
! 78: incr fails
! 79: }
! 80: } else {
! 81: if {[string match "*delete*" $flags] == 1} {
! 82: catch "file delete $testdir/$name/$bn" dummy
! 83: }
! 84: }
! 85: }
! 86: if {[string match "*rmdir*" $flags] == 1} {
! 87: set res [catch "exec rmdir $testdir/$name" dummy]
! 88: if {$res != 0} {
! 89: send_log "rmdir failed: $dummy\n"
! 90: incr fails
! 91: }
! 92: }
! 93: if [info exists "fail_is_ok"] {
! 94: if {$fails > 0} {
! 95: set fails 0;
! 96: } else {
! 97: set fails 1;
! 98: }
! 99: }
! 100: cd $OLDDIR
! 101: return $fails
! 102: }
! 103:
! 104: # own test function for xmodem: xmodem can't transfer file names
! 105: proc runxmodem { name sz szopts rz rzopts files } {
! 106: global MYTEMP
! 107: global OLDDIR
! 108: global testdir
! 109: global verbose
! 110: verbose "Testing $name" 1
! 111: exec mkdir $testdir/$name
! 112: set failed 0
! 113: cd $MYTEMP
! 114: foreach i $files {
! 115: set bn [file tail $i]
! 116: set output [catch "set done [exec sh -c "($sz $szopts --xmodem $i 2>/dev/null) \
! 117: <$testdir/pipe | \
! 118: (cd $testdir/$name ; exec $rz $rzopts --xmodem $bn >>../pipe 2>/dev/null)"]]"]
! 119: set res [catch "exec cmp $i $testdir/$name/$bn" dummy]
! 120: if {$res == 0} {
! 121: catch "file delete $testdir/$name/$bn" dummy
! 122: } else {
! 123: send_log "$i: not identical: cmp told\n"
! 124: send_log "$dummy\n"
! 125: set failed 1
! 126: }
! 127: }
! 128: set res [catch "exec rmdir $testdir/$name" dummy]
! 129: if {$res != 0} {
! 130: send_log "rmdir: $dummy\n"
! 131: set failed 1
! 132: }
! 133: cd $OLDDIR
! 134: if {$failed == 0} {
! 135: pass "$name"
! 136: } else {
! 137: fail "$name"
! 138: }
! 139: }
! 140:
! 141: proc runthem { name sz szopts rz rzopts files } {
! 142: verbose "Testing $name" 1
! 143: set fails [runthem_internal "$name" "$sz" "$szopts" "$rz" "$rzopts" \
! 144: "$files" "mkdir,compare,delete,rmdir" dummy]
! 145: if {$fails == 0} {
! 146: pass "$name"
! 147: } else {
! 148: fail "$name"
! 149: }
! 150: }
! 151:
! 152: proc runabuse { name sz szopts rz rzopts files } {
! 153: global fail_is_ok
! 154: global testdir
! 155:
! 156: set fail_is_ok 1
! 157: verbose "Testing $name" 1
! 158: set fails [runthem_internal "$name" "$sz" "$szopts" "$rz" "$rzopts" \
! 159: "$files" "mkdir" output]
! 160: if {$fails == 1 && [string match "*ZRINIT*" $output]} {
! 161: set fails 0
! 162: }
! 163: if {$fails == 1 && [string match "*Broken pipe*" $output]} {
! 164: set fails 0
! 165: }
! 166: if {$fails == 1 && [string match "*caught signal*" $output]} {
! 167: set fails 0
! 168: }
! 169: if {$fails == 1 && [string match "*exited abnormally*" $output]} {
! 170: set fails 0
! 171: }
! 172: if {$fails == 0} {
! 173: exec rm -rf "$testdir/$name"
! 174: pass "$name"
! 175: } else {
! 176: #puts "fails=$fails"
! 177: fail "$name"
! 178: }
! 179: unset fail_is_ok
! 180: }
! 181:
! 182: proc runthem0 { name sz szopts rz rzopts files } {
! 183: verbose "Testing $name (write to /dev/null)" 1
! 184: set fails [runthem_internal "$name" "$sz" "$szopts" "$rz" "$rzopts" \
! 185: "$files" "mkdir,rmdir" dummy]
! 186: if {$fails == 0} {
! 187: pass "$name"
! 188: } else {
! 189: fail "$name"
! 190: }
! 191: }
! 192:
! 193: proc runappend { name sz szopts rz rzopts file} {
! 194: global testdir
! 195: verbose "Testing $name" 1
! 196: set fails [runthem_internal "$name" "$sz" "$szopts" "$rz" "$rzopts" \
! 197: "$file $file" "mkdir" dummy]
! 198: if {$fails == 0} {
! 199: set compare "$testdir/$name/compare"
! 200: set bn [file tail $file]
! 201: exec rm -f $compare
! 202: exec cp $file $compare
! 203: exec cat $file >>$compare
! 204:
! 205: set res [catch "exec cmp $testdir/$name/$bn $compare" dummy]
! 206: if {$res != 0} {
! 207: incr fails
! 208: } else {
! 209: catch "file delete $testdir/$name/$bn" dummy
! 210: catch "file delete $compare" dummy
! 211: }
! 212: }
! 213: if {$fails == 0} {
! 214: set res [catch "exec rmdir $testdir/$name" dummy]
! 215: if {$res != 0} {
! 216: incr fails
! 217: }
! 218: }
! 219:
! 220: if {$fails == 0} {
! 221: pass "$name"
! 222: } else {
! 223: fail "$name"
! 224: }
! 225: }
! 226:
! 227: #
! 228: proc runrename { name sz szopts rz rzopts files} {
! 229: global testdir
! 230: verbose "Testing $name" 1
! 231: exec mkdir $testdir/$name
! 232: foreach i $files {
! 233: set bn [file tail $i]
! 234: exec touch "$testdir/$name/$bn"
! 235: exec echo "1234" ">$testdir/$name/$bn.0"
! 236: }
! 237: set fails [runthem_internal "$name" "$sz" "$szopts" "$rz" "$rzopts" \
! 238: "$files" "" dummy]
! 239: if {$fails == 0} {
! 240: foreach i $files {
! 241: set bn [file tail $i]
! 242: set f "$testdir/$name/$bn"
! 243: if {[file size $f] != 0} {
! 244: incr fails
! 245: send_log "$f: size !=0\n"
! 246: } else {
! 247: set s [file size $f.0]
! 248: if {$s == 0 || $s>5} {
! 249: incr fails
! 250: send_log "$f: size !=5\n"
! 251: } else {
! 252: set compare "$f.1"
! 253: set res [catch "exec cmp $i $compare" dummy]
! 254: if {$res != 0} {
! 255: incr fails
! 256: send_log "$f: compare failed\n"
! 257: } else {
! 258: catch "file delete $f" dummy
! 259: catch "file delete $f.0" dummy
! 260: catch "file delete $f.1" dummy
! 261: }
! 262: }
! 263: }
! 264: }
! 265: }
! 266: if {$fails == 0} {
! 267: set res [catch "exec rmdir $testdir/$name" dummy]
! 268: if {$res != 0} {
! 269: incr fails
! 270: }
! 271: }
! 272:
! 273: if {$fails == 0} {
! 274: pass "$name"
! 275: } else {
! 276: fail "$name"
! 277: }
! 278: }
! 279:
! 280: proc runresume { name sz szopts rz rzopts files} {
! 281: global testdir
! 282: global srcdir
! 283: verbose "Testing $name" 1
! 284: exec mkdir $testdir/$name
! 285: set trash $srcdir/../src/Makefile.in
! 286: foreach i $files {
! 287: set bn [file tail $i]
! 288: catch "exec dd if=$trash of=$testdir/$name/$bn bs=256 count=5" dummy
! 289: }
! 290:
! 291: set fails [runthem_internal "$name" "$sz" "$szopts" "$rz" "$rzopts" \
! 292: "$files" "" dummy]
! 293: if {$fails == 0} {
! 294: foreach i $files {
! 295: set bn [file tail $i]
! 296: set f "$testdir/$name/$bn"
! 297: set res [catch "exec cmp $i $f" dummy]
! 298: if {$res == 0} {
! 299: send_log "receiver did not resume but file is OK\n"
! 300: puts "receiver did not resume but file is OK - error, but not critical"
! 301: incr fails
! 302: } else {
! 303: catch "exec dd if=$i of=$f.1 bs=256 count=5" dummy
! 304: catch "exec dd if=$f bs=256 skip=5 >>$f.1" dummy
! 305: set res [catch "exec cmp $i $f.1" dummy]
! 306: if {$res == 0} {
! 307: catch "file delete $f" dummy
! 308: catch "file delete $f.1" dummy
! 309: } else {
! 310: send_log "sender resumed, but files differ. This is really bad\n"
! 311: puts "sender resumed, but files differ. This is really bad"
! 312: incr fails
! 313: }
! 314: }
! 315: }
! 316: }
! 317: if {$fails == 0} {
! 318: set res [catch "exec rmdir $testdir/$name" dummy]
! 319: if {$res != 0} {
! 320: incr fails
! 321: }
! 322: }
! 323:
! 324: if {$fails == 0} {
! 325: pass "$name"
! 326: } else {
! 327: fail "$name"
! 328: }
! 329: }
! 330:
! 331: # --protect option
! 332: proc runprotect { name sz szopts rz rzopts files} {
! 333: global testdir
! 334: verbose "Testing $name" 1
! 335: exec mkdir $testdir/$name
! 336: foreach i $files {
! 337: set bn [file tail $i]
! 338: exec touch "$testdir/$name/$bn"
! 339: }
! 340: set fails [runthem_internal "$name" "$sz" "$szopts" "$rz" "$rzopts" \
! 341: "$files" "" dummy]
! 342: foreach i $files {
! 343: set bn [file tail $i]
! 344: set f "$testdir/$name/$bn"
! 345: if {[file size $f] != 0} {
! 346: incr fails
! 347: send_log "$f: size !=0 - overwritten, nit protected\n"
! 348: } else {
! 349: catch "file delete $f" dummy
! 350: }
! 351: }
! 352: if {$fails == 0} {
! 353: set res [catch "exec rmdir $testdir/$name" dummy]
! 354: if {$res != 0} {
! 355: incr fails
! 356: }
! 357: }
! 358:
! 359: if {$fails == 0} {
! 360: pass "$name"
! 361: } else {
! 362: fail "$name"
! 363: }
! 364: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>