From 9eb4c31eb78c28dd9f72d1cbb940270311be343c Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Thu, 30 Aug 2012 14:13:12 +0200 Subject: tests: add .sh and .pl suffixes to shell and perl tests, respectively Not only this shrinks the size of the generated Makefile (from > 6300 lines to ~3000), but will allow further simplifications in future changes. * tests/Makefile.am (TEST_EXTENSIONS): Add '.sh' and '.pl'. (PL_LOG_COMPILER, SH_LOG_COMPILER): New, still defined simply to $(LOG_COMPILER) for the time being. (TESTS, root_tests): Adjust as described. * All tests: Rename as described. --- tests/Makefile.am | 989 ++++++++++++++------------- tests/chgrp/basic | 110 --- tests/chgrp/basic.sh | 110 +++ tests/chgrp/default-no-deref | 33 - tests/chgrp/default-no-deref.sh | 33 + tests/chgrp/deref | 60 -- tests/chgrp/deref.sh | 60 ++ tests/chgrp/no-x | 54 -- tests/chgrp/no-x.sh | 54 ++ tests/chgrp/posix-H | 70 -- tests/chgrp/posix-H.sh | 70 ++ tests/chgrp/recurse | 53 -- tests/chgrp/recurse.sh | 53 ++ tests/chmod/c-option | 40 -- tests/chmod/c-option.sh | 40 ++ tests/chmod/equal-x | 34 - tests/chmod/equal-x.sh | 34 + tests/chmod/equals | 46 -- tests/chmod/equals.sh | 46 ++ tests/chmod/inaccessible | 28 - tests/chmod/inaccessible.sh | 28 + tests/chmod/no-x | 57 -- tests/chmod/no-x.sh | 57 ++ tests/chmod/octal | 29 - tests/chmod/octal.sh | 29 + tests/chmod/setgid | 64 -- tests/chmod/setgid.sh | 64 ++ tests/chmod/silent | 29 - tests/chmod/silent.sh | 29 + tests/chmod/thru-dangling | 31 - tests/chmod/thru-dangling.sh | 31 + tests/chmod/umask-x | 26 - tests/chmod/umask-x.sh | 26 + tests/chmod/usage | 86 --- tests/chmod/usage.sh | 86 +++ tests/chown/basic | 59 -- tests/chown/basic.sh | 59 ++ tests/chown/deref | 38 - tests/chown/deref.sh | 38 + tests/chown/preserve-root | 66 -- tests/chown/preserve-root.sh | 66 ++ tests/chown/separator | 63 -- tests/chown/separator.sh | 63 ++ tests/cp/abuse | 50 -- tests/cp/abuse.sh | 50 ++ tests/cp/acl | 60 -- tests/cp/acl.sh | 60 ++ tests/cp/attr-existing | 29 - tests/cp/attr-existing.sh | 29 + tests/cp/backup-1 | 37 - tests/cp/backup-1.sh | 37 + tests/cp/backup-dir | 32 - tests/cp/backup-dir.sh | 32 + tests/cp/backup-is-src | 36 - tests/cp/backup-is-src.sh | 36 + tests/cp/capability | 52 -- tests/cp/capability.sh | 52 ++ tests/cp/cp-HL | 40 -- tests/cp/cp-HL.sh | 40 ++ tests/cp/cp-a-selinux | 114 --- tests/cp/cp-a-selinux.sh | 114 +++ tests/cp/cp-deref | 34 - tests/cp/cp-deref.sh | 34 + tests/cp/cp-i | 65 -- tests/cp/cp-i.sh | 65 ++ tests/cp/cp-mv-backup | 92 --- tests/cp/cp-mv-backup.sh | 92 +++ tests/cp/cp-mv-enotsup-xattr | 109 --- tests/cp/cp-mv-enotsup-xattr.sh | 109 +++ tests/cp/cp-parents | 58 -- tests/cp/cp-parents.sh | 58 ++ tests/cp/deref-slink | 28 - tests/cp/deref-slink.sh | 28 + tests/cp/dir-rm-dest | 30 - tests/cp/dir-rm-dest.sh | 30 + tests/cp/dir-slash | 35 - tests/cp/dir-slash.sh | 35 + tests/cp/dir-vs-file | 33 - tests/cp/dir-vs-file.sh | 33 + tests/cp/existing-perm-dir | 31 - tests/cp/existing-perm-dir.sh | 31 + tests/cp/existing-perm-race | 90 --- tests/cp/existing-perm-race.sh | 90 +++ tests/cp/fail-perm | 58 -- tests/cp/fail-perm.sh | 58 ++ tests/cp/fiemap-2 | 55 -- tests/cp/fiemap-2.sh | 55 ++ tests/cp/fiemap-empty | 101 --- tests/cp/fiemap-empty.sh | 101 +++ tests/cp/fiemap-perf | 49 -- tests/cp/fiemap-perf.sh | 49 ++ tests/cp/file-perm-race | 56 -- tests/cp/file-perm-race.sh | 56 ++ tests/cp/into-self | 57 -- tests/cp/into-self.sh | 57 ++ tests/cp/link | 31 - tests/cp/link-heap | 36 - tests/cp/link-heap.sh | 36 + tests/cp/link-no-deref | 29 - tests/cp/link-no-deref.sh | 29 + tests/cp/link-preserve | 91 --- tests/cp/link-preserve.sh | 91 +++ tests/cp/link-symlink | 41 -- tests/cp/link-symlink.sh | 41 ++ tests/cp/link.sh | 31 + tests/cp/nfs-removal-race | 70 -- tests/cp/nfs-removal-race.sh | 70 ++ tests/cp/no-deref-link1 | 39 -- tests/cp/no-deref-link1.sh | 39 ++ tests/cp/no-deref-link2 | 39 -- tests/cp/no-deref-link2.sh | 39 ++ tests/cp/no-deref-link3 | 36 - tests/cp/no-deref-link3.sh | 36 + tests/cp/parent-perm | 53 -- tests/cp/parent-perm-race | 64 -- tests/cp/parent-perm-race.sh | 64 ++ tests/cp/parent-perm.sh | 53 ++ tests/cp/perm | 77 --- tests/cp/perm.sh | 77 +++ tests/cp/preserve-2 | 29 - tests/cp/preserve-2.sh | 29 + tests/cp/preserve-gid | 136 ---- tests/cp/preserve-gid.sh | 136 ++++ tests/cp/preserve-link | 92 --- tests/cp/preserve-link.sh | 92 +++ tests/cp/preserve-slink-time | 41 -- tests/cp/preserve-slink-time.sh | 41 ++ tests/cp/proc-short-read | 40 -- tests/cp/proc-short-read.sh | 40 ++ tests/cp/proc-zero-len | 40 -- tests/cp/proc-zero-len.sh | 40 ++ tests/cp/r-vs-symlink | 41 -- tests/cp/r-vs-symlink.sh | 41 ++ tests/cp/reflink-auto | 41 -- tests/cp/reflink-auto.sh | 41 ++ tests/cp/reflink-perm | 45 -- tests/cp/reflink-perm.sh | 45 ++ tests/cp/same-file | 220 ------ tests/cp/same-file.sh | 220 ++++++ tests/cp/slink-2-slink | 32 - tests/cp/slink-2-slink.sh | 32 + tests/cp/sparse | 40 -- tests/cp/sparse-fiemap | 116 ---- tests/cp/sparse-fiemap.sh | 116 ++++ tests/cp/sparse-to-pipe | 35 - tests/cp/sparse-to-pipe.sh | 35 + tests/cp/sparse.sh | 40 ++ tests/cp/special-bits | 50 -- tests/cp/special-bits.sh | 50 ++ tests/cp/special-f | 35 - tests/cp/special-f.sh | 35 + tests/cp/src-base-dot | 32 - tests/cp/src-base-dot.sh | 32 + tests/cp/symlink-slash | 36 - tests/cp/symlink-slash.sh | 36 + tests/cp/thru-dangling | 41 -- tests/cp/thru-dangling.sh | 41 ++ tests/dd/bytes | 56 -- tests/dd/bytes.sh | 56 ++ tests/dd/direct | 35 - tests/dd/direct.sh | 35 + tests/dd/misc | 98 --- tests/dd/misc.sh | 98 +++ tests/dd/nocache | 58 -- tests/dd/nocache.sh | 58 ++ tests/dd/not-rewound | 31 - tests/dd/not-rewound.sh | 31 + tests/dd/reblock | 72 -- tests/dd/reblock.sh | 72 ++ tests/dd/skip-seek | 78 --- tests/dd/skip-seek-past-dev | 58 -- tests/dd/skip-seek-past-dev.sh | 58 ++ tests/dd/skip-seek-past-file | 89 --- tests/dd/skip-seek-past-file.sh | 89 +++ tests/dd/skip-seek.pl | 78 +++ tests/dd/skip-seek2 | 38 - tests/dd/skip-seek2.sh | 38 + tests/dd/sparse | 70 -- tests/dd/sparse.sh | 70 ++ tests/dd/stderr | 43 -- tests/dd/stderr.sh | 43 ++ tests/dd/unblock | 59 -- tests/dd/unblock-sync | 35 - tests/dd/unblock-sync.sh | 35 + tests/dd/unblock.pl | 59 ++ tests/df/df-P | 37 - tests/df/df-P.sh | 37 + tests/df/header | 28 - tests/df/header.sh | 28 + tests/df/no-mtab-status | 80 --- tests/df/no-mtab-status.sh | 80 +++ tests/df/problematic-chars | 44 -- tests/df/problematic-chars.sh | 44 ++ tests/df/total-unprocessed | 42 -- tests/df/total-unprocessed.sh | 42 ++ tests/df/total-verify | 64 -- tests/df/total-verify.sh | 64 ++ tests/df/unreadable | 27 - tests/df/unreadable.sh | 27 + tests/du/2g | 69 -- tests/du/2g.sh | 69 ++ tests/du/8gb | 53 -- tests/du/8gb.sh | 53 ++ tests/du/basic | 89 --- tests/du/basic.sh | 89 +++ tests/du/bigtime | 51 -- tests/du/bigtime.sh | 51 ++ tests/du/bind-mount-dir-cycle | 44 -- tests/du/bind-mount-dir-cycle.sh | 44 ++ tests/du/deref | 48 -- tests/du/deref-args | 48 -- tests/du/deref-args.sh | 48 ++ tests/du/deref.sh | 48 ++ tests/du/exclude | 58 -- tests/du/exclude.sh | 58 ++ tests/du/fd-leak | 43 -- tests/du/fd-leak.sh | 43 ++ tests/du/files0-from | 94 --- tests/du/files0-from-dir | 39 -- tests/du/files0-from-dir.sh | 39 ++ tests/du/files0-from.pl | 94 +++ tests/du/hard-link | 64 -- tests/du/hard-link.sh | 64 ++ tests/du/inacc-dest | 56 -- tests/du/inacc-dest.sh | 56 ++ tests/du/inacc-dir | 42 -- tests/du/inacc-dir.sh | 42 ++ tests/du/inaccessible-cwd | 40 -- tests/du/inaccessible-cwd.sh | 40 ++ tests/du/long-from-unreadable | 68 -- tests/du/long-from-unreadable.sh | 68 ++ tests/du/long-sloop | 72 -- tests/du/long-sloop.sh | 72 ++ tests/du/max-depth | 38 - tests/du/max-depth.sh | 38 + tests/du/move-dir-while-traversing | 96 --- tests/du/move-dir-while-traversing.sh | 96 +++ tests/du/no-deref | 33 - tests/du/no-deref.sh | 33 + tests/du/no-x | 49 -- tests/du/no-x.sh | 49 ++ tests/du/one-file-system | 57 -- tests/du/one-file-system.sh | 57 ++ tests/du/restore-wd | 31 - tests/du/restore-wd.sh | 31 + tests/du/slash | 33 - tests/du/slash.sh | 33 + tests/du/slink | 46 -- tests/du/slink.sh | 46 ++ tests/du/trailing-slash | 47 -- tests/du/trailing-slash.sh | 47 ++ tests/du/two-args | 40 -- tests/du/two-args.sh | 40 ++ tests/fmt/base | 64 -- tests/fmt/base.pl | 64 ++ tests/fmt/goal-option | 56 -- tests/fmt/goal-option.sh | 56 ++ tests/fmt/long-line | 61 -- tests/fmt/long-line.sh | 61 ++ tests/id/gnu-zero-uids | 29 - tests/id/gnu-zero-uids.sh | 29 + tests/id/no-context | 35 - tests/id/no-context.sh | 35 + tests/install/basic-1 | 115 ---- tests/install/basic-1.sh | 115 ++++ tests/install/create-leading | 35 - tests/install/create-leading.sh | 35 + tests/install/d-slashdot | 29 - tests/install/d-slashdot.sh | 29 + tests/install/install-C | 90 --- tests/install/install-C-root | 76 -- tests/install/install-C-root.sh | 76 ++ tests/install/install-C-selinux | 51 -- tests/install/install-C-selinux.sh | 51 ++ tests/install/install-C.sh | 90 +++ tests/install/strip-program | 36 - tests/install/strip-program.sh | 36 + tests/install/trap | 33 - tests/install/trap.sh | 33 + tests/ln/backup-1 | 30 - tests/ln/backup-1.sh | 30 + tests/ln/hard-backup | 32 - tests/ln/hard-backup.sh | 32 + tests/ln/hard-to-sym | 77 --- tests/ln/hard-to-sym.sh | 77 +++ tests/ln/misc | 124 ---- tests/ln/misc.sh | 124 ++++ tests/ln/relative | 32 - tests/ln/relative.sh | 32 + tests/ln/sf-1 | 31 - tests/ln/sf-1.sh | 31 + tests/ln/slash-decorated-nonexistent-dest | 29 - tests/ln/slash-decorated-nonexistent-dest.sh | 29 + tests/ln/target-1 | 30 - tests/ln/target-1.sh | 30 + tests/ls/abmon-align | 49 -- tests/ls/abmon-align.sh | 49 ++ tests/ls/block-size | 173 ----- tests/ls/block-size.sh | 173 +++++ tests/ls/capability | 63 -- tests/ls/capability.sh | 63 ++ tests/ls/color-clear-to-eol | 41 -- tests/ls/color-clear-to-eol.sh | 41 ++ tests/ls/color-dtype-dir | 64 -- tests/ls/color-dtype-dir.sh | 64 ++ tests/ls/color-norm | 84 --- tests/ls/color-norm.sh | 84 +++ tests/ls/dangle | 62 -- tests/ls/dangle.sh | 62 ++ tests/ls/dired | 35 - tests/ls/dired.sh | 35 + tests/ls/file-type | 65 -- tests/ls/file-type.sh | 65 ++ tests/ls/follow-slink | 61 -- tests/ls/follow-slink.sh | 61 ++ tests/ls/getxattr-speedup | 65 -- tests/ls/getxattr-speedup.sh | 65 ++ tests/ls/infloop | 42 -- tests/ls/infloop.sh | 42 ++ tests/ls/inode | 65 -- tests/ls/inode.sh | 65 ++ tests/ls/m-option | 40 -- tests/ls/m-option.sh | 40 ++ tests/ls/multihardlink | 80 --- tests/ls/multihardlink.sh | 80 +++ tests/ls/nameless-uid | 40 -- tests/ls/nameless-uid.sh | 40 ++ tests/ls/no-arg | 56 -- tests/ls/no-arg.sh | 56 ++ tests/ls/no-cap | 32 - tests/ls/no-cap.sh | 32 + tests/ls/proc-selinux-segfault | 27 - tests/ls/proc-selinux-segfault.sh | 27 + tests/ls/readdir-mountpoint-inode | 70 -- tests/ls/readdir-mountpoint-inode.sh | 70 ++ tests/ls/recursive | 62 -- tests/ls/recursive.sh | 62 ++ tests/ls/root-rel-symlink-color | 51 -- tests/ls/root-rel-symlink-color.sh | 51 ++ tests/ls/rt-1 | 46 -- tests/ls/rt-1.sh | 46 ++ tests/ls/slink-acl | 33 - tests/ls/slink-acl.sh | 33 + tests/ls/stat-dtype | 61 -- tests/ls/stat-dtype.sh | 61 ++ tests/ls/stat-failed | 52 -- tests/ls/stat-failed.sh | 52 ++ tests/ls/stat-free-color | 70 -- tests/ls/stat-free-color.sh | 70 ++ tests/ls/stat-free-symlinks | 52 -- tests/ls/stat-free-symlinks.sh | 52 ++ tests/ls/stat-vs-dirent | 60 -- tests/ls/stat-vs-dirent.sh | 60 ++ tests/ls/symlink-slash | 30 - tests/ls/symlink-slash.sh | 30 + tests/ls/time-style-diag | 39 -- tests/ls/time-style-diag.sh | 39 ++ tests/ls/x-option | 37 - tests/ls/x-option.sh | 37 + tests/misc/arch | 29 - tests/misc/arch.sh | 29 + tests/misc/base64 | 154 ----- tests/misc/base64.pl | 154 +++++ tests/misc/basename | 83 --- tests/misc/basename.pl | 83 +++ tests/misc/cat-buf | 44 -- tests/misc/cat-buf.sh | 44 ++ tests/misc/cat-proc | 38 - tests/misc/cat-proc.sh | 38 + tests/misc/chcon | 77 --- tests/misc/chcon-fail | 37 - tests/misc/chcon-fail.sh | 37 + tests/misc/chcon.sh | 77 +++ tests/misc/chroot-credentials | 52 -- tests/misc/chroot-credentials.sh | 52 ++ tests/misc/chroot-fail | 43 -- tests/misc/chroot-fail.sh | 43 ++ tests/misc/close-stdout | 65 -- tests/misc/close-stdout.sh | 65 ++ tests/misc/comm | 152 ---- tests/misc/comm.pl | 152 ++++ tests/misc/csplit | 103 --- tests/misc/csplit-1000 | 29 - tests/misc/csplit-1000.sh | 29 + tests/misc/csplit-heap | 29 - tests/misc/csplit-heap.sh | 29 + tests/misc/csplit.sh | 103 +++ tests/misc/cut | 198 ------ tests/misc/cut.pl | 198 ++++++ tests/misc/date | 323 --------- tests/misc/date-next-dow | 78 --- tests/misc/date-next-dow.pl | 78 +++ tests/misc/date-sec | 49 -- tests/misc/date-sec.sh | 49 ++ tests/misc/date.pl | 323 +++++++++ tests/misc/dircolors | 46 -- tests/misc/dircolors.pl | 46 ++ tests/misc/dirname | 72 -- tests/misc/dirname.pl | 72 ++ tests/misc/env | 152 ---- tests/misc/env-null | 61 -- tests/misc/env-null.sh | 61 ++ tests/misc/env.sh | 152 ++++ tests/misc/expand | 39 -- tests/misc/expand.pl | 39 ++ tests/misc/expr | 198 ------ tests/misc/expr.pl | 198 ++++++ tests/misc/factor | 99 --- tests/misc/factor.pl | 99 +++ tests/misc/false-status | 25 - tests/misc/false-status.sh | 25 + tests/misc/fold | 39 -- tests/misc/fold.pl | 39 ++ tests/misc/groups-dash | 32 - tests/misc/groups-dash.sh | 32 + tests/misc/groups-version | 28 - tests/misc/groups-version.sh | 28 + tests/misc/head | 83 --- tests/misc/head-c | 30 - tests/misc/head-c.sh | 30 + tests/misc/head-elide-tail | 107 --- tests/misc/head-elide-tail.pl | 107 +++ tests/misc/head-pos | 44 -- tests/misc/head-pos.sh | 44 ++ tests/misc/head.pl | 83 +++ tests/misc/help-version | 281 -------- tests/misc/help-version.sh | 281 ++++++++ tests/misc/id-context | 32 - tests/misc/id-context.sh | 32 + tests/misc/id-groups | 23 - tests/misc/id-groups.sh | 23 + tests/misc/id-setgid | 34 - tests/misc/id-setgid.sh | 34 + tests/misc/invalid-opt | 102 --- tests/misc/invalid-opt.pl | 102 +++ tests/misc/join | 315 --------- tests/misc/join.pl | 315 +++++++++ tests/misc/ls-misc | 341 --------- tests/misc/ls-misc.pl | 341 +++++++++ tests/misc/ls-time | 145 ---- tests/misc/ls-time.sh | 145 ++++ tests/misc/md5sum | 143 ---- tests/misc/md5sum-bsd | 88 --- tests/misc/md5sum-bsd.sh | 88 +++ tests/misc/md5sum-newline | 44 -- tests/misc/md5sum-newline.pl | 44 ++ tests/misc/md5sum-parallel | 32 - tests/misc/md5sum-parallel.sh | 32 + tests/misc/md5sum.pl | 143 ++++ tests/misc/mknod | 39 -- tests/misc/mknod.sh | 39 ++ tests/misc/mktemp | 204 ------ tests/misc/mktemp.pl | 204 ++++++ tests/misc/nice | 94 --- tests/misc/nice-fail | 38 - tests/misc/nice-fail.sh | 38 + tests/misc/nice.sh | 94 +++ tests/misc/nl | 43 -- tests/misc/nl.sh | 43 ++ tests/misc/nohup | 121 ---- tests/misc/nohup.sh | 121 ++++ tests/misc/nproc-avail | 27 - tests/misc/nproc-avail.sh | 27 + tests/misc/nproc-positive | 44 -- tests/misc/nproc-positive.sh | 44 ++ tests/misc/od | 67 -- tests/misc/od-N | 32 - tests/misc/od-N.sh | 32 + tests/misc/od-float | 58 -- tests/misc/od-float.sh | 58 ++ tests/misc/od-multiple-t | 42 -- tests/misc/od-multiple-t.sh | 42 ++ tests/misc/od-x8 | 43 -- tests/misc/od-x8.sh | 43 ++ tests/misc/od.pl | 67 ++ tests/misc/paste | 65 -- tests/misc/paste.pl | 65 ++ tests/misc/pathchk1 | 38 - tests/misc/pathchk1.sh | 38 + tests/misc/pr | 43 -- tests/misc/pr.pl | 43 ++ tests/misc/printenv | 81 --- tests/misc/printenv.sh | 81 +++ tests/misc/printf | 127 ---- tests/misc/printf-cov | 101 --- tests/misc/printf-cov.pl | 101 +++ tests/misc/printf-hex | 29 - tests/misc/printf-hex.sh | 29 + tests/misc/printf-surprise | 94 --- tests/misc/printf-surprise.sh | 94 +++ tests/misc/printf.sh | 127 ++++ tests/misc/ptx | 44 -- tests/misc/ptx-overrun | 35 - tests/misc/ptx-overrun.sh | 35 + tests/misc/ptx.pl | 44 ++ tests/misc/pwd-long | 124 ---- tests/misc/pwd-long.sh | 124 ++++ tests/misc/pwd-option | 62 -- tests/misc/pwd-option.sh | 62 ++ tests/misc/readlink-fp-loop | 68 -- tests/misc/readlink-fp-loop.sh | 68 ++ tests/misc/readlink-root | 92 --- tests/misc/readlink-root.sh | 92 +++ tests/misc/realpath | 111 --- tests/misc/realpath.sh | 111 +++ tests/misc/runcon-no-reorder | 42 -- tests/misc/runcon-no-reorder.sh | 42 ++ tests/misc/selinux | 59 -- tests/misc/selinux.sh | 59 ++ tests/misc/seq | 128 ---- tests/misc/seq-long-double | 47 -- tests/misc/seq-long-double.sh | 47 ++ tests/misc/seq.pl | 128 ++++ tests/misc/sha1sum | 90 --- tests/misc/sha1sum-vec | 534 --------------- tests/misc/sha1sum-vec.pl | 534 +++++++++++++++ tests/misc/sha1sum.pl | 90 +++ tests/misc/sha224sum | 49 -- tests/misc/sha224sum.pl | 49 ++ tests/misc/sha256sum | 55 -- tests/misc/sha256sum.pl | 55 ++ tests/misc/sha384sum | 55 -- tests/misc/sha384sum.pl | 55 ++ tests/misc/sha512sum | 55 -- tests/misc/sha512sum.pl | 55 ++ tests/misc/shred-exact | 36 - tests/misc/shred-exact.sh | 36 + tests/misc/shred-passes | 39 -- tests/misc/shred-passes.sh | 39 ++ tests/misc/shred-remove | 36 - tests/misc/shred-remove.sh | 36 + tests/misc/shuf | 60 -- tests/misc/shuf.sh | 60 ++ tests/misc/sort | 432 ------------ tests/misc/sort-NaN-infloop | 28 - tests/misc/sort-NaN-infloop.sh | 28 + tests/misc/sort-benchmark-random | 53 -- tests/misc/sort-benchmark-random.sh | 53 ++ tests/misc/sort-compress | 72 -- tests/misc/sort-compress-hang | 53 -- tests/misc/sort-compress-hang.sh | 53 ++ tests/misc/sort-compress-proc | 83 --- tests/misc/sort-compress-proc.sh | 83 +++ tests/misc/sort-compress.sh | 72 ++ tests/misc/sort-continue | 47 -- tests/misc/sort-continue.sh | 47 ++ tests/misc/sort-debug-keys | 330 --------- tests/misc/sort-debug-keys.sh | 330 +++++++++ tests/misc/sort-debug-warn | 90 --- tests/misc/sort-debug-warn.sh | 90 +++ tests/misc/sort-discrim | 89 --- tests/misc/sort-discrim.sh | 89 +++ tests/misc/sort-exit-early | 37 - tests/misc/sort-exit-early.sh | 37 + tests/misc/sort-files0-from | 96 --- tests/misc/sort-files0-from.pl | 96 +++ tests/misc/sort-float | 94 --- tests/misc/sort-float.sh | 94 +++ tests/misc/sort-merge | 84 --- tests/misc/sort-merge-fdlimit | 73 -- tests/misc/sort-merge-fdlimit.sh | 73 ++ tests/misc/sort-merge.pl | 84 +++ tests/misc/sort-month | 34 - tests/misc/sort-month.sh | 34 + tests/misc/sort-rand | 52 -- tests/misc/sort-rand.sh | 52 ++ tests/misc/sort-spinlock-abuse | 45 -- tests/misc/sort-spinlock-abuse.sh | 45 ++ tests/misc/sort-stale-thread-mem | 52 -- tests/misc/sort-stale-thread-mem.sh | 52 ++ tests/misc/sort-u-FMR | 29 - tests/misc/sort-u-FMR.sh | 29 + tests/misc/sort-unique | 42 -- tests/misc/sort-unique-segv | 48 -- tests/misc/sort-unique-segv.sh | 48 ++ tests/misc/sort-unique.sh | 42 ++ tests/misc/sort-version | 106 --- tests/misc/sort-version.sh | 106 +++ tests/misc/sort.pl | 432 ++++++++++++ tests/misc/stat-birthtime | 51 -- tests/misc/stat-birthtime.sh | 51 ++ tests/misc/stat-fmt | 30 - tests/misc/stat-fmt.sh | 30 + tests/misc/stat-hyphen | 30 - tests/misc/stat-hyphen.sh | 30 + tests/misc/stat-mount | 26 - tests/misc/stat-mount.sh | 26 + tests/misc/stat-nanoseconds | 46 -- tests/misc/stat-nanoseconds.sh | 46 ++ tests/misc/stat-printf | 64 -- tests/misc/stat-printf.pl | 64 ++ tests/misc/stat-slash | 44 -- tests/misc/stat-slash.sh | 44 ++ tests/misc/stdbuf | 121 ---- tests/misc/stdbuf.sh | 121 ++++ tests/misc/stty | 68 -- tests/misc/stty-invalid | 44 -- tests/misc/stty-invalid.sh | 44 ++ tests/misc/stty-pairs | 63 -- tests/misc/stty-pairs.sh | 63 ++ tests/misc/stty-row-col | 87 --- tests/misc/stty-row-col.sh | 87 +++ tests/misc/stty.sh | 68 ++ tests/misc/sum | 61 -- tests/misc/sum-sysv | 50 -- tests/misc/sum-sysv.sh | 50 ++ tests/misc/sum.pl | 61 ++ tests/misc/tac | 84 --- tests/misc/tac-2-nonseekable | 27 - tests/misc/tac-2-nonseekable.sh | 27 + tests/misc/tac-continue | 70 -- tests/misc/tac-continue.sh | 70 ++ tests/misc/tac.pl | 84 +++ tests/misc/tail | 140 ---- tests/misc/tail.pl | 140 ++++ tests/misc/tee | 34 - tests/misc/tee-dash | 24 - tests/misc/tee-dash.sh | 24 + tests/misc/tee.sh | 34 + tests/misc/test | 197 ------ tests/misc/test-diag | 39 -- tests/misc/test-diag.pl | 39 ++ tests/misc/test.pl | 197 ++++++ tests/misc/timeout | 59 -- tests/misc/timeout-group | 97 --- tests/misc/timeout-group.sh | 97 +++ tests/misc/timeout-parameters | 80 --- tests/misc/timeout-parameters.sh | 80 +++ tests/misc/timeout.sh | 59 ++ tests/misc/tr | 174 ----- tests/misc/tr-case-class | 113 --- tests/misc/tr-case-class.sh | 113 +++ tests/misc/tr.pl | 174 +++++ tests/misc/truncate-dangling-symlink | 28 - tests/misc/truncate-dangling-symlink.sh | 28 + tests/misc/truncate-dir-fail | 25 - tests/misc/truncate-dir-fail.sh | 25 + tests/misc/truncate-fail-diag | 43 -- tests/misc/truncate-fail-diag.sh | 43 ++ tests/misc/truncate-fifo | 27 - tests/misc/truncate-fifo.sh | 27 + tests/misc/truncate-no-create-missing | 26 - tests/misc/truncate-no-create-missing.sh | 26 + tests/misc/truncate-overflow | 39 -- tests/misc/truncate-overflow.sh | 39 ++ tests/misc/truncate-owned-by-other | 36 - tests/misc/truncate-owned-by-other.sh | 36 + tests/misc/truncate-parameters | 54 -- tests/misc/truncate-parameters.sh | 54 ++ tests/misc/truncate-relative | 35 - tests/misc/truncate-relative.sh | 35 + tests/misc/tsort | 66 -- tests/misc/tsort.pl | 66 ++ tests/misc/tty-eof | 110 --- tests/misc/tty-eof.pl | 110 +++ tests/misc/unexpand | 99 --- tests/misc/unexpand.pl | 99 +++ tests/misc/uniq | 218 ------ tests/misc/uniq-perf | 25 - tests/misc/uniq-perf.sh | 25 + tests/misc/uniq.pl | 218 ++++++ tests/misc/wc | 50 -- tests/misc/wc-files0 | 43 -- tests/misc/wc-files0-from | 93 --- tests/misc/wc-files0-from.pl | 93 +++ tests/misc/wc-files0.sh | 43 ++ tests/misc/wc-parallel | 32 - tests/misc/wc-parallel.sh | 32 + tests/misc/wc.pl | 50 ++ tests/misc/xattr | 130 ---- tests/misc/xattr.sh | 130 ++++ tests/misc/xstrtol | 49 -- tests/misc/xstrtol.pl | 49 ++ tests/mkdir/p-1 | 25 - tests/mkdir/p-1.sh | 25 + tests/mkdir/p-2 | 25 - tests/mkdir/p-2.sh | 25 + tests/mkdir/p-3 | 51 -- tests/mkdir/p-3.sh | 51 ++ tests/mkdir/p-slashdot | 29 - tests/mkdir/p-slashdot.sh | 29 + tests/mkdir/p-thru-slink | 27 - tests/mkdir/p-thru-slink.sh | 27 + tests/mkdir/p-v | 32 - tests/mkdir/p-v.sh | 32 + tests/mkdir/parents | 51 -- tests/mkdir/parents.sh | 51 ++ tests/mkdir/perm | 83 --- tests/mkdir/perm.sh | 83 +++ tests/mkdir/selinux | 56 -- tests/mkdir/selinux.sh | 56 ++ tests/mkdir/special-1 | 51 -- tests/mkdir/special-1.sh | 51 ++ tests/mkdir/t-slash | 31 - tests/mkdir/t-slash.sh | 31 + tests/mkdir/writable-under-readonly | 52 -- tests/mkdir/writable-under-readonly.sh | 52 ++ tests/mv/acl | 67 -- tests/mv/acl.sh | 67 ++ tests/mv/atomic | 46 -- tests/mv/atomic.sh | 46 ++ tests/mv/atomic2 | 45 -- tests/mv/atomic2.sh | 45 ++ tests/mv/backup-dir | 34 - tests/mv/backup-dir.sh | 34 + tests/mv/backup-is-src | 46 -- tests/mv/backup-is-src.sh | 46 ++ tests/mv/childproof | 83 --- tests/mv/childproof.sh | 83 +++ tests/mv/diag | 48 -- tests/mv/diag.sh | 48 ++ tests/mv/dir-file | 30 - tests/mv/dir-file.sh | 30 + tests/mv/dir2dir | 42 -- tests/mv/dir2dir.sh | 42 ++ tests/mv/dup-source | 65 -- tests/mv/dup-source.sh | 65 ++ tests/mv/force | 42 -- tests/mv/force.sh | 42 ++ tests/mv/hard-2 | 77 --- tests/mv/hard-2.sh | 77 +++ tests/mv/hard-3 | 69 -- tests/mv/hard-3.sh | 69 ++ tests/mv/hard-4 | 38 - tests/mv/hard-4.sh | 38 + tests/mv/hard-link-1 | 41 -- tests/mv/hard-link-1.sh | 41 ++ tests/mv/hard-verbose | 33 - tests/mv/hard-verbose.sh | 33 + tests/mv/i-1 | 44 -- tests/mv/i-1.pl | 44 ++ tests/mv/i-2 | 52 -- tests/mv/i-2.sh | 52 ++ tests/mv/i-3 | 69 -- tests/mv/i-3.sh | 69 ++ tests/mv/i-4 | 49 -- tests/mv/i-4.sh | 49 ++ tests/mv/i-5 | 29 - tests/mv/i-5.sh | 29 + tests/mv/i-link-no | 43 -- tests/mv/i-link-no.sh | 43 ++ tests/mv/into-self | 53 -- tests/mv/into-self-2 | 52 -- tests/mv/into-self-2.sh | 52 ++ tests/mv/into-self-3 | 41 -- tests/mv/into-self-3.sh | 41 ++ tests/mv/into-self-4 | 34 - tests/mv/into-self-4.sh | 34 + tests/mv/into-self.sh | 53 ++ tests/mv/leak-fd | 55 -- tests/mv/leak-fd.sh | 55 ++ tests/mv/mv-n | 57 -- tests/mv/mv-n.sh | 57 ++ tests/mv/mv-special-1 | 72 -- tests/mv/mv-special-1.sh | 72 ++ tests/mv/no-target-dir | 49 -- tests/mv/no-target-dir.sh | 49 ++ tests/mv/part-fail | 55 -- tests/mv/part-fail.sh | 55 ++ tests/mv/part-hardlink | 43 -- tests/mv/part-hardlink.sh | 43 ++ tests/mv/part-rename | 31 - tests/mv/part-rename.sh | 31 + tests/mv/part-symlink | 261 ------- tests/mv/part-symlink.sh | 261 +++++++ tests/mv/partition-perm | 37 - tests/mv/partition-perm.sh | 37 + tests/mv/perm-1 | 35 - tests/mv/perm-1.sh | 35 + tests/mv/sticky-to-xpart | 67 -- tests/mv/sticky-to-xpart.sh | 67 ++ tests/mv/symlink-onto-hardlink | 41 -- tests/mv/symlink-onto-hardlink-to-self | 56 -- tests/mv/symlink-onto-hardlink-to-self.sh | 56 ++ tests/mv/symlink-onto-hardlink.sh | 41 ++ tests/mv/to-symlink | 43 -- tests/mv/to-symlink.sh | 43 ++ tests/mv/trailing-slash | 65 -- tests/mv/trailing-slash.sh | 65 ++ tests/mv/update | 54 -- tests/mv/update.sh | 54 ++ tests/pr/pr-tests | 460 ------------- tests/pr/pr-tests.pl | 460 +++++++++++++ tests/readlink/can-e | 104 --- tests/readlink/can-e.sh | 104 +++ tests/readlink/can-f | 153 ----- tests/readlink/can-f.sh | 153 +++++ tests/readlink/can-m | 141 ---- tests/readlink/can-m.sh | 141 ++++ tests/readlink/rl-1 | 43 -- tests/readlink/rl-1.sh | 43 ++ tests/rm/cycle | 36 - tests/rm/cycle.sh | 36 + tests/rm/d-1 | 38 - tests/rm/d-1.sh | 38 + tests/rm/d-2 | 33 - tests/rm/d-2.sh | 33 + tests/rm/d-3 | 37 - tests/rm/d-3.sh | 37 + tests/rm/dangling-symlink | 45 -- tests/rm/dangling-symlink.sh | 45 ++ tests/rm/deep-1 | 53 -- tests/rm/deep-1.sh | 53 ++ tests/rm/deep-2 | 49 -- tests/rm/deep-2.sh | 49 ++ tests/rm/dir-no-w | 42 -- tests/rm/dir-no-w.sh | 42 ++ tests/rm/dir-nonrecur | 34 - tests/rm/dir-nonrecur.sh | 34 + tests/rm/dot-rel | 29 - tests/rm/dot-rel.sh | 29 + tests/rm/empty-inacc | 38 - tests/rm/empty-inacc.sh | 38 + tests/rm/empty-name | 60 -- tests/rm/empty-name.pl | 60 ++ tests/rm/ext3-perf | 83 --- tests/rm/ext3-perf.sh | 83 +++ tests/rm/f-1 | 26 - tests/rm/f-1.sh | 26 + tests/rm/fail-2eperm | 55 -- tests/rm/fail-2eperm.sh | 55 ++ tests/rm/fail-eacces | 54 -- tests/rm/fail-eacces.sh | 54 ++ tests/rm/hash | 37 - tests/rm/hash.sh | 37 + tests/rm/i-1 | 40 -- tests/rm/i-1.sh | 40 ++ tests/rm/i-never | 33 - tests/rm/i-never.sh | 33 + tests/rm/i-no-r | 34 - tests/rm/i-no-r.sh | 34 + tests/rm/ignorable | 30 - tests/rm/ignorable.sh | 30 + tests/rm/inaccessible | 49 -- tests/rm/inaccessible.sh | 49 ++ tests/rm/interactive-always | 87 --- tests/rm/interactive-always.sh | 87 +++ tests/rm/interactive-once | 107 --- tests/rm/interactive-once.sh | 107 +++ tests/rm/ir-1 | 56 -- tests/rm/ir-1.sh | 56 ++ tests/rm/isatty | 53 -- tests/rm/isatty.sh | 53 ++ tests/rm/many-dir-entries-vs-OOM | 38 - tests/rm/many-dir-entries-vs-OOM.sh | 38 + tests/rm/no-give-up | 41 -- tests/rm/no-give-up.sh | 41 ++ tests/rm/one-file-system | 48 -- tests/rm/one-file-system.sh | 48 ++ tests/rm/one-file-system2 | 27 - tests/rm/one-file-system2.sh | 27 + tests/rm/r-1 | 40 -- tests/rm/r-1.sh | 40 ++ tests/rm/r-2 | 45 -- tests/rm/r-2.sh | 45 ++ tests/rm/r-3 | 48 -- tests/rm/r-3.sh | 48 ++ tests/rm/r-4 | 36 - tests/rm/r-4.sh | 36 + tests/rm/read-only | 52 -- tests/rm/read-only.sh | 52 ++ tests/rm/readdir-bug | 41 -- tests/rm/readdir-bug.sh | 41 ++ tests/rm/rm1 | 48 -- tests/rm/rm1.sh | 48 ++ tests/rm/rm2 | 55 -- tests/rm/rm2.sh | 55 ++ tests/rm/rm3 | 73 -- tests/rm/rm3.sh | 73 ++ tests/rm/rm4 | 31 - tests/rm/rm4.sh | 31 + tests/rm/rm5 | 52 -- tests/rm/rm5.sh | 52 ++ tests/rm/sunos-1 | 29 - tests/rm/sunos-1.sh | 29 + tests/rm/unread2 | 35 - tests/rm/unread2.sh | 35 + tests/rm/unread3 | 43 -- tests/rm/unread3.sh | 43 ++ tests/rm/unreadable | 50 -- tests/rm/unreadable.pl | 50 ++ tests/rm/v-slash | 34 - tests/rm/v-slash.sh | 34 + tests/rmdir/fail-perm | 32 - tests/rmdir/fail-perm.sh | 32 + tests/rmdir/ignore | 32 - tests/rmdir/ignore.sh | 32 + tests/rmdir/t-slash | 29 - tests/rmdir/t-slash.sh | 29 + tests/split/additional-suffix | 44 -- tests/split/additional-suffix.sh | 44 ++ tests/split/b-chunk | 50 -- tests/split/b-chunk.sh | 50 ++ tests/split/fail | 81 --- tests/split/fail.sh | 81 +++ tests/split/filter | 57 -- tests/split/filter.sh | 57 ++ tests/split/guard-input | 33 - tests/split/guard-input.sh | 33 + tests/split/l-chunk | 141 ---- tests/split/l-chunk.sh | 141 ++++ tests/split/lines | 42 -- tests/split/lines.sh | 42 ++ tests/split/numeric | 65 -- tests/split/numeric.sh | 65 ++ tests/split/r-chunk | 66 -- tests/split/r-chunk.sh | 66 ++ tests/split/suffix-auto-length | 42 -- tests/split/suffix-auto-length.sh | 42 ++ tests/split/suffix-length | 76 -- tests/split/suffix-length.sh | 76 ++ tests/tail-2/F-vs-missing | 64 -- tests/tail-2/F-vs-missing.sh | 64 ++ tests/tail-2/F-vs-rename | 75 -- tests/tail-2/F-vs-rename.sh | 75 ++ tests/tail-2/append-only | 43 -- tests/tail-2/append-only.sh | 43 ++ tests/tail-2/assert | 61 -- tests/tail-2/assert-2 | 49 -- tests/tail-2/assert-2.sh | 49 ++ tests/tail-2/assert.sh | 61 ++ tests/tail-2/big-4gb | 50 -- tests/tail-2/big-4gb.sh | 50 ++ tests/tail-2/flush-initial | 40 -- tests/tail-2/flush-initial.sh | 40 ++ tests/tail-2/follow-name | 36 - tests/tail-2/follow-name.sh | 36 + tests/tail-2/follow-stdin | 36 - tests/tail-2/follow-stdin.sh | 36 + tests/tail-2/infloop-1 | 45 -- tests/tail-2/infloop-1.sh | 45 ++ tests/tail-2/inotify-hash-abuse | 63 -- tests/tail-2/inotify-hash-abuse.sh | 63 ++ tests/tail-2/inotify-hash-abuse2 | 39 -- tests/tail-2/inotify-hash-abuse2.sh | 39 ++ tests/tail-2/inotify-race | 69 -- tests/tail-2/inotify-race.sh | 69 ++ tests/tail-2/inotify-rotate | 68 -- tests/tail-2/inotify-rotate.sh | 68 ++ tests/tail-2/pid | 51 -- tests/tail-2/pid.sh | 51 ++ tests/tail-2/pipe-f | 27 - tests/tail-2/pipe-f.sh | 27 + tests/tail-2/pipe-f2 | 43 -- tests/tail-2/pipe-f2.sh | 43 ++ tests/tail-2/proc-ksyms | 28 - tests/tail-2/proc-ksyms.sh | 28 + tests/tail-2/start-middle | 33 - tests/tail-2/start-middle.sh | 33 + tests/tail-2/tail-n0f | 55 -- tests/tail-2/tail-n0f.sh | 55 ++ tests/tail-2/wait | 80 --- tests/tail-2/wait.sh | 80 +++ tests/touch/60-seconds | 33 - tests/touch/60-seconds.sh | 33 + tests/touch/dangling-symlink | 49 -- tests/touch/dangling-symlink.sh | 49 ++ tests/touch/dir-1 | 9 - tests/touch/dir-1.sh | 9 + tests/touch/empty-file | 80 --- tests/touch/empty-file.sh | 80 +++ tests/touch/fail-diag | 32 - tests/touch/fail-diag.sh | 32 + tests/touch/fifo | 27 - tests/touch/fifo.sh | 27 + tests/touch/no-create-missing | 39 -- tests/touch/no-create-missing.sh | 39 ++ tests/touch/no-dereference | 84 --- tests/touch/no-dereference.sh | 84 +++ tests/touch/no-rights | 40 -- tests/touch/no-rights.sh | 40 ++ tests/touch/not-owner | 55 -- tests/touch/not-owner.sh | 55 ++ tests/touch/now-owned-by-other | 35 - tests/touch/now-owned-by-other.sh | 35 + tests/touch/obsolescent | 41 -- tests/touch/obsolescent.sh | 41 ++ tests/touch/read-only | 31 - tests/touch/read-only.sh | 31 + tests/touch/relative | 38 - tests/touch/relative.sh | 38 + tests/touch/trailing-slash | 66 -- tests/touch/trailing-slash.sh | 66 ++ 983 files changed, 31247 insertions(+), 31244 deletions(-) delete mode 100755 tests/chgrp/basic create mode 100755 tests/chgrp/basic.sh delete mode 100755 tests/chgrp/default-no-deref create mode 100755 tests/chgrp/default-no-deref.sh delete mode 100755 tests/chgrp/deref create mode 100755 tests/chgrp/deref.sh delete mode 100755 tests/chgrp/no-x create mode 100755 tests/chgrp/no-x.sh delete mode 100755 tests/chgrp/posix-H create mode 100755 tests/chgrp/posix-H.sh delete mode 100755 tests/chgrp/recurse create mode 100755 tests/chgrp/recurse.sh delete mode 100755 tests/chmod/c-option create mode 100755 tests/chmod/c-option.sh delete mode 100755 tests/chmod/equal-x create mode 100755 tests/chmod/equal-x.sh delete mode 100755 tests/chmod/equals create mode 100755 tests/chmod/equals.sh delete mode 100755 tests/chmod/inaccessible create mode 100755 tests/chmod/inaccessible.sh delete mode 100755 tests/chmod/no-x create mode 100755 tests/chmod/no-x.sh delete mode 100755 tests/chmod/octal create mode 100755 tests/chmod/octal.sh delete mode 100755 tests/chmod/setgid create mode 100755 tests/chmod/setgid.sh delete mode 100755 tests/chmod/silent create mode 100755 tests/chmod/silent.sh delete mode 100755 tests/chmod/thru-dangling create mode 100755 tests/chmod/thru-dangling.sh delete mode 100755 tests/chmod/umask-x create mode 100755 tests/chmod/umask-x.sh delete mode 100755 tests/chmod/usage create mode 100755 tests/chmod/usage.sh delete mode 100755 tests/chown/basic create mode 100755 tests/chown/basic.sh delete mode 100755 tests/chown/deref create mode 100755 tests/chown/deref.sh delete mode 100755 tests/chown/preserve-root create mode 100755 tests/chown/preserve-root.sh delete mode 100755 tests/chown/separator create mode 100755 tests/chown/separator.sh delete mode 100755 tests/cp/abuse create mode 100755 tests/cp/abuse.sh delete mode 100755 tests/cp/acl create mode 100755 tests/cp/acl.sh delete mode 100755 tests/cp/attr-existing create mode 100755 tests/cp/attr-existing.sh delete mode 100755 tests/cp/backup-1 create mode 100755 tests/cp/backup-1.sh delete mode 100755 tests/cp/backup-dir create mode 100755 tests/cp/backup-dir.sh delete mode 100755 tests/cp/backup-is-src create mode 100755 tests/cp/backup-is-src.sh delete mode 100755 tests/cp/capability create mode 100755 tests/cp/capability.sh delete mode 100755 tests/cp/cp-HL create mode 100755 tests/cp/cp-HL.sh delete mode 100755 tests/cp/cp-a-selinux create mode 100755 tests/cp/cp-a-selinux.sh delete mode 100755 tests/cp/cp-deref create mode 100755 tests/cp/cp-deref.sh delete mode 100755 tests/cp/cp-i create mode 100755 tests/cp/cp-i.sh delete mode 100755 tests/cp/cp-mv-backup create mode 100755 tests/cp/cp-mv-backup.sh delete mode 100755 tests/cp/cp-mv-enotsup-xattr create mode 100755 tests/cp/cp-mv-enotsup-xattr.sh delete mode 100755 tests/cp/cp-parents create mode 100755 tests/cp/cp-parents.sh delete mode 100755 tests/cp/deref-slink create mode 100755 tests/cp/deref-slink.sh delete mode 100755 tests/cp/dir-rm-dest create mode 100755 tests/cp/dir-rm-dest.sh delete mode 100755 tests/cp/dir-slash create mode 100755 tests/cp/dir-slash.sh delete mode 100755 tests/cp/dir-vs-file create mode 100755 tests/cp/dir-vs-file.sh delete mode 100755 tests/cp/existing-perm-dir create mode 100755 tests/cp/existing-perm-dir.sh delete mode 100755 tests/cp/existing-perm-race create mode 100755 tests/cp/existing-perm-race.sh delete mode 100755 tests/cp/fail-perm create mode 100755 tests/cp/fail-perm.sh delete mode 100755 tests/cp/fiemap-2 create mode 100755 tests/cp/fiemap-2.sh delete mode 100755 tests/cp/fiemap-empty create mode 100755 tests/cp/fiemap-empty.sh delete mode 100755 tests/cp/fiemap-perf create mode 100755 tests/cp/fiemap-perf.sh delete mode 100755 tests/cp/file-perm-race create mode 100755 tests/cp/file-perm-race.sh delete mode 100755 tests/cp/into-self create mode 100755 tests/cp/into-self.sh delete mode 100755 tests/cp/link delete mode 100755 tests/cp/link-heap create mode 100755 tests/cp/link-heap.sh delete mode 100755 tests/cp/link-no-deref create mode 100755 tests/cp/link-no-deref.sh delete mode 100755 tests/cp/link-preserve create mode 100755 tests/cp/link-preserve.sh delete mode 100755 tests/cp/link-symlink create mode 100755 tests/cp/link-symlink.sh create mode 100755 tests/cp/link.sh delete mode 100755 tests/cp/nfs-removal-race create mode 100755 tests/cp/nfs-removal-race.sh delete mode 100755 tests/cp/no-deref-link1 create mode 100755 tests/cp/no-deref-link1.sh delete mode 100755 tests/cp/no-deref-link2 create mode 100755 tests/cp/no-deref-link2.sh delete mode 100755 tests/cp/no-deref-link3 create mode 100755 tests/cp/no-deref-link3.sh delete mode 100755 tests/cp/parent-perm delete mode 100755 tests/cp/parent-perm-race create mode 100755 tests/cp/parent-perm-race.sh create mode 100755 tests/cp/parent-perm.sh delete mode 100755 tests/cp/perm create mode 100755 tests/cp/perm.sh delete mode 100755 tests/cp/preserve-2 create mode 100755 tests/cp/preserve-2.sh delete mode 100755 tests/cp/preserve-gid create mode 100755 tests/cp/preserve-gid.sh delete mode 100755 tests/cp/preserve-link create mode 100755 tests/cp/preserve-link.sh delete mode 100755 tests/cp/preserve-slink-time create mode 100755 tests/cp/preserve-slink-time.sh delete mode 100755 tests/cp/proc-short-read create mode 100755 tests/cp/proc-short-read.sh delete mode 100755 tests/cp/proc-zero-len create mode 100755 tests/cp/proc-zero-len.sh delete mode 100755 tests/cp/r-vs-symlink create mode 100755 tests/cp/r-vs-symlink.sh delete mode 100755 tests/cp/reflink-auto create mode 100755 tests/cp/reflink-auto.sh delete mode 100755 tests/cp/reflink-perm create mode 100755 tests/cp/reflink-perm.sh delete mode 100755 tests/cp/same-file create mode 100755 tests/cp/same-file.sh delete mode 100755 tests/cp/slink-2-slink create mode 100755 tests/cp/slink-2-slink.sh delete mode 100755 tests/cp/sparse delete mode 100755 tests/cp/sparse-fiemap create mode 100755 tests/cp/sparse-fiemap.sh delete mode 100755 tests/cp/sparse-to-pipe create mode 100755 tests/cp/sparse-to-pipe.sh create mode 100755 tests/cp/sparse.sh delete mode 100755 tests/cp/special-bits create mode 100755 tests/cp/special-bits.sh delete mode 100755 tests/cp/special-f create mode 100755 tests/cp/special-f.sh delete mode 100755 tests/cp/src-base-dot create mode 100755 tests/cp/src-base-dot.sh delete mode 100755 tests/cp/symlink-slash create mode 100755 tests/cp/symlink-slash.sh delete mode 100755 tests/cp/thru-dangling create mode 100755 tests/cp/thru-dangling.sh delete mode 100755 tests/dd/bytes create mode 100755 tests/dd/bytes.sh delete mode 100755 tests/dd/direct create mode 100755 tests/dd/direct.sh delete mode 100755 tests/dd/misc create mode 100755 tests/dd/misc.sh delete mode 100755 tests/dd/nocache create mode 100755 tests/dd/nocache.sh delete mode 100755 tests/dd/not-rewound create mode 100755 tests/dd/not-rewound.sh delete mode 100755 tests/dd/reblock create mode 100755 tests/dd/reblock.sh delete mode 100755 tests/dd/skip-seek delete mode 100755 tests/dd/skip-seek-past-dev create mode 100755 tests/dd/skip-seek-past-dev.sh delete mode 100755 tests/dd/skip-seek-past-file create mode 100755 tests/dd/skip-seek-past-file.sh create mode 100755 tests/dd/skip-seek.pl delete mode 100755 tests/dd/skip-seek2 create mode 100755 tests/dd/skip-seek2.sh delete mode 100755 tests/dd/sparse create mode 100755 tests/dd/sparse.sh delete mode 100755 tests/dd/stderr create mode 100755 tests/dd/stderr.sh delete mode 100755 tests/dd/unblock delete mode 100755 tests/dd/unblock-sync create mode 100755 tests/dd/unblock-sync.sh create mode 100755 tests/dd/unblock.pl delete mode 100755 tests/df/df-P create mode 100755 tests/df/df-P.sh delete mode 100755 tests/df/header create mode 100755 tests/df/header.sh delete mode 100755 tests/df/no-mtab-status create mode 100755 tests/df/no-mtab-status.sh delete mode 100755 tests/df/problematic-chars create mode 100755 tests/df/problematic-chars.sh delete mode 100755 tests/df/total-unprocessed create mode 100755 tests/df/total-unprocessed.sh delete mode 100755 tests/df/total-verify create mode 100755 tests/df/total-verify.sh delete mode 100755 tests/df/unreadable create mode 100755 tests/df/unreadable.sh delete mode 100755 tests/du/2g create mode 100755 tests/du/2g.sh delete mode 100755 tests/du/8gb create mode 100755 tests/du/8gb.sh delete mode 100755 tests/du/basic create mode 100755 tests/du/basic.sh delete mode 100755 tests/du/bigtime create mode 100755 tests/du/bigtime.sh delete mode 100755 tests/du/bind-mount-dir-cycle create mode 100755 tests/du/bind-mount-dir-cycle.sh delete mode 100755 tests/du/deref delete mode 100755 tests/du/deref-args create mode 100755 tests/du/deref-args.sh create mode 100755 tests/du/deref.sh delete mode 100755 tests/du/exclude create mode 100755 tests/du/exclude.sh delete mode 100755 tests/du/fd-leak create mode 100755 tests/du/fd-leak.sh delete mode 100755 tests/du/files0-from delete mode 100755 tests/du/files0-from-dir create mode 100755 tests/du/files0-from-dir.sh create mode 100755 tests/du/files0-from.pl delete mode 100755 tests/du/hard-link create mode 100755 tests/du/hard-link.sh delete mode 100755 tests/du/inacc-dest create mode 100755 tests/du/inacc-dest.sh delete mode 100755 tests/du/inacc-dir create mode 100755 tests/du/inacc-dir.sh delete mode 100755 tests/du/inaccessible-cwd create mode 100755 tests/du/inaccessible-cwd.sh delete mode 100755 tests/du/long-from-unreadable create mode 100755 tests/du/long-from-unreadable.sh delete mode 100755 tests/du/long-sloop create mode 100755 tests/du/long-sloop.sh delete mode 100755 tests/du/max-depth create mode 100755 tests/du/max-depth.sh delete mode 100755 tests/du/move-dir-while-traversing create mode 100755 tests/du/move-dir-while-traversing.sh delete mode 100755 tests/du/no-deref create mode 100755 tests/du/no-deref.sh delete mode 100755 tests/du/no-x create mode 100755 tests/du/no-x.sh delete mode 100755 tests/du/one-file-system create mode 100755 tests/du/one-file-system.sh delete mode 100755 tests/du/restore-wd create mode 100755 tests/du/restore-wd.sh delete mode 100755 tests/du/slash create mode 100755 tests/du/slash.sh delete mode 100755 tests/du/slink create mode 100755 tests/du/slink.sh delete mode 100755 tests/du/trailing-slash create mode 100755 tests/du/trailing-slash.sh delete mode 100755 tests/du/two-args create mode 100755 tests/du/two-args.sh delete mode 100755 tests/fmt/base create mode 100755 tests/fmt/base.pl delete mode 100755 tests/fmt/goal-option create mode 100755 tests/fmt/goal-option.sh delete mode 100755 tests/fmt/long-line create mode 100755 tests/fmt/long-line.sh delete mode 100755 tests/id/gnu-zero-uids create mode 100755 tests/id/gnu-zero-uids.sh delete mode 100755 tests/id/no-context create mode 100755 tests/id/no-context.sh delete mode 100755 tests/install/basic-1 create mode 100755 tests/install/basic-1.sh delete mode 100755 tests/install/create-leading create mode 100755 tests/install/create-leading.sh delete mode 100755 tests/install/d-slashdot create mode 100755 tests/install/d-slashdot.sh delete mode 100755 tests/install/install-C delete mode 100755 tests/install/install-C-root create mode 100755 tests/install/install-C-root.sh delete mode 100755 tests/install/install-C-selinux create mode 100755 tests/install/install-C-selinux.sh create mode 100755 tests/install/install-C.sh delete mode 100755 tests/install/strip-program create mode 100755 tests/install/strip-program.sh delete mode 100755 tests/install/trap create mode 100755 tests/install/trap.sh delete mode 100755 tests/ln/backup-1 create mode 100755 tests/ln/backup-1.sh delete mode 100755 tests/ln/hard-backup create mode 100755 tests/ln/hard-backup.sh delete mode 100755 tests/ln/hard-to-sym create mode 100755 tests/ln/hard-to-sym.sh delete mode 100755 tests/ln/misc create mode 100755 tests/ln/misc.sh delete mode 100755 tests/ln/relative create mode 100755 tests/ln/relative.sh delete mode 100755 tests/ln/sf-1 create mode 100755 tests/ln/sf-1.sh delete mode 100755 tests/ln/slash-decorated-nonexistent-dest create mode 100755 tests/ln/slash-decorated-nonexistent-dest.sh delete mode 100755 tests/ln/target-1 create mode 100755 tests/ln/target-1.sh delete mode 100755 tests/ls/abmon-align create mode 100755 tests/ls/abmon-align.sh delete mode 100755 tests/ls/block-size create mode 100755 tests/ls/block-size.sh delete mode 100755 tests/ls/capability create mode 100755 tests/ls/capability.sh delete mode 100755 tests/ls/color-clear-to-eol create mode 100755 tests/ls/color-clear-to-eol.sh delete mode 100755 tests/ls/color-dtype-dir create mode 100755 tests/ls/color-dtype-dir.sh delete mode 100755 tests/ls/color-norm create mode 100755 tests/ls/color-norm.sh delete mode 100755 tests/ls/dangle create mode 100755 tests/ls/dangle.sh delete mode 100755 tests/ls/dired create mode 100755 tests/ls/dired.sh delete mode 100755 tests/ls/file-type create mode 100755 tests/ls/file-type.sh delete mode 100755 tests/ls/follow-slink create mode 100755 tests/ls/follow-slink.sh delete mode 100755 tests/ls/getxattr-speedup create mode 100755 tests/ls/getxattr-speedup.sh delete mode 100755 tests/ls/infloop create mode 100755 tests/ls/infloop.sh delete mode 100755 tests/ls/inode create mode 100755 tests/ls/inode.sh delete mode 100755 tests/ls/m-option create mode 100755 tests/ls/m-option.sh delete mode 100755 tests/ls/multihardlink create mode 100755 tests/ls/multihardlink.sh delete mode 100755 tests/ls/nameless-uid create mode 100755 tests/ls/nameless-uid.sh delete mode 100755 tests/ls/no-arg create mode 100755 tests/ls/no-arg.sh delete mode 100755 tests/ls/no-cap create mode 100755 tests/ls/no-cap.sh delete mode 100755 tests/ls/proc-selinux-segfault create mode 100755 tests/ls/proc-selinux-segfault.sh delete mode 100755 tests/ls/readdir-mountpoint-inode create mode 100755 tests/ls/readdir-mountpoint-inode.sh delete mode 100755 tests/ls/recursive create mode 100755 tests/ls/recursive.sh delete mode 100755 tests/ls/root-rel-symlink-color create mode 100755 tests/ls/root-rel-symlink-color.sh delete mode 100755 tests/ls/rt-1 create mode 100755 tests/ls/rt-1.sh delete mode 100755 tests/ls/slink-acl create mode 100755 tests/ls/slink-acl.sh delete mode 100755 tests/ls/stat-dtype create mode 100755 tests/ls/stat-dtype.sh delete mode 100755 tests/ls/stat-failed create mode 100755 tests/ls/stat-failed.sh delete mode 100755 tests/ls/stat-free-color create mode 100755 tests/ls/stat-free-color.sh delete mode 100755 tests/ls/stat-free-symlinks create mode 100755 tests/ls/stat-free-symlinks.sh delete mode 100755 tests/ls/stat-vs-dirent create mode 100755 tests/ls/stat-vs-dirent.sh delete mode 100755 tests/ls/symlink-slash create mode 100755 tests/ls/symlink-slash.sh delete mode 100755 tests/ls/time-style-diag create mode 100755 tests/ls/time-style-diag.sh delete mode 100755 tests/ls/x-option create mode 100755 tests/ls/x-option.sh delete mode 100755 tests/misc/arch create mode 100755 tests/misc/arch.sh delete mode 100755 tests/misc/base64 create mode 100755 tests/misc/base64.pl delete mode 100755 tests/misc/basename create mode 100755 tests/misc/basename.pl delete mode 100755 tests/misc/cat-buf create mode 100755 tests/misc/cat-buf.sh delete mode 100755 tests/misc/cat-proc create mode 100755 tests/misc/cat-proc.sh delete mode 100755 tests/misc/chcon delete mode 100755 tests/misc/chcon-fail create mode 100755 tests/misc/chcon-fail.sh create mode 100755 tests/misc/chcon.sh delete mode 100755 tests/misc/chroot-credentials create mode 100755 tests/misc/chroot-credentials.sh delete mode 100755 tests/misc/chroot-fail create mode 100755 tests/misc/chroot-fail.sh delete mode 100755 tests/misc/close-stdout create mode 100755 tests/misc/close-stdout.sh delete mode 100755 tests/misc/comm create mode 100755 tests/misc/comm.pl delete mode 100755 tests/misc/csplit delete mode 100755 tests/misc/csplit-1000 create mode 100755 tests/misc/csplit-1000.sh delete mode 100755 tests/misc/csplit-heap create mode 100755 tests/misc/csplit-heap.sh create mode 100755 tests/misc/csplit.sh delete mode 100755 tests/misc/cut create mode 100755 tests/misc/cut.pl delete mode 100755 tests/misc/date delete mode 100755 tests/misc/date-next-dow create mode 100755 tests/misc/date-next-dow.pl delete mode 100755 tests/misc/date-sec create mode 100755 tests/misc/date-sec.sh create mode 100755 tests/misc/date.pl delete mode 100755 tests/misc/dircolors create mode 100755 tests/misc/dircolors.pl delete mode 100755 tests/misc/dirname create mode 100755 tests/misc/dirname.pl delete mode 100755 tests/misc/env delete mode 100755 tests/misc/env-null create mode 100755 tests/misc/env-null.sh create mode 100755 tests/misc/env.sh delete mode 100755 tests/misc/expand create mode 100755 tests/misc/expand.pl delete mode 100755 tests/misc/expr create mode 100755 tests/misc/expr.pl delete mode 100755 tests/misc/factor create mode 100755 tests/misc/factor.pl delete mode 100755 tests/misc/false-status create mode 100755 tests/misc/false-status.sh delete mode 100755 tests/misc/fold create mode 100755 tests/misc/fold.pl delete mode 100755 tests/misc/groups-dash create mode 100755 tests/misc/groups-dash.sh delete mode 100755 tests/misc/groups-version create mode 100755 tests/misc/groups-version.sh delete mode 100755 tests/misc/head delete mode 100755 tests/misc/head-c create mode 100755 tests/misc/head-c.sh delete mode 100755 tests/misc/head-elide-tail create mode 100755 tests/misc/head-elide-tail.pl delete mode 100755 tests/misc/head-pos create mode 100755 tests/misc/head-pos.sh create mode 100755 tests/misc/head.pl delete mode 100755 tests/misc/help-version create mode 100755 tests/misc/help-version.sh delete mode 100755 tests/misc/id-context create mode 100755 tests/misc/id-context.sh delete mode 100755 tests/misc/id-groups create mode 100755 tests/misc/id-groups.sh delete mode 100755 tests/misc/id-setgid create mode 100755 tests/misc/id-setgid.sh delete mode 100755 tests/misc/invalid-opt create mode 100755 tests/misc/invalid-opt.pl delete mode 100755 tests/misc/join create mode 100755 tests/misc/join.pl delete mode 100755 tests/misc/ls-misc create mode 100755 tests/misc/ls-misc.pl delete mode 100755 tests/misc/ls-time create mode 100755 tests/misc/ls-time.sh delete mode 100755 tests/misc/md5sum delete mode 100755 tests/misc/md5sum-bsd create mode 100755 tests/misc/md5sum-bsd.sh delete mode 100755 tests/misc/md5sum-newline create mode 100755 tests/misc/md5sum-newline.pl delete mode 100755 tests/misc/md5sum-parallel create mode 100755 tests/misc/md5sum-parallel.sh create mode 100755 tests/misc/md5sum.pl delete mode 100755 tests/misc/mknod create mode 100755 tests/misc/mknod.sh delete mode 100755 tests/misc/mktemp create mode 100755 tests/misc/mktemp.pl delete mode 100755 tests/misc/nice delete mode 100755 tests/misc/nice-fail create mode 100755 tests/misc/nice-fail.sh create mode 100755 tests/misc/nice.sh delete mode 100755 tests/misc/nl create mode 100755 tests/misc/nl.sh delete mode 100755 tests/misc/nohup create mode 100755 tests/misc/nohup.sh delete mode 100755 tests/misc/nproc-avail create mode 100755 tests/misc/nproc-avail.sh delete mode 100755 tests/misc/nproc-positive create mode 100755 tests/misc/nproc-positive.sh delete mode 100755 tests/misc/od delete mode 100755 tests/misc/od-N create mode 100755 tests/misc/od-N.sh delete mode 100755 tests/misc/od-float create mode 100755 tests/misc/od-float.sh delete mode 100755 tests/misc/od-multiple-t create mode 100755 tests/misc/od-multiple-t.sh delete mode 100755 tests/misc/od-x8 create mode 100755 tests/misc/od-x8.sh create mode 100755 tests/misc/od.pl delete mode 100755 tests/misc/paste create mode 100755 tests/misc/paste.pl delete mode 100755 tests/misc/pathchk1 create mode 100755 tests/misc/pathchk1.sh delete mode 100755 tests/misc/pr create mode 100755 tests/misc/pr.pl delete mode 100755 tests/misc/printenv create mode 100755 tests/misc/printenv.sh delete mode 100755 tests/misc/printf delete mode 100755 tests/misc/printf-cov create mode 100755 tests/misc/printf-cov.pl delete mode 100755 tests/misc/printf-hex create mode 100755 tests/misc/printf-hex.sh delete mode 100755 tests/misc/printf-surprise create mode 100755 tests/misc/printf-surprise.sh create mode 100755 tests/misc/printf.sh delete mode 100755 tests/misc/ptx delete mode 100755 tests/misc/ptx-overrun create mode 100755 tests/misc/ptx-overrun.sh create mode 100755 tests/misc/ptx.pl delete mode 100755 tests/misc/pwd-long create mode 100755 tests/misc/pwd-long.sh delete mode 100755 tests/misc/pwd-option create mode 100755 tests/misc/pwd-option.sh delete mode 100755 tests/misc/readlink-fp-loop create mode 100755 tests/misc/readlink-fp-loop.sh delete mode 100755 tests/misc/readlink-root create mode 100755 tests/misc/readlink-root.sh delete mode 100755 tests/misc/realpath create mode 100755 tests/misc/realpath.sh delete mode 100755 tests/misc/runcon-no-reorder create mode 100755 tests/misc/runcon-no-reorder.sh delete mode 100755 tests/misc/selinux create mode 100755 tests/misc/selinux.sh delete mode 100755 tests/misc/seq delete mode 100755 tests/misc/seq-long-double create mode 100755 tests/misc/seq-long-double.sh create mode 100755 tests/misc/seq.pl delete mode 100755 tests/misc/sha1sum delete mode 100755 tests/misc/sha1sum-vec create mode 100755 tests/misc/sha1sum-vec.pl create mode 100755 tests/misc/sha1sum.pl delete mode 100755 tests/misc/sha224sum create mode 100755 tests/misc/sha224sum.pl delete mode 100755 tests/misc/sha256sum create mode 100755 tests/misc/sha256sum.pl delete mode 100755 tests/misc/sha384sum create mode 100755 tests/misc/sha384sum.pl delete mode 100755 tests/misc/sha512sum create mode 100755 tests/misc/sha512sum.pl delete mode 100755 tests/misc/shred-exact create mode 100755 tests/misc/shred-exact.sh delete mode 100755 tests/misc/shred-passes create mode 100755 tests/misc/shred-passes.sh delete mode 100755 tests/misc/shred-remove create mode 100755 tests/misc/shred-remove.sh delete mode 100755 tests/misc/shuf create mode 100755 tests/misc/shuf.sh delete mode 100755 tests/misc/sort delete mode 100755 tests/misc/sort-NaN-infloop create mode 100755 tests/misc/sort-NaN-infloop.sh delete mode 100755 tests/misc/sort-benchmark-random create mode 100755 tests/misc/sort-benchmark-random.sh delete mode 100755 tests/misc/sort-compress delete mode 100755 tests/misc/sort-compress-hang create mode 100755 tests/misc/sort-compress-hang.sh delete mode 100755 tests/misc/sort-compress-proc create mode 100755 tests/misc/sort-compress-proc.sh create mode 100755 tests/misc/sort-compress.sh delete mode 100755 tests/misc/sort-continue create mode 100755 tests/misc/sort-continue.sh delete mode 100755 tests/misc/sort-debug-keys create mode 100755 tests/misc/sort-debug-keys.sh delete mode 100755 tests/misc/sort-debug-warn create mode 100755 tests/misc/sort-debug-warn.sh delete mode 100755 tests/misc/sort-discrim create mode 100755 tests/misc/sort-discrim.sh delete mode 100755 tests/misc/sort-exit-early create mode 100755 tests/misc/sort-exit-early.sh delete mode 100755 tests/misc/sort-files0-from create mode 100755 tests/misc/sort-files0-from.pl delete mode 100755 tests/misc/sort-float create mode 100755 tests/misc/sort-float.sh delete mode 100755 tests/misc/sort-merge delete mode 100755 tests/misc/sort-merge-fdlimit create mode 100755 tests/misc/sort-merge-fdlimit.sh create mode 100755 tests/misc/sort-merge.pl delete mode 100755 tests/misc/sort-month create mode 100755 tests/misc/sort-month.sh delete mode 100755 tests/misc/sort-rand create mode 100755 tests/misc/sort-rand.sh delete mode 100755 tests/misc/sort-spinlock-abuse create mode 100755 tests/misc/sort-spinlock-abuse.sh delete mode 100755 tests/misc/sort-stale-thread-mem create mode 100755 tests/misc/sort-stale-thread-mem.sh delete mode 100755 tests/misc/sort-u-FMR create mode 100755 tests/misc/sort-u-FMR.sh delete mode 100755 tests/misc/sort-unique delete mode 100755 tests/misc/sort-unique-segv create mode 100755 tests/misc/sort-unique-segv.sh create mode 100755 tests/misc/sort-unique.sh delete mode 100755 tests/misc/sort-version create mode 100755 tests/misc/sort-version.sh create mode 100755 tests/misc/sort.pl delete mode 100755 tests/misc/stat-birthtime create mode 100755 tests/misc/stat-birthtime.sh delete mode 100755 tests/misc/stat-fmt create mode 100755 tests/misc/stat-fmt.sh delete mode 100755 tests/misc/stat-hyphen create mode 100755 tests/misc/stat-hyphen.sh delete mode 100755 tests/misc/stat-mount create mode 100755 tests/misc/stat-mount.sh delete mode 100755 tests/misc/stat-nanoseconds create mode 100755 tests/misc/stat-nanoseconds.sh delete mode 100755 tests/misc/stat-printf create mode 100755 tests/misc/stat-printf.pl delete mode 100755 tests/misc/stat-slash create mode 100755 tests/misc/stat-slash.sh delete mode 100755 tests/misc/stdbuf create mode 100755 tests/misc/stdbuf.sh delete mode 100755 tests/misc/stty delete mode 100755 tests/misc/stty-invalid create mode 100755 tests/misc/stty-invalid.sh delete mode 100755 tests/misc/stty-pairs create mode 100755 tests/misc/stty-pairs.sh delete mode 100755 tests/misc/stty-row-col create mode 100755 tests/misc/stty-row-col.sh create mode 100755 tests/misc/stty.sh delete mode 100755 tests/misc/sum delete mode 100755 tests/misc/sum-sysv create mode 100755 tests/misc/sum-sysv.sh create mode 100755 tests/misc/sum.pl delete mode 100755 tests/misc/tac delete mode 100755 tests/misc/tac-2-nonseekable create mode 100755 tests/misc/tac-2-nonseekable.sh delete mode 100755 tests/misc/tac-continue create mode 100755 tests/misc/tac-continue.sh create mode 100755 tests/misc/tac.pl delete mode 100755 tests/misc/tail create mode 100755 tests/misc/tail.pl delete mode 100755 tests/misc/tee delete mode 100755 tests/misc/tee-dash create mode 100755 tests/misc/tee-dash.sh create mode 100755 tests/misc/tee.sh delete mode 100755 tests/misc/test delete mode 100755 tests/misc/test-diag create mode 100755 tests/misc/test-diag.pl create mode 100755 tests/misc/test.pl delete mode 100755 tests/misc/timeout delete mode 100755 tests/misc/timeout-group create mode 100755 tests/misc/timeout-group.sh delete mode 100755 tests/misc/timeout-parameters create mode 100755 tests/misc/timeout-parameters.sh create mode 100755 tests/misc/timeout.sh delete mode 100755 tests/misc/tr delete mode 100755 tests/misc/tr-case-class create mode 100755 tests/misc/tr-case-class.sh create mode 100755 tests/misc/tr.pl delete mode 100755 tests/misc/truncate-dangling-symlink create mode 100755 tests/misc/truncate-dangling-symlink.sh delete mode 100755 tests/misc/truncate-dir-fail create mode 100755 tests/misc/truncate-dir-fail.sh delete mode 100755 tests/misc/truncate-fail-diag create mode 100755 tests/misc/truncate-fail-diag.sh delete mode 100755 tests/misc/truncate-fifo create mode 100755 tests/misc/truncate-fifo.sh delete mode 100755 tests/misc/truncate-no-create-missing create mode 100755 tests/misc/truncate-no-create-missing.sh delete mode 100755 tests/misc/truncate-overflow create mode 100755 tests/misc/truncate-overflow.sh delete mode 100755 tests/misc/truncate-owned-by-other create mode 100755 tests/misc/truncate-owned-by-other.sh delete mode 100755 tests/misc/truncate-parameters create mode 100755 tests/misc/truncate-parameters.sh delete mode 100755 tests/misc/truncate-relative create mode 100755 tests/misc/truncate-relative.sh delete mode 100755 tests/misc/tsort create mode 100755 tests/misc/tsort.pl delete mode 100755 tests/misc/tty-eof create mode 100755 tests/misc/tty-eof.pl delete mode 100755 tests/misc/unexpand create mode 100755 tests/misc/unexpand.pl delete mode 100755 tests/misc/uniq delete mode 100755 tests/misc/uniq-perf create mode 100755 tests/misc/uniq-perf.sh create mode 100755 tests/misc/uniq.pl delete mode 100755 tests/misc/wc delete mode 100755 tests/misc/wc-files0 delete mode 100755 tests/misc/wc-files0-from create mode 100755 tests/misc/wc-files0-from.pl create mode 100755 tests/misc/wc-files0.sh delete mode 100755 tests/misc/wc-parallel create mode 100755 tests/misc/wc-parallel.sh create mode 100755 tests/misc/wc.pl delete mode 100755 tests/misc/xattr create mode 100755 tests/misc/xattr.sh delete mode 100755 tests/misc/xstrtol create mode 100755 tests/misc/xstrtol.pl delete mode 100755 tests/mkdir/p-1 create mode 100755 tests/mkdir/p-1.sh delete mode 100755 tests/mkdir/p-2 create mode 100755 tests/mkdir/p-2.sh delete mode 100755 tests/mkdir/p-3 create mode 100755 tests/mkdir/p-3.sh delete mode 100755 tests/mkdir/p-slashdot create mode 100755 tests/mkdir/p-slashdot.sh delete mode 100755 tests/mkdir/p-thru-slink create mode 100755 tests/mkdir/p-thru-slink.sh delete mode 100755 tests/mkdir/p-v create mode 100755 tests/mkdir/p-v.sh delete mode 100755 tests/mkdir/parents create mode 100755 tests/mkdir/parents.sh delete mode 100755 tests/mkdir/perm create mode 100755 tests/mkdir/perm.sh delete mode 100755 tests/mkdir/selinux create mode 100755 tests/mkdir/selinux.sh delete mode 100755 tests/mkdir/special-1 create mode 100755 tests/mkdir/special-1.sh delete mode 100755 tests/mkdir/t-slash create mode 100755 tests/mkdir/t-slash.sh delete mode 100755 tests/mkdir/writable-under-readonly create mode 100755 tests/mkdir/writable-under-readonly.sh delete mode 100755 tests/mv/acl create mode 100755 tests/mv/acl.sh delete mode 100755 tests/mv/atomic create mode 100755 tests/mv/atomic.sh delete mode 100755 tests/mv/atomic2 create mode 100755 tests/mv/atomic2.sh delete mode 100755 tests/mv/backup-dir create mode 100755 tests/mv/backup-dir.sh delete mode 100755 tests/mv/backup-is-src create mode 100755 tests/mv/backup-is-src.sh delete mode 100755 tests/mv/childproof create mode 100755 tests/mv/childproof.sh delete mode 100755 tests/mv/diag create mode 100755 tests/mv/diag.sh delete mode 100755 tests/mv/dir-file create mode 100755 tests/mv/dir-file.sh delete mode 100755 tests/mv/dir2dir create mode 100755 tests/mv/dir2dir.sh delete mode 100755 tests/mv/dup-source create mode 100755 tests/mv/dup-source.sh delete mode 100755 tests/mv/force create mode 100755 tests/mv/force.sh delete mode 100755 tests/mv/hard-2 create mode 100755 tests/mv/hard-2.sh delete mode 100755 tests/mv/hard-3 create mode 100755 tests/mv/hard-3.sh delete mode 100755 tests/mv/hard-4 create mode 100755 tests/mv/hard-4.sh delete mode 100755 tests/mv/hard-link-1 create mode 100755 tests/mv/hard-link-1.sh delete mode 100755 tests/mv/hard-verbose create mode 100755 tests/mv/hard-verbose.sh delete mode 100755 tests/mv/i-1 create mode 100755 tests/mv/i-1.pl delete mode 100755 tests/mv/i-2 create mode 100755 tests/mv/i-2.sh delete mode 100755 tests/mv/i-3 create mode 100755 tests/mv/i-3.sh delete mode 100755 tests/mv/i-4 create mode 100755 tests/mv/i-4.sh delete mode 100755 tests/mv/i-5 create mode 100755 tests/mv/i-5.sh delete mode 100755 tests/mv/i-link-no create mode 100755 tests/mv/i-link-no.sh delete mode 100755 tests/mv/into-self delete mode 100755 tests/mv/into-self-2 create mode 100755 tests/mv/into-self-2.sh delete mode 100755 tests/mv/into-self-3 create mode 100755 tests/mv/into-self-3.sh delete mode 100755 tests/mv/into-self-4 create mode 100755 tests/mv/into-self-4.sh create mode 100755 tests/mv/into-self.sh delete mode 100755 tests/mv/leak-fd create mode 100755 tests/mv/leak-fd.sh delete mode 100755 tests/mv/mv-n create mode 100755 tests/mv/mv-n.sh delete mode 100755 tests/mv/mv-special-1 create mode 100755 tests/mv/mv-special-1.sh delete mode 100755 tests/mv/no-target-dir create mode 100755 tests/mv/no-target-dir.sh delete mode 100755 tests/mv/part-fail create mode 100755 tests/mv/part-fail.sh delete mode 100755 tests/mv/part-hardlink create mode 100755 tests/mv/part-hardlink.sh delete mode 100755 tests/mv/part-rename create mode 100755 tests/mv/part-rename.sh delete mode 100755 tests/mv/part-symlink create mode 100755 tests/mv/part-symlink.sh delete mode 100755 tests/mv/partition-perm create mode 100755 tests/mv/partition-perm.sh delete mode 100755 tests/mv/perm-1 create mode 100755 tests/mv/perm-1.sh delete mode 100755 tests/mv/sticky-to-xpart create mode 100755 tests/mv/sticky-to-xpart.sh delete mode 100755 tests/mv/symlink-onto-hardlink delete mode 100755 tests/mv/symlink-onto-hardlink-to-self create mode 100755 tests/mv/symlink-onto-hardlink-to-self.sh create mode 100755 tests/mv/symlink-onto-hardlink.sh delete mode 100755 tests/mv/to-symlink create mode 100755 tests/mv/to-symlink.sh delete mode 100755 tests/mv/trailing-slash create mode 100755 tests/mv/trailing-slash.sh delete mode 100755 tests/mv/update create mode 100755 tests/mv/update.sh delete mode 100755 tests/pr/pr-tests create mode 100755 tests/pr/pr-tests.pl delete mode 100755 tests/readlink/can-e create mode 100755 tests/readlink/can-e.sh delete mode 100755 tests/readlink/can-f create mode 100755 tests/readlink/can-f.sh delete mode 100755 tests/readlink/can-m create mode 100755 tests/readlink/can-m.sh delete mode 100755 tests/readlink/rl-1 create mode 100755 tests/readlink/rl-1.sh delete mode 100755 tests/rm/cycle create mode 100755 tests/rm/cycle.sh delete mode 100755 tests/rm/d-1 create mode 100755 tests/rm/d-1.sh delete mode 100755 tests/rm/d-2 create mode 100755 tests/rm/d-2.sh delete mode 100755 tests/rm/d-3 create mode 100755 tests/rm/d-3.sh delete mode 100755 tests/rm/dangling-symlink create mode 100755 tests/rm/dangling-symlink.sh delete mode 100755 tests/rm/deep-1 create mode 100755 tests/rm/deep-1.sh delete mode 100755 tests/rm/deep-2 create mode 100755 tests/rm/deep-2.sh delete mode 100755 tests/rm/dir-no-w create mode 100755 tests/rm/dir-no-w.sh delete mode 100755 tests/rm/dir-nonrecur create mode 100755 tests/rm/dir-nonrecur.sh delete mode 100755 tests/rm/dot-rel create mode 100755 tests/rm/dot-rel.sh delete mode 100755 tests/rm/empty-inacc create mode 100755 tests/rm/empty-inacc.sh delete mode 100755 tests/rm/empty-name create mode 100755 tests/rm/empty-name.pl delete mode 100755 tests/rm/ext3-perf create mode 100755 tests/rm/ext3-perf.sh delete mode 100755 tests/rm/f-1 create mode 100755 tests/rm/f-1.sh delete mode 100755 tests/rm/fail-2eperm create mode 100755 tests/rm/fail-2eperm.sh delete mode 100755 tests/rm/fail-eacces create mode 100755 tests/rm/fail-eacces.sh delete mode 100755 tests/rm/hash create mode 100755 tests/rm/hash.sh delete mode 100755 tests/rm/i-1 create mode 100755 tests/rm/i-1.sh delete mode 100755 tests/rm/i-never create mode 100755 tests/rm/i-never.sh delete mode 100755 tests/rm/i-no-r create mode 100755 tests/rm/i-no-r.sh delete mode 100755 tests/rm/ignorable create mode 100755 tests/rm/ignorable.sh delete mode 100755 tests/rm/inaccessible create mode 100755 tests/rm/inaccessible.sh delete mode 100755 tests/rm/interactive-always create mode 100755 tests/rm/interactive-always.sh delete mode 100755 tests/rm/interactive-once create mode 100755 tests/rm/interactive-once.sh delete mode 100755 tests/rm/ir-1 create mode 100755 tests/rm/ir-1.sh delete mode 100755 tests/rm/isatty create mode 100755 tests/rm/isatty.sh delete mode 100755 tests/rm/many-dir-entries-vs-OOM create mode 100755 tests/rm/many-dir-entries-vs-OOM.sh delete mode 100755 tests/rm/no-give-up create mode 100755 tests/rm/no-give-up.sh delete mode 100755 tests/rm/one-file-system create mode 100755 tests/rm/one-file-system.sh delete mode 100755 tests/rm/one-file-system2 create mode 100755 tests/rm/one-file-system2.sh delete mode 100755 tests/rm/r-1 create mode 100755 tests/rm/r-1.sh delete mode 100755 tests/rm/r-2 create mode 100755 tests/rm/r-2.sh delete mode 100755 tests/rm/r-3 create mode 100755 tests/rm/r-3.sh delete mode 100755 tests/rm/r-4 create mode 100755 tests/rm/r-4.sh delete mode 100755 tests/rm/read-only create mode 100755 tests/rm/read-only.sh delete mode 100755 tests/rm/readdir-bug create mode 100755 tests/rm/readdir-bug.sh delete mode 100755 tests/rm/rm1 create mode 100755 tests/rm/rm1.sh delete mode 100755 tests/rm/rm2 create mode 100755 tests/rm/rm2.sh delete mode 100755 tests/rm/rm3 create mode 100755 tests/rm/rm3.sh delete mode 100755 tests/rm/rm4 create mode 100755 tests/rm/rm4.sh delete mode 100755 tests/rm/rm5 create mode 100755 tests/rm/rm5.sh delete mode 100755 tests/rm/sunos-1 create mode 100755 tests/rm/sunos-1.sh delete mode 100755 tests/rm/unread2 create mode 100755 tests/rm/unread2.sh delete mode 100755 tests/rm/unread3 create mode 100755 tests/rm/unread3.sh delete mode 100755 tests/rm/unreadable create mode 100755 tests/rm/unreadable.pl delete mode 100755 tests/rm/v-slash create mode 100755 tests/rm/v-slash.sh delete mode 100755 tests/rmdir/fail-perm create mode 100755 tests/rmdir/fail-perm.sh delete mode 100755 tests/rmdir/ignore create mode 100755 tests/rmdir/ignore.sh delete mode 100755 tests/rmdir/t-slash create mode 100755 tests/rmdir/t-slash.sh delete mode 100755 tests/split/additional-suffix create mode 100755 tests/split/additional-suffix.sh delete mode 100755 tests/split/b-chunk create mode 100755 tests/split/b-chunk.sh delete mode 100755 tests/split/fail create mode 100755 tests/split/fail.sh delete mode 100755 tests/split/filter create mode 100755 tests/split/filter.sh delete mode 100755 tests/split/guard-input create mode 100755 tests/split/guard-input.sh delete mode 100755 tests/split/l-chunk create mode 100755 tests/split/l-chunk.sh delete mode 100755 tests/split/lines create mode 100755 tests/split/lines.sh delete mode 100755 tests/split/numeric create mode 100755 tests/split/numeric.sh delete mode 100755 tests/split/r-chunk create mode 100755 tests/split/r-chunk.sh delete mode 100755 tests/split/suffix-auto-length create mode 100755 tests/split/suffix-auto-length.sh delete mode 100755 tests/split/suffix-length create mode 100755 tests/split/suffix-length.sh delete mode 100755 tests/tail-2/F-vs-missing create mode 100755 tests/tail-2/F-vs-missing.sh delete mode 100755 tests/tail-2/F-vs-rename create mode 100755 tests/tail-2/F-vs-rename.sh delete mode 100755 tests/tail-2/append-only create mode 100755 tests/tail-2/append-only.sh delete mode 100755 tests/tail-2/assert delete mode 100755 tests/tail-2/assert-2 create mode 100755 tests/tail-2/assert-2.sh create mode 100755 tests/tail-2/assert.sh delete mode 100755 tests/tail-2/big-4gb create mode 100755 tests/tail-2/big-4gb.sh delete mode 100755 tests/tail-2/flush-initial create mode 100755 tests/tail-2/flush-initial.sh delete mode 100755 tests/tail-2/follow-name create mode 100755 tests/tail-2/follow-name.sh delete mode 100755 tests/tail-2/follow-stdin create mode 100755 tests/tail-2/follow-stdin.sh delete mode 100755 tests/tail-2/infloop-1 create mode 100755 tests/tail-2/infloop-1.sh delete mode 100755 tests/tail-2/inotify-hash-abuse create mode 100755 tests/tail-2/inotify-hash-abuse.sh delete mode 100755 tests/tail-2/inotify-hash-abuse2 create mode 100755 tests/tail-2/inotify-hash-abuse2.sh delete mode 100755 tests/tail-2/inotify-race create mode 100755 tests/tail-2/inotify-race.sh delete mode 100755 tests/tail-2/inotify-rotate create mode 100755 tests/tail-2/inotify-rotate.sh delete mode 100755 tests/tail-2/pid create mode 100755 tests/tail-2/pid.sh delete mode 100755 tests/tail-2/pipe-f create mode 100755 tests/tail-2/pipe-f.sh delete mode 100755 tests/tail-2/pipe-f2 create mode 100755 tests/tail-2/pipe-f2.sh delete mode 100755 tests/tail-2/proc-ksyms create mode 100755 tests/tail-2/proc-ksyms.sh delete mode 100755 tests/tail-2/start-middle create mode 100755 tests/tail-2/start-middle.sh delete mode 100755 tests/tail-2/tail-n0f create mode 100755 tests/tail-2/tail-n0f.sh delete mode 100755 tests/tail-2/wait create mode 100755 tests/tail-2/wait.sh delete mode 100755 tests/touch/60-seconds create mode 100755 tests/touch/60-seconds.sh delete mode 100755 tests/touch/dangling-symlink create mode 100755 tests/touch/dangling-symlink.sh delete mode 100755 tests/touch/dir-1 create mode 100755 tests/touch/dir-1.sh delete mode 100755 tests/touch/empty-file create mode 100755 tests/touch/empty-file.sh delete mode 100755 tests/touch/fail-diag create mode 100755 tests/touch/fail-diag.sh delete mode 100755 tests/touch/fifo create mode 100755 tests/touch/fifo.sh delete mode 100755 tests/touch/no-create-missing create mode 100755 tests/touch/no-create-missing.sh delete mode 100755 tests/touch/no-dereference create mode 100755 tests/touch/no-dereference.sh delete mode 100755 tests/touch/no-rights create mode 100755 tests/touch/no-rights.sh delete mode 100755 tests/touch/not-owner create mode 100755 tests/touch/not-owner.sh delete mode 100755 tests/touch/now-owned-by-other create mode 100755 tests/touch/now-owned-by-other.sh delete mode 100755 tests/touch/obsolescent create mode 100755 tests/touch/obsolescent.sh delete mode 100755 tests/touch/read-only create mode 100755 tests/touch/read-only.sh delete mode 100755 tests/touch/relative create mode 100755 tests/touch/relative.sh delete mode 100755 tests/touch/trailing-slash create mode 100755 tests/touch/trailing-slash.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index ff0af8494..a547b1181 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,7 +45,7 @@ check_DATA = .built-programs && MAKEFLAGS= $(MAKE) -s built_programs.list) \ > $@-t && mv $@-t $@ -TEST_EXTENSIONS = .xpl +TEST_EXTENSIONS = .sh .pl .xpl if HAVE_PERL TESTSUITE_PERL = $(PERL) @@ -63,6 +63,9 @@ LOG_COMPILER = \ --test-name "$$f" --srcdir '$(srcdir)' \ --shell '$(SHELL)' --perl '$(TESTSUITE_PERL)' -- +PL_LOG_COMPILER = $(LOG_COMPILER) +SH_LOG_COMPILER = $(LOG_COMPILER) + # Perl scripts that must be run in tainted mode. XPL_LOG_COMPILER = \ $(TESTSUITE_PERL) -wT -I$(srcdir) -MCoreutils -MCuSkip -M"CuTmpdir qw($$f)" @@ -131,32 +134,32 @@ EXTRA_DIST = \ $(pr_data) root_tests = \ - chown/basic \ - cp/cp-a-selinux \ - cp/preserve-gid \ - cp/special-bits \ - cp/cp-mv-enotsup-xattr \ - cp/capability \ - cp/sparse-fiemap \ - dd/skip-seek-past-dev \ - df/problematic-chars \ - du/bind-mount-dir-cycle \ - install/install-C-root \ - ls/capability \ - ls/nameless-uid \ - misc/chcon \ - misc/chroot-credentials \ - misc/id-setgid \ - misc/selinux \ - misc/truncate-owned-by-other \ - mkdir/writable-under-readonly \ - mv/sticky-to-xpart \ - rm/fail-2eperm \ - rm/no-give-up \ - rm/one-file-system \ - rm/read-only \ - tail-2/append-only \ - touch/now-owned-by-other + chown/basic.sh \ + cp/cp-a-selinux.sh \ + cp/preserve-gid.sh \ + cp/special-bits.sh \ + cp/cp-mv-enotsup-xattr.sh \ + cp/capability.sh \ + cp/sparse-fiemap.sh \ + dd/skip-seek-past-dev.sh \ + df/problematic-chars.sh \ + du/bind-mount-dir-cycle.sh \ + install/install-C-root.sh \ + ls/capability.sh \ + ls/nameless-uid.sh \ + misc/chcon.sh \ + misc/chroot-credentials.sh \ + misc/id-setgid.sh \ + misc/selinux.sh \ + misc/truncate-owned-by-other.sh \ + mkdir/writable-under-readonly.sh \ + mv/sticky-to-xpart.sh \ + rm/fail-2eperm.sh \ + rm/no-give-up.sh \ + rm/one-file-system.sh \ + rm/read-only.sh \ + tail-2/append-only.sh \ + touch/now-owned-by-other.sh .PHONY: check-root check-root: @@ -191,473 +194,473 @@ EXTRA_DIST += $(TESTS) # Put head-elide-tail early, because it's long-running. TESTS = \ - misc/help-version \ - tail-2/inotify-race \ - misc/invalid-opt \ - rm/ext3-perf \ - rm/cycle \ - cp/link-heap \ - misc/tty-eof \ - tail-2/inotify-hash-abuse \ - tail-2/inotify-hash-abuse2 \ - tail-2/F-vs-missing \ - tail-2/F-vs-rename \ - tail-2/inotify-rotate \ - chmod/no-x \ - chgrp/basic \ - rm/dangling-symlink \ - misc/ls-time \ - rm/d-1 \ - rm/d-2 \ - rm/d-3 \ - rm/deep-1 \ - rm/deep-2 \ - rm/dir-no-w \ - rm/dir-nonrecur \ - rm/dot-rel \ - rm/isatty \ - rm/empty-inacc \ - rm/empty-name \ - rm/f-1 \ - rm/fail-eacces \ + misc/help-version.sh \ + tail-2/inotify-race.sh \ + misc/invalid-opt.pl \ + rm/ext3-perf.sh \ + rm/cycle.sh \ + cp/link-heap.sh \ + misc/tty-eof.pl \ + tail-2/inotify-hash-abuse.sh \ + tail-2/inotify-hash-abuse2.sh \ + tail-2/F-vs-missing.sh \ + tail-2/F-vs-rename.sh \ + tail-2/inotify-rotate.sh \ + chmod/no-x.sh \ + chgrp/basic.sh \ + rm/dangling-symlink.sh \ + misc/ls-time.sh \ + rm/d-1.sh \ + rm/d-2.sh \ + rm/d-3.sh \ + rm/deep-1.sh \ + rm/deep-2.sh \ + rm/dir-no-w.sh \ + rm/dir-nonrecur.sh \ + rm/dot-rel.sh \ + rm/isatty.sh \ + rm/empty-inacc.sh \ + rm/empty-name.pl \ + rm/f-1.sh \ + rm/fail-eacces.sh \ rm/fail-eperm.xpl \ - tail-2/assert \ - rm/hash \ - rm/i-1 \ - rm/i-never \ - rm/i-no-r \ - tail-2/infloop-1 \ - rm/ignorable \ - rm/inaccessible \ - rm/interactive-always \ - rm/interactive-once \ - rm/ir-1 \ - rm/one-file-system2 \ - rm/r-1 \ - rm/r-2 \ - rm/r-3 \ - rm/r-4 \ - rm/readdir-bug \ - rm/rm1 \ - touch/empty-file \ - rm/rm2 \ - rm/rm3 \ - rm/rm4 \ - rm/rm5 \ - rm/sunos-1 \ - rm/unread2 \ - rm/unread3 \ - rm/unreadable \ - rm/v-slash \ - rm/many-dir-entries-vs-OOM \ - chgrp/default-no-deref \ - chgrp/deref \ - chgrp/no-x \ - chgrp/posix-H \ - chgrp/recurse \ - fmt/base \ - fmt/long-line \ - fmt/goal-option \ - misc/env \ - misc/ptx \ - misc/test \ - misc/seq \ - misc/seq-long-double \ - misc/head \ - misc/head-elide-tail \ - tail-2/tail-n0f \ - misc/ls-misc \ - misc/date \ - misc/date-next-dow \ - misc/ptx-overrun \ - misc/xstrtol \ - tail-2/pid \ - misc/od \ - misc/od-float \ - misc/mktemp \ - misc/arch \ - misc/pr \ - misc/join \ - pr/pr-tests \ - misc/pwd-option \ - misc/chcon-fail \ - misc/cut \ - misc/wc \ - misc/wc-files0-from \ - misc/wc-files0 \ - misc/wc-parallel \ - misc/cat-proc \ - misc/cat-buf \ - misc/base64 \ - misc/basename \ - misc/close-stdout \ - misc/chroot-fail \ - misc/comm \ - misc/csplit \ - misc/csplit-1000 \ - misc/csplit-heap \ - misc/date-sec \ - misc/dircolors \ - misc/dirname \ - misc/env-null \ - misc/expand \ - misc/expr \ - misc/factor \ - misc/false-status \ - misc/fold \ - misc/groups-dash \ - misc/groups-version \ - misc/head-c \ - misc/head-pos \ - misc/id-context \ - misc/id-groups \ - misc/id-setgid \ - misc/md5sum \ - misc/md5sum-bsd \ - misc/md5sum-newline \ - misc/md5sum-parallel \ - misc/mknod \ - misc/nice \ - misc/nice-fail \ - misc/nl \ - misc/nohup \ - misc/nproc-avail \ - misc/nproc-positive \ - misc/od-N \ - misc/od-multiple-t \ - misc/od-x8 \ - misc/paste \ - misc/pathchk1 \ - misc/printenv \ - misc/printf \ - misc/printf-cov \ - misc/printf-hex \ - misc/printf-surprise \ - misc/pwd-long \ - misc/readlink-fp-loop \ - misc/readlink-root \ - misc/realpath \ - misc/runcon-no-reorder \ - misc/sha1sum \ - misc/sha1sum-vec \ - misc/sha224sum \ - misc/sha256sum \ - misc/sha384sum \ - misc/sha512sum \ - misc/shred-exact \ - misc/shred-passes \ - misc/shred-remove \ - misc/shuf \ - misc/sort \ - misc/sort-benchmark-random \ - misc/sort-compress \ - misc/sort-compress-hang \ - misc/sort-compress-proc \ - misc/sort-continue \ - misc/sort-debug-keys \ - misc/sort-debug-warn \ - misc/sort-discrim \ - misc/sort-files0-from \ - misc/sort-float \ - misc/sort-merge \ - misc/sort-merge-fdlimit \ - misc/sort-month \ - misc/sort-exit-early \ - misc/sort-rand \ - misc/sort-spinlock-abuse \ - misc/sort-stale-thread-mem \ - misc/sort-unique \ - misc/sort-unique-segv \ - misc/sort-version \ - misc/sort-NaN-infloop \ - misc/sort-u-FMR \ - split/filter \ - split/suffix-auto-length \ - split/suffix-length \ - split/additional-suffix \ - split/b-chunk \ - split/fail \ - split/lines \ - split/l-chunk \ - split/r-chunk \ - split/numeric \ - split/guard-input \ - misc/stat-birthtime \ - misc/stat-fmt \ - misc/stat-hyphen \ - misc/stat-mount \ - misc/stat-nanoseconds \ - misc/stat-printf \ - misc/stat-slash \ - misc/stdbuf \ - misc/stty \ - misc/stty-invalid \ - misc/stty-pairs \ - misc/stty-row-col \ - misc/sum \ - misc/sum-sysv \ - misc/tac \ - misc/tac-continue \ - misc/tac-2-nonseekable \ - misc/tail \ - misc/tee \ - misc/tee-dash \ - misc/test-diag \ - misc/timeout \ - misc/timeout-group \ - misc/timeout-parameters \ - misc/tr \ - misc/tr-case-class \ - misc/truncate-dangling-symlink \ - misc/truncate-dir-fail \ - misc/truncate-fail-diag \ - misc/truncate-fifo \ - misc/truncate-no-create-missing \ - misc/truncate-overflow \ - misc/truncate-parameters \ - misc/truncate-relative \ - misc/tsort \ - misc/unexpand \ - misc/uniq \ - misc/uniq-perf \ - misc/xattr \ - tail-2/wait \ - chmod/c-option \ - chmod/equal-x \ - chmod/equals \ - chmod/inaccessible \ - chmod/octal \ - chmod/setgid \ - chmod/silent \ - chmod/thru-dangling \ - chmod/umask-x \ - chmod/usage \ - chown/deref \ - chown/preserve-root \ - chown/separator \ - cp/abuse \ - cp/acl \ - cp/attr-existing \ - cp/backup-1 \ - cp/backup-dir \ - cp/backup-is-src \ - cp/cp-HL \ - cp/cp-deref \ - cp/cp-i \ - cp/cp-mv-backup \ - cp/cp-parents \ - cp/deref-slink \ - cp/dir-rm-dest \ - cp/dir-slash \ - cp/dir-vs-file \ - cp/existing-perm-dir \ - cp/existing-perm-race \ - cp/fail-perm \ - cp/fiemap-empty \ - cp/fiemap-perf \ - cp/fiemap-2 \ - cp/file-perm-race \ - cp/into-self \ - cp/link \ - cp/link-no-deref \ - cp/link-preserve \ - cp/link-symlink \ - cp/nfs-removal-race \ - cp/no-deref-link1 \ - cp/no-deref-link2 \ - cp/no-deref-link3 \ - cp/parent-perm \ - cp/parent-perm-race \ - cp/perm \ - cp/preserve-2 \ - cp/preserve-link \ - cp/preserve-slink-time \ - cp/proc-short-read \ - cp/proc-zero-len \ - cp/r-vs-symlink \ - cp/reflink-auto \ - cp/reflink-perm \ - cp/same-file \ - cp/slink-2-slink \ - cp/sparse \ - cp/sparse-to-pipe \ - cp/special-f \ - cp/src-base-dot \ - cp/symlink-slash \ - cp/thru-dangling \ - df/header \ - df/df-P \ - df/unreadable \ - df/total-unprocessed \ - df/no-mtab-status \ - dd/direct \ - dd/misc \ - dd/nocache \ - dd/not-rewound \ - dd/reblock \ - dd/skip-seek \ - dd/skip-seek2 \ - dd/bytes \ - dd/skip-seek-past-file \ - dd/sparse \ - dd/stderr \ - dd/unblock \ - dd/unblock-sync \ - df/total-verify \ - du/2g \ - du/8gb \ - du/basic \ - du/bigtime \ - du/deref \ - du/deref-args \ - du/exclude \ - du/fd-leak \ - du/files0-from \ - du/files0-from-dir \ - du/hard-link \ - du/inacc-dest \ - du/inacc-dir \ - du/inaccessible-cwd \ - du/long-from-unreadable \ - du/long-sloop \ - du/max-depth \ - du/move-dir-while-traversing \ - du/no-deref \ - du/no-x \ - du/one-file-system \ - du/restore-wd \ - du/slash \ - du/slink \ - du/trailing-slash \ - du/two-args \ - id/gnu-zero-uids \ - id/no-context \ - install/basic-1 \ - install/create-leading \ - install/d-slashdot \ - install/install-C \ - install/install-C-selinux \ - install/strip-program \ - install/trap \ - ln/backup-1 \ - ln/hard-backup \ - ln/hard-to-sym \ - ln/misc \ - ln/relative \ - ln/sf-1 \ - ln/slash-decorated-nonexistent-dest \ - ln/target-1 \ - ls/abmon-align \ - ls/block-size \ - ls/color-clear-to-eol \ - ls/color-dtype-dir \ - ls/color-norm \ - ls/dangle \ - ls/dired \ - ls/file-type \ - ls/follow-slink \ - ls/getxattr-speedup \ - ls/infloop \ - ls/inode \ - ls/m-option \ - ls/multihardlink \ - ls/no-arg \ - ls/no-cap \ - ls/proc-selinux-segfault \ - ls/readdir-mountpoint-inode \ - ls/recursive \ - ls/root-rel-symlink-color \ - ls/rt-1 \ - ls/slink-acl \ - ls/stat-dtype \ - ls/stat-failed \ - ls/stat-free-color \ - ls/stat-free-symlinks \ - ls/stat-vs-dirent \ - ls/symlink-slash \ - ls/time-style-diag \ - ls/x-option \ - mkdir/p-1 \ - mkdir/p-2 \ - mkdir/p-3 \ - mkdir/p-slashdot \ - mkdir/p-thru-slink \ - mkdir/p-v \ - mkdir/parents \ - mkdir/perm \ - mkdir/selinux \ - mkdir/special-1 \ - mkdir/t-slash \ - mv/acl \ - mv/atomic \ - mv/atomic2 \ - mv/backup-dir \ - mv/backup-is-src \ - mv/childproof \ - mv/diag \ - mv/dir-file \ - mv/dir2dir \ - mv/dup-source \ - mv/force \ - mv/hard-2 \ - mv/hard-3 \ - mv/hard-4 \ - mv/hard-link-1 \ - mv/hard-verbose \ - mv/i-1 \ - mv/i-2 \ - mv/i-3 \ - mv/i-4 \ - mv/i-5 \ - mv/i-link-no \ - mv/into-self \ - mv/into-self-2 \ - mv/into-self-3 \ - mv/into-self-4 \ - mv/leak-fd \ - mv/mv-n \ - mv/mv-special-1 \ - mv/no-target-dir \ - mv/part-fail \ - mv/part-hardlink \ - mv/part-rename \ - mv/part-symlink \ - mv/partition-perm \ - mv/perm-1 \ - mv/symlink-onto-hardlink \ - mv/symlink-onto-hardlink-to-self \ - mv/to-symlink \ - mv/trailing-slash \ - mv/update \ - readlink/can-e \ - readlink/can-f \ - readlink/can-m \ - readlink/rl-1 \ - rmdir/fail-perm \ - rmdir/ignore \ - rmdir/t-slash \ - tail-2/assert-2 \ - tail-2/big-4gb \ - tail-2/flush-initial \ - tail-2/follow-name \ - tail-2/follow-stdin \ - tail-2/pipe-f \ - tail-2/pipe-f2 \ - tail-2/proc-ksyms \ - tail-2/start-middle \ - touch/60-seconds \ - touch/dangling-symlink \ - touch/dir-1 \ - touch/fail-diag \ - touch/fifo \ - touch/no-create-missing \ - touch/no-dereference \ - touch/no-rights \ - touch/not-owner \ - touch/obsolescent \ - touch/read-only \ - touch/relative \ - touch/trailing-slash \ + tail-2/assert.sh \ + rm/hash.sh \ + rm/i-1.sh \ + rm/i-never.sh \ + rm/i-no-r.sh \ + tail-2/infloop-1.sh \ + rm/ignorable.sh \ + rm/inaccessible.sh \ + rm/interactive-always.sh \ + rm/interactive-once.sh \ + rm/ir-1.sh \ + rm/one-file-system2.sh \ + rm/r-1.sh \ + rm/r-2.sh \ + rm/r-3.sh \ + rm/r-4.sh \ + rm/readdir-bug.sh \ + rm/rm1.sh \ + touch/empty-file.sh \ + rm/rm2.sh \ + rm/rm3.sh \ + rm/rm4.sh \ + rm/rm5.sh \ + rm/sunos-1.sh \ + rm/unread2.sh \ + rm/unread3.sh \ + rm/unreadable.pl \ + rm/v-slash.sh \ + rm/many-dir-entries-vs-OOM.sh \ + chgrp/default-no-deref.sh \ + chgrp/deref.sh \ + chgrp/no-x.sh \ + chgrp/posix-H.sh \ + chgrp/recurse.sh \ + fmt/base.pl \ + fmt/long-line.sh \ + fmt/goal-option.sh \ + misc/env.sh \ + misc/ptx.pl \ + misc/test.pl \ + misc/seq.pl \ + misc/seq-long-double.sh \ + misc/head.pl \ + misc/head-elide-tail.pl \ + tail-2/tail-n0f.sh \ + misc/ls-misc.pl \ + misc/date.pl \ + misc/date-next-dow.pl \ + misc/ptx-overrun.sh \ + misc/xstrtol.pl \ + tail-2/pid.sh \ + misc/od.pl \ + misc/od-float.sh \ + misc/mktemp.pl \ + misc/arch.sh \ + misc/pr.pl \ + misc/join.pl \ + pr/pr-tests.pl \ + misc/pwd-option.sh \ + misc/chcon-fail.sh \ + misc/cut.pl \ + misc/wc.pl \ + misc/wc-files0-from.pl \ + misc/wc-files0.sh \ + misc/wc-parallel.sh \ + misc/cat-proc.sh \ + misc/cat-buf.sh \ + misc/base64.pl \ + misc/basename.pl \ + misc/close-stdout.sh \ + misc/chroot-fail.sh \ + misc/comm.pl \ + misc/csplit.sh \ + misc/csplit-1000.sh \ + misc/csplit-heap.sh \ + misc/date-sec.sh \ + misc/dircolors.pl \ + misc/dirname.pl \ + misc/env-null.sh \ + misc/expand.pl \ + misc/expr.pl \ + misc/factor.pl \ + misc/false-status.sh \ + misc/fold.pl \ + misc/groups-dash.sh \ + misc/groups-version.sh \ + misc/head-c.sh \ + misc/head-pos.sh \ + misc/id-context.sh \ + misc/id-groups.sh \ + misc/id-setgid.sh \ + misc/md5sum.pl \ + misc/md5sum-bsd.sh \ + misc/md5sum-newline.pl \ + misc/md5sum-parallel.sh \ + misc/mknod.sh \ + misc/nice.sh \ + misc/nice-fail.sh \ + misc/nl.sh \ + misc/nohup.sh \ + misc/nproc-avail.sh \ + misc/nproc-positive.sh \ + misc/od-N.sh \ + misc/od-multiple-t.sh \ + misc/od-x8.sh \ + misc/paste.pl \ + misc/pathchk1.sh \ + misc/printenv.sh \ + misc/printf.sh \ + misc/printf-cov.pl \ + misc/printf-hex.sh \ + misc/printf-surprise.sh \ + misc/pwd-long.sh \ + misc/readlink-fp-loop.sh \ + misc/readlink-root.sh \ + misc/realpath.sh \ + misc/runcon-no-reorder.sh \ + misc/sha1sum.pl \ + misc/sha1sum-vec.pl \ + misc/sha224sum.pl \ + misc/sha256sum.pl \ + misc/sha384sum.pl \ + misc/sha512sum.pl \ + misc/shred-exact.sh \ + misc/shred-passes.sh \ + misc/shred-remove.sh \ + misc/shuf.sh \ + misc/sort.pl \ + misc/sort-benchmark-random.sh \ + misc/sort-compress.sh \ + misc/sort-compress-hang.sh \ + misc/sort-compress-proc.sh \ + misc/sort-continue.sh \ + misc/sort-debug-keys.sh \ + misc/sort-debug-warn.sh \ + misc/sort-discrim.sh \ + misc/sort-files0-from.pl \ + misc/sort-float.sh \ + misc/sort-merge.pl \ + misc/sort-merge-fdlimit.sh \ + misc/sort-month.sh \ + misc/sort-exit-early.sh \ + misc/sort-rand.sh \ + misc/sort-spinlock-abuse.sh \ + misc/sort-stale-thread-mem.sh \ + misc/sort-unique.sh \ + misc/sort-unique-segv.sh \ + misc/sort-version.sh \ + misc/sort-NaN-infloop.sh \ + misc/sort-u-FMR.sh \ + split/filter.sh \ + split/suffix-auto-length.sh \ + split/suffix-length.sh \ + split/additional-suffix.sh \ + split/b-chunk.sh \ + split/fail.sh \ + split/lines.sh \ + split/l-chunk.sh \ + split/r-chunk.sh \ + split/numeric.sh \ + split/guard-input.sh \ + misc/stat-birthtime.sh \ + misc/stat-fmt.sh \ + misc/stat-hyphen.sh \ + misc/stat-mount.sh \ + misc/stat-nanoseconds.sh \ + misc/stat-printf.pl \ + misc/stat-slash.sh \ + misc/stdbuf.sh \ + misc/stty.sh \ + misc/stty-invalid.sh \ + misc/stty-pairs.sh \ + misc/stty-row-col.sh \ + misc/sum.pl \ + misc/sum-sysv.sh \ + misc/tac.pl \ + misc/tac-continue.sh \ + misc/tac-2-nonseekable.sh \ + misc/tail.pl \ + misc/tee.sh \ + misc/tee-dash.sh \ + misc/test-diag.pl \ + misc/timeout.sh \ + misc/timeout-group.sh \ + misc/timeout-parameters.sh \ + misc/tr.pl \ + misc/tr-case-class.sh \ + misc/truncate-dangling-symlink.sh \ + misc/truncate-dir-fail.sh \ + misc/truncate-fail-diag.sh \ + misc/truncate-fifo.sh \ + misc/truncate-no-create-missing.sh \ + misc/truncate-overflow.sh \ + misc/truncate-parameters.sh \ + misc/truncate-relative.sh \ + misc/tsort.pl \ + misc/unexpand.pl \ + misc/uniq.pl \ + misc/uniq-perf.sh \ + misc/xattr.sh \ + tail-2/wait.sh \ + chmod/c-option.sh \ + chmod/equal-x.sh \ + chmod/equals.sh \ + chmod/inaccessible.sh \ + chmod/octal.sh \ + chmod/setgid.sh \ + chmod/silent.sh \ + chmod/thru-dangling.sh \ + chmod/umask-x.sh \ + chmod/usage.sh \ + chown/deref.sh \ + chown/preserve-root.sh \ + chown/separator.sh \ + cp/abuse.sh \ + cp/acl.sh \ + cp/attr-existing.sh \ + cp/backup-1.sh \ + cp/backup-dir.sh \ + cp/backup-is-src.sh \ + cp/cp-HL.sh \ + cp/cp-deref.sh \ + cp/cp-i.sh \ + cp/cp-mv-backup.sh \ + cp/cp-parents.sh \ + cp/deref-slink.sh \ + cp/dir-rm-dest.sh \ + cp/dir-slash.sh \ + cp/dir-vs-file.sh \ + cp/existing-perm-dir.sh \ + cp/existing-perm-race.sh \ + cp/fail-perm.sh \ + cp/fiemap-empty.sh \ + cp/fiemap-perf.sh \ + cp/fiemap-2.sh \ + cp/file-perm-race.sh \ + cp/into-self.sh \ + cp/link.sh \ + cp/link-no-deref.sh \ + cp/link-preserve.sh \ + cp/link-symlink.sh \ + cp/nfs-removal-race.sh \ + cp/no-deref-link1.sh \ + cp/no-deref-link2.sh \ + cp/no-deref-link3.sh \ + cp/parent-perm.sh \ + cp/parent-perm-race.sh \ + cp/perm.sh \ + cp/preserve-2.sh \ + cp/preserve-link.sh \ + cp/preserve-slink-time.sh \ + cp/proc-short-read.sh \ + cp/proc-zero-len.sh \ + cp/r-vs-symlink.sh \ + cp/reflink-auto.sh \ + cp/reflink-perm.sh \ + cp/same-file.sh \ + cp/slink-2-slink.sh \ + cp/sparse.sh \ + cp/sparse-to-pipe.sh \ + cp/special-f.sh \ + cp/src-base-dot.sh \ + cp/symlink-slash.sh \ + cp/thru-dangling.sh \ + df/header.sh \ + df/df-P.sh \ + df/unreadable.sh \ + df/total-unprocessed.sh \ + df/no-mtab-status.sh \ + dd/direct.sh \ + dd/misc.sh \ + dd/nocache.sh \ + dd/not-rewound.sh \ + dd/reblock.sh \ + dd/skip-seek.pl \ + dd/skip-seek2.sh \ + dd/bytes.sh \ + dd/skip-seek-past-file.sh \ + dd/sparse.sh \ + dd/stderr.sh \ + dd/unblock.pl \ + dd/unblock-sync.sh \ + df/total-verify.sh \ + du/2g.sh \ + du/8gb.sh \ + du/basic.sh \ + du/bigtime.sh \ + du/deref.sh \ + du/deref-args.sh \ + du/exclude.sh \ + du/fd-leak.sh \ + du/files0-from.pl \ + du/files0-from-dir.sh \ + du/hard-link.sh \ + du/inacc-dest.sh \ + du/inacc-dir.sh \ + du/inaccessible-cwd.sh \ + du/long-from-unreadable.sh \ + du/long-sloop.sh \ + du/max-depth.sh \ + du/move-dir-while-traversing.sh \ + du/no-deref.sh \ + du/no-x.sh \ + du/one-file-system.sh \ + du/restore-wd.sh \ + du/slash.sh \ + du/slink.sh \ + du/trailing-slash.sh \ + du/two-args.sh \ + id/gnu-zero-uids.sh \ + id/no-context.sh \ + install/basic-1.sh \ + install/create-leading.sh \ + install/d-slashdot.sh \ + install/install-C.sh \ + install/install-C-selinux.sh \ + install/strip-program.sh \ + install/trap.sh \ + ln/backup-1.sh \ + ln/hard-backup.sh \ + ln/hard-to-sym.sh \ + ln/misc.sh \ + ln/relative.sh \ + ln/sf-1.sh \ + ln/slash-decorated-nonexistent-dest.sh \ + ln/target-1.sh \ + ls/abmon-align.sh \ + ls/block-size.sh \ + ls/color-clear-to-eol.sh \ + ls/color-dtype-dir.sh \ + ls/color-norm.sh \ + ls/dangle.sh \ + ls/dired.sh \ + ls/file-type.sh \ + ls/follow-slink.sh \ + ls/getxattr-speedup.sh \ + ls/infloop.sh \ + ls/inode.sh \ + ls/m-option.sh \ + ls/multihardlink.sh \ + ls/no-arg.sh \ + ls/no-cap.sh \ + ls/proc-selinux-segfault.sh \ + ls/readdir-mountpoint-inode.sh \ + ls/recursive.sh \ + ls/root-rel-symlink-color.sh \ + ls/rt-1.sh \ + ls/slink-acl.sh \ + ls/stat-dtype.sh \ + ls/stat-failed.sh \ + ls/stat-free-color.sh \ + ls/stat-free-symlinks.sh \ + ls/stat-vs-dirent.sh \ + ls/symlink-slash.sh \ + ls/time-style-diag.sh \ + ls/x-option.sh \ + mkdir/p-1.sh \ + mkdir/p-2.sh \ + mkdir/p-3.sh \ + mkdir/p-slashdot.sh \ + mkdir/p-thru-slink.sh \ + mkdir/p-v.sh \ + mkdir/parents.sh \ + mkdir/perm.sh \ + mkdir/selinux.sh \ + mkdir/special-1.sh \ + mkdir/t-slash.sh \ + mv/acl.sh \ + mv/atomic.sh \ + mv/atomic2.sh \ + mv/backup-dir.sh \ + mv/backup-is-src.sh \ + mv/childproof.sh \ + mv/diag.sh \ + mv/dir-file.sh \ + mv/dir2dir.sh \ + mv/dup-source.sh \ + mv/force.sh \ + mv/hard-2.sh \ + mv/hard-3.sh \ + mv/hard-4.sh \ + mv/hard-link-1.sh \ + mv/hard-verbose.sh \ + mv/i-1.pl \ + mv/i-2.sh \ + mv/i-3.sh \ + mv/i-4.sh \ + mv/i-5.sh \ + mv/i-link-no.sh \ + mv/into-self.sh \ + mv/into-self-2.sh \ + mv/into-self-3.sh \ + mv/into-self-4.sh \ + mv/leak-fd.sh \ + mv/mv-n.sh \ + mv/mv-special-1.sh \ + mv/no-target-dir.sh \ + mv/part-fail.sh \ + mv/part-hardlink.sh \ + mv/part-rename.sh \ + mv/part-symlink.sh \ + mv/partition-perm.sh \ + mv/perm-1.sh \ + mv/symlink-onto-hardlink.sh \ + mv/symlink-onto-hardlink-to-self.sh \ + mv/to-symlink.sh \ + mv/trailing-slash.sh \ + mv/update.sh \ + readlink/can-e.sh \ + readlink/can-f.sh \ + readlink/can-m.sh \ + readlink/rl-1.sh \ + rmdir/fail-perm.sh \ + rmdir/ignore.sh \ + rmdir/t-slash.sh \ + tail-2/assert-2.sh \ + tail-2/big-4gb.sh \ + tail-2/flush-initial.sh \ + tail-2/follow-name.sh \ + tail-2/follow-stdin.sh \ + tail-2/pipe-f.sh \ + tail-2/pipe-f2.sh \ + tail-2/proc-ksyms.sh \ + tail-2/start-middle.sh \ + touch/60-seconds.sh \ + touch/dangling-symlink.sh \ + touch/dir-1.sh \ + touch/fail-diag.sh \ + touch/fifo.sh \ + touch/no-create-missing.sh \ + touch/no-dereference.sh \ + touch/no-rights.sh \ + touch/not-owner.sh \ + touch/obsolescent.sh \ + touch/read-only.sh \ + touch/relative.sh \ + touch/trailing-slash.sh \ $(root_tests) pr_data = \ diff --git a/tests/chgrp/basic b/tests/chgrp/basic deleted file mode 100755 index 8ce2f2ddc..000000000 --- a/tests/chgrp/basic +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh -# make sure chgrp is reasonable - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - - -set _ $groups; shift -g1=$1 -g2=$2 -mkdir d -touch f f2 d/f3 -chgrp $g1 f || fail=1 -chgrp $g2 f || fail=1 -chgrp $g2 f2 || fail=1 -chgrp -R $g1 d || fail=1 - -d_files='d d/f3' - -chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 -chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 -chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 -chgrp '' f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 -chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 -chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 -chgrp --reference=f2 f ; test $(stat --p=%g f) = $g2 || fail=1 - -chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 -chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 -chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 -chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 -chgrp $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g1:" || fail=1 - -rm -f f -touch f -ln -s f symlink -chgrp $g1 f -test $(stat --printf=%g f) = $g1 || fail=1 - -# This should not change the group of f. -chgrp -h $g2 symlink -test $(stat --printf=%g f) = $g1 || fail=1 - -# Don't fail if chgrp failed to set the group of a symlink. -# Some systems don't support that. -test $(stat --printf=%g symlink) = $g2 || - echo 'info: failed to set group of symlink' 1>&2 - -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# This *should* change the group of f. -# Though note that the diagnostic is misleading in that -# it says the 'group of 'symlink'' has been changed. -chgrp $g1 symlink; test $(stat --printf=%g f) = $g1 || fail=1 -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# If -R is specified without -H or L, -h is assumed. -chgrp -h $g1 f symlink; test $(stat --printf=%g symlink) = $g1 || fail=1 -chgrp -R $g2 symlink -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# Make sure we can change the group of inaccessible files. -chmod a-r f -chown --from=:$g2 :$g1 f; test $(stat --printf=%g f) = $g1 || fail=1 -chmod 0 f -chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 - -# chown() must not be optimized away even when -# the file's owner and group already have the desired value. -rm -f f g -touch f g -chgrp $g1 f g -chgrp $g2 g -sleep 1 -chgrp $g1 f - -# The following no-change chgrp command is supposed to update f's ctime, -# but on OpenBSD and Darwin 7.9.0-8.11.1 (aka MacOS X 10.3.9 - 10.4.11) -# it appears to be a no-op for some file system types (at least NFS) so g's -# ctime is more recent. This is not a big deal; -# this test works fine when the files are on a local file system (/tmp). -chgrp '' f -test "$(ls -C -c -t f g)" = 'f g' || \ - { - case $host_triplet in - *openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;; - *darwin7.9.*|*darwin8.*) - echo ignoring known MacOS X-specific chgrp failure 1>&2 ;; - *) echo $host_triplet: no-change chgrp failed to update ctime 1>&2; - fail=1 ;; - esac - } - -Exit $fail diff --git a/tests/chgrp/basic.sh b/tests/chgrp/basic.sh new file mode 100755 index 000000000..8ce2f2ddc --- /dev/null +++ b/tests/chgrp/basic.sh @@ -0,0 +1,110 @@ +#!/bin/sh +# make sure chgrp is reasonable + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + + +set _ $groups; shift +g1=$1 +g2=$2 +mkdir d +touch f f2 d/f3 +chgrp $g1 f || fail=1 +chgrp $g2 f || fail=1 +chgrp $g2 f2 || fail=1 +chgrp -R $g1 d || fail=1 + +d_files='d d/f3' + +chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 +chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 +chgrp $g2 f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 +chgrp '' f || fail=1 ; test $(stat --p=%g f) = $g2 || fail=1 +chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 +chgrp $g1 f || fail=1 ; test $(stat --p=%g f) = $g1 || fail=1 +chgrp --reference=f2 f ; test $(stat --p=%g f) = $g2 || fail=1 + +chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 +chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 +chgrp -R $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g2:" || fail=1 +chgrp -R $g1 d ||fail=1; test $(stat --p=%g: $d_files) = "$g1:$g1:" || fail=1 +chgrp $g2 d ||fail=1; test $(stat --p=%g: $d_files) = "$g2:$g1:" || fail=1 + +rm -f f +touch f +ln -s f symlink +chgrp $g1 f +test $(stat --printf=%g f) = $g1 || fail=1 + +# This should not change the group of f. +chgrp -h $g2 symlink +test $(stat --printf=%g f) = $g1 || fail=1 + +# Don't fail if chgrp failed to set the group of a symlink. +# Some systems don't support that. +test $(stat --printf=%g symlink) = $g2 || + echo 'info: failed to set group of symlink' 1>&2 + +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# This *should* change the group of f. +# Though note that the diagnostic is misleading in that +# it says the 'group of 'symlink'' has been changed. +chgrp $g1 symlink; test $(stat --printf=%g f) = $g1 || fail=1 +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# If -R is specified without -H or L, -h is assumed. +chgrp -h $g1 f symlink; test $(stat --printf=%g symlink) = $g1 || fail=1 +chgrp -R $g2 symlink +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# Make sure we can change the group of inaccessible files. +chmod a-r f +chown --from=:$g2 :$g1 f; test $(stat --printf=%g f) = $g1 || fail=1 +chmod 0 f +chown --from=:$g1 :$g2 f; test $(stat --printf=%g f) = $g2 || fail=1 + +# chown() must not be optimized away even when +# the file's owner and group already have the desired value. +rm -f f g +touch f g +chgrp $g1 f g +chgrp $g2 g +sleep 1 +chgrp $g1 f + +# The following no-change chgrp command is supposed to update f's ctime, +# but on OpenBSD and Darwin 7.9.0-8.11.1 (aka MacOS X 10.3.9 - 10.4.11) +# it appears to be a no-op for some file system types (at least NFS) so g's +# ctime is more recent. This is not a big deal; +# this test works fine when the files are on a local file system (/tmp). +chgrp '' f +test "$(ls -C -c -t f g)" = 'f g' || \ + { + case $host_triplet in + *openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;; + *darwin7.9.*|*darwin8.*) + echo ignoring known MacOS X-specific chgrp failure 1>&2 ;; + *) echo $host_triplet: no-change chgrp failed to update ctime 1>&2; + fail=1 ;; + esac + } + +Exit $fail diff --git a/tests/chgrp/default-no-deref b/tests/chgrp/default-no-deref deleted file mode 100755 index 5d140a8da..000000000 --- a/tests/chgrp/default-no-deref +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Ensure that chgrp -R does not dereference symlinks. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g2=$2 - -mkdir d && touch f && ln -s ../f d/s || framework_failure_ - - -g_init=$(stat --printf=%g f) -chgrp -R $g2 d || fail=1 -test $(stat --printf=%g f) = $g_init || fail=1 - -Exit $fail diff --git a/tests/chgrp/default-no-deref.sh b/tests/chgrp/default-no-deref.sh new file mode 100755 index 000000000..5d140a8da --- /dev/null +++ b/tests/chgrp/default-no-deref.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Ensure that chgrp -R does not dereference symlinks. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g2=$2 + +mkdir d && touch f && ln -s ../f d/s || framework_failure_ + + +g_init=$(stat --printf=%g f) +chgrp -R $g2 d || fail=1 +test $(stat --printf=%g f) = $g_init || fail=1 + +Exit $fail diff --git a/tests/chgrp/deref b/tests/chgrp/deref deleted file mode 100755 index 4c186ee82..000000000 --- a/tests/chgrp/deref +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# see if chgrp can change the group of a symlink - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g1=$1 -g2=$2 - -touch f -ln -s f symlink - -chgrp -h $g2 symlink 2> /dev/null -set _ $(ls -ln symlink) -g=$5 -test "$g" = $g2 || - skip_ "your system doesn't support changing the owner or group" \ - "of a symbolic link." - - -chgrp $g1 f -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 - -chgrp -h $g2 symlink || fail=1 -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 -set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 - -# This should not change the group of f. -chgrp -h $g2 symlink || fail=1 -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 -set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 - -chgrp $g2 f -set _ $(ls -ln f); g=$5; test "$g" = $g2 || fail=1 - -# This *should* change the group of f. -# Though note that the diagnostic you'd get with -c is misleading in that -# it says the 'group of 'symlink'' has been changed. -chgrp --dereference $g1 symlink -set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 -set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 - -Exit $fail diff --git a/tests/chgrp/deref.sh b/tests/chgrp/deref.sh new file mode 100755 index 000000000..4c186ee82 --- /dev/null +++ b/tests/chgrp/deref.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# see if chgrp can change the group of a symlink + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g1=$1 +g2=$2 + +touch f +ln -s f symlink + +chgrp -h $g2 symlink 2> /dev/null +set _ $(ls -ln symlink) +g=$5 +test "$g" = $g2 || + skip_ "your system doesn't support changing the owner or group" \ + "of a symbolic link." + + +chgrp $g1 f +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 + +chgrp -h $g2 symlink || fail=1 +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 +set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 + +# This should not change the group of f. +chgrp -h $g2 symlink || fail=1 +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 +set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 + +chgrp $g2 f +set _ $(ls -ln f); g=$5; test "$g" = $g2 || fail=1 + +# This *should* change the group of f. +# Though note that the diagnostic you'd get with -c is misleading in that +# it says the 'group of 'symlink'' has been changed. +chgrp --dereference $g1 symlink +set _ $(ls -ln f); g=$5; test "$g" = $g1 || fail=1 +set _ $(ls -ln symlink); g=$5; test "$g" = $g2 || fail=1 + +Exit $fail diff --git a/tests/chgrp/no-x b/tests/chgrp/no-x deleted file mode 100755 index 6e9347f99..000000000 --- a/tests/chgrp/no-x +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Make sure chgrp gives the right diagnostic for a readable, -# but inaccessible directory. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ -skip_if_root_ - -set _ $groups; shift -g1=$1 -g2=$2 - -mkdir -p d/no-x/y || framework_failure_ -chmod u=rw d/no-x || framework_failure_ - - -# This must exit nonzero. -chgrp -R $g2 d >/dev/null 2>out && fail=1 - -prog=chgrp -# NOTE: this code is the same for all tests/*/no-x tests. -# Depending on whether fts is using native fdopendir, we see one -# of the following diagnostics (note also the /y suffix in one case): -# prog: 'd/no-x': Permission denied -# prog: cannot access 'd/no-x/y': Permission denied -# prog: cannot read directory 'd/no-x': Permission denied -# Convert either of the latter two to the first one. -sed "s/^$prog: cannot access /$prog: /" out > t && mv t out -sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out -sed 's,d/no-x/y,d/no-x,' out > t && mv t out - -cat < exp -$prog: 'd/no-x': Permission denied -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/chgrp/no-x.sh b/tests/chgrp/no-x.sh new file mode 100755 index 000000000..6e9347f99 --- /dev/null +++ b/tests/chgrp/no-x.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Make sure chgrp gives the right diagnostic for a readable, +# but inaccessible directory. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ +skip_if_root_ + +set _ $groups; shift +g1=$1 +g2=$2 + +mkdir -p d/no-x/y || framework_failure_ +chmod u=rw d/no-x || framework_failure_ + + +# This must exit nonzero. +chgrp -R $g2 d >/dev/null 2>out && fail=1 + +prog=chgrp +# NOTE: this code is the same for all tests/*/no-x tests. +# Depending on whether fts is using native fdopendir, we see one +# of the following diagnostics (note also the /y suffix in one case): +# prog: 'd/no-x': Permission denied +# prog: cannot access 'd/no-x/y': Permission denied +# prog: cannot read directory 'd/no-x': Permission denied +# Convert either of the latter two to the first one. +sed "s/^$prog: cannot access /$prog: /" out > t && mv t out +sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out +sed 's,d/no-x/y,d/no-x,' out > t && mv t out + +cat < exp +$prog: 'd/no-x': Permission denied +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/chgrp/posix-H b/tests/chgrp/posix-H deleted file mode 100755 index 3965f1ff5..000000000 --- a/tests/chgrp/posix-H +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# Test POSIX-mandated -H option. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g1=$1 -g2=$2 - -mkdir 1 2 3 || framework_failure_ -touch 1/1F 2/2F 3/3F || framework_failure_ -ln -s 1 1s || framework_failure_ -ln -s ../3 2/2s || framework_failure_ -chgrp -R $g1 1 2 3 || framework_failure_ - - -chgrp --preserve-root -H -R $g2 1s 2 || fail=1 - -# These must have group $g2. -# ========================= -changed=' -1 -1/1F -2 -2/2F -3 -' -for i in $changed; do - # Filter out symlinks (entries that end in 's'), since it's not - # possible to change their group/owner information on some systems. - case $i in *s) continue;; esac - set _ $(ls -dgn $i); shift - group=$3 - test $group = $g2 || fail=1 -done - -# These must have group $g1. -# ========================= -not_changed=' -1s -2/2s -3/3F -' -for i in $not_changed; do - # Filter out symlinks (entries that end in 's'), since it's not - # possible to change their group/owner information on some systems. - case $i in *s) continue;; esac - set _ $(ls -dgn $i); shift - group=$3 - test $group = $g1 || fail=1 -done - -Exit $fail diff --git a/tests/chgrp/posix-H.sh b/tests/chgrp/posix-H.sh new file mode 100755 index 000000000..3965f1ff5 --- /dev/null +++ b/tests/chgrp/posix-H.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Test POSIX-mandated -H option. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g1=$1 +g2=$2 + +mkdir 1 2 3 || framework_failure_ +touch 1/1F 2/2F 3/3F || framework_failure_ +ln -s 1 1s || framework_failure_ +ln -s ../3 2/2s || framework_failure_ +chgrp -R $g1 1 2 3 || framework_failure_ + + +chgrp --preserve-root -H -R $g2 1s 2 || fail=1 + +# These must have group $g2. +# ========================= +changed=' +1 +1/1F +2 +2/2F +3 +' +for i in $changed; do + # Filter out symlinks (entries that end in 's'), since it's not + # possible to change their group/owner information on some systems. + case $i in *s) continue;; esac + set _ $(ls -dgn $i); shift + group=$3 + test $group = $g2 || fail=1 +done + +# These must have group $g1. +# ========================= +not_changed=' +1s +2/2s +3/3F +' +for i in $not_changed; do + # Filter out symlinks (entries that end in 's'), since it's not + # possible to change their group/owner information on some systems. + case $i in *s) continue;; esac + set _ $(ls -dgn $i); shift + group=$3 + test $group = $g1 || fail=1 +done + +Exit $fail diff --git a/tests/chgrp/recurse b/tests/chgrp/recurse deleted file mode 100755 index 95a910f6c..000000000 --- a/tests/chgrp/recurse +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# ad-hoc tests of chgrp with -R and -H or -L and symlinks - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp -require_membership_in_two_groups_ - -set _ $groups; shift -g1=$1 -g2=$2 - - -# chgrp -R should not traverse a symlink to a directory. -mkdir d e -touch d/dd e/ee -ln -s ../e d/s -chgrp -R $g1 e/ee || fail=1 -# This should not should change the group of e/ee -chgrp -R $g2 d -set _ $(ls -ln e/ee); g=$5; test "$g" = $g1 || fail=1 -# This must change the group of e/ee, since -L makes -# chgrp traverse the symlink from d/s into e. -chgrp -L -R $g2 d -set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 - -# This must *not* change the group of e/ee -chgrp -H -R $g1 d -set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 - -ln -s d link - -# This shouldn't change the group of e/ee either. -chgrp -H -R $g1 link || fail=1 -set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 -# But it *should* change d/dd. -set _ $(ls -ln d/dd); g=$5; test "$g" = $g1 || fail=1 - -Exit $fail diff --git a/tests/chgrp/recurse.sh b/tests/chgrp/recurse.sh new file mode 100755 index 000000000..95a910f6c --- /dev/null +++ b/tests/chgrp/recurse.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# ad-hoc tests of chgrp with -R and -H or -L and symlinks + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp +require_membership_in_two_groups_ + +set _ $groups; shift +g1=$1 +g2=$2 + + +# chgrp -R should not traverse a symlink to a directory. +mkdir d e +touch d/dd e/ee +ln -s ../e d/s +chgrp -R $g1 e/ee || fail=1 +# This should not should change the group of e/ee +chgrp -R $g2 d +set _ $(ls -ln e/ee); g=$5; test "$g" = $g1 || fail=1 +# This must change the group of e/ee, since -L makes +# chgrp traverse the symlink from d/s into e. +chgrp -L -R $g2 d +set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 + +# This must *not* change the group of e/ee +chgrp -H -R $g1 d +set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 + +ln -s d link + +# This shouldn't change the group of e/ee either. +chgrp -H -R $g1 link || fail=1 +set _ $(ls -ln e/ee); g=$5; test "$g" = $g2 || fail=1 +# But it *should* change d/dd. +set _ $(ls -ln d/dd); g=$5; test "$g" = $g1 || fail=1 + +Exit $fail diff --git a/tests/chmod/c-option b/tests/chmod/c-option deleted file mode 100755 index 0fc83912a..000000000 --- a/tests/chmod/c-option +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Verify that chmod's --changes (-c) option works. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - -umask 0 -file=f -touch $file || framework_failure_ -chmod 444 $file || framework_failure_ - -skip_if_setgid_ - - -chmod u=rwx $file || fail=1 -chmod -c g=rwx $file > out || fail=1 -chmod -c g=rwx $file > empty || fail=1 - -test -s empty && fail=1 -case "$(cat out)" in - "mode of 'f' changed from 0744 "?rwxr--r--?" to 0774 "?rwxrwxr--?) ;; - *) cat out; fail=1 ;; -esac - -Exit $fail diff --git a/tests/chmod/c-option.sh b/tests/chmod/c-option.sh new file mode 100755 index 000000000..0fc83912a --- /dev/null +++ b/tests/chmod/c-option.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Verify that chmod's --changes (-c) option works. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + +umask 0 +file=f +touch $file || framework_failure_ +chmod 444 $file || framework_failure_ + +skip_if_setgid_ + + +chmod u=rwx $file || fail=1 +chmod -c g=rwx $file > out || fail=1 +chmod -c g=rwx $file > empty || fail=1 + +test -s empty && fail=1 +case "$(cat out)" in + "mode of 'f' changed from 0744 "?rwxr--r--?" to 0774 "?rwxrwxr--?) ;; + *) cat out; fail=1 ;; +esac + +Exit $fail diff --git a/tests/chmod/equal-x b/tests/chmod/equal-x deleted file mode 100755 index e2cac3478..000000000 --- a/tests/chmod/equal-x +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Test "chmod =x" and the like. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - -file=f -touch $file || framework_failure_ - -umask 005 -for mode in =x =xX =Xx =x,=X =X,=x; do - chmod a=r,$mode $file || fail=1 - case "$(ls -l $file)" in - ---x--x---*) ;; - *) fail=1; echo "after 'chmod $mode $file':"; ls -l $file ;; - esac -done - -Exit $fail diff --git a/tests/chmod/equal-x.sh b/tests/chmod/equal-x.sh new file mode 100755 index 000000000..e2cac3478 --- /dev/null +++ b/tests/chmod/equal-x.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Test "chmod =x" and the like. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + +file=f +touch $file || framework_failure_ + +umask 005 +for mode in =x =xX =Xx =x,=X =X,=x; do + chmod a=r,$mode $file || fail=1 + case "$(ls -l $file)" in + ---x--x---*) ;; + *) fail=1; echo "after 'chmod $mode $file':"; ls -l $file ;; + esac +done + +Exit $fail diff --git a/tests/chmod/equals b/tests/chmod/equals deleted file mode 100755 index fd92055c2..000000000 --- a/tests/chmod/equals +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# Make sure chmod mode arguments of the form A=B work properly. -# Before fileutils-4.1.2, some of them didn't. -# Also, before coreutils-5.3.1, =[ugo] sometimes didn't work. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - -touch f || framework_failure_ - - -expected_u=-rwx------ -expected_g=----rwx--- -expected_o=-------rwx - -for src in u g o; do - for dest in u g o; do - test $dest = $src && continue - chmod a=,$src=rwx,$dest=$src,$src= f || fail=1 - actual_perms=$(ls -l f|cut -b-10) - expected_perms=$(eval 'echo $expected_'$dest) - test "$actual_perms" = "$expected_perms" || fail=1 - done -done - -umask 027 -chmod a=,u=rwx,=u f || fail=1 -actual_perms=$(ls -l f|cut -b-10) -test "$actual_perms" = "-rwxr-x---" || fail=1 - -Exit $fail diff --git a/tests/chmod/equals.sh b/tests/chmod/equals.sh new file mode 100755 index 000000000..fd92055c2 --- /dev/null +++ b/tests/chmod/equals.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Make sure chmod mode arguments of the form A=B work properly. +# Before fileutils-4.1.2, some of them didn't. +# Also, before coreutils-5.3.1, =[ugo] sometimes didn't work. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + +touch f || framework_failure_ + + +expected_u=-rwx------ +expected_g=----rwx--- +expected_o=-------rwx + +for src in u g o; do + for dest in u g o; do + test $dest = $src && continue + chmod a=,$src=rwx,$dest=$src,$src= f || fail=1 + actual_perms=$(ls -l f|cut -b-10) + expected_perms=$(eval 'echo $expected_'$dest) + test "$actual_perms" = "$expected_perms" || fail=1 + done +done + +umask 027 +chmod a=,u=rwx,=u f || fail=1 +actual_perms=$(ls -l f|cut -b-10) +test "$actual_perms" = "-rwxr-x---" || fail=1 + +Exit $fail diff --git a/tests/chmod/inaccessible b/tests/chmod/inaccessible deleted file mode 100755 index c90406803..000000000 --- a/tests/chmod/inaccessible +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Test for the bug fixed on 2006-09-20. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - -mkdir -p d/e || framework_failure_ -chmod 0 d/e d || framework_failure_ - - -chmod u+rwx d d/e || fail=1 - -Exit $fail diff --git a/tests/chmod/inaccessible.sh b/tests/chmod/inaccessible.sh new file mode 100755 index 000000000..c90406803 --- /dev/null +++ b/tests/chmod/inaccessible.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Test for the bug fixed on 2006-09-20. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + +mkdir -p d/e || framework_failure_ +chmod 0 d/e d || framework_failure_ + + +chmod u+rwx d d/e || fail=1 + +Exit $fail diff --git a/tests/chmod/no-x b/tests/chmod/no-x deleted file mode 100755 index e802b356f..000000000 --- a/tests/chmod/no-x +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# Make sure chmod gives the right diagnostic for a readable, -# but inaccessible directory. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod -skip_if_root_ - -mkdir -p d/no-x/y a/b || framework_failure_ -chmod u=rw d/no-x || framework_failure_ - - -# This must exit nonzero. -chmod -R o=r d >/dev/null 2>out && fail=1 - -prog=chmod -# NOTE: this code is the same for all tests/*/no-x tests. -# Depending on whether fts is using native fdopendir, we see one -# of the following diagnostics (note also the /y suffix in one case): -# prog: 'd/no-x': Permission denied -# prog: cannot access 'd/no-x/y': Permission denied -# prog: cannot read directory 'd/no-x': Permission denied -# Convert either of the latter two to the first one. -sed "s/^$prog: cannot access /$prog: /" out > t && mv t out -sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out -sed 's,d/no-x/y,d/no-x,' out > t && mv t out - -cat < exp -$prog: 'd/no-x': Permission denied -EOF - -compare exp out || fail=1 - -cd a -# This will fail with ''chmod: fts_read failed: Permission denied'' -chmod a-x . b 2> /dev/null && fail=1 -# chmod must exit with status 1. -# Due to a bug in coreutils-5.93's fts.c, chmod would provoke -# an abort (exit with status 134) on recent glibc-based systems. -test $? = 1 || fail=1 - -Exit $fail diff --git a/tests/chmod/no-x.sh b/tests/chmod/no-x.sh new file mode 100755 index 000000000..e802b356f --- /dev/null +++ b/tests/chmod/no-x.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Make sure chmod gives the right diagnostic for a readable, +# but inaccessible directory. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod +skip_if_root_ + +mkdir -p d/no-x/y a/b || framework_failure_ +chmod u=rw d/no-x || framework_failure_ + + +# This must exit nonzero. +chmod -R o=r d >/dev/null 2>out && fail=1 + +prog=chmod +# NOTE: this code is the same for all tests/*/no-x tests. +# Depending on whether fts is using native fdopendir, we see one +# of the following diagnostics (note also the /y suffix in one case): +# prog: 'd/no-x': Permission denied +# prog: cannot access 'd/no-x/y': Permission denied +# prog: cannot read directory 'd/no-x': Permission denied +# Convert either of the latter two to the first one. +sed "s/^$prog: cannot access /$prog: /" out > t && mv t out +sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out +sed 's,d/no-x/y,d/no-x,' out > t && mv t out + +cat < exp +$prog: 'd/no-x': Permission denied +EOF + +compare exp out || fail=1 + +cd a +# This will fail with ''chmod: fts_read failed: Permission denied'' +chmod a-x . b 2> /dev/null && fail=1 +# chmod must exit with status 1. +# Due to a bug in coreutils-5.93's fts.c, chmod would provoke +# an abort (exit with status 134) on recent glibc-based systems. +test $? = 1 || fail=1 + +Exit $fail diff --git a/tests/chmod/octal b/tests/chmod/octal deleted file mode 100755 index 845116b26..000000000 --- a/tests/chmod/octal +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# ensure that chmod diagnoses a certain type of invalid mode string - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - - -# Before coreutils-5.92, this would mistakenly succeed, -# and act like 'chmod 0 .'. -chmod 0-followed-by-anything . 2> /dev/null && fail=1 -chmod 7-followed-by-anything . 2> /dev/null && fail=1 -chmod 8 . 2> /dev/null && fail=1 - -Exit $fail diff --git a/tests/chmod/octal.sh b/tests/chmod/octal.sh new file mode 100755 index 000000000..845116b26 --- /dev/null +++ b/tests/chmod/octal.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# ensure that chmod diagnoses a certain type of invalid mode string + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + + +# Before coreutils-5.92, this would mistakenly succeed, +# and act like 'chmod 0 .'. +chmod 0-followed-by-anything . 2> /dev/null && fail=1 +chmod 7-followed-by-anything . 2> /dev/null && fail=1 +chmod 8 . 2> /dev/null && fail=1 + +Exit $fail diff --git a/tests/chmod/setgid b/tests/chmod/setgid deleted file mode 100755 index 7fc6db214..000000000 --- a/tests/chmod/setgid +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -# Make sure GNU chmod works the same way as those of Solaris, HPUX, AIX -# on directories with the setgid bit set. Also, check that the GNU octal -# notations work. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - -umask 0 -mkdir -m 755 d || framework_failure_ - -chmod g+s d 2> /dev/null && env -- test -g d || - { - # This is required because on some systems (at least NetBSD 1.4.2A), - # it may happen that when you create a directory, its group isn't one - # to which you belong. When that happens, the above chmod fails. So - # here, upon failure, we try to set the group, then rerun the chmod command. - - id_g=$(id -g) && - test -n "$id_g" && - chgrp "$id_g" d && - chmod g+s d || framework_failure_ - } - -# "chmod g+s d" does nothing on some NFS file systems. -env -- test -g d || - skip_ 'cannot create setgid directories' - -for mode in \ - + - g-s 00755 000755 =755 -2000 -7022 755 0755 \ - +2000 -5022 =7777,-5022 -do - chmod $mode d || fail=1 - - case $mode in - g-s | 00*755 | =755 | -2000 | -7022) - expected_mode=drwxr-xr-x ;; - *) expected_mode=drwxr-sr-x ;; - esac - ls_output=$(ls -ld d) - case $ls_output in - $expected_mode*) ;; - *) fail=1 ;; - esac - - chmod =2755 d || fail=1 -done - -Exit $fail diff --git a/tests/chmod/setgid.sh b/tests/chmod/setgid.sh new file mode 100755 index 000000000..7fc6db214 --- /dev/null +++ b/tests/chmod/setgid.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# Make sure GNU chmod works the same way as those of Solaris, HPUX, AIX +# on directories with the setgid bit set. Also, check that the GNU octal +# notations work. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + +umask 0 +mkdir -m 755 d || framework_failure_ + +chmod g+s d 2> /dev/null && env -- test -g d || + { + # This is required because on some systems (at least NetBSD 1.4.2A), + # it may happen that when you create a directory, its group isn't one + # to which you belong. When that happens, the above chmod fails. So + # here, upon failure, we try to set the group, then rerun the chmod command. + + id_g=$(id -g) && + test -n "$id_g" && + chgrp "$id_g" d && + chmod g+s d || framework_failure_ + } + +# "chmod g+s d" does nothing on some NFS file systems. +env -- test -g d || + skip_ 'cannot create setgid directories' + +for mode in \ + + - g-s 00755 000755 =755 -2000 -7022 755 0755 \ + +2000 -5022 =7777,-5022 +do + chmod $mode d || fail=1 + + case $mode in + g-s | 00*755 | =755 | -2000 | -7022) + expected_mode=drwxr-xr-x ;; + *) expected_mode=drwxr-sr-x ;; + esac + ls_output=$(ls -ld d) + case $ls_output in + $expected_mode*) ;; + *) fail=1 ;; + esac + + chmod =2755 d || fail=1 +done + +Exit $fail diff --git a/tests/chmod/silent b/tests/chmod/silent deleted file mode 100755 index 00e2348fc..000000000 --- a/tests/chmod/silent +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# ensure that chgrp, chmod, chown -f don't print some diagnostics - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chgrp chmod chown - -chmod -f 0 no-such 2> out && fail=1 -chgrp -f 0 no-such 2>> out && fail=1 -chown -f 0:0 no-such 2>> out && fail=1 -touch exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/chmod/silent.sh b/tests/chmod/silent.sh new file mode 100755 index 000000000..00e2348fc --- /dev/null +++ b/tests/chmod/silent.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# ensure that chgrp, chmod, chown -f don't print some diagnostics + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chgrp chmod chown + +chmod -f 0 no-such 2> out && fail=1 +chgrp -f 0 no-such 2>> out && fail=1 +chown -f 0:0 no-such 2>> out && fail=1 +touch exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/chmod/thru-dangling b/tests/chmod/thru-dangling deleted file mode 100755 index 78124009f..000000000 --- a/tests/chmod/thru-dangling +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Test for proper error and exit code of chmod on a dangling symlink. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - -ln -s non-existent dangle || framework_failure_ - - -# This operation cannot succeed since the symbolic link dangles. -chmod 644 dangle 2> out && fail=1 - -echo "chmod: cannot operate on dangling symlink 'dangle'" > exp -compare exp out || fail=1 - -Exit $fail diff --git a/tests/chmod/thru-dangling.sh b/tests/chmod/thru-dangling.sh new file mode 100755 index 000000000..78124009f --- /dev/null +++ b/tests/chmod/thru-dangling.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Test for proper error and exit code of chmod on a dangling symlink. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + +ln -s non-existent dangle || framework_failure_ + + +# This operation cannot succeed since the symbolic link dangles. +chmod 644 dangle 2> out && fail=1 + +echo "chmod: cannot operate on dangling symlink 'dangle'" > exp +compare exp out || fail=1 + +Exit $fail diff --git a/tests/chmod/umask-x b/tests/chmod/umask-x deleted file mode 100755 index dc133e183..000000000 --- a/tests/chmod/umask-x +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Test that chmod -x file reports an error if the result is executable. - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - -touch file -chmod 755 file -(umask 77 && chmod -x file) 2>/dev/null && fail=1 - -Exit $fail diff --git a/tests/chmod/umask-x.sh b/tests/chmod/umask-x.sh new file mode 100755 index 000000000..dc133e183 --- /dev/null +++ b/tests/chmod/umask-x.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Test that chmod -x file reports an error if the result is executable. + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + +touch file +chmod 755 file +(umask 77 && chmod -x file) 2>/dev/null && fail=1 + +Exit $fail diff --git a/tests/chmod/usage b/tests/chmod/usage deleted file mode 100755 index 9dd65f7cc..000000000 --- a/tests/chmod/usage +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh -# Verify that chmod works correctly with odd option combinations. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chmod - - -# Each line in this list is a set of arguments, followed by :, -# followed by the set of files it will attempt to chmod, -# or empty if the usage is erroneous. -# Many of these test cases are due to Glenn Fowler. -# These test cases assume GNU behavior for "options" like -w. -cases=' - -- : - -- -- : - -- -- -- f : -- f - -- -- -w f : -w f - -- -- f : f - -- -w : - -- -w -- f : -- f - -- -w -w f : -w f - -- -w f : f - -- f : - -w : - -w -- : - -w -- -- f : -- f - -w -- -w f : -w f - -w -- f : f - -w -w : - -w -w -- f : f - -w -w -w f : f - -w -w f : f - -w f : f - f : - f -- : - f -w : f - f f : - u+gr f : - ug,+x f : -' - -all_files=$(echo "$cases" | sed 's/.*://'|sort -u) - -old_IFS=$IFS -IFS=' -' -for case in $cases; do - IFS=$old_IFS - args=$(expr "$case" : ' *\(.*[^ ]\) *:') - files=$(expr "$case" : '.*: *\(.*\)') - - case $files in - '') - touch -- $all_files || framework_failure_ - chmod $args 2>/dev/null && fail=1 - ;; - ?*) - touch -- $files || framework_failure_ - chmod $args || fail=1 - for file in $files; do - # Test for misparsing args by creating all $files but $file. - # chmod has a bug if it succeeds even though $file is absent. - rm -f -- $all_files && touch -- $files && rm -- $file \ - || framework_failure_ - chmod $args 2>/dev/null && fail=1 - done - ;; - esac -done - -Exit $fail diff --git a/tests/chmod/usage.sh b/tests/chmod/usage.sh new file mode 100755 index 000000000..9dd65f7cc --- /dev/null +++ b/tests/chmod/usage.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# Verify that chmod works correctly with odd option combinations. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chmod + + +# Each line in this list is a set of arguments, followed by :, +# followed by the set of files it will attempt to chmod, +# or empty if the usage is erroneous. +# Many of these test cases are due to Glenn Fowler. +# These test cases assume GNU behavior for "options" like -w. +cases=' + -- : + -- -- : + -- -- -- f : -- f + -- -- -w f : -w f + -- -- f : f + -- -w : + -- -w -- f : -- f + -- -w -w f : -w f + -- -w f : f + -- f : + -w : + -w -- : + -w -- -- f : -- f + -w -- -w f : -w f + -w -- f : f + -w -w : + -w -w -- f : f + -w -w -w f : f + -w -w f : f + -w f : f + f : + f -- : + f -w : f + f f : + u+gr f : + ug,+x f : +' + +all_files=$(echo "$cases" | sed 's/.*://'|sort -u) + +old_IFS=$IFS +IFS=' +' +for case in $cases; do + IFS=$old_IFS + args=$(expr "$case" : ' *\(.*[^ ]\) *:') + files=$(expr "$case" : '.*: *\(.*\)') + + case $files in + '') + touch -- $all_files || framework_failure_ + chmod $args 2>/dev/null && fail=1 + ;; + ?*) + touch -- $files || framework_failure_ + chmod $args || fail=1 + for file in $files; do + # Test for misparsing args by creating all $files but $file. + # chmod has a bug if it succeeds even though $file is absent. + rm -f -- $all_files && touch -- $files && rm -- $file \ + || framework_failure_ + chmod $args 2>/dev/null && fail=1 + done + ;; + esac +done + +Exit $fail diff --git a/tests/chown/basic b/tests/chown/basic deleted file mode 100755 index 6225400e1..000000000 --- a/tests/chown/basic +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# make sure chown --from=... works - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chown -require_root_ - -touch f || framework_failure_ - -chown -R --preserve-root 0:1 f - -# Make sure the owner and group are 0 and 1 respectively. -set _ $(ls -n f); shift; test "$3:$4" = 0:1 || fail=1 - -# Make sure the correct diagnostic is output -# Note we output a name even though an id was specified. -chown -v --from=42 43 f > out || fail=1 -printf "ownership of 'f' retained as $(id -nu)\n" > exp -compare exp out || fail=1 - -# Ensure diagnostics work for non existent files. -chown -v 0 nf > out && fail=1 -printf "failed to change ownership of 'nf' to 0\n" > exp -compare exp out || fail=1 - -chown --from=0:1 2:010 f || fail=1 - -# And now they should be 2 and 10 respectively. -set _ $(ls -n f); shift; test "$3:$4" = 2:10 || fail=1 - -ln -s f slink -# Applying chown to a symlink with --no-dereference -# should change only the link. -chown --no-dereference 0:1 slink || fail=1 -# owner/group on the symlink should be set -set _ $(ls -n slink); shift; test "$3:$4" = 0:1 || fail=1 -# owner/group on the referent should remain unchanged -set _ $(ls -n f); shift; test "$3:$4" = 2:10 || fail=1 - -chown --no-dereference --from=0:1 2:010 slink || fail=1 -# owner/group on the symlink should be changed -set _ $(ls -n slink); shift; test "$3:$4" = 2:10 || fail=1 - -Exit $fail diff --git a/tests/chown/basic.sh b/tests/chown/basic.sh new file mode 100755 index 000000000..6225400e1 --- /dev/null +++ b/tests/chown/basic.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# make sure chown --from=... works + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chown +require_root_ + +touch f || framework_failure_ + +chown -R --preserve-root 0:1 f + +# Make sure the owner and group are 0 and 1 respectively. +set _ $(ls -n f); shift; test "$3:$4" = 0:1 || fail=1 + +# Make sure the correct diagnostic is output +# Note we output a name even though an id was specified. +chown -v --from=42 43 f > out || fail=1 +printf "ownership of 'f' retained as $(id -nu)\n" > exp +compare exp out || fail=1 + +# Ensure diagnostics work for non existent files. +chown -v 0 nf > out && fail=1 +printf "failed to change ownership of 'nf' to 0\n" > exp +compare exp out || fail=1 + +chown --from=0:1 2:010 f || fail=1 + +# And now they should be 2 and 10 respectively. +set _ $(ls -n f); shift; test "$3:$4" = 2:10 || fail=1 + +ln -s f slink +# Applying chown to a symlink with --no-dereference +# should change only the link. +chown --no-dereference 0:1 slink || fail=1 +# owner/group on the symlink should be set +set _ $(ls -n slink); shift; test "$3:$4" = 0:1 || fail=1 +# owner/group on the referent should remain unchanged +set _ $(ls -n f); shift; test "$3:$4" = 2:10 || fail=1 + +chown --no-dereference --from=0:1 2:010 slink || fail=1 +# owner/group on the symlink should be changed +set _ $(ls -n slink); shift; test "$3:$4" = 2:10 || fail=1 + +Exit $fail diff --git a/tests/chown/deref b/tests/chown/deref deleted file mode 100755 index d42a05412..000000000 --- a/tests/chown/deref +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# For coreutils-5.2.1 and earlier, chown --dereference would skip -# symlinks having owner/group matching the specified owner/group. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chown - -ln -s no-such dangle || framework_failure_ - - -set _ $(ls -ldo dangle); shift; user=$3 - -# With 5.2.1 and earlier, this command would mistakenly succeed. -chown --dereference $user dangle 2> out1 && fail=1 -sed 's/: [^:]*$//' out1 > out - -cat <<\EOF > exp || fail=1 -chown: cannot dereference 'dangle' -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/chown/deref.sh b/tests/chown/deref.sh new file mode 100755 index 000000000..d42a05412 --- /dev/null +++ b/tests/chown/deref.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# For coreutils-5.2.1 and earlier, chown --dereference would skip +# symlinks having owner/group matching the specified owner/group. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chown + +ln -s no-such dangle || framework_failure_ + + +set _ $(ls -ldo dangle); shift; user=$3 + +# With 5.2.1 and earlier, this command would mistakenly succeed. +chown --dereference $user dangle 2> out1 && fail=1 +sed 's/: [^:]*$//' out1 > out + +cat <<\EOF > exp || fail=1 +chown: cannot dereference 'dangle' +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/chown/preserve-root b/tests/chown/preserve-root deleted file mode 100755 index ffad22228..000000000 --- a/tests/chown/preserve-root +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# Verify that --preserve-root works. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chown -skip_if_root_ - -mkdir d && ln -s / d/slink-to-root - - -# Even if --preserve-root were to malfunction, allowing the chown or -# chgrp to traverse through "/", since we're running as non-root, -# they would be very unlikely to cause any changes. -chown -R --preserve-root 0 / > out 2>&1 && fail=1 -chgrp -R --preserve-root 0 / >> out 2>&1 && fail=1 - -# Here, if --preserve-root were to malfunction, chmod could make changes, -# but only to files owned and unreadable by the user running this test, -# and then, only to make them readable by owner. -chmod -R --preserve-root u+r / >> out 2>&1 && fail=1 - -# With -RHh, --preserve-root should trigger nothing, -# since the symlink in question is not a command line argument. -# Contrary to the above commands, these two should succeed. -echo '==== test -RHh' >> out -chown -RHh --preserve-root $(id -u) d >> out 2>&1 || fail=1 -chgrp -RHh --preserve-root $(id -g) d >> out 2>&1 || fail=1 - -# These must fail. -echo '==== test -RLh' >> out -chown -RLh --preserve-root $(id -u) d >> out 2>&1 && fail=1 -chgrp -RLh --preserve-root $(id -g) d >> out 2>&1 && fail=1 - -cat <<\EOF > exp || fail=1 -chown: it is dangerous to operate recursively on '/' -chown: use --no-preserve-root to override this failsafe -chgrp: it is dangerous to operate recursively on '/' -chgrp: use --no-preserve-root to override this failsafe -chmod: it is dangerous to operate recursively on '/' -chmod: use --no-preserve-root to override this failsafe -==== test -RHh -==== test -RLh -chown: it is dangerous to operate recursively on 'd/slink-to-root' (same as '/') -chown: use --no-preserve-root to override this failsafe -chgrp: it is dangerous to operate recursively on 'd/slink-to-root' (same as '/') -chgrp: use --no-preserve-root to override this failsafe -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/chown/preserve-root.sh b/tests/chown/preserve-root.sh new file mode 100755 index 000000000..ffad22228 --- /dev/null +++ b/tests/chown/preserve-root.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# Verify that --preserve-root works. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chown +skip_if_root_ + +mkdir d && ln -s / d/slink-to-root + + +# Even if --preserve-root were to malfunction, allowing the chown or +# chgrp to traverse through "/", since we're running as non-root, +# they would be very unlikely to cause any changes. +chown -R --preserve-root 0 / > out 2>&1 && fail=1 +chgrp -R --preserve-root 0 / >> out 2>&1 && fail=1 + +# Here, if --preserve-root were to malfunction, chmod could make changes, +# but only to files owned and unreadable by the user running this test, +# and then, only to make them readable by owner. +chmod -R --preserve-root u+r / >> out 2>&1 && fail=1 + +# With -RHh, --preserve-root should trigger nothing, +# since the symlink in question is not a command line argument. +# Contrary to the above commands, these two should succeed. +echo '==== test -RHh' >> out +chown -RHh --preserve-root $(id -u) d >> out 2>&1 || fail=1 +chgrp -RHh --preserve-root $(id -g) d >> out 2>&1 || fail=1 + +# These must fail. +echo '==== test -RLh' >> out +chown -RLh --preserve-root $(id -u) d >> out 2>&1 && fail=1 +chgrp -RLh --preserve-root $(id -g) d >> out 2>&1 && fail=1 + +cat <<\EOF > exp || fail=1 +chown: it is dangerous to operate recursively on '/' +chown: use --no-preserve-root to override this failsafe +chgrp: it is dangerous to operate recursively on '/' +chgrp: use --no-preserve-root to override this failsafe +chmod: it is dangerous to operate recursively on '/' +chmod: use --no-preserve-root to override this failsafe +==== test -RHh +==== test -RLh +chown: it is dangerous to operate recursively on 'd/slink-to-root' (same as '/') +chown: use --no-preserve-root to override this failsafe +chgrp: it is dangerous to operate recursively on 'd/slink-to-root' (same as '/') +chgrp: use --no-preserve-root to override this failsafe +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/chown/separator b/tests/chown/separator deleted file mode 100755 index d4264a8c8..000000000 --- a/tests/chown/separator +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Make sure "chown USER:GROUP FILE" works, and similar tests with separators. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chown - -id_u=$(id -u) || framework_failure_ -test -n "$id_u" || framework_failure_ - -id_un=$(id -un) || framework_failure_ -test -n "$id_un" || framework_failure_ - -id_g=$(id -g) || framework_failure_ -test -n "$id_g" || framework_failure_ - -id_gn=$(id -gn) || framework_failure_ -test -n "$id_gn" || framework_failure_ - -# FreeBSD 6.x's getgrnam fails to look up a group name containing -# a space. On such a system, skip this test if the group name contains -# a byte not in the portable filename character set. -case $host_triplet in - *-freebsd6.*) - case $id_gn in - *[^a-zA-Z0-9._-]*) skip_ "invalid group name: $id_gn";; - esac;; - *) ;; -esac - - -chown '' . || fail=1 - -for u in $id_u "$id_un" ''; do - for g in $id_g "$id_gn" ''; do - case $u$g in - *.*) seps=':' ;; - *) seps=': .' ;; - esac - for sep in $seps; do - case $u$sep$g in - [0-9]*$sep) chown "$u$sep$g" . 2> /dev/null && fail=1 ;; - *) chown "$u$sep$g" . || fail=1 ;; - esac - done - done -done - -Exit $fail diff --git a/tests/chown/separator.sh b/tests/chown/separator.sh new file mode 100755 index 000000000..d4264a8c8 --- /dev/null +++ b/tests/chown/separator.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Make sure "chown USER:GROUP FILE" works, and similar tests with separators. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chown + +id_u=$(id -u) || framework_failure_ +test -n "$id_u" || framework_failure_ + +id_un=$(id -un) || framework_failure_ +test -n "$id_un" || framework_failure_ + +id_g=$(id -g) || framework_failure_ +test -n "$id_g" || framework_failure_ + +id_gn=$(id -gn) || framework_failure_ +test -n "$id_gn" || framework_failure_ + +# FreeBSD 6.x's getgrnam fails to look up a group name containing +# a space. On such a system, skip this test if the group name contains +# a byte not in the portable filename character set. +case $host_triplet in + *-freebsd6.*) + case $id_gn in + *[^a-zA-Z0-9._-]*) skip_ "invalid group name: $id_gn";; + esac;; + *) ;; +esac + + +chown '' . || fail=1 + +for u in $id_u "$id_un" ''; do + for g in $id_g "$id_gn" ''; do + case $u$g in + *.*) seps=':' ;; + *) seps=': .' ;; + esac + for sep in $seps; do + case $u$sep$g in + [0-9]*$sep) chown "$u$sep$g" . 2> /dev/null && fail=1 ;; + *) chown "$u$sep$g" . || fail=1 ;; + esac + done + done +done + +Exit $fail diff --git a/tests/cp/abuse b/tests/cp/abuse deleted file mode 100755 index 6338e1f57..000000000 --- a/tests/cp/abuse +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# ensure that cp does not write through a just-copied symlink - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir a b c || framework_failure_ -ln -s ../t a/1 || framework_failure_ -echo payload > b/1 || framework_failure_ - -echo "cp: will not copy 'b/1' through just-created symlink 'c/1'" \ - > exp || framework_failure_ - -# Check both cases: a dangling symlink, and one pointing to a writable file. - -for i in dangling-dest existing-dest; do - test $i = existing-dest && echo i > t - test $i = dangling-dest && rm -f t - - cp -dR a/1 b/1 c 2> out && fail=1 - - compare exp out || fail=1 - - # When the destination is a dangling symlink, - # ensure that cp does not create it. - test $i = dangling-dest \ - && test -f t && fail=1 - - # When the destination symlink points to a writable file, - # ensure that cp does not change it. - test $i = existing-dest \ - && case $(cat t) in i);; *) fail=1;; esac -done - -Exit $fail diff --git a/tests/cp/abuse.sh b/tests/cp/abuse.sh new file mode 100755 index 000000000..6338e1f57 --- /dev/null +++ b/tests/cp/abuse.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# ensure that cp does not write through a just-copied symlink + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir a b c || framework_failure_ +ln -s ../t a/1 || framework_failure_ +echo payload > b/1 || framework_failure_ + +echo "cp: will not copy 'b/1' through just-created symlink 'c/1'" \ + > exp || framework_failure_ + +# Check both cases: a dangling symlink, and one pointing to a writable file. + +for i in dangling-dest existing-dest; do + test $i = existing-dest && echo i > t + test $i = dangling-dest && rm -f t + + cp -dR a/1 b/1 c 2> out && fail=1 + + compare exp out || fail=1 + + # When the destination is a dangling symlink, + # ensure that cp does not create it. + test $i = dangling-dest \ + && test -f t && fail=1 + + # When the destination symlink points to a writable file, + # ensure that cp does not change it. + test $i = existing-dest \ + && case $(cat t) in i);; *) fail=1;; esac +done + +Exit $fail diff --git a/tests/cp/acl b/tests/cp/acl deleted file mode 100755 index 4520fc9c6..000000000 --- a/tests/cp/acl +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# copy files/directories across file system boundaries -# and make sure acls are preserved appropriately - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp getfacl setfacl - -require_acl_ - -# Skip this test if cp was built without ACL support: -grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null || - skip_ "insufficient ACL support" - -mkdir -p a b || framework_failure_ -touch a/file || framework_failure_ - -# Ensure that setfacl and getfacl work on this file system. -skip=no -acl1=$(cd a && getfacl file) || skip=yes -setfacl -m user:bin:rw- a/file 2> /dev/null || skip=yes -test $skip = yes && - skip_ "'.' is not on a suitable file system for this test" - -# copy a file without preserving permissions -cp a/file b/ || fail=1 -acl2=$(cd b && getfacl file) || framework_failure_ -test "$acl1" = "$acl2" || fail=1 - -# Update with acl set above -acl1=$(cd a && getfacl file) || framework_failure_ - -# copy a file, preserving permissions -cp -p a/file b/ || fail=1 -acl2=$(cd b && getfacl file) || framework_failure_ -test "$acl1" = "$acl2" || fail=1 - -# copy a file, preserving permissions, with --attributes-only -echo > a/file || framework_failure_ # add some data -test -s a/file || framework_failure_ -cp -p --attributes-only a/file b/ || fail=1 -test -s b/file && fail=1 -acl2=$(cd b && getfacl file) || framework_failure_ -test "$acl1" = "$acl2" || fail=1 - -Exit $fail diff --git a/tests/cp/acl.sh b/tests/cp/acl.sh new file mode 100755 index 000000000..4520fc9c6 --- /dev/null +++ b/tests/cp/acl.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# copy files/directories across file system boundaries +# and make sure acls are preserved appropriately + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp getfacl setfacl + +require_acl_ + +# Skip this test if cp was built without ACL support: +grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null || + skip_ "insufficient ACL support" + +mkdir -p a b || framework_failure_ +touch a/file || framework_failure_ + +# Ensure that setfacl and getfacl work on this file system. +skip=no +acl1=$(cd a && getfacl file) || skip=yes +setfacl -m user:bin:rw- a/file 2> /dev/null || skip=yes +test $skip = yes && + skip_ "'.' is not on a suitable file system for this test" + +# copy a file without preserving permissions +cp a/file b/ || fail=1 +acl2=$(cd b && getfacl file) || framework_failure_ +test "$acl1" = "$acl2" || fail=1 + +# Update with acl set above +acl1=$(cd a && getfacl file) || framework_failure_ + +# copy a file, preserving permissions +cp -p a/file b/ || fail=1 +acl2=$(cd b && getfacl file) || framework_failure_ +test "$acl1" = "$acl2" || fail=1 + +# copy a file, preserving permissions, with --attributes-only +echo > a/file || framework_failure_ # add some data +test -s a/file || framework_failure_ +cp -p --attributes-only a/file b/ || fail=1 +test -s b/file && fail=1 +acl2=$(cd b && getfacl file) || framework_failure_ +test "$acl1" = "$acl2" || fail=1 + +Exit $fail diff --git a/tests/cp/attr-existing b/tests/cp/attr-existing deleted file mode 100755 index 9cf0ffcb3..000000000 --- a/tests/cp/attr-existing +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Make sure cp --attributes-only doesn't truncate existing data - -# Copyright 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -printf '1' > file1 -printf '2' > file2 -printf '2' > file2.exp - -cp --attributes-only file1 file2 || fail=1 -cmp file2 file2.exp || fail=1 - -Exit $fail diff --git a/tests/cp/attr-existing.sh b/tests/cp/attr-existing.sh new file mode 100755 index 000000000..9cf0ffcb3 --- /dev/null +++ b/tests/cp/attr-existing.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Make sure cp --attributes-only doesn't truncate existing data + +# Copyright 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +printf '1' > file1 +printf '2' > file2 +printf '2' > file2.exp + +cp --attributes-only file1 file2 || fail=1 +cmp file2 file2.exp || fail=1 + +Exit $fail diff --git a/tests/cp/backup-1 b/tests/cp/backup-1 deleted file mode 100755 index c7ece5f4d..000000000 --- a/tests/cp/backup-1 +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Test cp backup. - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -suffix=.b -file=F -file_backup="$file$suffix" - -echo test > $file || fail=1 - -# Specify both version control and suffix so the environment variables -# (possibly set by the user running these tests) aren't used. -cp --force --backup=simple --suffix=$suffix $file $file || fail=1 -cp -T --force --backup=simple --suffix=$suffix $file $file || fail=1 - -test -f $file || fail=1 -test -f $file_backup || fail=1 -compare $file $file_backup > /dev/null || fail=1 - -Exit $fail diff --git a/tests/cp/backup-1.sh b/tests/cp/backup-1.sh new file mode 100755 index 000000000..c7ece5f4d --- /dev/null +++ b/tests/cp/backup-1.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Test cp backup. + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +suffix=.b +file=F +file_backup="$file$suffix" + +echo test > $file || fail=1 + +# Specify both version control and suffix so the environment variables +# (possibly set by the user running these tests) aren't used. +cp --force --backup=simple --suffix=$suffix $file $file || fail=1 +cp -T --force --backup=simple --suffix=$suffix $file $file || fail=1 + +test -f $file || fail=1 +test -f $file_backup || fail=1 +compare $file $file_backup > /dev/null || fail=1 + +Exit $fail diff --git a/tests/cp/backup-dir b/tests/cp/backup-dir deleted file mode 100755 index bc05bd9b0..000000000 --- a/tests/cp/backup-dir +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Ensure that cp -b doesn't back up directories. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir x y || framework_failure_ - - -cp -a x y || fail=1 - -# This would mistakenly create a backup of y/x (y/x~) in coreutils-6.3. -cp -ab x y || fail=1 -test -d y/x || fail=1 -test -d y/x~ && fail=1 - -Exit $fail diff --git a/tests/cp/backup-dir.sh b/tests/cp/backup-dir.sh new file mode 100755 index 000000000..bc05bd9b0 --- /dev/null +++ b/tests/cp/backup-dir.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Ensure that cp -b doesn't back up directories. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir x y || framework_failure_ + + +cp -a x y || fail=1 + +# This would mistakenly create a backup of y/x (y/x~) in coreutils-6.3. +cp -ab x y || fail=1 +test -d y/x || fail=1 +test -d y/x~ && fail=1 + +Exit $fail diff --git a/tests/cp/backup-is-src b/tests/cp/backup-is-src deleted file mode 100755 index 98e2ed09a..000000000 --- a/tests/cp/backup-is-src +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Test cp backup to source file. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -echo a > a || framework_failure_ -echo a-tilde > a~ || framework_failure_ - -# This cp command should exit nonzero. -cp --b=simple a~ a > out 2>&1 && fail=1 - -sed "s,cp:,XXX:," out > out2 - -cat > exp <<\EOF -XXX: backing up 'a' would destroy source; 'a~' not copied -EOF - -compare exp out2 || fail=1 - -Exit $fail diff --git a/tests/cp/backup-is-src.sh b/tests/cp/backup-is-src.sh new file mode 100755 index 000000000..98e2ed09a --- /dev/null +++ b/tests/cp/backup-is-src.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Test cp backup to source file. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +echo a > a || framework_failure_ +echo a-tilde > a~ || framework_failure_ + +# This cp command should exit nonzero. +cp --b=simple a~ a > out 2>&1 && fail=1 + +sed "s,cp:,XXX:," out > out2 + +cat > exp <<\EOF +XXX: backing up 'a' would destroy source; 'a~' not copied +EOF + +compare exp out2 || fail=1 + +Exit $fail diff --git a/tests/cp/capability b/tests/cp/capability deleted file mode 100755 index 94e5aea16..000000000 --- a/tests/cp/capability +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Ensure cp --preserves copies capabilities - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -require_root_ -working_umask_or_skip_ - - -grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \ - || skip_ "configured without libcap support" - -(setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \ - || skip_ "setcap utility not found" -(getcap --help) 2>&1 |grep 'usage: getcap' > /dev/null \ - || skip_ "getcap utility not found" - - -touch file || framework_failure_ -chown $NON_ROOT_USERNAME file || framework_failure_ - -setcap 'cap_net_bind_service=ep' file || - skip_ "setcap doesn't work" -getcap file | grep cap_net_bind_service >/dev/null || - skip_ "getcap doesn't work" - -cp --preserve=xattr file copy1 || fail=1 - -# Before coreutils 8.5 the capabilities would not be preserved, -# as the owner was set _after_ copying xattrs, thus clearing any capabilities. -cp --preserve=all file copy2 || fail=1 - -for file in copy1 copy2; do - getcap $file | grep cap_net_bind_service >/dev/null || fail=1 -done - -Exit $fail diff --git a/tests/cp/capability.sh b/tests/cp/capability.sh new file mode 100755 index 000000000..94e5aea16 --- /dev/null +++ b/tests/cp/capability.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Ensure cp --preserves copies capabilities + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +require_root_ +working_umask_or_skip_ + + +grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \ + || skip_ "configured without libcap support" + +(setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \ + || skip_ "setcap utility not found" +(getcap --help) 2>&1 |grep 'usage: getcap' > /dev/null \ + || skip_ "getcap utility not found" + + +touch file || framework_failure_ +chown $NON_ROOT_USERNAME file || framework_failure_ + +setcap 'cap_net_bind_service=ep' file || + skip_ "setcap doesn't work" +getcap file | grep cap_net_bind_service >/dev/null || + skip_ "getcap doesn't work" + +cp --preserve=xattr file copy1 || fail=1 + +# Before coreutils 8.5 the capabilities would not be preserved, +# as the owner was set _after_ copying xattrs, thus clearing any capabilities. +cp --preserve=all file copy2 || fail=1 + +for file in copy1 copy2; do + getcap $file | grep cap_net_bind_service >/dev/null || fail=1 +done + +Exit $fail diff --git a/tests/cp/cp-HL b/tests/cp/cp-HL deleted file mode 100755 index bbbd75a74..000000000 --- a/tests/cp/cp-HL +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# test cp's -H and -L options - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir src-dir dest-dir || framework_failure_ -echo f > f || framework_failure_ -ln -s f slink || framework_failure_ -ln -s no-such-file src-dir/slink || framework_failure_ - - -cp -H -R slink src-dir dest-dir || fail=1 -test -d src-dir || fail=1 -test -d dest-dir/src-dir || fail=1 - -# Expect this to succeed since this slink is not a symlink -cat dest-dir/slink > /dev/null 2>&1 || fail=1 - -# Expect this to fail since *this* slink is a dangling symlink. -cat dest-dir/src-dir/slink > /dev/null 2>&1 && fail=1 - -# FIXME: test -L, too. - -Exit $fail diff --git a/tests/cp/cp-HL.sh b/tests/cp/cp-HL.sh new file mode 100755 index 000000000..bbbd75a74 --- /dev/null +++ b/tests/cp/cp-HL.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# test cp's -H and -L options + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir src-dir dest-dir || framework_failure_ +echo f > f || framework_failure_ +ln -s f slink || framework_failure_ +ln -s no-such-file src-dir/slink || framework_failure_ + + +cp -H -R slink src-dir dest-dir || fail=1 +test -d src-dir || fail=1 +test -d dest-dir/src-dir || fail=1 + +# Expect this to succeed since this slink is not a symlink +cat dest-dir/slink > /dev/null 2>&1 || fail=1 + +# Expect this to fail since *this* slink is a dangling symlink. +cat dest-dir/src-dir/slink > /dev/null 2>&1 && fail=1 + +# FIXME: test -L, too. + +Exit $fail diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux deleted file mode 100755 index b85298488..000000000 --- a/tests/cp/cp-a-selinux +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/sh -# Ensure that cp -a and cp --preserve=context work properly. -# In particular, test on a writable NFS partition. -# Check also locally if --preserve=context, -a and --preserve=all -# does work - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -require_root_ -require_selinux_ - -cwd=$(pwd) -cleanup_() { cd /; umount "$cwd/mnt"; } - -# This context is special: it works even when mcstransd isn't running. -ctx=root:object_r:tmp_t:s0 - -# Check basic functionality - before check on fixed context mount -touch c || framework_failure_ -chcon $ctx c || framework_failure_ -cp -a c d 2>err || framework_failure_ -cp --preserve=context c e || framework_failure_ -cp --preserve=all c f || framework_failure_ -ls -Z d | grep $ctx || fail=1 -test -s err && fail=1 #there must be no stderr output for -a -ls -Z e | grep $ctx || fail=1 -ls -Z f | grep $ctx || fail=1 - -skip=0 -# Create a file system, then mount it with the context=... option. -dd if=/dev/zero of=blob bs=8192 count=200 || skip=1 -mkdir mnt || skip=1 -mkfs -t ext2 -F blob || - skip_ "failed to create an ext2 file system" - -mount -oloop,context=$ctx blob mnt || skip=1 -test $skip = 1 \ - && skip_ "insufficient mount/ext2 support" - -cd mnt || framework_failure_ - -echo > f || framework_failure_ - -echo > g || framework_failure_ -# /bin/cp from coreutils-6.7-3.fc7 would fail this test by letting cp -# succeed (giving no diagnostics), yet leaving the destination file empty. -cp -a f g 2>err || fail=1 -test -s g || fail=1 # The destination file must not be empty. -test -s err && fail=1 # There must be no stderr output. - -# ===================================================== -# Here, we expect cp to succeed and not warn with "Operation not supported" -rm -f g -echo > g -cp --preserve=all f g 2>err || fail=1 -test -s g || fail=1 -grep "Operation not supported" err && fail=1 - -# ===================================================== -# The same as above except destination does not exist -rm -f g -cp --preserve=all f g 2>err || fail=1 -test -s g || fail=1 -grep "Operation not supported" err && fail=1 - -# An alternative to the following approach would be to run in a confined -# domain (maybe creating/loading it) that lacks the required permissions -# to the file type. -# Note: this test could also be run by a regular (non-root) user in an -# NFS mounted directory. When doing that, I get this diagnostic: -# cp: failed to set the security context of 'g' to 'system_u:object_r:nfs_t': \ -# Operation not supported -cat <<\EOF > exp || framework_failure_ -cp: failed to set the security context of -EOF - -rm -f g -echo > g -# ===================================================== -# Here, we expect cp to fail, because it cannot set the SELinux -# security context through NFS or a mount with fixed context. -cp --preserve=context f g 2> out && fail=1 -# Here, we *do* expect the destination to be empty. -test -s g && fail=1 -sed "s/ .g' to .*//" out > k -mv k out -compare exp out || fail=1 - -rm -f g -echo > g -# Check if -a option doesn't silence --preserve=context option diagnostics -cp -a --preserve=context f g 2> out2 && fail=1 -# Here, we *do* expect the destination to be empty. -test -s g && fail=1 -sed "s/ .g' to .*//" out2 > k -mv k out2 -compare exp out2 || fail=1 - -Exit $fail diff --git a/tests/cp/cp-a-selinux.sh b/tests/cp/cp-a-selinux.sh new file mode 100755 index 000000000..b85298488 --- /dev/null +++ b/tests/cp/cp-a-selinux.sh @@ -0,0 +1,114 @@ +#!/bin/sh +# Ensure that cp -a and cp --preserve=context work properly. +# In particular, test on a writable NFS partition. +# Check also locally if --preserve=context, -a and --preserve=all +# does work + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +require_root_ +require_selinux_ + +cwd=$(pwd) +cleanup_() { cd /; umount "$cwd/mnt"; } + +# This context is special: it works even when mcstransd isn't running. +ctx=root:object_r:tmp_t:s0 + +# Check basic functionality - before check on fixed context mount +touch c || framework_failure_ +chcon $ctx c || framework_failure_ +cp -a c d 2>err || framework_failure_ +cp --preserve=context c e || framework_failure_ +cp --preserve=all c f || framework_failure_ +ls -Z d | grep $ctx || fail=1 +test -s err && fail=1 #there must be no stderr output for -a +ls -Z e | grep $ctx || fail=1 +ls -Z f | grep $ctx || fail=1 + +skip=0 +# Create a file system, then mount it with the context=... option. +dd if=/dev/zero of=blob bs=8192 count=200 || skip=1 +mkdir mnt || skip=1 +mkfs -t ext2 -F blob || + skip_ "failed to create an ext2 file system" + +mount -oloop,context=$ctx blob mnt || skip=1 +test $skip = 1 \ + && skip_ "insufficient mount/ext2 support" + +cd mnt || framework_failure_ + +echo > f || framework_failure_ + +echo > g || framework_failure_ +# /bin/cp from coreutils-6.7-3.fc7 would fail this test by letting cp +# succeed (giving no diagnostics), yet leaving the destination file empty. +cp -a f g 2>err || fail=1 +test -s g || fail=1 # The destination file must not be empty. +test -s err && fail=1 # There must be no stderr output. + +# ===================================================== +# Here, we expect cp to succeed and not warn with "Operation not supported" +rm -f g +echo > g +cp --preserve=all f g 2>err || fail=1 +test -s g || fail=1 +grep "Operation not supported" err && fail=1 + +# ===================================================== +# The same as above except destination does not exist +rm -f g +cp --preserve=all f g 2>err || fail=1 +test -s g || fail=1 +grep "Operation not supported" err && fail=1 + +# An alternative to the following approach would be to run in a confined +# domain (maybe creating/loading it) that lacks the required permissions +# to the file type. +# Note: this test could also be run by a regular (non-root) user in an +# NFS mounted directory. When doing that, I get this diagnostic: +# cp: failed to set the security context of 'g' to 'system_u:object_r:nfs_t': \ +# Operation not supported +cat <<\EOF > exp || framework_failure_ +cp: failed to set the security context of +EOF + +rm -f g +echo > g +# ===================================================== +# Here, we expect cp to fail, because it cannot set the SELinux +# security context through NFS or a mount with fixed context. +cp --preserve=context f g 2> out && fail=1 +# Here, we *do* expect the destination to be empty. +test -s g && fail=1 +sed "s/ .g' to .*//" out > k +mv k out +compare exp out || fail=1 + +rm -f g +echo > g +# Check if -a option doesn't silence --preserve=context option diagnostics +cp -a --preserve=context f g 2> out2 && fail=1 +# Here, we *do* expect the destination to be empty. +test -s g && fail=1 +sed "s/ .g' to .*//" out2 > k +mv k out2 +compare exp out2 || fail=1 + +Exit $fail diff --git a/tests/cp/cp-deref b/tests/cp/cp-deref deleted file mode 100755 index 08a1485f9..000000000 --- a/tests/cp/cp-deref +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# cp -RL dir1 dir2' must handle the case in which each of dir1 and dir2 -# contain a symlink pointing to some third directory. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir a b c d || framework_failure_ -ln -s ../c a || framework_failure_ -ln -s ../c b || framework_failure_ - - -# Before coreutils-5.94, the following would fail with this message: -# cp: will not create hard link 'd/b/c' to directory 'd/a/c' -cp -RL a b d || fail=1 -test -d a/c || fail=1 -test -d b/c || fail=1 - -Exit $fail diff --git a/tests/cp/cp-deref.sh b/tests/cp/cp-deref.sh new file mode 100755 index 000000000..08a1485f9 --- /dev/null +++ b/tests/cp/cp-deref.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# cp -RL dir1 dir2' must handle the case in which each of dir1 and dir2 +# contain a symlink pointing to some third directory. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir a b c d || framework_failure_ +ln -s ../c a || framework_failure_ +ln -s ../c b || framework_failure_ + + +# Before coreutils-5.94, the following would fail with this message: +# cp: will not create hard link 'd/b/c' to directory 'd/a/c' +cp -RL a b d || fail=1 +test -d a/c || fail=1 +test -d b/c || fail=1 + +Exit $fail diff --git a/tests/cp/cp-i b/tests/cp/cp-i deleted file mode 100755 index 746dc2765..000000000 --- a/tests/cp/cp-i +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Test whether cp -i prompts in the right place. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir -p a b/a/c || framework_failure_ -touch a/c || framework_failure_ - - -# coreutils 6.2 cp would neglect to prompt in this case. -echo n | cp -iR a b 2>/dev/null || fail=1 - -# test miscellaneous combinations of -f -i -n parameters -touch c d || framework_failure_ -echo "'c' -> 'd'" > out_copy -> out_empty - -# ask for overwrite, answer no -echo n | cp -vi c d 2>/dev/null > out1 || fail=1 -compare out1 out_empty || fail=1 - -# ask for overwrite, answer yes -echo y | cp -vi c d 2>/dev/null > out2 || fail=1 -compare out2 out_copy || fail=1 - -# -i wins over -n -echo y | cp -vni c d 2>/dev/null > out3 || fail=1 -compare out3 out_copy || fail=1 - -# -n wins over -i -echo y | cp -vin c d 2>/dev/null > out4 || fail=1 -compare out4 out_empty || fail=1 - -# ask for overwrite, answer yes -echo y | cp -vfi c d 2>/dev/null > out5 || fail=1 -compare out5 out_copy || fail=1 - -# do not ask, prevent from overwrite -echo n | cp -vfn c d 2>/dev/null > out6 || fail=1 -compare out6 out_empty || fail=1 - -# do not ask, prevent from overwrite -echo n | cp -vnf c d 2>/dev/null > out7 || fail=1 -compare out7 out_empty || fail=1 - -# options --backup and --no-clobber are mutually exclusive -cp -bn c d 2>/dev/null && fail=1 - -Exit $fail diff --git a/tests/cp/cp-i.sh b/tests/cp/cp-i.sh new file mode 100755 index 000000000..746dc2765 --- /dev/null +++ b/tests/cp/cp-i.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Test whether cp -i prompts in the right place. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir -p a b/a/c || framework_failure_ +touch a/c || framework_failure_ + + +# coreutils 6.2 cp would neglect to prompt in this case. +echo n | cp -iR a b 2>/dev/null || fail=1 + +# test miscellaneous combinations of -f -i -n parameters +touch c d || framework_failure_ +echo "'c' -> 'd'" > out_copy +> out_empty + +# ask for overwrite, answer no +echo n | cp -vi c d 2>/dev/null > out1 || fail=1 +compare out1 out_empty || fail=1 + +# ask for overwrite, answer yes +echo y | cp -vi c d 2>/dev/null > out2 || fail=1 +compare out2 out_copy || fail=1 + +# -i wins over -n +echo y | cp -vni c d 2>/dev/null > out3 || fail=1 +compare out3 out_copy || fail=1 + +# -n wins over -i +echo y | cp -vin c d 2>/dev/null > out4 || fail=1 +compare out4 out_empty || fail=1 + +# ask for overwrite, answer yes +echo y | cp -vfi c d 2>/dev/null > out5 || fail=1 +compare out5 out_copy || fail=1 + +# do not ask, prevent from overwrite +echo n | cp -vfn c d 2>/dev/null > out6 || fail=1 +compare out6 out_empty || fail=1 + +# do not ask, prevent from overwrite +echo n | cp -vnf c d 2>/dev/null > out7 || fail=1 +compare out7 out_empty || fail=1 + +# options --backup and --no-clobber are mutually exclusive +cp -bn c d 2>/dev/null && fail=1 + +Exit $fail diff --git a/tests/cp/cp-mv-backup b/tests/cp/cp-mv-backup deleted file mode 100755 index 030f722dc..000000000 --- a/tests/cp/cp-mv-backup +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# Test basic --backup functionality for both cp and mv. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -umask 022 - -# Be careful to close $actual before removing the containing directory. -# Use '1>&2' rather than '1<&-' since the latter appears not to work -# with /bin/sh from powerpc-ibm-aix4.2.0.0. - -actual=actual -expected=expected - -exec 3>&1 1> $actual - -for prog in cp mv; do - for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do - for opt in none off numbered t existing nil simple never; do - touch $initial_files - $prog --backup=$opt x y || fail=1 - echo $initial_files $opt: $(ls [xy]*); rm -f x y y~ y.~?~ - done - done -done - -cat <<\EOF > $expected-tmp -x none: x y -x off: x y -x numbered: x y -x t: x y -x existing: x y -x nil: x y -x simple: x y -x never: x y -x y none: x y -x y off: x y -x y numbered: x y y.~1~ -x y t: x y y.~1~ -x y existing: x y y~ -x y nil: x y y~ -x y simple: x y y~ -x y never: x y y~ -x y y~ none: x y y~ -x y y~ off: x y y~ -x y y~ numbered: x y y.~1~ y~ -x y y~ t: x y y.~1~ y~ -x y y~ existing: x y y~ -x y y~ nil: x y y~ -x y y~ simple: x y y~ -x y y~ never: x y y~ -x y y.~1~ none: x y y.~1~ -x y y.~1~ off: x y y.~1~ -x y y.~1~ numbered: x y y.~1~ y.~2~ -x y y.~1~ t: x y y.~1~ y.~2~ -x y y.~1~ existing: x y y.~1~ y.~2~ -x y y.~1~ nil: x y y.~1~ y.~2~ -x y y.~1~ simple: x y y.~1~ y~ -x y y.~1~ never: x y y.~1~ y~ -x y y~ y.~1~ none: x y y.~1~ y~ -x y y~ y.~1~ off: x y y.~1~ y~ -x y y~ y.~1~ numbered: x y y.~1~ y.~2~ y~ -x y y~ y.~1~ t: x y y.~1~ y.~2~ y~ -x y y~ y.~1~ existing: x y y.~1~ y.~2~ y~ -x y y~ y.~1~ nil: x y y.~1~ y.~2~ y~ -x y y~ y.~1~ simple: x y y.~1~ y~ -x y y~ y.~1~ never: x y y.~1~ y~ -EOF - -sed 's/: x/:/' $expected-tmp |cat $expected-tmp - > $expected - -exec 1>&3 3>&- - -compare $expected $actual || fail=1 - -Exit $fail diff --git a/tests/cp/cp-mv-backup.sh b/tests/cp/cp-mv-backup.sh new file mode 100755 index 000000000..030f722dc --- /dev/null +++ b/tests/cp/cp-mv-backup.sh @@ -0,0 +1,92 @@ +#!/bin/sh +# Test basic --backup functionality for both cp and mv. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +umask 022 + +# Be careful to close $actual before removing the containing directory. +# Use '1>&2' rather than '1<&-' since the latter appears not to work +# with /bin/sh from powerpc-ibm-aix4.2.0.0. + +actual=actual +expected=expected + +exec 3>&1 1> $actual + +for prog in cp mv; do + for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do + for opt in none off numbered t existing nil simple never; do + touch $initial_files + $prog --backup=$opt x y || fail=1 + echo $initial_files $opt: $(ls [xy]*); rm -f x y y~ y.~?~ + done + done +done + +cat <<\EOF > $expected-tmp +x none: x y +x off: x y +x numbered: x y +x t: x y +x existing: x y +x nil: x y +x simple: x y +x never: x y +x y none: x y +x y off: x y +x y numbered: x y y.~1~ +x y t: x y y.~1~ +x y existing: x y y~ +x y nil: x y y~ +x y simple: x y y~ +x y never: x y y~ +x y y~ none: x y y~ +x y y~ off: x y y~ +x y y~ numbered: x y y.~1~ y~ +x y y~ t: x y y.~1~ y~ +x y y~ existing: x y y~ +x y y~ nil: x y y~ +x y y~ simple: x y y~ +x y y~ never: x y y~ +x y y.~1~ none: x y y.~1~ +x y y.~1~ off: x y y.~1~ +x y y.~1~ numbered: x y y.~1~ y.~2~ +x y y.~1~ t: x y y.~1~ y.~2~ +x y y.~1~ existing: x y y.~1~ y.~2~ +x y y.~1~ nil: x y y.~1~ y.~2~ +x y y.~1~ simple: x y y.~1~ y~ +x y y.~1~ never: x y y.~1~ y~ +x y y~ y.~1~ none: x y y.~1~ y~ +x y y~ y.~1~ off: x y y.~1~ y~ +x y y~ y.~1~ numbered: x y y.~1~ y.~2~ y~ +x y y~ y.~1~ t: x y y.~1~ y.~2~ y~ +x y y~ y.~1~ existing: x y y.~1~ y.~2~ y~ +x y y~ y.~1~ nil: x y y.~1~ y.~2~ y~ +x y y~ y.~1~ simple: x y y.~1~ y~ +x y y~ y.~1~ never: x y y.~1~ y~ +EOF + +sed 's/: x/:/' $expected-tmp |cat $expected-tmp - > $expected + +exec 1>&3 3>&- + +compare $expected $actual || fail=1 + +Exit $fail diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr deleted file mode 100755 index 66e54cf11..000000000 --- a/tests/cp/cp-mv-enotsup-xattr +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh -# Ensure that mv, cp -a and cp --preserve=xattr(all) options do work -# as expected on file system without their support and do show correct -# diagnostics when required - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv - -require_root_ - -cwd=$(pwd) -cleanup_() { cd /; umount "$cwd/noxattr"; umount "$cwd/xattr"; } - -skip=0 - -# Mount an ext2 loopback file system at $WHERE with $OPTS -make_fs() { - where="$1" - opts="$2" - - fs="$where.bin" - - dd if=/dev/zero of="$fs" bs=8192 count=200 > /dev/null 2>&1 \ - || skip=1 - mkdir "$where" || skip=1 - mkfs -t ext2 -F "$fs" || - skip_ "failed to create ext2 file system" - mount -oloop,$opts "$fs" "$where" || skip=1 - echo test > "$where"/f || skip=1 - test -s "$where"/f || skip=1 - - test $skip = 1 && - skip_ "insufficient mount/ext2 support" -} - -make_fs noxattr nouser_xattr -make_fs xattr user_xattr - -# testing xattr name-value pair -xattr_name="user.foo" -xattr_value="bar" -xattr_pair="$xattr_name=\"$xattr_value\"" - -echo test > xattr/a || framework_failure_ -getfattr -d xattr/a >out_a || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_a >/dev/null && framework_failure_ -setfattr -n "$xattr_name" -v "$xattr_value" xattr/a >out_a \ - || skip_ "failed to set xattr of file" -getfattr -d xattr/a >out_a || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_a >/dev/null \ - || skip_ "failed to set xattr of file" - - -# This should pass without diagnostics -cp -a xattr/a noxattr/ 2>err || fail=1 -test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output - -rm -f err noxattr/a - -# This should pass without diagnostics (new file) -cp --preserve=all xattr/a noxattr/ 2>err || fail=1 -test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output - -# This should pass without diagnostics (existing file) -cp --preserve=all xattr/a noxattr/ 2>err || fail=1 -test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output - -rm -f err noxattr/a - -# This should fail with coresponding diagnostics -cp -a --preserve=xattr xattr/a noxattr/ 2>err && fail=1 -if grep '^#define USE_XATTR 1' $CONFIG_HEADER > /dev/null; then -cat <<\EOF > exp -cp: setting attributes for 'noxattr/a': Operation not supported -EOF -else -cat <<\EOF > exp -cp: cannot preserve extended attributes, cp is built without xattr support -EOF -fi - -compare exp err || fail=1 - -rm -f err noxattr/a - -# This should pass without diagnostics -mv xattr/a noxattr/ 2>err || fail=1 -test -s noxattr/a || fail=1 # destination file must not be empty -test -s err && fail=1 # there must be no stderr output - -Exit $fail diff --git a/tests/cp/cp-mv-enotsup-xattr.sh b/tests/cp/cp-mv-enotsup-xattr.sh new file mode 100755 index 000000000..66e54cf11 --- /dev/null +++ b/tests/cp/cp-mv-enotsup-xattr.sh @@ -0,0 +1,109 @@ +#!/bin/sh +# Ensure that mv, cp -a and cp --preserve=xattr(all) options do work +# as expected on file system without their support and do show correct +# diagnostics when required + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv + +require_root_ + +cwd=$(pwd) +cleanup_() { cd /; umount "$cwd/noxattr"; umount "$cwd/xattr"; } + +skip=0 + +# Mount an ext2 loopback file system at $WHERE with $OPTS +make_fs() { + where="$1" + opts="$2" + + fs="$where.bin" + + dd if=/dev/zero of="$fs" bs=8192 count=200 > /dev/null 2>&1 \ + || skip=1 + mkdir "$where" || skip=1 + mkfs -t ext2 -F "$fs" || + skip_ "failed to create ext2 file system" + mount -oloop,$opts "$fs" "$where" || skip=1 + echo test > "$where"/f || skip=1 + test -s "$where"/f || skip=1 + + test $skip = 1 && + skip_ "insufficient mount/ext2 support" +} + +make_fs noxattr nouser_xattr +make_fs xattr user_xattr + +# testing xattr name-value pair +xattr_name="user.foo" +xattr_value="bar" +xattr_pair="$xattr_name=\"$xattr_value\"" + +echo test > xattr/a || framework_failure_ +getfattr -d xattr/a >out_a || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_a >/dev/null && framework_failure_ +setfattr -n "$xattr_name" -v "$xattr_value" xattr/a >out_a \ + || skip_ "failed to set xattr of file" +getfattr -d xattr/a >out_a || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_a >/dev/null \ + || skip_ "failed to set xattr of file" + + +# This should pass without diagnostics +cp -a xattr/a noxattr/ 2>err || fail=1 +test -s noxattr/a || fail=1 # destination file must not be empty +test -s err && fail=1 # there must be no stderr output + +rm -f err noxattr/a + +# This should pass without diagnostics (new file) +cp --preserve=all xattr/a noxattr/ 2>err || fail=1 +test -s noxattr/a || fail=1 # destination file must not be empty +test -s err && fail=1 # there must be no stderr output + +# This should pass without diagnostics (existing file) +cp --preserve=all xattr/a noxattr/ 2>err || fail=1 +test -s noxattr/a || fail=1 # destination file must not be empty +test -s err && fail=1 # there must be no stderr output + +rm -f err noxattr/a + +# This should fail with coresponding diagnostics +cp -a --preserve=xattr xattr/a noxattr/ 2>err && fail=1 +if grep '^#define USE_XATTR 1' $CONFIG_HEADER > /dev/null; then +cat <<\EOF > exp +cp: setting attributes for 'noxattr/a': Operation not supported +EOF +else +cat <<\EOF > exp +cp: cannot preserve extended attributes, cp is built without xattr support +EOF +fi + +compare exp err || fail=1 + +rm -f err noxattr/a + +# This should pass without diagnostics +mv xattr/a noxattr/ 2>err || fail=1 +test -s noxattr/a || fail=1 # destination file must not be empty +test -s err && fail=1 # there must be no stderr output + +Exit $fail diff --git a/tests/cp/cp-parents b/tests/cp/cp-parents deleted file mode 100755 index 506e708ac..000000000 --- a/tests/cp/cp-parents +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# cp -R --parents dir-specified-with-trailing-slash/ other-dir -# would get a failed assertion. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -working_umask_or_skip_ - -# Run the setgid check from the just-created directory. -skip_if_setgid_ - -mkdir foo bar || framework_failure_ -mkdir -p a/b/c d e g || framework_failure_ -ln -s d/a sym || framework_failure_ -touch f || framework_failure_ - - -# With 4.0.37 and earlier (back to when?), this would fail -# with the failed assertion from dirname.c. -cp -R --parents foo/ bar || fail=1 - -# Exercise the make_path and re_protect code in cp.c. -# FIXME: compare verbose output with expected output. -cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1 -test -d d/a/b/c || fail=1 - -# With 6.7 and earlier, cp --parents f/g d would mistakenly create a -# directory d/f, even though f is a regular file. -cp --parents f/g d 2>/dev/null && fail=1 -test -d d/f && fail=1 - -# Check that re_protect works. -chmod go=w d/a || framework_failure_ -cp -a --parents d/a/b/c e || fail=1 -cp -a --parents sym/b/c g || fail=1 -p=$(ls -ld e/d|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac -p=$(ls -ld e/d/a|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac -p=$(ls -ld g/sym|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac -p=$(ls -ld e/d/a/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac -p=$(ls -ld g/sym/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac - -Exit $fail diff --git a/tests/cp/cp-parents.sh b/tests/cp/cp-parents.sh new file mode 100755 index 000000000..506e708ac --- /dev/null +++ b/tests/cp/cp-parents.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# cp -R --parents dir-specified-with-trailing-slash/ other-dir +# would get a failed assertion. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +working_umask_or_skip_ + +# Run the setgid check from the just-created directory. +skip_if_setgid_ + +mkdir foo bar || framework_failure_ +mkdir -p a/b/c d e g || framework_failure_ +ln -s d/a sym || framework_failure_ +touch f || framework_failure_ + + +# With 4.0.37 and earlier (back to when?), this would fail +# with the failed assertion from dirname.c. +cp -R --parents foo/ bar || fail=1 + +# Exercise the make_path and re_protect code in cp.c. +# FIXME: compare verbose output with expected output. +cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1 +test -d d/a/b/c || fail=1 + +# With 6.7 and earlier, cp --parents f/g d would mistakenly create a +# directory d/f, even though f is a regular file. +cp --parents f/g d 2>/dev/null && fail=1 +test -d d/f && fail=1 + +# Check that re_protect works. +chmod go=w d/a || framework_failure_ +cp -a --parents d/a/b/c e || fail=1 +cp -a --parents sym/b/c g || fail=1 +p=$(ls -ld e/d|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac +p=$(ls -ld e/d/a|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac +p=$(ls -ld g/sym|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac +p=$(ls -ld e/d/a/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac +p=$(ls -ld g/sym/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac + +Exit $fail diff --git a/tests/cp/deref-slink b/tests/cp/deref-slink deleted file mode 100755 index 93f5cb8ae..000000000 --- a/tests/cp/deref-slink +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Demonstrate bug when using -d with an existing destination file -# that is a symlink. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -touch f slink-target || framework_failure_ -ln -s slink-target slink || framework_failure_ - -cp -d f slink || fail=1 - -Exit $fail diff --git a/tests/cp/deref-slink.sh b/tests/cp/deref-slink.sh new file mode 100755 index 000000000..93f5cb8ae --- /dev/null +++ b/tests/cp/deref-slink.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Demonstrate bug when using -d with an existing destination file +# that is a symlink. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +touch f slink-target || framework_failure_ +ln -s slink-target slink || framework_failure_ + +cp -d f slink || fail=1 + +Exit $fail diff --git a/tests/cp/dir-rm-dest b/tests/cp/dir-rm-dest deleted file mode 100755 index b2f0e72c5..000000000 --- a/tests/cp/dir-rm-dest +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# verify that cp's --remove-destination option works with -R - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir d e || framework_failure_ - -# Do it once with no destination... -cp -R --remove-destination d e || fail=1 - -# ...and again, with an existing destination. -cp -R --remove-destination d e || fail=1 - -Exit $fail diff --git a/tests/cp/dir-rm-dest.sh b/tests/cp/dir-rm-dest.sh new file mode 100755 index 000000000..b2f0e72c5 --- /dev/null +++ b/tests/cp/dir-rm-dest.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# verify that cp's --remove-destination option works with -R + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir d e || framework_failure_ + +# Do it once with no destination... +cp -R --remove-destination d e || fail=1 + +# ...and again, with an existing destination. +cp -R --remove-destination d e || fail=1 + +Exit $fail diff --git a/tests/cp/dir-slash b/tests/cp/dir-slash deleted file mode 100755 index b14aad823..000000000 --- a/tests/cp/dir-slash +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Make sure that cp -R DIR1 DIR2 does the right thing -# when DIR1 is written with a trailing slash. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir dir1 dir2 || framework_failure_ -touch dir1/file || framework_failure_ - -cp -R dir1/ dir2 || fail=1 - -# This file should not exist, but it did with fileutils-4.0w. -test -r dir2/file && fail=1 - -# These two should. -test -r dir2/dir1/file || fail=1 -test -r dir1/file || fail=1 - -Exit $fail diff --git a/tests/cp/dir-slash.sh b/tests/cp/dir-slash.sh new file mode 100755 index 000000000..b14aad823 --- /dev/null +++ b/tests/cp/dir-slash.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Make sure that cp -R DIR1 DIR2 does the right thing +# when DIR1 is written with a trailing slash. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir dir1 dir2 || framework_failure_ +touch dir1/file || framework_failure_ + +cp -R dir1/ dir2 || fail=1 + +# This file should not exist, but it did with fileutils-4.0w. +test -r dir2/file && fail=1 + +# These two should. +test -r dir2/dir1/file || fail=1 +test -r dir1/file || fail=1 + +Exit $fail diff --git a/tests/cp/dir-vs-file b/tests/cp/dir-vs-file deleted file mode 100755 index c8e388fa7..000000000 --- a/tests/cp/dir-vs-file +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# A directory may not replace an existing file. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir dir || framework_failure_ -touch file || framework_failure_ - - -# In 4.0.35, this cp invocation silently succeeded. -cp -R dir file 2>/dev/null && fail=1 - -# Make sure file is not replaced with a directory. -# In 4.0.35, it was. -test -f file || fail=1 - -Exit $fail diff --git a/tests/cp/dir-vs-file.sh b/tests/cp/dir-vs-file.sh new file mode 100755 index 000000000..c8e388fa7 --- /dev/null +++ b/tests/cp/dir-vs-file.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# A directory may not replace an existing file. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir dir || framework_failure_ +touch file || framework_failure_ + + +# In 4.0.35, this cp invocation silently succeeded. +cp -R dir file 2>/dev/null && fail=1 + +# Make sure file is not replaced with a directory. +# In 4.0.35, it was. +test -f file || fail=1 + +Exit $fail diff --git a/tests/cp/existing-perm-dir b/tests/cp/existing-perm-dir deleted file mode 100755 index 40b55a3f4..000000000 --- a/tests/cp/existing-perm-dir +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Make sure cp -p doesn't "restore" permissions it shouldn't (Bug#9170). - -# Copyright 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -umask 002 -mkdir -p -m ug-s,u=rwx,g=rwx,o=rx src/dir || fail=1 -mkdir -p -m ug-s,u=rwx,g=,o= dst/dir || fail=1 - -cp -r src/. dst/ || fail=1 - -mode=$(stat --p=%A dst/dir) -test "$mode" = drwx------ || fail=1 - -Exit $fail diff --git a/tests/cp/existing-perm-dir.sh b/tests/cp/existing-perm-dir.sh new file mode 100755 index 000000000..40b55a3f4 --- /dev/null +++ b/tests/cp/existing-perm-dir.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Make sure cp -p doesn't "restore" permissions it shouldn't (Bug#9170). + +# Copyright 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +umask 002 +mkdir -p -m ug-s,u=rwx,g=rwx,o=rx src/dir || fail=1 +mkdir -p -m ug-s,u=rwx,g=,o= dst/dir || fail=1 + +cp -r src/. dst/ || fail=1 + +mode=$(stat --p=%A dst/dir) +test "$mode" = drwx------ || fail=1 + +Exit $fail diff --git a/tests/cp/existing-perm-race b/tests/cp/existing-perm-race deleted file mode 100755 index 35c1556f5..000000000 --- a/tests/cp/existing-perm-race +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -# Make sure cp -p isn't too generous with existing file permissions. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -require_membership_in_two_groups_ - -# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least -require_local_dir_ - -set _ $groups; shift -g1=$1 -g2=$2 - - -umask 077 -mkfifo_or_skip_ fifo - -touch fifo-copy && -chgrp $g1 fifo && -chgrp $g2 fifo-copy && -chmod g+r fifo-copy || framework-failure - -# Copy a fifo's contents. That way, we can examine the -# destination permissions before they're finalized. -cp -p --copy-contents fifo fifo-copy & -cp_pid=$! - -( - # Now 'cp' is reading the fifo. Wait for the destination file to - # be written to, encouraging things along by echoing to the fifo. - while test ! -s fifo-copy; do - echo foo - done - - # Check the permissions of the destination. - ls -l -n fifo-copy >ls.out && - - # Close the fifo so that "cp" can continue. But output first, - # before exiting, otherwise some shells would optimize away the file - # descriptor that holds the fifo open. - echo foo -) >fifo || fail=1 - -# Check that the destination mode is safe while the file is being copied. -read mode links owner group etc ls.out && -read mode links owner group etc . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +require_membership_in_two_groups_ + +# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least +require_local_dir_ + +set _ $groups; shift +g1=$1 +g2=$2 + + +umask 077 +mkfifo_or_skip_ fifo + +touch fifo-copy && +chgrp $g1 fifo && +chgrp $g2 fifo-copy && +chmod g+r fifo-copy || framework-failure + +# Copy a fifo's contents. That way, we can examine the +# destination permissions before they're finalized. +cp -p --copy-contents fifo fifo-copy & +cp_pid=$! + +( + # Now 'cp' is reading the fifo. Wait for the destination file to + # be written to, encouraging things along by echoing to the fifo. + while test ! -s fifo-copy; do + echo foo + done + + # Check the permissions of the destination. + ls -l -n fifo-copy >ls.out && + + # Close the fifo so that "cp" can continue. But output first, + # before exiting, otherwise some shells would optimize away the file + # descriptor that holds the fifo open. + echo foo +) >fifo || fail=1 + +# Check that the destination mode is safe while the file is being copied. +read mode links owner group etc ls.out && +read mode links owner group etc . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -skip_if_root_ - -chmod g-s . || framework_failure_ -mkdir D D/D || framework_failure_ -touch D/a || framework_failure_ -chmod 0 D/a || framework_failure_ -chmod u=rx,go=,-st D || framework_failure_ - - -# This is expected to exit non-zero, because it can't read D/a. -cp -pR D DD > /dev/null 2>&1 && fail=1 - -# Permissions on DD must be 'dr-x------' - -mode=$(ls -ld DD|cut -b-10) -test "$mode" = dr-x------ || fail=1 - -chmod 0 D -ln -s D/D symlink -touch F -cat > exp <<\EOF -cp: accessing 'symlink': Permission denied -EOF - -cp F symlink 2> out && fail=1 -# HPUX appears to fail with EACCES rather than EPERM. -# Transform their diagnostic -# ...: The file access permissions do not allow the specified action. -# to the expected one: -sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out -compare exp out || fail=1 - -cp --target-directory=symlink F 2> out && fail=1 -sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out -compare exp out || fail=1 - -chmod 700 D - -Exit $fail diff --git a/tests/cp/fail-perm.sh b/tests/cp/fail-perm.sh new file mode 100755 index 000000000..2c37d6fb1 --- /dev/null +++ b/tests/cp/fail-perm.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +skip_if_root_ + +chmod g-s . || framework_failure_ +mkdir D D/D || framework_failure_ +touch D/a || framework_failure_ +chmod 0 D/a || framework_failure_ +chmod u=rx,go=,-st D || framework_failure_ + + +# This is expected to exit non-zero, because it can't read D/a. +cp -pR D DD > /dev/null 2>&1 && fail=1 + +# Permissions on DD must be 'dr-x------' + +mode=$(ls -ld DD|cut -b-10) +test "$mode" = dr-x------ || fail=1 + +chmod 0 D +ln -s D/D symlink +touch F +cat > exp <<\EOF +cp: accessing 'symlink': Permission denied +EOF + +cp F symlink 2> out && fail=1 +# HPUX appears to fail with EACCES rather than EPERM. +# Transform their diagnostic +# ...: The file access permissions do not allow the specified action. +# to the expected one: +sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out +compare exp out || fail=1 + +cp --target-directory=symlink F 2> out && fail=1 +sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out +compare exp out || fail=1 + +chmod 700 D + +Exit $fail diff --git a/tests/cp/fiemap-2 b/tests/cp/fiemap-2 deleted file mode 100755 index f24baf282..000000000 --- a/tests/cp/fiemap-2 +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Exercise a few more corners of the fiemap-copying code. - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# Require a fiemap-enabled FS. -touch fiemap_chk # check a file rather than current dir for best coverage -fiemap_capable_ fiemap_chk \ - || skip_ "this file system lacks FIEMAP support" - -# Exercise the code that handles a file ending in a hole. -printf x > k || framework_failure_ -dd bs=1k seek=128 of=k < /dev/null || framework_failure_ - -# The first time through the outer loop, the input file, K, ends with a hole. -# The second time through, we append a byte so that it does not. -for append in no yes; do - test $append = yes && printf y >> k - for i in always never; do - cp --sparse=$i k k2 || fail=1 - cmp k k2 || fail=1 - done -done - -# Ensure that --sparse=always can restore holes. -rm -f k -# Create a file starting with an "x", followed by 256K-1 0 bytes. -printf x > k || framework_failure_ -dd bs=1k seek=1 of=k count=255 < /dev/zero || framework_failure_ - -# cp should detect the all-zero blocks and convert some of them to holes. -# How many it detects/converts currently depends on io_blksize. -# Currently, on my F14/ext4 desktop, this K starts off with size 256KiB, -# (note that the K in the preceding test starts off with size 4KiB). -# cp from coreutils-8.9 with --sparse=always reduces the size to 32KiB. -cp --sparse=always k k2 || fail=1 -test $(stat -c %b k2) -lt $(stat -c %b k) || fail=1 - -Exit $fail diff --git a/tests/cp/fiemap-2.sh b/tests/cp/fiemap-2.sh new file mode 100755 index 000000000..f24baf282 --- /dev/null +++ b/tests/cp/fiemap-2.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Exercise a few more corners of the fiemap-copying code. + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# Require a fiemap-enabled FS. +touch fiemap_chk # check a file rather than current dir for best coverage +fiemap_capable_ fiemap_chk \ + || skip_ "this file system lacks FIEMAP support" + +# Exercise the code that handles a file ending in a hole. +printf x > k || framework_failure_ +dd bs=1k seek=128 of=k < /dev/null || framework_failure_ + +# The first time through the outer loop, the input file, K, ends with a hole. +# The second time through, we append a byte so that it does not. +for append in no yes; do + test $append = yes && printf y >> k + for i in always never; do + cp --sparse=$i k k2 || fail=1 + cmp k k2 || fail=1 + done +done + +# Ensure that --sparse=always can restore holes. +rm -f k +# Create a file starting with an "x", followed by 256K-1 0 bytes. +printf x > k || framework_failure_ +dd bs=1k seek=1 of=k count=255 < /dev/zero || framework_failure_ + +# cp should detect the all-zero blocks and convert some of them to holes. +# How many it detects/converts currently depends on io_blksize. +# Currently, on my F14/ext4 desktop, this K starts off with size 256KiB, +# (note that the K in the preceding test starts off with size 4KiB). +# cp from coreutils-8.9 with --sparse=always reduces the size to 32KiB. +cp --sparse=always k k2 || fail=1 +test $(stat -c %b k2) -lt $(stat -c %b k) || fail=1 + +Exit $fail diff --git a/tests/cp/fiemap-empty b/tests/cp/fiemap-empty deleted file mode 100755 index 4ba4ee30e..000000000 --- a/tests/cp/fiemap-empty +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/sh -# Test cp reads unwritten extents efficiently - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# FIXME: enable any part of this test that is still relevant, -# or, if none are relevant (now that cp does not handle unwritten -# extents), just remove the test altogether. -skip_ 'disabled for now' - -touch fiemap_chk -fiemap_capable_ fiemap_chk || - skip_ 'this file system lacks FIEMAP support' -rm fiemap_chk - -# TODO: rather than requiring $(fallocate), possible add -# this functionality to truncate --alloc -fallocate --help >/dev/null || skip_ 'The fallocate utility is required' -fallocate -l 1 -n falloc.test || - skip_ 'this file system lacks FALLOCATE support' -rm falloc.test - -# Require more space than we'll actually use, so that -# tests run in parallel do not run out of space. -# Otherwise, with inadequate space, simply running the following -# fallocate command would induce a temporary disk-full condition, -# which would cause failure of unrelated tests run in parallel. -require_file_system_bytes_free_ 800000000 - -fallocate -l 600MiB space.test || - skip_ 'this test needs at least 600MiB free space' - -# Disable this test on old BTRFS (e.g. Fedora 14) -# which reports ordinary extents for unwritten ones. -filefrag space.test || skip_ 'the 'filefrag' utility is missing' -filefrag -v space.test | grep -F 'unwritten' > /dev/null || - skip_ 'this file system does not report empty extents as "unwritten"' - -rm space.test - -# Ensure we read a large empty file quickly -fallocate -l 300MiB empty.big || framework_failure_ -timeout 3 cp --sparse=always empty.big cp.test || fail=1 -test $(stat -c %s empty.big) = $(stat -c %s cp.test) || fail=1 -rm empty.big cp.test - -# Ensure we handle extents beyond file size correctly. -# Note until we support fallocate, we will not maintain -# the file allocation. FIXME: amend this test when fallocate is supported. -fallocate -l 10MiB -n unwritten.withdata || framework_failure_ -dd count=10 if=/dev/urandom conv=notrunc iflag=fullblock of=unwritten.withdata -cp unwritten.withdata cp.test || fail=1 -test $(stat -c %s unwritten.withdata) = $(stat -c %s cp.test) || fail=1 -cmp unwritten.withdata cp.test || fail=1 -rm unwritten.withdata cp.test - -# The following to generate unaccounted extents followed by a hole, is not -# supported by ext4 at least. The ftruncate discards all extents not -# accounted for in the size. -# fallocate -l 10MiB -n unacc.withholes -# dd count=10 if=/dev/urandom conv=notrunc iflag=fullblock of=unacc.withholes -# truncate -s20M unacc.withholes - -# Ensure we handle a hole after empty extents correctly. -# Since all extents are accounted for in the size, -# we can maintain the allocation independently from -# fallocate() support. -fallocate -l 10MiB empty.withholes -truncate -s 20M empty.withholes -sectors_per_block=$(expr $(stat -c %o .) / 512) -cp empty.withholes cp.test || fail=1 -test $(stat -c %s empty.withholes) = $(stat -c %s cp.test) || fail=1 -# These are usually equal but can vary by an IO block due to alignment -alloc_diff=$(expr $(stat -c %b empty.withholes) - $(stat -c %b cp.test)) -alloc_diff=$(echo $alloc_diff | tr -d -- -) # abs() -test $alloc_diff -le $sectors_per_block || fail=1 -# Again with SPARSE_ALWAYS -cp --sparse=always empty.withholes cp.test || fail=1 -test $(stat -c %s empty.withholes) = $(stat -c %s cp.test) || fail=1 -# cp.test should take 0 space, but allowing for some systems -# that store default extended attributes in data blocks -test $(stat -c %b cp.test) -le $sectors_per_block || fail=1 -rm empty.withholes cp.test - -Exit $fail diff --git a/tests/cp/fiemap-empty.sh b/tests/cp/fiemap-empty.sh new file mode 100755 index 000000000..4ba4ee30e --- /dev/null +++ b/tests/cp/fiemap-empty.sh @@ -0,0 +1,101 @@ +#!/bin/sh +# Test cp reads unwritten extents efficiently + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# FIXME: enable any part of this test that is still relevant, +# or, if none are relevant (now that cp does not handle unwritten +# extents), just remove the test altogether. +skip_ 'disabled for now' + +touch fiemap_chk +fiemap_capable_ fiemap_chk || + skip_ 'this file system lacks FIEMAP support' +rm fiemap_chk + +# TODO: rather than requiring $(fallocate), possible add +# this functionality to truncate --alloc +fallocate --help >/dev/null || skip_ 'The fallocate utility is required' +fallocate -l 1 -n falloc.test || + skip_ 'this file system lacks FALLOCATE support' +rm falloc.test + +# Require more space than we'll actually use, so that +# tests run in parallel do not run out of space. +# Otherwise, with inadequate space, simply running the following +# fallocate command would induce a temporary disk-full condition, +# which would cause failure of unrelated tests run in parallel. +require_file_system_bytes_free_ 800000000 + +fallocate -l 600MiB space.test || + skip_ 'this test needs at least 600MiB free space' + +# Disable this test on old BTRFS (e.g. Fedora 14) +# which reports ordinary extents for unwritten ones. +filefrag space.test || skip_ 'the 'filefrag' utility is missing' +filefrag -v space.test | grep -F 'unwritten' > /dev/null || + skip_ 'this file system does not report empty extents as "unwritten"' + +rm space.test + +# Ensure we read a large empty file quickly +fallocate -l 300MiB empty.big || framework_failure_ +timeout 3 cp --sparse=always empty.big cp.test || fail=1 +test $(stat -c %s empty.big) = $(stat -c %s cp.test) || fail=1 +rm empty.big cp.test + +# Ensure we handle extents beyond file size correctly. +# Note until we support fallocate, we will not maintain +# the file allocation. FIXME: amend this test when fallocate is supported. +fallocate -l 10MiB -n unwritten.withdata || framework_failure_ +dd count=10 if=/dev/urandom conv=notrunc iflag=fullblock of=unwritten.withdata +cp unwritten.withdata cp.test || fail=1 +test $(stat -c %s unwritten.withdata) = $(stat -c %s cp.test) || fail=1 +cmp unwritten.withdata cp.test || fail=1 +rm unwritten.withdata cp.test + +# The following to generate unaccounted extents followed by a hole, is not +# supported by ext4 at least. The ftruncate discards all extents not +# accounted for in the size. +# fallocate -l 10MiB -n unacc.withholes +# dd count=10 if=/dev/urandom conv=notrunc iflag=fullblock of=unacc.withholes +# truncate -s20M unacc.withholes + +# Ensure we handle a hole after empty extents correctly. +# Since all extents are accounted for in the size, +# we can maintain the allocation independently from +# fallocate() support. +fallocate -l 10MiB empty.withholes +truncate -s 20M empty.withholes +sectors_per_block=$(expr $(stat -c %o .) / 512) +cp empty.withholes cp.test || fail=1 +test $(stat -c %s empty.withholes) = $(stat -c %s cp.test) || fail=1 +# These are usually equal but can vary by an IO block due to alignment +alloc_diff=$(expr $(stat -c %b empty.withholes) - $(stat -c %b cp.test)) +alloc_diff=$(echo $alloc_diff | tr -d -- -) # abs() +test $alloc_diff -le $sectors_per_block || fail=1 +# Again with SPARSE_ALWAYS +cp --sparse=always empty.withholes cp.test || fail=1 +test $(stat -c %s empty.withholes) = $(stat -c %s cp.test) || fail=1 +# cp.test should take 0 space, but allowing for some systems +# that store default extended attributes in data blocks +test $(stat -c %b cp.test) -le $sectors_per_block || fail=1 +rm empty.withholes cp.test + +Exit $fail diff --git a/tests/cp/fiemap-perf b/tests/cp/fiemap-perf deleted file mode 100755 index ca093b5a0..000000000 --- a/tests/cp/fiemap-perf +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# ensure that a sparse file is copied efficiently, by default - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# Require a fiemap-enabled FS. -touch fiemap_chk -fiemap_capable_ fiemap_chk || - skip_ "this file system lacks FIEMAP support" - -# Exclude ext[23] (or unknown fs types) -# as the emulated extent scanning can be slow -df -t ext2 -t ext3 . >/dev/null && - skip_ "ext[23] can have slow FIEMAP scanning" - -# Create a large-but-sparse file. -timeout 10 truncate -s1T f || - skip_ "unable to create a 1 TiB sparse file" - -# Disable this test on old BTRFS (e.g. Fedora 14) -# which reports (unwritten) extents for holes. -filefrag f || skip_ 'the 'filefrag' utility is missing' -filefrag f | grep -F ': 0 extents found' > /dev/null || - skip_ 'this file system reports extents for holes' - -# Nothing can read (much less write) that many bytes in so little time. -timeout 10 cp f f2 || fail=1 - -# Ensure that the sparse file copied through fiemap has the same size -# in bytes as the original. -test "$(stat --printf %s f)" = "$(stat --printf %s f2)" || fail=1 - -Exit $fail diff --git a/tests/cp/fiemap-perf.sh b/tests/cp/fiemap-perf.sh new file mode 100755 index 000000000..ca093b5a0 --- /dev/null +++ b/tests/cp/fiemap-perf.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ensure that a sparse file is copied efficiently, by default + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# Require a fiemap-enabled FS. +touch fiemap_chk +fiemap_capable_ fiemap_chk || + skip_ "this file system lacks FIEMAP support" + +# Exclude ext[23] (or unknown fs types) +# as the emulated extent scanning can be slow +df -t ext2 -t ext3 . >/dev/null && + skip_ "ext[23] can have slow FIEMAP scanning" + +# Create a large-but-sparse file. +timeout 10 truncate -s1T f || + skip_ "unable to create a 1 TiB sparse file" + +# Disable this test on old BTRFS (e.g. Fedora 14) +# which reports (unwritten) extents for holes. +filefrag f || skip_ 'the 'filefrag' utility is missing' +filefrag f | grep -F ': 0 extents found' > /dev/null || + skip_ 'this file system reports extents for holes' + +# Nothing can read (much less write) that many bytes in so little time. +timeout 10 cp f f2 || fail=1 + +# Ensure that the sparse file copied through fiemap has the same size +# in bytes as the original. +test "$(stat --printf %s f)" = "$(stat --printf %s f2)" || fail=1 + +Exit $fail diff --git a/tests/cp/file-perm-race b/tests/cp/file-perm-race deleted file mode 100755 index fbc9a86eb..000000000 --- a/tests/cp/file-perm-race +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# Make sure cp -p isn't too generous with file permissions. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least -require_local_dir_ - -umask 022 -mkfifo_or_skip_ fifo - -# Copy a fifo's contents. That way, we can examine the -# destination permissions before they're finalized. -cp -p --copy-contents fifo fifo-copy & -cp_pid=$! - -( - # Now 'cp' is reading the fifo. Wait for the destination file to - # be created, encouraging things along by echoing to the fifo. - while test ! -f fifo-copy; do - echo foo - done - - # Check the permissions of the destination. - ls -l fifo-copy >ls.out - - # Close the fifo so that "cp" can continue. But output first, - # before exiting, otherwise some shells would optimize away the file - # descriptor that holds the fifo open. - echo foo -) >fifo - -case $(cat ls.out) in --???------*) ;; -*) fail=1;; -esac - -wait $cp_pid || fail=1 - -Exit $fail diff --git a/tests/cp/file-perm-race.sh b/tests/cp/file-perm-race.sh new file mode 100755 index 000000000..fbc9a86eb --- /dev/null +++ b/tests/cp/file-perm-race.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Make sure cp -p isn't too generous with file permissions. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least +require_local_dir_ + +umask 022 +mkfifo_or_skip_ fifo + +# Copy a fifo's contents. That way, we can examine the +# destination permissions before they're finalized. +cp -p --copy-contents fifo fifo-copy & +cp_pid=$! + +( + # Now 'cp' is reading the fifo. Wait for the destination file to + # be created, encouraging things along by echoing to the fifo. + while test ! -f fifo-copy; do + echo foo + done + + # Check the permissions of the destination. + ls -l fifo-copy >ls.out + + # Close the fifo so that "cp" can continue. But output first, + # before exiting, otherwise some shells would optimize away the file + # descriptor that holds the fifo open. + echo foo +) >fifo + +case $(cat ls.out) in +-???------*) ;; +*) fail=1;; +esac + +wait $cp_pid || fail=1 + +Exit $fail diff --git a/tests/cp/into-self b/tests/cp/into-self deleted file mode 100755 index 6121f0ad8..000000000 --- a/tests/cp/into-self +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# Confirm that copying a directory into itself gets a proper diagnostic. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# In 4.0.35 and earlier, 'mkdir dir && cp -R dir dir' would produce this: -# cp: won't create hard link 'dir/dir/dir' to directory '' -# Now it gives this: -# cp: can't copy a directory 'dir' into itself 'dir/dir' - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir a dir || framework_failure_ - - -# This command should exit nonzero. -cp -R dir dir 2> out && fail=1 -echo 1 >> out - -# This should, too. However, with coreutils-7.1 it would infloop. -cp -rl dir dir 2>> out && fail=1 -echo 2 >> out - -cp -rl a dir dir 2>> out && fail=1 -echo 3 >> out -cp -rl a dir dir 2>> out && fail=1 -echo 4 >> out - -cat > exp <<\EOF -cp: cannot copy a directory, 'dir', into itself, 'dir/dir' -1 -cp: cannot copy a directory, 'dir', into itself, 'dir/dir' -2 -cp: cannot copy a directory, 'dir', into itself, 'dir/dir' -3 -cp: cannot copy a directory, 'dir', into itself, 'dir/dir' -4 -EOF -#' - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/cp/into-self.sh b/tests/cp/into-self.sh new file mode 100755 index 000000000..6121f0ad8 --- /dev/null +++ b/tests/cp/into-self.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Confirm that copying a directory into itself gets a proper diagnostic. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# In 4.0.35 and earlier, 'mkdir dir && cp -R dir dir' would produce this: +# cp: won't create hard link 'dir/dir/dir' to directory '' +# Now it gives this: +# cp: can't copy a directory 'dir' into itself 'dir/dir' + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir a dir || framework_failure_ + + +# This command should exit nonzero. +cp -R dir dir 2> out && fail=1 +echo 1 >> out + +# This should, too. However, with coreutils-7.1 it would infloop. +cp -rl dir dir 2>> out && fail=1 +echo 2 >> out + +cp -rl a dir dir 2>> out && fail=1 +echo 3 >> out +cp -rl a dir dir 2>> out && fail=1 +echo 4 >> out + +cat > exp <<\EOF +cp: cannot copy a directory, 'dir', into itself, 'dir/dir' +1 +cp: cannot copy a directory, 'dir', into itself, 'dir/dir' +2 +cp: cannot copy a directory, 'dir', into itself, 'dir/dir' +3 +cp: cannot copy a directory, 'dir', into itself, 'dir/dir' +4 +EOF +#' + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/cp/link b/tests/cp/link deleted file mode 100755 index 3a899f31c..000000000 --- a/tests/cp/link +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Make sure cp --link -f works when the target exists. -# This failed for 4.0z (due to a bug introduced in that test release). - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -touch src || framework_failure_ -touch dest || framework_failure_ -touch dest2 || framework_failure_ - - -cp -f --link src dest || fail=1 -cp -f --symbolic-link src dest2 || fail=1 - -Exit $fail diff --git a/tests/cp/link-heap b/tests/cp/link-heap deleted file mode 100755 index 7e948de7b..000000000 --- a/tests/cp/link-heap +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# ensure that cp --preserve=link --link doesn't waste heap - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -expensive_ -require_ulimit_ - -a=$(printf %031d 0) -b=$(printf %031d 1) -(mkdir $a \ - && cd $a \ - && seq --format=%031g 10000 |xargs touch \ - && seq --format=d%030g 10000 |xargs mkdir ) || framework_failure_ -cp -al $a $b || framework_failure_ -mkdir e || framework_failure_ -mv $a $b e || framework_failure_ - -(ulimit -v 20000; cp -al e f) || fail=1 - -Exit $fail diff --git a/tests/cp/link-heap.sh b/tests/cp/link-heap.sh new file mode 100755 index 000000000..7e948de7b --- /dev/null +++ b/tests/cp/link-heap.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# ensure that cp --preserve=link --link doesn't waste heap + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +expensive_ +require_ulimit_ + +a=$(printf %031d 0) +b=$(printf %031d 1) +(mkdir $a \ + && cd $a \ + && seq --format=%031g 10000 |xargs touch \ + && seq --format=d%030g 10000 |xargs mkdir ) || framework_failure_ +cp -al $a $b || framework_failure_ +mkdir e || framework_failure_ +mv $a $b e || framework_failure_ + +(ulimit -v 20000; cp -al e f) || fail=1 + +Exit $fail diff --git a/tests/cp/link-no-deref b/tests/cp/link-no-deref deleted file mode 100755 index af48fd085..000000000 --- a/tests/cp/link-no-deref +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Ensure that cp --link --no-dereference works properly - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -ln -s no-such-file dangling-slink || framework_failure_ - - -# Prior to coreutils-6.0, this would fail on non-Linux kernels, -# with link being applied to the dangling symlink. -cp --link --no-dereference dangling-slink d2 || fail=1 - -Exit $fail diff --git a/tests/cp/link-no-deref.sh b/tests/cp/link-no-deref.sh new file mode 100755 index 000000000..af48fd085 --- /dev/null +++ b/tests/cp/link-no-deref.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Ensure that cp --link --no-dereference works properly + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +ln -s no-such-file dangling-slink || framework_failure_ + + +# Prior to coreutils-6.0, this would fail on non-Linux kernels, +# with link being applied to the dangling symlink. +cp --link --no-dereference dangling-slink d2 || fail=1 + +Exit $fail diff --git a/tests/cp/link-preserve b/tests/cp/link-preserve deleted file mode 100755 index 9ca1705f5..000000000 --- a/tests/cp/link-preserve +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh -# ensure that 'cp -d' preserves hard-links between command line arguments -# ensure that --preserve=links works with -RH and -RL - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -touch a || framework_failure_ -ln a b || framework_failure_ -mkdir c || framework_failure_ -cp -d a b c || framework_failure_ -test -f c/a || framework_failure_ -test -f c/b || framework_failure_ - - -a_inode=$(ls -i c/a|sed 's,c/.*,,') -b_inode=$(ls -i c/b|sed 's,c/.*,,') -test "$a_inode" = "$b_inode" || fail=1 -# -------------------------------------- - -rm -rf a b c -touch a -ln -s a b -mkdir c -cp --preserve=links -R -H a b c -a_inode=$(ls -i c/a|sed 's,c/.*,,') -b_inode=$(ls -i c/b|sed 's,c/.*,,') -test "$a_inode" = "$b_inode" || fail=1 -# -------------------------------------- - -# Ensure that -L makes cp follow the b->a symlink -# and translates to hard-linked a and b in the destination dir. -rm -rf a b c d; mkdir d; (cd d; touch a; ln -s a b) -cp --preserve=links -R -L d c -a_inode=$(ls -i c/a|sed 's,c/.*,,') -b_inode=$(ls -i c/b|sed 's,c/.*,,') -test "$a_inode" = "$b_inode" || fail=1 -# -------------------------------------- - -# Same as above, but starting with a/b hard linked. -rm -rf a b c d; mkdir d; (cd d; touch a; ln a b) -cp --preserve=links -R -L d c -a_inode=$(ls -i c/a|sed 's,c/.*,,') -b_inode=$(ls -i c/b|sed 's,c/.*,,') -test "$a_inode" = "$b_inode" || fail=1 -# -------------------------------------- - -# Ensure that --no-preserve=links works. -rm -rf a b c d; mkdir d; (cd d; touch a; ln a b) -cp -dR --no-preserve=links d c -a_inode=$(ls -i c/a|sed 's,c/.*,,') -b_inode=$(ls -i c/b|sed 's,c/.*,,') -test "$a_inode" = "$b_inode" && fail=1 -# -------------------------------------- - -# Ensure that -d still preserves hard links. -rm -rf a b c d -touch a; ln a b -mkdir c -cp -d a b c -a_inode=$(ls -i c/a|sed 's,c/.*,,') -b_inode=$(ls -i c/b|sed 's,c/.*,,') -test "$a_inode" = "$b_inode" || fail=1 -# -------------------------------------- - -# Ensure that --no-preserve=mode works -rm -rf a b c d -touch a; chmod 731 a -umask 077 -cp -a --no-preserve=mode a b -mode=$(ls -l b|cut -b-10) -test "$mode" = "-rwx------" || fail=1 -umask 022 -# -------------------------------------- - -Exit $fail diff --git a/tests/cp/link-preserve.sh b/tests/cp/link-preserve.sh new file mode 100755 index 000000000..9ca1705f5 --- /dev/null +++ b/tests/cp/link-preserve.sh @@ -0,0 +1,91 @@ +#!/bin/sh +# ensure that 'cp -d' preserves hard-links between command line arguments +# ensure that --preserve=links works with -RH and -RL + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +touch a || framework_failure_ +ln a b || framework_failure_ +mkdir c || framework_failure_ +cp -d a b c || framework_failure_ +test -f c/a || framework_failure_ +test -f c/b || framework_failure_ + + +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') +test "$a_inode" = "$b_inode" || fail=1 +# -------------------------------------- + +rm -rf a b c +touch a +ln -s a b +mkdir c +cp --preserve=links -R -H a b c +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') +test "$a_inode" = "$b_inode" || fail=1 +# -------------------------------------- + +# Ensure that -L makes cp follow the b->a symlink +# and translates to hard-linked a and b in the destination dir. +rm -rf a b c d; mkdir d; (cd d; touch a; ln -s a b) +cp --preserve=links -R -L d c +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') +test "$a_inode" = "$b_inode" || fail=1 +# -------------------------------------- + +# Same as above, but starting with a/b hard linked. +rm -rf a b c d; mkdir d; (cd d; touch a; ln a b) +cp --preserve=links -R -L d c +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') +test "$a_inode" = "$b_inode" || fail=1 +# -------------------------------------- + +# Ensure that --no-preserve=links works. +rm -rf a b c d; mkdir d; (cd d; touch a; ln a b) +cp -dR --no-preserve=links d c +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') +test "$a_inode" = "$b_inode" && fail=1 +# -------------------------------------- + +# Ensure that -d still preserves hard links. +rm -rf a b c d +touch a; ln a b +mkdir c +cp -d a b c +a_inode=$(ls -i c/a|sed 's,c/.*,,') +b_inode=$(ls -i c/b|sed 's,c/.*,,') +test "$a_inode" = "$b_inode" || fail=1 +# -------------------------------------- + +# Ensure that --no-preserve=mode works +rm -rf a b c d +touch a; chmod 731 a +umask 077 +cp -a --no-preserve=mode a b +mode=$(ls -l b|cut -b-10) +test "$mode" = "-rwx------" || fail=1 +umask 022 +# -------------------------------------- + +Exit $fail diff --git a/tests/cp/link-symlink b/tests/cp/link-symlink deleted file mode 100755 index 57bc9c715..000000000 --- a/tests/cp/link-symlink +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Ensure that cp -a --link maintains timestamps if possible - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# Check that the timestamps of the symlink are copied -# if we're using hardlink to symlink emulation. -touch file -ln -s file link || framework_failure_ -touch -m -h -d 2011-01-01 link || - skip_ "Your system doesn't support updating symlink timestamps" -case $(stat --format=%y link) in - 2011-01-01*) ;; - *) skip_ "Your system doesn't support updating symlink timestamps" ;; -esac - -# link.cp is probably a hardlink, but may also be a symlink -# In either case the timestamp should match the original. -cp -al link link.cp -case $(stat --format=%y link.cp) in - 2011-01-01*) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/cp/link-symlink.sh b/tests/cp/link-symlink.sh new file mode 100755 index 000000000..57bc9c715 --- /dev/null +++ b/tests/cp/link-symlink.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Ensure that cp -a --link maintains timestamps if possible + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# Check that the timestamps of the symlink are copied +# if we're using hardlink to symlink emulation. +touch file +ln -s file link || framework_failure_ +touch -m -h -d 2011-01-01 link || + skip_ "Your system doesn't support updating symlink timestamps" +case $(stat --format=%y link) in + 2011-01-01*) ;; + *) skip_ "Your system doesn't support updating symlink timestamps" ;; +esac + +# link.cp is probably a hardlink, but may also be a symlink +# In either case the timestamp should match the original. +cp -al link link.cp +case $(stat --format=%y link.cp) in + 2011-01-01*) ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/cp/link.sh b/tests/cp/link.sh new file mode 100755 index 000000000..3a899f31c --- /dev/null +++ b/tests/cp/link.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Make sure cp --link -f works when the target exists. +# This failed for 4.0z (due to a bug introduced in that test release). + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +touch src || framework_failure_ +touch dest || framework_failure_ +touch dest2 || framework_failure_ + + +cp -f --link src dest || fail=1 +cp -f --symbolic-link src dest2 || fail=1 + +Exit $fail diff --git a/tests/cp/nfs-removal-race b/tests/cp/nfs-removal-race deleted file mode 100755 index cb8aba37f..000000000 --- a/tests/cp/nfs-removal-race +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# Running cp S D on an NFS client while another client has just removed D -# would lead (w/coreutils-8.16 and earlier) to cp's initial stat call -# seeing (via stale NFS cache) that D exists, so that cp would then call -# open without the O_CREAT flag. Yet, the open must actually consult -# the server, which confesses that D has been deleted, thus causing the -# open call to fail with ENOENT. -# -# This test simulates that situation by intercepting stat for a nonexistent -# destination, D, and making the stat fill in the result struct for another -# file and return 0. -# -# This test is skipped on systems that lack LD_PRELOAD support; that's fine. -# Similarly, on a system that lacks or __xstat, skipping it is fine. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# Replace each stat call with a call to this wrapper. -cat > k.c <<'EOF' || framework_failure_ -#define _GNU_SOURCE -#include -#include - -#define __xstat __xstat_orig - -#include -#include - -#undef __xstat - -int -__xstat (int ver, const char *path, struct stat *st) -{ - static int (*real_stat)(int ver, const char *path, struct stat *st) = NULL; - if (!real_stat) - real_stat = dlsym (RTLD_NEXT, "__xstat"); - /* When asked to stat nonexistent "d", - return results suggesting it exists. */ - return real_stat (ver, *path == 'd' && path[1] == 0 ? "d2" : path, st); -} -EOF - -# Then compile/link it: -$CC -shared -fPIC -O2 k.c -o k.so -ldl \ - || framework_failure_ 'failed to compile with -shared -fPIC' - -touch d2 || framework_failure_ -echo xyz > src || framework_failure_ - -# Finally, run the test: -LD_PRELOAD=./k.so cp src d || fail=1 - -compare src d || fail=1 -Exit $fail diff --git a/tests/cp/nfs-removal-race.sh b/tests/cp/nfs-removal-race.sh new file mode 100755 index 000000000..cb8aba37f --- /dev/null +++ b/tests/cp/nfs-removal-race.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Running cp S D on an NFS client while another client has just removed D +# would lead (w/coreutils-8.16 and earlier) to cp's initial stat call +# seeing (via stale NFS cache) that D exists, so that cp would then call +# open without the O_CREAT flag. Yet, the open must actually consult +# the server, which confesses that D has been deleted, thus causing the +# open call to fail with ENOENT. +# +# This test simulates that situation by intercepting stat for a nonexistent +# destination, D, and making the stat fill in the result struct for another +# file and return 0. +# +# This test is skipped on systems that lack LD_PRELOAD support; that's fine. +# Similarly, on a system that lacks or __xstat, skipping it is fine. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# Replace each stat call with a call to this wrapper. +cat > k.c <<'EOF' || framework_failure_ +#define _GNU_SOURCE +#include +#include + +#define __xstat __xstat_orig + +#include +#include + +#undef __xstat + +int +__xstat (int ver, const char *path, struct stat *st) +{ + static int (*real_stat)(int ver, const char *path, struct stat *st) = NULL; + if (!real_stat) + real_stat = dlsym (RTLD_NEXT, "__xstat"); + /* When asked to stat nonexistent "d", + return results suggesting it exists. */ + return real_stat (ver, *path == 'd' && path[1] == 0 ? "d2" : path, st); +} +EOF + +# Then compile/link it: +$CC -shared -fPIC -O2 k.c -o k.so -ldl \ + || framework_failure_ 'failed to compile with -shared -fPIC' + +touch d2 || framework_failure_ +echo xyz > src || framework_failure_ + +# Finally, run the test: +LD_PRELOAD=./k.so cp src d || fail=1 + +compare src d || fail=1 +Exit $fail diff --git a/tests/cp/no-deref-link1 b/tests/cp/no-deref-link1 deleted file mode 100755 index c2a565793..000000000 --- a/tests/cp/no-deref-link1 +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# cp from 3.16 fails this test - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir a b -msg=bar -echo $msg > a/foo -cd b -ln -s ../a/foo . -cd .. - - -# It should fail with a message something like this: -# ./cp: 'a/foo' and 'b/foo' are the same file -cp -d a/foo b 2>/dev/null - -# Fail this test if the exit status is not 1 -test $? = 1 || fail=1 - -test "$(cat a/foo)" = $msg || fail=1 - -Exit $fail diff --git a/tests/cp/no-deref-link1.sh b/tests/cp/no-deref-link1.sh new file mode 100755 index 000000000..c2a565793 --- /dev/null +++ b/tests/cp/no-deref-link1.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# cp from 3.16 fails this test + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir a b +msg=bar +echo $msg > a/foo +cd b +ln -s ../a/foo . +cd .. + + +# It should fail with a message something like this: +# ./cp: 'a/foo' and 'b/foo' are the same file +cp -d a/foo b 2>/dev/null + +# Fail this test if the exit status is not 1 +test $? = 1 || fail=1 + +test "$(cat a/foo)" = $msg || fail=1 + +Exit $fail diff --git a/tests/cp/no-deref-link2 b/tests/cp/no-deref-link2 deleted file mode 100755 index 584029954..000000000 --- a/tests/cp/no-deref-link2 +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# cp from 3.16 fails this test - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir b -msg=bar -echo $msg > a -cd b -ln -s ../a . -cd .. - - -# It should fail with a message something like this: -# cp: 'a' and 'b/foo' are the same file -cp -d a b 2>/dev/null - -# Fail this test if the exit status is not 1 -test $? = 1 || fail=1 - -test "$(cat a)" = $msg || fail=1 - -Exit $fail diff --git a/tests/cp/no-deref-link2.sh b/tests/cp/no-deref-link2.sh new file mode 100755 index 000000000..584029954 --- /dev/null +++ b/tests/cp/no-deref-link2.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# cp from 3.16 fails this test + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir b +msg=bar +echo $msg > a +cd b +ln -s ../a . +cd .. + + +# It should fail with a message something like this: +# cp: 'a' and 'b/foo' are the same file +cp -d a b 2>/dev/null + +# Fail this test if the exit status is not 1 +test $? = 1 || fail=1 + +test "$(cat a)" = $msg || fail=1 + +Exit $fail diff --git a/tests/cp/no-deref-link3 b/tests/cp/no-deref-link3 deleted file mode 100755 index 5f63f2699..000000000 --- a/tests/cp/no-deref-link3 +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# cp from 3.16 fails this test - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -msg=bar -echo $msg > a -ln -s a b - - -# It should fail with a message something like this: -# cp: 'a' and 'b' are the same file -cp -d a b 2>/dev/null - -# Fail this test if the exit status is not 1 -test $? = 1 || fail=1 - -test "$(cat a)" = $msg || fail=1 - -Exit $fail diff --git a/tests/cp/no-deref-link3.sh b/tests/cp/no-deref-link3.sh new file mode 100755 index 000000000..5f63f2699 --- /dev/null +++ b/tests/cp/no-deref-link3.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# cp from 3.16 fails this test + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +msg=bar +echo $msg > a +ln -s a b + + +# It should fail with a message something like this: +# cp: 'a' and 'b' are the same file +cp -d a b 2>/dev/null + +# Fail this test if the exit status is not 1 +test $? = 1 || fail=1 + +test "$(cat a)" = $msg || fail=1 + +Exit $fail diff --git a/tests/cp/parent-perm b/tests/cp/parent-perm deleted file mode 100755 index bac38c683..000000000 --- a/tests/cp/parent-perm +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# Ensure that cp --parents works properly with a preexisting dest. directory - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -working_umask_or_skip_ -# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least -require_local_dir_ - -mkdir -p a/b/c a/b/d e || framework_failure_ -touch a/b/c/foo a/b/d/foo || framework_failure_ -cp -p --parent a/b/c/foo e || framework_failure_ - -# Make permissions of e/a different, so that we exercise the -# code in cp -p --parents that propagates permissions even -# to a destination directory that it doesn't create. -chmod g-rx e/a e/a/b || framework_failure_ - -cp -p --parent a/b/d/foo e || fail=1 - -# Ensure that permissions on just-created directory, e/a/, -# are the same as those on original, a/. - -# The sed filter maps any 's' from an inherited set-GID bit -# to the usual 'x'. Otherwise, under unusual circumstances, this -# test would fail with e.g., drwxr-sr-x != drwxr-xr-x . -# For reference, the unusual circumstances is: build dir is set-gid, -# so "a/" inherits that. However, when the user does not belong to -# the group of the build directory, chmod ("a/e", 02755) returns 0, -# yet fails to set the S_ISGID bit. -for dir in a a/b a/b/d; do - test $(stat --printf %A $dir|sed s/s/x/g) \ - = $(stat --printf %A e/$dir|sed s/s/x/g) || - fail=1 -done - -Exit $fail diff --git a/tests/cp/parent-perm-race b/tests/cp/parent-perm-race deleted file mode 100755 index 41486fcb1..000000000 --- a/tests/cp/parent-perm-race +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -# Make sure cp -pR --parents isn't too generous with parent permissions. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least -require_local_dir_ - -umask 002 -mkdir mode ownership d || framework_failure_ -chmod g+s d 2>/dev/null # The cp test is valid either way. - - -for attr in mode ownership -do - mkfifo_or_skip_ $attr/fifo - - # Copy a fifo's contents. That way, we can examine d/$attr's - # state while cp is running. - cp --preserve=$attr -R --copy-contents --parents $attr d & - cp_pid=$! - - ( - # Now 'cp' is reading the fifo. - # Check the permissions of the temporary destination - # directory that 'cp' has made. - ls -ld d/$attr >d/$attr.ls - - # Close the fifo so that "cp" can continue. But output first, - # before exiting, otherwise some shells would optimize away the file - # descriptor that holds the fifo open. - echo foo - ) >$attr/fifo - - ls_output=$(cat d/$attr.ls) || fail=1 - case $attr,$ls_output in - ownership,d???--[-S]--[-S]* | \ - mode,d????-??-?* | \ - mode,d??[-x]?w[-x]?-[-x]* ) - ;; - *) - fail=1;; - esac - - wait $cp_pid || fail=1 -done - -Exit $fail diff --git a/tests/cp/parent-perm-race.sh b/tests/cp/parent-perm-race.sh new file mode 100755 index 000000000..41486fcb1 --- /dev/null +++ b/tests/cp/parent-perm-race.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# Make sure cp -pR --parents isn't too generous with parent permissions. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least +require_local_dir_ + +umask 002 +mkdir mode ownership d || framework_failure_ +chmod g+s d 2>/dev/null # The cp test is valid either way. + + +for attr in mode ownership +do + mkfifo_or_skip_ $attr/fifo + + # Copy a fifo's contents. That way, we can examine d/$attr's + # state while cp is running. + cp --preserve=$attr -R --copy-contents --parents $attr d & + cp_pid=$! + + ( + # Now 'cp' is reading the fifo. + # Check the permissions of the temporary destination + # directory that 'cp' has made. + ls -ld d/$attr >d/$attr.ls + + # Close the fifo so that "cp" can continue. But output first, + # before exiting, otherwise some shells would optimize away the file + # descriptor that holds the fifo open. + echo foo + ) >$attr/fifo + + ls_output=$(cat d/$attr.ls) || fail=1 + case $attr,$ls_output in + ownership,d???--[-S]--[-S]* | \ + mode,d????-??-?* | \ + mode,d??[-x]?w[-x]?-[-x]* ) + ;; + *) + fail=1;; + esac + + wait $cp_pid || fail=1 +done + +Exit $fail diff --git a/tests/cp/parent-perm.sh b/tests/cp/parent-perm.sh new file mode 100755 index 000000000..bac38c683 --- /dev/null +++ b/tests/cp/parent-perm.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Ensure that cp --parents works properly with a preexisting dest. directory + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +working_umask_or_skip_ +# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least +require_local_dir_ + +mkdir -p a/b/c a/b/d e || framework_failure_ +touch a/b/c/foo a/b/d/foo || framework_failure_ +cp -p --parent a/b/c/foo e || framework_failure_ + +# Make permissions of e/a different, so that we exercise the +# code in cp -p --parents that propagates permissions even +# to a destination directory that it doesn't create. +chmod g-rx e/a e/a/b || framework_failure_ + +cp -p --parent a/b/d/foo e || fail=1 + +# Ensure that permissions on just-created directory, e/a/, +# are the same as those on original, a/. + +# The sed filter maps any 's' from an inherited set-GID bit +# to the usual 'x'. Otherwise, under unusual circumstances, this +# test would fail with e.g., drwxr-sr-x != drwxr-xr-x . +# For reference, the unusual circumstances is: build dir is set-gid, +# so "a/" inherits that. However, when the user does not belong to +# the group of the build directory, chmod ("a/e", 02755) returns 0, +# yet fails to set the S_ISGID bit. +for dir in a a/b a/b/d; do + test $(stat --printf %A $dir|sed s/s/x/g) \ + = $(stat --printf %A e/$dir|sed s/s/x/g) || + fail=1 +done + +Exit $fail diff --git a/tests/cp/perm b/tests/cp/perm deleted file mode 100755 index a93df7182..000000000 --- a/tests/cp/perm +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# Make sure the permission-preserving code in copy.c (mv, cp, install) works. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv - -very_expensive_ - -umask 037 - - -# Now, try it with 'mv', with combinations of --force, no-f and -# existing-destination and not. -for u in 31 37 2; do - echo umask: $u - umask $u - for cmd in mv 'cp -p' cp; do - for force in '' -f; do - for existing_dest in yes no; do - for g_perm in r w x rw wx xr rwx; do - for o_perm in r w x rw wx xr rwx; do - touch src || exit 1 - chmod u=r,g=rx,o= src || exit 1 - expected_perms=$(stat --format=%A src) - rm -f dest - test $existing_dest = yes && { - touch dest || exit 1 - chmod u=rw,g=$g_perm,o=$o_perm dest || exit 1 - } - $cmd $force src dest || exit 1 - test "$cmd" = mv && test -f src && exit 1 - test "$cmd" = cp && { test -f src || exit 1; } - actual_perms=$(stat --format=%A dest) - - case "$cmd:$force:$existing_dest" in - cp:*:yes) - _g_perm=$(echo rwx|sed 's/[^'$g_perm']/-/g') - _o_perm=$(echo rwx|sed 's/[^'$o_perm']/-/g') - expected_perms=-rw-$_g_perm$_o_perm - ;; - cp:*:no) - test $u = 37 && - expected_perms=$( - echo $expected_perms | sed 's/.....$/-----/' - ) - test $u = 31 && - expected_perms=$( - echo $expected_perms | sed 's/..\(..\).$/--\1-/' - ) - ;; - esac - test _$actual_perms = _$expected_perms || exit 1 - # Perform only one iteration when there's no existing destination. - test $existing_dest = no && break 3 - done - done - done - done - done -done - -Exit $fail diff --git a/tests/cp/perm.sh b/tests/cp/perm.sh new file mode 100755 index 000000000..a93df7182 --- /dev/null +++ b/tests/cp/perm.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# Make sure the permission-preserving code in copy.c (mv, cp, install) works. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv + +very_expensive_ + +umask 037 + + +# Now, try it with 'mv', with combinations of --force, no-f and +# existing-destination and not. +for u in 31 37 2; do + echo umask: $u + umask $u + for cmd in mv 'cp -p' cp; do + for force in '' -f; do + for existing_dest in yes no; do + for g_perm in r w x rw wx xr rwx; do + for o_perm in r w x rw wx xr rwx; do + touch src || exit 1 + chmod u=r,g=rx,o= src || exit 1 + expected_perms=$(stat --format=%A src) + rm -f dest + test $existing_dest = yes && { + touch dest || exit 1 + chmod u=rw,g=$g_perm,o=$o_perm dest || exit 1 + } + $cmd $force src dest || exit 1 + test "$cmd" = mv && test -f src && exit 1 + test "$cmd" = cp && { test -f src || exit 1; } + actual_perms=$(stat --format=%A dest) + + case "$cmd:$force:$existing_dest" in + cp:*:yes) + _g_perm=$(echo rwx|sed 's/[^'$g_perm']/-/g') + _o_perm=$(echo rwx|sed 's/[^'$o_perm']/-/g') + expected_perms=-rw-$_g_perm$_o_perm + ;; + cp:*:no) + test $u = 37 && + expected_perms=$( + echo $expected_perms | sed 's/.....$/-----/' + ) + test $u = 31 && + expected_perms=$( + echo $expected_perms | sed 's/..\(..\).$/--\1-/' + ) + ;; + esac + test _$actual_perms = _$expected_perms || exit 1 + # Perform only one iteration when there's no existing destination. + test $existing_dest = no && break 3 + done + done + done + done + done +done + +Exit $fail diff --git a/tests/cp/preserve-2 b/tests/cp/preserve-2 deleted file mode 100755 index fea4b6c33..000000000 --- a/tests/cp/preserve-2 +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# ensure that cp's --preserve=X,Y option is parsed properly - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least -require_local_dir_ - -touch f || framework_failure_ - -cp --preserve=mode,links f g || fail=1 - -Exit $fail diff --git a/tests/cp/preserve-2.sh b/tests/cp/preserve-2.sh new file mode 100755 index 000000000..fea4b6c33 --- /dev/null +++ b/tests/cp/preserve-2.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# ensure that cp's --preserve=X,Y option is parsed properly + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least +require_local_dir_ + +touch f || framework_failure_ + +cp --preserve=mode,links f g || fail=1 + +Exit $fail diff --git a/tests/cp/preserve-gid b/tests/cp/preserve-gid deleted file mode 100755 index 746c57a60..000000000 --- a/tests/cp/preserve-gid +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/sh -# Verify that cp -p preserves GID when it is possible. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -require_root_ - -# Some of the tests expect a umask that grants group and/or world read access. -working_umask_or_skip_ - -# Record primary group number, usually 0. -# This is the group ID used when cp (without -p) creates a new file. -primary_group_num=$(id -g) - -create() { - echo "$1" > "$1" || exit 1 - chown "+$2:+$3" "$1" || exit 1 -} - -t0() { - f=$1; shift - u=$1; shift - g=$1; shift - rm -f b || exit 1 - "$@" "$f" b || exit 1 - s=$(stat -c '%u %g' b) - if test "x$s" != "x$u $g"; then - # Allow the actual group to match that of the parent directory - # (it was set to 0 above). - if test "x$s" = "x$u $primary_group_num"; then - : - else - echo "$0: $* $f b: $u $g != $s" 1>&2 - Exit 1 - fi - fi -} - -nameless_uid=$($PERL -le ' - foreach my $i (1000..16*1024-1) - { - getpwuid $i or (print $i), exit - } -') -nameless_gid1=$($PERL -le ' - foreach my $i (1000..16*1024) - { - getgrgid $i or (print $i), exit - } -') -nameless_gid2=$($PERL -le ' - foreach my $i ('"$nameless_gid1"'+1..16*1024) - { - getgrgid $i or (print $i), exit - } -') - -if test -z "$nameless_uid" \ - || test -z "$nameless_gid1" \ - || test -z "$nameless_gid2"; then - skip_ "couldn't find a nameless UID or GID" -fi - -chown "+$nameless_uid:+0" . - -create a0 0 0 -create b0 "$nameless_uid" "$nameless_gid1" -create b1 "$nameless_uid" "$nameless_gid2" -create c0 0 "$nameless_gid1" -create c1 0 "$nameless_gid2" - -t0 a0 0 0 cp -t0 b0 0 0 cp -t0 b1 0 0 cp -t0 c0 0 0 cp -t0 c1 0 0 cp - -t0 a0 0 0 cp -p -t0 b0 "$nameless_uid" "$nameless_gid1" cp -p -t0 b1 "$nameless_uid" "$nameless_gid2" cp -p -t0 c0 0 "$nameless_gid1" cp -p -t0 c1 0 "$nameless_gid2" cp -p - -# For the remaining tests, we need a cp binary that is accessible to a user -# with UID of $nameless_uid. The build directory may not be accessible, -# so create a temporary directory and copy cp into it, ensure that -# $nameless_uid can access it and then make that directory the search path. -tmp_path= -cleanup_() { rm -rf "$tmp_path"; } - -# Cause mktemp to create a directory directly under /tmp. -# Setting TMPDIR explicitly is required here, in case $TMPDIR -# is not readable by our nameless IDs. -test -d /tmp && TMPDIR=/tmp -tmp_path=$(mktemp -d) || fail_ "failed to create temporary directory" -cp "$abs_path_dir_/cp" "$tmp_path" -chmod -R a+rx "$tmp_path" - -t1() { - f=$1; shift - u=$1; shift - g=$1; shift - t0 "$f" "$u" "$g" \ - setuidgid -g "$nameless_gid1,$nameless_gid2" \ - "$nameless_uid" env PATH="$tmp_path" "$@" -} - -t1 a0 "$nameless_uid" "$nameless_gid1" cp -t1 b0 "$nameless_uid" "$nameless_gid1" cp -t1 b1 "$nameless_uid" "$nameless_gid1" cp -t1 c0 "$nameless_uid" "$nameless_gid1" cp -t1 c1 "$nameless_uid" "$nameless_gid1" cp - -t1 a0 "$nameless_uid" "$nameless_gid1" cp -p -t1 b0 "$nameless_uid" "$nameless_gid1" cp -p -t1 b1 "$nameless_uid" "$nameless_gid2" cp -p -t1 c0 "$nameless_uid" "$nameless_gid1" cp -p -t1 c1 "$nameless_uid" "$nameless_gid2" cp -p - -Exit $fail diff --git a/tests/cp/preserve-gid.sh b/tests/cp/preserve-gid.sh new file mode 100755 index 000000000..746c57a60 --- /dev/null +++ b/tests/cp/preserve-gid.sh @@ -0,0 +1,136 @@ +#!/bin/sh +# Verify that cp -p preserves GID when it is possible. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +require_root_ + +# Some of the tests expect a umask that grants group and/or world read access. +working_umask_or_skip_ + +# Record primary group number, usually 0. +# This is the group ID used when cp (without -p) creates a new file. +primary_group_num=$(id -g) + +create() { + echo "$1" > "$1" || exit 1 + chown "+$2:+$3" "$1" || exit 1 +} + +t0() { + f=$1; shift + u=$1; shift + g=$1; shift + rm -f b || exit 1 + "$@" "$f" b || exit 1 + s=$(stat -c '%u %g' b) + if test "x$s" != "x$u $g"; then + # Allow the actual group to match that of the parent directory + # (it was set to 0 above). + if test "x$s" = "x$u $primary_group_num"; then + : + else + echo "$0: $* $f b: $u $g != $s" 1>&2 + Exit 1 + fi + fi +} + +nameless_uid=$($PERL -le ' + foreach my $i (1000..16*1024-1) + { + getpwuid $i or (print $i), exit + } +') +nameless_gid1=$($PERL -le ' + foreach my $i (1000..16*1024) + { + getgrgid $i or (print $i), exit + } +') +nameless_gid2=$($PERL -le ' + foreach my $i ('"$nameless_gid1"'+1..16*1024) + { + getgrgid $i or (print $i), exit + } +') + +if test -z "$nameless_uid" \ + || test -z "$nameless_gid1" \ + || test -z "$nameless_gid2"; then + skip_ "couldn't find a nameless UID or GID" +fi + +chown "+$nameless_uid:+0" . + +create a0 0 0 +create b0 "$nameless_uid" "$nameless_gid1" +create b1 "$nameless_uid" "$nameless_gid2" +create c0 0 "$nameless_gid1" +create c1 0 "$nameless_gid2" + +t0 a0 0 0 cp +t0 b0 0 0 cp +t0 b1 0 0 cp +t0 c0 0 0 cp +t0 c1 0 0 cp + +t0 a0 0 0 cp -p +t0 b0 "$nameless_uid" "$nameless_gid1" cp -p +t0 b1 "$nameless_uid" "$nameless_gid2" cp -p +t0 c0 0 "$nameless_gid1" cp -p +t0 c1 0 "$nameless_gid2" cp -p + +# For the remaining tests, we need a cp binary that is accessible to a user +# with UID of $nameless_uid. The build directory may not be accessible, +# so create a temporary directory and copy cp into it, ensure that +# $nameless_uid can access it and then make that directory the search path. +tmp_path= +cleanup_() { rm -rf "$tmp_path"; } + +# Cause mktemp to create a directory directly under /tmp. +# Setting TMPDIR explicitly is required here, in case $TMPDIR +# is not readable by our nameless IDs. +test -d /tmp && TMPDIR=/tmp +tmp_path=$(mktemp -d) || fail_ "failed to create temporary directory" +cp "$abs_path_dir_/cp" "$tmp_path" +chmod -R a+rx "$tmp_path" + +t1() { + f=$1; shift + u=$1; shift + g=$1; shift + t0 "$f" "$u" "$g" \ + setuidgid -g "$nameless_gid1,$nameless_gid2" \ + "$nameless_uid" env PATH="$tmp_path" "$@" +} + +t1 a0 "$nameless_uid" "$nameless_gid1" cp +t1 b0 "$nameless_uid" "$nameless_gid1" cp +t1 b1 "$nameless_uid" "$nameless_gid1" cp +t1 c0 "$nameless_uid" "$nameless_gid1" cp +t1 c1 "$nameless_uid" "$nameless_gid1" cp + +t1 a0 "$nameless_uid" "$nameless_gid1" cp -p +t1 b0 "$nameless_uid" "$nameless_gid1" cp -p +t1 b1 "$nameless_uid" "$nameless_gid2" cp -p +t1 c0 "$nameless_uid" "$nameless_gid1" cp -p +t1 c1 "$nameless_uid" "$nameless_gid2" cp -p + +Exit $fail diff --git a/tests/cp/preserve-link b/tests/cp/preserve-link deleted file mode 100755 index 5f069af7c..000000000 --- a/tests/cp/preserve-link +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# Exercise the fix for http://debbugs.gnu.org/8419 - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -same_inode() -{ - local u v - u=$(stat --format %i "$1") && - v=$(stat --format %i "$2") && test "$u" = "$v" -} - -create_source_tree() -{ - rm -Rf s - mkdir s || framework_failure_ - - # a missing link in dest will be created - touch s/f || framework_failure_ - ln s/f s/linkm || framework_failure_ - - # an existing link in dest will be maintained - ln s/f s/linke || framework_failure_ - - # a separate older file in dest will be overwritten - ln s/f s/fileo || framework_failure_ - - # a separate newer file in dest will be overwritten! - ln s/f s/fileu || framework_failure_ -} - -create_target_tree() -{ - f=$1 # which of f or linkm to create in t/ - - rm -Rf t - mkdir -p t/s/ || framework_failure_ - - # a missing link in dest must be created - touch t/s/$f || framework_failure_ - - # an existing link must be maintained - ln t/s/$f t/s/linke || framework_failure_ - - # a separate older file in dest will be overwritten - touch -d '-1 hour' t/s/fileo || framework_failure_ - - # a separate newer file in dest will be overwritten! - touch -d '+1 hour' t/s/fileu || framework_failure_ -} - - -# Note we repeat this, creating either one of -# two hard linked files from source in the dest, so as to -# test both paths in $(cp) for creating the hard links. -# The path taken by cp is dependent on which cp encounters -# first in the source, which is non deterministic currently -# (I'm guessing that results are sorted by inode and -# beauses they're the same here, and due to the sort -# being unstable, either can be processed first). -create_source_tree - -for f in f linkm; do - create_target_tree $f - - # Copy all the hard links across. With cp from coreutils-8.12 - # and prior, it would sometimes mistakenly copy rather than link. - cp -au s t || fail=1 - - same_inode t/s/f t/s/linkm || fail=1 - same_inode t/s/f t/s/linke || fail=1 - same_inode t/s/f t/s/fileo || fail=1 - same_inode t/s/f t/s/fileu || fail=1 -done - -Exit $fail diff --git a/tests/cp/preserve-link.sh b/tests/cp/preserve-link.sh new file mode 100755 index 000000000..5f069af7c --- /dev/null +++ b/tests/cp/preserve-link.sh @@ -0,0 +1,92 @@ +#!/bin/sh +# Exercise the fix for http://debbugs.gnu.org/8419 + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +same_inode() +{ + local u v + u=$(stat --format %i "$1") && + v=$(stat --format %i "$2") && test "$u" = "$v" +} + +create_source_tree() +{ + rm -Rf s + mkdir s || framework_failure_ + + # a missing link in dest will be created + touch s/f || framework_failure_ + ln s/f s/linkm || framework_failure_ + + # an existing link in dest will be maintained + ln s/f s/linke || framework_failure_ + + # a separate older file in dest will be overwritten + ln s/f s/fileo || framework_failure_ + + # a separate newer file in dest will be overwritten! + ln s/f s/fileu || framework_failure_ +} + +create_target_tree() +{ + f=$1 # which of f or linkm to create in t/ + + rm -Rf t + mkdir -p t/s/ || framework_failure_ + + # a missing link in dest must be created + touch t/s/$f || framework_failure_ + + # an existing link must be maintained + ln t/s/$f t/s/linke || framework_failure_ + + # a separate older file in dest will be overwritten + touch -d '-1 hour' t/s/fileo || framework_failure_ + + # a separate newer file in dest will be overwritten! + touch -d '+1 hour' t/s/fileu || framework_failure_ +} + + +# Note we repeat this, creating either one of +# two hard linked files from source in the dest, so as to +# test both paths in $(cp) for creating the hard links. +# The path taken by cp is dependent on which cp encounters +# first in the source, which is non deterministic currently +# (I'm guessing that results are sorted by inode and +# beauses they're the same here, and due to the sort +# being unstable, either can be processed first). +create_source_tree + +for f in f linkm; do + create_target_tree $f + + # Copy all the hard links across. With cp from coreutils-8.12 + # and prior, it would sometimes mistakenly copy rather than link. + cp -au s t || fail=1 + + same_inode t/s/f t/s/linkm || fail=1 + same_inode t/s/f t/s/linke || fail=1 + same_inode t/s/f t/s/fileo || fail=1 + same_inode t/s/f t/s/fileu || fail=1 +done + +Exit $fail diff --git a/tests/cp/preserve-slink-time b/tests/cp/preserve-slink-time deleted file mode 100755 index dc5d1cdd8..000000000 --- a/tests/cp/preserve-slink-time +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Verify that cp -Pp preserves times even on symlinks. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null || -grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null || - skip_ 'this system lacks the utimensat function' - -ln -s no-such dangle || framework_failure_ - -# If the current file system lacks sub-second resolution, sleep for 2s to -# ensure that the times on the copy are different from those of the original. -case $(stat --format=%y dangle) in - ??:??:??.000000000) sleep 2;; -esac - -# Can't use --format=%x, as lstat() modifies atime on some platforms. -cp -Pp dangle d2 || framework_failure_ -stat --format=%y dangle > t1 || framework_failure_ -stat --format=%y d2 > t2 || framework_failure_ - -compare t1 t2 || fail=1 - -Exit $fail diff --git a/tests/cp/preserve-slink-time.sh b/tests/cp/preserve-slink-time.sh new file mode 100755 index 000000000..dc5d1cdd8 --- /dev/null +++ b/tests/cp/preserve-slink-time.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Verify that cp -Pp preserves times even on symlinks. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null || +grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null || + skip_ 'this system lacks the utimensat function' + +ln -s no-such dangle || framework_failure_ + +# If the current file system lacks sub-second resolution, sleep for 2s to +# ensure that the times on the copy are different from those of the original. +case $(stat --format=%y dangle) in + ??:??:??.000000000) sleep 2;; +esac + +# Can't use --format=%x, as lstat() modifies atime on some platforms. +cp -Pp dangle d2 || framework_failure_ +stat --format=%y dangle > t1 || framework_failure_ +stat --format=%y d2 > t2 || framework_failure_ + +compare t1 t2 || fail=1 + +Exit $fail diff --git a/tests/cp/proc-short-read b/tests/cp/proc-short-read deleted file mode 100755 index 632418e4b..000000000 --- a/tests/cp/proc-short-read +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# exercise cp's short-read failure when operating on >4KB files in /proc - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -kall=/proc/kallsyms - -test -r $kall || skip_ "your system lacks $kall" - -# Before coreutils-7.3, cp would copy less than 4KiB of this 1MB+ file. -cp $kall 1 || fail=1 -cat $kall > 2 || fail=1 -compare 1 2 || fail=1 - -# Also check md5sum, just for good measure. -md5sum $kall > 3 || fail=1 -md5sum 2 > 4 || fail=1 - -# Remove each file name before comparing checksums. -sed 's/ .*//' 3 > sum.proc || fail=1 -sed 's/ .*//' 4 > sum.2 || fail=1 -compare sum.proc sum.2 || fail=1 - -Exit $fail diff --git a/tests/cp/proc-short-read.sh b/tests/cp/proc-short-read.sh new file mode 100755 index 000000000..632418e4b --- /dev/null +++ b/tests/cp/proc-short-read.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# exercise cp's short-read failure when operating on >4KB files in /proc + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +kall=/proc/kallsyms + +test -r $kall || skip_ "your system lacks $kall" + +# Before coreutils-7.3, cp would copy less than 4KiB of this 1MB+ file. +cp $kall 1 || fail=1 +cat $kall > 2 || fail=1 +compare 1 2 || fail=1 + +# Also check md5sum, just for good measure. +md5sum $kall > 3 || fail=1 +md5sum 2 > 4 || fail=1 + +# Remove each file name before comparing checksums. +sed 's/ .*//' 3 > sum.proc || fail=1 +sed 's/ .*//' 4 > sum.2 || fail=1 +compare sum.proc sum.2 || fail=1 + +Exit $fail diff --git a/tests/cp/proc-zero-len b/tests/cp/proc-zero-len deleted file mode 100755 index b8b9e9c60..000000000 --- a/tests/cp/proc-zero-len +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Ensure that cp copies contents of non-empty "regular" file with st_size==0 - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -touch empty || framework_failure_ - -f=/proc/cpuinfo -test -r $f || f=empty - -cat $f > out || fail=1 - -# With coreutils-6.9, this would create a zero-length "exp" file. -cp $f exp || fail=1 - -# Don't simply compare contents; they might differ, -# e.g., if CPU freq changes between cat and cp invocations. -# Instead, simply compare whether they're both nonempty. -test -s out && { rm -f out; echo nonempty > out; } -test -s exp && { rm -f exp; echo nonempty > exp; } - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/cp/proc-zero-len.sh b/tests/cp/proc-zero-len.sh new file mode 100755 index 000000000..b8b9e9c60 --- /dev/null +++ b/tests/cp/proc-zero-len.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Ensure that cp copies contents of non-empty "regular" file with st_size==0 + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +touch empty || framework_failure_ + +f=/proc/cpuinfo +test -r $f || f=empty + +cat $f > out || fail=1 + +# With coreutils-6.9, this would create a zero-length "exp" file. +cp $f exp || fail=1 + +# Don't simply compare contents; they might differ, +# e.g., if CPU freq changes between cat and cp invocations. +# Instead, simply compare whether they're both nonempty. +test -s out && { rm -f out; echo nonempty > out; } +test -s exp && { rm -f exp; echo nonempty > exp; } + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/cp/r-vs-symlink b/tests/cp/r-vs-symlink deleted file mode 100755 index e96c58425..000000000 --- a/tests/cp/r-vs-symlink +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# cp -r should not create symlinks. Fixed in fileutils-4.1.5. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Restored old behavior (whereby cp -r preserves symlinks) in 4.1.6, -# though now such usage evokes a warning: -# cp: 'slink': WARNING: using -r to copy symbolic links is not portable - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -echo abc > foo || framework_failure_ -ln -s foo slink || framework_failure_ -ln -s no-such-file no-file || framework_failure_ - - -# This would fail in 4.1.5, not in 4.1.6. -cp -r no-file junk 2>/dev/null || fail=1 - -cp -r slink bar 2>/dev/null || fail=1 -set x $(ls -l bar); shift; mode=$1 -case $mode in - l*) ;; - *) fail=1;; -esac - -Exit $fail diff --git a/tests/cp/r-vs-symlink.sh b/tests/cp/r-vs-symlink.sh new file mode 100755 index 000000000..e96c58425 --- /dev/null +++ b/tests/cp/r-vs-symlink.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# cp -r should not create symlinks. Fixed in fileutils-4.1.5. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Restored old behavior (whereby cp -r preserves symlinks) in 4.1.6, +# though now such usage evokes a warning: +# cp: 'slink': WARNING: using -r to copy symbolic links is not portable + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +echo abc > foo || framework_failure_ +ln -s foo slink || framework_failure_ +ln -s no-such-file no-file || framework_failure_ + + +# This would fail in 4.1.5, not in 4.1.6. +cp -r no-file junk 2>/dev/null || fail=1 + +cp -r slink bar 2>/dev/null || fail=1 +set x $(ls -l bar); shift; mode=$1 +case $mode in + l*) ;; + *) fail=1;; +esac + +Exit $fail diff --git a/tests/cp/reflink-auto b/tests/cp/reflink-auto deleted file mode 100755 index 036148c4e..000000000 --- a/tests/cp/reflink-auto +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Test cp --reflink=auto - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" -a_other="$other_partition_tmpdir/a" -rm -f "$a_other" || framework_failure_ - -echo non_zero_size > "$a_other" || framework_failure_ - -# we shouldn't be able to reflink() files on separate partitions -cp --reflink "$a_other" b && fail=1 - -# --reflink=auto should fall back to a normal copy -cp --reflink=auto "$a_other" b || fail=1 -test -s b || fail=1 - -# --reflink=auto should allow --sparse for fallback copies. -# This command can be used to create minimal sized copies. -cp --reflink=auto --sparse=always "$a_other" b || fail=1 -test -s b || fail=1 - -Exit $fail diff --git a/tests/cp/reflink-auto.sh b/tests/cp/reflink-auto.sh new file mode 100755 index 000000000..036148c4e --- /dev/null +++ b/tests/cp/reflink-auto.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Test cp --reflink=auto + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" +a_other="$other_partition_tmpdir/a" +rm -f "$a_other" || framework_failure_ + +echo non_zero_size > "$a_other" || framework_failure_ + +# we shouldn't be able to reflink() files on separate partitions +cp --reflink "$a_other" b && fail=1 + +# --reflink=auto should fall back to a normal copy +cp --reflink=auto "$a_other" b || fail=1 +test -s b || fail=1 + +# --reflink=auto should allow --sparse for fallback copies. +# This command can be used to create minimal sized copies. +cp --reflink=auto --sparse=always "$a_other" b || fail=1 +test -s b || fail=1 + +Exit $fail diff --git a/tests/cp/reflink-perm b/tests/cp/reflink-perm deleted file mode 100755 index c229993a2..000000000 --- a/tests/cp/reflink-perm +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# Test cp --reflink copies permissions - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - - -: > time_check -: > file -ts='2009-08-28 19:00' -touch -d "$ts" file || framework_failure_ -test time_check -nt file || skip_ "The system clock is wrong" - -chmod a=rwx file || framework_failure_ -umask 077 -cp --reflink=auto --preserve file copy || fail=1 - -mode=$(stat --printf "%A" copy) -test "$mode" = "-rwxrwxrwx" || fail=1 - -test copy -nt file && fail=1 - -# Ensure that --attributes-only overrides --reflink completely -echo > file2 # file with data -cp --reflink=auto --preserve --attributes-only file2 empty_copy || fail=1 -test -s empty_copy && fail=1 -cp --reflink=always --preserve --attributes-only file2 empty_copy || fail=1 -test -s empty_copy && fail=1 - -Exit $fail diff --git a/tests/cp/reflink-perm.sh b/tests/cp/reflink-perm.sh new file mode 100755 index 000000000..c229993a2 --- /dev/null +++ b/tests/cp/reflink-perm.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Test cp --reflink copies permissions + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + + +: > time_check +: > file +ts='2009-08-28 19:00' +touch -d "$ts" file || framework_failure_ +test time_check -nt file || skip_ "The system clock is wrong" + +chmod a=rwx file || framework_failure_ +umask 077 +cp --reflink=auto --preserve file copy || fail=1 + +mode=$(stat --printf "%A" copy) +test "$mode" = "-rwxrwxrwx" || fail=1 + +test copy -nt file && fail=1 + +# Ensure that --attributes-only overrides --reflink completely +echo > file2 # file with data +cp --reflink=auto --preserve --attributes-only file2 empty_copy || fail=1 +test -s empty_copy && fail=1 +cp --reflink=always --preserve --attributes-only file2 empty_copy || fail=1 +test -s empty_copy && fail=1 + +Exit $fail diff --git a/tests/cp/same-file b/tests/cp/same-file deleted file mode 100755 index 2ca7bf6ba..000000000 --- a/tests/cp/same-file +++ /dev/null @@ -1,220 +0,0 @@ -#!/bin/sh -# Test some of cp's options and how cp handles situations in -# which a naive implementation might overwrite the source file. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -# Unset CDPATH. Otherwise, output from the 'cd dir' command -# can make this test fail. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -VERSION_CONTROL=numbered; export VERSION_CONTROL - -# Determine whether a hard link to a symlink points to the symlink -# itself or to its referent. For example, the link from FreeBSD6.1 -# does dereference a symlink, but the one from Linux does not. -ln -s no-such dangling-slink -ln dangling-slink hard-link > /dev/null 2>&1 \ - && hard_link_to_symlink_does_the_deref=no \ - || hard_link_to_symlink_does_the_deref=yes -rm -f no-such dangling-slink hard-link - -test $hard_link_to_symlink_does_the_deref = yes \ - && remove_these_sed='/^0 -[bf]*l .*sl1 ->/d' \ - || remove_these_sed='/^ELIDE NO TEST OUTPUT/d' - -exec 3>&1 1> actual - -# FIXME: This should be bigger: like more than 8k -contents=XYZ - -for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do - for options in '' -d -f -df --rem -b -bd -bf -bdf \ - -l -dl -fl -dfl -bl -bdl -bfl -bdfl; do - case $args$options in - # These tests are not portable. - # They all involve making a hard link to a symbolic link. - # In the past, we've skipped the tests that are not portable, - # by doing "continue" here and eliminating the corresponding - # expected output lines below. Don't do that anymore. - 'symlink foo'-dfl) - continue;; - 'symlink foo'-bdl) - continue;; - 'symlink foo'-bdfl) - continue;; - 'sl1 sl2'-dfl) - continue;; - 'sl1 sl2'-bd*l) - continue;; - 'sl1 sl2'-dl) - continue;; - esac - - # cont'd Instead, skip them only on systems for which link does - # dereference a symlink. Detect and skip such tests here. - case $hard_link_to_symlink_does_the_deref:$args:$options in - 'yes:sl1 sl2:-fl') - continue ;; - 'yes:sl1 sl2:-bl') - continue ;; - 'yes:sl1 sl2:-bfl') - continue ;; - esac - - rm -rf dir - mkdir dir - cd dir - echo $contents > foo - case "$args" in *symlink*) ln -s foo symlink ;; esac - case "$args" in *hardlink*) ln foo hardlink ;; esac - case "$args" in *sl1*) ln -s foo sl1;; esac - case "$args" in *sl2*) ln -s foo sl2;; esac - ( - ( - # echo 1>&2 cp $options $args - cp $options $args 2>_err - echo $? $options - - # Normalize the program name and diagnostics in the error output, - # and put brackets around the output. - if test -s _err; then - sed ' - s/^[^:]*:\([^:]*\).*/cp:\1/ - 1s/^/[/ - $s/$/]/ - ' _err - fi - # Strip off all but the file names. - ls=$(ls -gG --ignore=_err . \ - | sed \ - -e '/^total /d' \ - -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//') - echo "($ls)" - # Make sure the original is unchanged and that - # the destination is a copy. - for f in $args; do - if test -f $f; then - case "$(cat $f)" in - "$contents") ;; - *) echo cp FAILED;; - esac - else - echo symlink-loop - fi - done - ) | tr '\n' ' ' - echo - ) | sed 's/ *$//' - cd .. - done - echo -done - -cat <<\EOF | sed "$remove_these_sed" > expected -1 [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) -1 -d [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) -1 -f [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) -1 -df [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) -0 --rem (foo symlink) -0 -b (foo symlink symlink.~1~ -> foo) -0 -bd (foo symlink symlink.~1~ -> foo) -0 -bf (foo symlink symlink.~1~ -> foo) -0 -bdf (foo symlink symlink.~1~ -> foo) -1 -l [cp: cannot create hard link 'symlink' to 'foo'] (foo symlink -> foo) -0 -dl (foo symlink -> foo) -0 -fl (foo symlink) -0 -dfl (foo symlink) -0 -bl (foo symlink symlink.~1~ -> foo) -0 -bdl (foo symlink symlink.~1~ -> foo) -0 -bfl (foo symlink symlink.~1~ -> foo) -0 -bdfl (foo symlink symlink.~1~ -> foo) - -1 [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) -1 -d [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) -1 -f [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) -1 -df [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) -1 --rem [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) -1 -b [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) -0 -bd (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop -1 -bf [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) -0 -bdf (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop -0 -l (foo symlink -> foo) -0 -dl (foo symlink -> foo) -0 -fl (foo symlink -> foo) -0 -bl (foo symlink -> foo) -0 -bfl (foo symlink -> foo) - -1 [cp: 'foo' and 'foo' are the same file] (foo) -1 -d [cp: 'foo' and 'foo' are the same file] (foo) -1 -f [cp: 'foo' and 'foo' are the same file] (foo) -1 -df [cp: 'foo' and 'foo' are the same file] (foo) -1 --rem [cp: 'foo' and 'foo' are the same file] (foo) -1 -b [cp: 'foo' and 'foo' are the same file] (foo) -1 -bd [cp: 'foo' and 'foo' are the same file] (foo) -0 -bf (foo foo.~1~) -0 -bdf (foo foo.~1~) -0 -l (foo) -0 -dl (foo) -0 -fl (foo) -0 -dfl (foo) -0 -bl (foo) -0 -bdl (foo) -0 -bfl (foo foo.~1~) -0 -bdfl (foo foo.~1~) - -1 [cp: 'sl1' and 'sl2' are the same file] (foo sl1 -> foo sl2 -> foo) -0 -d (foo sl1 -> foo sl2 -> foo) -1 -f [cp: 'sl1' and 'sl2' are the same file] (foo sl1 -> foo sl2 -> foo) -0 -df (foo sl1 -> foo sl2 -> foo) -0 --rem (foo sl1 -> foo sl2) -0 -b (foo sl1 -> foo sl2 sl2.~1~ -> foo) -0 -bd (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) -0 -bf (foo sl1 -> foo sl2 sl2.~1~ -> foo) -0 -bdf (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) -1 -l [cp: cannot create hard link 'sl2' to 'sl1'] (foo sl1 -> foo sl2 -> foo) -0 -fl (foo sl1 -> foo sl2 -> foo) -0 -bl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) -0 -bfl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) - -1 [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) -1 -d [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) -1 -f [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) -1 -df [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) -0 --rem (foo hardlink) -0 -b (foo hardlink hardlink.~1~) -0 -bd (foo hardlink hardlink.~1~) -0 -bf (foo hardlink hardlink.~1~) -0 -bdf (foo hardlink hardlink.~1~) -0 -l (foo hardlink) -0 -dl (foo hardlink) -0 -fl (foo hardlink) -0 -dfl (foo hardlink) -0 -bl (foo hardlink) -0 -bdl (foo hardlink) -0 -bfl (foo hardlink) -0 -bdfl (foo hardlink) - -EOF - -exec 1>&3 3>&- - -compare expected actual 1>&2 || fail=1 - -Exit $fail diff --git a/tests/cp/same-file.sh b/tests/cp/same-file.sh new file mode 100755 index 000000000..2ca7bf6ba --- /dev/null +++ b/tests/cp/same-file.sh @@ -0,0 +1,220 @@ +#!/bin/sh +# Test some of cp's options and how cp handles situations in +# which a naive implementation might overwrite the source file. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +# Unset CDPATH. Otherwise, output from the 'cd dir' command +# can make this test fail. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +VERSION_CONTROL=numbered; export VERSION_CONTROL + +# Determine whether a hard link to a symlink points to the symlink +# itself or to its referent. For example, the link from FreeBSD6.1 +# does dereference a symlink, but the one from Linux does not. +ln -s no-such dangling-slink +ln dangling-slink hard-link > /dev/null 2>&1 \ + && hard_link_to_symlink_does_the_deref=no \ + || hard_link_to_symlink_does_the_deref=yes +rm -f no-such dangling-slink hard-link + +test $hard_link_to_symlink_does_the_deref = yes \ + && remove_these_sed='/^0 -[bf]*l .*sl1 ->/d' \ + || remove_these_sed='/^ELIDE NO TEST OUTPUT/d' + +exec 3>&1 1> actual + +# FIXME: This should be bigger: like more than 8k +contents=XYZ + +for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do + for options in '' -d -f -df --rem -b -bd -bf -bdf \ + -l -dl -fl -dfl -bl -bdl -bfl -bdfl; do + case $args$options in + # These tests are not portable. + # They all involve making a hard link to a symbolic link. + # In the past, we've skipped the tests that are not portable, + # by doing "continue" here and eliminating the corresponding + # expected output lines below. Don't do that anymore. + 'symlink foo'-dfl) + continue;; + 'symlink foo'-bdl) + continue;; + 'symlink foo'-bdfl) + continue;; + 'sl1 sl2'-dfl) + continue;; + 'sl1 sl2'-bd*l) + continue;; + 'sl1 sl2'-dl) + continue;; + esac + + # cont'd Instead, skip them only on systems for which link does + # dereference a symlink. Detect and skip such tests here. + case $hard_link_to_symlink_does_the_deref:$args:$options in + 'yes:sl1 sl2:-fl') + continue ;; + 'yes:sl1 sl2:-bl') + continue ;; + 'yes:sl1 sl2:-bfl') + continue ;; + esac + + rm -rf dir + mkdir dir + cd dir + echo $contents > foo + case "$args" in *symlink*) ln -s foo symlink ;; esac + case "$args" in *hardlink*) ln foo hardlink ;; esac + case "$args" in *sl1*) ln -s foo sl1;; esac + case "$args" in *sl2*) ln -s foo sl2;; esac + ( + ( + # echo 1>&2 cp $options $args + cp $options $args 2>_err + echo $? $options + + # Normalize the program name and diagnostics in the error output, + # and put brackets around the output. + if test -s _err; then + sed ' + s/^[^:]*:\([^:]*\).*/cp:\1/ + 1s/^/[/ + $s/$/]/ + ' _err + fi + # Strip off all but the file names. + ls=$(ls -gG --ignore=_err . \ + | sed \ + -e '/^total /d' \ + -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//') + echo "($ls)" + # Make sure the original is unchanged and that + # the destination is a copy. + for f in $args; do + if test -f $f; then + case "$(cat $f)" in + "$contents") ;; + *) echo cp FAILED;; + esac + else + echo symlink-loop + fi + done + ) | tr '\n' ' ' + echo + ) | sed 's/ *$//' + cd .. + done + echo +done + +cat <<\EOF | sed "$remove_these_sed" > expected +1 [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) +1 -d [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) +1 -f [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) +1 -df [cp: 'foo' and 'symlink' are the same file] (foo symlink -> foo) +0 --rem (foo symlink) +0 -b (foo symlink symlink.~1~ -> foo) +0 -bd (foo symlink symlink.~1~ -> foo) +0 -bf (foo symlink symlink.~1~ -> foo) +0 -bdf (foo symlink symlink.~1~ -> foo) +1 -l [cp: cannot create hard link 'symlink' to 'foo'] (foo symlink -> foo) +0 -dl (foo symlink -> foo) +0 -fl (foo symlink) +0 -dfl (foo symlink) +0 -bl (foo symlink symlink.~1~ -> foo) +0 -bdl (foo symlink symlink.~1~ -> foo) +0 -bfl (foo symlink symlink.~1~ -> foo) +0 -bdfl (foo symlink symlink.~1~ -> foo) + +1 [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) +1 -d [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) +1 -f [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) +1 -df [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) +1 --rem [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) +1 -b [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) +0 -bd (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop +1 -bf [cp: 'symlink' and 'foo' are the same file] (foo symlink -> foo) +0 -bdf (foo -> foo foo.~1~ symlink -> foo) symlink-loop symlink-loop +0 -l (foo symlink -> foo) +0 -dl (foo symlink -> foo) +0 -fl (foo symlink -> foo) +0 -bl (foo symlink -> foo) +0 -bfl (foo symlink -> foo) + +1 [cp: 'foo' and 'foo' are the same file] (foo) +1 -d [cp: 'foo' and 'foo' are the same file] (foo) +1 -f [cp: 'foo' and 'foo' are the same file] (foo) +1 -df [cp: 'foo' and 'foo' are the same file] (foo) +1 --rem [cp: 'foo' and 'foo' are the same file] (foo) +1 -b [cp: 'foo' and 'foo' are the same file] (foo) +1 -bd [cp: 'foo' and 'foo' are the same file] (foo) +0 -bf (foo foo.~1~) +0 -bdf (foo foo.~1~) +0 -l (foo) +0 -dl (foo) +0 -fl (foo) +0 -dfl (foo) +0 -bl (foo) +0 -bdl (foo) +0 -bfl (foo foo.~1~) +0 -bdfl (foo foo.~1~) + +1 [cp: 'sl1' and 'sl2' are the same file] (foo sl1 -> foo sl2 -> foo) +0 -d (foo sl1 -> foo sl2 -> foo) +1 -f [cp: 'sl1' and 'sl2' are the same file] (foo sl1 -> foo sl2 -> foo) +0 -df (foo sl1 -> foo sl2 -> foo) +0 --rem (foo sl1 -> foo sl2) +0 -b (foo sl1 -> foo sl2 sl2.~1~ -> foo) +0 -bd (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) +0 -bf (foo sl1 -> foo sl2 sl2.~1~ -> foo) +0 -bdf (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) +1 -l [cp: cannot create hard link 'sl2' to 'sl1'] (foo sl1 -> foo sl2 -> foo) +0 -fl (foo sl1 -> foo sl2 -> foo) +0 -bl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) +0 -bfl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) + +1 [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) +1 -d [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) +1 -f [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) +1 -df [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) +0 --rem (foo hardlink) +0 -b (foo hardlink hardlink.~1~) +0 -bd (foo hardlink hardlink.~1~) +0 -bf (foo hardlink hardlink.~1~) +0 -bdf (foo hardlink hardlink.~1~) +0 -l (foo hardlink) +0 -dl (foo hardlink) +0 -fl (foo hardlink) +0 -dfl (foo hardlink) +0 -bl (foo hardlink) +0 -bdl (foo hardlink) +0 -bfl (foo hardlink) +0 -bdfl (foo hardlink) + +EOF + +exec 1>&3 3>&- + +compare expected actual 1>&2 || fail=1 + +Exit $fail diff --git a/tests/cp/slink-2-slink b/tests/cp/slink-2-slink deleted file mode 100755 index bf3238736..000000000 --- a/tests/cp/slink-2-slink +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# 'test cp --update A B' where A and B are both symlinks that point -# to the same file - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -touch file || framework_failure_ -ln -s file a || framework_failure_ -ln -s file b || framework_failure_ -ln -s no-such-file c || framework_failure_ -ln -s no-such-file d || framework_failure_ - -cp --update --no-dereference a b || fail=1 -cp --update --no-dereference c d || fail=1 - -Exit $fail diff --git a/tests/cp/slink-2-slink.sh b/tests/cp/slink-2-slink.sh new file mode 100755 index 000000000..bf3238736 --- /dev/null +++ b/tests/cp/slink-2-slink.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# 'test cp --update A B' where A and B are both symlinks that point +# to the same file + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +touch file || framework_failure_ +ln -s file a || framework_failure_ +ln -s file b || framework_failure_ +ln -s no-such-file c || framework_failure_ +ln -s no-such-file d || framework_failure_ + +cp --update --no-dereference a b || fail=1 +cp --update --no-dereference c d || fail=1 + +Exit $fail diff --git a/tests/cp/sparse b/tests/cp/sparse deleted file mode 100755 index a55202877..000000000 --- a/tests/cp/sparse +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Test cp --sparse=always - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -require_sparse_support_ - -# Create a sparse file. -# It has to be at least 128K in order to be sparse on some systems. -# Make its size one larger than 128K, in order to tickle the -# bug in coreutils-6.0. -size=$(expr 128 \* 1024 + 1) -dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure_ - - -cp --sparse=always sparse copy || fail=1 - -# Ensure that the copy has the same block count as the original. -test $(stat --printf %b copy) -le $(stat --printf %b sparse) || fail=1 - -# Ensure that --sparse={always,never} with --reflink fail. -cp --sparse=always --reflink sparse copy && fail=1 -cp --sparse=never --reflink sparse copy && fail=1 - -Exit $fail diff --git a/tests/cp/sparse-fiemap b/tests/cp/sparse-fiemap deleted file mode 100755 index f2e5f330d..000000000 --- a/tests/cp/sparse-fiemap +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/sh -# Test cp --sparse=always through fiemap copy - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -require_perl_ - -# The test was seen to fail on ext3 so exclude that type -# (or any file system where the type can't be determined) -touch fiemap_chk -if fiemap_capable_ fiemap_chk && ! df -t ext3 . >/dev/null; then - : # Current partition has working extents. Good! -else - # FIXME: temporarily(?) skip this variant, at least until after this bug - # is fixed: http://thread.gmane.org/gmane.comp.file-systems.ext4/24495 - skip_ "current file system has insufficient FIEMAP support" - - # It's not; we need to create one, hence we need root access. - require_root_ - - cwd=$PWD - cleanup_() { cd /; umount "$cwd/mnt"; } - - skip=0 - # Create an ext4 loopback file system - dd if=/dev/zero of=blob bs=32k count=1000 || skip=1 - mkdir mnt - mkfs -t ext4 -F blob || - skip_ "failed to create ext4 file system" - mount -oloop blob mnt || skip=1 - cd mnt || skip=1 - echo test > f || skip=1 - test -s f || skip=1 - - test $skip = 1 && - skip_ "insufficient mount/ext4 support" -fi - -# ================================================= -# Ensure that we exercise the FIEMAP-copying code enough -# to provoke at least two iterations of the do...while loop -# in which it calls ioctl (fd, FS_IOC_FIEMAP,... -# This also verifies that non-trivial extents are preserved. - -# Extract logical block number and length pairs from filefrag -v output. -# The initial sed is to remove the "eof" from the normally-empty "flags" field. -# Similarly, remove flags values like "unknown,delalloc,eof". -# That is required when that final extent has no number in the "expected" field. -f() -{ - sed 's/ [a-z,][a-z,]*$//' $@ \ - | $AWK '/^ *[0-9]/ {printf "%d %d ", $2, (NF<5 ? $NF : $5) } END {print ""}' -} - -for i in $(seq 1 2 21); do - for j in 1 2 31 100; do - $PERL -e '$n = '$i' * 1024; *F = *STDOUT;' \ - -e 'for (1..'$j') { sysseek (*F, $n, 1)' \ - -e '&& syswrite (*F, chr($_)x$n) or die "$!"}' > j1 || fail=1 - - # Note there is an implicit sync performed by cp on Linux kernels - # before 2.6.39 to work around bugs in EXT4 and BTRFS. - # Note also the -s parameter to the filefrag commands below - # for the same reasons. - cp --sparse=always j1 j2 || fail=1 - - cmp j1 j2 || fail_ "data loss i=$i j=$j" - if ! filefrag -vs j1 | grep -F extent >/dev/null; then - test $skip != 1 && warn_ 'skipping part; you lack filefrag' - skip=1 - else - # Here is sample filefrag output: - # $ perl -e 'BEGIN{$n=16*1024; *F=*STDOUT}' \ - # -e 'for (1..5) { sysseek(*F,$n,1)' \ - # -e '&& syswrite *F,"."x$n or die "$!"}' > j - # $ filefrag -v j - # File system type is: ef53 - # File size of j is 163840 (40 blocks, blocksize 4096) - # ext logical physical expected length flags - # 0 4 6258884 4 - # 1 12 6258892 6258887 4 - # 2 20 6258900 6258895 4 - # 3 28 6258908 6258903 4 - # 4 36 6258916 6258911 4 eof - # j: 6 extents found - - # exclude the physical block numbers; they always differ - filefrag -v j1 > ff1 || framework_failure_ - filefrag -vs j2 > ff2 || framework_failure_ - { f ff1; f ff2; } | $PERL $abs_top_srcdir/tests/filefrag-extent-compare \ - || { - warn_ ignoring filefrag-reported extent map differences - # Show the differing extent maps. - head -n99 ff1 ff2 - } - fi - test $fail = 1 && break 2 - done -done - -Exit $fail diff --git a/tests/cp/sparse-fiemap.sh b/tests/cp/sparse-fiemap.sh new file mode 100755 index 000000000..f2e5f330d --- /dev/null +++ b/tests/cp/sparse-fiemap.sh @@ -0,0 +1,116 @@ +#!/bin/sh +# Test cp --sparse=always through fiemap copy + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +require_perl_ + +# The test was seen to fail on ext3 so exclude that type +# (or any file system where the type can't be determined) +touch fiemap_chk +if fiemap_capable_ fiemap_chk && ! df -t ext3 . >/dev/null; then + : # Current partition has working extents. Good! +else + # FIXME: temporarily(?) skip this variant, at least until after this bug + # is fixed: http://thread.gmane.org/gmane.comp.file-systems.ext4/24495 + skip_ "current file system has insufficient FIEMAP support" + + # It's not; we need to create one, hence we need root access. + require_root_ + + cwd=$PWD + cleanup_() { cd /; umount "$cwd/mnt"; } + + skip=0 + # Create an ext4 loopback file system + dd if=/dev/zero of=blob bs=32k count=1000 || skip=1 + mkdir mnt + mkfs -t ext4 -F blob || + skip_ "failed to create ext4 file system" + mount -oloop blob mnt || skip=1 + cd mnt || skip=1 + echo test > f || skip=1 + test -s f || skip=1 + + test $skip = 1 && + skip_ "insufficient mount/ext4 support" +fi + +# ================================================= +# Ensure that we exercise the FIEMAP-copying code enough +# to provoke at least two iterations of the do...while loop +# in which it calls ioctl (fd, FS_IOC_FIEMAP,... +# This also verifies that non-trivial extents are preserved. + +# Extract logical block number and length pairs from filefrag -v output. +# The initial sed is to remove the "eof" from the normally-empty "flags" field. +# Similarly, remove flags values like "unknown,delalloc,eof". +# That is required when that final extent has no number in the "expected" field. +f() +{ + sed 's/ [a-z,][a-z,]*$//' $@ \ + | $AWK '/^ *[0-9]/ {printf "%d %d ", $2, (NF<5 ? $NF : $5) } END {print ""}' +} + +for i in $(seq 1 2 21); do + for j in 1 2 31 100; do + $PERL -e '$n = '$i' * 1024; *F = *STDOUT;' \ + -e 'for (1..'$j') { sysseek (*F, $n, 1)' \ + -e '&& syswrite (*F, chr($_)x$n) or die "$!"}' > j1 || fail=1 + + # Note there is an implicit sync performed by cp on Linux kernels + # before 2.6.39 to work around bugs in EXT4 and BTRFS. + # Note also the -s parameter to the filefrag commands below + # for the same reasons. + cp --sparse=always j1 j2 || fail=1 + + cmp j1 j2 || fail_ "data loss i=$i j=$j" + if ! filefrag -vs j1 | grep -F extent >/dev/null; then + test $skip != 1 && warn_ 'skipping part; you lack filefrag' + skip=1 + else + # Here is sample filefrag output: + # $ perl -e 'BEGIN{$n=16*1024; *F=*STDOUT}' \ + # -e 'for (1..5) { sysseek(*F,$n,1)' \ + # -e '&& syswrite *F,"."x$n or die "$!"}' > j + # $ filefrag -v j + # File system type is: ef53 + # File size of j is 163840 (40 blocks, blocksize 4096) + # ext logical physical expected length flags + # 0 4 6258884 4 + # 1 12 6258892 6258887 4 + # 2 20 6258900 6258895 4 + # 3 28 6258908 6258903 4 + # 4 36 6258916 6258911 4 eof + # j: 6 extents found + + # exclude the physical block numbers; they always differ + filefrag -v j1 > ff1 || framework_failure_ + filefrag -vs j2 > ff2 || framework_failure_ + { f ff1; f ff2; } | $PERL $abs_top_srcdir/tests/filefrag-extent-compare \ + || { + warn_ ignoring filefrag-reported extent map differences + # Show the differing extent maps. + head -n99 ff1 ff2 + } + fi + test $fail = 1 && break 2 + done +done + +Exit $fail diff --git a/tests/cp/sparse-to-pipe b/tests/cp/sparse-to-pipe deleted file mode 100755 index 0cfda8d55..000000000 --- a/tests/cp/sparse-to-pipe +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# copy a sparse file to a pipe, to exercise some seldom-used parts of copy.c - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -require_sparse_support_ - -mkfifo_or_skip_ pipe -timeout 10 cat pipe > copy & - -truncate -s1M sparse || framework_failure_ -cp sparse pipe || fail=1 - -# Ensure that the cat has completed before comparing. -wait - -cmp sparse copy || fail=1 - -Exit $fail diff --git a/tests/cp/sparse-to-pipe.sh b/tests/cp/sparse-to-pipe.sh new file mode 100755 index 000000000..0cfda8d55 --- /dev/null +++ b/tests/cp/sparse-to-pipe.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# copy a sparse file to a pipe, to exercise some seldom-used parts of copy.c + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +require_sparse_support_ + +mkfifo_or_skip_ pipe +timeout 10 cat pipe > copy & + +truncate -s1M sparse || framework_failure_ +cp sparse pipe || fail=1 + +# Ensure that the cat has completed before comparing. +wait + +cmp sparse copy || fail=1 + +Exit $fail diff --git a/tests/cp/sparse.sh b/tests/cp/sparse.sh new file mode 100755 index 000000000..a55202877 --- /dev/null +++ b/tests/cp/sparse.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Test cp --sparse=always + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +require_sparse_support_ + +# Create a sparse file. +# It has to be at least 128K in order to be sparse on some systems. +# Make its size one larger than 128K, in order to tickle the +# bug in coreutils-6.0. +size=$(expr 128 \* 1024 + 1) +dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure_ + + +cp --sparse=always sparse copy || fail=1 + +# Ensure that the copy has the same block count as the original. +test $(stat --printf %b copy) -le $(stat --printf %b sparse) || fail=1 + +# Ensure that --sparse={always,never} with --reflink fail. +cp --sparse=always --reflink sparse copy && fail=1 +cp --sparse=never --reflink sparse copy && fail=1 + +Exit $fail diff --git a/tests/cp/special-bits b/tests/cp/special-bits deleted file mode 100755 index 4a00891d9..000000000 --- a/tests/cp/special-bits +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# make sure 'cp -p' preserves special bits -# This works only when run as root. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# This test would fail due to a bug introduced in 4.0y. -# The bug was fixed in 4.0z. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -require_root_ - -touch a b c || framework_failure_ -chmod u+sx,go= a || framework_failure_ -chmod u=rwx,g=sx,o= b || framework_failure_ -chmod a=r,ug+sx c || framework_failure_ -chown $NON_ROOT_USERNAME . || framework_failure_ -chmod u=rwx,g=rx,o=rx . || framework_failure_ - - -cp -p a a2 || fail=1 -set _ $(ls -l a); shift; p1=$1 -set _ $(ls -l a2); shift; p2=$1 -test $p1 = $p2 || fail=1 - -cp -p b b2 || fail=1 -set _ $(ls -l b); shift; p1=$1 -set _ $(ls -l b2); shift; p2=$1 -test $p1 = $p2 || fail=1 - -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" cp -p c c2 || fail=1 -set _ $(ls -l c); shift; p1=$1 -set _ $(ls -l c2); shift; p2=$1 -test $p1 = $p2 && fail=1 - -Exit $fail diff --git a/tests/cp/special-bits.sh b/tests/cp/special-bits.sh new file mode 100755 index 000000000..4a00891d9 --- /dev/null +++ b/tests/cp/special-bits.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# make sure 'cp -p' preserves special bits +# This works only when run as root. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This test would fail due to a bug introduced in 4.0y. +# The bug was fixed in 4.0z. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +require_root_ + +touch a b c || framework_failure_ +chmod u+sx,go= a || framework_failure_ +chmod u=rwx,g=sx,o= b || framework_failure_ +chmod a=r,ug+sx c || framework_failure_ +chown $NON_ROOT_USERNAME . || framework_failure_ +chmod u=rwx,g=rx,o=rx . || framework_failure_ + + +cp -p a a2 || fail=1 +set _ $(ls -l a); shift; p1=$1 +set _ $(ls -l a2); shift; p2=$1 +test $p1 = $p2 || fail=1 + +cp -p b b2 || fail=1 +set _ $(ls -l b); shift; p1=$1 +set _ $(ls -l b2); shift; p2=$1 +test $p1 = $p2 || fail=1 + +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" cp -p c c2 || fail=1 +set _ $(ls -l c); shift; p1=$1 +set _ $(ls -l c2); shift; p2=$1 +test $p1 = $p2 && fail=1 + +Exit $fail diff --git a/tests/cp/special-f b/tests/cp/special-f deleted file mode 100755 index a47655ef7..000000000 --- a/tests/cp/special-f +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Ensure that "cp -Rf fifo E" unlinks E and retries. -# Up until coreutils-6.10.171, it would not. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkfifo_or_skip_ fifo - -touch e || framework-failure - - -# Without -f, expect it to fail. -cp -R fifo e || fail=1 - -# With -f, it must succeed. -cp -Rf fifo e || fail=1 -test -p fifo || fail=1 - -Exit $fail diff --git a/tests/cp/special-f.sh b/tests/cp/special-f.sh new file mode 100755 index 000000000..a47655ef7 --- /dev/null +++ b/tests/cp/special-f.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Ensure that "cp -Rf fifo E" unlinks E and retries. +# Up until coreutils-6.10.171, it would not. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkfifo_or_skip_ fifo + +touch e || framework-failure + + +# Without -f, expect it to fail. +cp -R fifo e || fail=1 + +# With -f, it must succeed. +cp -Rf fifo e || fail=1 +test -p fifo || fail=1 + +Exit $fail diff --git a/tests/cp/src-base-dot b/tests/cp/src-base-dot deleted file mode 100755 index 14438d09a..000000000 --- a/tests/cp/src-base-dot +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Ensure that "mkdir x y; cd y; cp -ab ../x/. ." is a successful, silent, no-op. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir x y || framework_failure_ - - -cd y -cp --verbose -ab ../x/. . > out 2>&1 || fail=1 -cat <<\EOF > exp || fail=1 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/cp/src-base-dot.sh b/tests/cp/src-base-dot.sh new file mode 100755 index 000000000..14438d09a --- /dev/null +++ b/tests/cp/src-base-dot.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Ensure that "mkdir x y; cd y; cp -ab ../x/. ." is a successful, silent, no-op. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir x y || framework_failure_ + + +cd y +cp --verbose -ab ../x/. . > out 2>&1 || fail=1 +cat <<\EOF > exp || fail=1 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/cp/symlink-slash b/tests/cp/symlink-slash deleted file mode 100755 index 95c9cfa04..000000000 --- a/tests/cp/symlink-slash +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Make sure that cp -dR dereferences a symlink arg if its name is -# written with a trailing slash. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -mkdir dir || framework_failure_ -ln -s dir symlink || framework_failure_ - -cp -dR symlink/ s || fail=1 -set $(ls -l s) - -# Prior to fileutils-4.0q, the following would have output ...'s -> dir' -# because the trailing slash was removed unconditionally (now you have to -# use the new --strip-trailing-slash option) causing cp to reproduce the -# symlink. Now, the trailing slash is interpreted by the stat library -# call and so cp ends up dereferencing the symlink and copying the directory. -test "$*" = 'total 0' && : || fail=1 - -Exit $fail diff --git a/tests/cp/symlink-slash.sh b/tests/cp/symlink-slash.sh new file mode 100755 index 000000000..95c9cfa04 --- /dev/null +++ b/tests/cp/symlink-slash.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Make sure that cp -dR dereferences a symlink arg if its name is +# written with a trailing slash. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +mkdir dir || framework_failure_ +ln -s dir symlink || framework_failure_ + +cp -dR symlink/ s || fail=1 +set $(ls -l s) + +# Prior to fileutils-4.0q, the following would have output ...'s -> dir' +# because the trailing slash was removed unconditionally (now you have to +# use the new --strip-trailing-slash option) causing cp to reproduce the +# symlink. Now, the trailing slash is interpreted by the stat library +# call and so cp ends up dereferencing the symlink and copying the directory. +test "$*" = 'total 0' && : || fail=1 + +Exit $fail diff --git a/tests/cp/thru-dangling b/tests/cp/thru-dangling deleted file mode 100755 index f8527af8d..000000000 --- a/tests/cp/thru-dangling +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Ensure that cp works as documented, when the destination is a dangling symlink - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp - -ln -s no-such dangle || framework_failure_ -echo hi > f || framework_failure_ -echo hi > exp || framework_failure_ -echo "cp: not writing through dangling symlink 'dangle'" \ - > exp-err || framework_failure_ - - -# Starting with 6.9.90, this usage fails, by default: -cp f dangle > err 2>&1 && fail=1 - -compare exp-err err || fail=1 -test -f no-such && fail=1 - -# But you can set POSIXLY_CORRECT to get the historical behavior. -env POSIXLY_CORRECT=1 cp f dangle > out 2>&1 || fail=1 -cat no-such >> out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/cp/thru-dangling.sh b/tests/cp/thru-dangling.sh new file mode 100755 index 000000000..f8527af8d --- /dev/null +++ b/tests/cp/thru-dangling.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Ensure that cp works as documented, when the destination is a dangling symlink + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp + +ln -s no-such dangle || framework_failure_ +echo hi > f || framework_failure_ +echo hi > exp || framework_failure_ +echo "cp: not writing through dangling symlink 'dangle'" \ + > exp-err || framework_failure_ + + +# Starting with 6.9.90, this usage fails, by default: +cp f dangle > err 2>&1 && fail=1 + +compare exp-err err || fail=1 +test -f no-such && fail=1 + +# But you can set POSIXLY_CORRECT to get the historical behavior. +env POSIXLY_CORRECT=1 cp f dangle > out 2>&1 || fail=1 +cat no-such >> out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/dd/bytes b/tests/dd/bytes deleted file mode 100755 index 2d40f0641..000000000 --- a/tests/dd/bytes +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -# count_bytes -echo 0123456789abcdefghijklm > in || framework_failure_ -dd count=14 conv=swab iflag=count_bytes < in > out 2> /dev/null || fail=1 -case $(cat out) in - 1032547698badc) ;; - *) fail=1 ;; -esac - -# skip_bytes -echo 0123456789abcdefghijklm > in || framework_failure_ -dd skip=10 iflag=skip_bytes < in > out 2> /dev/null || fail=1 -case $(cat out) in - abcdefghijklm) ;; - *) fail=1 ;; -esac - -# skip records and bytes from pipe -echo 0123456789abcdefghijklm | - dd skip=10 bs=2 iflag=skip_bytes > out 2> /dev/null || fail=1 -case $(cat out) in - abcdefghijklm) ;; - *) fail=1 ;; -esac - -# seek bytes -echo abcdefghijklm | - dd bs=5 seek=8 oflag=seek_bytes > out 2> /dev/null || fail=1 -printf '\0\0\0\0\0\0\0\0abcdefghijklm\n' > expected -compare expected out || fail=1 - -# Just truncation, no I/O -dd bs=5 seek=8 oflag=seek_bytes of=out2 count=0 2> /dev/null || fail=1 -truncate -s8 expected2 -compare expected2 out2 || fail=1 - -Exit $fail diff --git a/tests/dd/bytes.sh b/tests/dd/bytes.sh new file mode 100755 index 000000000..2d40f0641 --- /dev/null +++ b/tests/dd/bytes.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +# count_bytes +echo 0123456789abcdefghijklm > in || framework_failure_ +dd count=14 conv=swab iflag=count_bytes < in > out 2> /dev/null || fail=1 +case $(cat out) in + 1032547698badc) ;; + *) fail=1 ;; +esac + +# skip_bytes +echo 0123456789abcdefghijklm > in || framework_failure_ +dd skip=10 iflag=skip_bytes < in > out 2> /dev/null || fail=1 +case $(cat out) in + abcdefghijklm) ;; + *) fail=1 ;; +esac + +# skip records and bytes from pipe +echo 0123456789abcdefghijklm | + dd skip=10 bs=2 iflag=skip_bytes > out 2> /dev/null || fail=1 +case $(cat out) in + abcdefghijklm) ;; + *) fail=1 ;; +esac + +# seek bytes +echo abcdefghijklm | + dd bs=5 seek=8 oflag=seek_bytes > out 2> /dev/null || fail=1 +printf '\0\0\0\0\0\0\0\0abcdefghijklm\n' > expected +compare expected out || fail=1 + +# Just truncation, no I/O +dd bs=5 seek=8 oflag=seek_bytes of=out2 count=0 2> /dev/null || fail=1 +truncate -s8 expected2 +compare expected2 out2 || fail=1 + +Exit $fail diff --git a/tests/dd/direct b/tests/dd/direct deleted file mode 100755 index c231bee30..000000000 --- a/tests/dd/direct +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# ensure that dd's oflag=direct works - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -truncate -s 8192 in || framework_failure_ -dd if=in oflag=direct of=out 2> /dev/null \ - || skip_ 'this file system lacks support for O_DIRECT' - -truncate -s 511 short || framework_failure_ -truncate -s 8191 m1 || framework_failure_ -truncate -s 8193 p1 || framework_failure_ - -for i in short m1 p1; do - rm -f out - dd if=$i oflag=direct of=out || fail=1 -done - -Exit $fail diff --git a/tests/dd/direct.sh b/tests/dd/direct.sh new file mode 100755 index 000000000..c231bee30 --- /dev/null +++ b/tests/dd/direct.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# ensure that dd's oflag=direct works + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +truncate -s 8192 in || framework_failure_ +dd if=in oflag=direct of=out 2> /dev/null \ + || skip_ 'this file system lacks support for O_DIRECT' + +truncate -s 511 short || framework_failure_ +truncate -s 8191 m1 || framework_failure_ +truncate -s 8193 p1 || framework_failure_ + +for i in short m1 p1; do + rm -f out + dd if=$i oflag=direct of=out || fail=1 +done + +Exit $fail diff --git a/tests/dd/misc b/tests/dd/misc deleted file mode 100755 index 52a5b2081..000000000 --- a/tests/dd/misc +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -# Ensure dd treats '--' properly. -# Also test some flag values. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -tmp_in=dd-in -tmp_in2=dd-in2 -tmp_sym=dd-sym -tmp_out=dd-out - -warn=0 -echo data > $tmp_in || framework_failure_ -ln $tmp_in $tmp_in2 || framework_failure_ -ln -s $tmp_in $tmp_sym || framework_failure_ - -dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1 -compare $tmp_in $tmp_out || fail=1 - -rm $tmp_out -dd -- if=$tmp_in of=$tmp_out 2> /dev/null || fail=1 -compare $tmp_in $tmp_out || fail=1 - -if dd oflag=append if=$tmp_in of=$tmp_out 2> /dev/null; then - compare $tmp_in $tmp_out || fail=1 -fi - -case $(cat /dev/stdin <$tmp_in 2>/dev/null) in -(data) - rm -f $tmp_out - dd if=/dev/stdin of=$tmp_out <$tmp_in || fail=1 - compare $tmp_in $tmp_out || fail=1 -esac - -if dd iflag=nofollow if=$tmp_in count=0 2> /dev/null; then - dd iflag=nofollow if=$tmp_sym count=0 2> /dev/null && fail=1 -fi - -if dd iflag=directory if=. count=0 2> /dev/null; then - dd iflag=directory count=0 <. 2> /dev/null || fail=1 - dd iflag=directory count=0 <$tmp_in 2> /dev/null && fail=1 -fi - -old_ls=$(ls -u --full-time $tmp_in) -sleep 1 -if dd iflag=noatime if=$tmp_in of=$tmp_out 2> /dev/null; then - new_ls=$(ls -u --full-time $tmp_in) - if test "x$old_ls" != "x$new_ls"; then - cat >&2 < /dev/null; then - dd iflag=nolinks if=$tmp_in > /dev/null 2>&1 && fail=1 - dd iflag=nolinks < $tmp_in > /dev/null 2>&1 && fail=1 - dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1 -fi - -outbytes=$(echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c) -test "$outbytes" -eq 3 || fail=1 - -# A delay is required to trigger a failure. -# There might be some missed failures but it's unlikely. -(echo a; sleep .1; echo b) \ - | env LC_ALL=C dd bs=4 status=noxfer iflag=fullblock >out 2>err || fail=1 -printf 'a\nb\n' > out_ok || framework_failure_ -echo "1+0 records in -1+0 records out" > err_ok || framework_failure_ -compare out_ok out || fail=1 -compare err_ok err || fail=1 - -test $fail -eq 0 && fail=$warn - -Exit $fail diff --git a/tests/dd/misc.sh b/tests/dd/misc.sh new file mode 100755 index 000000000..52a5b2081 --- /dev/null +++ b/tests/dd/misc.sh @@ -0,0 +1,98 @@ +#!/bin/sh +# Ensure dd treats '--' properly. +# Also test some flag values. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +tmp_in=dd-in +tmp_in2=dd-in2 +tmp_sym=dd-sym +tmp_out=dd-out + +warn=0 +echo data > $tmp_in || framework_failure_ +ln $tmp_in $tmp_in2 || framework_failure_ +ln -s $tmp_in $tmp_sym || framework_failure_ + +dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1 +compare $tmp_in $tmp_out || fail=1 + +rm $tmp_out +dd -- if=$tmp_in of=$tmp_out 2> /dev/null || fail=1 +compare $tmp_in $tmp_out || fail=1 + +if dd oflag=append if=$tmp_in of=$tmp_out 2> /dev/null; then + compare $tmp_in $tmp_out || fail=1 +fi + +case $(cat /dev/stdin <$tmp_in 2>/dev/null) in +(data) + rm -f $tmp_out + dd if=/dev/stdin of=$tmp_out <$tmp_in || fail=1 + compare $tmp_in $tmp_out || fail=1 +esac + +if dd iflag=nofollow if=$tmp_in count=0 2> /dev/null; then + dd iflag=nofollow if=$tmp_sym count=0 2> /dev/null && fail=1 +fi + +if dd iflag=directory if=. count=0 2> /dev/null; then + dd iflag=directory count=0 <. 2> /dev/null || fail=1 + dd iflag=directory count=0 <$tmp_in 2> /dev/null && fail=1 +fi + +old_ls=$(ls -u --full-time $tmp_in) +sleep 1 +if dd iflag=noatime if=$tmp_in of=$tmp_out 2> /dev/null; then + new_ls=$(ls -u --full-time $tmp_in) + if test "x$old_ls" != "x$new_ls"; then + cat >&2 < /dev/null; then + dd iflag=nolinks if=$tmp_in > /dev/null 2>&1 && fail=1 + dd iflag=nolinks < $tmp_in > /dev/null 2>&1 && fail=1 + dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1 +fi + +outbytes=$(echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c) +test "$outbytes" -eq 3 || fail=1 + +# A delay is required to trigger a failure. +# There might be some missed failures but it's unlikely. +(echo a; sleep .1; echo b) \ + | env LC_ALL=C dd bs=4 status=noxfer iflag=fullblock >out 2>err || fail=1 +printf 'a\nb\n' > out_ok || framework_failure_ +echo "1+0 records in +1+0 records out" > err_ok || framework_failure_ +compare out_ok out || fail=1 +compare err_ok err || fail=1 + +test $fail -eq 0 && fail=$warn + +Exit $fail diff --git a/tests/dd/nocache b/tests/dd/nocache deleted file mode 100755 index 274bb8a03..000000000 --- a/tests/dd/nocache +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# Ensure dd handles the 'nocache' flag - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -# This should not call posix_fadvise -dd iflag=nocache oflag=nocache if=/dev/null of=/dev/null || fail=1 - -# We should get an error for trying to process a pipe -dd count=0 | dd iflag=nocache count=0 && fail=1 - -# O_DIRECT is orthogonal to drop cache so mutually exclusive -dd iflag=nocache,direct if=/dev/null && fail=1 - -# The rest ensure that the documented uses cases -# proceed without error -for f in ifile ofile; do - dd if=/dev/zero of=$f conv=fdatasync count=100 || framework_failure_ -done - -# Advise to drop cache for whole file -if ! dd if=ifile iflag=nocache count=0 2>err; then - # We could check for 'Operation not supported' in err here, - # but that was seen to be brittle. HPUX returns ENOTTY for example. - # So assume that if this basic operation fails, it's due to lack - # of support by the system. - warn_ 'skipping part; this file system lacks support for posix_fadvise()' - skip=1 -fi - -if test "$skip" != 1; then - # Ensure drop cache for whole file - dd of=ofile oflag=nocache conv=notrunc,fdatasync count=0 || fail=1 - - # Drop cache for part of file - dd if=ifile iflag=nocache skip=10 count=10 of=/dev/null || fail=1 - - # Stream data just using readahead cache - dd if=ifile of=ofile iflag=nocache oflag=nocache || fail=1 -fi - -Exit $fail diff --git a/tests/dd/nocache.sh b/tests/dd/nocache.sh new file mode 100755 index 000000000..274bb8a03 --- /dev/null +++ b/tests/dd/nocache.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Ensure dd handles the 'nocache' flag + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +# This should not call posix_fadvise +dd iflag=nocache oflag=nocache if=/dev/null of=/dev/null || fail=1 + +# We should get an error for trying to process a pipe +dd count=0 | dd iflag=nocache count=0 && fail=1 + +# O_DIRECT is orthogonal to drop cache so mutually exclusive +dd iflag=nocache,direct if=/dev/null && fail=1 + +# The rest ensure that the documented uses cases +# proceed without error +for f in ifile ofile; do + dd if=/dev/zero of=$f conv=fdatasync count=100 || framework_failure_ +done + +# Advise to drop cache for whole file +if ! dd if=ifile iflag=nocache count=0 2>err; then + # We could check for 'Operation not supported' in err here, + # but that was seen to be brittle. HPUX returns ENOTTY for example. + # So assume that if this basic operation fails, it's due to lack + # of support by the system. + warn_ 'skipping part; this file system lacks support for posix_fadvise()' + skip=1 +fi + +if test "$skip" != 1; then + # Ensure drop cache for whole file + dd of=ofile oflag=nocache conv=notrunc,fdatasync count=0 || fail=1 + + # Drop cache for part of file + dd if=ifile iflag=nocache skip=10 count=10 of=/dev/null || fail=1 + + # Stream data just using readahead cache + dd if=ifile of=ofile iflag=nocache oflag=nocache || fail=1 +fi + +Exit $fail diff --git a/tests/dd/not-rewound b/tests/dd/not-rewound deleted file mode 100755 index 5364f907f..000000000 --- a/tests/dd/not-rewound +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Make sure dd does the right thing when the input file descriptor -# is not rewound. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - - -echo abcde > in -(dd skip=1 count=1 bs=1; dd skip=1 bs=1) < in > out 2> /dev/null || fail=1 -case $(cat out) in - bde) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/dd/not-rewound.sh b/tests/dd/not-rewound.sh new file mode 100755 index 000000000..5364f907f --- /dev/null +++ b/tests/dd/not-rewound.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Make sure dd does the right thing when the input file descriptor +# is not rewound. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + + +echo abcde > in +(dd skip=1 count=1 bs=1; dd skip=1 bs=1) < in > out 2> /dev/null || fail=1 +case $(cat out) in + bde) ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/dd/reblock b/tests/dd/reblock deleted file mode 100755 index 92253fb19..000000000 --- a/tests/dd/reblock +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# test dd reblocking vs. bs= - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -# 2 short reads -> 1 full write + 1 partial write -cat <<\EOF > exp-reblock || framework_failure_ -0+2 records in -1+1 records out -4 bytes (4 B) copied -EOF - -# 2 short reads -> 2 partial writes -cat <<\EOF > exp-no-reblock || framework_failure_ -0+2 records in -0+2 records out -4 bytes (4 B) copied -EOF - - -# Use a fifo rather than a pipe in the tests below -# so that the producer (printf subshell) will wait -# until the consumer (dd) opens the fifo therefore -# increasing the chance that dd will read the data -# from each printf separately. -mkfifo_or_skip_ dd.fifo - -dd_reblock_1() -{ - local delay="$1" - - # ensure that dd reblocks when bs= is not specified - dd ibs=3 obs=3 if=dd.fifo > out 2> err& - (printf 'ab'; sleep $delay; printf 'cd') > dd.fifo - wait #for dd to complete - sed 's/,.*//' err > k && mv k err - compare exp-reblock err -} - -retry_delay_ dd_reblock_1 .1 6 || fail=1 - -dd_reblock_2() -{ - local delay="$1" - - # Demonstrate that bs=N supersedes even following ibs= and obs= settings. - dd bs=3 ibs=1 obs=1 if=dd.fifo > out 2> err& - (printf 'ab'; sleep $delay; printf 'cd') > dd.fifo - wait #for dd to complete - sed 's/,.*//' err > k && mv k err - compare exp-no-reblock err -} - -retry_delay_ dd_reblock_2 .1 6 || fail=1 - -Exit $fail diff --git a/tests/dd/reblock.sh b/tests/dd/reblock.sh new file mode 100755 index 000000000..92253fb19 --- /dev/null +++ b/tests/dd/reblock.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# test dd reblocking vs. bs= + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +# 2 short reads -> 1 full write + 1 partial write +cat <<\EOF > exp-reblock || framework_failure_ +0+2 records in +1+1 records out +4 bytes (4 B) copied +EOF + +# 2 short reads -> 2 partial writes +cat <<\EOF > exp-no-reblock || framework_failure_ +0+2 records in +0+2 records out +4 bytes (4 B) copied +EOF + + +# Use a fifo rather than a pipe in the tests below +# so that the producer (printf subshell) will wait +# until the consumer (dd) opens the fifo therefore +# increasing the chance that dd will read the data +# from each printf separately. +mkfifo_or_skip_ dd.fifo + +dd_reblock_1() +{ + local delay="$1" + + # ensure that dd reblocks when bs= is not specified + dd ibs=3 obs=3 if=dd.fifo > out 2> err& + (printf 'ab'; sleep $delay; printf 'cd') > dd.fifo + wait #for dd to complete + sed 's/,.*//' err > k && mv k err + compare exp-reblock err +} + +retry_delay_ dd_reblock_1 .1 6 || fail=1 + +dd_reblock_2() +{ + local delay="$1" + + # Demonstrate that bs=N supersedes even following ibs= and obs= settings. + dd bs=3 ibs=1 obs=1 if=dd.fifo > out 2> err& + (printf 'ab'; sleep $delay; printf 'cd') > dd.fifo + wait #for dd to complete + sed 's/,.*//' err > k && mv k err + compare exp-no-reblock err +} + +retry_delay_ dd_reblock_2 .1 6 || fail=1 + +Exit $fail diff --git a/tests/dd/skip-seek b/tests/dd/skip-seek deleted file mode 100755 index 33eb9b451..000000000 --- a/tests/dd/skip-seek +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl -# Test dd's skip and seek options. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; -my $out = 'out'; - -my @Tests = - ( - [ - 'sk-seek1', - qw (bs=1 skip=1 seek=2 conv=notrunc count=3 status=noxfer of=@AUX@ < ), - {IN=> '0123456789abcdef'}, - {AUX=> 'zyxwvutsrqponmlkji'}, - {OUT=> ''}, - {ERR=> "3+0 records in\n3+0 records out\n"}, - {CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]}, - ], - [ - 'sk-seek2', - qw (bs=5 skip=1 seek=1 conv=notrunc count=1 status=noxfer of=@AUX@ < ), - {IN=> '0123456789abcdef'}, - {AUX=> 'zyxwvutsrqponmlkji'}, - {OUT=> ''}, - {ERR=> "1+0 records in\n1+0 records out\n"}, - {CMP=> ['zyxwv56789ponmlkji', {'@AUX@'=> undef}]}, - ], - [ - 'sk-seek3', - qw (bs=5 skip=1 seek=1 count=1 status=noxfer of=@AUX@ < ), - {IN=> '0123456789abcdef'}, - {AUX=> 'zyxwvutsrqponmlkji'}, - {OUT=> ''}, - {ERR=> "1+0 records in\n1+0 records out\n"}, - {CMP=> ['zyxwv56789', {'@AUX@'=> undef}]}, - ], - [ - # Before fileutils-4.0.45, the last 10 bytes of output - # were these "\0\0\0\0\0\0\0\0 ". - 'block-sync-1', qw(ibs=10 cbs=10 status=noxfer), 'conv=block,sync', '<', - {IN=> "01234567\nabcdefghijkl\n"}, - {OUT=> "01234567 abcdefghij "}, - {ERR=> "2+1 records in\n0+1 records out\n1 truncated record\n"}, - ], - [ - # Before coreutils-5.93, this would output just "c\n". - 'sk-seek4', qw(bs=1 skip=1 status=noxfer), - {IN_PIPE=> "abc\n"}, - {OUT=> "bc\n"}, - {ERR=> "3+0 records in\n3+0 records out\n"}, - ], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'dd'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/dd/skip-seek-past-dev b/tests/dd/skip-seek-past-dev deleted file mode 100755 index f4184b1bf..000000000 --- a/tests/dd/skip-seek-past-dev +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# test diagnostics are printed immediately when seeking beyond device. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -# need write access to local device -# (even though we don't actually write anything) -require_root_ -require_local_dir_ - -get_device_size() { - BLOCKDEV=blockdev - $BLOCKDEV -V >/dev/null 2>&1 || BLOCKDEV=/sbin/blockdev - $BLOCKDEV --getsize64 "$1" -} - - -# Get path to device the current dir is on. -# Note df can only get fs size, not device size. -device=$(df -P . | tail -n1 | cut -d' ' -f1) || framework_failure_ - -dev_size=$(get_device_size "$device") || - skip_ "failed to determine size of $device" - -# Don't use shell arithmetic as older versions of dash use longs -DEV_OFLOW=$(expr $dev_size + 1) - -timeout 10 dd bs=1 skip=$DEV_OFLOW count=0 status=noxfer < "$device" 2> err -test "$?" = "1" || fail=1 -echo "dd: 'standard input': cannot skip: Invalid argument -0+0 records in -0+0 records out" > err_ok || framework_failure_ -compare err_ok err || fail=1 - -timeout 10 dd bs=1 seek=$DEV_OFLOW count=0 status=noxfer > "$device" 2> err -test "$?" = "1" || fail=1 -echo "dd: 'standard output': cannot seek: Invalid argument -0+0 records in -0+0 records out" > err_ok || framework_failure_ -compare err_ok err || fail=1 - -Exit $fail diff --git a/tests/dd/skip-seek-past-dev.sh b/tests/dd/skip-seek-past-dev.sh new file mode 100755 index 000000000..f4184b1bf --- /dev/null +++ b/tests/dd/skip-seek-past-dev.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# test diagnostics are printed immediately when seeking beyond device. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +# need write access to local device +# (even though we don't actually write anything) +require_root_ +require_local_dir_ + +get_device_size() { + BLOCKDEV=blockdev + $BLOCKDEV -V >/dev/null 2>&1 || BLOCKDEV=/sbin/blockdev + $BLOCKDEV --getsize64 "$1" +} + + +# Get path to device the current dir is on. +# Note df can only get fs size, not device size. +device=$(df -P . | tail -n1 | cut -d' ' -f1) || framework_failure_ + +dev_size=$(get_device_size "$device") || + skip_ "failed to determine size of $device" + +# Don't use shell arithmetic as older versions of dash use longs +DEV_OFLOW=$(expr $dev_size + 1) + +timeout 10 dd bs=1 skip=$DEV_OFLOW count=0 status=noxfer < "$device" 2> err +test "$?" = "1" || fail=1 +echo "dd: 'standard input': cannot skip: Invalid argument +0+0 records in +0+0 records out" > err_ok || framework_failure_ +compare err_ok err || fail=1 + +timeout 10 dd bs=1 seek=$DEV_OFLOW count=0 status=noxfer > "$device" 2> err +test "$?" = "1" || fail=1 +echo "dd: 'standard output': cannot seek: Invalid argument +0+0 records in +0+0 records out" > err_ok || framework_failure_ +compare err_ok err || fail=1 + +Exit $fail diff --git a/tests/dd/skip-seek-past-file b/tests/dd/skip-seek-past-file deleted file mode 100755 index 0a8e1fdc5..000000000 --- a/tests/dd/skip-seek-past-file +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -# test diagnostics are printed when seeking too far in seekable files. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd -require_sparse_support_ # for 'truncate --size=$OFF_T_MAX' -eval $(getlimits) # for OFF_T limits - - -printf "1234" > file || framework_failure_ - -echo "\ -dd: 'standard input': cannot skip to specified offset -0+0 records in -0+0 records out" > skip_err || framework_failure_ - -# skipping beyond number of blocks in file should issue a warning -dd bs=1 skip=5 count=0 status=noxfer < file 2> err || fail=1 -compare skip_err err || fail=1 - -# skipping beyond number of bytes in file should issue a warning -dd bs=3 skip=2 count=0 status=noxfer < file 2> err || fail=1 -compare skip_err err || fail=1 - -# skipping beyond number of blocks in pipe should issue a warning -cat file | dd bs=1 skip=5 count=0 status=noxfer 2> err || fail=1 -compare skip_err err || fail=1 - -# skipping beyond number of bytes in pipe should issue a warning -cat file | dd bs=3 skip=2 count=0 status=noxfer 2> err || fail=1 -compare skip_err err || fail=1 - -# Check seeking beyond file already offset into -# skipping beyond number of blocks in file should issue a warning -(dd bs=1 skip=1 count=0 2>/dev/null && - dd bs=1 skip=4 status=noxfer 2> err) < file || fail=1 -compare skip_err err || fail=1 - -# Check seeking beyond file already offset into -# skipping beyond number of bytes in file should issue a warning -(dd bs=1 skip=1 count=0 2>/dev/null && - dd bs=2 skip=2 status=noxfer 2> err) < file || fail=1 -compare skip_err err || fail=1 - -# seeking beyond end of file is OK -dd bs=1 seek=5 count=0 status=noxfer > file 2> err || fail=1 -echo "0+0 records in -0+0 records out" > err_ok || framework_failure_ -compare err_ok err || fail=1 - -# skipping > OFF_T_MAX should fail immediately -dd bs=1 skip=$OFF_T_OFLOW count=0 status=noxfer < file 2> err && fail=1 -# error message should be "... cannot skip: strerror(EOVERFLOW)" -grep "cannot skip:" err >/dev/null || fail=1 - -# skipping > max file size should fail immediately -if ! truncate --size=$OFF_T_MAX in 2>/dev/null; then - # truncate is to ensure file system doesn't actually support OFF_T_MAX files - dd bs=1 skip=$OFF_T_MAX count=0 status=noxfer < file 2> err \ - && lseek_ok=yes \ - || lseek_ok=no - - if test $lseek_ok = yes; then - # On Solaris 10 at least, lseek(>max file size) succeeds, - # so just check for the skip warning. - compare skip_err err || fail=1 - else - # On Linux kernels at least, lseek(>max file size) fails. - # error message should be "... cannot skip: strerror(EINVAL)" - grep "cannot skip:" err >/dev/null || fail=1 - fi -fi - -Exit $fail diff --git a/tests/dd/skip-seek-past-file.sh b/tests/dd/skip-seek-past-file.sh new file mode 100755 index 000000000..0a8e1fdc5 --- /dev/null +++ b/tests/dd/skip-seek-past-file.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# test diagnostics are printed when seeking too far in seekable files. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd +require_sparse_support_ # for 'truncate --size=$OFF_T_MAX' +eval $(getlimits) # for OFF_T limits + + +printf "1234" > file || framework_failure_ + +echo "\ +dd: 'standard input': cannot skip to specified offset +0+0 records in +0+0 records out" > skip_err || framework_failure_ + +# skipping beyond number of blocks in file should issue a warning +dd bs=1 skip=5 count=0 status=noxfer < file 2> err || fail=1 +compare skip_err err || fail=1 + +# skipping beyond number of bytes in file should issue a warning +dd bs=3 skip=2 count=0 status=noxfer < file 2> err || fail=1 +compare skip_err err || fail=1 + +# skipping beyond number of blocks in pipe should issue a warning +cat file | dd bs=1 skip=5 count=0 status=noxfer 2> err || fail=1 +compare skip_err err || fail=1 + +# skipping beyond number of bytes in pipe should issue a warning +cat file | dd bs=3 skip=2 count=0 status=noxfer 2> err || fail=1 +compare skip_err err || fail=1 + +# Check seeking beyond file already offset into +# skipping beyond number of blocks in file should issue a warning +(dd bs=1 skip=1 count=0 2>/dev/null && + dd bs=1 skip=4 status=noxfer 2> err) < file || fail=1 +compare skip_err err || fail=1 + +# Check seeking beyond file already offset into +# skipping beyond number of bytes in file should issue a warning +(dd bs=1 skip=1 count=0 2>/dev/null && + dd bs=2 skip=2 status=noxfer 2> err) < file || fail=1 +compare skip_err err || fail=1 + +# seeking beyond end of file is OK +dd bs=1 seek=5 count=0 status=noxfer > file 2> err || fail=1 +echo "0+0 records in +0+0 records out" > err_ok || framework_failure_ +compare err_ok err || fail=1 + +# skipping > OFF_T_MAX should fail immediately +dd bs=1 skip=$OFF_T_OFLOW count=0 status=noxfer < file 2> err && fail=1 +# error message should be "... cannot skip: strerror(EOVERFLOW)" +grep "cannot skip:" err >/dev/null || fail=1 + +# skipping > max file size should fail immediately +if ! truncate --size=$OFF_T_MAX in 2>/dev/null; then + # truncate is to ensure file system doesn't actually support OFF_T_MAX files + dd bs=1 skip=$OFF_T_MAX count=0 status=noxfer < file 2> err \ + && lseek_ok=yes \ + || lseek_ok=no + + if test $lseek_ok = yes; then + # On Solaris 10 at least, lseek(>max file size) succeeds, + # so just check for the skip warning. + compare skip_err err || fail=1 + else + # On Linux kernels at least, lseek(>max file size) fails. + # error message should be "... cannot skip: strerror(EINVAL)" + grep "cannot skip:" err >/dev/null || fail=1 + fi +fi + +Exit $fail diff --git a/tests/dd/skip-seek.pl b/tests/dd/skip-seek.pl new file mode 100755 index 000000000..33eb9b451 --- /dev/null +++ b/tests/dd/skip-seek.pl @@ -0,0 +1,78 @@ +#!/usr/bin/perl +# Test dd's skip and seek options. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; +my $out = 'out'; + +my @Tests = + ( + [ + 'sk-seek1', + qw (bs=1 skip=1 seek=2 conv=notrunc count=3 status=noxfer of=@AUX@ < ), + {IN=> '0123456789abcdef'}, + {AUX=> 'zyxwvutsrqponmlkji'}, + {OUT=> ''}, + {ERR=> "3+0 records in\n3+0 records out\n"}, + {CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]}, + ], + [ + 'sk-seek2', + qw (bs=5 skip=1 seek=1 conv=notrunc count=1 status=noxfer of=@AUX@ < ), + {IN=> '0123456789abcdef'}, + {AUX=> 'zyxwvutsrqponmlkji'}, + {OUT=> ''}, + {ERR=> "1+0 records in\n1+0 records out\n"}, + {CMP=> ['zyxwv56789ponmlkji', {'@AUX@'=> undef}]}, + ], + [ + 'sk-seek3', + qw (bs=5 skip=1 seek=1 count=1 status=noxfer of=@AUX@ < ), + {IN=> '0123456789abcdef'}, + {AUX=> 'zyxwvutsrqponmlkji'}, + {OUT=> ''}, + {ERR=> "1+0 records in\n1+0 records out\n"}, + {CMP=> ['zyxwv56789', {'@AUX@'=> undef}]}, + ], + [ + # Before fileutils-4.0.45, the last 10 bytes of output + # were these "\0\0\0\0\0\0\0\0 ". + 'block-sync-1', qw(ibs=10 cbs=10 status=noxfer), 'conv=block,sync', '<', + {IN=> "01234567\nabcdefghijkl\n"}, + {OUT=> "01234567 abcdefghij "}, + {ERR=> "2+1 records in\n0+1 records out\n1 truncated record\n"}, + ], + [ + # Before coreutils-5.93, this would output just "c\n". + 'sk-seek4', qw(bs=1 skip=1 status=noxfer), + {IN_PIPE=> "abc\n"}, + {OUT=> "bc\n"}, + {ERR=> "3+0 records in\n3+0 records out\n"}, + ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'dd'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/dd/skip-seek2 b/tests/dd/skip-seek2 deleted file mode 100755 index 7f5e0560f..000000000 --- a/tests/dd/skip-seek2 +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# show how to skip an amount that is smaller than the nominal block size. -# There's a more realistic example in the documentation. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - - -echo LA:3456789abcdef > in || fail=1 -(dd bs=1 skip=3 count=0 && dd bs=5) < in > out 2> /dev/null || fail=1 -case $(cat out) in - 3456789abcdef) ;; - *) fail=1 ;; -esac - -echo LA:3456789abcdef > in || fail=1 -(dd bs=1 skip=3 count=0 && dd bs=5 count=2) < in > out 2> /dev/null || fail=1 -case $(cat out) in - 3456789abc) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/dd/skip-seek2.sh b/tests/dd/skip-seek2.sh new file mode 100755 index 000000000..7f5e0560f --- /dev/null +++ b/tests/dd/skip-seek2.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# show how to skip an amount that is smaller than the nominal block size. +# There's a more realistic example in the documentation. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + + +echo LA:3456789abcdef > in || fail=1 +(dd bs=1 skip=3 count=0 && dd bs=5) < in > out 2> /dev/null || fail=1 +case $(cat out) in + 3456789abcdef) ;; + *) fail=1 ;; +esac + +echo LA:3456789abcdef > in || fail=1 +(dd bs=1 skip=3 count=0 && dd bs=5 count=2) < in > out 2> /dev/null || fail=1 +case $(cat out) in + 3456789abc) ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/dd/sparse b/tests/dd/sparse deleted file mode 100755 index 35ddda91e..000000000 --- a/tests/dd/sparse +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd -require_sparse_support_ - -# Ensure basic sparse generation works -truncate -s1M sparse -dd bs=32K if=sparse of=sparse.dd conv=sparse -test $(stat -c %s sparse) = $(stat -c %s sparse.dd) || fail=1 - -# Demonstrate that conv=sparse with oflag=append, -# will do ineffective seeks in the output -printf 'a\000\000b' > file.in -printf 'ab' > exp -dd if=file.in bs=1 conv=sparse oflag=append > out -compare exp out || fail=1 - -# Demonstrate conv=sparse with conv=notrunc, -# where data in file.out is not overwritten with NULs -printf '____' > out -printf 'a__b' > exp -dd if=file.in bs=1 conv=sparse,notrunc of=out -compare exp out || fail=1 - -# Ensure we fall back to write if seek fails -dd if=file.in bs=1 conv=sparse | cat > file.out -cmp file.in file.out || fail=1 - -# Setup for block size tests: create a 3MiB file with a 1MiB -# stretch of NUL bytes in the middle. -rm -f file.in -dd if=/dev/urandom of=file.in bs=1M count=3 iflag=fullblock || fail=1 -dd if=/dev/zero of=file.in bs=1M count=1 seek=1 conv=notrunc || fail=1 - -kb_alloc() { du -k "$1"|cut -f1; } - -# If our just-created input file appears to be too small, -# skip the remaining tests. On at least Solaris 10 with NFS, -# file.in is reported to occupy <= 1KiB for about 50 seconds -# after its creation. -if test $(kb_alloc file.in) -gt 3000; then - - # Ensure NUL blocks smaller than the block size are not made sparse. - # Here, with a 2MiB block size, dd's conv=sparse must *not* introduce a hole. - dd if=file.in of=file.out bs=2M conv=sparse - test 2500 -lt $(kb_alloc file.out) || fail=1 - - # Ensure that this 1MiB string of NULs *is* converted to a hole. - dd if=file.in of=file.out bs=1M conv=sparse - test $(kb_alloc file.out) -lt 2500 || fail=1 - -fi - -Exit $fail diff --git a/tests/dd/sparse.sh b/tests/dd/sparse.sh new file mode 100755 index 000000000..35ddda91e --- /dev/null +++ b/tests/dd/sparse.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd +require_sparse_support_ + +# Ensure basic sparse generation works +truncate -s1M sparse +dd bs=32K if=sparse of=sparse.dd conv=sparse +test $(stat -c %s sparse) = $(stat -c %s sparse.dd) || fail=1 + +# Demonstrate that conv=sparse with oflag=append, +# will do ineffective seeks in the output +printf 'a\000\000b' > file.in +printf 'ab' > exp +dd if=file.in bs=1 conv=sparse oflag=append > out +compare exp out || fail=1 + +# Demonstrate conv=sparse with conv=notrunc, +# where data in file.out is not overwritten with NULs +printf '____' > out +printf 'a__b' > exp +dd if=file.in bs=1 conv=sparse,notrunc of=out +compare exp out || fail=1 + +# Ensure we fall back to write if seek fails +dd if=file.in bs=1 conv=sparse | cat > file.out +cmp file.in file.out || fail=1 + +# Setup for block size tests: create a 3MiB file with a 1MiB +# stretch of NUL bytes in the middle. +rm -f file.in +dd if=/dev/urandom of=file.in bs=1M count=3 iflag=fullblock || fail=1 +dd if=/dev/zero of=file.in bs=1M count=1 seek=1 conv=notrunc || fail=1 + +kb_alloc() { du -k "$1"|cut -f1; } + +# If our just-created input file appears to be too small, +# skip the remaining tests. On at least Solaris 10 with NFS, +# file.in is reported to occupy <= 1KiB for about 50 seconds +# after its creation. +if test $(kb_alloc file.in) -gt 3000; then + + # Ensure NUL blocks smaller than the block size are not made sparse. + # Here, with a 2MiB block size, dd's conv=sparse must *not* introduce a hole. + dd if=file.in of=file.out bs=2M conv=sparse + test 2500 -lt $(kb_alloc file.out) || fail=1 + + # Ensure that this 1MiB string of NULs *is* converted to a hole. + dd if=file.in of=file.out bs=1M conv=sparse + test $(kb_alloc file.out) -lt 2500 || fail=1 + +fi + +Exit $fail diff --git a/tests/dd/stderr b/tests/dd/stderr deleted file mode 100755 index 2c062787d..000000000 --- a/tests/dd/stderr +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Ensure dd recognizes failure to write to stderr. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -p=$abs_top_builddir - - -# Ensure this exits successfully, even though stderr is closed, -# because it generates no stderr output. -dd --help >/dev/null 2>&- || fail=1 - -# If 2>&- works, ensure this fails, because stderr is closed and it -# *does* generate output. 2>&- apparently does not work in HP-UX 11.23. -# This test is ineffective unless /dev/stderr also works. -# This exposes a failure present in 6.11 through 7.5. -if "$p/src/test" -w /dev/stderr 2>/dev/null && - "$p/src/test" ! -w /dev/stderr 2>&-; then - : | dd 2>&- && fail=1 -fi - -# Likewise for /dev/full, if /dev/full works. -if test -w /dev/full && test -c /dev/full; then - : | dd 2>/dev/full && fail=1 -fi - -Exit $fail diff --git a/tests/dd/stderr.sh b/tests/dd/stderr.sh new file mode 100755 index 000000000..2c062787d --- /dev/null +++ b/tests/dd/stderr.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Ensure dd recognizes failure to write to stderr. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +p=$abs_top_builddir + + +# Ensure this exits successfully, even though stderr is closed, +# because it generates no stderr output. +dd --help >/dev/null 2>&- || fail=1 + +# If 2>&- works, ensure this fails, because stderr is closed and it +# *does* generate output. 2>&- apparently does not work in HP-UX 11.23. +# This test is ineffective unless /dev/stderr also works. +# This exposes a failure present in 6.11 through 7.5. +if "$p/src/test" -w /dev/stderr 2>/dev/null && + "$p/src/test" ! -w /dev/stderr 2>&-; then + : | dd 2>&- && fail=1 +fi + +# Likewise for /dev/full, if /dev/full works. +if test -w /dev/full && test -c /dev/full; then + : | dd 2>/dev/full && fail=1 +fi + +Exit $fail diff --git a/tests/dd/unblock b/tests/dd/unblock deleted file mode 100755 index d71873333..000000000 --- a/tests/dd/unblock +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl -# Exercise dd's conv=unblock mode - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; -my $out = 'out'; - -my @t = - ( - # An empty test name signals that these are the arguments to use for the - # following tests. - ['', [qw (cbs=3 conv=unblock status=noxfer < )]], - ['0', '', ''], - ['1', "a\n ", "a\n\n\n"], - ['2', "a\n ", "a\n\n"], - ['3', "a ", "a\n"], - ['4', "a \n ", "a \n\n\n"], - ['5', "a \n", "a \n\n"], - ['6', "a ", "a\n\n"], - ['7', "a \n", "a\n\n\n"], - ); - -my @Tests; -my $args; -foreach my $t (@t) - { - $t->[0] eq '' - and $args = $t->[1], next; - - push @Tests, [$t->[0], @$args, {IN=>$t->[1]}, {OUT=>$t->[2]}, - {ERR_SUBST=>'s/^\d+\+\d+ records (?:in|out)$//'}, - {ERR=>"\n\n"}]; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'dd'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/dd/unblock-sync b/tests/dd/unblock-sync deleted file mode 100755 index 68239f228..000000000 --- a/tests/dd/unblock-sync +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Ensure that dd conv=unblock,sync works. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ dd - -printf 000100020003xx > in || framework_failure_ - - -dd cbs=4 ibs=4 conv=unblock,sync < in > out 2> /dev/null || fail=1 -cat <<\EOF > exp || fail=1 -0001 -0002 -0003 -xx -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/dd/unblock-sync.sh b/tests/dd/unblock-sync.sh new file mode 100755 index 000000000..68239f228 --- /dev/null +++ b/tests/dd/unblock-sync.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Ensure that dd conv=unblock,sync works. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ dd + +printf 000100020003xx > in || framework_failure_ + + +dd cbs=4 ibs=4 conv=unblock,sync < in > out 2> /dev/null || fail=1 +cat <<\EOF > exp || fail=1 +0001 +0002 +0003 +xx +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/dd/unblock.pl b/tests/dd/unblock.pl new file mode 100755 index 000000000..d71873333 --- /dev/null +++ b/tests/dd/unblock.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# Exercise dd's conv=unblock mode + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; +my $out = 'out'; + +my @t = + ( + # An empty test name signals that these are the arguments to use for the + # following tests. + ['', [qw (cbs=3 conv=unblock status=noxfer < )]], + ['0', '', ''], + ['1', "a\n ", "a\n\n\n"], + ['2', "a\n ", "a\n\n"], + ['3', "a ", "a\n"], + ['4', "a \n ", "a \n\n\n"], + ['5', "a \n", "a \n\n"], + ['6', "a ", "a\n\n"], + ['7', "a \n", "a\n\n\n"], + ); + +my @Tests; +my $args; +foreach my $t (@t) + { + $t->[0] eq '' + and $args = $t->[1], next; + + push @Tests, [$t->[0], @$args, {IN=>$t->[1]}, {OUT=>$t->[2]}, + {ERR_SUBST=>'s/^\d+\+\d+ records (?:in|out)$//'}, + {ERR=>"\n\n"}]; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'dd'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/df/df-P b/tests/df/df-P deleted file mode 100755 index dfce41419..000000000 --- a/tests/df/df-P +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Ensure that df -P is not affected by BLOCK_SIZE settings - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ df - - - df -P . > t1 || fail=1 -BLOCK_SIZE=1M df -P . > t2 || fail=1 - -# Since disk utilization may be changing, compare only df's header line. -# That records the block size. E.g., for "1M", it would be: -# Filesystem 1048576-blocks Used Available Capacity Mounted on -# while for 1K, it would be -# Filesystem 1024-blocks Used Available Capacity Mounted on - -head -n1 t1 > exp || fail=1 -head -n1 t2 > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/df/df-P.sh b/tests/df/df-P.sh new file mode 100755 index 000000000..dfce41419 --- /dev/null +++ b/tests/df/df-P.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Ensure that df -P is not affected by BLOCK_SIZE settings + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ df + + + df -P . > t1 || fail=1 +BLOCK_SIZE=1M df -P . > t2 || fail=1 + +# Since disk utilization may be changing, compare only df's header line. +# That records the block size. E.g., for "1M", it would be: +# Filesystem 1048576-blocks Used Available Capacity Mounted on +# while for 1K, it would be +# Filesystem 1024-blocks Used Available Capacity Mounted on + +head -n1 t1 > exp || fail=1 +head -n1 t2 > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/df/header b/tests/df/header deleted file mode 100755 index 4fc626e8f..000000000 --- a/tests/df/header +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Ensure that "df ." outputs a header. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ df - -case $(df .) in -*' -'*) ;; -*) fail=1;; -esac - -Exit $fail diff --git a/tests/df/header.sh b/tests/df/header.sh new file mode 100755 index 000000000..4fc626e8f --- /dev/null +++ b/tests/df/header.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Ensure that "df ." outputs a header. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ df + +case $(df .) in +*' +'*) ;; +*) fail=1;; +esac + +Exit $fail diff --git a/tests/df/no-mtab-status b/tests/df/no-mtab-status deleted file mode 100755 index e434f5f3e..000000000 --- a/tests/df/no-mtab-status +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# Test df's behaviour when the mount list cannot be read. -# This test is skipped on systems that lack LD_PRELOAD support; that's fine. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ df - -df || skip_ "df fails" - -# Simulate "mtab" failure. -cat > k.c <<'EOF' || framework_failure_ -#include -#include -#include - -struct mntent *getmntent (FILE *fp) -{ - /* Prove that LD_PRELOAD works. */ - static int done = 0; - if (!done) - { - fclose (fopen ("x", "w")); - ++done; - } - /* Now simulate the failure. */ - errno = ENOENT; - return NULL; -} -EOF - -# Then compile/link it: -$CC -shared -fPIC -ldl -O2 k.c -o k.so \ - || skip_ "getmntent hack does not work on this platform" - -# Test if LD_PRELOAD works: -LD_PRELOAD=./k.so df -test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" - -# These tests are supposed to succeed: -LD_PRELOAD=./k.so df '.' || fail=1 -LD_PRELOAD=./k.so df -i '.' || fail=1 -LD_PRELOAD=./k.so df -T '.' || fail=1 -LD_PRELOAD=./k.so df -Ti '.' || fail=1 -LD_PRELOAD=./k.so df --total '.' || fail=1 - -# These tests are supposed to fail: -LD_PRELOAD=./k.so df && fail=1 -LD_PRELOAD=./k.so df -i && fail=1 -LD_PRELOAD=./k.so df -T && fail=1 -LD_PRELOAD=./k.so df -Ti && fail=1 -LD_PRELOAD=./k.so df --total && fail=1 - -LD_PRELOAD=./k.so df -a && fail=1 -LD_PRELOAD=./k.so df -a '.' && fail=1 - -LD_PRELOAD=./k.so df -l && fail=1 -LD_PRELOAD=./k.so df -l '.' && fail=1 - -LD_PRELOAD=./k.so df -t hello && fail=1 -LD_PRELOAD=./k.so df -t hello '.' && fail=1 - -LD_PRELOAD=./k.so df -x hello && fail=1 -LD_PRELOAD=./k.so df -x hello '.' && fail=1 - -Exit $fail diff --git a/tests/df/no-mtab-status.sh b/tests/df/no-mtab-status.sh new file mode 100755 index 000000000..e434f5f3e --- /dev/null +++ b/tests/df/no-mtab-status.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Test df's behaviour when the mount list cannot be read. +# This test is skipped on systems that lack LD_PRELOAD support; that's fine. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ df + +df || skip_ "df fails" + +# Simulate "mtab" failure. +cat > k.c <<'EOF' || framework_failure_ +#include +#include +#include + +struct mntent *getmntent (FILE *fp) +{ + /* Prove that LD_PRELOAD works. */ + static int done = 0; + if (!done) + { + fclose (fopen ("x", "w")); + ++done; + } + /* Now simulate the failure. */ + errno = ENOENT; + return NULL; +} +EOF + +# Then compile/link it: +$CC -shared -fPIC -ldl -O2 k.c -o k.so \ + || skip_ "getmntent hack does not work on this platform" + +# Test if LD_PRELOAD works: +LD_PRELOAD=./k.so df +test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" + +# These tests are supposed to succeed: +LD_PRELOAD=./k.so df '.' || fail=1 +LD_PRELOAD=./k.so df -i '.' || fail=1 +LD_PRELOAD=./k.so df -T '.' || fail=1 +LD_PRELOAD=./k.so df -Ti '.' || fail=1 +LD_PRELOAD=./k.so df --total '.' || fail=1 + +# These tests are supposed to fail: +LD_PRELOAD=./k.so df && fail=1 +LD_PRELOAD=./k.so df -i && fail=1 +LD_PRELOAD=./k.so df -T && fail=1 +LD_PRELOAD=./k.so df -Ti && fail=1 +LD_PRELOAD=./k.so df --total && fail=1 + +LD_PRELOAD=./k.so df -a && fail=1 +LD_PRELOAD=./k.so df -a '.' && fail=1 + +LD_PRELOAD=./k.so df -l && fail=1 +LD_PRELOAD=./k.so df -l '.' && fail=1 + +LD_PRELOAD=./k.so df -t hello && fail=1 +LD_PRELOAD=./k.so df -t hello '.' && fail=1 + +LD_PRELOAD=./k.so df -x hello && fail=1 +LD_PRELOAD=./k.so df -x hello '.' && fail=1 + +Exit $fail diff --git a/tests/df/problematic-chars b/tests/df/problematic-chars deleted file mode 100755 index 801c4d9cf..000000000 --- a/tests/df/problematic-chars +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# Ensure that df outputs one line per entry - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ df -require_root_ - -mnt='mount -point' - -cwd=$(pwd) -cleanup_() { cd /; umount "$cwd/$mnt"; } - -skip=0 -# Create a file system, then mount it. -dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \ - || skip=1 -mkdir "$mnt" || skip=1 -mkfs -t ext2 -F blob \ - || skip_ "failed to create ext2 file system" - -mount -oloop blob "$mnt" || skip=1 - -test $skip = 1 \ - && skip_ "insufficient mount/ext2 support" - -test $(df "$mnt" | wc -l) = 2 || fail=1 - -Exit $fail diff --git a/tests/df/problematic-chars.sh b/tests/df/problematic-chars.sh new file mode 100755 index 000000000..801c4d9cf --- /dev/null +++ b/tests/df/problematic-chars.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Ensure that df outputs one line per entry + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ df +require_root_ + +mnt='mount +point' + +cwd=$(pwd) +cleanup_() { cd /; umount "$cwd/$mnt"; } + +skip=0 +# Create a file system, then mount it. +dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \ + || skip=1 +mkdir "$mnt" || skip=1 +mkfs -t ext2 -F blob \ + || skip_ "failed to create ext2 file system" + +mount -oloop blob "$mnt" || skip=1 + +test $skip = 1 \ + && skip_ "insufficient mount/ext2 support" + +test $(df "$mnt" | wc -l) = 2 || fail=1 + +Exit $fail diff --git a/tests/df/total-unprocessed b/tests/df/total-unprocessed deleted file mode 100755 index aa4983683..000000000 --- a/tests/df/total-unprocessed +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# Ensure that df exits non-Zero and writes an error message when -# --total is used but no file system has been processed. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ df -require_mount_list_ - -cat <<\EOF > exp || framework_failure_ -df: no file systems processed -EOF - -# The following simply finds no match for the combination -# of the options --local and FS-type nfs together with the -# argument ".". It must exit non-Zero nonetheless. -df --local -t nfs --total '.' 2>out && fail=1 -compare exp out || fail=1 - -cat <<\EOF > exp || framework_failure_ -df: '_does_not_exist_': No such file or directory -EOF - -# Ensure that df writes the error message also in the following case. -df --total _does_not_exist_ 2>out && fail=1 -compare exp out || fail=1 - -Exit $fail diff --git a/tests/df/total-unprocessed.sh b/tests/df/total-unprocessed.sh new file mode 100755 index 000000000..aa4983683 --- /dev/null +++ b/tests/df/total-unprocessed.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Ensure that df exits non-Zero and writes an error message when +# --total is used but no file system has been processed. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ df +require_mount_list_ + +cat <<\EOF > exp || framework_failure_ +df: no file systems processed +EOF + +# The following simply finds no match for the combination +# of the options --local and FS-type nfs together with the +# argument ".". It must exit non-Zero nonetheless. +df --local -t nfs --total '.' 2>out && fail=1 +compare exp out || fail=1 + +cat <<\EOF > exp || framework_failure_ +df: '_does_not_exist_': No such file or directory +EOF + +# Ensure that df writes the error message also in the following case. +df --total _does_not_exist_ 2>out && fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/tests/df/total-verify b/tests/df/total-verify deleted file mode 100755 index 948b002e0..000000000 --- a/tests/df/total-verify +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -# Ensure "df --total" computes accurate totals - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ df -require_perl_ - -df || skip_ "df fails" - -cat <<\EOF > check-df || framework_failure_ -my ($total, $used, $avail) = (0, 0, 0); -while (<>) - { - $. == 1 - and next; # skip first (header) line - # Recognize df output lines like these: - # /dev/sdc1 0 0 0 - /c - # tmpfs 1536000 12965 1523035 1% /tmp - # total 5285932 787409 4498523 15% - /^(.*?) +(-?\d+|-) +(-?\d+|-) +(-?\d+|-) +(?:- |[0-9]+%)(.*)$/ - or die "$0: invalid input line\n: $_"; - if ($1 eq 'total' && $5 eq '') - { - $total == $2 or die "$total != $2"; - $used == $3 or die "$used != $3"; - $avail == $4 or die "$avail != $4"; - my $line = <>; - defined $line - and die "$0: extra line(s) after totals\n"; - exit 0; - } - $total += $2 unless $2 eq '-'; - $used += $3 unless $3 eq '-'; - $avail += $4 unless $4 eq '-'; - } -die "$0: missing line of totals\n"; -EOF - -# Use --block-size=512 to keep df from printing rounded-to-kilobyte -# numbers which wouldn't necessarily add up to the displayed total. -df --total -P --block-size=512 > space || framework_failure_ -cat space # this helps when debugging any test failure -df --total -i -P > inode || framework_failure_ -cat inode - -$PERL check-df space || fail=1 -$PERL check-df inode || fail=1 - -Exit $fail diff --git a/tests/df/total-verify.sh b/tests/df/total-verify.sh new file mode 100755 index 000000000..948b002e0 --- /dev/null +++ b/tests/df/total-verify.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# Ensure "df --total" computes accurate totals + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ df +require_perl_ + +df || skip_ "df fails" + +cat <<\EOF > check-df || framework_failure_ +my ($total, $used, $avail) = (0, 0, 0); +while (<>) + { + $. == 1 + and next; # skip first (header) line + # Recognize df output lines like these: + # /dev/sdc1 0 0 0 - /c + # tmpfs 1536000 12965 1523035 1% /tmp + # total 5285932 787409 4498523 15% + /^(.*?) +(-?\d+|-) +(-?\d+|-) +(-?\d+|-) +(?:- |[0-9]+%)(.*)$/ + or die "$0: invalid input line\n: $_"; + if ($1 eq 'total' && $5 eq '') + { + $total == $2 or die "$total != $2"; + $used == $3 or die "$used != $3"; + $avail == $4 or die "$avail != $4"; + my $line = <>; + defined $line + and die "$0: extra line(s) after totals\n"; + exit 0; + } + $total += $2 unless $2 eq '-'; + $used += $3 unless $3 eq '-'; + $avail += $4 unless $4 eq '-'; + } +die "$0: missing line of totals\n"; +EOF + +# Use --block-size=512 to keep df from printing rounded-to-kilobyte +# numbers which wouldn't necessarily add up to the displayed total. +df --total -P --block-size=512 > space || framework_failure_ +cat space # this helps when debugging any test failure +df --total -i -P > inode || framework_failure_ +cat inode + +$PERL check-df space || fail=1 +$PERL check-df inode || fail=1 + +Exit $fail diff --git a/tests/df/unreadable b/tests/df/unreadable deleted file mode 100755 index b0ef3fc84..000000000 --- a/tests/df/unreadable +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# ensure that df can handle an unreadable argument - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ df -skip_if_root_ - -touch unreadable || fail=1 -chmod a-r unreadable || fail=1 -df unreadable || fail=1 - -Exit $fail diff --git a/tests/df/unreadable.sh b/tests/df/unreadable.sh new file mode 100755 index 000000000..b0ef3fc84 --- /dev/null +++ b/tests/df/unreadable.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# ensure that df can handle an unreadable argument + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ df +skip_if_root_ + +touch unreadable || fail=1 +chmod a-r unreadable || fail=1 +df unreadable || fail=1 + +Exit $fail diff --git a/tests/du/2g b/tests/du/2g deleted file mode 100755 index 96cf62d7c..000000000 --- a/tests/du/2g +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -# Ensure that du can handle a 2GB file (i.e., a file of size 2^31 bytes) -# Before coreutils-5.93, on systems with a signed, 32-bit stat.st_blocks -# one of du's computations would overflow. - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -# Creating a 2GB file counts as 'very expensive'. -very_expensive_ - - -# Get number of free kilobytes on current partition, so we can -# skip this test if there is insufficient free space. - -# This technique relies on the fact that the 'Available' kilobyte -# count is the number just before the one with a trailing '%'. -free_kb=$(df -kP .|tail -1|sed 's/ [0-9][0-9]*%.*//;s/ *$//;s/.* //') -case "$free_kb" in - [0-9]*) ;; - *) skip_ "invalid size from df: $free_kb";; -esac - -# Require about 3GB free. -min_kb=3000000 -test $min_kb -lt $free_kb || -{ - skip_ \ - "too little free space on current partition: $free_kb (need $min_kb KB)" -} - -big=big -rm -f $big -test -t 1 || printf 'creating a 2GB file...\n' -for i in $(seq 100); do - # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration. - printf %21474836s x >> $big || fail=1 - # On the final iteration, append the remaining 48 bytes. - test $i = 100 && { printf %48s x >> $big || fail=1; } - test -t 1 && printf 'creating a 2GB file: %d%% complete\r' $i -done -echo - -du -k $big > out1 || fail=1 -rm -f $big -sed 's/^2[0-9][0-9][0-9][0-9][0-9][0-9] '$big'$/~2M/' out1 > out - -cat <<\EOF > exp || fail=1 -~2M -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/2g.sh b/tests/du/2g.sh new file mode 100755 index 000000000..96cf62d7c --- /dev/null +++ b/tests/du/2g.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# Ensure that du can handle a 2GB file (i.e., a file of size 2^31 bytes) +# Before coreutils-5.93, on systems with a signed, 32-bit stat.st_blocks +# one of du's computations would overflow. + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +# Creating a 2GB file counts as 'very expensive'. +very_expensive_ + + +# Get number of free kilobytes on current partition, so we can +# skip this test if there is insufficient free space. + +# This technique relies on the fact that the 'Available' kilobyte +# count is the number just before the one with a trailing '%'. +free_kb=$(df -kP .|tail -1|sed 's/ [0-9][0-9]*%.*//;s/ *$//;s/.* //') +case "$free_kb" in + [0-9]*) ;; + *) skip_ "invalid size from df: $free_kb";; +esac + +# Require about 3GB free. +min_kb=3000000 +test $min_kb -lt $free_kb || +{ + skip_ \ + "too little free space on current partition: $free_kb (need $min_kb KB)" +} + +big=big +rm -f $big +test -t 1 || printf 'creating a 2GB file...\n' +for i in $(seq 100); do + # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration. + printf %21474836s x >> $big || fail=1 + # On the final iteration, append the remaining 48 bytes. + test $i = 100 && { printf %48s x >> $big || fail=1; } + test -t 1 && printf 'creating a 2GB file: %d%% complete\r' $i +done +echo + +du -k $big > out1 || fail=1 +rm -f $big +sed 's/^2[0-9][0-9][0-9][0-9][0-9][0-9] '$big'$/~2M/' out1 > out + +cat <<\EOF > exp || fail=1 +~2M +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/8gb b/tests/du/8gb deleted file mode 100755 index 556423e3c..000000000 --- a/tests/du/8gb +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# Ensure that du does not rely on narrow types like size_t for -# file sizes or sums. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du -require_sparse_support_ - -dd bs=1 seek=8G of=big < /dev/null 2> /dev/null -if test $? != 0; then - skip_ 'cannot create a file large enough for this test; possibly -because file offsets are only 32 bits on this file system' -fi - -# FIXME: this should be a test of dd. -# On some systems (at least linux-2.4.18 + NFS to disks on a Solaris system) -# the 'dd' command above mistakenly creates a file of length '0', yet -# doesn't fail. The root of that failure is that the ftruncate call -# returns zero but doesn't do its job. Detect this failure. -set x $(ls -gG big) -size=$4 -if test "$size" = 0; then - skip_ "cannot create a file large enough for this test -possibly because this system's NFS support is buggy -Consider rerunning this test on a different file system." -fi - - -# This would print '0 big' with coreutils-4.5.8. -du -ab big > out || fail=1 - -cat <<\EOF > exp -8589934592 big -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/8gb.sh b/tests/du/8gb.sh new file mode 100755 index 000000000..556423e3c --- /dev/null +++ b/tests/du/8gb.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Ensure that du does not rely on narrow types like size_t for +# file sizes or sums. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du +require_sparse_support_ + +dd bs=1 seek=8G of=big < /dev/null 2> /dev/null +if test $? != 0; then + skip_ 'cannot create a file large enough for this test; possibly +because file offsets are only 32 bits on this file system' +fi + +# FIXME: this should be a test of dd. +# On some systems (at least linux-2.4.18 + NFS to disks on a Solaris system) +# the 'dd' command above mistakenly creates a file of length '0', yet +# doesn't fail. The root of that failure is that the ftruncate call +# returns zero but doesn't do its job. Detect this failure. +set x $(ls -gG big) +size=$4 +if test "$size" = 0; then + skip_ "cannot create a file large enough for this test +possibly because this system's NFS support is buggy +Consider rerunning this test on a different file system." +fi + + +# This would print '0 big' with coreutils-4.5.8. +du -ab big > out || fail=1 + +cat <<\EOF > exp +8589934592 big +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/basic b/tests/du/basic deleted file mode 100755 index d8acf6420..000000000 --- a/tests/du/basic +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -# Compare actual numbers from du, assuming block size matches mine. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir -p a/b d d/sub || framework_failure_ - -# Ensure that these files contain more than 64 bytes, so that we don't -# immediately disqualify file systems (e.g., NetApp) on which smaller -# files take up zero disk blocks. -printf '%*s' 257 make-sure-the-file-is-non-empty > a/b/F || framework_failure_ -printf %4096s x > d/1 -cp d/1 d/sub/2 - - -B=$(stat --format=%B a/b/F) - -du --block-size=$B -a a > out || fail=1 -echo === >> out -du --block-size=$B -a -S a >> out || fail=1 -echo === >> out -du --block-size=$B -s a >> out || fail=1 - -f=$(stat --format=%b a/b/F) -b=$(stat --format=%b a/b) -a=$(stat --format=%b a) -bf=$(expr $b + $f) -tot=$(expr $bf + $a) - -cat < exp -$f a/b/F -$bf a/b -$tot a -=== -$f a/b/F # size of file, a/b/F -$bf a/b # size of dir entry, a/b, + size of file, a/b/F -$a a # size of dir entry, a -=== -$tot a -EOF - -compare exp out || fail=1 - -# Perform this test only if "." is on a local file system. -# Otherwise, it would fail e.g., on an NFS-mounted Solaris ZFS file system. -if is_local_dir_ .; then - rm -f out exp - du --block-size=$B -a d | sort -r -k2,2 > out || fail=1 - echo === >> out - du --block-size=$B -S d | sort -r -k2,2 >> out || fail=1 - - t2=$(stat --format=%b d/sub/2) - ts=$(stat --format=%b d/sub) - t1=$(stat --format=%b d/1) - td=$(stat --format=%b d) - tot=$(expr $t1 + $t2 + $ts + $td) - d1=$(expr $td + $t1) - s2=$(expr $ts + $t2) - - cat < exp -$t2 d/sub/2 -$s2 d/sub -$t1 d/1 -$tot d -=== -$s2 d/sub -$d1 d # d + d/1; don't count the dir. entry for d/sub -EOF - - compare exp out || fail=1 -fi - -Exit $fail diff --git a/tests/du/basic.sh b/tests/du/basic.sh new file mode 100755 index 000000000..d8acf6420 --- /dev/null +++ b/tests/du/basic.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# Compare actual numbers from du, assuming block size matches mine. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir -p a/b d d/sub || framework_failure_ + +# Ensure that these files contain more than 64 bytes, so that we don't +# immediately disqualify file systems (e.g., NetApp) on which smaller +# files take up zero disk blocks. +printf '%*s' 257 make-sure-the-file-is-non-empty > a/b/F || framework_failure_ +printf %4096s x > d/1 +cp d/1 d/sub/2 + + +B=$(stat --format=%B a/b/F) + +du --block-size=$B -a a > out || fail=1 +echo === >> out +du --block-size=$B -a -S a >> out || fail=1 +echo === >> out +du --block-size=$B -s a >> out || fail=1 + +f=$(stat --format=%b a/b/F) +b=$(stat --format=%b a/b) +a=$(stat --format=%b a) +bf=$(expr $b + $f) +tot=$(expr $bf + $a) + +cat < exp +$f a/b/F +$bf a/b +$tot a +=== +$f a/b/F # size of file, a/b/F +$bf a/b # size of dir entry, a/b, + size of file, a/b/F +$a a # size of dir entry, a +=== +$tot a +EOF + +compare exp out || fail=1 + +# Perform this test only if "." is on a local file system. +# Otherwise, it would fail e.g., on an NFS-mounted Solaris ZFS file system. +if is_local_dir_ .; then + rm -f out exp + du --block-size=$B -a d | sort -r -k2,2 > out || fail=1 + echo === >> out + du --block-size=$B -S d | sort -r -k2,2 >> out || fail=1 + + t2=$(stat --format=%b d/sub/2) + ts=$(stat --format=%b d/sub) + t1=$(stat --format=%b d/1) + td=$(stat --format=%b d) + tot=$(expr $t1 + $t2 + $ts + $td) + d1=$(expr $td + $t1) + s2=$(expr $ts + $t2) + + cat < exp +$t2 d/sub/2 +$s2 d/sub +$t1 d/1 +$tot d +=== +$s2 d/sub +$d1 d # d + d/1; don't count the dir. entry for d/sub +EOF + + compare exp out || fail=1 +fi + +Exit $fail diff --git a/tests/du/bigtime b/tests/du/bigtime deleted file mode 100755 index 964fb710a..000000000 --- a/tests/du/bigtime +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Exercise du on a file with a big time stamp. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src - -export LC_ALL=C -export TZ=UTC0 - -# 2**63 - 1 -bignum=9223372036854775807 - -touch -d @$bignum future 2>/dev/null && -future_time=$(ls -l future) && -case "$future_time" in -*" $bignum "*) - : ;; -*' Dec 4 300627798676 '*) - skip_ "file system and localtime both handle big timestamps" ;; -*) - skip_ "file system or localtime mishandles big time stamps:" \ - "$future_time" ;; -esac || skip_ "file system cannot represent big time stamps" - -printf "0\t$bignum\tfuture\n" > exp || framework_failure_ -printf "du: time $bignum is out of range\n" > err_ok || framework_failure_ - -du --time future >out 2>err || fail=1 - -# On some systems an empty file occupies 4 blocks. -# Map the number of blocks to 0. -sed 's/^[0-9][0-9]*/0/' out > k && mv k out - -compare exp out || fail=1 -compare err err_ok || fail=1 - -Exit $fail diff --git a/tests/du/bigtime.sh b/tests/du/bigtime.sh new file mode 100755 index 000000000..964fb710a --- /dev/null +++ b/tests/du/bigtime.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Exercise du on a file with a big time stamp. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +export LC_ALL=C +export TZ=UTC0 + +# 2**63 - 1 +bignum=9223372036854775807 + +touch -d @$bignum future 2>/dev/null && +future_time=$(ls -l future) && +case "$future_time" in +*" $bignum "*) + : ;; +*' Dec 4 300627798676 '*) + skip_ "file system and localtime both handle big timestamps" ;; +*) + skip_ "file system or localtime mishandles big time stamps:" \ + "$future_time" ;; +esac || skip_ "file system cannot represent big time stamps" + +printf "0\t$bignum\tfuture\n" > exp || framework_failure_ +printf "du: time $bignum is out of range\n" > err_ok || framework_failure_ + +du --time future >out 2>err || fail=1 + +# On some systems an empty file occupies 4 blocks. +# Map the number of blocks to 0. +sed 's/^[0-9][0-9]*/0/' out > k && mv k out + +compare exp out || fail=1 +compare err err_ok || fail=1 + +Exit $fail diff --git a/tests/du/bind-mount-dir-cycle b/tests/du/bind-mount-dir-cycle deleted file mode 100755 index 516ceae58..000000000 --- a/tests/du/bind-mount-dir-cycle +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# Exercise du's new ability to handle bind-mount-induced dir cycles. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du -require_root_ - -cleanup_() -{ - # When you take the undesirable shortcut of making /etc/mtab a link - # to /proc/mounts, unmounting "$other_partition_tmpdir" would fail. - # So, here we unmount a/b instead. - umount a/b -} - -mkdir -p a/b || framework_failure_ -mount --bind a a/b \ - || skip_ "This test requires mount with a working --bind option." - -echo a > exp || framework_failure_ -echo "du: mount point 'a/b' already traversed" > exp-err || framework_failure_ - -du a > out 2> err && fail=1 -sed 's/^[0-9][0-9]* //' out > k && mv k out - -compare exp-err err || fail=1 -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/bind-mount-dir-cycle.sh b/tests/du/bind-mount-dir-cycle.sh new file mode 100755 index 000000000..516ceae58 --- /dev/null +++ b/tests/du/bind-mount-dir-cycle.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Exercise du's new ability to handle bind-mount-induced dir cycles. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du +require_root_ + +cleanup_() +{ + # When you take the undesirable shortcut of making /etc/mtab a link + # to /proc/mounts, unmounting "$other_partition_tmpdir" would fail. + # So, here we unmount a/b instead. + umount a/b +} + +mkdir -p a/b || framework_failure_ +mount --bind a a/b \ + || skip_ "This test requires mount with a working --bind option." + +echo a > exp || framework_failure_ +echo "du: mount point 'a/b' already traversed" > exp-err || framework_failure_ + +du a > out 2> err && fail=1 +sed 's/^[0-9][0-9]* //' out > k && mv k out + +compare exp-err err || fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/deref b/tests/du/deref deleted file mode 100755 index 90b765039..000000000 --- a/tests/du/deref +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# prior to coreutils-4.5.3, du -D didn't work in some cases -# Based on an example from Andreas Schwab and/or Michal Svec. -# Also, up to coreutils-8.5, du -L sometimes incorrectly -# counted the space of the followed symlinks. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir -p a/sub || framework_failure_ -ln -s a/sub slink || framework_failure_ -touch b || framework_failure_ -ln -s .. a/sub/dotdot || framework_failure_ -ln -s nowhere dangle || framework_failure_ - - -# This used to fail with the following diagnostic: -# du: 'b': No such file or directory -du -sD slink b > /dev/null 2>&1 || fail=1 - -# This used to fail to report the dangling symlink. -du -L dangle > /dev/null 2>&1 && fail=1 - -# du -L used to mess up, either by counting the symlink's disk space itself -# (-L should follow symlinks, not count their space) -# or (briefly in July 2010) by omitting the entry for "a". -du_L_output=$(du -L a) || fail=1 -du_lL_output=$(du -lL a) || fail=1 -du_x_output=$(du --exclude=dotdot a) || fail=1 -test "X$du_L_output" = "X$du_x_output" || fail=1 -test "X$du_lL_output" = "X$du_x_output" || fail=1 - -Exit $fail diff --git a/tests/du/deref-args b/tests/du/deref-args deleted file mode 100755 index 098e01a46..000000000 --- a/tests/du/deref-args +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# Ensure that --dereference-args (-D) gives reasonable names. -# This test would fail for coreutils-5.0.91. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir -p dir/a || framework_failure_ -ln -s dir slink || framework_failure_ -printf %65536s x > 64k || framework_failure_ -ln -s 64k slink-to-64k || framework_failure_ - - -du -D slink | sed 's/^[0-9][0-9]* //' > out -# Ensure that the trailing slash is preserved and handled properly. -du -D slink/ | sed 's/^[0-9][0-9]* //' >> out - -# Ensure that -D makes du dereference even symlinks to non-directories. -# Be sure to use --apparent-size. Otherwise, we'd get varying block counts -# depending on file system type (e.g. 68 on ext3 vs. 64 on tmpfs and 72 -# on SELinux-enabled systems). -du --apparent-size --block-size=1K -D slink-to-64k >> out -cat <<\EOF > exp -slink/a -slink -slink/a -slink/ -64 slink-to-64k -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/deref-args.sh b/tests/du/deref-args.sh new file mode 100755 index 000000000..098e01a46 --- /dev/null +++ b/tests/du/deref-args.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Ensure that --dereference-args (-D) gives reasonable names. +# This test would fail for coreutils-5.0.91. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir -p dir/a || framework_failure_ +ln -s dir slink || framework_failure_ +printf %65536s x > 64k || framework_failure_ +ln -s 64k slink-to-64k || framework_failure_ + + +du -D slink | sed 's/^[0-9][0-9]* //' > out +# Ensure that the trailing slash is preserved and handled properly. +du -D slink/ | sed 's/^[0-9][0-9]* //' >> out + +# Ensure that -D makes du dereference even symlinks to non-directories. +# Be sure to use --apparent-size. Otherwise, we'd get varying block counts +# depending on file system type (e.g. 68 on ext3 vs. 64 on tmpfs and 72 +# on SELinux-enabled systems). +du --apparent-size --block-size=1K -D slink-to-64k >> out +cat <<\EOF > exp +slink/a +slink +slink/a +slink/ +64 slink-to-64k +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/deref.sh b/tests/du/deref.sh new file mode 100755 index 000000000..90b765039 --- /dev/null +++ b/tests/du/deref.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# prior to coreutils-4.5.3, du -D didn't work in some cases +# Based on an example from Andreas Schwab and/or Michal Svec. +# Also, up to coreutils-8.5, du -L sometimes incorrectly +# counted the space of the followed symlinks. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir -p a/sub || framework_failure_ +ln -s a/sub slink || framework_failure_ +touch b || framework_failure_ +ln -s .. a/sub/dotdot || framework_failure_ +ln -s nowhere dangle || framework_failure_ + + +# This used to fail with the following diagnostic: +# du: 'b': No such file or directory +du -sD slink b > /dev/null 2>&1 || fail=1 + +# This used to fail to report the dangling symlink. +du -L dangle > /dev/null 2>&1 && fail=1 + +# du -L used to mess up, either by counting the symlink's disk space itself +# (-L should follow symlinks, not count their space) +# or (briefly in July 2010) by omitting the entry for "a". +du_L_output=$(du -L a) || fail=1 +du_lL_output=$(du -lL a) || fail=1 +du_x_output=$(du --exclude=dotdot a) || fail=1 +test "X$du_L_output" = "X$du_x_output" || fail=1 +test "X$du_lL_output" = "X$du_x_output" || fail=1 + +Exit $fail diff --git a/tests/du/exclude b/tests/du/exclude deleted file mode 100755 index cad2d7f89..000000000 --- a/tests/du/exclude +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# make sure du's --exclude option works - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir -p a/b/c a/x/y a/u/v || framework_failure_ - - -du --exclude=x a | sed 's/^[0-9][0-9]* //' | sort > out || fail=1 -printf '===\n' >> out -printf 'b\n' > excl -du --exclude-from=excl a | sed 's/^[0-9][0-9]* //' | sort >> out || fail=1 -printf '===\n' >> out -# Make sure that we can exclude an entire hierarchy. -du --exclude=a a >> out || fail=1 -# Make sure that we can exclude based on more than one component. -# Before coreutils-5.3.0, this part would fail. -printf '===\n' >> out -du --exclude=a/u --exclude=a/b a \ - | sed 's/^[0-9][0-9]* //' | sort >> out || fail=1 -cat <<\EOF > exp -a -a/b -a/b/c -a/u -a/u/v -=== -a -a/u -a/u/v -a/x -a/x/y -=== -=== -a -a/x -a/x/y -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/exclude.sh b/tests/du/exclude.sh new file mode 100755 index 000000000..cad2d7f89 --- /dev/null +++ b/tests/du/exclude.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# make sure du's --exclude option works + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir -p a/b/c a/x/y a/u/v || framework_failure_ + + +du --exclude=x a | sed 's/^[0-9][0-9]* //' | sort > out || fail=1 +printf '===\n' >> out +printf 'b\n' > excl +du --exclude-from=excl a | sed 's/^[0-9][0-9]* //' | sort >> out || fail=1 +printf '===\n' >> out +# Make sure that we can exclude an entire hierarchy. +du --exclude=a a >> out || fail=1 +# Make sure that we can exclude based on more than one component. +# Before coreutils-5.3.0, this part would fail. +printf '===\n' >> out +du --exclude=a/u --exclude=a/b a \ + | sed 's/^[0-9][0-9]* //' | sort >> out || fail=1 +cat <<\EOF > exp +a +a/b +a/b/c +a/u +a/u/v +=== +a +a/u +a/u/v +a/x +a/x/y +=== +=== +a +a/x +a/x/y +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/fd-leak b/tests/du/fd-leak deleted file mode 100755 index 84a22760a..000000000 --- a/tests/du/fd-leak +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# check for file descriptor leak - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -# Call this an expensive test. It's not that expensive, but command line -# limitations might induce failure on some losing systems. -expensive_ - -# Create 1296 (36^2) files. -# Their names and separating spaces take up 3887 bytes. -x='a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9' -f= -for i in $x; do - for j in $x; do - f="$f $i$j" - done -done - -# This may fail due to command line limitations. -touch $f || framework_failure_ - - -# With coreutils-5.0, this would fail due to a file descriptor leak. -du $f > out || fail=1 - -Exit $fail diff --git a/tests/du/fd-leak.sh b/tests/du/fd-leak.sh new file mode 100755 index 000000000..84a22760a --- /dev/null +++ b/tests/du/fd-leak.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# check for file descriptor leak + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +# Call this an expensive test. It's not that expensive, but command line +# limitations might induce failure on some losing systems. +expensive_ + +# Create 1296 (36^2) files. +# Their names and separating spaces take up 3887 bytes. +x='a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9' +f= +for i in $x; do + for j in $x; do + f="$f $i$j" + done +done + +# This may fail due to command line limitations. +touch $f || framework_failure_ + + +# With coreutils-5.0, this would fail due to a file descriptor leak. +du $f > out || fail=1 + +Exit $fail diff --git a/tests/du/files0-from b/tests/du/files0-from deleted file mode 100755 index e6de79f0a..000000000 --- a/tests/du/files0-from +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/perl -# Exercise du's --files0-from option. -# FIXME: keep this file in sync with tests/misc/wc-files0-from. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -my $prog = 'du'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - # invalid extra command line argument - ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1}, - {ERR => "$prog: extra operand 'no-such'\n" - . "file operands cannot be combined with --files0-from\n" - . "Try '$prog --help' for more information.\n"} - ], - - # missing input file - ['missing', '--files0-from=missing', {EXIT=>1}, - {ERR => "$prog: cannot open 'missing' for reading: " - . "No such file or directory\n"}], - - # input file name of '-' - ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1}, - {ERR => "$prog: when reading file names from stdin, no file name of" - . " '-' allowed\n"}], - - # empty input, regular file - ['empty', '--files0-from=@AUX@', {AUX=>''}], - - # empty input, from non-regular file - ['empty-nonreg', '--files0-from=/dev/null'], - - # one NUL - ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, - {ERR => "$prog: -:1: invalid zero-length file name\n"}], - - # two NULs - ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, - {ERR => "$prog: -:1: invalid zero-length file name\n" - . "$prog: -:2: invalid zero-length file name\n"}], - - # one file name, no NUL - ['1', '--files0-from=-', '<', - {IN=>{f=>"g"}}, {AUX=>{g=>''}}, - {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], - - # one file name, with NUL - ['1a', '--files0-from=-', '<', - {IN=>{f=>"g\0"}}, {AUX=>{g=>''}}, - {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], - - # two identical file names, no final NUL - ['2', '--files0-from=-', '<', - {IN=>{f=>"g\0g"}}, {AUX=>{g=>''}}, - {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], - - # two identical file names, with final NUL - ['2a', '--files0-from=-', '<', - {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>''}}, - {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], - - # Ensure that $prog processes FILEs following a zero-length name. - ['zero-len', '--files0-from=-', '<', - {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, - {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'}, - {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/du/files0-from-dir b/tests/du/files0-from-dir deleted file mode 100755 index 86bfe269b..000000000 --- a/tests/du/files0-from-dir +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# ensure that du and wc handle --files0-from=DIR - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du wc - -mkdir dir - -# Skip this test if reading from a directory succeeds. -# In that case, using --files0-from=dir would yield garbage, -# interpreting the directory entry as a sequence of -# NUL-separated file names. -cat dir > /dev/null && skip_ "cat dir/ succeeds" - -for prog in du wc; do - $prog --files0-from=dir > /dev/null 2>err && fail=1 - printf "$prog: dir:\n" > exp || fail=1 - # The diagnostic string is usually "Is a directory" (ENOTDIR), - # but accept a different string or errno value. - sed 's/dir:.*/dir:/' err > k; mv k err - compare exp err || fail=1 -done - -Exit $fail diff --git a/tests/du/files0-from-dir.sh b/tests/du/files0-from-dir.sh new file mode 100755 index 000000000..86bfe269b --- /dev/null +++ b/tests/du/files0-from-dir.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# ensure that du and wc handle --files0-from=DIR + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du wc + +mkdir dir + +# Skip this test if reading from a directory succeeds. +# In that case, using --files0-from=dir would yield garbage, +# interpreting the directory entry as a sequence of +# NUL-separated file names. +cat dir > /dev/null && skip_ "cat dir/ succeeds" + +for prog in du wc; do + $prog --files0-from=dir > /dev/null 2>err && fail=1 + printf "$prog: dir:\n" > exp || fail=1 + # The diagnostic string is usually "Is a directory" (ENOTDIR), + # but accept a different string or errno value. + sed 's/dir:.*/dir:/' err > k; mv k err + compare exp err || fail=1 +done + +Exit $fail diff --git a/tests/du/files0-from.pl b/tests/du/files0-from.pl new file mode 100755 index 000000000..e6de79f0a --- /dev/null +++ b/tests/du/files0-from.pl @@ -0,0 +1,94 @@ +#!/usr/bin/perl +# Exercise du's --files0-from option. +# FIXME: keep this file in sync with tests/misc/wc-files0-from. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +my $prog = 'du'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + # invalid extra command line argument + ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1}, + {ERR => "$prog: extra operand 'no-such'\n" + . "file operands cannot be combined with --files0-from\n" + . "Try '$prog --help' for more information.\n"} + ], + + # missing input file + ['missing', '--files0-from=missing', {EXIT=>1}, + {ERR => "$prog: cannot open 'missing' for reading: " + . "No such file or directory\n"}], + + # input file name of '-' + ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1}, + {ERR => "$prog: when reading file names from stdin, no file name of" + . " '-' allowed\n"}], + + # empty input, regular file + ['empty', '--files0-from=@AUX@', {AUX=>''}], + + # empty input, from non-regular file + ['empty-nonreg', '--files0-from=/dev/null'], + + # one NUL + ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, + {ERR => "$prog: -:1: invalid zero-length file name\n"}], + + # two NULs + ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, + {ERR => "$prog: -:1: invalid zero-length file name\n" + . "$prog: -:2: invalid zero-length file name\n"}], + + # one file name, no NUL + ['1', '--files0-from=-', '<', + {IN=>{f=>"g"}}, {AUX=>{g=>''}}, + {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], + + # one file name, with NUL + ['1a', '--files0-from=-', '<', + {IN=>{f=>"g\0"}}, {AUX=>{g=>''}}, + {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], + + # two identical file names, no final NUL + ['2', '--files0-from=-', '<', + {IN=>{f=>"g\0g"}}, {AUX=>{g=>''}}, + {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], + + # two identical file names, with final NUL + ['2a', '--files0-from=-', '<', + {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>''}}, + {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'} ], + + # Ensure that $prog processes FILEs following a zero-length name. + ['zero-len', '--files0-from=-', '<', + {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, + {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'}, + {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/du/hard-link b/tests/du/hard-link deleted file mode 100755 index 0e0641e75..000000000 --- a/tests/du/hard-link +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -# Ensure that hard-linked files are counted (and listed) only once. -# Likewise for excluded directories. -# Ensure that hard links _are_ listed twice when using --count-links. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir -p dir/sub -( cd dir && - { echo non-empty > f1 - ln f1 f2 - ln -s f1 f3 - echo non-empty > sub/F; } ) - -du -a -L --exclude=sub --count-links dir \ - | sed 's/^[0-9][0-9]* //' | sort -r > out || fail=1 - -# For these tests, transform f1 or f2 or f3 (whichever name is find -# first) to f_. That is necessary because, depending on the type of -# file system, du could encounter any of those linked files first, -# thus listing that one and not the others. -for args in '-L' 'dir' '-L dir' -do - echo === >> out - du -a --exclude=sub $args dir \ - | sed 's/^[0-9][0-9]* //' | sed 's/f[123]/f_/' >> out || fail=1 -done - -cat <<\EOF > exp -dir/f3 -dir/f2 -dir/f1 -dir -=== -dir/f_ -dir -=== -dir/f_ -dir/f_ -dir -=== -dir/f_ -dir -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/hard-link.sh b/tests/du/hard-link.sh new file mode 100755 index 000000000..0e0641e75 --- /dev/null +++ b/tests/du/hard-link.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# Ensure that hard-linked files are counted (and listed) only once. +# Likewise for excluded directories. +# Ensure that hard links _are_ listed twice when using --count-links. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir -p dir/sub +( cd dir && + { echo non-empty > f1 + ln f1 f2 + ln -s f1 f3 + echo non-empty > sub/F; } ) + +du -a -L --exclude=sub --count-links dir \ + | sed 's/^[0-9][0-9]* //' | sort -r > out || fail=1 + +# For these tests, transform f1 or f2 or f3 (whichever name is find +# first) to f_. That is necessary because, depending on the type of +# file system, du could encounter any of those linked files first, +# thus listing that one and not the others. +for args in '-L' 'dir' '-L dir' +do + echo === >> out + du -a --exclude=sub $args dir \ + | sed 's/^[0-9][0-9]* //' | sed 's/f[123]/f_/' >> out || fail=1 +done + +cat <<\EOF > exp +dir/f3 +dir/f2 +dir/f1 +dir +=== +dir/f_ +dir +=== +dir/f_ +dir/f_ +dir +=== +dir/f_ +dir +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/inacc-dest b/tests/du/inacc-dest deleted file mode 100755 index c9c709759..000000000 --- a/tests/du/inacc-dest +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# Prior to coreutils-6.5, an inaccessible destination dir (chmod a-x) -# would cause du to exit prematurely on systems with native openat support. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du -skip_if_root_ - -mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \ - || framework_failure_ - -du > ../t 2>&1 && fail=1 - -# Accept either of the following outputs. -# You get the first from a system with openat _emulation_ (via /proc), -# the second from a system with native openat support. -# FIXME: there may well be a third output, for systems with neither -# /proc support, nor native openat support. - -sed 's/^[0-9][0-9]* //' ../t | sort -u > out -cat <<\EOF > exp || fail=1 -. -./a -./b -./c -./d -./e -du: cannot read directory './c': Permission denied -EOF - -# Map a diagnostic like this -# du: cannot access './c/j': Permission denied -# to this: -# du: cannot access './c': Permission denied -# And accept "cannot read directory" in place of "cannot access" -sed "s,/c/j': ,/c': ," out > t && mv t out -sed 's,cannot access,cannot read directory,' out > t && mv t out - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/inacc-dest.sh b/tests/du/inacc-dest.sh new file mode 100755 index 000000000..c9c709759 --- /dev/null +++ b/tests/du/inacc-dest.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Prior to coreutils-6.5, an inaccessible destination dir (chmod a-x) +# would cause du to exit prematurely on systems with native openat support. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du +skip_if_root_ + +mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \ + || framework_failure_ + +du > ../t 2>&1 && fail=1 + +# Accept either of the following outputs. +# You get the first from a system with openat _emulation_ (via /proc), +# the second from a system with native openat support. +# FIXME: there may well be a third output, for systems with neither +# /proc support, nor native openat support. + +sed 's/^[0-9][0-9]* //' ../t | sort -u > out +cat <<\EOF > exp || fail=1 +. +./a +./b +./c +./d +./e +du: cannot read directory './c': Permission denied +EOF + +# Map a diagnostic like this +# du: cannot access './c/j': Permission denied +# to this: +# du: cannot access './c': Permission denied +# And accept "cannot read directory" in place of "cannot access" +sed "s,/c/j': ,/c': ," out > t && mv t out +sed 's,cannot access,cannot read directory,' out > t && mv t out + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/inacc-dir b/tests/du/inacc-dir deleted file mode 100755 index 8395c56e8..000000000 --- a/tests/du/inacc-dir +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# Ensure that du counts the size of an inaccessible directory. -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du -skip_if_root_ - -mkdir -p a/sub || framework_failure_ - - -du -s a > exp || fail=1 -chmod 0 a/sub || fail=1 -# Expect failure, ignore diagnostics. -du -s a > out 2> /dev/null && fail=1 - -compare exp out || fail=1 - -# Same as above, but don't use -s, so we print -# an entry for the unreadable "sub", too. -chmod 700 a/sub || fail=1 -du -k a > exp || fail=1 -chmod 0 a/sub || fail=1 -# Expect failure, ignore diagnostics. -du -k a > out 2> /dev/null && fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/inacc-dir.sh b/tests/du/inacc-dir.sh new file mode 100755 index 000000000..8395c56e8 --- /dev/null +++ b/tests/du/inacc-dir.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Ensure that du counts the size of an inaccessible directory. +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du +skip_if_root_ + +mkdir -p a/sub || framework_failure_ + + +du -s a > exp || fail=1 +chmod 0 a/sub || fail=1 +# Expect failure, ignore diagnostics. +du -s a > out 2> /dev/null && fail=1 + +compare exp out || fail=1 + +# Same as above, but don't use -s, so we print +# an entry for the unreadable "sub", too. +chmod 700 a/sub || fail=1 +du -k a > exp || fail=1 +chmod 0 a/sub || fail=1 +# Expect failure, ignore diagnostics. +du -k a > out 2> /dev/null && fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/inaccessible-cwd b/tests/du/inaccessible-cwd deleted file mode 100755 index bfc8cf92e..000000000 --- a/tests/du/inaccessible-cwd +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Ensure that even when run from an inaccessible directory, du can still -# operate on accessible directories elsewhere. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Before the switch to an fts-based implementation in coreutils 5.0.92, -# this test would fail. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -# Skip this test if your system has neither the openat-style functions -# nor /proc/self/fd support with which to emulate them. -require_openat_support_ - -skip_if_root_ - -cwd=$(pwd) -mkdir -p no-x a/b || framework_failure_ -cd no-x || framework_failure_ -chmod 0 . || framework_failure_ - - -du "$cwd/a" > /dev/null || fail=1 - -Exit $fail diff --git a/tests/du/inaccessible-cwd.sh b/tests/du/inaccessible-cwd.sh new file mode 100755 index 000000000..bfc8cf92e --- /dev/null +++ b/tests/du/inaccessible-cwd.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Ensure that even when run from an inaccessible directory, du can still +# operate on accessible directories elsewhere. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Before the switch to an fts-based implementation in coreutils 5.0.92, +# this test would fail. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +# Skip this test if your system has neither the openat-style functions +# nor /proc/self/fd support with which to emulate them. +require_openat_support_ + +skip_if_root_ + +cwd=$(pwd) +mkdir -p no-x a/b || framework_failure_ +cd no-x || framework_failure_ +chmod 0 . || framework_failure_ + + +du "$cwd/a" > /dev/null || fail=1 + +Exit $fail diff --git a/tests/du/long-from-unreadable b/tests/du/long-from-unreadable deleted file mode 100755 index 7fc129c17..000000000 --- a/tests/du/long-from-unreadable +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -# Show fts fails on old-fashioned systems. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Show that fts (hence du, chmod, chgrp, chown) fails when all of the -# following are true: -# - '.' is not readable -# - operating on a hierarchy containing a relative name longer than PATH_MAX -# - run on a system where gnulib's openat emulation must resort to using -# save_cwd and restore_cwd (which fail if '.' is not readable). -# Thus, the following du invocation should succeed on newer Linux and -# Solaris systems, yet it must fail on systems lacking both openat and -# /proc support. However, before coreutils-6.0 this test would fail even -# on Linux+PROC_FS systems because its fts implementation would revert -# unnecessarily to using FTS_NOCHDIR mode in this corner case. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -proc_file=/proc/self/fd -if test ! -d $proc_file; then - skip_ 'This test would fail, since your system lacks /proc support.' -fi - -dir=$(printf '%200s\n' ' '|tr ' ' x) - -# Construct a hierarchy containing a relative file with a name -# longer than PATH_MAX. -# for i in $(seq 52); do -# mkdir $dir || framework_failure_ -# cd $dir || framework_failure_ -# done -# cd $tmp || framework_failure_ - -# Sheesh. Bash 3.1.5 can't create this hierarchy. I get -# cd: error retrieving current directory: getcwd: -# cannot access parent directories: -# (all on one line). - -cwd=$(pwd) -# Use perl instead: -: ${PERL=perl} -$PERL \ - -e 'my $d = '$dir'; foreach my $i (1..52)' \ - -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \ - || framework_failure_ - -mkdir inaccessible || framework_failure_ -cd inaccessible || framework_failure_ -chmod 0 . || framework_failure_ - -du -s "$cwd/$dir" > /dev/null || fail=1 - -Exit $fail diff --git a/tests/du/long-from-unreadable.sh b/tests/du/long-from-unreadable.sh new file mode 100755 index 000000000..7fc129c17 --- /dev/null +++ b/tests/du/long-from-unreadable.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# Show fts fails on old-fashioned systems. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Show that fts (hence du, chmod, chgrp, chown) fails when all of the +# following are true: +# - '.' is not readable +# - operating on a hierarchy containing a relative name longer than PATH_MAX +# - run on a system where gnulib's openat emulation must resort to using +# save_cwd and restore_cwd (which fail if '.' is not readable). +# Thus, the following du invocation should succeed on newer Linux and +# Solaris systems, yet it must fail on systems lacking both openat and +# /proc support. However, before coreutils-6.0 this test would fail even +# on Linux+PROC_FS systems because its fts implementation would revert +# unnecessarily to using FTS_NOCHDIR mode in this corner case. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +proc_file=/proc/self/fd +if test ! -d $proc_file; then + skip_ 'This test would fail, since your system lacks /proc support.' +fi + +dir=$(printf '%200s\n' ' '|tr ' ' x) + +# Construct a hierarchy containing a relative file with a name +# longer than PATH_MAX. +# for i in $(seq 52); do +# mkdir $dir || framework_failure_ +# cd $dir || framework_failure_ +# done +# cd $tmp || framework_failure_ + +# Sheesh. Bash 3.1.5 can't create this hierarchy. I get +# cd: error retrieving current directory: getcwd: +# cannot access parent directories: +# (all on one line). + +cwd=$(pwd) +# Use perl instead: +: ${PERL=perl} +$PERL \ + -e 'my $d = '$dir'; foreach my $i (1..52)' \ + -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \ + || framework_failure_ + +mkdir inaccessible || framework_failure_ +cd inaccessible || framework_failure_ +chmod 0 . || framework_failure_ + +du -s "$cwd/$dir" > /dev/null || fail=1 + +Exit $fail diff --git a/tests/du/long-sloop b/tests/du/long-sloop deleted file mode 100755 index 48e2e30ac..000000000 --- a/tests/du/long-sloop +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# Use du to exercise a corner of fts's FTS_LOGICAL code. -# Show that du fails with ELOOP (Too many levels of symbolic links) -# when it encounters that condition. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -# Create lots of directories, each containing a single symlink -# pointing at the next directory in the list. - -# This number should be larger than the number of symlinks allowed in -# file name resolution, but not too large as a number of entries -# in a single directory. -n=400 - -dir_list=$(seq $n) -mkdir $dir_list || framework_failure_ -file=1 -i_minus_1=0 -for i in $dir_list $(expr $n + 1); do - case $i_minus_1 in - 0) ;; - *) - ln -s ../$i $i_minus_1/s || framework_failure_ - file=$file/s;; - esac - i_minus_1=$i -done -echo foo > $i - -# If a system can handle this many symlinks in a file name, -# just skip this test. - -# The following also serves to record in 'err' the string -# corresponding to strerror (ELOOP). This is necessary because while -# Linux/libc gives 'Too many levels of symbolic links', Solaris -# renders it as "Number of symbolic links encountered during path -# name traversal exceeds MAXSYMLINKS". - -cat $file > /dev/null 2> err && - skip_ 'Your system appears to be able to handle more than $n symlinks -in file name resolution' -too_many=$(sed 's/.*: //' err) - - -# With coreutils-5.93 there was no failure. -# With coreutils-5.94 we get the desired diagnostic: -# du: cannot access '1/s/s/s/.../s': Too many levels of symbolic links -du -L 1 > /dev/null 2> out1 && fail=1 -sed "s, .1/s/s/s/[/s]*',," out1 > out || fail=1 - -echo "du: cannot access: $too_many" > exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/long-sloop.sh b/tests/du/long-sloop.sh new file mode 100755 index 000000000..48e2e30ac --- /dev/null +++ b/tests/du/long-sloop.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Use du to exercise a corner of fts's FTS_LOGICAL code. +# Show that du fails with ELOOP (Too many levels of symbolic links) +# when it encounters that condition. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +# Create lots of directories, each containing a single symlink +# pointing at the next directory in the list. + +# This number should be larger than the number of symlinks allowed in +# file name resolution, but not too large as a number of entries +# in a single directory. +n=400 + +dir_list=$(seq $n) +mkdir $dir_list || framework_failure_ +file=1 +i_minus_1=0 +for i in $dir_list $(expr $n + 1); do + case $i_minus_1 in + 0) ;; + *) + ln -s ../$i $i_minus_1/s || framework_failure_ + file=$file/s;; + esac + i_minus_1=$i +done +echo foo > $i + +# If a system can handle this many symlinks in a file name, +# just skip this test. + +# The following also serves to record in 'err' the string +# corresponding to strerror (ELOOP). This is necessary because while +# Linux/libc gives 'Too many levels of symbolic links', Solaris +# renders it as "Number of symbolic links encountered during path +# name traversal exceeds MAXSYMLINKS". + +cat $file > /dev/null 2> err && + skip_ 'Your system appears to be able to handle more than $n symlinks +in file name resolution' +too_many=$(sed 's/.*: //' err) + + +# With coreutils-5.93 there was no failure. +# With coreutils-5.94 we get the desired diagnostic: +# du: cannot access '1/s/s/s/.../s': Too many levels of symbolic links +du -L 1 > /dev/null 2> out1 && fail=1 +sed "s, .1/s/s/s/[/s]*',," out1 > out || fail=1 + +echo "du: cannot access: $too_many" > exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/max-depth b/tests/du/max-depth deleted file mode 100755 index 30671c4d8..000000000 --- a/tests/du/max-depth +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# exercise du's --max-depth=N option - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src - -mkdir -p a/b/c/d/e || framework_failure_ -printf 'a/b/c\na/b\na\n' > exp || framework_failure_ - -du --max-depth=2 a > out 2>err || fail=1 - -# Remove the sizes. They vary between file systems. -cut -f2- out > k && mv k out -compare exp out || fail=1 -compare /dev/null err || fail=1 - -# Repeat, but use -d 1. -printf 'a/b\na\n' > exp || framework_failure_ -du -d 1 a > out 2>err || fail=1 -cut -f2- out > k && mv k out -compare exp out || fail=1 -compare /dev/null err || fail=1 - -Exit $fail diff --git a/tests/du/max-depth.sh b/tests/du/max-depth.sh new file mode 100755 index 000000000..30671c4d8 --- /dev/null +++ b/tests/du/max-depth.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# exercise du's --max-depth=N option + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +mkdir -p a/b/c/d/e || framework_failure_ +printf 'a/b/c\na/b\na\n' > exp || framework_failure_ + +du --max-depth=2 a > out 2>err || fail=1 + +# Remove the sizes. They vary between file systems. +cut -f2- out > k && mv k out +compare exp out || fail=1 +compare /dev/null err || fail=1 + +# Repeat, but use -d 1. +printf 'a/b\na\n' > exp || framework_failure_ +du -d 1 a > out 2>err || fail=1 +cut -f2- out > k && mv k out +compare exp out || fail=1 +compare /dev/null err || fail=1 + +Exit $fail diff --git a/tests/du/move-dir-while-traversing b/tests/du/move-dir-while-traversing deleted file mode 100755 index 4f603a0e1..000000000 --- a/tests/du/move-dir-while-traversing +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh -# Trigger a failed assertion in coreutils-8.9 and earlier. - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -# We use a python-inotify script, so... -python -m pyinotify -h > /dev/null \ - || skip_ 'python inotify package not installed' - -# Move a directory "up" while du is processing its sub-directories. -# While du is processing a hierarchy .../B/C/D/... this script -# detects when du opens D/, and then moves C/ "up" one level -# so that it is a sibling of B/. -# Given the inherent race condition, we have to add enough "weight" -# under D/ so that in most cases, the monitor performs the single -# rename syscall before du finishes processing the subtree under D/. - -cat <<'EOF' > inotify-watch-for-dir-access.py -#!/usr/bin/env python -import pyinotify as pn -import os,sys - -dir = sys.argv[1] -dest_parent = os.path.dirname(os.path.dirname(dir)) -dest = os.path.join(dest_parent, os.path.basename(dir)) - -class ProcessDir(pn.ProcessEvent): - - def process_IN_OPEN(self, event): - os.rename(dir, dest) - sys.exit(0) - - def process_default(self, event): - pass - -wm = pn.WatchManager() -notifier = pn.Notifier(wm) -wm.watch_transient_file(dir, pn.IN_OPEN, ProcessDir) -sys.stdout.write('started\n') -sys.stdout.flush() -notifier.loop() -EOF -chmod a+x inotify-watch-for-dir-access.py - -t=T/U -mkdir d2 || framework_failure_ -long=d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z -# One iteration of this loop creates a tree with which -# du sometimes completes its traversal before the above rename. -# Five iterations was not enough in 2 of 7 "make -j20 check" runs on a -# 6/12-core system. However, using "10", I saw no failure in 20 trials. -# Using 10 iterations was not enough, either. -# Using 50, I saw no failure in 200 trials. -for i in $(seq 50); do - mkdir -p $t/3/a/b/c/$i/$long || framework_failure_ -done - -# Prohibit suspension, which could otherwise cause a timeout-induced FP failure. -trap '' TSTP - -timeout 6 ./inotify-watch-for-dir-access.py $t/3/a/b > start-msg & - -# Wait for the watcher to start... -nonempty() { test -s start-msg || { sleep $1; return 1; }; } -retry_delay_ nonempty .1 5 - -# The above watches for an IN_OPEN event on $t/3/a/b, -# and when it triggers, moves the parent, $t/3/a, up one level -# so it's directly under $t. - -du -a $t d2 2> err -# Before coreutils-8.10, du would abort. -test $? = 1 || fail=1 - -# check for the new diagnostic -printf "du: fts_read failed: $t/3/a/b: No such file or directory\n" > exp \ - || fail=1 -compare exp err || fail=1 - -Exit $fail diff --git a/tests/du/move-dir-while-traversing.sh b/tests/du/move-dir-while-traversing.sh new file mode 100755 index 000000000..4f603a0e1 --- /dev/null +++ b/tests/du/move-dir-while-traversing.sh @@ -0,0 +1,96 @@ +#!/bin/sh +# Trigger a failed assertion in coreutils-8.9 and earlier. + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +# We use a python-inotify script, so... +python -m pyinotify -h > /dev/null \ + || skip_ 'python inotify package not installed' + +# Move a directory "up" while du is processing its sub-directories. +# While du is processing a hierarchy .../B/C/D/... this script +# detects when du opens D/, and then moves C/ "up" one level +# so that it is a sibling of B/. +# Given the inherent race condition, we have to add enough "weight" +# under D/ so that in most cases, the monitor performs the single +# rename syscall before du finishes processing the subtree under D/. + +cat <<'EOF' > inotify-watch-for-dir-access.py +#!/usr/bin/env python +import pyinotify as pn +import os,sys + +dir = sys.argv[1] +dest_parent = os.path.dirname(os.path.dirname(dir)) +dest = os.path.join(dest_parent, os.path.basename(dir)) + +class ProcessDir(pn.ProcessEvent): + + def process_IN_OPEN(self, event): + os.rename(dir, dest) + sys.exit(0) + + def process_default(self, event): + pass + +wm = pn.WatchManager() +notifier = pn.Notifier(wm) +wm.watch_transient_file(dir, pn.IN_OPEN, ProcessDir) +sys.stdout.write('started\n') +sys.stdout.flush() +notifier.loop() +EOF +chmod a+x inotify-watch-for-dir-access.py + +t=T/U +mkdir d2 || framework_failure_ +long=d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z +# One iteration of this loop creates a tree with which +# du sometimes completes its traversal before the above rename. +# Five iterations was not enough in 2 of 7 "make -j20 check" runs on a +# 6/12-core system. However, using "10", I saw no failure in 20 trials. +# Using 10 iterations was not enough, either. +# Using 50, I saw no failure in 200 trials. +for i in $(seq 50); do + mkdir -p $t/3/a/b/c/$i/$long || framework_failure_ +done + +# Prohibit suspension, which could otherwise cause a timeout-induced FP failure. +trap '' TSTP + +timeout 6 ./inotify-watch-for-dir-access.py $t/3/a/b > start-msg & + +# Wait for the watcher to start... +nonempty() { test -s start-msg || { sleep $1; return 1; }; } +retry_delay_ nonempty .1 5 + +# The above watches for an IN_OPEN event on $t/3/a/b, +# and when it triggers, moves the parent, $t/3/a, up one level +# so it's directly under $t. + +du -a $t d2 2> err +# Before coreutils-8.10, du would abort. +test $? = 1 || fail=1 + +# check for the new diagnostic +printf "du: fts_read failed: $t/3/a/b: No such file or directory\n" > exp \ + || fail=1 +compare exp err || fail=1 + +Exit $fail diff --git a/tests/du/no-deref b/tests/du/no-deref deleted file mode 100755 index 2f2055123..000000000 --- a/tests/du/no-deref +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Ensure that by default, du doesn't dereference command-line symlinks. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir -p dir/a/b || framework_failure_ -ln -s dir slink || framework_failure_ - - -du slink | sed 's/^[0-9][0-9]* //' > out -cat <<\EOF > exp -slink -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/no-deref.sh b/tests/du/no-deref.sh new file mode 100755 index 000000000..2f2055123 --- /dev/null +++ b/tests/du/no-deref.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Ensure that by default, du doesn't dereference command-line symlinks. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir -p dir/a/b || framework_failure_ +ln -s dir slink || framework_failure_ + + +du slink | sed 's/^[0-9][0-9]* //' > out +cat <<\EOF > exp +slink +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/no-x b/tests/du/no-x deleted file mode 100755 index 28f797685..000000000 --- a/tests/du/no-x +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Make sure du gives the right diagnostic for a readable, -# but inaccessible directory. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du -skip_if_root_ - -mkdir -p d/no-x/y || framework_failure_ -chmod u=rw d/no-x || framework_failure_ - - -# This must exit nonzero. -du d >/dev/null 2>out && fail=1 - -prog=du -# NOTE: this code is the same for all tests/*/no-x tests. -# Depending on whether fts is using native fdopendir, we see one -# of the following diagnostics (note also the /y suffix in one case): -# prog: 'd/no-x': Permission denied -# prog: cannot access 'd/no-x/y': Permission denied -# prog: cannot read directory 'd/no-x': Permission denied -# Convert either of the latter two to the first one. -sed "s/^$prog: cannot access /$prog: /" out > t && mv t out -sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out -sed 's,d/no-x/y,d/no-x,' out > t && mv t out - -cat < exp -$prog: 'd/no-x': Permission denied -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/no-x.sh b/tests/du/no-x.sh new file mode 100755 index 000000000..28f797685 --- /dev/null +++ b/tests/du/no-x.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Make sure du gives the right diagnostic for a readable, +# but inaccessible directory. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du +skip_if_root_ + +mkdir -p d/no-x/y || framework_failure_ +chmod u=rw d/no-x || framework_failure_ + + +# This must exit nonzero. +du d >/dev/null 2>out && fail=1 + +prog=du +# NOTE: this code is the same for all tests/*/no-x tests. +# Depending on whether fts is using native fdopendir, we see one +# of the following diagnostics (note also the /y suffix in one case): +# prog: 'd/no-x': Permission denied +# prog: cannot access 'd/no-x/y': Permission denied +# prog: cannot read directory 'd/no-x': Permission denied +# Convert either of the latter two to the first one. +sed "s/^$prog: cannot access /$prog: /" out > t && mv t out +sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out +sed 's,d/no-x/y,d/no-x,' out > t && mv t out + +cat < exp +$prog: 'd/no-x': Permission denied +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/one-file-system b/tests/du/one-file-system deleted file mode 100755 index 110080f02..000000000 --- a/tests/du/one-file-system +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# Test for bugs in du's --one-file-system (-x) option. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -mkdir -p b/c y/z d "$other_partition_tmpdir/x" || framework_failure_ -ln -s "$other_partition_tmpdir/x" d || framework_failure_ - -# Due to a used-uninitialized variable, the "du -x" from coreutils-6.6 -# would not traverse into second and subsequent directories listed -# on the command line. -du -ax b y > t || fail=1 -sed 's/^[0-9][0-9]* //' t > out -cat <<\EOF > exp || fail=1 -b/c -b -y/z -y -EOF - -compare exp out || fail=1 - -# "du -xL" reported a zero count for a file in a different file system, -# instead of ignoring it. -du -xL d > u || fail=1 -sed 's/^[0-9][0-9]* //' u > out1 -echo d > exp1 || fail=1 -compare exp1 out1 || fail=1 - -# With coreutils-8.15, "du -xs FILE" would print no output. -touch f -for opt in -x -xs; do - du $opt f > u || fail=1 - sed 's/^[0-9][0-9]* //' u > out2 - echo f > exp2 || fail=1 - compare exp2 out2 || fail=1 -done - -Exit $fail diff --git a/tests/du/one-file-system.sh b/tests/du/one-file-system.sh new file mode 100755 index 000000000..110080f02 --- /dev/null +++ b/tests/du/one-file-system.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Test for bugs in du's --one-file-system (-x) option. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +mkdir -p b/c y/z d "$other_partition_tmpdir/x" || framework_failure_ +ln -s "$other_partition_tmpdir/x" d || framework_failure_ + +# Due to a used-uninitialized variable, the "du -x" from coreutils-6.6 +# would not traverse into second and subsequent directories listed +# on the command line. +du -ax b y > t || fail=1 +sed 's/^[0-9][0-9]* //' t > out +cat <<\EOF > exp || fail=1 +b/c +b +y/z +y +EOF + +compare exp out || fail=1 + +# "du -xL" reported a zero count for a file in a different file system, +# instead of ignoring it. +du -xL d > u || fail=1 +sed 's/^[0-9][0-9]* //' u > out1 +echo d > exp1 || fail=1 +compare exp1 out1 || fail=1 + +# With coreutils-8.15, "du -xs FILE" would print no output. +touch f +for opt in -x -xs; do + du $opt f > u || fail=1 + sed 's/^[0-9][0-9]* //' u > out2 + echo f > exp2 || fail=1 + compare exp2 out2 || fail=1 +done + +Exit $fail diff --git a/tests/du/restore-wd b/tests/du/restore-wd deleted file mode 100755 index 19ed5fa00..000000000 --- a/tests/du/restore-wd +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# due to a bug in glibc's ftw.c, in some cases, nftw w/FTW_CHDIR -# would not restore the working directory. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir a b || framework_failure_ - - -# With du from coreutils-4.5.5 and 4.5.6, this would fail with -# du: 'b': No such file or directory - -du a b > out || fail=1 - -Exit $fail diff --git a/tests/du/restore-wd.sh b/tests/du/restore-wd.sh new file mode 100755 index 000000000..19ed5fa00 --- /dev/null +++ b/tests/du/restore-wd.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# due to a bug in glibc's ftw.c, in some cases, nftw w/FTW_CHDIR +# would not restore the working directory. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir a b || framework_failure_ + + +# With du from coreutils-4.5.5 and 4.5.6, this would fail with +# du: 'b': No such file or directory + +du a b > out || fail=1 + +Exit $fail diff --git a/tests/du/slash b/tests/du/slash deleted file mode 100755 index 95012411a..000000000 --- a/tests/du/slash +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# 'du /' would omit the '/' on the last line. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du -require_readable_root_ - - -du --exclude='[^/]*' -x / > out-t || fail=1 -sed 's/^[0-9][0-9]* //' out-t > out -rm -f out-t -cat <<\EOF > exp -/ -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/slash.sh b/tests/du/slash.sh new file mode 100755 index 000000000..95012411a --- /dev/null +++ b/tests/du/slash.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# 'du /' would omit the '/' on the last line. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du +require_readable_root_ + + +du --exclude='[^/]*' -x / > out-t || fail=1 +sed 's/^[0-9][0-9]* //' out-t > out +rm -f out-t +cat <<\EOF > exp +/ +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/slink b/tests/du/slink deleted file mode 100755 index 674e6a224..000000000 --- a/tests/du/slink +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# Ensure that the size of a long-named-symlink is > 0. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -# Determine if '.' is on a local (would non-NFS be sufficient?) file system. -# At least on OSF/1 4.0d, when using an nfsv3 file system, -# each created symlink can end up having a size of 0. -require_local_dir_ - -if df --type=xfs . >/dev/null 2>&1; then - # At least on Irix-6.5.19, when using an xfs file system, - # each created symlink (name lengths up to 255) would have a size of '0'. - skip_ "'.' is on an XFS file system" -fi - -symlink_name_lengths='1 15 16 31 32 59 60 63 64 127 128 255 256 511 512 1024' -for len in $symlink_name_lengths; do - name=$(seq 1 $len|tr -c x y |head -c$len) - # Record the names of symlinks that are successfully created. - ln -fs $name $len > /dev/null 2>&1 \ - && symlinks="$symlinks $len" -done - -du -a $symlinks > out || fail=1 - -# Require that at least one of these symlinks has a non-zero size. -grep '^[1-9]' out > /dev/null || fail=1 - -Exit $fail diff --git a/tests/du/slink.sh b/tests/du/slink.sh new file mode 100755 index 000000000..674e6a224 --- /dev/null +++ b/tests/du/slink.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Ensure that the size of a long-named-symlink is > 0. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +# Determine if '.' is on a local (would non-NFS be sufficient?) file system. +# At least on OSF/1 4.0d, when using an nfsv3 file system, +# each created symlink can end up having a size of 0. +require_local_dir_ + +if df --type=xfs . >/dev/null 2>&1; then + # At least on Irix-6.5.19, when using an xfs file system, + # each created symlink (name lengths up to 255) would have a size of '0'. + skip_ "'.' is on an XFS file system" +fi + +symlink_name_lengths='1 15 16 31 32 59 60 63 64 127 128 255 256 511 512 1024' +for len in $symlink_name_lengths; do + name=$(seq 1 $len|tr -c x y |head -c$len) + # Record the names of symlinks that are successfully created. + ln -fs $name $len > /dev/null 2>&1 \ + && symlinks="$symlinks $len" +done + +du -a $symlinks > out || fail=1 + +# Require that at least one of these symlinks has a non-zero size. +grep '^[1-9]' out > /dev/null || fail=1 + +Exit $fail diff --git a/tests/du/trailing-slash b/tests/du/trailing-slash deleted file mode 100755 index 4efda6c73..000000000 --- a/tests/du/trailing-slash +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# Ensure that du works properly for an argument that refers to a -# symbolic link, and that is specified with a trailing slash. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Before coreutils-4.5.3, it would remove a single trailing slash. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -mkdir -p dir/1/2 || framework_failure_ -ln -s dir slink || framework_failure_ - - -du slink/ | sed 's/^[0-9][0-9]* //' > out -echo === >> out - -# Ensure that with -L we get the same results (modulo the trailing slash -# on the third line) even without the trailing slash on the command line. -du -L slink | sed 's/^[0-9][0-9]* //' >> out -cat <<\EOF > exp -slink/1/2 -slink/1 -slink/ -=== -slink/1/2 -slink/1 -slink -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/du/trailing-slash.sh b/tests/du/trailing-slash.sh new file mode 100755 index 000000000..4efda6c73 --- /dev/null +++ b/tests/du/trailing-slash.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Ensure that du works properly for an argument that refers to a +# symbolic link, and that is specified with a trailing slash. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Before coreutils-4.5.3, it would remove a single trailing slash. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +mkdir -p dir/1/2 || framework_failure_ +ln -s dir slink || framework_failure_ + + +du slink/ | sed 's/^[0-9][0-9]* //' > out +echo === >> out + +# Ensure that with -L we get the same results (modulo the trailing slash +# on the third line) even without the trailing slash on the command line. +du -L slink | sed 's/^[0-9][0-9]* //' >> out +cat <<\EOF > exp +slink/1/2 +slink/1 +slink/ +=== +slink/1/2 +slink/1 +slink +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/du/two-args b/tests/du/two-args deleted file mode 100755 index 10c0a0578..000000000 --- a/tests/du/two-args +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Make sure 'du d/1 d/2' works. -# That command failed with du from fileutils-4.0q. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ du - -# Run this test from a sub-directory one level deeper than normal, -# so that the "du .." below doesn't traverse sibling directories -# that may be inaccessible due concurrently-running tests. -mkdir sub || framework_failure_ -cd sub || framework_failure_ - -t=t -mkdir -p $t/1 $t/2 || framework_failure_ - -test -d $t || fail=1 -du $t/1 $t/2 > /dev/null || fail=1 - -# Make sure 'du . $t' and 'du .. $t' work. -# These would fail prior to fileutils-4.0y. -du . $t > /dev/null || fail=1 -du .. $t > /dev/null || fail=1 - -Exit $fail diff --git a/tests/du/two-args.sh b/tests/du/two-args.sh new file mode 100755 index 000000000..10c0a0578 --- /dev/null +++ b/tests/du/two-args.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Make sure 'du d/1 d/2' works. +# That command failed with du from fileutils-4.0q. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ du + +# Run this test from a sub-directory one level deeper than normal, +# so that the "du .." below doesn't traverse sibling directories +# that may be inaccessible due concurrently-running tests. +mkdir sub || framework_failure_ +cd sub || framework_failure_ + +t=t +mkdir -p $t/1 $t/2 || framework_failure_ + +test -d $t || fail=1 +du $t/1 $t/2 > /dev/null || fail=1 + +# Make sure 'du . $t' and 'du .. $t' work. +# These would fail prior to fileutils-4.0y. +du . $t > /dev/null || fail=1 +du .. $t > /dev/null || fail=1 + +Exit $fail diff --git a/tests/fmt/base b/tests/fmt/base deleted file mode 100755 index e94d6134e..000000000 --- a/tests/fmt/base +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/perl -# Basic tests for "fmt". - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -my @Tests = - ( - ['8-bit-pfx', qw (-p 'ç'), - {IN=> "ça\nçb\n"}, - {OUT=>"ça b\n"}], - ['wide-1', '-w 32768', - {ERR => "fmt: invalid width: '32768'\n"}, {EXIT => 1}], - ['wide-2', '-w 2147483647', - {ERR => "fmt: invalid width: '2147483647'\n"}, {EXIT => 1}], - ['bad-suffix', '-72x', {IN=> ''}, - {ERR => "fmt: invalid width: '72x'\n"}, {EXIT => 1}], - ['no-file', 'no-such-file', - {ERR => "fmt: cannot open 'no-such-file' for reading:" - . " No such file or directory\n"}, {EXIT => 1}], - ['obs-1', '-c -72', - {ERR => "fmt: invalid option -- 7; -WIDTH is recognized only when it" - . " is the first\noption; use -w N instead\n" - . "Try 'fmt --help' for more information.\n" }, {EXIT => 1}], - - # With --prefix=P, do not remove leading space on lines without the prefix. - ['pfx-1', qw (-p '>'), - {IN=> " 1\n 2\n\t3\n\t\t4\n> quoted\n> text\n"}, - {OUT=> " 1\n 2\n\t3\n\t\t4\n> quoted text\n"}], - - # Don't remove prefix from a prefix-only line. - ['pfx-only', qw (-p '>'), - {IN=> ">\n"}, - {OUT=> ">\n"}], - - # With a multi-byte prefix, say, "foo", don't empty a line that - # starts with a strict prefix (e.g. "fo") of that prefix. - # With fmt from coreutils-6.7, it would mistakenly output an empty line. - ['pfx-of-pfx', qw (-p 'foo'), - {IN=> "fo\n"}, - {OUT=> "fo\n"}], -); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; -my $prog = 'fmt'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/fmt/base.pl b/tests/fmt/base.pl new file mode 100755 index 000000000..e94d6134e --- /dev/null +++ b/tests/fmt/base.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# Basic tests for "fmt". + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +my @Tests = + ( + ['8-bit-pfx', qw (-p 'ç'), + {IN=> "ça\nçb\n"}, + {OUT=>"ça b\n"}], + ['wide-1', '-w 32768', + {ERR => "fmt: invalid width: '32768'\n"}, {EXIT => 1}], + ['wide-2', '-w 2147483647', + {ERR => "fmt: invalid width: '2147483647'\n"}, {EXIT => 1}], + ['bad-suffix', '-72x', {IN=> ''}, + {ERR => "fmt: invalid width: '72x'\n"}, {EXIT => 1}], + ['no-file', 'no-such-file', + {ERR => "fmt: cannot open 'no-such-file' for reading:" + . " No such file or directory\n"}, {EXIT => 1}], + ['obs-1', '-c -72', + {ERR => "fmt: invalid option -- 7; -WIDTH is recognized only when it" + . " is the first\noption; use -w N instead\n" + . "Try 'fmt --help' for more information.\n" }, {EXIT => 1}], + + # With --prefix=P, do not remove leading space on lines without the prefix. + ['pfx-1', qw (-p '>'), + {IN=> " 1\n 2\n\t3\n\t\t4\n> quoted\n> text\n"}, + {OUT=> " 1\n 2\n\t3\n\t\t4\n> quoted text\n"}], + + # Don't remove prefix from a prefix-only line. + ['pfx-only', qw (-p '>'), + {IN=> ">\n"}, + {OUT=> ">\n"}], + + # With a multi-byte prefix, say, "foo", don't empty a line that + # starts with a strict prefix (e.g. "fo") of that prefix. + # With fmt from coreutils-6.7, it would mistakenly output an empty line. + ['pfx-of-pfx', qw (-p 'foo'), + {IN=> "fo\n"}, + {OUT=> "fo\n"}], +); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; +my $prog = 'fmt'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/fmt/goal-option b/tests/fmt/goal-option deleted file mode 100755 index 2efb8c5ce..000000000 --- a/tests/fmt/goal-option +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# Exercise the fmt -g option. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ fmt - -cat <<\_EOF_ > base || fail=1 - -@command{fmt} prefers breaking lines at the end of a sentence, and tries to -avoid line breaks after the first word of a sentence or before the last word -of a sentence. A @dfn{sentence break} is defined as either the end of a -paragraph or a word ending in any of @samp{.?!}, followed by two spaces or end -of line, ignoring any intervening parentheses or quotes. Like @TeX{}, -@command{fmt} reads entire ''paragraphs'' before choosing line breaks; the -algorithm is a variant of that given by -Donald E. Knuth and Michael F. Plass -in ''Breaking Paragraphs Into Lines'', -@cite{Software---Practice & Experience} -@b{11}, 11 (November 1981), 1119--1184. -_EOF_ - -fmt -g 60 -w 72 base > out || fail=1 - -cat <<\_EOF_ > exp - -@command{fmt} prefers breaking lines at the end of a sentence, -and tries to avoid line breaks after the first word of a sentence -or before the last word of a sentence. A @dfn{sentence break} -is defined as either the end of a paragraph or a word ending -in any of @samp{.?!}, followed by two spaces or end of line, -ignoring any intervening parentheses or quotes. Like @TeX{}, -@command{fmt} reads entire ''paragraphs'' before choosing line -breaks; the algorithm is a variant of that given by Donald -E. Knuth and Michael F. Plass in ''Breaking Paragraphs Into -Lines'', @cite{Software---Practice & Experience} @b{11}, 11 -(November 1981), 1119--1184. -_EOF_ - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/fmt/goal-option.sh b/tests/fmt/goal-option.sh new file mode 100755 index 000000000..2efb8c5ce --- /dev/null +++ b/tests/fmt/goal-option.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Exercise the fmt -g option. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ fmt + +cat <<\_EOF_ > base || fail=1 + +@command{fmt} prefers breaking lines at the end of a sentence, and tries to +avoid line breaks after the first word of a sentence or before the last word +of a sentence. A @dfn{sentence break} is defined as either the end of a +paragraph or a word ending in any of @samp{.?!}, followed by two spaces or end +of line, ignoring any intervening parentheses or quotes. Like @TeX{}, +@command{fmt} reads entire ''paragraphs'' before choosing line breaks; the +algorithm is a variant of that given by +Donald E. Knuth and Michael F. Plass +in ''Breaking Paragraphs Into Lines'', +@cite{Software---Practice & Experience} +@b{11}, 11 (November 1981), 1119--1184. +_EOF_ + +fmt -g 60 -w 72 base > out || fail=1 + +cat <<\_EOF_ > exp + +@command{fmt} prefers breaking lines at the end of a sentence, +and tries to avoid line breaks after the first word of a sentence +or before the last word of a sentence. A @dfn{sentence break} +is defined as either the end of a paragraph or a word ending +in any of @samp{.?!}, followed by two spaces or end of line, +ignoring any intervening parentheses or quotes. Like @TeX{}, +@command{fmt} reads entire ''paragraphs'' before choosing line +breaks; the algorithm is a variant of that given by Donald +E. Knuth and Michael F. Plass in ''Breaking Paragraphs Into +Lines'', @cite{Software---Practice & Experience} @b{11}, 11 +(November 1981), 1119--1184. +_EOF_ + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/fmt/long-line b/tests/fmt/long-line deleted file mode 100755 index 04674e201..000000000 --- a/tests/fmt/long-line +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# make sure fmt -s works even on long lines - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ fmt - -printf '%2030s\n' ' '|sed 's/../ y/g' > in || framework_failure_ - -cat <<\EOF > exp || framework_failure_ - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y - y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y -EOF - - -fmt -s in > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/fmt/long-line.sh b/tests/fmt/long-line.sh new file mode 100755 index 000000000..04674e201 --- /dev/null +++ b/tests/fmt/long-line.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# make sure fmt -s works even on long lines + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ fmt + +printf '%2030s\n' ' '|sed 's/../ y/g' > in || framework_failure_ + +cat <<\EOF > exp || framework_failure_ + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y + y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y +EOF + + +fmt -s in > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/id/gnu-zero-uids b/tests/id/gnu-zero-uids deleted file mode 100755 index 6ca8dc651..000000000 --- a/tests/id/gnu-zero-uids +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# On GNU, 'id' must fail for processes with zero UIDs. - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ id - -require_gnu_ - -sush - true || skip_ "the 'sush' command does not work" - -# Run 'id' with zero UIDs. It should exit with a non-zero status. -sush - id > out && fail=1 - -Exit $fail diff --git a/tests/id/gnu-zero-uids.sh b/tests/id/gnu-zero-uids.sh new file mode 100755 index 000000000..6ca8dc651 --- /dev/null +++ b/tests/id/gnu-zero-uids.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# On GNU, 'id' must fail for processes with zero UIDs. + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ id + +require_gnu_ + +sush - true || skip_ "the 'sush' command does not work" + +# Run 'id' with zero UIDs. It should exit with a non-zero status. +sush - id > out && fail=1 + +Exit $fail diff --git a/tests/id/no-context b/tests/id/no-context deleted file mode 100755 index 94111b84e..000000000 --- a/tests/id/no-context +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# With POSIXLY_CORRECT, id must not print context=... - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ id - -# We don't need selinux *FS* support to test id, -# but this is as good a witness as any, in general. -require_selinux_ - - -# Require the context=... part by default. -id > out || fail=1 -grep context= out || fail=1 - -# Require no context=... part in conforming mode. -POSIXLY_CORRECT=1 id > out || fail=1 -grep context= out && fail=1 - -Exit $fail diff --git a/tests/id/no-context.sh b/tests/id/no-context.sh new file mode 100755 index 000000000..94111b84e --- /dev/null +++ b/tests/id/no-context.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# With POSIXLY_CORRECT, id must not print context=... + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ id + +# We don't need selinux *FS* support to test id, +# but this is as good a witness as any, in general. +require_selinux_ + + +# Require the context=... part by default. +id > out || fail=1 +grep context= out || fail=1 + +# Require no context=... part in conforming mode. +POSIXLY_CORRECT=1 id > out || fail=1 +grep context= out && fail=1 + +Exit $fail diff --git a/tests/install/basic-1 b/tests/install/basic-1 deleted file mode 100755 index aa80fcf33..000000000 --- a/tests/install/basic-1 +++ /dev/null @@ -1,115 +0,0 @@ -#! /bin/sh -# Basic tests for "install". - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ginstall -skip_if_root_ - -dir=dir -file=file - -rm -rf $dir $file || framework_failure_ -mkdir -p $dir || framework_failure_ -echo foo > $file || framework_failure_ - -ginstall $file $dir || fail=1 -# Make sure the source file still exists. -test -f $file || fail=1 -# Make sure the dest file has been created. -test -f $dir/$file || fail=1 - -# Make sure strip works. -dd=dd$EXEEXT -dd2=dd2$EXEEXT - -just_built_dd=$abs_top_builddir/src/$dd - -test -r "$just_built_dd" \ - || warn_ "WARNING!!! Your just-built dd binary, $just_built_dd -is not readable, so skipping the remaining tests in this file." - -cp "$just_built_dd" . || fail=1 -cp $dd $dd2 || fail=1 - -strip $dd2 \ - || warn_ "WARNING!!! Your strip command doesn't seem to work, -so skipping the test of install's --strip option." - -# This test would fail with 3.16s when using versions of strip that -# don't work on read-only files (the one from binutils works fine). -ginstall -s -c -m 555 $dd $dir || fail=1 -# Make sure the source file is still around. -test -f $dd || fail=1 - -# Make sure that the destination file has the requested permissions. -mode=$(ls -l $dir/$dd|cut -b-10) -test "$mode" = -r-xr-xr-x || fail=1 - -# These failed in coreutils CVS from 2004-06-25 to 2004-08-11. -ginstall -d . || fail=1 -ginstall -d newdir || fail=1 -test -d newdir || fail=1 -ginstall -d newdir1 newdir2 newdir3 || fail=1 -test -d newdir1 || fail=1 -test -d newdir2 || fail=1 -test -d newdir3 || fail=1 - -# This fails because mkdir-p.c's make_dir_parents fails to return to its -# initial working directory ($iwd) after creating the first argument, and -# hence cannot do anything meaningful with the following relative-named dirs. -iwd=$(pwd) -mkdir sub || fail=1 -(cd sub && - chmod 0 . && - ginstall -d "$iwd/xx/yy" rel/sub1 rel/sub2 2> /dev/null -) && fail=1 -chmod 755 sub - -# Ensure that the first argument-dir has been created. -test -d xx/yy || fail=1 - -# Make sure that the 'rel' directory was not created... -test -d sub/rel && fail=1 -# and make sure it was not created in the wrong place. -test -d xx/rel && fail=1 - -# Test that we can install from an unreadable directory with an -# inaccessible parent. coreutils 5.97 fails this test. -# Perform this test only if "." is on a local file system. -# Otherwise, it would fail e.g., on an NFS-mounted file system. -if is_local_dir_ .; then - mkdir -p sub1/d || fail=1 - (cd sub1/d && chmod a-r . && chmod a-rx .. && - ginstall -d "$iwd/xx/zz" rel/a rel/b) || fail=1 - chmod 755 sub1 sub1/d || fail=1 - test -d xx/zz || fail=1 - test -d sub1/d/rel/a || fail=1 - test -d sub1/d/rel/b || fail=1 -fi - -touch file || fail=1 -ginstall -Dv file sub3/a/b/c/file >out 2>&1 || fail=1 -compare - out <<\EOF || fail=1 -ginstall: creating directory 'sub3' -ginstall: creating directory 'sub3/a' -ginstall: creating directory 'sub3/a/b' -ginstall: creating directory 'sub3/a/b/c' -'file' -> 'sub3/a/b/c/file' -EOF - -Exit $fail diff --git a/tests/install/basic-1.sh b/tests/install/basic-1.sh new file mode 100755 index 000000000..aa80fcf33 --- /dev/null +++ b/tests/install/basic-1.sh @@ -0,0 +1,115 @@ +#! /bin/sh +# Basic tests for "install". + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ginstall +skip_if_root_ + +dir=dir +file=file + +rm -rf $dir $file || framework_failure_ +mkdir -p $dir || framework_failure_ +echo foo > $file || framework_failure_ + +ginstall $file $dir || fail=1 +# Make sure the source file still exists. +test -f $file || fail=1 +# Make sure the dest file has been created. +test -f $dir/$file || fail=1 + +# Make sure strip works. +dd=dd$EXEEXT +dd2=dd2$EXEEXT + +just_built_dd=$abs_top_builddir/src/$dd + +test -r "$just_built_dd" \ + || warn_ "WARNING!!! Your just-built dd binary, $just_built_dd +is not readable, so skipping the remaining tests in this file." + +cp "$just_built_dd" . || fail=1 +cp $dd $dd2 || fail=1 + +strip $dd2 \ + || warn_ "WARNING!!! Your strip command doesn't seem to work, +so skipping the test of install's --strip option." + +# This test would fail with 3.16s when using versions of strip that +# don't work on read-only files (the one from binutils works fine). +ginstall -s -c -m 555 $dd $dir || fail=1 +# Make sure the source file is still around. +test -f $dd || fail=1 + +# Make sure that the destination file has the requested permissions. +mode=$(ls -l $dir/$dd|cut -b-10) +test "$mode" = -r-xr-xr-x || fail=1 + +# These failed in coreutils CVS from 2004-06-25 to 2004-08-11. +ginstall -d . || fail=1 +ginstall -d newdir || fail=1 +test -d newdir || fail=1 +ginstall -d newdir1 newdir2 newdir3 || fail=1 +test -d newdir1 || fail=1 +test -d newdir2 || fail=1 +test -d newdir3 || fail=1 + +# This fails because mkdir-p.c's make_dir_parents fails to return to its +# initial working directory ($iwd) after creating the first argument, and +# hence cannot do anything meaningful with the following relative-named dirs. +iwd=$(pwd) +mkdir sub || fail=1 +(cd sub && + chmod 0 . && + ginstall -d "$iwd/xx/yy" rel/sub1 rel/sub2 2> /dev/null +) && fail=1 +chmod 755 sub + +# Ensure that the first argument-dir has been created. +test -d xx/yy || fail=1 + +# Make sure that the 'rel' directory was not created... +test -d sub/rel && fail=1 +# and make sure it was not created in the wrong place. +test -d xx/rel && fail=1 + +# Test that we can install from an unreadable directory with an +# inaccessible parent. coreutils 5.97 fails this test. +# Perform this test only if "." is on a local file system. +# Otherwise, it would fail e.g., on an NFS-mounted file system. +if is_local_dir_ .; then + mkdir -p sub1/d || fail=1 + (cd sub1/d && chmod a-r . && chmod a-rx .. && + ginstall -d "$iwd/xx/zz" rel/a rel/b) || fail=1 + chmod 755 sub1 sub1/d || fail=1 + test -d xx/zz || fail=1 + test -d sub1/d/rel/a || fail=1 + test -d sub1/d/rel/b || fail=1 +fi + +touch file || fail=1 +ginstall -Dv file sub3/a/b/c/file >out 2>&1 || fail=1 +compare - out <<\EOF || fail=1 +ginstall: creating directory 'sub3' +ginstall: creating directory 'sub3/a' +ginstall: creating directory 'sub3/a/b' +ginstall: creating directory 'sub3/a/b/c' +'file' -> 'sub3/a/b/c/file' +EOF + +Exit $fail diff --git a/tests/install/create-leading b/tests/install/create-leading deleted file mode 100755 index 0ecf4d958..000000000 --- a/tests/install/create-leading +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -# Test -D option. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Note that the tests below use 'ginstall', not install, because -# that's the name of the binary in ../../src. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ginstall - - -file=file -echo foo > $file - -# Before 4.0q, this would mistakenly create $file, not 'dest' -# in no-dir1/no-dir2/. -ginstall -D $file no-dir1/no-dir2/dest || fail=1 -test -d no-dir1/no-dir2 || fail=1 -test -r no-dir1/no-dir2/dest || fail=1 - -Exit $fail diff --git a/tests/install/create-leading.sh b/tests/install/create-leading.sh new file mode 100755 index 000000000..0ecf4d958 --- /dev/null +++ b/tests/install/create-leading.sh @@ -0,0 +1,35 @@ +#! /bin/sh +# Test -D option. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Note that the tests below use 'ginstall', not install, because +# that's the name of the binary in ../../src. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ginstall + + +file=file +echo foo > $file + +# Before 4.0q, this would mistakenly create $file, not 'dest' +# in no-dir1/no-dir2/. +ginstall -D $file no-dir1/no-dir2/dest || fail=1 +test -d no-dir1/no-dir2 || fail=1 +test -r no-dir1/no-dir2/dest || fail=1 + +Exit $fail diff --git a/tests/install/d-slashdot b/tests/install/d-slashdot deleted file mode 100755 index 2abdd57a8..000000000 --- a/tests/install/d-slashdot +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Ensure that ginstall -d works with arguments specified with a trailing "/.". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ install - - -ginstall -d d1/. || fail=1 -test -d d1 || fail=1 - -ginstall -d d2/.. || fail=1 -test -d d2 || fail=1 - -Exit $fail diff --git a/tests/install/d-slashdot.sh b/tests/install/d-slashdot.sh new file mode 100755 index 000000000..2abdd57a8 --- /dev/null +++ b/tests/install/d-slashdot.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Ensure that ginstall -d works with arguments specified with a trailing "/.". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ install + + +ginstall -d d1/. || fail=1 +test -d d1 || fail=1 + +ginstall -d d2/.. || fail=1 +test -d d2 || fail=1 + +Exit $fail diff --git a/tests/install/install-C b/tests/install/install-C deleted file mode 100755 index 0883d9e6b..000000000 --- a/tests/install/install-C +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -# Ensure "install -C" works. (basic tests) - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ginstall -skip_if_setgid_ - -mode1=0644 -mode2=0755 -mode3=2755 - - -echo test > a || framework_failure_ -echo "'a' -> 'b'" > out_installed_first || framework_failure_ -echo "removed 'b' -'a' -> 'b'" > out_installed_second || framework_failure_ -: > out_empty || framework_failure_ - -# destination file does not exist -ginstall -Cv -m$mode1 a b > out || fail=1 -compare out out_installed_first || fail=1 - -# destination file exists -ginstall -Cv -m$mode1 a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists (long option) -ginstall -v --compare -m$mode1 a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but -C is not given -ginstall -v -m$mode1 a b > out || fail=1 -compare out out_installed_second || fail=1 - -# option -C ignored if any non-permission mode should be set -ginstall -Cv -m$mode3 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv -m$mode3 a b > out || fail=1 -compare out out_installed_second || fail=1 - -# files are not regular files -ln -s a c || framework_failure_ -ln -s b d || framework_failure_ -ginstall -Cv -m$mode1 c d > out || fail=1 -echo "removed 'd' -'c' -> 'd'" > out_installed_second_cd -compare out out_installed_second_cd || fail=1 - -# destination file exists but content differs -echo test1 > a || framework_failure_ -ginstall -Cv -m$mode1 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv -m$mode1 a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but content differs (same size) -echo test2 > a || framework_failure_ -ginstall -Cv -m$mode1 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv -m$mode1 a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but mode differs -ginstall -Cv -m$mode2 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv -m$mode2 a b > out || fail=1 -compare out out_empty || fail=1 - -# options -C and --preserve-timestamps are mutually exclusive -ginstall -C --preserve-timestamps a b && fail=1 - -# options -C and --strip are mutually exclusive -ginstall -C --strip --strip-program=echo a b && fail=1 - -Exit $fail diff --git a/tests/install/install-C-root b/tests/install/install-C-root deleted file mode 100755 index 5fbae058a..000000000 --- a/tests/install/install-C-root +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -# Ensure "install -C" compares owner and group. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ginstall -require_root_ -skip_if_setgid_ - -u1=1 -u2=2 -g1=1 -g2=2 - - -echo test > a || framework_failure_ -echo "'a' -> 'b'" > out_installed_first -echo "removed 'b' -'a' -> 'b'" > out_installed_second -> out_empty - -# destination file does not exist -ginstall -Cv -o$u1 -g$g1 a b > out || fail=1 -compare out out_installed_first || fail=1 - -# destination file exists -ginstall -Cv -o$u1 -g$g1 a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but -C is not given -ginstall -v -o$u1 -g$g1 a b > out || fail=1 -compare out out_installed_second || fail=1 - -# destination file exists but owner differs -ginstall -Cv -o$u2 -g$g1 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv -o$u2 -g$g1 a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but group differs -ginstall -Cv -o$u2 -g$g2 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv -o$u2 -g$g2 a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but owner differs from getuid () -ginstall -Cv -o$u2 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but group differs from getgid () -ginstall -Cv -g$g2 a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv a b > out || fail=1 -compare out out_empty || fail=1 - -Exit $fail diff --git a/tests/install/install-C-root.sh b/tests/install/install-C-root.sh new file mode 100755 index 000000000..5fbae058a --- /dev/null +++ b/tests/install/install-C-root.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# Ensure "install -C" compares owner and group. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ginstall +require_root_ +skip_if_setgid_ + +u1=1 +u2=2 +g1=1 +g2=2 + + +echo test > a || framework_failure_ +echo "'a' -> 'b'" > out_installed_first +echo "removed 'b' +'a' -> 'b'" > out_installed_second +> out_empty + +# destination file does not exist +ginstall -Cv -o$u1 -g$g1 a b > out || fail=1 +compare out out_installed_first || fail=1 + +# destination file exists +ginstall -Cv -o$u1 -g$g1 a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but -C is not given +ginstall -v -o$u1 -g$g1 a b > out || fail=1 +compare out out_installed_second || fail=1 + +# destination file exists but owner differs +ginstall -Cv -o$u2 -g$g1 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv -o$u2 -g$g1 a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but group differs +ginstall -Cv -o$u2 -g$g2 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv -o$u2 -g$g2 a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but owner differs from getuid () +ginstall -Cv -o$u2 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but group differs from getgid () +ginstall -Cv -g$g2 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv a b > out || fail=1 +compare out out_empty || fail=1 + +Exit $fail diff --git a/tests/install/install-C-selinux b/tests/install/install-C-selinux deleted file mode 100755 index db2a5d227..000000000 --- a/tests/install/install-C-selinux +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Ensure "install -C" compares SELinux context. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ginstall -require_selinux_ - - -echo test > a || framework_failure_ -chcon -u system_u a || skip_ "chcon doesn't work" - -echo "'a' -> 'b'" > out_installed_first -echo "removed 'b' -'a' -> 'b'" > out_installed_second -> out_empty - -# destination file does not exist -ginstall -Cv --preserve-context a b > out || fail=1 -compare out out_installed_first || fail=1 - -# destination file exists -ginstall -Cv --preserve-context a b > out || fail=1 -compare out out_empty || fail=1 - -# destination file exists but -C is not given -ginstall -v --preserve-context a b > out || fail=1 -compare out out_installed_second || fail=1 - -# destination file exists but SELinux context differs -chcon -u unconfined_u a || skip_ "chcon doesn't work" -ginstall -Cv --preserve-context a b > out || fail=1 -compare out out_installed_second || fail=1 -ginstall -Cv --preserve-context a b > out || fail=1 -compare out out_empty || fail=1 - -Exit $fail diff --git a/tests/install/install-C-selinux.sh b/tests/install/install-C-selinux.sh new file mode 100755 index 000000000..db2a5d227 --- /dev/null +++ b/tests/install/install-C-selinux.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Ensure "install -C" compares SELinux context. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ginstall +require_selinux_ + + +echo test > a || framework_failure_ +chcon -u system_u a || skip_ "chcon doesn't work" + +echo "'a' -> 'b'" > out_installed_first +echo "removed 'b' +'a' -> 'b'" > out_installed_second +> out_empty + +# destination file does not exist +ginstall -Cv --preserve-context a b > out || fail=1 +compare out out_installed_first || fail=1 + +# destination file exists +ginstall -Cv --preserve-context a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but -C is not given +ginstall -v --preserve-context a b > out || fail=1 +compare out out_installed_second || fail=1 + +# destination file exists but SELinux context differs +chcon -u unconfined_u a || skip_ "chcon doesn't work" +ginstall -Cv --preserve-context a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv --preserve-context a b > out || fail=1 +compare out out_empty || fail=1 + +Exit $fail diff --git a/tests/install/install-C.sh b/tests/install/install-C.sh new file mode 100755 index 000000000..0883d9e6b --- /dev/null +++ b/tests/install/install-C.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# Ensure "install -C" works. (basic tests) + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ginstall +skip_if_setgid_ + +mode1=0644 +mode2=0755 +mode3=2755 + + +echo test > a || framework_failure_ +echo "'a' -> 'b'" > out_installed_first || framework_failure_ +echo "removed 'b' +'a' -> 'b'" > out_installed_second || framework_failure_ +: > out_empty || framework_failure_ + +# destination file does not exist +ginstall -Cv -m$mode1 a b > out || fail=1 +compare out out_installed_first || fail=1 + +# destination file exists +ginstall -Cv -m$mode1 a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists (long option) +ginstall -v --compare -m$mode1 a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but -C is not given +ginstall -v -m$mode1 a b > out || fail=1 +compare out out_installed_second || fail=1 + +# option -C ignored if any non-permission mode should be set +ginstall -Cv -m$mode3 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv -m$mode3 a b > out || fail=1 +compare out out_installed_second || fail=1 + +# files are not regular files +ln -s a c || framework_failure_ +ln -s b d || framework_failure_ +ginstall -Cv -m$mode1 c d > out || fail=1 +echo "removed 'd' +'c' -> 'd'" > out_installed_second_cd +compare out out_installed_second_cd || fail=1 + +# destination file exists but content differs +echo test1 > a || framework_failure_ +ginstall -Cv -m$mode1 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv -m$mode1 a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but content differs (same size) +echo test2 > a || framework_failure_ +ginstall -Cv -m$mode1 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv -m$mode1 a b > out || fail=1 +compare out out_empty || fail=1 + +# destination file exists but mode differs +ginstall -Cv -m$mode2 a b > out || fail=1 +compare out out_installed_second || fail=1 +ginstall -Cv -m$mode2 a b > out || fail=1 +compare out out_empty || fail=1 + +# options -C and --preserve-timestamps are mutually exclusive +ginstall -C --preserve-timestamps a b && fail=1 + +# options -C and --strip are mutually exclusive +ginstall -C --strip --strip-program=echo a b && fail=1 + +Exit $fail diff --git a/tests/install/strip-program b/tests/install/strip-program deleted file mode 100755 index 591614118..000000000 --- a/tests/install/strip-program +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Ensure "install -s --strip-program=PROGRAM" uses the program to strip - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ginstall - -working_umask_or_skip_ - -cat < b || framework_failure_ -#!$PREFERABLY_POSIX_SHELL -sed s/b/B/ \$1 > \$1.t && mv \$1.t \$1 -EOF -chmod a+x b || framework_failure_ - - -echo abc > src || fail=1 -echo aBc > exp || fail=1 -ginstall src dest -s --strip-program=./b || fail=1 -compare exp dest || fail=1 - -Exit $fail diff --git a/tests/install/strip-program.sh b/tests/install/strip-program.sh new file mode 100755 index 000000000..591614118 --- /dev/null +++ b/tests/install/strip-program.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Ensure "install -s --strip-program=PROGRAM" uses the program to strip + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ginstall + +working_umask_or_skip_ + +cat < b || framework_failure_ +#!$PREFERABLY_POSIX_SHELL +sed s/b/B/ \$1 > \$1.t && mv \$1.t \$1 +EOF +chmod a+x b || framework_failure_ + + +echo abc > src || fail=1 +echo aBc > exp || fail=1 +ginstall src dest -s --strip-program=./b || fail=1 +compare exp dest || fail=1 + +Exit $fail diff --git a/tests/install/trap b/tests/install/trap deleted file mode 100755 index e3ccf54ac..000000000 --- a/tests/install/trap +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Ensure that 'install -s' doesn't infloop when its parent -# process traps CHLD signal. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ginstall - - -# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. -( - # ash doesn't support "trap '' CHLD"; it knows only signal numbers. - sig=$("$abs_top_builddir/src/kill" -l CHLD 2>/dev/null) && trap '' $sig - - # Before 2004-04-21, install would infloop, in the 'while (wait...' loop: - exec ginstall -s "$abs_top_builddir/src/ginstall$EXEEXT" . -) - -Exit $fail diff --git a/tests/install/trap.sh b/tests/install/trap.sh new file mode 100755 index 000000000..e3ccf54ac --- /dev/null +++ b/tests/install/trap.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Ensure that 'install -s' doesn't infloop when its parent +# process traps CHLD signal. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ginstall + + +# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. +( + # ash doesn't support "trap '' CHLD"; it knows only signal numbers. + sig=$("$abs_top_builddir/src/kill" -l CHLD 2>/dev/null) && trap '' $sig + + # Before 2004-04-21, install would infloop, in the 'while (wait...' loop: + exec ginstall -s "$abs_top_builddir/src/ginstall$EXEEXT" . +) + +Exit $fail diff --git a/tests/ln/backup-1 b/tests/ln/backup-1 deleted file mode 100755 index ffd630bcf..000000000 --- a/tests/ln/backup-1 +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Try to create a symlink with backup where the destination file exists -# and the backup file name is a hard link to the destination file. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Based on a problem report from Jamie Lokier. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - -touch a b || framework_failure_ - -ln b b~ || fail=1 -ln -f --b=simple a b || fail=1 - -Exit $fail diff --git a/tests/ln/backup-1.sh b/tests/ln/backup-1.sh new file mode 100755 index 000000000..ffd630bcf --- /dev/null +++ b/tests/ln/backup-1.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Try to create a symlink with backup where the destination file exists +# and the backup file name is a hard link to the destination file. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Based on a problem report from Jamie Lokier. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + +touch a b || framework_failure_ + +ln b b~ || fail=1 +ln -f --b=simple a b || fail=1 + +Exit $fail diff --git a/tests/ln/hard-backup b/tests/ln/hard-backup deleted file mode 100755 index bc38bbe5d..000000000 --- a/tests/ln/hard-backup +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Ensure that 'ln --backup F F' gives a proper diagnostic. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - -touch f || framework_failure_ - - -ln --backup f f 2> out && fail=1 -cat <<\EOF > exp || fail=1 -ln: 'f' and 'f' are the same file -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ln/hard-backup.sh b/tests/ln/hard-backup.sh new file mode 100755 index 000000000..bc38bbe5d --- /dev/null +++ b/tests/ln/hard-backup.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Ensure that 'ln --backup F F' gives a proper diagnostic. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + +touch f || framework_failure_ + + +ln --backup f f 2> out && fail=1 +cat <<\EOF > exp || fail=1 +ln: 'f' and 'f' are the same file +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ln/hard-to-sym b/tests/ln/hard-to-sym deleted file mode 100755 index 358b93008..000000000 --- a/tests/ln/hard-to-sym +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# Tests for ln -L/-P. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - - -# =================================================== -# ensure -s silently overrides -L, -P -touch a || framework_failure_ -ln -L -s a symlink1 || fail=1 -ln -P -s symlink1 symlink2 || fail=1 -ln -s -L -P symlink2 symlink3 || fail=1 - -# =================================================== -# ensure that -L follows symlinks, and overrides -P -ln -P -L symlink3 hard-to-a || fail=1 -ls=$(ls -lG hard-to-a)x -case "$ls" in - *'hard-to-ax') ;; - *'hard-to-a -> '*x) fail=1 ;; - *) framework_failure_ ;; -esac - -# =================================================== -# ensure that -P links (or at least duplicates) symlinks, and overrides -L -ln -L -P symlink3 hard-to-3 || fail=1 -ls=$(ls -lG hard-to-3)x -case "$ls" in - *'hard-to-3 -> symlink2x') ;; - *'hard-to-3x') fail=1 ;; - *'hard-to-3 -> '*x) fail=1 ;; - *) framework_failure_ ;; -esac - -# =================================================== -# Create a hard link to a dangling symlink. -ln -s /no-such-dir || framework_failure_ -ln -L no-such-dir hard-to-dangle 2>err && fail=1 -case $(cat err) in - *" accessing 'no-such-dir'":*) ;; - *) fail=1 ;; -esac -ln -P no-such-dir hard-to-dangle || fail=1 - -# =================================================== -# Create a hard link to a symlink to a directory. -mkdir d || framework_failure_ -ln -s d link-to-dir || framework_failure_ -ln -L link-to-dir hard-to-dir-link 2>err && fail=1 -case $(cat err) in - *": 'link-to-dir': hard link not allowed for directory"*) ;; - *) fail=1 ;; -esac -ln -P link-to-dir/ hard-to-dir-link 2>err && fail=1 -case $(cat err) in - *": 'link-to-dir/': hard link not allowed for directory"*) ;; - *) fail=1 ;; -esac -ln -P link-to-dir hard-to-dir-link || fail=1 - -Exit $fail diff --git a/tests/ln/hard-to-sym.sh b/tests/ln/hard-to-sym.sh new file mode 100755 index 000000000..358b93008 --- /dev/null +++ b/tests/ln/hard-to-sym.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# Tests for ln -L/-P. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + + +# =================================================== +# ensure -s silently overrides -L, -P +touch a || framework_failure_ +ln -L -s a symlink1 || fail=1 +ln -P -s symlink1 symlink2 || fail=1 +ln -s -L -P symlink2 symlink3 || fail=1 + +# =================================================== +# ensure that -L follows symlinks, and overrides -P +ln -P -L symlink3 hard-to-a || fail=1 +ls=$(ls -lG hard-to-a)x +case "$ls" in + *'hard-to-ax') ;; + *'hard-to-a -> '*x) fail=1 ;; + *) framework_failure_ ;; +esac + +# =================================================== +# ensure that -P links (or at least duplicates) symlinks, and overrides -L +ln -L -P symlink3 hard-to-3 || fail=1 +ls=$(ls -lG hard-to-3)x +case "$ls" in + *'hard-to-3 -> symlink2x') ;; + *'hard-to-3x') fail=1 ;; + *'hard-to-3 -> '*x) fail=1 ;; + *) framework_failure_ ;; +esac + +# =================================================== +# Create a hard link to a dangling symlink. +ln -s /no-such-dir || framework_failure_ +ln -L no-such-dir hard-to-dangle 2>err && fail=1 +case $(cat err) in + *" accessing 'no-such-dir'":*) ;; + *) fail=1 ;; +esac +ln -P no-such-dir hard-to-dangle || fail=1 + +# =================================================== +# Create a hard link to a symlink to a directory. +mkdir d || framework_failure_ +ln -s d link-to-dir || framework_failure_ +ln -L link-to-dir hard-to-dir-link 2>err && fail=1 +case $(cat err) in + *": 'link-to-dir': hard link not allowed for directory"*) ;; + *) fail=1 ;; +esac +ln -P link-to-dir/ hard-to-dir-link 2>err && fail=1 +case $(cat err) in + *": 'link-to-dir/': hard link not allowed for directory"*) ;; + *) fail=1 ;; +esac +ln -P link-to-dir hard-to-dir-link || fail=1 + +Exit $fail diff --git a/tests/ln/misc b/tests/ln/misc deleted file mode 100755 index 4da0eda45..000000000 --- a/tests/ln/misc +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh -# Miscellaneous tests for "ln". - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - -t=tln-symlink -d=tln-subdir -ld=tln-symlink-to-subdir -f=tln-file - -# Create a simple symlink with both source and destination files -# in current directory. -touch $f || framework_failure_ -rm -f $t || framework_failure_ -ln -s $f $t || fail=1 -test -f $t || fail=1 -rm $t $f - -# Create a symlink with source file and explicit destination directory/file. -touch $f || framework_failure_ -rm -rf $d || framework_failure_ -mkdir $d || framework_failure_ -ln -s ../$f $d/$t || fail=1 -test -f $d/$t || fail=1 -rm -rf $d $f - -# Create a symlink with source file and destination directory. -touch $f || framework_failure_ -rm -rf $d || framework_failure_ -mkdir $d || framework_failure_ -ln -s ../$f $d || fail=1 -test -f $d/$f || fail=1 -rm -rf $d $f - -# See whether a trailing slash is followed too far. -touch $f || framework_failure_ -rm -rf $d || framework_failure_ -mkdir $d $d/$f || framework_failure_ -ln $f $d/ 2> /dev/null && fail=1 -ln -s $f $d/ 2> /dev/null && fail=1 -rm -rf $d $f - -# Make sure we get a failure with existing dest without -f option -touch $t || framework_failure_ -# FIXME: don't ignore the error message but rather test -# it to make sure it's the right one. -ln -s $t $t 2> /dev/null && fail=1 -rm $t - -# Make sure -sf fails when src and dest are the same -touch $t || framework_failure_ -ln -sf $t $t 2> /dev/null && fail=1 -rm $t - -# Create a symlink with source file and no explicit directory -rm -rf $d || framework_failure_ -mkdir $d || framework_failure_ -touch $d/$f || framework_failure_ -ln -s $d/$f || fail=1 -test -f $f || fail=1 -rm -rf $d $f - -# Create a symlink with source file and destination symlink-to-directory. -rm -rf $d $f $ld || framework_failure_ -touch $f || framework_failure_ -mkdir $d || framework_failure_ -ln -s $d $ld -ln -s ../$f $ld || fail=1 -test -f $d/$f || fail=1 -rm -rf $d $f $ld - -# Create a symlink with source file and destination symlink-to-directory. -# BUT use the new --no-dereference option. -rm -rf $d $f $ld || framework_failure_ -touch $f || framework_failure_ -mkdir $d || framework_failure_ -ln -s $d $ld -af=$(pwd)/$f -ln --no-dereference -fs "$af" $ld || fail=1 -test -f $ld || fail=1 -rm -rf $d $f $ld - -# Try to create a symlink with backup where the destination file exists -# and the backup file name is a hard link to the destination file. -touch a b || framework_failure_ -ln b b~ || framework_failure_ -ln -f --b=simple a b || fail=1 - -# =================================================== - -# Make sure ln can make simple backups. -# This was fixed in 4.0.34. Broken in 4.0r. -for cmd in ln cp mv ginstall; do - rm -rf a x a.orig - touch a x || framework_failure_ - $cmd --backup=simple --suffix=.orig x a || fail=1 - test -f a.orig || fail=1 -done - -# =================================================== -# With coreutils-5.2.1, this would mistakenly access argv[1][-1]. -# I'm including it here, in case some day programs like valgrind detect that. -# Purify probably would have done so. -ln foo '' 2> /dev/null - -# =================================================== - -Exit $fail diff --git a/tests/ln/misc.sh b/tests/ln/misc.sh new file mode 100755 index 000000000..4da0eda45 --- /dev/null +++ b/tests/ln/misc.sh @@ -0,0 +1,124 @@ +#!/bin/sh +# Miscellaneous tests for "ln". + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + +t=tln-symlink +d=tln-subdir +ld=tln-symlink-to-subdir +f=tln-file + +# Create a simple symlink with both source and destination files +# in current directory. +touch $f || framework_failure_ +rm -f $t || framework_failure_ +ln -s $f $t || fail=1 +test -f $t || fail=1 +rm $t $f + +# Create a symlink with source file and explicit destination directory/file. +touch $f || framework_failure_ +rm -rf $d || framework_failure_ +mkdir $d || framework_failure_ +ln -s ../$f $d/$t || fail=1 +test -f $d/$t || fail=1 +rm -rf $d $f + +# Create a symlink with source file and destination directory. +touch $f || framework_failure_ +rm -rf $d || framework_failure_ +mkdir $d || framework_failure_ +ln -s ../$f $d || fail=1 +test -f $d/$f || fail=1 +rm -rf $d $f + +# See whether a trailing slash is followed too far. +touch $f || framework_failure_ +rm -rf $d || framework_failure_ +mkdir $d $d/$f || framework_failure_ +ln $f $d/ 2> /dev/null && fail=1 +ln -s $f $d/ 2> /dev/null && fail=1 +rm -rf $d $f + +# Make sure we get a failure with existing dest without -f option +touch $t || framework_failure_ +# FIXME: don't ignore the error message but rather test +# it to make sure it's the right one. +ln -s $t $t 2> /dev/null && fail=1 +rm $t + +# Make sure -sf fails when src and dest are the same +touch $t || framework_failure_ +ln -sf $t $t 2> /dev/null && fail=1 +rm $t + +# Create a symlink with source file and no explicit directory +rm -rf $d || framework_failure_ +mkdir $d || framework_failure_ +touch $d/$f || framework_failure_ +ln -s $d/$f || fail=1 +test -f $f || fail=1 +rm -rf $d $f + +# Create a symlink with source file and destination symlink-to-directory. +rm -rf $d $f $ld || framework_failure_ +touch $f || framework_failure_ +mkdir $d || framework_failure_ +ln -s $d $ld +ln -s ../$f $ld || fail=1 +test -f $d/$f || fail=1 +rm -rf $d $f $ld + +# Create a symlink with source file and destination symlink-to-directory. +# BUT use the new --no-dereference option. +rm -rf $d $f $ld || framework_failure_ +touch $f || framework_failure_ +mkdir $d || framework_failure_ +ln -s $d $ld +af=$(pwd)/$f +ln --no-dereference -fs "$af" $ld || fail=1 +test -f $ld || fail=1 +rm -rf $d $f $ld + +# Try to create a symlink with backup where the destination file exists +# and the backup file name is a hard link to the destination file. +touch a b || framework_failure_ +ln b b~ || framework_failure_ +ln -f --b=simple a b || fail=1 + +# =================================================== + +# Make sure ln can make simple backups. +# This was fixed in 4.0.34. Broken in 4.0r. +for cmd in ln cp mv ginstall; do + rm -rf a x a.orig + touch a x || framework_failure_ + $cmd --backup=simple --suffix=.orig x a || fail=1 + test -f a.orig || fail=1 +done + +# =================================================== +# With coreutils-5.2.1, this would mistakenly access argv[1][-1]. +# I'm including it here, in case some day programs like valgrind detect that. +# Purify probably would have done so. +ln foo '' 2> /dev/null + +# =================================================== + +Exit $fail diff --git a/tests/ln/relative b/tests/ln/relative deleted file mode 100755 index cfc34691e..000000000 --- a/tests/ln/relative +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Test "ln --relative". - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - -mkdir -p usr/bin || framework_failure_ -mkdir -p usr/lib/foo || framework_failure_ -touch usr/lib/foo/foo || framework_failure_ - -ln -sr usr/lib/foo/foo usr/bin/foo -test $(readlink usr/bin/foo) = '../lib/foo/foo' || fail=1 - -ln -sr usr/bin/foo usr/lib/foo/link-to-foo -test $(readlink usr/lib/foo/link-to-foo) = 'foo' || fail=1 - -Exit $fail diff --git a/tests/ln/relative.sh b/tests/ln/relative.sh new file mode 100755 index 000000000..cfc34691e --- /dev/null +++ b/tests/ln/relative.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Test "ln --relative". + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + +mkdir -p usr/bin || framework_failure_ +mkdir -p usr/lib/foo || framework_failure_ +touch usr/lib/foo/foo || framework_failure_ + +ln -sr usr/lib/foo/foo usr/bin/foo +test $(readlink usr/bin/foo) = '../lib/foo/foo' || fail=1 + +ln -sr usr/bin/foo usr/lib/foo/link-to-foo +test $(readlink usr/lib/foo/link-to-foo) = 'foo' || fail=1 + +Exit $fail diff --git a/tests/ln/sf-1 b/tests/ln/sf-1 deleted file mode 100755 index 824c22432..000000000 --- a/tests/ln/sf-1 +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Test "ln -sf". - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - -echo foo > a || framework_failure_ -ln -s . b || framework_failure_ - -ln -sf a b > err 2>&1 && fail=1 -case $(cat err) in - *'are the same file') ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/ln/sf-1.sh b/tests/ln/sf-1.sh new file mode 100755 index 000000000..824c22432 --- /dev/null +++ b/tests/ln/sf-1.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Test "ln -sf". + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + +echo foo > a || framework_failure_ +ln -s . b || framework_failure_ + +ln -sf a b > err 2>&1 && fail=1 +case $(cat err) in + *'are the same file') ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/ln/slash-decorated-nonexistent-dest b/tests/ln/slash-decorated-nonexistent-dest deleted file mode 100755 index 5da855e6c..000000000 --- a/tests/ln/slash-decorated-nonexistent-dest +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# ensure that touch f; ln -T f no-such-file/ does not mistakenly succeed - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - -touch f || framework_failure_ - - -# Before coreutils-7.6, this would succeed on Solaris 10 -ln -T f no-such-file/ && fail=1 -test -e no-such-file && fail=1 - -Exit $fail diff --git a/tests/ln/slash-decorated-nonexistent-dest.sh b/tests/ln/slash-decorated-nonexistent-dest.sh new file mode 100755 index 000000000..5da855e6c --- /dev/null +++ b/tests/ln/slash-decorated-nonexistent-dest.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# ensure that touch f; ln -T f no-such-file/ does not mistakenly succeed + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + +touch f || framework_failure_ + + +# Before coreutils-7.6, this would succeed on Solaris 10 +ln -T f no-such-file/ && fail=1 +test -e no-such-file && fail=1 + +Exit $fail diff --git a/tests/ln/target-1 b/tests/ln/target-1 deleted file mode 100755 index 1d511e5e7..000000000 --- a/tests/ln/target-1 +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Test "ln --target-dir" with one file. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Before coreutils-4.5.3, --target-dir didn't work with one file. -# It would create the desired link, but would fail with a diagnosis like this: -# ln: 'd/.': cannot overwrite directory -# Based on a test case from Dmitry V. Levin. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ln - -mkdir d || framework_failure_ -ln -s --target-dir=d ../f || fail=1 - -Exit $fail diff --git a/tests/ln/target-1.sh b/tests/ln/target-1.sh new file mode 100755 index 000000000..1d511e5e7 --- /dev/null +++ b/tests/ln/target-1.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Test "ln --target-dir" with one file. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Before coreutils-4.5.3, --target-dir didn't work with one file. +# It would create the desired link, but would fail with a diagnosis like this: +# ln: 'd/.': cannot overwrite directory +# Based on a test case from Dmitry V. Levin. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ln + +mkdir d || framework_failure_ +ln -s --target-dir=d ../f || fail=1 + +Exit $fail diff --git a/tests/ls/abmon-align b/tests/ls/abmon-align deleted file mode 100755 index 4285d0759..000000000 --- a/tests/ls/abmon-align +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Ensure ls output is aligned when using abbreviated months from the locale - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -for mon in $(seq -w 12); do - touch -d"+$mon month" $mon.ts || framework_failure_ -done - - -# Note some of the following locales may be missing but if so -# we should fail back to the C locale which should be aligned - -for format in "%b" "[%b" "%b]" "[%b]"; do - for LOC in C gv_GB ga_IE fi_FI.utf8 zh_CN ar_SY $LOCALE_FR_UTF8; do - # The sed usage here is slightly different from the original, - # removing the \(.*\), to avoid triggering misbehavior in at least - # GNU sed 4.2 (possibly miscompiled) on Mac OS X (Darwin 9.8.0). - n_widths=$( - LC_ALL=$LOC TIME_STYLE=+"$format" ls -lgG *.ts | - LC_ALL=C sed 's/.\{15\}//;s/ ..\.ts$//;s/ /./g' | - while read mon; do echo "$mon" | LC_ALL=$LOC wc -L; done | - uniq | wc -l - ) - test "$n_widths" = "1" || { fail=1; break 2; } - done -done -if test "$fail" = "1"; then - echo "misalignment detected in $LOC locale:" - LC_ALL=$LOC TIME_STYLE=+%b ls -lgG *.ts -fi - -Exit $fail diff --git a/tests/ls/abmon-align.sh b/tests/ls/abmon-align.sh new file mode 100755 index 000000000..4285d0759 --- /dev/null +++ b/tests/ls/abmon-align.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Ensure ls output is aligned when using abbreviated months from the locale + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +for mon in $(seq -w 12); do + touch -d"+$mon month" $mon.ts || framework_failure_ +done + + +# Note some of the following locales may be missing but if so +# we should fail back to the C locale which should be aligned + +for format in "%b" "[%b" "%b]" "[%b]"; do + for LOC in C gv_GB ga_IE fi_FI.utf8 zh_CN ar_SY $LOCALE_FR_UTF8; do + # The sed usage here is slightly different from the original, + # removing the \(.*\), to avoid triggering misbehavior in at least + # GNU sed 4.2 (possibly miscompiled) on Mac OS X (Darwin 9.8.0). + n_widths=$( + LC_ALL=$LOC TIME_STYLE=+"$format" ls -lgG *.ts | + LC_ALL=C sed 's/.\{15\}//;s/ ..\.ts$//;s/ /./g' | + while read mon; do echo "$mon" | LC_ALL=$LOC wc -L; done | + uniq | wc -l + ) + test "$n_widths" = "1" || { fail=1; break 2; } + done +done +if test "$fail" = "1"; then + echo "misalignment detected in $LOC locale:" + LC_ALL=$LOC TIME_STYLE=+%b ls -lgG *.ts +fi + +Exit $fail diff --git a/tests/ls/block-size b/tests/ls/block-size deleted file mode 100755 index 99750201a..000000000 --- a/tests/ls/block-size +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/sh -# Exercise ls --block-size and related options. - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -TZ=UTC0 -export TZ - -mkdir sub -cd sub - -for size in 1024 4096 262144; do - echo foo | dd conv=sync bs=$size >file$size || fail=1 -done -touch -d '2001-01-01 00:00' file* || fail=1 - -size_etc='s/[^ ]* *[^ ]* *[^ ]* *[^ ]* *//' - -ls -l * | sed "$size_etc" >../out || fail=1 -POSIXLY_CORRECT=1 ls -l * | sed "$size_etc" >>../out || fail=1 -POSIXLY_CORRECT=1 ls -k -l * | sed "$size_etc" >>../out || fail=1 - -for var in BLOCKSIZE BLOCK_SIZE LS_BLOCK_SIZE; do - for blocksize in 1 512 1K 1KiB; do - (eval $var=$blocksize && export $var && - ls -l * && - ls -l -k * && - ls -l -k --block-size=$blocksize * - ) | sed "$size_etc" >>../out || fail=1 - done -done - -cd .. - -cat >exp <<'EOF' -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -2 Jan 1 2001 file1024 -512 Jan 1 2001 file262144 -8 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -2 Jan 1 2001 file1024 -512 Jan 1 2001 file262144 -8 Jan 1 2001 file4096 -2 Jan 1 2001 file1024 -512 Jan 1 2001 file262144 -8 Jan 1 2001 file4096 -2 Jan 1 2001 file1024 -512 Jan 1 2001 file262144 -8 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -1024 Jan 1 2001 file1024 -262144 Jan 1 2001 file262144 -4096 Jan 1 2001 file4096 -2 Jan 1 2001 file1024 -512 Jan 1 2001 file262144 -8 Jan 1 2001 file4096 -2 Jan 1 2001 file1024 -512 Jan 1 2001 file262144 -8 Jan 1 2001 file4096 -2 Jan 1 2001 file1024 -512 Jan 1 2001 file262144 -8 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -1 Jan 1 2001 file1024 -256 Jan 1 2001 file262144 -4 Jan 1 2001 file4096 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/block-size.sh b/tests/ls/block-size.sh new file mode 100755 index 000000000..99750201a --- /dev/null +++ b/tests/ls/block-size.sh @@ -0,0 +1,173 @@ +#!/bin/sh +# Exercise ls --block-size and related options. + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +TZ=UTC0 +export TZ + +mkdir sub +cd sub + +for size in 1024 4096 262144; do + echo foo | dd conv=sync bs=$size >file$size || fail=1 +done +touch -d '2001-01-01 00:00' file* || fail=1 + +size_etc='s/[^ ]* *[^ ]* *[^ ]* *[^ ]* *//' + +ls -l * | sed "$size_etc" >../out || fail=1 +POSIXLY_CORRECT=1 ls -l * | sed "$size_etc" >>../out || fail=1 +POSIXLY_CORRECT=1 ls -k -l * | sed "$size_etc" >>../out || fail=1 + +for var in BLOCKSIZE BLOCK_SIZE LS_BLOCK_SIZE; do + for blocksize in 1 512 1K 1KiB; do + (eval $var=$blocksize && export $var && + ls -l * && + ls -l -k * && + ls -l -k --block-size=$blocksize * + ) | sed "$size_etc" >>../out || fail=1 + done +done + +cd .. + +cat >exp <<'EOF' +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +2 Jan 1 2001 file1024 +512 Jan 1 2001 file262144 +8 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +2 Jan 1 2001 file1024 +512 Jan 1 2001 file262144 +8 Jan 1 2001 file4096 +2 Jan 1 2001 file1024 +512 Jan 1 2001 file262144 +8 Jan 1 2001 file4096 +2 Jan 1 2001 file1024 +512 Jan 1 2001 file262144 +8 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +1024 Jan 1 2001 file1024 +262144 Jan 1 2001 file262144 +4096 Jan 1 2001 file4096 +2 Jan 1 2001 file1024 +512 Jan 1 2001 file262144 +8 Jan 1 2001 file4096 +2 Jan 1 2001 file1024 +512 Jan 1 2001 file262144 +8 Jan 1 2001 file4096 +2 Jan 1 2001 file1024 +512 Jan 1 2001 file262144 +8 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +1 Jan 1 2001 file1024 +256 Jan 1 2001 file262144 +4 Jan 1 2001 file4096 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/capability b/tests/ls/capability deleted file mode 100755 index d5d5ee047..000000000 --- a/tests/ls/capability +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Ensure "ls --color" properly colorizes file with capability. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls -require_root_ - -grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \ - || skip_ "configured without libcap support" - -(setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \ - || skip_ "setcap utility not found" - -# Don't let a different umask perturb the results. -umask 22 - -# We create 2 files of the same name as -# before coreutils 8.1 only the name rather than -# the full path was used to read the capabilities -# thus giving false positives and negatives. -mkdir test test/dir -cd test -touch cap_pos dir/cap_pos dir/cap_neg -for file in cap_pos dir/cap_neg; do - setcap 'cap_net_bind_service=ep' $file || - skip_ "setcap doesn't work" -done - -code='30;41' -# Note we explicitly disable "executable" coloring -# so that capability coloring is not dependent on it, -# as was the case before coreutils 8.1 -for ex in '' ex=:; do - LS_COLORS="di=:${ex}ca=$code" \ - ls --color=always cap_pos dir > out || fail=1 - - env printf "\ -\e[0m\e[${code}mcap_pos\e[0m - -dir: -\e[${code}mcap_neg\e[0m -cap_pos -" > out_ok || framework_failure_ - - compare out out_ok || fail=1 -done - -Exit $fail diff --git a/tests/ls/capability.sh b/tests/ls/capability.sh new file mode 100755 index 000000000..d5d5ee047 --- /dev/null +++ b/tests/ls/capability.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Ensure "ls --color" properly colorizes file with capability. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls +require_root_ + +grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \ + || skip_ "configured without libcap support" + +(setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \ + || skip_ "setcap utility not found" + +# Don't let a different umask perturb the results. +umask 22 + +# We create 2 files of the same name as +# before coreutils 8.1 only the name rather than +# the full path was used to read the capabilities +# thus giving false positives and negatives. +mkdir test test/dir +cd test +touch cap_pos dir/cap_pos dir/cap_neg +for file in cap_pos dir/cap_neg; do + setcap 'cap_net_bind_service=ep' $file || + skip_ "setcap doesn't work" +done + +code='30;41' +# Note we explicitly disable "executable" coloring +# so that capability coloring is not dependent on it, +# as was the case before coreutils 8.1 +for ex in '' ex=:; do + LS_COLORS="di=:${ex}ca=$code" \ + ls --color=always cap_pos dir > out || fail=1 + + env printf "\ +\e[0m\e[${code}mcap_pos\e[0m + +dir: +\e[${code}mcap_neg\e[0m +cap_pos +" > out_ok || framework_failure_ + + compare out out_ok || fail=1 +done + +Exit $fail diff --git a/tests/ls/color-clear-to-eol b/tests/ls/color-clear-to-eol deleted file mode 100755 index 5dc6d16be..000000000 --- a/tests/ls/color-clear-to-eol +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# ensure that ls --color works well when a colored name is wrapped - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -long_name=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.foo -touch $long_name || framework_failure_ - -e='\33' -color_code='0;31;42' -c_pre="$e[0m$e[${color_code}m" -c_post="$e[0m$e[K\n" -printf "$c_pre$long_name$c_post\n" > exp || framework_failure_ - -env TERM=xterm COLUMNS=80 LS_COLORS="*.foo=$color_code" TIME_STYLE=+T \ - ls -og --color=always $long_name > out || fail=1 - -# Append a newline, to accommodate less-capable versions of sed. -echo >> out || fail=1 - -sed 's/.*T //' out > k && mv k out - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/color-clear-to-eol.sh b/tests/ls/color-clear-to-eol.sh new file mode 100755 index 000000000..5dc6d16be --- /dev/null +++ b/tests/ls/color-clear-to-eol.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# ensure that ls --color works well when a colored name is wrapped + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +long_name=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.foo +touch $long_name || framework_failure_ + +e='\33' +color_code='0;31;42' +c_pre="$e[0m$e[${color_code}m" +c_post="$e[0m$e[K\n" +printf "$c_pre$long_name$c_post\n" > exp || framework_failure_ + +env TERM=xterm COLUMNS=80 LS_COLORS="*.foo=$color_code" TIME_STYLE=+T \ + ls -og --color=always $long_name > out || fail=1 + +# Append a newline, to accommodate less-capable versions of sed. +echo >> out || fail=1 + +sed 's/.*T //' out > k && mv k out + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/color-dtype-dir b/tests/ls/color-dtype-dir deleted file mode 100755 index 69dffd79c..000000000 --- a/tests/ls/color-dtype-dir +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -# Ensure "ls --color" properly colors other-writable and sticky directories. -# Before coreutils-6.2, this test would fail, coloring all three -# directories the same as the first one -- but only on a file system -# with dirent.d_type support. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -# Don't let a different umask perturb the results. -umask 22 - -mkdir d other-writable sticky || framework_failure_ -chmod o+w other-writable || framework_failure_ -chmod o+t sticky || framework_failure_ - - -ls --color=always > out || fail=1 -cat -A out > o1 || fail=1 -mv o1 out || fail=1 - -cat <<\EOF > exp || fail=1 -^[[0m^[[01;34md^[[0m$ -^[[34;42mother-writable^[[0m$ -out$ -^[[37;44msticky^[[0m$ -EOF - -compare exp out || fail=1 - -rm exp - -# Turn off colors for other-writable dirs and ensure -# we fall back to the color for standard directories. - -LS_COLORS="ow=:" ls --color=always > out || fail=1 -cat -A out > o1 || fail=1 -mv o1 out || fail=1 - -cat <<\EOF > exp || fail=1 -^[[0m^[[01;34md^[[0m$ -^[[01;34mother-writable^[[0m$ -out$ -^[[37;44msticky^[[0m$ -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/color-dtype-dir.sh b/tests/ls/color-dtype-dir.sh new file mode 100755 index 000000000..69dffd79c --- /dev/null +++ b/tests/ls/color-dtype-dir.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# Ensure "ls --color" properly colors other-writable and sticky directories. +# Before coreutils-6.2, this test would fail, coloring all three +# directories the same as the first one -- but only on a file system +# with dirent.d_type support. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +# Don't let a different umask perturb the results. +umask 22 + +mkdir d other-writable sticky || framework_failure_ +chmod o+w other-writable || framework_failure_ +chmod o+t sticky || framework_failure_ + + +ls --color=always > out || fail=1 +cat -A out > o1 || fail=1 +mv o1 out || fail=1 + +cat <<\EOF > exp || fail=1 +^[[0m^[[01;34md^[[0m$ +^[[34;42mother-writable^[[0m$ +out$ +^[[37;44msticky^[[0m$ +EOF + +compare exp out || fail=1 + +rm exp + +# Turn off colors for other-writable dirs and ensure +# we fall back to the color for standard directories. + +LS_COLORS="ow=:" ls --color=always > out || fail=1 +cat -A out > o1 || fail=1 +mv o1 out || fail=1 + +cat <<\EOF > exp || fail=1 +^[[0m^[[01;34md^[[0m$ +^[[01;34mother-writable^[[0m$ +out$ +^[[37;44msticky^[[0m$ +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/color-norm b/tests/ls/color-norm deleted file mode 100755 index 28366fb5c..000000000 --- a/tests/ls/color-norm +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -# Ensure "ls --color" properly colors "normal" text and files. -# I.E. that it uses NORMAL to style non file name output and -# file names with no associated color (unless FILE is also set). - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -# Don't let a different umask perturb the results. -umask 22 - -# Output time as something constant -export TIME_STYLE="+norm" - -# helper to strip ls columns up to "norm" time -qls() { sed 's/-r.*norm/norm/'; } - -touch exe || framework_failure_ -chmod u+x exe || framework_failure_ -touch nocolor || framework_failure_ - -TCOLORS="no=7:ex=01;32" - -# Non coloured files inherit NORMAL attributes -LS_COLORS=$TCOLORS ls -gGU --color exe nocolor | qls >> out || fail=1 -LS_COLORS=$TCOLORS ls -xU --color exe nocolor >> out || fail=1 -LS_COLORS=$TCOLORS ls -gGU --color nocolor exe | qls >> out || fail=1 -LS_COLORS=$TCOLORS ls -xU --color nocolor exe >> out || fail=1 - -# NORMAL does not override FILE though -LS_COLORS=$TCOLORS:fi=1 ls -gGU --color nocolor exe | qls >> out || fail=1 - -# Support uncolored ordinary files that do _not_ inherit from NORMAL. -# Note there is a redundant RESET output before a non colored -# file in this case which may be removed in future. -LS_COLORS=$TCOLORS:fi= ls -gGU --color nocolor exe | qls >> out || fail=1 -LS_COLORS=$TCOLORS:fi=0 ls -gGU --color nocolor exe | qls >> out || fail=1 - -# A caveat worth noting is that commas (-m), indicator chars (-F) -# and the "total" line, do not currently use NORMAL attributes -LS_COLORS=$TCOLORS ls -mFU --color nocolor exe >> out || fail=1 - -# Ensure no coloring is done unless enabled -LS_COLORS=$TCOLORS ls -gGU nocolor exe | qls >> out || fail=1 - -cat -A out > out.display || framework_failure_ -mv out.display out || framework_failure_ - -cat <<\EOF > exp || framework_failure_ -^[[0m^[[7mnorm ^[[m^[[01;32mexe^[[0m$ -^[[7mnorm nocolor^[[0m$ -^[[0m^[[7m^[[m^[[01;32mexe^[[0m ^[[7mnocolor^[[0m$ -^[[0m^[[7mnorm nocolor^[[0m$ -^[[7mnorm ^[[m^[[01;32mexe^[[0m$ -^[[0m^[[7mnocolor^[[0m ^[[7m^[[m^[[01;32mexe^[[0m$ -^[[0m^[[7mnorm ^[[m^[[1mnocolor^[[0m$ -^[[7mnorm ^[[m^[[01;32mexe^[[0m$ -^[[0m^[[7mnorm ^[[m^[[mnocolor^[[0m$ -^[[7mnorm ^[[m^[[01;32mexe^[[0m$ -^[[0m^[[7mnorm ^[[m^[[0mnocolor^[[0m$ -^[[7mnorm ^[[m^[[01;32mexe^[[0m$ -^[[0m^[[7mnocolor^[[0m, ^[[7m^[[m^[[01;32mexe^[[0m*$ -norm nocolor$ -norm exe$ -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/color-norm.sh b/tests/ls/color-norm.sh new file mode 100755 index 000000000..28366fb5c --- /dev/null +++ b/tests/ls/color-norm.sh @@ -0,0 +1,84 @@ +#!/bin/sh +# Ensure "ls --color" properly colors "normal" text and files. +# I.E. that it uses NORMAL to style non file name output and +# file names with no associated color (unless FILE is also set). + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +# Don't let a different umask perturb the results. +umask 22 + +# Output time as something constant +export TIME_STYLE="+norm" + +# helper to strip ls columns up to "norm" time +qls() { sed 's/-r.*norm/norm/'; } + +touch exe || framework_failure_ +chmod u+x exe || framework_failure_ +touch nocolor || framework_failure_ + +TCOLORS="no=7:ex=01;32" + +# Non coloured files inherit NORMAL attributes +LS_COLORS=$TCOLORS ls -gGU --color exe nocolor | qls >> out || fail=1 +LS_COLORS=$TCOLORS ls -xU --color exe nocolor >> out || fail=1 +LS_COLORS=$TCOLORS ls -gGU --color nocolor exe | qls >> out || fail=1 +LS_COLORS=$TCOLORS ls -xU --color nocolor exe >> out || fail=1 + +# NORMAL does not override FILE though +LS_COLORS=$TCOLORS:fi=1 ls -gGU --color nocolor exe | qls >> out || fail=1 + +# Support uncolored ordinary files that do _not_ inherit from NORMAL. +# Note there is a redundant RESET output before a non colored +# file in this case which may be removed in future. +LS_COLORS=$TCOLORS:fi= ls -gGU --color nocolor exe | qls >> out || fail=1 +LS_COLORS=$TCOLORS:fi=0 ls -gGU --color nocolor exe | qls >> out || fail=1 + +# A caveat worth noting is that commas (-m), indicator chars (-F) +# and the "total" line, do not currently use NORMAL attributes +LS_COLORS=$TCOLORS ls -mFU --color nocolor exe >> out || fail=1 + +# Ensure no coloring is done unless enabled +LS_COLORS=$TCOLORS ls -gGU nocolor exe | qls >> out || fail=1 + +cat -A out > out.display || framework_failure_ +mv out.display out || framework_failure_ + +cat <<\EOF > exp || framework_failure_ +^[[0m^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[7mnorm nocolor^[[0m$ +^[[0m^[[7m^[[m^[[01;32mexe^[[0m ^[[7mnocolor^[[0m$ +^[[0m^[[7mnorm nocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnocolor^[[0m ^[[7m^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnorm ^[[m^[[1mnocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnorm ^[[m^[[mnocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnorm ^[[m^[[0mnocolor^[[0m$ +^[[7mnorm ^[[m^[[01;32mexe^[[0m$ +^[[0m^[[7mnocolor^[[0m, ^[[7m^[[m^[[01;32mexe^[[0m*$ +norm nocolor$ +norm exe$ +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/dangle b/tests/ls/dangle deleted file mode 100755 index dbc24476a..000000000 --- a/tests/ls/dangle +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh -# Make sure ls properly handles dangling symlinks vs. ls's -L, -H, options. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -ln -s no-such-file dangle || framework_failure_ -mkdir -p dir/sub || framework_failure_ -ln -s dir slink-to-dir || framework_failure_ -mkdir d || framework_failure_ -ln -s no-such d/dangle || framework_failure_ -printf '? dangle\n' > subdir_Li_exp || framework_failure_ -printf 'total 0\n? dangle\n' > subdir_Ls_exp || framework_failure_ - - -# This must exit nonzero. -ls -L dangle > /dev/null 2>&1 && fail=1 -# So must this. -ls -H dangle > /dev/null 2>&1 && fail=1 - -# This must exit successfully. -ls dangle >> out || fail=1 - -ls slink-to-dir >> out 2>&1 || fail=1 -ls -H slink-to-dir >> out 2>&1 || fail=1 -ls -L slink-to-dir >> out 2>&1 || fail=1 - -cat <<\EOF > exp -dangle -sub -sub -sub -EOF - -compare exp out || fail=1 - -# Ensure that ls -Li prints "?" as the inode of a dangling symlink. -rm -f out -ls -Li d > out 2>/dev/null && fail=1 -compare subdir_Li_exp out || fail=1 - -# Ensure that ls -Ls prints "?" as the allocation of a dangling symlink. -rm -f out -ls -Ls d > out 2>/dev/null && fail=1 -compare subdir_Ls_exp out || fail=1 - -Exit $fail diff --git a/tests/ls/dangle.sh b/tests/ls/dangle.sh new file mode 100755 index 000000000..dbc24476a --- /dev/null +++ b/tests/ls/dangle.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# Make sure ls properly handles dangling symlinks vs. ls's -L, -H, options. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +ln -s no-such-file dangle || framework_failure_ +mkdir -p dir/sub || framework_failure_ +ln -s dir slink-to-dir || framework_failure_ +mkdir d || framework_failure_ +ln -s no-such d/dangle || framework_failure_ +printf '? dangle\n' > subdir_Li_exp || framework_failure_ +printf 'total 0\n? dangle\n' > subdir_Ls_exp || framework_failure_ + + +# This must exit nonzero. +ls -L dangle > /dev/null 2>&1 && fail=1 +# So must this. +ls -H dangle > /dev/null 2>&1 && fail=1 + +# This must exit successfully. +ls dangle >> out || fail=1 + +ls slink-to-dir >> out 2>&1 || fail=1 +ls -H slink-to-dir >> out 2>&1 || fail=1 +ls -L slink-to-dir >> out 2>&1 || fail=1 + +cat <<\EOF > exp +dangle +sub +sub +sub +EOF + +compare exp out || fail=1 + +# Ensure that ls -Li prints "?" as the inode of a dangling symlink. +rm -f out +ls -Li d > out 2>/dev/null && fail=1 +compare subdir_Li_exp out || fail=1 + +# Ensure that ls -Ls prints "?" as the allocation of a dangling symlink. +rm -f out +ls -Ls d > out 2>/dev/null && fail=1 +compare subdir_Ls_exp out || fail=1 + +Exit $fail diff --git a/tests/ls/dired b/tests/ls/dired deleted file mode 100755 index 6b55f435f..000000000 --- a/tests/ls/dired +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# make sure --dired option works - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -mkdir dir || framework_failure_ - - -LC_MESSAGES=C ls -lR --dired dir > out || fail=1 -cat < exp - dir: - total 0 -//SUBDIRED// 2 5 -//DIRED-OPTIONS// --quoting-style=literal -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/dired.sh b/tests/ls/dired.sh new file mode 100755 index 000000000..6b55f435f --- /dev/null +++ b/tests/ls/dired.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# make sure --dired option works + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +mkdir dir || framework_failure_ + + +LC_MESSAGES=C ls -lR --dired dir > out || fail=1 +cat < exp + dir: + total 0 +//SUBDIRED// 2 5 +//DIRED-OPTIONS// --quoting-style=literal +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/file-type b/tests/ls/file-type deleted file mode 100755 index 3bb7937a6..000000000 --- a/tests/ls/file-type +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# contrast ls -F, ls -p, and ls --indicator-style=file-type - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -mkdir sub -cd sub -mkdir dir -touch regular executable -chmod a+x executable -ln -s regular slink-reg -ln -s dir slink-dir -ln -s nowhere slink-dangle -mknod block b 20 20 2> /dev/null && block="block -" -mknod char c 10 10 2> /dev/null && char="char -" -mkfifo_or_skip_ fifo -cd .. - - - -ls -F sub > out || fail=1 -cat < exp -$block${char}dir/ -executable* -fifo| -regular -slink-dangle@ -slink-dir@ -slink-reg@ -EOF - -sed 's/\*//' exp > exp2 -ls --indicator-style=file-type sub > out2 || fail=1 - -sed 's/[@|]$//' exp2 > exp3 -ls -p sub > out3 || fail=1 - -compare exp out || fail=1 - -compare exp2 out2 || fail=1 - -compare exp3 out3 || fail=1 - -ls --color=auto -F sub > out || fail=1 -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/file-type.sh b/tests/ls/file-type.sh new file mode 100755 index 000000000..3bb7937a6 --- /dev/null +++ b/tests/ls/file-type.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# contrast ls -F, ls -p, and ls --indicator-style=file-type + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +mkdir sub +cd sub +mkdir dir +touch regular executable +chmod a+x executable +ln -s regular slink-reg +ln -s dir slink-dir +ln -s nowhere slink-dangle +mknod block b 20 20 2> /dev/null && block="block +" +mknod char c 10 10 2> /dev/null && char="char +" +mkfifo_or_skip_ fifo +cd .. + + + +ls -F sub > out || fail=1 +cat < exp +$block${char}dir/ +executable* +fifo| +regular +slink-dangle@ +slink-dir@ +slink-reg@ +EOF + +sed 's/\*//' exp > exp2 +ls --indicator-style=file-type sub > out2 || fail=1 + +sed 's/[@|]$//' exp2 > exp3 +ls -p sub > out3 || fail=1 + +compare exp out || fail=1 + +compare exp2 out2 || fail=1 + +compare exp3 out3 || fail=1 + +ls --color=auto -F sub > out || fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/follow-slink b/tests/ls/follow-slink deleted file mode 100755 index d3c0d6ef5..000000000 --- a/tests/ls/follow-slink +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# make sure ls -L always follows symlinks - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -# Isolate output files from directory being listed -mkdir dir dir/sub dir1 || framework_failure_ -cd dir || framework_failure_ -ln -s link link || framework_failure_ -ln -s ../../dir1 sub/link-to-dir || framework_failure_ - -# Make sure the symlink was created. -# 'ln -s link link' succeeds, but creates no file on -# systems running some DJGPP-2.03 libc. -ls -F link > /dev/null || framework_failure_ - - -# When explicitly listing a broken link, the command must fail. -ls -L link 2> /dev/null && fail=1 - -# When encountering a broken link implicitly, Solaris 9 and OpenBSD 3.4 -# list the link, provided no further information about the link needed -# to be printed. Since POSIX does not specify one way or the other, we -# opt for compatibility (this was broken in 5.3.0 through 5.94). -LC_ALL=C ls -L > ../out-L || fail=1 -LC_ALL=C ls -FLR sub > ../out-FLR-sub || fail=1 - -cd .. || fail=1 - -cat <<\EOF > exp-L -link -sub -EOF - -cat <<\EOF > exp-FLR-sub -sub: -link-to-dir/ - -sub/link-to-dir: -EOF - -compare exp-L out-L || fail=1 -compare exp-FLR-sub out-FLR-sub || fail=1 - -Exit $fail diff --git a/tests/ls/follow-slink.sh b/tests/ls/follow-slink.sh new file mode 100755 index 000000000..d3c0d6ef5 --- /dev/null +++ b/tests/ls/follow-slink.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# make sure ls -L always follows symlinks + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +# Isolate output files from directory being listed +mkdir dir dir/sub dir1 || framework_failure_ +cd dir || framework_failure_ +ln -s link link || framework_failure_ +ln -s ../../dir1 sub/link-to-dir || framework_failure_ + +# Make sure the symlink was created. +# 'ln -s link link' succeeds, but creates no file on +# systems running some DJGPP-2.03 libc. +ls -F link > /dev/null || framework_failure_ + + +# When explicitly listing a broken link, the command must fail. +ls -L link 2> /dev/null && fail=1 + +# When encountering a broken link implicitly, Solaris 9 and OpenBSD 3.4 +# list the link, provided no further information about the link needed +# to be printed. Since POSIX does not specify one way or the other, we +# opt for compatibility (this was broken in 5.3.0 through 5.94). +LC_ALL=C ls -L > ../out-L || fail=1 +LC_ALL=C ls -FLR sub > ../out-FLR-sub || fail=1 + +cd .. || fail=1 + +cat <<\EOF > exp-L +link +sub +EOF + +cat <<\EOF > exp-FLR-sub +sub: +link-to-dir/ + +sub/link-to-dir: +EOF + +compare exp-L out-L || fail=1 +compare exp-FLR-sub out-FLR-sub || fail=1 + +Exit $fail diff --git a/tests/ls/getxattr-speedup b/tests/ls/getxattr-speedup deleted file mode 100755 index 967f7c95f..000000000 --- a/tests/ls/getxattr-speedup +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Show that we've eliminated most of ls' failing getxattr syscalls, -# regardless of how many files are in a directory we list. -# This test is skipped on systems that lack LD_PRELOAD support; that's fine. -# Similarly, on a system that lacks getxattr altogether, skipping it is fine. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -# Replace each getxattr and lgetxattr call with a call to these stubs. -# Count those and write the total number of calls to the file "x" -# via a global destructor. -cat > k.c <<'EOF' || framework_failure_ -#include -#include -#include - -static unsigned long int n_calls; - -static void __attribute__ ((destructor)) -print_call_count (void) -{ - FILE *fp = fopen ("x", "w"); if (!fp) return; - fprintf (fp, "%lu\n", n_calls); fclose (fp); -} - -static ssize_t incr () { ++n_calls; errno = ENOTSUP; return -1; } -ssize_t getxattr (const char *path, const char *name, void *value, size_t size) -{ return incr (); } -ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) -{ return incr (); } -EOF - -# Then compile/link it: -$CC -shared -fPIC -O2 k.c -o k.so \ - || framework_failure_ 'failed to compile with -shared -fPIC' - -# Create a few files: -seq 20 | xargs touch || framework_failure_ - -# Finally, run the test: -LD_PRELOAD=./k.so ls --color=always -l . || fail=1 - -test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" - -# Ensure that there were no more than 3 *getxattr calls. -n_calls=$(cat x) -test "$n_calls" -le 3 || fail=1 - -Exit $fail diff --git a/tests/ls/getxattr-speedup.sh b/tests/ls/getxattr-speedup.sh new file mode 100755 index 000000000..967f7c95f --- /dev/null +++ b/tests/ls/getxattr-speedup.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Show that we've eliminated most of ls' failing getxattr syscalls, +# regardless of how many files are in a directory we list. +# This test is skipped on systems that lack LD_PRELOAD support; that's fine. +# Similarly, on a system that lacks getxattr altogether, skipping it is fine. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +# Replace each getxattr and lgetxattr call with a call to these stubs. +# Count those and write the total number of calls to the file "x" +# via a global destructor. +cat > k.c <<'EOF' || framework_failure_ +#include +#include +#include + +static unsigned long int n_calls; + +static void __attribute__ ((destructor)) +print_call_count (void) +{ + FILE *fp = fopen ("x", "w"); if (!fp) return; + fprintf (fp, "%lu\n", n_calls); fclose (fp); +} + +static ssize_t incr () { ++n_calls; errno = ENOTSUP; return -1; } +ssize_t getxattr (const char *path, const char *name, void *value, size_t size) +{ return incr (); } +ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) +{ return incr (); } +EOF + +# Then compile/link it: +$CC -shared -fPIC -O2 k.c -o k.so \ + || framework_failure_ 'failed to compile with -shared -fPIC' + +# Create a few files: +seq 20 | xargs touch || framework_failure_ + +# Finally, run the test: +LD_PRELOAD=./k.so ls --color=always -l . || fail=1 + +test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?" + +# Ensure that there were no more than 3 *getxattr calls. +n_calls=$(cat x) +test "$n_calls" -le 3 || fail=1 + +Exit $fail diff --git a/tests/ls/infloop b/tests/ls/infloop deleted file mode 100755 index 9652112c8..000000000 --- a/tests/ls/infloop +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# show that the following no longer makes ls infloop -# mkdir loop; cd loop; ln -s ../loop sub; ls -RL -# Also ensure ls exits with status = 2 in that case. -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -mkdir loop || framework_failure_ -ln -s ../loop loop/sub || framework_failure_ - -cat <<\EOF > exp-out || framework_failure_ -loop: -sub -EOF - -cat <<\EOF > exp-err || framework_failure_ -ls: loop/sub: not listing already-listed directory -EOF - -timeout 10 ls -RL loop >out 2>err -# Ensure that ls exits with status 2 upon detecting a cycle -test $? = 2 || fail=1 - -compare exp-err err || fail=1 -compare exp-out out || fail=1 - -Exit $fail diff --git a/tests/ls/infloop.sh b/tests/ls/infloop.sh new file mode 100755 index 000000000..9652112c8 --- /dev/null +++ b/tests/ls/infloop.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# show that the following no longer makes ls infloop +# mkdir loop; cd loop; ln -s ../loop sub; ls -RL +# Also ensure ls exits with status = 2 in that case. +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +mkdir loop || framework_failure_ +ln -s ../loop loop/sub || framework_failure_ + +cat <<\EOF > exp-out || framework_failure_ +loop: +sub +EOF + +cat <<\EOF > exp-err || framework_failure_ +ls: loop/sub: not listing already-listed directory +EOF + +timeout 10 ls -RL loop >out 2>err +# Ensure that ls exits with status 2 upon detecting a cycle +test $? = 2 || fail=1 + +compare exp-err err || fail=1 +compare exp-out out || fail=1 + +Exit $fail diff --git a/tests/ls/inode b/tests/ls/inode deleted file mode 100755 index 8bf5ba153..000000000 --- a/tests/ls/inode +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Make sure that ls -i works properly on symlinks. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -touch f || framework_failure_ -ln -s f slink || framework_failure_ - - -# When listed explicitly: - -set x $(ls -Ci f slink); shift -test $# = 4 || fail=1 -# The inode numbers should differ. -test "$1" != "$3" || fail=1 - -set x $(ls -CLi f slink); shift -test $# = 4 || fail=1 -# With -L, they must be the same. -test "$1" = "$3" || fail=1 - -set x $(ls -CHi f slink); shift -test $# = 4 || fail=1 -# With -H, they must be the same, too, from the command line. -# Note that POSIX says -H must make ls dereference only -# symlinks (specified on the command line) to directories, -# but the historical BSD meaning of -H is to dereference -# any symlink given on the command line. For compatibility GNU ls -# implements the BSD semantics. -test "$1" = "$3" || fail=1 - -# When listed from a directory: - -set x $(ls -Ci); shift -test $# = 4 || fail=1 -# The inode numbers should differ. -test "$1" != "$3" || fail=1 - -set x $(ls -CLi); shift -test $# = 4 || fail=1 -# With -L, they must be the same. -test "$1" = "$3" || fail=1 - -set x $(ls -CHi); shift -test $# = 4 || fail=1 -# With -H, they must be different from inside a directory. -test "$1" != "$3" || fail=1 - -Exit $fail diff --git a/tests/ls/inode.sh b/tests/ls/inode.sh new file mode 100755 index 000000000..8bf5ba153 --- /dev/null +++ b/tests/ls/inode.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Make sure that ls -i works properly on symlinks. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +touch f || framework_failure_ +ln -s f slink || framework_failure_ + + +# When listed explicitly: + +set x $(ls -Ci f slink); shift +test $# = 4 || fail=1 +# The inode numbers should differ. +test "$1" != "$3" || fail=1 + +set x $(ls -CLi f slink); shift +test $# = 4 || fail=1 +# With -L, they must be the same. +test "$1" = "$3" || fail=1 + +set x $(ls -CHi f slink); shift +test $# = 4 || fail=1 +# With -H, they must be the same, too, from the command line. +# Note that POSIX says -H must make ls dereference only +# symlinks (specified on the command line) to directories, +# but the historical BSD meaning of -H is to dereference +# any symlink given on the command line. For compatibility GNU ls +# implements the BSD semantics. +test "$1" = "$3" || fail=1 + +# When listed from a directory: + +set x $(ls -Ci); shift +test $# = 4 || fail=1 +# The inode numbers should differ. +test "$1" != "$3" || fail=1 + +set x $(ls -CLi); shift +test $# = 4 || fail=1 +# With -L, they must be the same. +test "$1" = "$3" || fail=1 + +set x $(ls -CHi); shift +test $# = 4 || fail=1 +# With -H, they must be different from inside a directory. +test "$1" != "$3" || fail=1 + +Exit $fail diff --git a/tests/ls/m-option b/tests/ls/m-option deleted file mode 100755 index cc72e73cc..000000000 --- a/tests/ls/m-option +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# exercise the -m option - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -seq 2000 > b || framework_failure_ -touch a || framework_failure_ - - -# Before coreutils-5.1.1, the following would output a space after the comma. -ls -w2 -m a b > out || fail=1 - -# Before coreutils-5.1.1, the following would produce leading white space. -# All of the sed business is because the sizes are not portable. -ls -sm a b | sed 's/^[0-9]/0/;s/, [0-9][0-9]* b/, 12 b/' >> out || fail=1 -cat <<\EOF > exp || fail=1 -a, -b -0 a, 12 b -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/m-option.sh b/tests/ls/m-option.sh new file mode 100755 index 000000000..cc72e73cc --- /dev/null +++ b/tests/ls/m-option.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# exercise the -m option + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +seq 2000 > b || framework_failure_ +touch a || framework_failure_ + + +# Before coreutils-5.1.1, the following would output a space after the comma. +ls -w2 -m a b > out || fail=1 + +# Before coreutils-5.1.1, the following would produce leading white space. +# All of the sed business is because the sizes are not portable. +ls -sm a b | sed 's/^[0-9]/0/;s/, [0-9][0-9]* b/, 12 b/' >> out || fail=1 +cat <<\EOF > exp || fail=1 +a, +b +0 a, 12 b +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/multihardlink b/tests/ls/multihardlink deleted file mode 100755 index 68a587255..000000000 --- a/tests/ls/multihardlink +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# Ensure "ls --color" properly colorizes hard linked files. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls -working_umask_or_skip_ - -touch file file1 || framework_failure_ -ln file1 file2 || skip_ "can't create hard link" -code_mh='44;37' -code_ex='01;32' -code_png='01;35' -c0=$(printf '\033[0m') -c_mh=$(printf '\033[%sm' $code_mh) -c_ex=$(printf '\033[%sm' $code_ex) -c_png=$(printf '\033[%sm' $code_png) - -# regular file - not hard linked -LS_COLORS="mh=$code_mh" ls -U1 --color=always file > out || fail=1 -printf "file\n" > out_ok || framework_failure_ -compare out out_ok || fail=1 - -# hard links -LS_COLORS="mh=$code_mh" ls -U1 --color=always file1 file2 > out || fail=1 -printf "$c0${c_mh}file1$c0 -${c_mh}file2$c0 -" > out_ok || framework_failure_ -compare out out_ok || fail=1 - -# hard links and png (hard link coloring takes precedence) -mv file2 file2.png || framework_failure_ -LS_COLORS="mh=$code_mh:*.png=$code_png" ls -U1 --color=always file1 file2.png \ - > out || fail=1 -printf "$c0${c_mh}file1$c0 -${c_mh}file2.png$c0 -" > out_ok || framework_failure_ -compare out out_ok || fail=1 - -# hard links and exe (exe coloring takes precedence) -chmod a+x file2.png || framework_failure_ -LS_COLORS="mh=$code_mh:*.png=$code_png:ex=$code_ex" \ - ls -U1 --color=always file1 file2.png > out || fail=1 -chmod a-x file2.png || framework_failure_ -printf "$c0${c_ex}file1$c0 -${c_ex}file2.png$c0 -" > out_ok || framework_failure_ -compare out out_ok || fail=1 - -# hard links and png (hard link coloring disabled => png coloring enabled) -LS_COLORS="mh=00:*.png=$code_png" ls -U1 --color=always file1 file2.png > out \ - || fail=1 -printf "file1 -$c0${c_png}file2.png$c0 -" > out_ok || framework_failure_ -compare out out_ok || fail=1 - -# hard links and png (hard link coloring not enabled explicitly => png coloring) -LS_COLORS="*.png=$code_png" ls -U1 --color=always file1 file2.png > out \ - || fail=1 -printf "file1 -$c0${c_png}file2.png$c0 -" > out_ok || framework_failure_ -compare out out_ok || fail=1 - -Exit $fail diff --git a/tests/ls/multihardlink.sh b/tests/ls/multihardlink.sh new file mode 100755 index 000000000..68a587255 --- /dev/null +++ b/tests/ls/multihardlink.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Ensure "ls --color" properly colorizes hard linked files. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls +working_umask_or_skip_ + +touch file file1 || framework_failure_ +ln file1 file2 || skip_ "can't create hard link" +code_mh='44;37' +code_ex='01;32' +code_png='01;35' +c0=$(printf '\033[0m') +c_mh=$(printf '\033[%sm' $code_mh) +c_ex=$(printf '\033[%sm' $code_ex) +c_png=$(printf '\033[%sm' $code_png) + +# regular file - not hard linked +LS_COLORS="mh=$code_mh" ls -U1 --color=always file > out || fail=1 +printf "file\n" > out_ok || framework_failure_ +compare out out_ok || fail=1 + +# hard links +LS_COLORS="mh=$code_mh" ls -U1 --color=always file1 file2 > out || fail=1 +printf "$c0${c_mh}file1$c0 +${c_mh}file2$c0 +" > out_ok || framework_failure_ +compare out out_ok || fail=1 + +# hard links and png (hard link coloring takes precedence) +mv file2 file2.png || framework_failure_ +LS_COLORS="mh=$code_mh:*.png=$code_png" ls -U1 --color=always file1 file2.png \ + > out || fail=1 +printf "$c0${c_mh}file1$c0 +${c_mh}file2.png$c0 +" > out_ok || framework_failure_ +compare out out_ok || fail=1 + +# hard links and exe (exe coloring takes precedence) +chmod a+x file2.png || framework_failure_ +LS_COLORS="mh=$code_mh:*.png=$code_png:ex=$code_ex" \ + ls -U1 --color=always file1 file2.png > out || fail=1 +chmod a-x file2.png || framework_failure_ +printf "$c0${c_ex}file1$c0 +${c_ex}file2.png$c0 +" > out_ok || framework_failure_ +compare out out_ok || fail=1 + +# hard links and png (hard link coloring disabled => png coloring enabled) +LS_COLORS="mh=00:*.png=$code_png" ls -U1 --color=always file1 file2.png > out \ + || fail=1 +printf "file1 +$c0${c_png}file2.png$c0 +" > out_ok || framework_failure_ +compare out out_ok || fail=1 + +# hard links and png (hard link coloring not enabled explicitly => png coloring) +LS_COLORS="*.png=$code_png" ls -U1 --color=always file1 file2.png > out \ + || fail=1 +printf "file1 +$c0${c_png}file2.png$c0 +" > out_ok || framework_failure_ +compare out out_ok || fail=1 + +Exit $fail diff --git a/tests/ls/nameless-uid b/tests/ls/nameless-uid deleted file mode 100755 index 5b45b091b..000000000 --- a/tests/ls/nameless-uid +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Ensure that ls -l works on files with nameless uid and/or gid - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -require_root_ -require_perl_ - -nameless_uid=$($PERL -e ' - foreach my $i (1000..16*1024) { getpwuid $i or (print "$i\n"), exit } -') - -if test x$nameless_uid = x; then - skip_ "couldn't find a nameless UID" -fi - -touch f || framework_failure_ -chown $nameless_uid f || framework_failure_ - - -set -- $(ls -o f) || fail=1 -test $3 = $nameless_uid || fail=1 - -Exit $fail diff --git a/tests/ls/nameless-uid.sh b/tests/ls/nameless-uid.sh new file mode 100755 index 000000000..5b45b091b --- /dev/null +++ b/tests/ls/nameless-uid.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Ensure that ls -l works on files with nameless uid and/or gid + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +require_root_ +require_perl_ + +nameless_uid=$($PERL -e ' + foreach my $i (1000..16*1024) { getpwuid $i or (print "$i\n"), exit } +') + +if test x$nameless_uid = x; then + skip_ "couldn't find a nameless UID" +fi + +touch f || framework_failure_ +chown $nameless_uid f || framework_failure_ + + +set -- $(ls -o f) || fail=1 +test $3 = $nameless_uid || fail=1 + +Exit $fail diff --git a/tests/ls/no-arg b/tests/ls/no-arg deleted file mode 100755 index 8e7d1d616..000000000 --- a/tests/ls/no-arg +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# make sure ls and 'ls -R' do the right thing when invoked with no arguments. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -mkdir -p dir/subdir || framework_failure_ -touch dir/subdir/file2 || framework_failure_ -ln -s f symlink || framework_failure_ - -cat > exp <<\EOF || framework_failure_ -dir -exp -out -symlink -EOF - - -ls -1 > out || fail=1 - -compare exp out || fail=1 - -cat > exp <<\EOF -.: -dir -exp -out -symlink - -./dir: -subdir - -./dir/subdir: -file2 -EOF - -ls -R1 > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/no-arg.sh b/tests/ls/no-arg.sh new file mode 100755 index 000000000..8e7d1d616 --- /dev/null +++ b/tests/ls/no-arg.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# make sure ls and 'ls -R' do the right thing when invoked with no arguments. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +mkdir -p dir/subdir || framework_failure_ +touch dir/subdir/file2 || framework_failure_ +ln -s f symlink || framework_failure_ + +cat > exp <<\EOF || framework_failure_ +dir +exp +out +symlink +EOF + + +ls -1 > out || fail=1 + +compare exp out || fail=1 + +cat > exp <<\EOF +.: +dir +exp +out +symlink + +./dir: +subdir + +./dir/subdir: +file2 +EOF + +ls -R1 > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/no-cap b/tests/ls/no-cap deleted file mode 100755 index 5e1e7887e..000000000 --- a/tests/ls/no-cap +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# ensure that an empty "ca=" attribute disables ls's capability-checking - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls -require_strace_ capget - -strace -e capget ls --color=always > /dev/null 2> out || fail=1 -$EGREP 'capget\(' out || skip_ "your ls doesn't call capget" - -rm -f out -eval "$(TERM=xterm dircolors -b | sed 's/ca=[^:]*:/ca=:/')" -strace -e capget ls --color=always > /dev/null 2> out || fail=1 - -$EGREP 'capget\(' out && fail=1 - -Exit $fail diff --git a/tests/ls/no-cap.sh b/tests/ls/no-cap.sh new file mode 100755 index 000000000..5e1e7887e --- /dev/null +++ b/tests/ls/no-cap.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# ensure that an empty "ca=" attribute disables ls's capability-checking + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls +require_strace_ capget + +strace -e capget ls --color=always > /dev/null 2> out || fail=1 +$EGREP 'capget\(' out || skip_ "your ls doesn't call capget" + +rm -f out +eval "$(TERM=xterm dircolors -b | sed 's/ca=[^:]*:/ca=:/')" +strace -e capget ls --color=always > /dev/null 2> out || fail=1 + +$EGREP 'capget\(' out && fail=1 + +Exit $fail diff --git a/tests/ls/proc-selinux-segfault b/tests/ls/proc-selinux-segfault deleted file mode 100755 index da17ec4f1..000000000 --- a/tests/ls/proc-selinux-segfault +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1 - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -f=/proc/sys -test -r $f || f=. - -ls -l $f > out || fail=1 - -Exit $fail diff --git a/tests/ls/proc-selinux-segfault.sh b/tests/ls/proc-selinux-segfault.sh new file mode 100755 index 000000000..da17ec4f1 --- /dev/null +++ b/tests/ls/proc-selinux-segfault.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1 + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +f=/proc/sys +test -r $f || f=. + +ls -l $f > out || fail=1 + +Exit $fail diff --git a/tests/ls/readdir-mountpoint-inode b/tests/ls/readdir-mountpoint-inode deleted file mode 100755 index d46208ba6..000000000 --- a/tests/ls/readdir-mountpoint-inode +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# ensure that ls -i works also for mount points - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -# We use --local here so as to not activate -# potentially very many remote mounts. -mount_points=$(df --local -P 2>&1 | sed -n 's,.*[0-9]% \(/.\),\1,p') -test -z "$mount_points" && - skip_ "this test requires a non-root mount point" - -# Given e.g., /dev/shm, produce the list of GNU ls options that -# let us list just that entry using readdir data from its parent: -# ls -i -I '[^s]*' -I 's[^h]*' -I 'sh[^m]*' -I 'shm?*' -I '.?*' \ -# -I '?' -I '??' /dev - -ls_ignore_options() -{ - name=$1 - opts="-I '.?*' -I '$name?*'" - while :; do - glob=$(echo "$name"|sed 's/\(.*\)\(.\)$/\1[^\2]*/') - opts="$opts -I '$glob'" - name=$(echo "$name"|sed 's/.$//') - test -z "$name" && break - glob=$(echo "$name"|sed 's/./?/g') - opts="$opts -I '$glob'" - done - echo "$opts" -} - -inode_via_readdir() -{ - mount_point=$1 - base=$(basename $mount_point) - case $base in - .*) skip_ 'mount point component starts with "."' ;; - *[*?]*) skip_ 'mount point component contains "?" or "*"' ;; - esac - opts=$(ls_ignore_options "$base") - parent_dir=$(dirname $mount_point) - eval "ls -i $opts $parent_dir" | sed 's/ .*//' -} - -for dir in $mount_points; do - readdir_inode=$(inode_via_readdir $dir) - test $? = 77 && continue - stat_inode=$(timeout 1 stat --format=%i $dir) - # If stat fails or says the inode is 0, skip $dir. - case $stat_inode in 0|'') continue;; esac - test "$readdir_inode" = "$stat_inode" || fail=1 -done - -Exit $fail diff --git a/tests/ls/readdir-mountpoint-inode.sh b/tests/ls/readdir-mountpoint-inode.sh new file mode 100755 index 000000000..d46208ba6 --- /dev/null +++ b/tests/ls/readdir-mountpoint-inode.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# ensure that ls -i works also for mount points + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +# We use --local here so as to not activate +# potentially very many remote mounts. +mount_points=$(df --local -P 2>&1 | sed -n 's,.*[0-9]% \(/.\),\1,p') +test -z "$mount_points" && + skip_ "this test requires a non-root mount point" + +# Given e.g., /dev/shm, produce the list of GNU ls options that +# let us list just that entry using readdir data from its parent: +# ls -i -I '[^s]*' -I 's[^h]*' -I 'sh[^m]*' -I 'shm?*' -I '.?*' \ +# -I '?' -I '??' /dev + +ls_ignore_options() +{ + name=$1 + opts="-I '.?*' -I '$name?*'" + while :; do + glob=$(echo "$name"|sed 's/\(.*\)\(.\)$/\1[^\2]*/') + opts="$opts -I '$glob'" + name=$(echo "$name"|sed 's/.$//') + test -z "$name" && break + glob=$(echo "$name"|sed 's/./?/g') + opts="$opts -I '$glob'" + done + echo "$opts" +} + +inode_via_readdir() +{ + mount_point=$1 + base=$(basename $mount_point) + case $base in + .*) skip_ 'mount point component starts with "."' ;; + *[*?]*) skip_ 'mount point component contains "?" or "*"' ;; + esac + opts=$(ls_ignore_options "$base") + parent_dir=$(dirname $mount_point) + eval "ls -i $opts $parent_dir" | sed 's/ .*//' +} + +for dir in $mount_points; do + readdir_inode=$(inode_via_readdir $dir) + test $? = 77 && continue + stat_inode=$(timeout 1 stat --format=%i $dir) + # If stat fails or says the inode is 0, skip $dir. + case $stat_inode in 0|'') continue;; esac + test "$readdir_inode" = "$stat_inode" || fail=1 +done + +Exit $fail diff --git a/tests/ls/recursive b/tests/ls/recursive deleted file mode 100755 index 79fdc7f30..000000000 --- a/tests/ls/recursive +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh -# 4.1.1 and 4.1.2 had a bug whereby some recursive listings -# didn't include a blank line between per-directory groups of files. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -mkdir x y a b c a/1 a/2 a/3 || framework_failure_ -touch f a/1/I a/1/II || framework_failure_ - - -# This first example is from Andreas Schwab's bug report. -ls -R1 a b c > out || fail=1 -cat < exp -a: -1 -2 -3 - -a/1: -I -II - -a/2: - -a/3: - -b: - -c: -EOF - -compare exp out || fail=1 - -rm -rf out exp -ls -R1 x y f > out || fail=1 -cat < exp -f - -x: - -y: -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/recursive.sh b/tests/ls/recursive.sh new file mode 100755 index 000000000..79fdc7f30 --- /dev/null +++ b/tests/ls/recursive.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# 4.1.1 and 4.1.2 had a bug whereby some recursive listings +# didn't include a blank line between per-directory groups of files. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +mkdir x y a b c a/1 a/2 a/3 || framework_failure_ +touch f a/1/I a/1/II || framework_failure_ + + +# This first example is from Andreas Schwab's bug report. +ls -R1 a b c > out || fail=1 +cat < exp +a: +1 +2 +3 + +a/1: +I +II + +a/2: + +a/3: + +b: + +c: +EOF + +compare exp out || fail=1 + +rm -rf out exp +ls -R1 x y f > out || fail=1 +cat < exp +f + +x: + +y: +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/root-rel-symlink-color b/tests/ls/root-rel-symlink-color deleted file mode 100755 index d7954323e..000000000 --- a/tests/ls/root-rel-symlink-color +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Exercise the 8.17 ls bug with coloring relative-named symlinks in "/". - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -symlink_to_rel= -for i in /*; do - # Skip non-symlinks: - env test -h "$i" || continue - - # Skip dangling symlinks: - env test -e "$i" || continue - - # Skip any symlink-to-absolute-name: - case $(readlink "$i") in /*) continue ;; esac - - symlink_to_rel=$i - break -done - -test -z "$symlink_to_rel" \ - && skip_ no relative symlink in / - -e='\33' -color_code='01;36' -c_pre="$e[0m$e[${color_code}m" -c_post="$e[0m" -printf "$c_pre$symlink_to_rel$c_post\n" > exp || framework_failure_ - -env TERM=xterm LS_COLORS="ln=$color_code:or=1;31;42" \ - ls -d --color=always "$symlink_to_rel" > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/root-rel-symlink-color.sh b/tests/ls/root-rel-symlink-color.sh new file mode 100755 index 000000000..d7954323e --- /dev/null +++ b/tests/ls/root-rel-symlink-color.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Exercise the 8.17 ls bug with coloring relative-named symlinks in "/". + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +symlink_to_rel= +for i in /*; do + # Skip non-symlinks: + env test -h "$i" || continue + + # Skip dangling symlinks: + env test -e "$i" || continue + + # Skip any symlink-to-absolute-name: + case $(readlink "$i") in /*) continue ;; esac + + symlink_to_rel=$i + break +done + +test -z "$symlink_to_rel" \ + && skip_ no relative symlink in / + +e='\33' +color_code='01;36' +c_pre="$e[0m$e[${color_code}m" +c_post="$e[0m" +printf "$c_pre$symlink_to_rel$c_post\n" > exp || framework_failure_ + +env TERM=xterm LS_COLORS="ln=$color_code:or=1;31;42" \ + ls -d --color=always "$symlink_to_rel" > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/rt-1 b/tests/ls/rt-1 deleted file mode 100755 index f7d78df65..000000000 --- a/tests/ls/rt-1 +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# Make sure name is used as secondary key when sorting on mtime or ctime. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls touch - -date=1998-01-15 - -touch -d "$date" c || framework_failure_ -touch -d "$date" a || framework_failure_ -touch -d "$date" b || framework_failure_ - - -ls -1t a b c > out || fail=1 -cat < exp -a -b -c -EOF -compare exp out || fail=1 - -rm -rf out exp -ls -1rt a b c > out || fail=1 -cat < exp -c -b -a -EOF -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/rt-1.sh b/tests/ls/rt-1.sh new file mode 100755 index 000000000..f7d78df65 --- /dev/null +++ b/tests/ls/rt-1.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Make sure name is used as secondary key when sorting on mtime or ctime. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls touch + +date=1998-01-15 + +touch -d "$date" c || framework_failure_ +touch -d "$date" a || framework_failure_ +touch -d "$date" b || framework_failure_ + + +ls -1t a b c > out || fail=1 +cat < exp +a +b +c +EOF +compare exp out || fail=1 + +rm -rf out exp +ls -1rt a b c > out || fail=1 +cat < exp +c +b +a +EOF +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/slink-acl b/tests/ls/slink-acl deleted file mode 100755 index ae9af5039..000000000 --- a/tests/ls/slink-acl +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# verify that ls -lL works when applied to a symlink to an ACL'd file - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -require_setfacl_ - -touch k || framework_failure_ -setfacl -m user::r-- k || framework_failure_ -ln -s k s || framework_failure_ - -set _ $(ls -Log s); shift; link=$1 -set _ $(ls -og k); shift; reg=$1 - -test "$link" = "$reg" || fail=1 - -Exit $fail diff --git a/tests/ls/slink-acl.sh b/tests/ls/slink-acl.sh new file mode 100755 index 000000000..ae9af5039 --- /dev/null +++ b/tests/ls/slink-acl.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# verify that ls -lL works when applied to a symlink to an ACL'd file + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +require_setfacl_ + +touch k || framework_failure_ +setfacl -m user::r-- k || framework_failure_ +ln -s k s || framework_failure_ + +set _ $(ls -Log s); shift; link=$1 +set _ $(ls -og k); shift; reg=$1 + +test "$link" = "$reg" || fail=1 + +Exit $fail diff --git a/tests/ls/stat-dtype b/tests/ls/stat-dtype deleted file mode 100755 index b84d5d51a..000000000 --- a/tests/ls/stat-dtype +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# Ensure that ls --file-type does not call stat unnecessarily. -# Also check for the dtype-related (and fs-type dependent) bug -# in coreutils-6.0 that made ls -CF columns misaligned. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# The trick is to create an un-stat'able symlink and to see if ls -# can report its type nonetheless, using dirent.d_type. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -# Skip this test unless "." is on a file system with useful d_type info. -# FIXME: This uses "ls -p" to decide whether to test "ls" with other options, -# but if ls's d_type code is buggy then "ls -p" might be buggy too. -mkdir -p c/d || framework_failure_ -chmod a-x c || framework_failure_ -if test "X$(ls -p c 2>&1)" != Xd/; then - skip_ "'.' is not on a suitable file system for this test" -fi - -mkdir d || framework_failure_ -ln -s / d/s || framework_failure_ -chmod 600 d || framework_failure_ - -mkdir -p e/a2345 e/b || framework_failure_ -chmod 600 e || framework_failure_ - - -ls --file-type d > out || fail=1 -cat <<\EOF > exp || fail=1 -s@ -EOF - -compare exp out || fail=1 - -rm -f out exp -# Check for the ls -CF misaligned-columns bug: -ls -CF e > out || fail=1 - -# coreutils-6.0 would print two spaces after the first slash, -# rather than the appropriate TAB. -printf 'a2345/\tb/\n' > exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/stat-dtype.sh b/tests/ls/stat-dtype.sh new file mode 100755 index 000000000..b84d5d51a --- /dev/null +++ b/tests/ls/stat-dtype.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Ensure that ls --file-type does not call stat unnecessarily. +# Also check for the dtype-related (and fs-type dependent) bug +# in coreutils-6.0 that made ls -CF columns misaligned. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# The trick is to create an un-stat'able symlink and to see if ls +# can report its type nonetheless, using dirent.d_type. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +# Skip this test unless "." is on a file system with useful d_type info. +# FIXME: This uses "ls -p" to decide whether to test "ls" with other options, +# but if ls's d_type code is buggy then "ls -p" might be buggy too. +mkdir -p c/d || framework_failure_ +chmod a-x c || framework_failure_ +if test "X$(ls -p c 2>&1)" != Xd/; then + skip_ "'.' is not on a suitable file system for this test" +fi + +mkdir d || framework_failure_ +ln -s / d/s || framework_failure_ +chmod 600 d || framework_failure_ + +mkdir -p e/a2345 e/b || framework_failure_ +chmod 600 e || framework_failure_ + + +ls --file-type d > out || fail=1 +cat <<\EOF > exp || fail=1 +s@ +EOF + +compare exp out || fail=1 + +rm -f out exp +# Check for the ls -CF misaligned-columns bug: +ls -CF e > out || fail=1 + +# coreutils-6.0 would print two spaces after the first slash, +# rather than the appropriate TAB. +printf 'a2345/\tb/\n' > exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/stat-failed b/tests/ls/stat-failed deleted file mode 100755 index 464406bd5..000000000 --- a/tests/ls/stat-failed +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Verify that ls works properly when it fails to stat a file that is -# not mentioned on the command line. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls -skip_if_root_ - -mkdir d || framework_failure_ -ln -s / d/s || framework_failure_ -chmod 600 d || framework_failure_ - - -ls -Log d > out -test $? = 1 || fail=1 - -cat <<\EOF > exp || fail=1 -total 0 -?????????? ? ? ? s -EOF - -sed 's/^l/?/' out | compare exp - || fail=1 - -# Ensure that the offsets in --dired output are accurate. -rm -f out exp -ls --dired -l d > out && fail=1 - -cat <<\EOF > exp || fail=1 - total 0 - ?????????? ? ? ? ? ? s -//DIRED// 44 45 -//DIRED-OPTIONS// --quoting-style=literal -EOF - -sed 's/^ l/ ?/' out | compare exp - || fail=1 - -Exit $fail diff --git a/tests/ls/stat-failed.sh b/tests/ls/stat-failed.sh new file mode 100755 index 000000000..464406bd5 --- /dev/null +++ b/tests/ls/stat-failed.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Verify that ls works properly when it fails to stat a file that is +# not mentioned on the command line. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls +skip_if_root_ + +mkdir d || framework_failure_ +ln -s / d/s || framework_failure_ +chmod 600 d || framework_failure_ + + +ls -Log d > out +test $? = 1 || fail=1 + +cat <<\EOF > exp || fail=1 +total 0 +?????????? ? ? ? s +EOF + +sed 's/^l/?/' out | compare exp - || fail=1 + +# Ensure that the offsets in --dired output are accurate. +rm -f out exp +ls --dired -l d > out && fail=1 + +cat <<\EOF > exp || fail=1 + total 0 + ?????????? ? ? ? ? ? s +//DIRED// 44 45 +//DIRED-OPTIONS// --quoting-style=literal +EOF + +sed 's/^ l/ ?/' out | compare exp - || fail=1 + +Exit $fail diff --git a/tests/ls/stat-free-color b/tests/ls/stat-free-color deleted file mode 100755 index daff2eb5c..000000000 --- a/tests/ls/stat-free-color +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# Show that --color need not use stat, as long as we have d_type support. - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls -require_strace_ stat -require_dirent_d_type_ - -for i in 1 2 3; do - ln -s nowhere dangle-$i || framework_failure_ -done - -# Disable enough features via LS_COLORS so that ls --color -# can do its job without calling stat (other than the obligatory -# one-call-per-command-line argument). -cat < color-without-stat || framework_failure_ -RESET 0 -DIR 01;34 -LINK 01;36 -FIFO 40;33 -SOCK 01;35 -DOOR 01;35 -BLK 40;33;01 -CHR 40;33;01 -ORPHAN 00 -SETUID 00 -SETGID 00 -CAPABILITY 00 -STICKY_OTHER_WRITABLE 00 -OTHER_WRITABLE 00 -STICKY 00 -EXEC 00 -MULTIHARDLINK 00 -EOF -eval $(dircolors -b color-without-stat) - -# The system may perform additional stat-like calls before main. -# To avoid counting those, first get a baseline count by running -# ls with only the --help option. Then, compare that with the -# invocation under test. -strace -o log-help -e stat,lstat,stat64,lstat64 ls --help >/dev/null || fail=1 -n_lines_help=$(wc -l < log-help) - -strace -o log -e stat,lstat,stat64,lstat64 ls --color=always . || fail=1 -n_lines=$(wc -l < log) - -n_stat=$(expr $n_lines - $n_lines_help) - -# Expect one or two stat calls. -case $n_stat in - 1) ;; - *) fail=1; head -n30 log* ;; -esac - -Exit $fail diff --git a/tests/ls/stat-free-color.sh b/tests/ls/stat-free-color.sh new file mode 100755 index 000000000..daff2eb5c --- /dev/null +++ b/tests/ls/stat-free-color.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Show that --color need not use stat, as long as we have d_type support. + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls +require_strace_ stat +require_dirent_d_type_ + +for i in 1 2 3; do + ln -s nowhere dangle-$i || framework_failure_ +done + +# Disable enough features via LS_COLORS so that ls --color +# can do its job without calling stat (other than the obligatory +# one-call-per-command-line argument). +cat < color-without-stat || framework_failure_ +RESET 0 +DIR 01;34 +LINK 01;36 +FIFO 40;33 +SOCK 01;35 +DOOR 01;35 +BLK 40;33;01 +CHR 40;33;01 +ORPHAN 00 +SETUID 00 +SETGID 00 +CAPABILITY 00 +STICKY_OTHER_WRITABLE 00 +OTHER_WRITABLE 00 +STICKY 00 +EXEC 00 +MULTIHARDLINK 00 +EOF +eval $(dircolors -b color-without-stat) + +# The system may perform additional stat-like calls before main. +# To avoid counting those, first get a baseline count by running +# ls with only the --help option. Then, compare that with the +# invocation under test. +strace -o log-help -e stat,lstat,stat64,lstat64 ls --help >/dev/null || fail=1 +n_lines_help=$(wc -l < log-help) + +strace -o log -e stat,lstat,stat64,lstat64 ls --color=always . || fail=1 +n_lines=$(wc -l < log) + +n_stat=$(expr $n_lines - $n_lines_help) + +# Expect one or two stat calls. +case $n_stat in + 1) ;; + *) fail=1; head -n30 log* ;; +esac + +Exit $fail diff --git a/tests/ls/stat-free-symlinks b/tests/ls/stat-free-symlinks deleted file mode 100755 index 8e04e2e8c..000000000 --- a/tests/ls/stat-free-symlinks +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# ensure that ls does not stat a symlink in an unusual case - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls -require_strace_ stat - -touch x || framework_failure_ -chmod a+x x || framework_failure_ -ln -s x link-to-x || framework_failure_ - - -# ls from coreutils 6.9 would unnecessarily stat a symlink in an unusual case: -# When not coloring orphan and missing entries, and without ln=target, -# ensure that ls -F (or -d, or -l: i.e., when not dereferencing) -# does not stat a symlink to directory, and does still color that -# symlink and an executable file properly. - -LS_COLORS='or=0:mi=0:ex=01;32:ln=01;35' \ - strace -qe stat ls -F --color=always x link-to-x > out.tmp 2> err || fail -# Elide info messages strace can send to stdout of the form: -# [ Process PID=1234 runs in 32 bit mode. ] -sed '/Process PID=/d' out.tmp > out - -# With coreutils 6.9 and earlier, this file would contain a -# line showing ls had called stat on "x". -grep '^stat("x"' err && fail=1 - -# Check that output is colorized, as requested, too. -{ - printf '\033[0m\033[01;35mlink-to-x\033[0m@\n' - printf '\033[01;32mx\033[0m*\n' -} > exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/stat-free-symlinks.sh b/tests/ls/stat-free-symlinks.sh new file mode 100755 index 000000000..8e04e2e8c --- /dev/null +++ b/tests/ls/stat-free-symlinks.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ensure that ls does not stat a symlink in an unusual case + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls +require_strace_ stat + +touch x || framework_failure_ +chmod a+x x || framework_failure_ +ln -s x link-to-x || framework_failure_ + + +# ls from coreutils 6.9 would unnecessarily stat a symlink in an unusual case: +# When not coloring orphan and missing entries, and without ln=target, +# ensure that ls -F (or -d, or -l: i.e., when not dereferencing) +# does not stat a symlink to directory, and does still color that +# symlink and an executable file properly. + +LS_COLORS='or=0:mi=0:ex=01;32:ln=01;35' \ + strace -qe stat ls -F --color=always x link-to-x > out.tmp 2> err || fail +# Elide info messages strace can send to stdout of the form: +# [ Process PID=1234 runs in 32 bit mode. ] +sed '/Process PID=/d' out.tmp > out + +# With coreutils 6.9 and earlier, this file would contain a +# line showing ls had called stat on "x". +grep '^stat("x"' err && fail=1 + +# Check that output is colorized, as requested, too. +{ + printf '\033[0m\033[01;35mlink-to-x\033[0m@\n' + printf '\033[01;32mx\033[0m*\n' +} > exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/ls/stat-vs-dirent b/tests/ls/stat-vs-dirent deleted file mode 100755 index 1dd6e6621..000000000 --- a/tests/ls/stat-vs-dirent +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Ensure that d_ino (from ls -di) and st_ino (from stat --format=%i) match. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - - -root_dev_ino=$(stat --format=%d-%i /) -t=$(pwd) -while :; do - ls -i1 "$t" > tmp - if test $? = 0; then - # Extract the inode number from the first line of output from ls -i1. - # This value comes from dirent.d_ino, on systems with d_ino support. - d_ino=$(sed -n '1s/^ *\([0-9][0-9]*\) .*/\1/p;q' tmp) - - # Extract the name of the corresponding directory entry. - file=$(sed -n '1s/^ *[0-9][0-9]* *//p;q' tmp) - - # Get its inode number (stat.st_ino) via stat(1)'s call to lstat. - st_ino=$(stat --format=%i "$t/$file") - - # Make sure that they are the same. - # We know from experience that there may be mismatches on some - # buggy file systems, at mount points. - # Note that when a directory contains only entries whose names - # start with ".", d_ino and file will both be empty. In that case, - # skip the test. - if test -n "$d_ino" && test "$d_ino" != "$st_ino"; then - echo "$0: test failed: $t/$file: d_ino($d_ino) != st_ino($st_ino) - This may indicate a flaw in your kernel or file system implementation. - The flaw isn't serious for coreutils, but it might break other tools, - so you should report it to your operating system vendor." 1>&2 - - fail=1 - break - fi - fi - - t=$(cd "$t/.."; pwd) - dev_ino=$(stat --format=%d-%i "$t") - test $dev_ino = $root_dev_ino && break -done - -Exit $fail diff --git a/tests/ls/stat-vs-dirent.sh b/tests/ls/stat-vs-dirent.sh new file mode 100755 index 000000000..1dd6e6621 --- /dev/null +++ b/tests/ls/stat-vs-dirent.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# Ensure that d_ino (from ls -di) and st_ino (from stat --format=%i) match. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + + +root_dev_ino=$(stat --format=%d-%i /) +t=$(pwd) +while :; do + ls -i1 "$t" > tmp + if test $? = 0; then + # Extract the inode number from the first line of output from ls -i1. + # This value comes from dirent.d_ino, on systems with d_ino support. + d_ino=$(sed -n '1s/^ *\([0-9][0-9]*\) .*/\1/p;q' tmp) + + # Extract the name of the corresponding directory entry. + file=$(sed -n '1s/^ *[0-9][0-9]* *//p;q' tmp) + + # Get its inode number (stat.st_ino) via stat(1)'s call to lstat. + st_ino=$(stat --format=%i "$t/$file") + + # Make sure that they are the same. + # We know from experience that there may be mismatches on some + # buggy file systems, at mount points. + # Note that when a directory contains only entries whose names + # start with ".", d_ino and file will both be empty. In that case, + # skip the test. + if test -n "$d_ino" && test "$d_ino" != "$st_ino"; then + echo "$0: test failed: $t/$file: d_ino($d_ino) != st_ino($st_ino) + This may indicate a flaw in your kernel or file system implementation. + The flaw isn't serious for coreutils, but it might break other tools, + so you should report it to your operating system vendor." 1>&2 + + fail=1 + break + fi + fi + + t=$(cd "$t/.."; pwd) + dev_ino=$(stat --format=%d-%i "$t") + test $dev_ino = $root_dev_ino && break +done + +Exit $fail diff --git a/tests/ls/symlink-slash b/tests/ls/symlink-slash deleted file mode 100755 index 28c7d32b2..000000000 --- a/tests/ls/symlink-slash +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Do dereference a symlink arg if its name is written with a trailing slash. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -mkdir dir || framework_failure_ -ln -s dir symlink || framework_failure_ - -set $(ls -l symlink/) - -# Prior to fileutils-4.0k, the following would have output '... symlink -> dir'. -test "$*" = 'total 0' && : || fail=1 - -Exit $fail diff --git a/tests/ls/symlink-slash.sh b/tests/ls/symlink-slash.sh new file mode 100755 index 000000000..28c7d32b2 --- /dev/null +++ b/tests/ls/symlink-slash.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Do dereference a symlink arg if its name is written with a trailing slash. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +mkdir dir || framework_failure_ +ln -s dir symlink || framework_failure_ + +set $(ls -l symlink/) + +# Prior to fileutils-4.0k, the following would have output '... symlink -> dir'. +test "$*" = 'total 0' && : || fail=1 + +Exit $fail diff --git a/tests/ls/time-style-diag b/tests/ls/time-style-diag deleted file mode 100755 index ae41c9361..000000000 --- a/tests/ls/time-style-diag +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Ensure that an invalid --time-style=ARG is diagnosed the way we want. - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -ls -l --time-style=XX > out 2> err -test $? = 2 || fail=1 - -cat <<\EOF > exp || fail=1 -ls: invalid argument 'XX' for 'time style' -Valid arguments are: - - [posix-]full-iso - - [posix-]long-iso - - [posix-]iso - - [posix-]locale - - +FORMAT (e.g., +%H:%M) for a 'date'-style format -Try 'ls --help' for more information. -EOF - -compare exp err || fail=1 -compare /dev/null out || fail=1 - -Exit $fail diff --git a/tests/ls/time-style-diag.sh b/tests/ls/time-style-diag.sh new file mode 100755 index 000000000..ae41c9361 --- /dev/null +++ b/tests/ls/time-style-diag.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Ensure that an invalid --time-style=ARG is diagnosed the way we want. + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +ls -l --time-style=XX > out 2> err +test $? = 2 || fail=1 + +cat <<\EOF > exp || fail=1 +ls: invalid argument 'XX' for 'time style' +Valid arguments are: + - [posix-]full-iso + - [posix-]long-iso + - [posix-]iso + - [posix-]locale + - +FORMAT (e.g., +%H:%M) for a 'date'-style format +Try 'ls --help' for more information. +EOF + +compare exp err || fail=1 +compare /dev/null out || fail=1 + +Exit $fail diff --git a/tests/ls/x-option b/tests/ls/x-option deleted file mode 100755 index 38faa72b8..000000000 --- a/tests/ls/x-option +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Exercise the -x option. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -mkdir subdir || framework_failure_ -touch subdir/b || framework_failure_ -touch subdir/a || framework_failure_ - - -# Coreutils 6.8 and 6.9 would output this in the wrong order. -ls -x subdir > out || fail=1 -ls -rx subdir >> out || fail=1 -cat <<\EOF > exp || fail=1 -a b -b a -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/ls/x-option.sh b/tests/ls/x-option.sh new file mode 100755 index 000000000..38faa72b8 --- /dev/null +++ b/tests/ls/x-option.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Exercise the -x option. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +mkdir subdir || framework_failure_ +touch subdir/b || framework_failure_ +touch subdir/a || framework_failure_ + + +# Coreutils 6.8 and 6.9 would output this in the wrong order. +ls -x subdir > out || fail=1 +ls -rx subdir >> out || fail=1 +cat <<\EOF > exp || fail=1 +a b +b a +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/arch b/tests/misc/arch deleted file mode 100755 index e1d730897..000000000 --- a/tests/misc/arch +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Ensure that arch output is equal to uname -m - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ arch - -require_built_ arch - -arch > out || fail=1 -uname -m > exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/arch.sh b/tests/misc/arch.sh new file mode 100755 index 000000000..e1d730897 --- /dev/null +++ b/tests/misc/arch.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Ensure that arch output is equal to uname -m + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ arch + +require_built_ arch + +arch > out || fail=1 +uname -m > exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/base64 b/tests/misc/base64 deleted file mode 100755 index 44a792754..000000000 --- a/tests/misc/base64 +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/perl -# Exercise base64. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# Return the encoding of a string of N 'a's. -sub enc($) -{ - my ($n) = @_; - my %remainder = ( 0 => '', 1 => 'YQ==', 2 => 'YWE=' ); - return 'YWFh' x ($n / 3) . $remainder{$n % 3}; -} - -# Construct an encoded string of length 4KB, using 3K "a"s. -my $a3k = enc 3072; -my @a3k_nl; -# A few copies, each with different number of newlines at the start. -for my $k (0..3) - { - (my $t = $a3k) =~ s/^/"\n"x $k/e; - push @a3k_nl, $t; - } - -# Return a copy of S, with newlines inserted every WIDTH bytes. -# Ensure that the result (if not the empty string) is newline-terminated. -sub wrap($$) -{ - my ($s, $width) = @_; - $s =~ s/(.{$width})/$1\n/g; - substr ($s, -1, 1) ne "\n" - and $s .= "\n"; - return $s; -} - -my @Tests = - ( - ['empty', {IN=>''}, {OUT=>""}], - ['inout', {IN=>'a'}, {OUT=>"YQ==\n"}], - ['wrap', '--wrap 0', {IN=>'foo'}, {OUT=>'Zm9v'}], - ['wrap5-39', '--wrap=5', {IN=>'a' x 39}, {OUT=>wrap enc(39),5}], - ['wrap5-40', '--wrap=5', {IN=>'a' x 40}, {OUT=>wrap enc(40),5}], - ['wrap5-41', '--wrap=5', {IN=>'a' x 41}, {OUT=>wrap enc(41),5}], - ['wrap5-42', '--wrap=5', {IN=>'a' x 42}, {OUT=>wrap enc(42),5}], - ['wrap5-43', '--wrap=5', {IN=>'a' x 43}, {OUT=>wrap enc(43),5}], - ['wrap5-44', '--wrap=5', {IN=>'a' x 44}, {OUT=>wrap enc(44),5}], - ['wrap5-45', '--wrap=5', {IN=>'a' x 45}, {OUT=>wrap enc(45),5}], - ['wrap5-46', '--wrap=5', {IN=>'a' x 46}, {OUT=>wrap enc(46),5}], - - ['buf-1', '--decode', {IN=>enc 1}, {OUT=>'a' x 1}], - ['buf-2', '--decode', {IN=>enc 2}, {OUT=>'a' x 2}], - ['buf-3', '--decode', {IN=>enc 3}, {OUT=>'a' x 3}], - ['buf-4', '--decode', {IN=>enc 4}, {OUT=>'a' x 4}], - # 4KB worth of input. - ['buf-4k0', '--decode', {IN=>enc 3072+0}, {OUT=>'a' x (3072+0)}], - ['buf-4k1', '--decode', {IN=>enc 3072+1}, {OUT=>'a' x (3072+1)}], - ['buf-4k2', '--decode', {IN=>enc 3072+2}, {OUT=>'a' x (3072+2)}], - ['buf-4k3', '--decode', {IN=>enc 3072+3}, {OUT=>'a' x (3072+3)}], - ['buf-4km1','--decode', {IN=>enc 3072-1}, {OUT=>'a' x (3072-1)}], - ['buf-4km2','--decode', {IN=>enc 3072-2}, {OUT=>'a' x (3072-2)}], - ['buf-4km3','--decode', {IN=>enc 3072-3}, {OUT=>'a' x (3072-3)}], - ['buf-4km4','--decode', {IN=>enc 3072-4}, {OUT=>'a' x (3072-4)}], - - # Exercise the case in which the final base-64 byte is - # in a buffer all by itself. - ['b4k-1', '--decode', {IN=>$a3k_nl[1]}, {OUT=>'a' x (3072+0)}], - ['b4k-2', '--decode', {IN=>$a3k_nl[2]}, {OUT=>'a' x (3072+0)}], - ['b4k-3', '--decode', {IN=>$a3k_nl[3]}, {OUT=>'a' x (3072+0)}], - - ['baddecode', '--decode', {IN=>'a'}, {OUT=>""}, - {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], - ['baddecode2', '--decode', {IN=>'ab'}, {OUT=>"i"}, - {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], - ['baddecode3', '--decode', {IN=>'Zzz'}, {OUT=>"g<"}, - {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], - ['baddecode4', '--decode', {IN=>'Zz='}, {OUT=>"g"}, - {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], - ['baddecode5', '--decode', {IN=>'Z==='}, {OUT=>""}, - {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}] - ); - -# For each non-failing test, create a --decode test using the -# expected output as input. Also, add tests inserting newlines. -my @new; -foreach my $t (@Tests) - { - my $exit_val; - my $in; - my @out; - - # If the test has a single option of "--decode", then skip it. - !ref $t->[1] && $t->[1] eq '--decode' - and next; - - foreach my $e (@$t) - { - ref $e && ref $e eq 'HASH' - or next; - defined $e->{EXIT} - and $exit_val = $e->{EXIT}; - defined $e->{IN} - and $in = $e->{IN}; - if (defined $e->{OUT}) - { - my $t = $e->{OUT}; - push @out, $t; - my $len = length $t; - foreach my $i (0..$len) - { - my $u = $t; - substr ($u, $i, 0) = "\n"; - push @out, $u; - 10 <= $i - and last; - } - } - } - $exit_val - and next; - - my $i = 0; - foreach my $o (@out) - { - push @new, ["d$i-$t->[0]", '--decode', {IN => $o}, {OUT => $in}]; - ++$i; - } - } -push @Tests, @new; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'base64'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/base64.pl b/tests/misc/base64.pl new file mode 100755 index 000000000..44a792754 --- /dev/null +++ b/tests/misc/base64.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl +# Exercise base64. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# Return the encoding of a string of N 'a's. +sub enc($) +{ + my ($n) = @_; + my %remainder = ( 0 => '', 1 => 'YQ==', 2 => 'YWE=' ); + return 'YWFh' x ($n / 3) . $remainder{$n % 3}; +} + +# Construct an encoded string of length 4KB, using 3K "a"s. +my $a3k = enc 3072; +my @a3k_nl; +# A few copies, each with different number of newlines at the start. +for my $k (0..3) + { + (my $t = $a3k) =~ s/^/"\n"x $k/e; + push @a3k_nl, $t; + } + +# Return a copy of S, with newlines inserted every WIDTH bytes. +# Ensure that the result (if not the empty string) is newline-terminated. +sub wrap($$) +{ + my ($s, $width) = @_; + $s =~ s/(.{$width})/$1\n/g; + substr ($s, -1, 1) ne "\n" + and $s .= "\n"; + return $s; +} + +my @Tests = + ( + ['empty', {IN=>''}, {OUT=>""}], + ['inout', {IN=>'a'}, {OUT=>"YQ==\n"}], + ['wrap', '--wrap 0', {IN=>'foo'}, {OUT=>'Zm9v'}], + ['wrap5-39', '--wrap=5', {IN=>'a' x 39}, {OUT=>wrap enc(39),5}], + ['wrap5-40', '--wrap=5', {IN=>'a' x 40}, {OUT=>wrap enc(40),5}], + ['wrap5-41', '--wrap=5', {IN=>'a' x 41}, {OUT=>wrap enc(41),5}], + ['wrap5-42', '--wrap=5', {IN=>'a' x 42}, {OUT=>wrap enc(42),5}], + ['wrap5-43', '--wrap=5', {IN=>'a' x 43}, {OUT=>wrap enc(43),5}], + ['wrap5-44', '--wrap=5', {IN=>'a' x 44}, {OUT=>wrap enc(44),5}], + ['wrap5-45', '--wrap=5', {IN=>'a' x 45}, {OUT=>wrap enc(45),5}], + ['wrap5-46', '--wrap=5', {IN=>'a' x 46}, {OUT=>wrap enc(46),5}], + + ['buf-1', '--decode', {IN=>enc 1}, {OUT=>'a' x 1}], + ['buf-2', '--decode', {IN=>enc 2}, {OUT=>'a' x 2}], + ['buf-3', '--decode', {IN=>enc 3}, {OUT=>'a' x 3}], + ['buf-4', '--decode', {IN=>enc 4}, {OUT=>'a' x 4}], + # 4KB worth of input. + ['buf-4k0', '--decode', {IN=>enc 3072+0}, {OUT=>'a' x (3072+0)}], + ['buf-4k1', '--decode', {IN=>enc 3072+1}, {OUT=>'a' x (3072+1)}], + ['buf-4k2', '--decode', {IN=>enc 3072+2}, {OUT=>'a' x (3072+2)}], + ['buf-4k3', '--decode', {IN=>enc 3072+3}, {OUT=>'a' x (3072+3)}], + ['buf-4km1','--decode', {IN=>enc 3072-1}, {OUT=>'a' x (3072-1)}], + ['buf-4km2','--decode', {IN=>enc 3072-2}, {OUT=>'a' x (3072-2)}], + ['buf-4km3','--decode', {IN=>enc 3072-3}, {OUT=>'a' x (3072-3)}], + ['buf-4km4','--decode', {IN=>enc 3072-4}, {OUT=>'a' x (3072-4)}], + + # Exercise the case in which the final base-64 byte is + # in a buffer all by itself. + ['b4k-1', '--decode', {IN=>$a3k_nl[1]}, {OUT=>'a' x (3072+0)}], + ['b4k-2', '--decode', {IN=>$a3k_nl[2]}, {OUT=>'a' x (3072+0)}], + ['b4k-3', '--decode', {IN=>$a3k_nl[3]}, {OUT=>'a' x (3072+0)}], + + ['baddecode', '--decode', {IN=>'a'}, {OUT=>""}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode2', '--decode', {IN=>'ab'}, {OUT=>"i"}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode3', '--decode', {IN=>'Zzz'}, {OUT=>"g<"}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode4', '--decode', {IN=>'Zz='}, {OUT=>"g"}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}], + ['baddecode5', '--decode', {IN=>'Z==='}, {OUT=>""}, + {ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}] + ); + +# For each non-failing test, create a --decode test using the +# expected output as input. Also, add tests inserting newlines. +my @new; +foreach my $t (@Tests) + { + my $exit_val; + my $in; + my @out; + + # If the test has a single option of "--decode", then skip it. + !ref $t->[1] && $t->[1] eq '--decode' + and next; + + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' + or next; + defined $e->{EXIT} + and $exit_val = $e->{EXIT}; + defined $e->{IN} + and $in = $e->{IN}; + if (defined $e->{OUT}) + { + my $t = $e->{OUT}; + push @out, $t; + my $len = length $t; + foreach my $i (0..$len) + { + my $u = $t; + substr ($u, $i, 0) = "\n"; + push @out, $u; + 10 <= $i + and last; + } + } + } + $exit_val + and next; + + my $i = 0; + foreach my $o (@out) + { + push @new, ["d$i-$t->[0]", '--decode', {IN => $o}, {OUT => $in}]; + ++$i; + } + } +push @Tests, @new; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'base64'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/basename b/tests/misc/basename deleted file mode 100755 index d0ab57bf6..000000000 --- a/tests/misc/basename +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/perl -# Test basename. -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; -use File::stat; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $stat_single = stat('/'); -my $stat_double = stat('//'); -my $double_slash = ($stat_single->dev == $stat_double->dev - && $stat_single->ino == $stat_double->ino) ? '/' : '//'; - -my $prog = 'basename'; - -my @Tests = - ( - ['fail-1', {ERR => "$prog: missing operand\n" - . "Try '$prog --help' for more information.\n"}, {EXIT => '1'}], - ['fail-2', qw(a b c), {ERR => "$prog: extra operand 'c'\n" - . "Try '$prog --help' for more information.\n"}, {EXIT => '1'}], - - ['a', qw(d/f), {OUT => 'f'}], - ['b', qw(/d/f), {OUT => 'f'}], - ['c', qw(d/f/), {OUT => 'f'}], - ['d', qw(d/f//), {OUT => 'f'}], - ['e', qw(f), {OUT => 'f'}], - ['f', qw(/), {OUT => '/'}], - ['g', qw(//), {OUT => "$double_slash"}], - ['h', qw(///), {OUT => '/'}], - ['i', qw(///a///), {OUT => 'a'}], - ['j', qw(''), {OUT => ''}], - ['k', qw(aa a), {OUT => 'a'}], - ['l', qw(-a a b), {OUT => "a\nb"}], - ['m', qw(-s a aa ba ab), {OUT => "a\nb\nab"}], - ['n', qw(a-a -a), {OUT => 'a'}], - ['1', qw(f.s .s), {OUT => 'f'}], - ['2', qw(fs s), {OUT => 'f'}], - ['3', qw(fs fs), {OUT => 'fs'}], - ['4', qw(fs/ s), {OUT => 'f'}], - ['5', qw(dir/file.suf .suf), {OUT => 'file'}], - ['6', qw(// /), {OUT => "$double_slash"}], - ['7', qw(// //), {OUT => "$double_slash"}], - ['8', qw(fs x), {OUT => 'fs'}], - ['9', qw(fs ''), {OUT => 'fs'}], - ['10', qw(fs/ s/), {OUT => 'fs'}], - ); - -# Append a newline to end of each expected 'OUT' string. -my $t; -foreach $t (@Tests) - { - my $arg1 = $t->[1]; - my $e; - foreach $e (@$t) - { - $e->{OUT} = "$e->{OUT}\n" - if ref $e eq 'HASH' and exists $e->{OUT}; - } - } - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/basename.pl b/tests/misc/basename.pl new file mode 100755 index 000000000..d0ab57bf6 --- /dev/null +++ b/tests/misc/basename.pl @@ -0,0 +1,83 @@ +#!/usr/bin/perl +# Test basename. +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use File::stat; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $stat_single = stat('/'); +my $stat_double = stat('//'); +my $double_slash = ($stat_single->dev == $stat_double->dev + && $stat_single->ino == $stat_double->ino) ? '/' : '//'; + +my $prog = 'basename'; + +my @Tests = + ( + ['fail-1', {ERR => "$prog: missing operand\n" + . "Try '$prog --help' for more information.\n"}, {EXIT => '1'}], + ['fail-2', qw(a b c), {ERR => "$prog: extra operand 'c'\n" + . "Try '$prog --help' for more information.\n"}, {EXIT => '1'}], + + ['a', qw(d/f), {OUT => 'f'}], + ['b', qw(/d/f), {OUT => 'f'}], + ['c', qw(d/f/), {OUT => 'f'}], + ['d', qw(d/f//), {OUT => 'f'}], + ['e', qw(f), {OUT => 'f'}], + ['f', qw(/), {OUT => '/'}], + ['g', qw(//), {OUT => "$double_slash"}], + ['h', qw(///), {OUT => '/'}], + ['i', qw(///a///), {OUT => 'a'}], + ['j', qw(''), {OUT => ''}], + ['k', qw(aa a), {OUT => 'a'}], + ['l', qw(-a a b), {OUT => "a\nb"}], + ['m', qw(-s a aa ba ab), {OUT => "a\nb\nab"}], + ['n', qw(a-a -a), {OUT => 'a'}], + ['1', qw(f.s .s), {OUT => 'f'}], + ['2', qw(fs s), {OUT => 'f'}], + ['3', qw(fs fs), {OUT => 'fs'}], + ['4', qw(fs/ s), {OUT => 'f'}], + ['5', qw(dir/file.suf .suf), {OUT => 'file'}], + ['6', qw(// /), {OUT => "$double_slash"}], + ['7', qw(// //), {OUT => "$double_slash"}], + ['8', qw(fs x), {OUT => 'fs'}], + ['9', qw(fs ''), {OUT => 'fs'}], + ['10', qw(fs/ s/), {OUT => 'fs'}], + ); + +# Append a newline to end of each expected 'OUT' string. +my $t; +foreach $t (@Tests) + { + my $arg1 = $t->[1]; + my $e; + foreach $e (@$t) + { + $e->{OUT} = "$e->{OUT}\n" + if ref $e eq 'HASH' and exists $e->{OUT}; + } + } + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/cat-buf b/tests/misc/cat-buf deleted file mode 100755 index 2b6ba2a64..000000000 --- a/tests/misc/cat-buf +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# Ensure that cat outputs processed data immediately. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cat - -# Use a fifo rather than a pipe in the tests below -# so that the producer (cat) will wait until the -# consumer (dd) opens the fifo therefore increasing -# the chance that dd will read the data from each -# write separately. -mkfifo_or_skip_ fifo - - -echo 1 > exp - -cat_buf_1() -{ - local delay="$1" - - dd count=1 if=fifo > out & - (echo 1; sleep $delay; echo 2) | cat -v > fifo - wait # for dd to complete - compare exp out -} - -retry_delay_ cat_buf_1 .1 6 || fail=1 - -Exit $fail diff --git a/tests/misc/cat-buf.sh b/tests/misc/cat-buf.sh new file mode 100755 index 000000000..2b6ba2a64 --- /dev/null +++ b/tests/misc/cat-buf.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Ensure that cat outputs processed data immediately. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cat + +# Use a fifo rather than a pipe in the tests below +# so that the producer (cat) will wait until the +# consumer (dd) opens the fifo therefore increasing +# the chance that dd will read the data from each +# write separately. +mkfifo_or_skip_ fifo + + +echo 1 > exp + +cat_buf_1() +{ + local delay="$1" + + dd count=1 if=fifo > out & + (echo 1; sleep $delay; echo 2) | cat -v > fifo + wait # for dd to complete + compare exp out +} + +retry_delay_ cat_buf_1 .1 6 || fail=1 + +Exit $fail diff --git a/tests/misc/cat-proc b/tests/misc/cat-proc deleted file mode 100755 index 082c727e0..000000000 --- a/tests/misc/cat-proc +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Ensure that cat -E produces same output as cat, module '$'s, -# even when applied to a file in /proc. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cat - - -f=/proc/cpuinfo -test -f $f \ - || skip_ "no $f" - - -# Yes, parts of /proc/cpuinfo might change between cat runs. -# If that happens, consider choosing a file that's less likely to change, -# or just filter out the changing lines. The sed filter should help -# to avoid any spurious numeric differences. -cat -E $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > out || fail=1 -cat $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/cat-proc.sh b/tests/misc/cat-proc.sh new file mode 100755 index 000000000..082c727e0 --- /dev/null +++ b/tests/misc/cat-proc.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Ensure that cat -E produces same output as cat, module '$'s, +# even when applied to a file in /proc. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cat + + +f=/proc/cpuinfo +test -f $f \ + || skip_ "no $f" + + +# Yes, parts of /proc/cpuinfo might change between cat runs. +# If that happens, consider choosing a file that's less likely to change, +# or just filter out the changing lines. The sed filter should help +# to avoid any spurious numeric differences. +cat -E $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > out || fail=1 +cat $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/chcon b/tests/misc/chcon deleted file mode 100755 index 6b4458034..000000000 --- a/tests/misc/chcon +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# exercise chcon - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chcon -require_root_ -require_selinux_ -skip_if_mcstransd_is_running_ - -mkdir -p d/sub/s2 || framework_failure_ -touch f g d/sub/1 d/sub/2 || framework_failure_ - - -# Set to a specified context. -# Use root:object_r:tmp_t:s0. It is special in that -# it works even when mcstransd isn't running. -u1=root -r1=object_r -t1=tmp_t -range=s0 -ctx=$u1:$r1:$t1:$range -chcon $ctx f || fail=1 -stat --printf='f|%C\n' f > out || fail=1 - -# Use --reference. -chcon --ref=f g || fail=1 -stat --printf='g|%C\n' g >> out || fail=1 - -# Change the individual parts of the context, one by one. -u2=user_u -r2=object_r -t2=file_t -for i in --user=$u2 --role=$r2 --type=$t2 --range=$range; do - chcon $i f || fail=1 - stat --printf="f|$i|"'%C\n' f >> out || fail=1 -done - -# Same, but change back using the short-named options. -for i in -u$u1 -r$r1 -t$t1; do - chcon $i f || fail=1 - stat --printf="f|$i|"'%C\n' f >> out || fail=1 -done - -cat < exp || fail=1 -f|$ctx -g|$ctx -f|--user=$u2|$u2:$r1:$t1:$range -f|--role=$r2|$u2:$r2:$t1:$range -f|--type=$t2|$u2:$r2:$t2:$range -f|--range=$range|$u2:$r2:$t2:$range -f|-uroot|root:object_r:file_t:$range -f|-robject_r|root:object_r:file_t:$range -f|-ttmp_t|root:object_r:tmp_t:$range -EOF - -compare exp out || fail=1 - -chcon --verbose -u$u1 f > out || fail=1 -echo "changing security context of 'f'" > exp -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/chcon-fail b/tests/misc/chcon-fail deleted file mode 100755 index d9f6c21b7..000000000 --- a/tests/misc/chcon-fail +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Ensure that chcon fails when it should. -# These tests don't use any actual SE Linux syscalls. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chcon - - -# neither context nor file -chcon 2> /dev/null && fail=1 - -# No file -chcon CON 2> /dev/null && fail=1 - -# No file -touch f -chcon --reference=f 2> /dev/null && fail=1 - -# No file -chcon -u anyone 2> /dev/null && fail=1 - -Exit $fail diff --git a/tests/misc/chcon-fail.sh b/tests/misc/chcon-fail.sh new file mode 100755 index 000000000..d9f6c21b7 --- /dev/null +++ b/tests/misc/chcon-fail.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Ensure that chcon fails when it should. +# These tests don't use any actual SE Linux syscalls. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chcon + + +# neither context nor file +chcon 2> /dev/null && fail=1 + +# No file +chcon CON 2> /dev/null && fail=1 + +# No file +touch f +chcon --reference=f 2> /dev/null && fail=1 + +# No file +chcon -u anyone 2> /dev/null && fail=1 + +Exit $fail diff --git a/tests/misc/chcon.sh b/tests/misc/chcon.sh new file mode 100755 index 000000000..6b4458034 --- /dev/null +++ b/tests/misc/chcon.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# exercise chcon + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chcon +require_root_ +require_selinux_ +skip_if_mcstransd_is_running_ + +mkdir -p d/sub/s2 || framework_failure_ +touch f g d/sub/1 d/sub/2 || framework_failure_ + + +# Set to a specified context. +# Use root:object_r:tmp_t:s0. It is special in that +# it works even when mcstransd isn't running. +u1=root +r1=object_r +t1=tmp_t +range=s0 +ctx=$u1:$r1:$t1:$range +chcon $ctx f || fail=1 +stat --printf='f|%C\n' f > out || fail=1 + +# Use --reference. +chcon --ref=f g || fail=1 +stat --printf='g|%C\n' g >> out || fail=1 + +# Change the individual parts of the context, one by one. +u2=user_u +r2=object_r +t2=file_t +for i in --user=$u2 --role=$r2 --type=$t2 --range=$range; do + chcon $i f || fail=1 + stat --printf="f|$i|"'%C\n' f >> out || fail=1 +done + +# Same, but change back using the short-named options. +for i in -u$u1 -r$r1 -t$t1; do + chcon $i f || fail=1 + stat --printf="f|$i|"'%C\n' f >> out || fail=1 +done + +cat < exp || fail=1 +f|$ctx +g|$ctx +f|--user=$u2|$u2:$r1:$t1:$range +f|--role=$r2|$u2:$r2:$t1:$range +f|--type=$t2|$u2:$r2:$t2:$range +f|--range=$range|$u2:$r2:$t2:$range +f|-uroot|root:object_r:file_t:$range +f|-robject_r|root:object_r:file_t:$range +f|-ttmp_t|root:object_r:tmp_t:$range +EOF + +compare exp out || fail=1 + +chcon --verbose -u$u1 f > out || fail=1 +echo "changing security context of 'f'" > exp +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/chroot-credentials b/tests/misc/chroot-credentials deleted file mode 100755 index bae9d4255..000000000 --- a/tests/misc/chroot-credentials +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Verify that the credentials are changed correctly. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chroot - -require_root_ - - -# Verify that root credentials are kept. -test $(chroot / whoami) = root || fail=1 -test "$(groups)" = "$(chroot / groups)" || fail=1 - -# Verify that credentials are changed correctly. -whoami_after_chroot=$( - chroot --userspec=$NON_ROOT_USERNAME:$NON_ROOT_GROUP / whoami -) -test "$whoami_after_chroot" != root || fail=1 - -# Verify that there are no additional groups. -id_G_after_chroot=$( - chroot --userspec=$NON_ROOT_USERNAME:$NON_ROOT_GROUP \ - --groups=$NON_ROOT_GROUP / id -G -) -test "$id_G_after_chroot" = $NON_ROOT_GROUP || fail=1 - -# Verify that when specifying only the user name we get the current -# primary group ID. -test "$(chroot --userspec=$NON_ROOT_USERNAME / id -g)" = "$(id -g)" \ - || fail=1 - -# Verify that when specifying only a group we get the current user ID -test "$(chroot --userspec=:$NON_ROOT_GROUP / id -u)" = "$(id -u)" \ - || fail=1 - -Exit $fail diff --git a/tests/misc/chroot-credentials.sh b/tests/misc/chroot-credentials.sh new file mode 100755 index 000000000..bae9d4255 --- /dev/null +++ b/tests/misc/chroot-credentials.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Verify that the credentials are changed correctly. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chroot + +require_root_ + + +# Verify that root credentials are kept. +test $(chroot / whoami) = root || fail=1 +test "$(groups)" = "$(chroot / groups)" || fail=1 + +# Verify that credentials are changed correctly. +whoami_after_chroot=$( + chroot --userspec=$NON_ROOT_USERNAME:$NON_ROOT_GROUP / whoami +) +test "$whoami_after_chroot" != root || fail=1 + +# Verify that there are no additional groups. +id_G_after_chroot=$( + chroot --userspec=$NON_ROOT_USERNAME:$NON_ROOT_GROUP \ + --groups=$NON_ROOT_GROUP / id -G +) +test "$id_G_after_chroot" = $NON_ROOT_GROUP || fail=1 + +# Verify that when specifying only the user name we get the current +# primary group ID. +test "$(chroot --userspec=$NON_ROOT_USERNAME / id -g)" = "$(id -g)" \ + || fail=1 + +# Verify that when specifying only a group we get the current user ID +test "$(chroot --userspec=:$NON_ROOT_GROUP / id -u)" = "$(id -u)" \ + || fail=1 + +Exit $fail diff --git a/tests/misc/chroot-fail b/tests/misc/chroot-fail deleted file mode 100755 index 6a5ecf32f..000000000 --- a/tests/misc/chroot-fail +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Verify that internal failure in chroot gives exact status. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chroot - - -# These tests verify exact status of internal failure; since none of -# them actually run a command, we don't need root privileges -chroot # missing argument -test $? = 125 || fail=1 -chroot --- / true # unknown option -test $? = 125 || fail=1 - -# chroot("/") succeeds for non-root users on some systems, but not all. -if chroot / true ; then - chroot / sh -c 'exit 2' # exit status propagation - test $? = 2 || fail=1 - chroot / . # invalid command - test $? = 126 || fail=1 - chroot / no_such # no such command - test $? = 127 || fail=1 -else - test $? = 125 || fail=1 -fi - -Exit $fail diff --git a/tests/misc/chroot-fail.sh b/tests/misc/chroot-fail.sh new file mode 100755 index 000000000..6a5ecf32f --- /dev/null +++ b/tests/misc/chroot-fail.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Verify that internal failure in chroot gives exact status. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chroot + + +# These tests verify exact status of internal failure; since none of +# them actually run a command, we don't need root privileges +chroot # missing argument +test $? = 125 || fail=1 +chroot --- / true # unknown option +test $? = 125 || fail=1 + +# chroot("/") succeeds for non-root users on some systems, but not all. +if chroot / true ; then + chroot / sh -c 'exit 2' # exit status propagation + test $? = 2 || fail=1 + chroot / . # invalid command + test $? = 126 || fail=1 + chroot / no_such # no such command + test $? = 127 || fail=1 +else + test $? = 125 || fail=1 +fi + +Exit $fail diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout deleted file mode 100755 index 8584dfea4..000000000 --- a/tests/misc/close-stdout +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Ensure that several programs work fine, even with stdout initially closed. -# This is effectively a test of closeout.c's close_stdout function. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -p=$abs_top_builddir - - -# Ensure these exit successfully, even though stdout is closed, -# because they generate no output. -touch a -cp a b >&- || fail=1 -test -f b || fail=1 -chmod o-w . >&- || fail=1 -ln a c >&- || fail=1 -rm c >&- || fail=1 -mkdir d >&- || fail=1 -mv d e >&- || fail=1 -rmdir e >&- || fail=1 -touch e >&- || fail=1 -sleep 0 >&- || fail=1 -"$p/src/true" >&- || fail=1 -"$p/src/printf" '' >&- || fail=1 - -# If >&- works, ensure these fail, because stdout is closed and they -# *do* generate output. >&- apparently does not work in HP-UX 11.23. -# This test is ineffective unless /dev/stdout also works. -if "$p/src/test" -w /dev/stdout >/dev/null && - "$p/src/test" ! -w /dev/stdout >&-; then - "$p/src/printf" 'foo' >&- 2>/dev/null && fail=1 - cp --verbose a b >&- 2>/dev/null && fail=1 - rm -Rf tmpfile-?????? || fail=1 - mktemp tmpfile-XXXXXX >&- 2>/dev/null && fail=1 - mktemp tmpfile-XXXXXX -q >&- 2>/dev/null && fail=1 - case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac -fi - -# Likewise for /dev/full, if /dev/full works. -if test -w /dev/full && test -c /dev/full; then - "$p/src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 - cp --verbose a b >/dev/full 2>/dev/null && fail=1 - rm -Rf tmpdir-?????? || fail=1 - mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1 - mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1 - case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac -fi - -Exit $fail diff --git a/tests/misc/close-stdout.sh b/tests/misc/close-stdout.sh new file mode 100755 index 000000000..8584dfea4 --- /dev/null +++ b/tests/misc/close-stdout.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Ensure that several programs work fine, even with stdout initially closed. +# This is effectively a test of closeout.c's close_stdout function. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +p=$abs_top_builddir + + +# Ensure these exit successfully, even though stdout is closed, +# because they generate no output. +touch a +cp a b >&- || fail=1 +test -f b || fail=1 +chmod o-w . >&- || fail=1 +ln a c >&- || fail=1 +rm c >&- || fail=1 +mkdir d >&- || fail=1 +mv d e >&- || fail=1 +rmdir e >&- || fail=1 +touch e >&- || fail=1 +sleep 0 >&- || fail=1 +"$p/src/true" >&- || fail=1 +"$p/src/printf" '' >&- || fail=1 + +# If >&- works, ensure these fail, because stdout is closed and they +# *do* generate output. >&- apparently does not work in HP-UX 11.23. +# This test is ineffective unless /dev/stdout also works. +if "$p/src/test" -w /dev/stdout >/dev/null && + "$p/src/test" ! -w /dev/stdout >&-; then + "$p/src/printf" 'foo' >&- 2>/dev/null && fail=1 + cp --verbose a b >&- 2>/dev/null && fail=1 + rm -Rf tmpfile-?????? || fail=1 + mktemp tmpfile-XXXXXX >&- 2>/dev/null && fail=1 + mktemp tmpfile-XXXXXX -q >&- 2>/dev/null && fail=1 + case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac +fi + +# Likewise for /dev/full, if /dev/full works. +if test -w /dev/full && test -c /dev/full; then + "$p/src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 + cp --verbose a b >/dev/full 2>/dev/null && fail=1 + rm -Rf tmpdir-?????? || fail=1 + mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1 + mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1 + case $(echo tmpfile-??????) in 'tmpfile-??????') ;; *) fail=1 ;; esac +fi + +Exit $fail diff --git a/tests/misc/comm b/tests/misc/comm deleted file mode 100755 index 0de4f6999..000000000 --- a/tests/misc/comm +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/perl -# -*- perl -*- -# Test comm - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -require 5.003; -use strict; - -(my $program_name = $0) =~ s|.*/||; - -my $prog = 'comm'; - -# Turn off localization of executable's ouput. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @inputs = ({IN=>{a=>"1\n3"}}, {IN=>{b=>"2\n3"}}); - -my @Tests = - ( - # basic operation - ['basic', @inputs, {OUT=>"1\n\t2\n\t\t3\n"} ], - - # suppress lines unique to file 1 - ['opt-1', '-1', @inputs, {OUT=>"2\n\t3\n"} ], - - # suppress lines unique to file 2 - ['opt-2', '-2', @inputs, {OUT=>"1\n\t3\n"} ], - - # suppress lines that appear in both files - ['opt-3', '-3', @inputs, {OUT=>"1\n\t2\n"} ], - - # suppress lines unique to file 1 and lines unique to file 2 - ['opt-12', '-1', '-2', @inputs, {OUT=>"3\n"} ], - - # suppress lines unique to file 1 and those that appear in both files - ['opt-13', '-1', '-3', @inputs, {OUT=>"2\n"} ], - - # suppress lines unique to file 2 and those that appear in both files - ['opt-23', '-2', '-3', @inputs, {OUT=>"1\n"} ], - - # suppress all output (really?) - ['opt-123', '-1', '-2', '-3', @inputs, {OUT=>""} ], - - # invalid missing command line argument (1) - ['missing-arg1', $inputs[0], {EXIT=>1}, - {ERR => "$prog: missing operand after 'a'\n" - . "Try '$prog --help' for more information.\n"}], - - # invalid missing command line argument (both) - ['missing-arg2', {EXIT=>1}, - {ERR => "$prog: missing operand\n" - . "Try '$prog --help' for more information.\n"}], - - # invalid extra command line argument - ['extra-arg', @inputs, 'no-such', {EXIT=>1}, - {ERR => "$prog: extra operand 'no-such'\n" - . "Try '$prog --help' for more information.\n"}], - - # out-of-order input - ['ooo', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, - {OUT => "1\n\t\t3\n\t2\n"}, - {ERR => "$prog: file 2 is not in sorted order\n"}], - - # out-of-order input, fatal - ['ooo2', '--check-order', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, - {OUT => "1\n\t\t3\n"}, - {ERR => "$prog: file 2 is not in sorted order\n"}], - - # out-of-order input, ignored - ['ooo3', '--nocheck-order', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, - {OUT => "1\n\t\t3\n\t2\n"}], - - # both inputs out-of-order - ['ooo4', {IN=>{a=>"3\n1\n0"}}, {IN=>{b=>"3\n2\n0"}}, {EXIT=>1}, - {OUT => "\t\t3\n1\n0\n\t2\n\t0\n"}, - {ERR => "$prog: file 1 is not in sorted order\n". - "$prog: file 2 is not in sorted order\n" }], - - # both inputs out-of-order on last pair - ['ooo5', {IN=>{a=>"3\n1"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, - {OUT => "\t\t3\n1\n\t2\n"}, - {ERR => "$prog: file 1 is not in sorted order\n". - "$prog: file 2 is not in sorted order\n" }], - - # first input out-of-order extended - ['ooo5b', {IN=>{a=>"0\n3\n1"}}, {IN=>{b=>"2\n3"}}, {EXIT=>1}, - {OUT => "0\n\t2\n\t\t3\n1\n"}, - {ERR => "$prog: file 1 is not in sorted order\n"}], - - # second input out-of-order extended - ['ooo5c', {IN=>{a=>"0\n3"}}, {IN=>{b=>"2\n3\n1"}}, {EXIT=>1}, - {OUT => "0\n\t2\n\t\t3\n\t1\n"}, - {ERR => "$prog: file 2 is not in sorted order\n"}], - - # both inputs out-of-order, but fully pairable - ['ooo6', {IN=>{a=>"2\n1\n0"}}, {IN=>{b=>"2\n1\n0"}}, {EXIT=>0}, - {OUT => "\t\t2\n\t\t1\n\t\t0\n"}], - - # both inputs out-of-order, fully pairable, but forced to fail - ['ooo7', '--check-order', {IN=>{a=>"2\n1\n0"}}, {IN=>{b=>"2\n1\n0"}}, - {EXIT=>1}, - {OUT => "\t\t2\n"}, - {ERR => "$prog: file 1 is not in sorted order\n"}], - - # out-of-order, line 2 is a prefix of line 1 - # until coreutils-7.2, this test would fail -- no disorder detected - ['ooo-prefix', '--check-order', {IN=>{a=>"Xa\nX\n"}}, {IN=>{b=>""}}, - {EXIT=>1}, - {OUT => "Xa\n"}, - {ERR => "$prog: file 1 is not in sorted order\n"}], - - # alternate delimiter: ',' - ['delim-comma', '--output-delimiter=,', @inputs, - {OUT=>"1\n,2\n,,3\n"} ], - - # two-character alternate delimiter: '++' - ['delim-2char', '--output-delimiter=++', @inputs, - {OUT=>"1\n++2\n++++3\n"} ], - - # invalid empty delimiter - ['delim-empty', '--output-delimiter=', @inputs, {EXIT=>1}, - {ERR => "$prog: empty '--output-delimiter' not allowed\n"}], - - # invalid dual delimiter - ['delim-dual', '--output-delimiter=,', '--output-delimiter=+', - @inputs, {EXIT=>1}, {ERR => "$prog: multiple delimiters specified\n"}], - - # valid dual delimiter specification - ['delim-dual2', '--output-delimiter=,', '--output-delimiter=,', @inputs, - {OUT=>"1\n,2\n,,3\n"} ], - - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/comm.pl b/tests/misc/comm.pl new file mode 100755 index 000000000..0de4f6999 --- /dev/null +++ b/tests/misc/comm.pl @@ -0,0 +1,152 @@ +#!/usr/bin/perl +# -*- perl -*- +# Test comm + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +require 5.003; +use strict; + +(my $program_name = $0) =~ s|.*/||; + +my $prog = 'comm'; + +# Turn off localization of executable's ouput. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @inputs = ({IN=>{a=>"1\n3"}}, {IN=>{b=>"2\n3"}}); + +my @Tests = + ( + # basic operation + ['basic', @inputs, {OUT=>"1\n\t2\n\t\t3\n"} ], + + # suppress lines unique to file 1 + ['opt-1', '-1', @inputs, {OUT=>"2\n\t3\n"} ], + + # suppress lines unique to file 2 + ['opt-2', '-2', @inputs, {OUT=>"1\n\t3\n"} ], + + # suppress lines that appear in both files + ['opt-3', '-3', @inputs, {OUT=>"1\n\t2\n"} ], + + # suppress lines unique to file 1 and lines unique to file 2 + ['opt-12', '-1', '-2', @inputs, {OUT=>"3\n"} ], + + # suppress lines unique to file 1 and those that appear in both files + ['opt-13', '-1', '-3', @inputs, {OUT=>"2\n"} ], + + # suppress lines unique to file 2 and those that appear in both files + ['opt-23', '-2', '-3', @inputs, {OUT=>"1\n"} ], + + # suppress all output (really?) + ['opt-123', '-1', '-2', '-3', @inputs, {OUT=>""} ], + + # invalid missing command line argument (1) + ['missing-arg1', $inputs[0], {EXIT=>1}, + {ERR => "$prog: missing operand after 'a'\n" + . "Try '$prog --help' for more information.\n"}], + + # invalid missing command line argument (both) + ['missing-arg2', {EXIT=>1}, + {ERR => "$prog: missing operand\n" + . "Try '$prog --help' for more information.\n"}], + + # invalid extra command line argument + ['extra-arg', @inputs, 'no-such', {EXIT=>1}, + {ERR => "$prog: extra operand 'no-such'\n" + . "Try '$prog --help' for more information.\n"}], + + # out-of-order input + ['ooo', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, + {OUT => "1\n\t\t3\n\t2\n"}, + {ERR => "$prog: file 2 is not in sorted order\n"}], + + # out-of-order input, fatal + ['ooo2', '--check-order', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, + {OUT => "1\n\t\t3\n"}, + {ERR => "$prog: file 2 is not in sorted order\n"}], + + # out-of-order input, ignored + ['ooo3', '--nocheck-order', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, + {OUT => "1\n\t\t3\n\t2\n"}], + + # both inputs out-of-order + ['ooo4', {IN=>{a=>"3\n1\n0"}}, {IN=>{b=>"3\n2\n0"}}, {EXIT=>1}, + {OUT => "\t\t3\n1\n0\n\t2\n\t0\n"}, + {ERR => "$prog: file 1 is not in sorted order\n". + "$prog: file 2 is not in sorted order\n" }], + + # both inputs out-of-order on last pair + ['ooo5', {IN=>{a=>"3\n1"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, + {OUT => "\t\t3\n1\n\t2\n"}, + {ERR => "$prog: file 1 is not in sorted order\n". + "$prog: file 2 is not in sorted order\n" }], + + # first input out-of-order extended + ['ooo5b', {IN=>{a=>"0\n3\n1"}}, {IN=>{b=>"2\n3"}}, {EXIT=>1}, + {OUT => "0\n\t2\n\t\t3\n1\n"}, + {ERR => "$prog: file 1 is not in sorted order\n"}], + + # second input out-of-order extended + ['ooo5c', {IN=>{a=>"0\n3"}}, {IN=>{b=>"2\n3\n1"}}, {EXIT=>1}, + {OUT => "0\n\t2\n\t\t3\n\t1\n"}, + {ERR => "$prog: file 2 is not in sorted order\n"}], + + # both inputs out-of-order, but fully pairable + ['ooo6', {IN=>{a=>"2\n1\n0"}}, {IN=>{b=>"2\n1\n0"}}, {EXIT=>0}, + {OUT => "\t\t2\n\t\t1\n\t\t0\n"}], + + # both inputs out-of-order, fully pairable, but forced to fail + ['ooo7', '--check-order', {IN=>{a=>"2\n1\n0"}}, {IN=>{b=>"2\n1\n0"}}, + {EXIT=>1}, + {OUT => "\t\t2\n"}, + {ERR => "$prog: file 1 is not in sorted order\n"}], + + # out-of-order, line 2 is a prefix of line 1 + # until coreutils-7.2, this test would fail -- no disorder detected + ['ooo-prefix', '--check-order', {IN=>{a=>"Xa\nX\n"}}, {IN=>{b=>""}}, + {EXIT=>1}, + {OUT => "Xa\n"}, + {ERR => "$prog: file 1 is not in sorted order\n"}], + + # alternate delimiter: ',' + ['delim-comma', '--output-delimiter=,', @inputs, + {OUT=>"1\n,2\n,,3\n"} ], + + # two-character alternate delimiter: '++' + ['delim-2char', '--output-delimiter=++', @inputs, + {OUT=>"1\n++2\n++++3\n"} ], + + # invalid empty delimiter + ['delim-empty', '--output-delimiter=', @inputs, {EXIT=>1}, + {ERR => "$prog: empty '--output-delimiter' not allowed\n"}], + + # invalid dual delimiter + ['delim-dual', '--output-delimiter=,', '--output-delimiter=+', + @inputs, {EXIT=>1}, {ERR => "$prog: multiple delimiters specified\n"}], + + # valid dual delimiter specification + ['delim-dual2', '--output-delimiter=,', '--output-delimiter=,', @inputs, + {OUT=>"1\n,2\n,,3\n"} ], + + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/csplit b/tests/misc/csplit deleted file mode 100755 index aea2e918f..000000000 --- a/tests/misc/csplit +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh -# various csplit tests - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ csplit - - -# csplit could get a failed assertion to 2.0.17 -(echo a; echo; echo) > in -csplit in '/^$/' 2 > out || fail=1 -cat < exp -2 -0 -2 -EOF -compare exp out || fail=1 -rm -f in out exp - -# Ensure that xx02 contains just two newlines. -# This would fail due to reading from freed buffer with coreutils-5.0.91. -printf '\n\n' > exp -cp xx02 out || fail=1 -compare exp out || fail=1 -rm -f in out exp - -# csplit would infloop -(echo; echo a) > in -csplit in '/a/-1' '{*}' > out || fail=1 -cat < exp -0 -3 -EOF -compare exp out || fail=1 -rm -f in out exp - -# 'echo |csplit - 1 1' used to abort. -echo > in -csplit in 1 1 > out 2> err || fail=1 -cat < exp -0 -0 -1 -EOF -compare exp out || fail=1 -cat <<\EOF > experr -csplit: warning: line number '1' is the same as preceding line number -EOF -compare experr err || fail=1 -rm -f in out exp err experr - -# 'echo | csplit -b '%0#6.3x' - 1' incorrectly warned about the format -# up through coreutils 8.6. -echo > in -csplit -b '%0#6.3x' in 1 > out 2> err || fail=1 -cat < exp -0 -1 -EOF -compare exp out || fail=1 -touch experr -compare experr err || fail=1 -compare 'xx 000' experr || fail=1 -compare 'xx 0x001' in || fail=1 -rm -f in out exp err experr xx* - -# make sure 'csplit FILE 0' fails. -echo > in -csplit in 0 > out 2> err && fail=1 -csplit in 2 1 > out 2>> err && fail=1 -csplit in 3 3 > out 2>> err && fail=1 -cat <<\EOF > experr -csplit: 0: line number must be greater than zero -csplit: line number '1' is smaller than preceding line number, 2 -csplit: warning: line number '3' is the same as preceding line number -csplit: '3': line number out of range -EOF -compare experr err || fail=1 - -# Ensure that lines longer than the initial buffer length don't cause -# trouble (e.g. reading from freed memory, resulting in corrupt output). -# This test failed at least in coreutils-5.2.1 and 5.3.0, and was fixed -# in 5.3.1. -rm -f in out exp err experr xx?? -printf 'x%8199s\nx\n%8199s\nx\n' x x > in -csplit in '/x\{1\}/' '{*}' > /dev/null || fail=1 -cat xx?? | compare - in || fail=1 - -Exit $fail diff --git a/tests/misc/csplit-1000 b/tests/misc/csplit-1000 deleted file mode 100755 index 217097e53..000000000 --- a/tests/misc/csplit-1000 +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# cause a 1-byte heap buffer overrun - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ csplit - -# Before coreutils-8.7, this would overrun the 6-byte filename_space buffer. -# It's hard to detect that without using valgrind, so here, we simply -# run the demonstrator. -seq 1000 | csplit - '/./' '{*}' || fail=1 -test -f xx1000 || fail=1 -test -f xx1001 && fail=1 - -Exit $fail diff --git a/tests/misc/csplit-1000.sh b/tests/misc/csplit-1000.sh new file mode 100755 index 000000000..217097e53 --- /dev/null +++ b/tests/misc/csplit-1000.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# cause a 1-byte heap buffer overrun + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ csplit + +# Before coreutils-8.7, this would overrun the 6-byte filename_space buffer. +# It's hard to detect that without using valgrind, so here, we simply +# run the demonstrator. +seq 1000 | csplit - '/./' '{*}' || fail=1 +test -f xx1000 || fail=1 +test -f xx1001 && fail=1 + +Exit $fail diff --git a/tests/misc/csplit-heap b/tests/misc/csplit-heap deleted file mode 100755 index f12f9fe0d..000000000 --- a/tests/misc/csplit-heap +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# ensure that csplit uses a bounded amount of memory - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ csplit - -require_ulimit_ - -( - ulimit -v 20000 - { yes | head -n2500000; echo n; } | csplit -z - %n%1 -) || fail=1 - -Exit $fail diff --git a/tests/misc/csplit-heap.sh b/tests/misc/csplit-heap.sh new file mode 100755 index 000000000..f12f9fe0d --- /dev/null +++ b/tests/misc/csplit-heap.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# ensure that csplit uses a bounded amount of memory + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ csplit + +require_ulimit_ + +( + ulimit -v 20000 + { yes | head -n2500000; echo n; } | csplit -z - %n%1 +) || fail=1 + +Exit $fail diff --git a/tests/misc/csplit.sh b/tests/misc/csplit.sh new file mode 100755 index 000000000..aea2e918f --- /dev/null +++ b/tests/misc/csplit.sh @@ -0,0 +1,103 @@ +#!/bin/sh +# various csplit tests + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ csplit + + +# csplit could get a failed assertion to 2.0.17 +(echo a; echo; echo) > in +csplit in '/^$/' 2 > out || fail=1 +cat < exp +2 +0 +2 +EOF +compare exp out || fail=1 +rm -f in out exp + +# Ensure that xx02 contains just two newlines. +# This would fail due to reading from freed buffer with coreutils-5.0.91. +printf '\n\n' > exp +cp xx02 out || fail=1 +compare exp out || fail=1 +rm -f in out exp + +# csplit would infloop +(echo; echo a) > in +csplit in '/a/-1' '{*}' > out || fail=1 +cat < exp +0 +3 +EOF +compare exp out || fail=1 +rm -f in out exp + +# 'echo |csplit - 1 1' used to abort. +echo > in +csplit in 1 1 > out 2> err || fail=1 +cat < exp +0 +0 +1 +EOF +compare exp out || fail=1 +cat <<\EOF > experr +csplit: warning: line number '1' is the same as preceding line number +EOF +compare experr err || fail=1 +rm -f in out exp err experr + +# 'echo | csplit -b '%0#6.3x' - 1' incorrectly warned about the format +# up through coreutils 8.6. +echo > in +csplit -b '%0#6.3x' in 1 > out 2> err || fail=1 +cat < exp +0 +1 +EOF +compare exp out || fail=1 +touch experr +compare experr err || fail=1 +compare 'xx 000' experr || fail=1 +compare 'xx 0x001' in || fail=1 +rm -f in out exp err experr xx* + +# make sure 'csplit FILE 0' fails. +echo > in +csplit in 0 > out 2> err && fail=1 +csplit in 2 1 > out 2>> err && fail=1 +csplit in 3 3 > out 2>> err && fail=1 +cat <<\EOF > experr +csplit: 0: line number must be greater than zero +csplit: line number '1' is smaller than preceding line number, 2 +csplit: warning: line number '3' is the same as preceding line number +csplit: '3': line number out of range +EOF +compare experr err || fail=1 + +# Ensure that lines longer than the initial buffer length don't cause +# trouble (e.g. reading from freed memory, resulting in corrupt output). +# This test failed at least in coreutils-5.2.1 and 5.3.0, and was fixed +# in 5.3.1. +rm -f in out exp err experr xx?? +printf 'x%8199s\nx\n%8199s\nx\n' x x > in +csplit in '/x\{1\}/' '{*}' > /dev/null || fail=1 +cat xx?? | compare - in || fail=1 + +Exit $fail diff --git a/tests/misc/cut b/tests/misc/cut deleted file mode 100755 index 0ce051ab0..000000000 --- a/tests/misc/cut +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/perl -# Test "cut". - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $ME = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $mb_locale = $ENV{LOCALE_FR_UTF8}; -! defined $mb_locale || $mb_locale eq 'none' - and $mb_locale = 'C'; - -my $prog = 'cut'; -my $try = "Try '$prog --help' for more information.\n"; -my $from_1 = "$prog: fields and positions are numbered from 1\n$try"; -my $inval = "$prog: invalid byte or field list\n$try"; -my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try"; - -my @Tests = - ( - # Provoke a double-free in cut from coreutils-6.7. - ['dbl-free', '-f2-', {IN=>{f=>'x'}}, {IN=>{g=>'y'}}, {OUT=>"x\ny\n"}], - - # This failed (as it should) even before coreutils-6.9.90, - # but cut from 6.9.90 produces a more useful diagnostic. - ['zero-1', '-b0', {ERR=>$from_1}, {EXIT => 1} ], - - # Up to coreutils-6.9, specifying a range of 0-2 was not an error. - # It was treated just like "-2". - ['zero-2', '-f0-2', {ERR=>$from_1}, {EXIT => 1} ], - - ['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], - ['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], - ['3', qw(-d: -f2-), {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}], - ['4', qw(-d: -f4), {IN=>"a:b:c\n"}, {OUT=>"\n"}], - ['5', qw(-d: -f4), {IN=>""}, {OUT=>""}], - ['6', '-c4', {IN=>"123\n"}, {OUT=>"\n"}], - ['7', '-c4', {IN=>"123"}, {OUT=>"\n"}], - ['8', '-c4', {IN=>"123\n1"}, {OUT=>"\n\n"}], - ['9', '-c4', {IN=>""}, {OUT=>""}], - ['a', qw(-s -d:), '-f3-', {IN=>"a:b:c\n"}, {OUT=>"c\n"}], - ['b', qw(-s -d:), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}], - ['c', qw(-s -d:), '-f1,3', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], - # Trailing colon should not be output - ['d', qw(-s -d:), '-f1,3', {IN=>"a:b:c:\n"}, {OUT=>"a:c\n"}], - ['e', qw(-s -d:), '-f3-', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}], - ['f', qw(-s -d:), '-f3-4', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}], - ['g', qw(-s -d:), '-f3,4', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}], - # Make sure -s suppresses non-delimited lines - ['h', qw(-s -d:), '-f2,3', {IN=>"abc\n"}, {OUT=>""}], - # - ['i', qw(-d: -f1-3), {IN=>":::\n"}, {OUT=>"::\n"}], - ['j', qw(-d: -f1-4), {IN=>":::\n"}, {OUT=>":::\n"}], - ['k', qw(-d: -f2-3), {IN=>":::\n"}, {OUT=>":\n"}], - ['l', qw(-d: -f2-4), {IN=>":::\n"}, {OUT=>"::\n"}], - ['m', qw(-s -d: -f1-3), {IN=>":::\n"}, {OUT=>"::\n"}], - ['n', qw(-s -d: -f1-4), {IN=>":::\n"}, {OUT=>":::\n"}], - ['o', qw(-s -d: -f2-3), {IN=>":::\n"}, {OUT=>":\n"}], - ['p', qw(-s -d: -f2-4), {IN=>":::\n"}, {OUT=>"::\n"}], - ['q', qw(-s -d: -f2-4), {IN=>":::\n:\n"}, {OUT=>"::\n\n"}], - ['r', qw(-s -d: -f2-4), {IN=>":::\n:1\n"}, {OUT=>"::\n1\n"}], - ['s', qw(-s -d: -f1-4), {IN=>":::\n:a\n"}, {OUT=>":::\n:a\n"}], - ['t', qw(-s -d: -f3-), {IN=>":::\n:1\n"}, {OUT=>":\n\n"}], - # Make sure it handles empty input properly, with and without -s. - ['u', qw(-s -f3-), {IN=>""}, {OUT=>""}], - ['v', '-f3-', {IN=>""}, {OUT=>""}], - # Make sure it handles empty input properly. - ['w', qw(-b 1), {IN=>""}, {OUT=>""}], - ['x', qw(-s -d: -f2-4), {IN=>":\n"}, {OUT=>"\n"}], - # Errors - # -s may be used only with -f - ['y', qw(-s -b4), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, - {ERR=>"$prog: suppressing non-delimited lines makes sense\n" - . "\tonly when operating on fields\n$try"}], - # You must specify bytes or fields (or chars) - ['z', '', {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, - {ERR=>"$prog: you must specify a list of bytes, characters, or fields\n$try"} - ], - # Empty field list - ['empty-fl', qw(-f ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}], - # Missing field list - ['missing-fl', qw(-f --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}], - # Empty byte list - ['empty-bl', qw(-b ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}], - # Missing byte list - ['missing-bl', qw(-b --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}], - - # This test fails with cut from textutils-1.22. - ['empty-f1', '-f1', {IN=>""}, {OUT=>""}], - - ['empty-f2', '-f2', {IN=>""}, {OUT=>""}], - - ['o-delim', qw(-d: --out=_), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b_c\n"}], - ['nul-idelim', qw(-d '' --out=_), '-f2,3', {IN=>"a\0b\0c\n"}, {OUT=>"b_c\n"}], - ['nul-odelim', qw(-d: --out=), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b\0c\n"}], - ['multichar-od', qw(-d: --out=_._), '-f2,3', {IN=>"a:b:c\n"}, - {OUT=>"b_._c\n"}], - - # Prior to 1.22i, you couldn't use a delimiter that would sign-extend. - ['8bit-delim', '-d', "\255", '--out=_', '-f2,3', {IN=>"a\255b\255c\n"}, - {OUT=>"b_c\n"}], - - # New functionality: - ['out-delim1', '-c1-3,5-', '--output-d=:', {IN=>"abcdefg\n"}, - {OUT=>"abc:efg\n"}], - # A totally overlapped field shouldn't change anything: - ['out-delim2', '-c1-3,2,5-', '--output-d=:', {IN=>"abcdefg\n"}, - {OUT=>"abc:efg\n"}], - # Partial overlap: index '2' is not at the start of a range. - ['out-delim3', '-c1-3,2-4,6', '--output-d=:', {IN=>"abcdefg\n"}, - {OUT=>"abcd:f\n"}], - ['out-delim3a', '-c1-3,2-4,6-', '--output-d=:', {IN=>"abcdefg\n"}, - {OUT=>"abcd:fg\n"}], - # Ensure that the following two commands produce the same output. - # Before an off-by-1 fix, the output from the former would not contain a ':'. - ['out-delim4', '-c4-,2-3', '--output-d=:', - {IN=>"abcdefg\n"}, {OUT=>"bc:defg\n"}], - ['out-delim5', '-c2-3,4-', '--output-d=:', - {IN=>"abcdefg\n"}, {OUT=>"bc:defg\n"}], - # This test would fail for cut from coreutils-5.0.1 and earlier. - ['out-delim6', '-c2,1-3', '--output-d=:', {IN=>"abc\n"}, {OUT=>"abc\n"}], - # - ['od-abut', '-b1-2,3-4', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"ab:cd\n"}], - ['od-overlap', '-b1-2,2', '--output-d=:', {IN=>"abc\n"}, {OUT=>"ab\n"}], - ['od-overlap2', '-b1-2,2-', '--output-d=:', {IN=>"abc\n"}, {OUT=>"abc\n"}], - ['od-overlap3', '-b1-3,2-', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"abcd\n"}], - ['od-overlap4', '-b1-3,2-3', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"abc\n"}], - ['od-overlap5', '-b1-3,1-4', '--output-d=:', - {IN=>"abcde\n"}, {OUT=>"abcd\n"}], - - # None of the following invalid ranges provoked an error up to coreutils-6.9. - ['inval1', qw(-f 2-0), {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: invalid decreasing range\n$try"}], - ['inval2', qw(-f -), {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], - ['inval3', '-f', '4,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], - ['inval4', '-f', '1-2,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>$no_endpoint}], - ['inval5', '-f', '1-,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], - ['inval6', '-f', '-1,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], - # This would evoke a segfault from 5.3.0..6.10 - ['big-unbounded-b', '--output-d=:', '-b1234567890-', {IN=>''}, {OUT=>''}], - ['big-unbounded-c', '--output-d=:', '-c1234567890-', {IN=>''}, {OUT=>''}], - ['big-unbounded-f', '--output-d=:', '-f1234567890-', {IN=>''}, {OUT=>''}], - ); - -if ($mb_locale ne 'C') - { - # Duplicate each test vector, appending "-mb" to the test name and - # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we - # provide coverage for the distro-added multi-byte code paths. - my @new; - foreach my $t (@Tests) - { - my @new_t = @$t; - my $test_name = shift @new_t; - - # Depending on whether cut is multi-byte-patched, - # it emits different diagnostics: - # non-MB: invalid byte or field list - # MB: invalid byte, character or field list - # Adjust the expected error output accordingly. - if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval} - (@new_t)) - { - my $sub = {ERR_SUBST => 's/, character//'}; - push @new_t, $sub; - push @$t, $sub; - } - push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; - } - push @Tests, @new; - } - - -@Tests = triple_test \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl new file mode 100755 index 000000000..0ce051ab0 --- /dev/null +++ b/tests/misc/cut.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl +# Test "cut". + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $ME = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $mb_locale = $ENV{LOCALE_FR_UTF8}; +! defined $mb_locale || $mb_locale eq 'none' + and $mb_locale = 'C'; + +my $prog = 'cut'; +my $try = "Try '$prog --help' for more information.\n"; +my $from_1 = "$prog: fields and positions are numbered from 1\n$try"; +my $inval = "$prog: invalid byte or field list\n$try"; +my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try"; + +my @Tests = + ( + # Provoke a double-free in cut from coreutils-6.7. + ['dbl-free', '-f2-', {IN=>{f=>'x'}}, {IN=>{g=>'y'}}, {OUT=>"x\ny\n"}], + + # This failed (as it should) even before coreutils-6.9.90, + # but cut from 6.9.90 produces a more useful diagnostic. + ['zero-1', '-b0', {ERR=>$from_1}, {EXIT => 1} ], + + # Up to coreutils-6.9, specifying a range of 0-2 was not an error. + # It was treated just like "-2". + ['zero-2', '-f0-2', {ERR=>$from_1}, {EXIT => 1} ], + + ['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], + ['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], + ['3', qw(-d: -f2-), {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}], + ['4', qw(-d: -f4), {IN=>"a:b:c\n"}, {OUT=>"\n"}], + ['5', qw(-d: -f4), {IN=>""}, {OUT=>""}], + ['6', '-c4', {IN=>"123\n"}, {OUT=>"\n"}], + ['7', '-c4', {IN=>"123"}, {OUT=>"\n"}], + ['8', '-c4', {IN=>"123\n1"}, {OUT=>"\n\n"}], + ['9', '-c4', {IN=>""}, {OUT=>""}], + ['a', qw(-s -d:), '-f3-', {IN=>"a:b:c\n"}, {OUT=>"c\n"}], + ['b', qw(-s -d:), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}], + ['c', qw(-s -d:), '-f1,3', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], + # Trailing colon should not be output + ['d', qw(-s -d:), '-f1,3', {IN=>"a:b:c:\n"}, {OUT=>"a:c\n"}], + ['e', qw(-s -d:), '-f3-', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}], + ['f', qw(-s -d:), '-f3-4', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}], + ['g', qw(-s -d:), '-f3,4', {IN=>"a:b:c:\n"}, {OUT=>"c:\n"}], + # Make sure -s suppresses non-delimited lines + ['h', qw(-s -d:), '-f2,3', {IN=>"abc\n"}, {OUT=>""}], + # + ['i', qw(-d: -f1-3), {IN=>":::\n"}, {OUT=>"::\n"}], + ['j', qw(-d: -f1-4), {IN=>":::\n"}, {OUT=>":::\n"}], + ['k', qw(-d: -f2-3), {IN=>":::\n"}, {OUT=>":\n"}], + ['l', qw(-d: -f2-4), {IN=>":::\n"}, {OUT=>"::\n"}], + ['m', qw(-s -d: -f1-3), {IN=>":::\n"}, {OUT=>"::\n"}], + ['n', qw(-s -d: -f1-4), {IN=>":::\n"}, {OUT=>":::\n"}], + ['o', qw(-s -d: -f2-3), {IN=>":::\n"}, {OUT=>":\n"}], + ['p', qw(-s -d: -f2-4), {IN=>":::\n"}, {OUT=>"::\n"}], + ['q', qw(-s -d: -f2-4), {IN=>":::\n:\n"}, {OUT=>"::\n\n"}], + ['r', qw(-s -d: -f2-4), {IN=>":::\n:1\n"}, {OUT=>"::\n1\n"}], + ['s', qw(-s -d: -f1-4), {IN=>":::\n:a\n"}, {OUT=>":::\n:a\n"}], + ['t', qw(-s -d: -f3-), {IN=>":::\n:1\n"}, {OUT=>":\n\n"}], + # Make sure it handles empty input properly, with and without -s. + ['u', qw(-s -f3-), {IN=>""}, {OUT=>""}], + ['v', '-f3-', {IN=>""}, {OUT=>""}], + # Make sure it handles empty input properly. + ['w', qw(-b 1), {IN=>""}, {OUT=>""}], + ['x', qw(-s -d: -f2-4), {IN=>":\n"}, {OUT=>"\n"}], + # Errors + # -s may be used only with -f + ['y', qw(-s -b4), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, + {ERR=>"$prog: suppressing non-delimited lines makes sense\n" + . "\tonly when operating on fields\n$try"}], + # You must specify bytes or fields (or chars) + ['z', '', {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, + {ERR=>"$prog: you must specify a list of bytes, characters, or fields\n$try"} + ], + # Empty field list + ['empty-fl', qw(-f ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}], + # Missing field list + ['missing-fl', qw(-f --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}], + # Empty byte list + ['empty-bl', qw(-b ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}], + # Missing byte list + ['missing-bl', qw(-b --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}], + + # This test fails with cut from textutils-1.22. + ['empty-f1', '-f1', {IN=>""}, {OUT=>""}], + + ['empty-f2', '-f2', {IN=>""}, {OUT=>""}], + + ['o-delim', qw(-d: --out=_), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b_c\n"}], + ['nul-idelim', qw(-d '' --out=_), '-f2,3', {IN=>"a\0b\0c\n"}, {OUT=>"b_c\n"}], + ['nul-odelim', qw(-d: --out=), '-f2,3', {IN=>"a:b:c\n"}, {OUT=>"b\0c\n"}], + ['multichar-od', qw(-d: --out=_._), '-f2,3', {IN=>"a:b:c\n"}, + {OUT=>"b_._c\n"}], + + # Prior to 1.22i, you couldn't use a delimiter that would sign-extend. + ['8bit-delim', '-d', "\255", '--out=_', '-f2,3', {IN=>"a\255b\255c\n"}, + {OUT=>"b_c\n"}], + + # New functionality: + ['out-delim1', '-c1-3,5-', '--output-d=:', {IN=>"abcdefg\n"}, + {OUT=>"abc:efg\n"}], + # A totally overlapped field shouldn't change anything: + ['out-delim2', '-c1-3,2,5-', '--output-d=:', {IN=>"abcdefg\n"}, + {OUT=>"abc:efg\n"}], + # Partial overlap: index '2' is not at the start of a range. + ['out-delim3', '-c1-3,2-4,6', '--output-d=:', {IN=>"abcdefg\n"}, + {OUT=>"abcd:f\n"}], + ['out-delim3a', '-c1-3,2-4,6-', '--output-d=:', {IN=>"abcdefg\n"}, + {OUT=>"abcd:fg\n"}], + # Ensure that the following two commands produce the same output. + # Before an off-by-1 fix, the output from the former would not contain a ':'. + ['out-delim4', '-c4-,2-3', '--output-d=:', + {IN=>"abcdefg\n"}, {OUT=>"bc:defg\n"}], + ['out-delim5', '-c2-3,4-', '--output-d=:', + {IN=>"abcdefg\n"}, {OUT=>"bc:defg\n"}], + # This test would fail for cut from coreutils-5.0.1 and earlier. + ['out-delim6', '-c2,1-3', '--output-d=:', {IN=>"abc\n"}, {OUT=>"abc\n"}], + # + ['od-abut', '-b1-2,3-4', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"ab:cd\n"}], + ['od-overlap', '-b1-2,2', '--output-d=:', {IN=>"abc\n"}, {OUT=>"ab\n"}], + ['od-overlap2', '-b1-2,2-', '--output-d=:', {IN=>"abc\n"}, {OUT=>"abc\n"}], + ['od-overlap3', '-b1-3,2-', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"abcd\n"}], + ['od-overlap4', '-b1-3,2-3', '--output-d=:', {IN=>"abcd\n"}, {OUT=>"abc\n"}], + ['od-overlap5', '-b1-3,1-4', '--output-d=:', + {IN=>"abcde\n"}, {OUT=>"abcd\n"}], + + # None of the following invalid ranges provoked an error up to coreutils-6.9. + ['inval1', qw(-f 2-0), {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: invalid decreasing range\n$try"}], + ['inval2', qw(-f -), {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], + ['inval3', '-f', '4,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], + ['inval4', '-f', '1-2,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>$no_endpoint}], + ['inval5', '-f', '1-,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], + ['inval6', '-f', '-1,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], + # This would evoke a segfault from 5.3.0..6.10 + ['big-unbounded-b', '--output-d=:', '-b1234567890-', {IN=>''}, {OUT=>''}], + ['big-unbounded-c', '--output-d=:', '-c1234567890-', {IN=>''}, {OUT=>''}], + ['big-unbounded-f', '--output-d=:', '-f1234567890-', {IN=>''}, {OUT=>''}], + ); + +if ($mb_locale ne 'C') + { + # Duplicate each test vector, appending "-mb" to the test name and + # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we + # provide coverage for the distro-added multi-byte code paths. + my @new; + foreach my $t (@Tests) + { + my @new_t = @$t; + my $test_name = shift @new_t; + + # Depending on whether cut is multi-byte-patched, + # it emits different diagnostics: + # non-MB: invalid byte or field list + # MB: invalid byte, character or field list + # Adjust the expected error output accordingly. + if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval} + (@new_t)) + { + my $sub = {ERR_SUBST => 's/, character//'}; + push @new_t, $sub; + push @$t, $sub; + } + push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; + } + push @Tests, @new; + } + + +@Tests = triple_test \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/date b/tests/misc/date deleted file mode 100755 index 8b6fdb24d..000000000 --- a/tests/misc/date +++ /dev/null @@ -1,323 +0,0 @@ -#!/usr/bin/perl -# Test "date". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $ME = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# Export TZ=UTC0 so that zone-dependent strings match. -$ENV{TZ} = 'UTC0'; - -my $t0 = '08:17:48'; -my $d0 = '1997-01-19'; -my $d1 = "$d0 $t0 +0"; -my $dT = "${d0}T$t0+0"; # ISO 8601 with "T" separator - -my $ts = '08:17:49'; # next second -my $tm = '08:18:48'; # next minute -my $th = '09:17:48'; # next hour - -my $dd = '1997-01-20'; # next day -my $dw = '1997-01-26'; # next week -my $dm = '1997-02-19'; # next month -my $dy = '1998-01-19'; # next month - -my $fmt = "'+%Y-%m-%d %T'"; - -# Determine a number of seconds that will provoke an invalid -# time diagnostic from date. If possible, use a number that -# is less than 2^64, yet so large that it would cause the resulting -# tm_year value to be too large for a 32-bit int. But some systems -# (Solaris 8) have a buggy localtime that mistakenly accepts such -# invalid times and give garbage in tm_year. Other systems might -# have an int type that is wider than 32. So if this localtime -# call succeeds, use 2^64 as the number of seconds. -my $n_seconds = 72057594037927935; -my @d = localtime ($n_seconds); -my $year = $d[5]; -defined $year - and $n_seconds = '18446744073709551616'; - -my @Tests = - ( - # test-name, [option, option, ...] {OUT=>"expected-output"} - # - ['1', "-d '$d1' +'%% %a %A %b %B'", {OUT=>"% Sun Sunday Jan January"}], - - # [Actually, skip it on *all* systems. -- this Perl code is run at - # distribution-build-time, not at configure/test time. ] - - # Skip the test of %c on SunOS4 systems. Such systems would fail this - # test because their underlying strftime doesn't handle the %c format - # properly. GNU strftime must rely on the underlying host library - # function to get locale-dependent behavior, as strftime is the only - # portable interface to that behavior. - # ['2', "-d '$d1' +'%c'", {OUT=>"Sun Jan 19 $t0 1997"}], - - ['3', "-d '$d1' +'%d_%D_%e_%h_%H'", {OUT=>"19_01/19/97_19_Jan_08"}], - ['3T',"-d '$dT' +'%d_%D_%e_%h_%H'", {OUT=>"19_01/19/97_19_Jan_08"}], - - ['4', "-d '$d1' +'%I_%j_%k_%l_%m'", {OUT=>"08_019_ 8_ 8_01"}], - ['5', "-d '$d1' +'%M_%n_%p_%r'", {OUT=>"17_\n_AM_$t0 AM"}], - ['6', "-d '$d1' +'%s_%S_%t_%T'", {OUT=>"853661868_48_\t_$t0"}], - ['7', "-d '$d1' +'%U_%V_%w_%W'", {OUT=>"03_03_0_02"}], - ['8', "-d '$d1' +'%x_%X_%y_%Y'", {OUT=>"01/19/97_${t0}_97_1997"}], - ['9', "-d '$d1' +'%z'", {OUT=>"+0000"}], - - ['leap-1', "--date '02/29/1996 1 year' +%Y-%m-%d", {OUT=>"1997-03-01"}], - - ['U95-1', "--date '1995-1-1' +%U", {OUT=>"01"}], - ['U95-2', "--date '1995-1-7' +%U", {OUT=>"01"}], - ['U95-3', "--date '1995-1-8' +%U", {OUT=>"02"}], - - ['U92-1', "--date '1992-1-1' +%U", {OUT=>"00"}], - ['U92-2', "--date '1992-1-4' +%U", {OUT=>"00"}], - ['U92-3', "--date '1992-1-5' +%U", {OUT=>"01"}], - - ['V92-1', "--date '1992-1-1' +%V", {OUT=>"01"}], - ['V92-2', "--date '1992-1-5' +%V", {OUT=>"01"}], - ['V92-3', "--date '1992-1-6' +%V", {OUT=>"02"}], - - ['W92-1', "--date '1992-1-1' +%W", {OUT=>"00"}], - ['W92-2', "--date '1992-1-5' +%W", {OUT=>"00"}], - ['W92-3', "--date '1992-1-6' +%W", {OUT=>"01"}], - - ['millen-1', "--date '1998-1-1 3 years' +%Y", {OUT=>"2001"}], - - ['rel-0', "-d '$d1 now' '+%Y-%m-%d %T'", {OUT=>"$d0 $t0"}], - - ['rel-1a', "-d '$d1 yesterday' $fmt", {OUT=>"1997-01-18 $t0"}], - ['rel-1b', "-d '$d1 tomorrow' $fmt", {OUT=>"1997-01-20 $t0"}], - - ['rel-2a', "-d '$d1 6 years ago' $fmt", {OUT=>"1991-01-19 $t0"}], - ['rel-2b', "-d '$d1 7 months ago' $fmt", {OUT=>"1996-06-19 $t0"}], - ['rel-2c', "-d '$d1 8 weeks ago' $fmt", {OUT=>"1996-11-24 $t0"}], - ['rel-2d', "-d '$d1 1 day ago' $fmt", {OUT=>"1997-01-18 $t0"}], - ['rel-2e', "-d '$d1 2 hours ago' $fmt", {OUT=>"$d0 06:17:48"}], - ['rel-2f', "-d '$d1 3 minutes ago' $fmt", {OUT=>"$d0 08:14:48"}], - ['rel-2g', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}], - - ['rel-3a', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}], - - # This has always worked, ... - ['rel-1day', "-d '20050101 1 day' +%F", {OUT=>"2005-01-02"}], - # ...but up to coreutils-6.9, this was rejected due to the "+". - ['rel-plus1', "-d '20050101 +1 day' +%F", {OUT=>"2005-01-02"}], - - ['next-s', "-d '$d1 next second' '+%Y-%m-%d %T'", {OUT=>"$d0 $ts"}], - ['next-m', "-d '$d1 next minute' '+%Y-%m-%d %T'", {OUT=>"$d0 $tm"}], - ['next-h', "-d '$d1 next hour' '+%Y-%m-%d %T'", {OUT=>"$d0 $th"}], - ['next-d', "-d '$d1 next day' '+%Y-%m-%d %T'", {OUT=>"$dd $t0"}], - ['next-w', "-d '$d1 next week' '+%Y-%m-%d %T'", {OUT=>"$dw $t0"}], - ['next-mo', "-d '$d1 next month' '+%Y-%m-%d %T'", {OUT=>"$dm $t0"}], - ['next-y', "-d '$d1 next year' '+%Y-%m-%d %T'", {OUT=>"$dy $t0"}], - - ['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {OUT=>"08/01/97,06:00"}, - {ENV => 'TZ=UTC+4'}], - - ['utc-0a', "-u -d '08/01/97 6:00 UTC +4 hours' '+%D,%H:%M'", - {OUT=>"08/01/97,10:00"}], - # Make sure --file=FILE works with -u. - ['utc-1', "-u --file=f '+%Y-%m-%d %T'", - {AUX=>{f=>"$d0 $t0\n$d0 $t0"}}, - {OUT=>"$d0 $t0\n$d0 $t0"}, - {ENV => 'TZ=UTC+1'}], - - ['utc-1a', "-u --file=f '+%Y-%m-%d %T'", - {AUX=>{f=>"$d0 $t0 UTC +1 hour\n$d0 $t0 UTC +1 hour"}}, - {OUT=>"$d0 $th\n$d0 $th"}], - - # From the examples in the documentation. - ['date2sec-0', "-d '1970-01-01 00:00:01' +%s", {OUT=>"7201"}, - {ENV => 'TZ=UTC+2'}], - - # Same as above, but don't rely on TZ in environment. - ['date2sec-0a', "-d '1970-01-01 00:00:01 UTC +2 hours' +%s", - {OUT=>"7201"}], - - ['date2sec-1', "-d 2000-01-01 +%s", {OUT=>"946684800"}], - ['sec2date-0', "-d '1970-01-01 UTC 946684800 sec' +'%Y-%m-%d %T %z'", - {OUT=>"2000-01-01 00:00:00 +0000"}], - - ['this-m', "-d '$d0 $t0 this minute' $fmt", {OUT=>"$d0 $t0"}], - ['this-h', "-d '$d0 $t0 this hour' $fmt", {OUT=>"$d0 $t0"}], - ['this-w', "-d '$d0 $t0 this week' $fmt", {OUT=>"$d0 $t0"}], - ['this-mo', "-d '$d0 $t0 this month' $fmt", {OUT=>"$d0 $t0"}], - ['this-y', "-d '$d0 $t0 this year' $fmt", {OUT=>"$d0 $t0"}], - - ['risks-1', "-d 'Nov 10 1996' $fmt", {OUT=>"1996-11-10 00:00:00"}], - - # This one would pass if TZ (with any, or even no, value) were in - # the environment. - ['regress-1', "-u -d '1996-11-10 0:00:00 +0' $fmt", - {OUT=>"1996-11-10 00:00:00"}, - {ENV =>'LANG=C'}], - - - ['datevtime-1', "-d 000909 $fmt", {OUT=>"2000-09-09 00:00:00"}], - - # test for RFC-822 conformance - ['rfc822-1', "-R -d '$d1'", {OUT=>"Sun, 19 Jan 1997 08:17:48 +0000"}, - # Solaris 5.9's /bin/sh emits this diagnostic to stderr - # if you don't have support for the named locale. - {ERR_SUBST => q!s/^couldn't set locale correctly\n//!}, - {ENV => 'LC_ALL=de_DE TZ=UTC0'}], - - # Relative seconds, with time. fixed in 2.0j - ['relative-1', "--utc -d '1970-01-01 00:00:00 UTC +961062237 sec' $fmt", - {OUT=>"2000-06-15 09:43:57"}], - - # Relative seconds, no time. - ['relative-2', "--utc -d '1970-01-01 UTC +961062237 sec' $fmt", - {OUT=>"2000-06-15 09:43:57"}, - {ENV => 'TZ=UTC+1'}], - - # Relative days, no time, across time zones. - ['relative-3', "-I -d '2006-04-23 21 days ago'", {OUT=>"2006-04-02"}, - {ENV=>'TZ=PST8PDT,M4.1.0,M10.5.0'}], - - # This would infloop (or appear to) prior to coreutils-4.5.5, - # due to a bug in strftime.c. - ['wide-fmt', "-d '1999-06-01'", '+%3004Y', {OUT=>'0' x 3000 . "1999"}], - - # Ensure that we can parse MONTHNAME-DAY-YEAR. - ['moname-d-y', '--iso -d May-23-2003', {OUT=>"2003-05-23"}], - ['moname-d-y-r', '--rfc-3339=date -d May-23-2003', {OUT=>"2003-05-23"}], - - ['epoch', '--iso=sec -d @31536000', - {OUT=>"1971-01-01T00:00:00+0000"}], - ['epoch-r', '--rfc-3339=sec -d @31536000', - {OUT=>"1971-01-01 00:00:00+00:00"}], - - ['ns-10', '--iso=ns', '-d "1969-12-31 13:00:00.00000001-1100"', - {OUT=>"1970-01-01T00:00:00,000000010+0000"}], - ['ns-10-r', '--rfc-3339=ns', '-d "1969-12-31 13:00:00.00000001-1100"', - {OUT=>"1970-01-01 00:00:00.000000010+00:00"}], - - ['ns-max32', '--iso=ns', '-d "2038-01-19 03:14:07.999999999"', - {OUT=>"2038-01-19T03:14:07,999999999+0000"}], - ['ns-max32-r', '--rfc-3339=ns', '-d "2038-01-19 03:14:07.999999999"', - {OUT=>"2038-01-19 03:14:07.999999999+00:00"}], - - ['tz-1', '+%:::z', {OUT=>"-12:34:56"}, {ENV=>'TZ=XXX12:34:56'}], - - ['tz-2', '+%:::z', {OUT=>"+12:34:56"}, {ENV=>'TZ=XXX-12:34:56'}], - - ['tz-3', '+%::z', {OUT=>"+01:02:03"}, {ENV=>'TZ=XXX-1:02:03'}], - - ['tz-4', '+%:::z', {OUT=>"+12"}, {ENV=>'TZ=XXX-12'}], - - ['tz-5', '+%:z', {OUT=>"-00:01"}, {ENV=>'TZ=XXX0:01'}], - - # Accept %:z with a field width before the ':'. - ['tz-5w','+%8:z', {OUT=>"-0000:01"}, {ENV=>'TZ=XXX0:01'}], - # Don't recognize %:z with a field width between the ':' and the 'z'. - ['tz-5wf', '+%:8z', {OUT=>"%:8z"}, {ENV=>'TZ=XXX0:01'}], - - ['ns-relative', - '--iso=ns', - "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'", - {OUT=>"2000-06-15T09:43:58,111111021+0000"}], - ['ns-relativer', '--rfc-3339=ns', - "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'", - {OUT=>"2000-06-15 09:43:58.111111021+00:00"}], - - # Since coreutils/lib/getdate.y revision 1.96 (post-coreutils-5.3.0), - # a command like the following would mistakenly exit nonzero with an - # 'invalid date ...' diagnostic, but when run in a time zone for - # which daylight savings time is in effect for the starting date. - # Unfortunately (for ease of testing), if you set TZ at all, this - # failure is not triggered, hence the removal of TZ from the environment. - ['cross-dst', "-d'2005-03-27 +1 day'", '+%Y', {OUT=>"2005"}, - {ENV_DEL => 'TZ'}, - ], - - ['empty-fmt', '+', {OUT=>""}], - - ['neg-secs', '-d @-22 +%05s', {OUT=>"-0022"}], - ['neg-secs2', '-d @-22 +%_5s', {OUT=>" -22"}], - - # Before today's fix, date would print uninitialized data - # to standard output for an out-of-range date: - # $ date -d @$(echo 2^56-1|bc) 2> /dev/null | od -a -N3 - # 0000000 p 4 6 - # 0000003 - ['uninit-64', "-d \@$n_seconds", - {OUT=>''}, - # Use ERR_SUBST to get around fact that the diagnostic - # you get on a system with 32-bit time_t is not the same as - # the one you get for a system where it's 64 bits wide: - # - date: time 72057594037927935 is out of range - # + date: invalid date '@72057594037927935' - {ERR_SUBST => 's/.*//'}, - {ERR => "\n"}, - {EXIT => 1}, - ], - - ['fill-1', '-d 1999-12-08 +%_3d', {OUT=>' 8'}], - ['fill-2', '-d 1999-12-08 +%03d', {OUT=>'008'}], - - # Test the combination of the to-upper-case modifier (^) and a conversion - # specifier that expands to a string containing lower case characters. - ['subfmt-up1', '-d "1999-12-08 7:30" "+%^c"', - # Solaris 5.9 prints 'WED DEC 08 07:30:00 1999', while - # most others print 'WED DEC 8 07:30:00 1999'. - {OUT_SUBST => 's/ [ 0]8.*//'}, - {OUT=>'WED DEC'}], - - ['invalid-high-bit-set', "-d '\xb0'", - {ERR => "date: invalid date '\\260'\n"}, - {EXIT => 1}, - ], - ); - -# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364. -foreach my $i (1..364) - { - push @Tests, ["cross-dst$i", - "-d'2005-01-01 +$i day'", '+%Y', {OUT=>"2005"}, - {ENV_DEL => 'TZ'}, - ]; - } - -# Append "\n" to each OUT=> RHS if the expected exit value is either -# zero or not specified (defaults to zero). -foreach my $t (@Tests) - { - my $exit_val; - foreach my $e (@$t) - { - ref $e && ref $e eq 'HASH' && defined $e->{EXIT} - and $exit_val = $e->{EXIT}; - } - foreach my $e (@$t) - { - ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val - and $e->{OUT} .= "\n"; - } - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'date'; -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/date-next-dow b/tests/misc/date-next-dow deleted file mode 100755 index 7c85d2387..000000000 --- a/tests/misc/date-next-dow +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl -# Test "date". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; -use POSIX qw(strftime); - -(my $ME = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# Export TZ=UTC0 so that zone-dependent strings match. -$ENV{TZ} = 'UTC0'; - -my $now = time; -my @d = localtime ($now); -my @d_week = localtime ($now + 7 * 24 * 3600); -my $wday = $d[6]; -my $wday_str = qw(sun mon tue wed thu fri sat)[$wday]; - -my @Tests = - ( - # test-name, [option, option, ...] {OUT=>"expected-output"} - # - - # Running "date -d mon +%a" on a Monday must print Mon. - ['dow', "-d $wday_str +%a", {OUT => ucfirst $wday_str}], - # It had better be the same date, too. - ['dow2', "-d $wday_str +%Y-%m-%d", {OUT => strftime("%Y-%m-%d", @d)}], - - ['next-dow', "-d 'next $wday_str' +%Y-%m-%d", - {OUT => strftime("%Y-%m-%d", @d_week)}], - ); - -# Append "\n" to each OUT=> RHS if the expected exit value is either -# zero or not specified (defaults to zero). -foreach my $t (@Tests) - { - my $exit_val; - foreach my $e (@$t) - { - ref $e && ref $e eq 'HASH' && defined $e->{EXIT} - and $exit_val = $e->{EXIT}; - } - foreach my $e (@$t) - { - ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val - and $e->{OUT} .= "\n"; - } - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'date'; -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); - -# Skip the test if the starting and stopping day numbers differ. -my @d_post = localtime (time); -$d_post[7] == $d[7] - or CuSkip::skip "$ME: test straddled a day boundary; skipped"; - -exit $fail; diff --git a/tests/misc/date-next-dow.pl b/tests/misc/date-next-dow.pl new file mode 100755 index 000000000..7c85d2387 --- /dev/null +++ b/tests/misc/date-next-dow.pl @@ -0,0 +1,78 @@ +#!/usr/bin/perl +# Test "date". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use POSIX qw(strftime); + +(my $ME = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# Export TZ=UTC0 so that zone-dependent strings match. +$ENV{TZ} = 'UTC0'; + +my $now = time; +my @d = localtime ($now); +my @d_week = localtime ($now + 7 * 24 * 3600); +my $wday = $d[6]; +my $wday_str = qw(sun mon tue wed thu fri sat)[$wday]; + +my @Tests = + ( + # test-name, [option, option, ...] {OUT=>"expected-output"} + # + + # Running "date -d mon +%a" on a Monday must print Mon. + ['dow', "-d $wday_str +%a", {OUT => ucfirst $wday_str}], + # It had better be the same date, too. + ['dow2', "-d $wday_str +%Y-%m-%d", {OUT => strftime("%Y-%m-%d", @d)}], + + ['next-dow', "-d 'next $wday_str' +%Y-%m-%d", + {OUT => strftime("%Y-%m-%d", @d_week)}], + ); + +# Append "\n" to each OUT=> RHS if the expected exit value is either +# zero or not specified (defaults to zero). +foreach my $t (@Tests) + { + my $exit_val; + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' && defined $e->{EXIT} + and $exit_val = $e->{EXIT}; + } + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val + and $e->{OUT} .= "\n"; + } + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'date'; +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); + +# Skip the test if the starting and stopping day numbers differ. +my @d_post = localtime (time); +$d_post[7] == $d[7] + or CuSkip::skip "$ME: test straddled a day boundary; skipped"; + +exit $fail; diff --git a/tests/misc/date-sec b/tests/misc/date-sec deleted file mode 100755 index a46b47903..000000000 --- a/tests/misc/date-sec +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Ensure that a command like -# date --date="21:04 +0100" +%S' always prints '00'. -# Before coreutils-5.2.1, it would print the seconds from the current time. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ date - - - -# It would be easier simply to sleep for two seconds between two runs -# of $(date --date="21:04 +0100" +%S) and ensure that both outputs -# are '00', but I prefer not to sleep unconditionally. 'make check' -# takes long enough as it is. - -n=0 -# See if the current number of seconds is '00' or just before. -s=$(date +%S) -case "$s" in - 58) n=3;; - 59) n=2;; - 00) n=1;; -esac - -# If necessary, wait for the system clock to pass the minute mark. -test $n = 0 || sleep $n - -s=$(date --date="21:04 +0100" +%S) -case "$s" in - 00) ;; - *) fail=1;; -esac - -Exit $fail diff --git a/tests/misc/date-sec.sh b/tests/misc/date-sec.sh new file mode 100755 index 000000000..a46b47903 --- /dev/null +++ b/tests/misc/date-sec.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Ensure that a command like +# date --date="21:04 +0100" +%S' always prints '00'. +# Before coreutils-5.2.1, it would print the seconds from the current time. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ date + + + +# It would be easier simply to sleep for two seconds between two runs +# of $(date --date="21:04 +0100" +%S) and ensure that both outputs +# are '00', but I prefer not to sleep unconditionally. 'make check' +# takes long enough as it is. + +n=0 +# See if the current number of seconds is '00' or just before. +s=$(date +%S) +case "$s" in + 58) n=3;; + 59) n=2;; + 00) n=1;; +esac + +# If necessary, wait for the system clock to pass the minute mark. +test $n = 0 || sleep $n + +s=$(date --date="21:04 +0100" +%S) +case "$s" in + 00) ;; + *) fail=1;; +esac + +Exit $fail diff --git a/tests/misc/date.pl b/tests/misc/date.pl new file mode 100755 index 000000000..8b6fdb24d --- /dev/null +++ b/tests/misc/date.pl @@ -0,0 +1,323 @@ +#!/usr/bin/perl +# Test "date". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $ME = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# Export TZ=UTC0 so that zone-dependent strings match. +$ENV{TZ} = 'UTC0'; + +my $t0 = '08:17:48'; +my $d0 = '1997-01-19'; +my $d1 = "$d0 $t0 +0"; +my $dT = "${d0}T$t0+0"; # ISO 8601 with "T" separator + +my $ts = '08:17:49'; # next second +my $tm = '08:18:48'; # next minute +my $th = '09:17:48'; # next hour + +my $dd = '1997-01-20'; # next day +my $dw = '1997-01-26'; # next week +my $dm = '1997-02-19'; # next month +my $dy = '1998-01-19'; # next month + +my $fmt = "'+%Y-%m-%d %T'"; + +# Determine a number of seconds that will provoke an invalid +# time diagnostic from date. If possible, use a number that +# is less than 2^64, yet so large that it would cause the resulting +# tm_year value to be too large for a 32-bit int. But some systems +# (Solaris 8) have a buggy localtime that mistakenly accepts such +# invalid times and give garbage in tm_year. Other systems might +# have an int type that is wider than 32. So if this localtime +# call succeeds, use 2^64 as the number of seconds. +my $n_seconds = 72057594037927935; +my @d = localtime ($n_seconds); +my $year = $d[5]; +defined $year + and $n_seconds = '18446744073709551616'; + +my @Tests = + ( + # test-name, [option, option, ...] {OUT=>"expected-output"} + # + ['1', "-d '$d1' +'%% %a %A %b %B'", {OUT=>"% Sun Sunday Jan January"}], + + # [Actually, skip it on *all* systems. -- this Perl code is run at + # distribution-build-time, not at configure/test time. ] + + # Skip the test of %c on SunOS4 systems. Such systems would fail this + # test because their underlying strftime doesn't handle the %c format + # properly. GNU strftime must rely on the underlying host library + # function to get locale-dependent behavior, as strftime is the only + # portable interface to that behavior. + # ['2', "-d '$d1' +'%c'", {OUT=>"Sun Jan 19 $t0 1997"}], + + ['3', "-d '$d1' +'%d_%D_%e_%h_%H'", {OUT=>"19_01/19/97_19_Jan_08"}], + ['3T',"-d '$dT' +'%d_%D_%e_%h_%H'", {OUT=>"19_01/19/97_19_Jan_08"}], + + ['4', "-d '$d1' +'%I_%j_%k_%l_%m'", {OUT=>"08_019_ 8_ 8_01"}], + ['5', "-d '$d1' +'%M_%n_%p_%r'", {OUT=>"17_\n_AM_$t0 AM"}], + ['6', "-d '$d1' +'%s_%S_%t_%T'", {OUT=>"853661868_48_\t_$t0"}], + ['7', "-d '$d1' +'%U_%V_%w_%W'", {OUT=>"03_03_0_02"}], + ['8', "-d '$d1' +'%x_%X_%y_%Y'", {OUT=>"01/19/97_${t0}_97_1997"}], + ['9', "-d '$d1' +'%z'", {OUT=>"+0000"}], + + ['leap-1', "--date '02/29/1996 1 year' +%Y-%m-%d", {OUT=>"1997-03-01"}], + + ['U95-1', "--date '1995-1-1' +%U", {OUT=>"01"}], + ['U95-2', "--date '1995-1-7' +%U", {OUT=>"01"}], + ['U95-3', "--date '1995-1-8' +%U", {OUT=>"02"}], + + ['U92-1', "--date '1992-1-1' +%U", {OUT=>"00"}], + ['U92-2', "--date '1992-1-4' +%U", {OUT=>"00"}], + ['U92-3', "--date '1992-1-5' +%U", {OUT=>"01"}], + + ['V92-1', "--date '1992-1-1' +%V", {OUT=>"01"}], + ['V92-2', "--date '1992-1-5' +%V", {OUT=>"01"}], + ['V92-3', "--date '1992-1-6' +%V", {OUT=>"02"}], + + ['W92-1', "--date '1992-1-1' +%W", {OUT=>"00"}], + ['W92-2', "--date '1992-1-5' +%W", {OUT=>"00"}], + ['W92-3', "--date '1992-1-6' +%W", {OUT=>"01"}], + + ['millen-1', "--date '1998-1-1 3 years' +%Y", {OUT=>"2001"}], + + ['rel-0', "-d '$d1 now' '+%Y-%m-%d %T'", {OUT=>"$d0 $t0"}], + + ['rel-1a', "-d '$d1 yesterday' $fmt", {OUT=>"1997-01-18 $t0"}], + ['rel-1b', "-d '$d1 tomorrow' $fmt", {OUT=>"1997-01-20 $t0"}], + + ['rel-2a', "-d '$d1 6 years ago' $fmt", {OUT=>"1991-01-19 $t0"}], + ['rel-2b', "-d '$d1 7 months ago' $fmt", {OUT=>"1996-06-19 $t0"}], + ['rel-2c', "-d '$d1 8 weeks ago' $fmt", {OUT=>"1996-11-24 $t0"}], + ['rel-2d', "-d '$d1 1 day ago' $fmt", {OUT=>"1997-01-18 $t0"}], + ['rel-2e', "-d '$d1 2 hours ago' $fmt", {OUT=>"$d0 06:17:48"}], + ['rel-2f', "-d '$d1 3 minutes ago' $fmt", {OUT=>"$d0 08:14:48"}], + ['rel-2g', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}], + + ['rel-3a', "-d '$d1 4 seconds ago' $fmt", {OUT=>"$d0 08:17:44"}], + + # This has always worked, ... + ['rel-1day', "-d '20050101 1 day' +%F", {OUT=>"2005-01-02"}], + # ...but up to coreutils-6.9, this was rejected due to the "+". + ['rel-plus1', "-d '20050101 +1 day' +%F", {OUT=>"2005-01-02"}], + + ['next-s', "-d '$d1 next second' '+%Y-%m-%d %T'", {OUT=>"$d0 $ts"}], + ['next-m', "-d '$d1 next minute' '+%Y-%m-%d %T'", {OUT=>"$d0 $tm"}], + ['next-h', "-d '$d1 next hour' '+%Y-%m-%d %T'", {OUT=>"$d0 $th"}], + ['next-d', "-d '$d1 next day' '+%Y-%m-%d %T'", {OUT=>"$dd $t0"}], + ['next-w', "-d '$d1 next week' '+%Y-%m-%d %T'", {OUT=>"$dw $t0"}], + ['next-mo', "-d '$d1 next month' '+%Y-%m-%d %T'", {OUT=>"$dm $t0"}], + ['next-y', "-d '$d1 next year' '+%Y-%m-%d %T'", {OUT=>"$dy $t0"}], + + ['utc-0', "-u -d '08/01/97 6:00' '+%D,%H:%M'", {OUT=>"08/01/97,06:00"}, + {ENV => 'TZ=UTC+4'}], + + ['utc-0a', "-u -d '08/01/97 6:00 UTC +4 hours' '+%D,%H:%M'", + {OUT=>"08/01/97,10:00"}], + # Make sure --file=FILE works with -u. + ['utc-1', "-u --file=f '+%Y-%m-%d %T'", + {AUX=>{f=>"$d0 $t0\n$d0 $t0"}}, + {OUT=>"$d0 $t0\n$d0 $t0"}, + {ENV => 'TZ=UTC+1'}], + + ['utc-1a', "-u --file=f '+%Y-%m-%d %T'", + {AUX=>{f=>"$d0 $t0 UTC +1 hour\n$d0 $t0 UTC +1 hour"}}, + {OUT=>"$d0 $th\n$d0 $th"}], + + # From the examples in the documentation. + ['date2sec-0', "-d '1970-01-01 00:00:01' +%s", {OUT=>"7201"}, + {ENV => 'TZ=UTC+2'}], + + # Same as above, but don't rely on TZ in environment. + ['date2sec-0a', "-d '1970-01-01 00:00:01 UTC +2 hours' +%s", + {OUT=>"7201"}], + + ['date2sec-1', "-d 2000-01-01 +%s", {OUT=>"946684800"}], + ['sec2date-0', "-d '1970-01-01 UTC 946684800 sec' +'%Y-%m-%d %T %z'", + {OUT=>"2000-01-01 00:00:00 +0000"}], + + ['this-m', "-d '$d0 $t0 this minute' $fmt", {OUT=>"$d0 $t0"}], + ['this-h', "-d '$d0 $t0 this hour' $fmt", {OUT=>"$d0 $t0"}], + ['this-w', "-d '$d0 $t0 this week' $fmt", {OUT=>"$d0 $t0"}], + ['this-mo', "-d '$d0 $t0 this month' $fmt", {OUT=>"$d0 $t0"}], + ['this-y', "-d '$d0 $t0 this year' $fmt", {OUT=>"$d0 $t0"}], + + ['risks-1', "-d 'Nov 10 1996' $fmt", {OUT=>"1996-11-10 00:00:00"}], + + # This one would pass if TZ (with any, or even no, value) were in + # the environment. + ['regress-1', "-u -d '1996-11-10 0:00:00 +0' $fmt", + {OUT=>"1996-11-10 00:00:00"}, + {ENV =>'LANG=C'}], + + + ['datevtime-1', "-d 000909 $fmt", {OUT=>"2000-09-09 00:00:00"}], + + # test for RFC-822 conformance + ['rfc822-1', "-R -d '$d1'", {OUT=>"Sun, 19 Jan 1997 08:17:48 +0000"}, + # Solaris 5.9's /bin/sh emits this diagnostic to stderr + # if you don't have support for the named locale. + {ERR_SUBST => q!s/^couldn't set locale correctly\n//!}, + {ENV => 'LC_ALL=de_DE TZ=UTC0'}], + + # Relative seconds, with time. fixed in 2.0j + ['relative-1', "--utc -d '1970-01-01 00:00:00 UTC +961062237 sec' $fmt", + {OUT=>"2000-06-15 09:43:57"}], + + # Relative seconds, no time. + ['relative-2', "--utc -d '1970-01-01 UTC +961062237 sec' $fmt", + {OUT=>"2000-06-15 09:43:57"}, + {ENV => 'TZ=UTC+1'}], + + # Relative days, no time, across time zones. + ['relative-3', "-I -d '2006-04-23 21 days ago'", {OUT=>"2006-04-02"}, + {ENV=>'TZ=PST8PDT,M4.1.0,M10.5.0'}], + + # This would infloop (or appear to) prior to coreutils-4.5.5, + # due to a bug in strftime.c. + ['wide-fmt', "-d '1999-06-01'", '+%3004Y', {OUT=>'0' x 3000 . "1999"}], + + # Ensure that we can parse MONTHNAME-DAY-YEAR. + ['moname-d-y', '--iso -d May-23-2003', {OUT=>"2003-05-23"}], + ['moname-d-y-r', '--rfc-3339=date -d May-23-2003', {OUT=>"2003-05-23"}], + + ['epoch', '--iso=sec -d @31536000', + {OUT=>"1971-01-01T00:00:00+0000"}], + ['epoch-r', '--rfc-3339=sec -d @31536000', + {OUT=>"1971-01-01 00:00:00+00:00"}], + + ['ns-10', '--iso=ns', '-d "1969-12-31 13:00:00.00000001-1100"', + {OUT=>"1970-01-01T00:00:00,000000010+0000"}], + ['ns-10-r', '--rfc-3339=ns', '-d "1969-12-31 13:00:00.00000001-1100"', + {OUT=>"1970-01-01 00:00:00.000000010+00:00"}], + + ['ns-max32', '--iso=ns', '-d "2038-01-19 03:14:07.999999999"', + {OUT=>"2038-01-19T03:14:07,999999999+0000"}], + ['ns-max32-r', '--rfc-3339=ns', '-d "2038-01-19 03:14:07.999999999"', + {OUT=>"2038-01-19 03:14:07.999999999+00:00"}], + + ['tz-1', '+%:::z', {OUT=>"-12:34:56"}, {ENV=>'TZ=XXX12:34:56'}], + + ['tz-2', '+%:::z', {OUT=>"+12:34:56"}, {ENV=>'TZ=XXX-12:34:56'}], + + ['tz-3', '+%::z', {OUT=>"+01:02:03"}, {ENV=>'TZ=XXX-1:02:03'}], + + ['tz-4', '+%:::z', {OUT=>"+12"}, {ENV=>'TZ=XXX-12'}], + + ['tz-5', '+%:z', {OUT=>"-00:01"}, {ENV=>'TZ=XXX0:01'}], + + # Accept %:z with a field width before the ':'. + ['tz-5w','+%8:z', {OUT=>"-0000:01"}, {ENV=>'TZ=XXX0:01'}], + # Don't recognize %:z with a field width between the ':' and the 'z'. + ['tz-5wf', '+%:8z', {OUT=>"%:8z"}, {ENV=>'TZ=XXX0:01'}], + + ['ns-relative', + '--iso=ns', + "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'", + {OUT=>"2000-06-15T09:43:58,111111021+0000"}], + ['ns-relativer', '--rfc-3339=ns', + "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'", + {OUT=>"2000-06-15 09:43:58.111111021+00:00"}], + + # Since coreutils/lib/getdate.y revision 1.96 (post-coreutils-5.3.0), + # a command like the following would mistakenly exit nonzero with an + # 'invalid date ...' diagnostic, but when run in a time zone for + # which daylight savings time is in effect for the starting date. + # Unfortunately (for ease of testing), if you set TZ at all, this + # failure is not triggered, hence the removal of TZ from the environment. + ['cross-dst', "-d'2005-03-27 +1 day'", '+%Y', {OUT=>"2005"}, + {ENV_DEL => 'TZ'}, + ], + + ['empty-fmt', '+', {OUT=>""}], + + ['neg-secs', '-d @-22 +%05s', {OUT=>"-0022"}], + ['neg-secs2', '-d @-22 +%_5s', {OUT=>" -22"}], + + # Before today's fix, date would print uninitialized data + # to standard output for an out-of-range date: + # $ date -d @$(echo 2^56-1|bc) 2> /dev/null | od -a -N3 + # 0000000 p 4 6 + # 0000003 + ['uninit-64', "-d \@$n_seconds", + {OUT=>''}, + # Use ERR_SUBST to get around fact that the diagnostic + # you get on a system with 32-bit time_t is not the same as + # the one you get for a system where it's 64 bits wide: + # - date: time 72057594037927935 is out of range + # + date: invalid date '@72057594037927935' + {ERR_SUBST => 's/.*//'}, + {ERR => "\n"}, + {EXIT => 1}, + ], + + ['fill-1', '-d 1999-12-08 +%_3d', {OUT=>' 8'}], + ['fill-2', '-d 1999-12-08 +%03d', {OUT=>'008'}], + + # Test the combination of the to-upper-case modifier (^) and a conversion + # specifier that expands to a string containing lower case characters. + ['subfmt-up1', '-d "1999-12-08 7:30" "+%^c"', + # Solaris 5.9 prints 'WED DEC 08 07:30:00 1999', while + # most others print 'WED DEC 8 07:30:00 1999'. + {OUT_SUBST => 's/ [ 0]8.*//'}, + {OUT=>'WED DEC'}], + + ['invalid-high-bit-set', "-d '\xb0'", + {ERR => "date: invalid date '\\260'\n"}, + {EXIT => 1}, + ], + ); + +# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364. +foreach my $i (1..364) + { + push @Tests, ["cross-dst$i", + "-d'2005-01-01 +$i day'", '+%Y', {OUT=>"2005"}, + {ENV_DEL => 'TZ'}, + ]; + } + +# Append "\n" to each OUT=> RHS if the expected exit value is either +# zero or not specified (defaults to zero). +foreach my $t (@Tests) + { + my $exit_val; + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' && defined $e->{EXIT} + and $exit_val = $e->{EXIT}; + } + foreach my $e (@$t) + { + ref $e && ref $e eq 'HASH' && defined $e->{OUT} && ! $exit_val + and $e->{OUT} .= "\n"; + } + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'date'; +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/dircolors b/tests/misc/dircolors deleted file mode 100755 index e2a703e36..000000000 --- a/tests/misc/dircolors +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/perl -# Simple dircolors tests. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['a', '-b', {IN => {k => "exec\n"}}, - {ERR => "dircolors: k:1: invalid line; missing second token\n"}, - {EXIT => 1}], - ['quote', '-b', {IN => "exec 'echo Hello;:'\n"}, - {OUT => "LS_COLORS='ex='\\''echo Hello;\\:'\\'':';\n" - . "export LS_COLORS\n"}], - ['other-wr', '-b', {IN => "owt 40;33\n"}, - {OUT => "LS_COLORS='tw=40;33:';\nexport LS_COLORS\n"}], - - # CAREFUL: always specify the -b option, unless explicitly testing - # for csh syntax output. - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'dircolors'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/dircolors.pl b/tests/misc/dircolors.pl new file mode 100755 index 000000000..e2a703e36 --- /dev/null +++ b/tests/misc/dircolors.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl +# Simple dircolors tests. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['a', '-b', {IN => {k => "exec\n"}}, + {ERR => "dircolors: k:1: invalid line; missing second token\n"}, + {EXIT => 1}], + ['quote', '-b', {IN => "exec 'echo Hello;:'\n"}, + {OUT => "LS_COLORS='ex='\\''echo Hello;\\:'\\'':';\n" + . "export LS_COLORS\n"}], + ['other-wr', '-b', {IN => "owt 40;33\n"}, + {OUT => "LS_COLORS='tw=40;33:';\nexport LS_COLORS\n"}], + + # CAREFUL: always specify the -b option, unless explicitly testing + # for csh syntax output. + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'dircolors'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/dirname b/tests/misc/dirname deleted file mode 100755 index 002183678..000000000 --- a/tests/misc/dirname +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/perl -# Test "dirname". - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; -use File::stat; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $stat_single = stat('/'); -my $stat_double = stat('//'); -my $double_slash = ($stat_single->dev == $stat_double->dev - && $stat_single->ino == $stat_double->ino) ? '/' : '//'; - -my $prog = 'dirname'; - -my @Tests = - ( - ['fail-1', {ERR => "$prog: missing operand\n" - . "Try '$prog --help' for more information.\n"}, {EXIT => '1'}], - - ['a', qw(d/f), {OUT => 'd'}], - ['b', qw(/d/f), {OUT => '/d'}], - ['c', qw(d/f/), {OUT => 'd'}], - ['d', qw(d/f//), {OUT => 'd'}], - ['e', qw(f), {OUT => '.'}], - ['f', qw(/), {OUT => '/'}], - ['g', qw(//), {OUT => "$double_slash"}], - ['h', qw(///), {OUT => '/'}], - ['i', qw(//a//), {OUT => "$double_slash"}], - ['j', qw(///a///), {OUT => '/'}], - ['k', qw(///a///b), {OUT => '///a'}], - ['l', qw(///a//b/), {OUT => '///a'}], - ['m', qw(''), {OUT => '.'}], - ['n', qw(a/b c/d), {OUT => "a\nc"}], - ); - -# Append a newline to end of each expected 'OUT' string. -my $t; -foreach $t (@Tests) - { - my $arg1 = $t->[1]; - my $e; - foreach $e (@$t) - { - $e->{OUT} = "$e->{OUT}\n" - if ref $e eq 'HASH' and exists $e->{OUT}; - } - } - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/dirname.pl b/tests/misc/dirname.pl new file mode 100755 index 000000000..002183678 --- /dev/null +++ b/tests/misc/dirname.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl +# Test "dirname". + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use File::stat; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $stat_single = stat('/'); +my $stat_double = stat('//'); +my $double_slash = ($stat_single->dev == $stat_double->dev + && $stat_single->ino == $stat_double->ino) ? '/' : '//'; + +my $prog = 'dirname'; + +my @Tests = + ( + ['fail-1', {ERR => "$prog: missing operand\n" + . "Try '$prog --help' for more information.\n"}, {EXIT => '1'}], + + ['a', qw(d/f), {OUT => 'd'}], + ['b', qw(/d/f), {OUT => '/d'}], + ['c', qw(d/f/), {OUT => 'd'}], + ['d', qw(d/f//), {OUT => 'd'}], + ['e', qw(f), {OUT => '.'}], + ['f', qw(/), {OUT => '/'}], + ['g', qw(//), {OUT => "$double_slash"}], + ['h', qw(///), {OUT => '/'}], + ['i', qw(//a//), {OUT => "$double_slash"}], + ['j', qw(///a///), {OUT => '/'}], + ['k', qw(///a///b), {OUT => '///a'}], + ['l', qw(///a//b/), {OUT => '///a'}], + ['m', qw(''), {OUT => '.'}], + ['n', qw(a/b c/d), {OUT => "a\nc"}], + ); + +# Append a newline to end of each expected 'OUT' string. +my $t; +foreach $t (@Tests) + { + my $arg1 = $t->[1]; + my $e; + foreach $e (@$t) + { + $e->{OUT} = "$e->{OUT}\n" + if ref $e eq 'HASH' and exists $e->{OUT}; + } + } + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/env b/tests/misc/env deleted file mode 100755 index 6f8c064ce..000000000 --- a/tests/misc/env +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/sh -# Verify behavior of env. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ env - - -# Verify clearing the environment -a=1 -export a -env - > out || fail=1 -test -s out && fail=1 -env -i > out || fail=1 -test -s out && fail=1 -env -u a -i -u a -- > out || fail=1 -test -s out && fail=1 -env -i -- a=b > out || fail=1 -echo a=b > exp || framework_failure_ -compare exp out || fail=1 - -# These tests verify exact status of internal failure. -env --- # unknown option -test $? = 125 || fail=1 -env -u # missing option argument -test $? = 125 || fail=1 -env sh -c 'exit 2' # exit status propagation -test $? = 2 || fail=2 -env . # invalid command -test $? = 126 || fail=1 -env no_such # no such command -test $? = 127 || fail=1 - -# POSIX is clear that environ may, but need not be, sorted. -# Environment variable values may contain newlines, which cannot be -# observed by merely inspecting output from env. -# Cygwin requires a minimal environment to launch new processes: execve -# adds missing variables SYSTEMROOT and WINDIR, which show up in a -# subsequent env. Cygwin also requires /bin to always be part of PATH, -# and attempts to unset or reduce PATH may cause execve to fail. -# -# For these reasons, it is more portable to grep that our desired changes -# took place, rather than comparing output of env over an entire environment. -if env | grep '^ENV_TEST' >/dev/null ; then - skip_ "environment has potential interference from ENV_TEST*" -fi - -ENV_TEST1=a -export ENV_TEST1 -: >out || framework_failure_ -env ENV_TEST2= > all || fail=1 -grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ -env -u ENV_TEST1 ENV_TEST3=c > all || fail=1 -grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ -env ENV_TEST1=b > all || fail=1 -grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ -env ENV_TEST2= env > all || fail=1 -grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ -env -u ENV_TEST1 ENV_TEST3=c env > all || fail=1 -grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ -env ENV_TEST1=b env > all || fail=1 -grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ -cat <exp || framework_failure_ -ENV_TEST1=a -ENV_TEST2= -ENV_TEST3=c -ENV_TEST1=b -ENV_TEST1=a -ENV_TEST2= -ENV_TEST3=c -ENV_TEST1=b -EOF -compare exp out || fail=1 - -# PATH modifications affect exec. -mkdir unlikely_name || framework_failure_ -cat < unlikely_name/also_unlikely || framework_failure_ -#!/bin/sh -echo pass -EOF -chmod +x unlikely_name/also_unlikely || framework_failure_ -env also_unlikely && fail=1 -test x$(PATH=$PATH:unlikely_name env also_unlikely) = xpass || fail=1 -test x$(env PATH="$PATH":unlikely_name also_unlikely) = xpass || fail=1 - -# Explicitly put . on the PATH for the rest of this test. -PATH=$PATH: -export PATH - -# Use -- to end options (but not variable assignments). -# On some systems, execve("-i") invokes a shebang script ./-i on PATH as -# '/bin/sh -i', rather than '/bin/sh -- -i', which doesn't do what we want. -# Avoid the issue by using an executable rather than a script. -# Test -u, rather than -i, to minimize PATH problems. -ln -s "$abs_top_builddir/src/echo" ./-u || framework_failure_ -case $(env -u echo echo good) in - good) ;; - *) fail=1 ;; -esac -case $(env -u echo -- echo good) in - good) ;; - *) fail=1 ;; -esac -case $(env -- -u pass) in - pass) ;; - *) fail=1 ;; -esac - -# After options have ended, the first argument not containing = is a program. -env a=b -- true -test $? = 127 || fail=1 -ln -s "$abs_top_builddir/src/echo" ./-- || framework_failure_ -case $(env a=b -- true || echo fail) in - true) ;; - *) fail=1 ;; -esac - -# No way to directly invoke program name containing =. -cat <./c=d || framework_failure_ -#!/bin/sh -echo pass -EOF -chmod +x c=d || framework_failure_ -test "x$(env c=d echo fail)" = xfail || fail=1 -test "x$(env -- c=d echo fail)" = xfail || fail=1 -test "x$(env ./c=d echo fail)" = xfail || fail=1 -test "x$(env sh -c 'exec "$@"' sh c=d echo fail)" = xpass || fail=1 -test "x$(sh -c '\c=d echo fail')" = xpass && #dash 0.5.4 fails so check first - { test "x$(env sh -c '\c=d echo fail')" = xpass || fail=1; } - -# catch unsetenv failure, broken through coreutils 8.0 -env -u a=b true && fail=1 -test $? = 125 || fail=1 -env -u '' true && fail=1 -test $? = 125 || fail=1 - -Exit $fail diff --git a/tests/misc/env-null b/tests/misc/env-null deleted file mode 100755 index 0190bf413..000000000 --- a/tests/misc/env-null +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# Verify behavior of env -0 and printenv -0. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ env printenv - -# POSIX is clear that environ may, but need not be, sorted. -# Environment variable values may contain newlines, which cannot be -# observed by merely inspecting output from env. -# Cygwin requires a minimal environment to launch new processes: execve -# adds missing variables SYSTEMROOT and WINDIR, which show up in a -# subsequent env. Cygwin also requires /bin to always be part of PATH, -# and attempts to unset or reduce PATH may cause execve to fail. -# -# For these reasons, it is better to compare two outputs from distinct -# programs that should be the same, rather than building an exp file. -env -i PATH="$PATH" env -0 > out1 || fail=1 -env -i PATH="$PATH" printenv -0 > out2 || fail=1 -compare out1 out2 || fail=1 -env -i PATH="$PATH" env --null > out2 || fail=1 -compare out1 out2 || fail=1 -env -i PATH="$PATH" printenv --null > out2 || fail=1 -compare out1 out2 || fail=1 - -# env -0 does not work if a command is specified. -env -0 echo hi > out -test $? = 125 || fail=1 -test -s out && fail=1 - -# Test env -0 on a one-variable environment. -printf 'a=b\nc=\0' > exp || framework_failure_ -env -i -0 "$(printf 'a=b\nc=')" > out || fail=1 -compare exp out || fail=1 - -# Test printenv -0 on particular values. -printf 'b\nc=\0' > exp || framework_failure_ -env "$(printf 'a=b\nc=')" printenv -0 a > out || fail=1 -compare exp out || fail=1 -env -u a printenv -0 a > out -test $? = 1 || fail=1 -test -s out && fail=1 -env -u b "$(printf 'a=b\nc=')" printenv -0 b a > out -test $? = 1 || fail=1 -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/env-null.sh b/tests/misc/env-null.sh new file mode 100755 index 000000000..0190bf413 --- /dev/null +++ b/tests/misc/env-null.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Verify behavior of env -0 and printenv -0. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ env printenv + +# POSIX is clear that environ may, but need not be, sorted. +# Environment variable values may contain newlines, which cannot be +# observed by merely inspecting output from env. +# Cygwin requires a minimal environment to launch new processes: execve +# adds missing variables SYSTEMROOT and WINDIR, which show up in a +# subsequent env. Cygwin also requires /bin to always be part of PATH, +# and attempts to unset or reduce PATH may cause execve to fail. +# +# For these reasons, it is better to compare two outputs from distinct +# programs that should be the same, rather than building an exp file. +env -i PATH="$PATH" env -0 > out1 || fail=1 +env -i PATH="$PATH" printenv -0 > out2 || fail=1 +compare out1 out2 || fail=1 +env -i PATH="$PATH" env --null > out2 || fail=1 +compare out1 out2 || fail=1 +env -i PATH="$PATH" printenv --null > out2 || fail=1 +compare out1 out2 || fail=1 + +# env -0 does not work if a command is specified. +env -0 echo hi > out +test $? = 125 || fail=1 +test -s out && fail=1 + +# Test env -0 on a one-variable environment. +printf 'a=b\nc=\0' > exp || framework_failure_ +env -i -0 "$(printf 'a=b\nc=')" > out || fail=1 +compare exp out || fail=1 + +# Test printenv -0 on particular values. +printf 'b\nc=\0' > exp || framework_failure_ +env "$(printf 'a=b\nc=')" printenv -0 a > out || fail=1 +compare exp out || fail=1 +env -u a printenv -0 a > out +test $? = 1 || fail=1 +test -s out && fail=1 +env -u b "$(printf 'a=b\nc=')" printenv -0 b a > out +test $? = 1 || fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/env.sh b/tests/misc/env.sh new file mode 100755 index 000000000..6f8c064ce --- /dev/null +++ b/tests/misc/env.sh @@ -0,0 +1,152 @@ +#!/bin/sh +# Verify behavior of env. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ env + + +# Verify clearing the environment +a=1 +export a +env - > out || fail=1 +test -s out && fail=1 +env -i > out || fail=1 +test -s out && fail=1 +env -u a -i -u a -- > out || fail=1 +test -s out && fail=1 +env -i -- a=b > out || fail=1 +echo a=b > exp || framework_failure_ +compare exp out || fail=1 + +# These tests verify exact status of internal failure. +env --- # unknown option +test $? = 125 || fail=1 +env -u # missing option argument +test $? = 125 || fail=1 +env sh -c 'exit 2' # exit status propagation +test $? = 2 || fail=2 +env . # invalid command +test $? = 126 || fail=1 +env no_such # no such command +test $? = 127 || fail=1 + +# POSIX is clear that environ may, but need not be, sorted. +# Environment variable values may contain newlines, which cannot be +# observed by merely inspecting output from env. +# Cygwin requires a minimal environment to launch new processes: execve +# adds missing variables SYSTEMROOT and WINDIR, which show up in a +# subsequent env. Cygwin also requires /bin to always be part of PATH, +# and attempts to unset or reduce PATH may cause execve to fail. +# +# For these reasons, it is more portable to grep that our desired changes +# took place, rather than comparing output of env over an entire environment. +if env | grep '^ENV_TEST' >/dev/null ; then + skip_ "environment has potential interference from ENV_TEST*" +fi + +ENV_TEST1=a +export ENV_TEST1 +: >out || framework_failure_ +env ENV_TEST2= > all || fail=1 +grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ +env -u ENV_TEST1 ENV_TEST3=c > all || fail=1 +grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ +env ENV_TEST1=b > all || fail=1 +grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ +env ENV_TEST2= env > all || fail=1 +grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ +env -u ENV_TEST1 ENV_TEST3=c env > all || fail=1 +grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ +env ENV_TEST1=b env > all || fail=1 +grep '^ENV_TEST' all | LC_ALL=C sort >> out || framework_failure_ +cat <exp || framework_failure_ +ENV_TEST1=a +ENV_TEST2= +ENV_TEST3=c +ENV_TEST1=b +ENV_TEST1=a +ENV_TEST2= +ENV_TEST3=c +ENV_TEST1=b +EOF +compare exp out || fail=1 + +# PATH modifications affect exec. +mkdir unlikely_name || framework_failure_ +cat < unlikely_name/also_unlikely || framework_failure_ +#!/bin/sh +echo pass +EOF +chmod +x unlikely_name/also_unlikely || framework_failure_ +env also_unlikely && fail=1 +test x$(PATH=$PATH:unlikely_name env also_unlikely) = xpass || fail=1 +test x$(env PATH="$PATH":unlikely_name also_unlikely) = xpass || fail=1 + +# Explicitly put . on the PATH for the rest of this test. +PATH=$PATH: +export PATH + +# Use -- to end options (but not variable assignments). +# On some systems, execve("-i") invokes a shebang script ./-i on PATH as +# '/bin/sh -i', rather than '/bin/sh -- -i', which doesn't do what we want. +# Avoid the issue by using an executable rather than a script. +# Test -u, rather than -i, to minimize PATH problems. +ln -s "$abs_top_builddir/src/echo" ./-u || framework_failure_ +case $(env -u echo echo good) in + good) ;; + *) fail=1 ;; +esac +case $(env -u echo -- echo good) in + good) ;; + *) fail=1 ;; +esac +case $(env -- -u pass) in + pass) ;; + *) fail=1 ;; +esac + +# After options have ended, the first argument not containing = is a program. +env a=b -- true +test $? = 127 || fail=1 +ln -s "$abs_top_builddir/src/echo" ./-- || framework_failure_ +case $(env a=b -- true || echo fail) in + true) ;; + *) fail=1 ;; +esac + +# No way to directly invoke program name containing =. +cat <./c=d || framework_failure_ +#!/bin/sh +echo pass +EOF +chmod +x c=d || framework_failure_ +test "x$(env c=d echo fail)" = xfail || fail=1 +test "x$(env -- c=d echo fail)" = xfail || fail=1 +test "x$(env ./c=d echo fail)" = xfail || fail=1 +test "x$(env sh -c 'exec "$@"' sh c=d echo fail)" = xpass || fail=1 +test "x$(sh -c '\c=d echo fail')" = xpass && #dash 0.5.4 fails so check first + { test "x$(env sh -c '\c=d echo fail')" = xpass || fail=1; } + +# catch unsetenv failure, broken through coreutils 8.0 +env -u a=b true && fail=1 +test $? = 125 || fail=1 +env -u '' true && fail=1 +test $? = 125 || fail=1 + +Exit $fail diff --git a/tests/misc/expand b/tests/misc/expand deleted file mode 100755 index 581a912d7..000000000 --- a/tests/misc/expand +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -# Exercise expand. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['t1', '--tabs=3', {IN=>"a\tb"}, {OUT=>"a b"}], - ['t2', '--tabs=3,6,9', {IN=>"a\tb\tc\td\te"}, {OUT=>"a b c d e"}], - ['i1', '--tabs=3 -i', {IN=>"\ta\tb"}, {OUT=>" a\tb"}], - ['i2', '--tabs=3 -i', {IN=>" \ta\tb"}, {OUT=>" a\tb"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'expand'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/expand.pl b/tests/misc/expand.pl new file mode 100755 index 000000000..581a912d7 --- /dev/null +++ b/tests/misc/expand.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +# Exercise expand. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['t1', '--tabs=3', {IN=>"a\tb"}, {OUT=>"a b"}], + ['t2', '--tabs=3,6,9', {IN=>"a\tb\tc\td\te"}, {OUT=>"a b c d e"}], + ['i1', '--tabs=3 -i', {IN=>"\ta\tb"}, {OUT=>" a\tb"}], + ['i2', '--tabs=3 -i', {IN=>" \ta\tb"}, {OUT=>" a\tb"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'expand'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/expr b/tests/misc/expr deleted file mode 100755 index c298d4c29..000000000 --- a/tests/misc/expr +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/perl -# Basic tests for "expr". - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; -my $prog = 'expr'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $big = '98782897298723498732987928734'; -my $big_p1 = '98782897298723498732987928735'; -my $big_sum = '197565794597446997465975857469'; -my $big_prod = '9758060798730154302876482828124348356960410232492450771490'; - -my @Tests = - ( - ['a', '5 + 6', {OUT => '11'}], - ['b', '5 - 6', {OUT => '-1'}], - ['c', '5 \* 6', {OUT => '30'}], - ['d', '100 / 6', {OUT => '16'}], - ['e', '100 % 6', {OUT => '4'}], - ['f', '3 + -2', {OUT => '1'}], - ['g', '-2 + -2', {OUT => '-4'}], - - # Verify option processing. - # Added when option processing broke in the 7.0 beta release - ['opt1', '-- -11 + 12', {OUT => '1'}], - ['opt2', '-11 + 12', {OUT => '1'}], - ['opt3', '-- -1 + 2', {OUT => '1'}], - ['opt4', '-1 + 2', {OUT => '1'}], - # This evoked a syntax error diagnostic before 2.0.12. - ['opt5', '-- 2 + 2', {OUT => '4'}], - - ['paren1', '\( 100 % 6 \)', {OUT => '4'}], - ['paren2', '\( 100 % 6 \) - 8', {OUT => '-4'}], - ['paren3', '9 / \( 100 % 6 \) - 8', {OUT => '-6'}], - ['paren4', '9 / \( \( 100 % 6 \) - 8 \)', {OUT => '-2'}], - ['paren5', '9 + \( 100 % 6 \)', {OUT => '13'}], - - # Before 2.0.12, this would output '1'. - ['0bang', '00 \< 0!', {OUT => '0'}, {EXIT => 1}], - - # In 5.1.3 and earlier, these would exit with status 0. - ['00', '00', {OUT => '00'}, {EXIT => 1}], - ['minus0', '-0', {OUT => '-0'}, {EXIT => 1}], - - # In 5.1.3 and earlier, these would report errors. - ['andand', '0 \& 1 / 0', {OUT => '0'}, {EXIT => 1}], - ['oror', '1 \| 1 / 0', {OUT => '1'}, {EXIT => 0}], - - # In 5.1.3 and earlier, this would output the empty string. - ['orempty', '"" \| ""', {OUT => '0'}, {EXIT => 1}], - - - # This erroneously succeeded and output '3' before 2.0.12. - ['fail-a', '3 + -', {ERR => "$prog: non-integer argument\n"}, - {EXIT => 2}], - - # This erroneously succeeded before 5.3.1. - ['bigcmp', '-- -2417851639229258349412352 \< 2417851639229258349412352', - {OUT => '1'}, {EXIT => 0}], - - # In 5.94 and earlier, anchors incorrectly matched newlines. - ['anchor', "'a\nb' : 'a\$'", {OUT => '0'}, {EXIT => 1}], - - # These tests are taken from grep/tests/bre.tests. - ['bre1', '"abc" : "a\\(b\\)c"', {OUT => 'b'}], - ['bre2', '"a(" : "a("', {OUT => '2'}], - ['bre3', '_ : "a\\("', - {ERR => "$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], - ['bre4', '_ : "a\\(b"', - {ERR => "$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], - ['bre5', '"a(b" : "a(b"', {OUT => '3'}], - ['bre6', '"a)" : "a)"', {OUT => '2'}], - ['bre7', '_ : "a\\)"', - {ERR => "$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], - ['bre8', '_ : "\\)"', - {ERR => "$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], - ['bre9', '"ab" : "a\\(\\)b"', {OUT => ''}, {EXIT => 1}], - ['bre10', '"a^b" : "a^b"', {OUT => '3'}], - ['bre11', '"a\$b" : "a\$b"', {OUT => '3'}], - ['bre12', '"" : "\\($\\)\\(^\\)"', {OUT => ''}, {EXIT => 1}], - ['bre13', '"b" : "a*\\(^b\$\\)c*"', {OUT => 'b'}], - ['bre14', '"X|" : "X\\(|\\)" : "(" "X|" : "X\\(|\\)" ")"', {OUT => '1'}], - ['bre15', '"X*" : "X\\(*\\)" : "(" "X*" : "X\\(*\\)" ")"', {OUT => '1'}], - ['bre16', '"abc" : "\\(\\)"', {OUT => ''}, {EXIT => 1}], - ['bre17', '"{1}a" : "\\(\\{1\\}a\\)"', {OUT => '{1}a'}], - ['bre18', '"X*" : "X\\(*\\)" : "^*"', {OUT => '1'}], - ['bre19', '"{1}" : "^\\{1\\}"', {OUT => '3'}], - ['bre20', '"{" : "{"', {OUT => '1'}], - ['bre21', '"abbcbd" : "a\\(b*\\)c\\1d"', {OUT => ''}, {EXIT => 1}], - ['bre22', '"abbcbbbd" : "a\\(b*\\)c\\1d"', {OUT => ''}, {EXIT => 1}], - ['bre23', '"abc" : "\\(.\\)\\1"', {OUT => ''}, {EXIT => 1}], - ['bre24', '"abbccd" : "a\\(\\([bc]\\)\\2\\)*d"', {OUT => 'cc'}], - ['bre25', '"abbcbd" : "a\\(\\([bc]\\)\\2\\)*d"', - {OUT => ''}, {EXIT => 1}], - ['bre26', '"abbbd" : "a\\(\\(b\\)*\\2\\)*d"', {OUT => 'bbb'}], - ['bre27', '"aabcd" : "\\(a\\)\\1bcd"', {OUT => 'a'}], - ['bre28', '"aabcd" : "\\(a\\)\\1bc*d"', {OUT => 'a'}], - ['bre29', '"aabd" : "\\(a\\)\\1bc*d"', {OUT => 'a'}], - ['bre30', '"aabcccd" : "\\(a\\)\\1bc*d"', {OUT => 'a'}], - ['bre31', '"aabcccd" : "\\(a\\)\\1bc*[ce]d"', {OUT => 'a'}], - ['bre32', '"aabcccd" : "\\(a\\)\\1b\\(c\\)*cd\$"', {OUT => 'a'}], - ['bre33', '"a*b" : "a\\(*\\)b"', {OUT => '*'}], - ['bre34', '"ab" : "a\\(**\\)b"', {OUT => ''}, {EXIT => 1}], - ['bre35', '"ab" : "a\\(***\\)b"', {OUT => ''}, {EXIT => 1}], - ['bre36', '"*a" : "*a"', {OUT => '2'}], - ['bre37', '"a" : "**a"', {OUT => '1'}], - ['bre38', '"a" : "***a"', {OUT => '1'}], - ['bre39', '"ab" : "a\\{1\\}b"', {OUT => '2'}], - ['bre40', '"ab" : "a\\{1,\\}b"', {OUT => '2'}], - ['bre41', '"aab" : "a\\{1,2\\}b"', {OUT => '3'}], - ['bre42', '_ : "a\\{1"', - {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], - ['bre43', '_ : "a\\{1a"', - {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], - ['bre44', '_ : "a\\{1a\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], - ['bre45', '"a" : "a\\{,2\\}"', {OUT => '1'}], - ['bre46', '"a" : "a\\{,\\}"', {OUT => '1'}], - ['bre47', '_ : "a\\{1,x\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], - ['bre48', '_ : "a\\{1,x"', - {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], - ['bre49', '_ : "a\\{32768\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}, - # Map AIX-6's different diagnostic to the one we expect: - {ERR_SUBST => - 's,Regular expression too big,Invalid content of \\\\{\\\\},'}, - ], - ['bre50', '_ : "a\\{1,0\\}"', - {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], - ['bre51', '"acabc" : ".*ab\\{0,0\\}c"', {OUT => '2'}], - ['bre52', '"abcac" : "ab\\{0,1\\}c"', {OUT => '3'}], - ['bre53', '"abbcac" : "ab\\{0,3\\}c"', {OUT => '4'}], - ['bre54', '"abcac" : ".*ab\\{1,1\\}c"', {OUT => '3'}], - ['bre55', '"abcac" : ".*ab\\{1,3\\}c"', {OUT => '3'}], - ['bre56', '"abbcabc" : ".*ab\{2,2\}c"', {OUT => '4'}], - ['bre57', '"abbcabc" : ".*ab\{2,4\}c"', {OUT => '4'}], - ['bre58', '"aa" : "a\\{1\\}\\{1\\}"', {OUT => '1'}], - ['bre59', '"aa" : "a*\\{1\\}"', {OUT => '2'}], - ['bre60', '"aa" : "a\\{1\\}*"', {OUT => '2'}], - ['bre61', '"acd" : "a\\(b\\)?c\\1d"', {OUT => ''}, {EXIT => 1}], - ['bre62', '-- "-5" : "-\\{0,1\\}[0-9]*\$"', {OUT => '2'}], - - ['fail-b', '9 9', {ERR => "$prog: syntax error\n"}, - {EXIT => 2}], - ['fail-c', {ERR => "$prog: missing operand\n" - . "Try '$prog --help' for more information.\n"}, - {EXIT => 2}], - - ['bignum-add', "$big + 1", {OUT => $big_p1}], - ['bignum-add2', "$big + $big_p1", {OUT => $big_sum}], - ['bignum-sub', "$big_p1 - 1", {OUT => $big}], - ['bignum-sub2', "$big_sum - $big", {OUT => $big_p1}], - ['bignum-mul', "$big_p1 '*' $big", {OUT => $big_prod}], - ['bignum-div', "$big_prod / $big", {OUT => $big_p1}], - ); - -# If using big numbers fails, remove all /^bignum-/ tests -qx!expr $big_prod '*' $big_prod '*' $big_prod! - or @Tests = grep {$_->[0] !~ /^bignum-/} @Tests; - -# Append a newline to end of each expected 'OUT' string. -my $t; -foreach $t (@Tests) - { - my $arg1 = $t->[1]; - my $e; - foreach $e (@$t) - { - $e->{OUT} .= "\n" - if ref $e eq 'HASH' and exists $e->{OUT}; - } - } - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/expr.pl b/tests/misc/expr.pl new file mode 100755 index 000000000..c298d4c29 --- /dev/null +++ b/tests/misc/expr.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl +# Basic tests for "expr". + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; +my $prog = 'expr'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $big = '98782897298723498732987928734'; +my $big_p1 = '98782897298723498732987928735'; +my $big_sum = '197565794597446997465975857469'; +my $big_prod = '9758060798730154302876482828124348356960410232492450771490'; + +my @Tests = + ( + ['a', '5 + 6', {OUT => '11'}], + ['b', '5 - 6', {OUT => '-1'}], + ['c', '5 \* 6', {OUT => '30'}], + ['d', '100 / 6', {OUT => '16'}], + ['e', '100 % 6', {OUT => '4'}], + ['f', '3 + -2', {OUT => '1'}], + ['g', '-2 + -2', {OUT => '-4'}], + + # Verify option processing. + # Added when option processing broke in the 7.0 beta release + ['opt1', '-- -11 + 12', {OUT => '1'}], + ['opt2', '-11 + 12', {OUT => '1'}], + ['opt3', '-- -1 + 2', {OUT => '1'}], + ['opt4', '-1 + 2', {OUT => '1'}], + # This evoked a syntax error diagnostic before 2.0.12. + ['opt5', '-- 2 + 2', {OUT => '4'}], + + ['paren1', '\( 100 % 6 \)', {OUT => '4'}], + ['paren2', '\( 100 % 6 \) - 8', {OUT => '-4'}], + ['paren3', '9 / \( 100 % 6 \) - 8', {OUT => '-6'}], + ['paren4', '9 / \( \( 100 % 6 \) - 8 \)', {OUT => '-2'}], + ['paren5', '9 + \( 100 % 6 \)', {OUT => '13'}], + + # Before 2.0.12, this would output '1'. + ['0bang', '00 \< 0!', {OUT => '0'}, {EXIT => 1}], + + # In 5.1.3 and earlier, these would exit with status 0. + ['00', '00', {OUT => '00'}, {EXIT => 1}], + ['minus0', '-0', {OUT => '-0'}, {EXIT => 1}], + + # In 5.1.3 and earlier, these would report errors. + ['andand', '0 \& 1 / 0', {OUT => '0'}, {EXIT => 1}], + ['oror', '1 \| 1 / 0', {OUT => '1'}, {EXIT => 0}], + + # In 5.1.3 and earlier, this would output the empty string. + ['orempty', '"" \| ""', {OUT => '0'}, {EXIT => 1}], + + + # This erroneously succeeded and output '3' before 2.0.12. + ['fail-a', '3 + -', {ERR => "$prog: non-integer argument\n"}, + {EXIT => 2}], + + # This erroneously succeeded before 5.3.1. + ['bigcmp', '-- -2417851639229258349412352 \< 2417851639229258349412352', + {OUT => '1'}, {EXIT => 0}], + + # In 5.94 and earlier, anchors incorrectly matched newlines. + ['anchor', "'a\nb' : 'a\$'", {OUT => '0'}, {EXIT => 1}], + + # These tests are taken from grep/tests/bre.tests. + ['bre1', '"abc" : "a\\(b\\)c"', {OUT => 'b'}], + ['bre2', '"a(" : "a("', {OUT => '2'}], + ['bre3', '_ : "a\\("', + {ERR => "$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], + ['bre4', '_ : "a\\(b"', + {ERR => "$prog: Unmatched ( or \\(\n"}, {EXIT => 2}], + ['bre5', '"a(b" : "a(b"', {OUT => '3'}], + ['bre6', '"a)" : "a)"', {OUT => '2'}], + ['bre7', '_ : "a\\)"', + {ERR => "$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], + ['bre8', '_ : "\\)"', + {ERR => "$prog: Unmatched ) or \\)\n"}, {EXIT => 2}], + ['bre9', '"ab" : "a\\(\\)b"', {OUT => ''}, {EXIT => 1}], + ['bre10', '"a^b" : "a^b"', {OUT => '3'}], + ['bre11', '"a\$b" : "a\$b"', {OUT => '3'}], + ['bre12', '"" : "\\($\\)\\(^\\)"', {OUT => ''}, {EXIT => 1}], + ['bre13', '"b" : "a*\\(^b\$\\)c*"', {OUT => 'b'}], + ['bre14', '"X|" : "X\\(|\\)" : "(" "X|" : "X\\(|\\)" ")"', {OUT => '1'}], + ['bre15', '"X*" : "X\\(*\\)" : "(" "X*" : "X\\(*\\)" ")"', {OUT => '1'}], + ['bre16', '"abc" : "\\(\\)"', {OUT => ''}, {EXIT => 1}], + ['bre17', '"{1}a" : "\\(\\{1\\}a\\)"', {OUT => '{1}a'}], + ['bre18', '"X*" : "X\\(*\\)" : "^*"', {OUT => '1'}], + ['bre19', '"{1}" : "^\\{1\\}"', {OUT => '3'}], + ['bre20', '"{" : "{"', {OUT => '1'}], + ['bre21', '"abbcbd" : "a\\(b*\\)c\\1d"', {OUT => ''}, {EXIT => 1}], + ['bre22', '"abbcbbbd" : "a\\(b*\\)c\\1d"', {OUT => ''}, {EXIT => 1}], + ['bre23', '"abc" : "\\(.\\)\\1"', {OUT => ''}, {EXIT => 1}], + ['bre24', '"abbccd" : "a\\(\\([bc]\\)\\2\\)*d"', {OUT => 'cc'}], + ['bre25', '"abbcbd" : "a\\(\\([bc]\\)\\2\\)*d"', + {OUT => ''}, {EXIT => 1}], + ['bre26', '"abbbd" : "a\\(\\(b\\)*\\2\\)*d"', {OUT => 'bbb'}], + ['bre27', '"aabcd" : "\\(a\\)\\1bcd"', {OUT => 'a'}], + ['bre28', '"aabcd" : "\\(a\\)\\1bc*d"', {OUT => 'a'}], + ['bre29', '"aabd" : "\\(a\\)\\1bc*d"', {OUT => 'a'}], + ['bre30', '"aabcccd" : "\\(a\\)\\1bc*d"', {OUT => 'a'}], + ['bre31', '"aabcccd" : "\\(a\\)\\1bc*[ce]d"', {OUT => 'a'}], + ['bre32', '"aabcccd" : "\\(a\\)\\1b\\(c\\)*cd\$"', {OUT => 'a'}], + ['bre33', '"a*b" : "a\\(*\\)b"', {OUT => '*'}], + ['bre34', '"ab" : "a\\(**\\)b"', {OUT => ''}, {EXIT => 1}], + ['bre35', '"ab" : "a\\(***\\)b"', {OUT => ''}, {EXIT => 1}], + ['bre36', '"*a" : "*a"', {OUT => '2'}], + ['bre37', '"a" : "**a"', {OUT => '1'}], + ['bre38', '"a" : "***a"', {OUT => '1'}], + ['bre39', '"ab" : "a\\{1\\}b"', {OUT => '2'}], + ['bre40', '"ab" : "a\\{1,\\}b"', {OUT => '2'}], + ['bre41', '"aab" : "a\\{1,2\\}b"', {OUT => '3'}], + ['bre42', '_ : "a\\{1"', + {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], + ['bre43', '_ : "a\\{1a"', + {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], + ['bre44', '_ : "a\\{1a\\}"', + {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], + ['bre45', '"a" : "a\\{,2\\}"', {OUT => '1'}], + ['bre46', '"a" : "a\\{,\\}"', {OUT => '1'}], + ['bre47', '_ : "a\\{1,x\\}"', + {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], + ['bre48', '_ : "a\\{1,x"', + {ERR => "$prog: Unmatched \\{\n"}, {EXIT => 2}], + ['bre49', '_ : "a\\{32768\\}"', + {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}, + # Map AIX-6's different diagnostic to the one we expect: + {ERR_SUBST => + 's,Regular expression too big,Invalid content of \\\\{\\\\},'}, + ], + ['bre50', '_ : "a\\{1,0\\}"', + {ERR => "$prog: Invalid content of \\{\\}\n"}, {EXIT => 2}], + ['bre51', '"acabc" : ".*ab\\{0,0\\}c"', {OUT => '2'}], + ['bre52', '"abcac" : "ab\\{0,1\\}c"', {OUT => '3'}], + ['bre53', '"abbcac" : "ab\\{0,3\\}c"', {OUT => '4'}], + ['bre54', '"abcac" : ".*ab\\{1,1\\}c"', {OUT => '3'}], + ['bre55', '"abcac" : ".*ab\\{1,3\\}c"', {OUT => '3'}], + ['bre56', '"abbcabc" : ".*ab\{2,2\}c"', {OUT => '4'}], + ['bre57', '"abbcabc" : ".*ab\{2,4\}c"', {OUT => '4'}], + ['bre58', '"aa" : "a\\{1\\}\\{1\\}"', {OUT => '1'}], + ['bre59', '"aa" : "a*\\{1\\}"', {OUT => '2'}], + ['bre60', '"aa" : "a\\{1\\}*"', {OUT => '2'}], + ['bre61', '"acd" : "a\\(b\\)?c\\1d"', {OUT => ''}, {EXIT => 1}], + ['bre62', '-- "-5" : "-\\{0,1\\}[0-9]*\$"', {OUT => '2'}], + + ['fail-b', '9 9', {ERR => "$prog: syntax error\n"}, + {EXIT => 2}], + ['fail-c', {ERR => "$prog: missing operand\n" + . "Try '$prog --help' for more information.\n"}, + {EXIT => 2}], + + ['bignum-add', "$big + 1", {OUT => $big_p1}], + ['bignum-add2', "$big + $big_p1", {OUT => $big_sum}], + ['bignum-sub', "$big_p1 - 1", {OUT => $big}], + ['bignum-sub2', "$big_sum - $big", {OUT => $big_p1}], + ['bignum-mul', "$big_p1 '*' $big", {OUT => $big_prod}], + ['bignum-div', "$big_prod / $big", {OUT => $big_p1}], + ); + +# If using big numbers fails, remove all /^bignum-/ tests +qx!expr $big_prod '*' $big_prod '*' $big_prod! + or @Tests = grep {$_->[0] !~ /^bignum-/} @Tests; + +# Append a newline to end of each expected 'OUT' string. +my $t; +foreach $t (@Tests) + { + my $arg1 = $t->[1]; + my $e; + foreach $e (@$t) + { + $e->{OUT} .= "\n" + if ref $e eq 'HASH' and exists $e->{OUT}; + } + } + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/factor b/tests/misc/factor deleted file mode 100755 index 47f934309..000000000 --- a/tests/misc/factor +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/perl -# Basic tests for "factor". - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; -my $prog = 'factor'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['1', '9', {OUT => '3 3'}], - ['1a', '7', {OUT => '7'}], - ['2', '4294967291', {OUT => '4294967291'}], - ['3', '4294967292', {OUT => '2 2 3 3 7 11 31 151 331'}], - ['4', '4294967293', {OUT => '9241 464773'}], - - ['a', '4294966201', {OUT => '12197 352133'}], - ['b', '4294966339', {OUT => '13187 325697'}], - ['c', '4294966631', {OUT => '13729 312839'}], - ['d', '4294966457', {OUT => '14891 288427'}], - ['e', '4294966759', {OUT => '21649 198391'}], - ['f', '4294966573', {OUT => '23071 186163'}], - ['g', '4294967101', {OUT => '23603 181967'}], - ['h', '4294966519', {OUT => '34583 124193'}], - ['i', '4294966561', {OUT => '36067 119083'}], - ['j', '4294966901', {OUT => '37747 113783'}], - ['k', '4294966691', {OUT => '39241 109451'}], - ['l', '4294966969', {OUT => '44201 97169'}], - ['m', '4294967099', {OUT => '44483 96553'}], - ['n', '4294966271', {OUT => '44617 96263'}], - ['o', '4294966789', {OUT => '50411 85199'}], - ['p', '4294966189', {OUT => '53197 80737'}], - ['q', '4294967213', {OUT => '57139 75167'}], - ['s', '4294967071', {OUT => '65521 65551'}], - ['t', '4294966194', {OUT => '2 3 3 3 3 3 3 3 53 97 191'}], - ['u', '4294966272', {OUT => '2 2 2 2 2 2 2 2 2 2 3 23 89 683'}], - ['v', '4294966400', {OUT => '2 2 2 2 2 2 2 5 5 1342177'}], - ['w', '4294966464', {OUT => '2 2 2 2 2 2 3 3 3 2485513'}], - ['x', '4294966896', {OUT => '2 2 2 2 3 3 3 11 607 1489'}], - ['y', '4294966998', {OUT => '2 3 7 3917 26107'}], - ['z', '-1', - # Map newer glibc diagnostic to expected. - # Also map OpenBSD 5.1's "unknown option" to expected "invalid option". - {ERR_SUBST => q!s/'1'/1/;s/unknown/invalid/!}, - {ERR => "$prog: invalid option -- 1\n" - . "Try '$prog --help' for more information.\n"}, - {EXIT => 1}], - ['cont', 'a 4', - {OUT => "4: 2 2\n"}, - {ERR => "$prog: 'a' is not a valid positive integer\n"}, - {EXIT => 1}], - ); - -# Prepend the command line argument and append a newline to end -# of each expected 'OUT' string. -my $t; - -Test: -foreach $t (@Tests) - { - my $arg1 = $t->[1]; - - # Don't fiddle with expected OUT string if there's a nonzero exit status. - foreach my $e (@$t) - { - ref $e eq 'HASH' && exists $e->{EXIT} && $e->{EXIT} - and next Test; - } - - foreach my $e (@$t) - { - ref $e eq 'HASH' && exists $e->{OUT} - and $e->{OUT} = "$arg1: $e->{OUT}\n" - } - } - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/factor.pl b/tests/misc/factor.pl new file mode 100755 index 000000000..47f934309 --- /dev/null +++ b/tests/misc/factor.pl @@ -0,0 +1,99 @@ +#!/usr/bin/perl +# Basic tests for "factor". + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; +my $prog = 'factor'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['1', '9', {OUT => '3 3'}], + ['1a', '7', {OUT => '7'}], + ['2', '4294967291', {OUT => '4294967291'}], + ['3', '4294967292', {OUT => '2 2 3 3 7 11 31 151 331'}], + ['4', '4294967293', {OUT => '9241 464773'}], + + ['a', '4294966201', {OUT => '12197 352133'}], + ['b', '4294966339', {OUT => '13187 325697'}], + ['c', '4294966631', {OUT => '13729 312839'}], + ['d', '4294966457', {OUT => '14891 288427'}], + ['e', '4294966759', {OUT => '21649 198391'}], + ['f', '4294966573', {OUT => '23071 186163'}], + ['g', '4294967101', {OUT => '23603 181967'}], + ['h', '4294966519', {OUT => '34583 124193'}], + ['i', '4294966561', {OUT => '36067 119083'}], + ['j', '4294966901', {OUT => '37747 113783'}], + ['k', '4294966691', {OUT => '39241 109451'}], + ['l', '4294966969', {OUT => '44201 97169'}], + ['m', '4294967099', {OUT => '44483 96553'}], + ['n', '4294966271', {OUT => '44617 96263'}], + ['o', '4294966789', {OUT => '50411 85199'}], + ['p', '4294966189', {OUT => '53197 80737'}], + ['q', '4294967213', {OUT => '57139 75167'}], + ['s', '4294967071', {OUT => '65521 65551'}], + ['t', '4294966194', {OUT => '2 3 3 3 3 3 3 3 53 97 191'}], + ['u', '4294966272', {OUT => '2 2 2 2 2 2 2 2 2 2 3 23 89 683'}], + ['v', '4294966400', {OUT => '2 2 2 2 2 2 2 5 5 1342177'}], + ['w', '4294966464', {OUT => '2 2 2 2 2 2 3 3 3 2485513'}], + ['x', '4294966896', {OUT => '2 2 2 2 3 3 3 11 607 1489'}], + ['y', '4294966998', {OUT => '2 3 7 3917 26107'}], + ['z', '-1', + # Map newer glibc diagnostic to expected. + # Also map OpenBSD 5.1's "unknown option" to expected "invalid option". + {ERR_SUBST => q!s/'1'/1/;s/unknown/invalid/!}, + {ERR => "$prog: invalid option -- 1\n" + . "Try '$prog --help' for more information.\n"}, + {EXIT => 1}], + ['cont', 'a 4', + {OUT => "4: 2 2\n"}, + {ERR => "$prog: 'a' is not a valid positive integer\n"}, + {EXIT => 1}], + ); + +# Prepend the command line argument and append a newline to end +# of each expected 'OUT' string. +my $t; + +Test: +foreach $t (@Tests) + { + my $arg1 = $t->[1]; + + # Don't fiddle with expected OUT string if there's a nonzero exit status. + foreach my $e (@$t) + { + ref $e eq 'HASH' && exists $e->{EXIT} && $e->{EXIT} + and next Test; + } + + foreach my $e (@$t) + { + ref $e eq 'HASH' && exists $e->{OUT} + and $e->{OUT} = "$arg1: $e->{OUT}\n" + } + } + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/false-status b/tests/misc/false-status deleted file mode 100755 index d192bbd7e..000000000 --- a/tests/misc/false-status +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# ensure that false exits nonzero even with --help or --version - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ false - -false --version > /dev/null && fail=1 -false --help > /dev/null && fail=1 - -Exit $fail diff --git a/tests/misc/false-status.sh b/tests/misc/false-status.sh new file mode 100755 index 000000000..d192bbd7e --- /dev/null +++ b/tests/misc/false-status.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# ensure that false exits nonzero even with --help or --version + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ false + +false --version > /dev/null && fail=1 +false --help > /dev/null && fail=1 + +Exit $fail diff --git a/tests/misc/fold b/tests/misc/fold deleted file mode 100755 index 8291a70ed..000000000 --- a/tests/misc/fold +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -# Exercise fold. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['s1', '-w2 -s', {IN=>"a\t"}, {OUT=>"a\n\t"}], - ['s2', '-w4 -s', {IN=>"abcdef d\n"}, {OUT=>"abcd\nef d\n"}], - ['s3', '-w4 -s', {IN=>"a cd fgh\n"}, {OUT=>"a \ncd \nfgh\n"}], - ['s4', '-w4 -s', {IN=>"abc ef\n"}, {OUT=>"abc \nef\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'fold'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl new file mode 100755 index 000000000..8291a70ed --- /dev/null +++ b/tests/misc/fold.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +# Exercise fold. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['s1', '-w2 -s', {IN=>"a\t"}, {OUT=>"a\n\t"}], + ['s2', '-w4 -s', {IN=>"abcdef d\n"}, {OUT=>"abcd\nef d\n"}], + ['s3', '-w4 -s', {IN=>"a cd fgh\n"}, {OUT=>"a \ncd \nfgh\n"}], + ['s4', '-w4 -s', {IN=>"abc ef\n"}, {OUT=>"abc \nef\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'fold'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/groups-dash b/tests/misc/groups-dash deleted file mode 100755 index 24e7b9a79..000000000 --- a/tests/misc/groups-dash +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# ensure groups handles -- sanely - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ groups -require_built_ groups - -# Coreutils 6.9 and earlier failed to display information on first argument -# if later argument was --. -groups none -- > out 2>&1 && fail=1 -echo $? >> out -groups -- none -- > exp 2>&1 && fail=1 -echo $? >> exp - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/groups-dash.sh b/tests/misc/groups-dash.sh new file mode 100755 index 000000000..24e7b9a79 --- /dev/null +++ b/tests/misc/groups-dash.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# ensure groups handles -- sanely + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ groups +require_built_ groups + +# Coreutils 6.9 and earlier failed to display information on first argument +# if later argument was --. +groups none -- > out 2>&1 && fail=1 +echo $? >> out +groups -- none -- > exp 2>&1 && fail=1 +echo $? >> exp + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/groups-version b/tests/misc/groups-version deleted file mode 100755 index 9a8bf3927..000000000 --- a/tests/misc/groups-version +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# ensure groups --version output is similar to id --version - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ groups -require_built_ groups - -groups --version | sed 's/^groups/id/; /^$/q' > out || fail=1 -id --version | sed '/^$/q' > exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/groups-version.sh b/tests/misc/groups-version.sh new file mode 100755 index 000000000..9a8bf3927 --- /dev/null +++ b/tests/misc/groups-version.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# ensure groups --version output is similar to id --version + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ groups +require_built_ groups + +groups --version | sed 's/^groups/id/; /^$/q' > out || fail=1 +id --version | sed '/^$/q' > exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/head b/tests/misc/head deleted file mode 100755 index 2355e6abf..000000000 --- a/tests/misc/head +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/perl -# test head - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'head'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $in = join ('', map { "$_\n" } 0..600); -my $in_1024 = substr $in, 0, 1024; - -# FIXME: set this properly -my $x32_bit_long = 0; - -my @Tests = -( - ['idem-0', {IN=>''}, {OUT=>''}], - ['idem-1', {IN=>'a'}, {OUT=>'a'}], - ['idem-2', {IN=>"\n"}, {OUT=>"\n"}], - ['idem-3', {IN=>"a\n"}, {OUT=>"a\n"}], - - ['basic-10', - {IN=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n"}, - {OUT=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n"}], - - ['basic-09', - {IN=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n"}, - {OUT=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n"}], - - ['basic-11', - {IN=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\nb\n"}, - {OUT=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n"}], - - ['obs-0', '-1', {IN=>"1\n2\n"}, {OUT=>"1\n"}], - ['obs-1', '-1c', {IN=>''}, {OUT=>''}], - ['obs-2', '-1c', {IN=>'12'}, {OUT=>'1'}], - ['obs-3', '-14c', {IN=>'1234567890abcdefg'}, {OUT=>'1234567890abcd'}], - ['obs-4', '-2b', {IN=>$in}, {OUT=>$in_1024}], - ['obs-5', '-1k', {IN=>$in}, {OUT=>$in_1024}], - - # This test fails for textutils-1.22, because head let 4096m overflow to 0 - # and did not fail. Now head fails with a diagnostic. - # Disable this test because it fails on systems with 64-bit uintmax_t. - # ['fail-0', qw(-n 4096m), {IN=>"a\n"}, {EXIT=>1}], - - # In spite of its name, this test passes -- just to contrast with the above. - ['fail-1', qw(-n 2048m), {IN=>"a\n"}, {OUT=>"a\n"}], - - # Make sure we don't break like AIX 4.3.1 on files with \0 in them. - ['null-1', {IN=>"a\0a\n"}, {OUT=>"a\0a\n"}], - - # Make sure counts are interpreted as decimal. - # Before 2.0f, these would have been interpreted as octal - ['no-oct-1', '-08', {IN=>"\n"x12}, {OUT=>"\n"x8}], - ['no-oct-2', '-010', {IN=>"\n"x12}, {OUT=>"\n"x10}], - ['no-oct-3', '-n 08', {IN=>"\n"x12}, {OUT=>"\n"x8}], - ['no-oct-4', '-c 08', {IN=>"\n"x12}, {OUT=>"\n"x8}], -); - -@Tests = triple_test \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/head-c b/tests/misc/head-c deleted file mode 100755 index 32f86d2f3..000000000 --- a/tests/misc/head-c +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# exercise the fix of 2001-08-18, based on test case from Ian Bruce - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ head - -echo abc > in || framework_failure_ - -(head -c1; head -c1) < in > out || fail=1 -case "$(cat out)" in - ab) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/misc/head-c.sh b/tests/misc/head-c.sh new file mode 100755 index 000000000..32f86d2f3 --- /dev/null +++ b/tests/misc/head-c.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# exercise the fix of 2001-08-18, based on test case from Ian Bruce + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ head + +echo abc > in || framework_failure_ + +(head -c1; head -c1) < in > out || fail=1 +case "$(cat out)" in + ab) ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/misc/head-elide-tail b/tests/misc/head-elide-tail deleted file mode 100755 index 85f509d26..000000000 --- a/tests/misc/head-elide-tail +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/perl -# Exercise head's --bytes=-N option. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -$ENV{PROG} = 'head'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# This should match the definition in head.c. -my $READ_BUFSIZE = 8192; - -my @Tests = - ( - # Elide the exact size of the file. - ['elide-b1', "--bytes=-2", {IN=>"a\n"}, {OUT=>''}], - # Elide more than the size of the file. - ['elide-b2', "--bytes=-2", {IN=>"a"}, {OUT=>''}], - # Leave just one byte. - ['elide-b3', "--bytes=-2", {IN=>"abc"}, {OUT=>'a'}], - # Make it so the elided bytes straddle the end of the first - # $READ_BUFSIZE block. - ['elide-b4', "--bytes=-2", - {IN=> 'a' x ($READ_BUFSIZE-3) . "\nbcd"}, - {OUT=>'a' x ($READ_BUFSIZE-3) . "\nb"}], - # Make it so the elided bytes straddle the end of the 2nd - # $READ_BUFSIZE block. - ['elide-b5', "--bytes=-2", - {IN=> 'a' x (2 * $READ_BUFSIZE - 2) . 'bcd'}, - {OUT=>'a' x (2 * $READ_BUFSIZE - 2) . 'b'}], - - ['elide-l0', "--lines=-1", {IN=>''}, {OUT=>''}], - ['elide-l1', "--lines=-1", {IN=>"a\n"}, {OUT=>''}], - ['elide-l2', "--lines=-1", {IN=>"a"}, {OUT=>''}], - ['elide-l3', "--lines=-1", {IN=>"a\nb"}, {OUT=>"a\n"}], - ['elide-l4', "--lines=-1", {IN=>"a\nb\n"}, {OUT=>"a\n"}], - ); - -if ($ENV{RUN_EXPENSIVE_TESTS}) - { - # Brute force: use all combinations of file sizes [0..20] and - # number of bytes to elide [0..20]. For better coverage, recompile - # head with -DHEAD_TAIL_PIPE_READ_BUFSIZE=4 and - # -DHEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD=8 - my $s = "abcdefghijklmnopqrst"; - for my $file_size (0..20) - { - for my $n_elide (0..20) - { - my $input = substr $s, 0, $file_size; - my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; - my $output = substr $input, 0, $out_len; - my $t = ["elideb$file_size-$n_elide", "--bytes=-$n_elide", - {IN=>$input}, {OUT=>$output}]; - push @Tests, $t; - my @u = @$t; - # Insert the ---presume-input-pipe option. - $u[0] .= 'p'; - $u[1] .= ' ---presume-input-pipe'; - push @Tests, \@u; - } - } - - $s =~ s/(.)/$1\n/g; - for my $file_size (0..20) - { - for my $n_elide (0..20) - { - my $input = substr $s, 0, 2 * $file_size; - my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; - my $output = substr $input, 0, 2 * $out_len; - my $t = ["elidel$file_size-$n_elide", "--lines=-$n_elide", - {IN=>$input}, {OUT=>$output}]; - push @Tests, $t; - my @u = @$t; - # Insert the ---presume-input-pipe option. - $u[0] .= 'p'; - $u[1] .= ' ---presume-input-pipe'; - push @Tests, \@u; - } - } - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/head-elide-tail.pl b/tests/misc/head-elide-tail.pl new file mode 100755 index 000000000..85f509d26 --- /dev/null +++ b/tests/misc/head-elide-tail.pl @@ -0,0 +1,107 @@ +#!/usr/bin/perl +# Exercise head's --bytes=-N option. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +$ENV{PROG} = 'head'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# This should match the definition in head.c. +my $READ_BUFSIZE = 8192; + +my @Tests = + ( + # Elide the exact size of the file. + ['elide-b1', "--bytes=-2", {IN=>"a\n"}, {OUT=>''}], + # Elide more than the size of the file. + ['elide-b2', "--bytes=-2", {IN=>"a"}, {OUT=>''}], + # Leave just one byte. + ['elide-b3', "--bytes=-2", {IN=>"abc"}, {OUT=>'a'}], + # Make it so the elided bytes straddle the end of the first + # $READ_BUFSIZE block. + ['elide-b4', "--bytes=-2", + {IN=> 'a' x ($READ_BUFSIZE-3) . "\nbcd"}, + {OUT=>'a' x ($READ_BUFSIZE-3) . "\nb"}], + # Make it so the elided bytes straddle the end of the 2nd + # $READ_BUFSIZE block. + ['elide-b5', "--bytes=-2", + {IN=> 'a' x (2 * $READ_BUFSIZE - 2) . 'bcd'}, + {OUT=>'a' x (2 * $READ_BUFSIZE - 2) . 'b'}], + + ['elide-l0', "--lines=-1", {IN=>''}, {OUT=>''}], + ['elide-l1', "--lines=-1", {IN=>"a\n"}, {OUT=>''}], + ['elide-l2', "--lines=-1", {IN=>"a"}, {OUT=>''}], + ['elide-l3', "--lines=-1", {IN=>"a\nb"}, {OUT=>"a\n"}], + ['elide-l4', "--lines=-1", {IN=>"a\nb\n"}, {OUT=>"a\n"}], + ); + +if ($ENV{RUN_EXPENSIVE_TESTS}) + { + # Brute force: use all combinations of file sizes [0..20] and + # number of bytes to elide [0..20]. For better coverage, recompile + # head with -DHEAD_TAIL_PIPE_READ_BUFSIZE=4 and + # -DHEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD=8 + my $s = "abcdefghijklmnopqrst"; + for my $file_size (0..20) + { + for my $n_elide (0..20) + { + my $input = substr $s, 0, $file_size; + my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; + my $output = substr $input, 0, $out_len; + my $t = ["elideb$file_size-$n_elide", "--bytes=-$n_elide", + {IN=>$input}, {OUT=>$output}]; + push @Tests, $t; + my @u = @$t; + # Insert the ---presume-input-pipe option. + $u[0] .= 'p'; + $u[1] .= ' ---presume-input-pipe'; + push @Tests, \@u; + } + } + + $s =~ s/(.)/$1\n/g; + for my $file_size (0..20) + { + for my $n_elide (0..20) + { + my $input = substr $s, 0, 2 * $file_size; + my $out_len = $n_elide < $file_size ? $file_size - $n_elide : 0; + my $output = substr $input, 0, 2 * $out_len; + my $t = ["elidel$file_size-$n_elide", "--lines=-$n_elide", + {IN=>$input}, {OUT=>$output}]; + push @Tests, $t; + my @u = @$t; + # Insert the ---presume-input-pipe option. + $u[0] .= 'p'; + $u[1] .= ' ---presume-input-pipe'; + push @Tests, \@u; + } + } + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/head-pos b/tests/misc/head-pos deleted file mode 100755 index fa3284e90..000000000 --- a/tests/misc/head-pos +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# When reading a specified number of lines, ensure that the output -# file pointer is positioned just after those lines. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ head - -(echo a; echo b) > in || framework_failure_ -echo b > exp || framework_failure_ - -for i in -1 1; do - (head -n $i >/dev/null; cat) < in > out || fail=1 - compare exp out || fail=1 -done - -# Exercise the (start_pos < pos) block in elide_tail_lines_seekable. -# So far, this is the only test to do that. -# Do that by creating a file larger than BUFSIZ (I've seen 128K) and -# elide a suffix of it (by line count) that is also larger than BUFSIZ. -# 50000 lines times 6 bytes per line gives us enough leeway even on a -# system with a BUFSIZ of 256K. -n_lines=50000 -seq 70000 > in2 || framework_failure_ -echo $n_lines > exp-n || framework_failure_ - -(head -n-$n_lines>/dev/null; wc -l) < in2 > n -compare exp-n n || fail=1 - -Exit $fail diff --git a/tests/misc/head-pos.sh b/tests/misc/head-pos.sh new file mode 100755 index 000000000..fa3284e90 --- /dev/null +++ b/tests/misc/head-pos.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# When reading a specified number of lines, ensure that the output +# file pointer is positioned just after those lines. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ head + +(echo a; echo b) > in || framework_failure_ +echo b > exp || framework_failure_ + +for i in -1 1; do + (head -n $i >/dev/null; cat) < in > out || fail=1 + compare exp out || fail=1 +done + +# Exercise the (start_pos < pos) block in elide_tail_lines_seekable. +# So far, this is the only test to do that. +# Do that by creating a file larger than BUFSIZ (I've seen 128K) and +# elide a suffix of it (by line count) that is also larger than BUFSIZ. +# 50000 lines times 6 bytes per line gives us enough leeway even on a +# system with a BUFSIZ of 256K. +n_lines=50000 +seq 70000 > in2 || framework_failure_ +echo $n_lines > exp-n || framework_failure_ + +(head -n-$n_lines>/dev/null; wc -l) < in2 > n +compare exp-n n || fail=1 + +Exit $fail diff --git a/tests/misc/head.pl b/tests/misc/head.pl new file mode 100755 index 000000000..2355e6abf --- /dev/null +++ b/tests/misc/head.pl @@ -0,0 +1,83 @@ +#!/usr/bin/perl +# test head + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'head'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $in = join ('', map { "$_\n" } 0..600); +my $in_1024 = substr $in, 0, 1024; + +# FIXME: set this properly +my $x32_bit_long = 0; + +my @Tests = +( + ['idem-0', {IN=>''}, {OUT=>''}], + ['idem-1', {IN=>'a'}, {OUT=>'a'}], + ['idem-2', {IN=>"\n"}, {OUT=>"\n"}], + ['idem-3', {IN=>"a\n"}, {OUT=>"a\n"}], + + ['basic-10', + {IN=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n"}, + {OUT=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n"}], + + ['basic-09', + {IN=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n"}, + {OUT=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n"}], + + ['basic-11', + {IN=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\nb\n"}, + {OUT=>"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n"}], + + ['obs-0', '-1', {IN=>"1\n2\n"}, {OUT=>"1\n"}], + ['obs-1', '-1c', {IN=>''}, {OUT=>''}], + ['obs-2', '-1c', {IN=>'12'}, {OUT=>'1'}], + ['obs-3', '-14c', {IN=>'1234567890abcdefg'}, {OUT=>'1234567890abcd'}], + ['obs-4', '-2b', {IN=>$in}, {OUT=>$in_1024}], + ['obs-5', '-1k', {IN=>$in}, {OUT=>$in_1024}], + + # This test fails for textutils-1.22, because head let 4096m overflow to 0 + # and did not fail. Now head fails with a diagnostic. + # Disable this test because it fails on systems with 64-bit uintmax_t. + # ['fail-0', qw(-n 4096m), {IN=>"a\n"}, {EXIT=>1}], + + # In spite of its name, this test passes -- just to contrast with the above. + ['fail-1', qw(-n 2048m), {IN=>"a\n"}, {OUT=>"a\n"}], + + # Make sure we don't break like AIX 4.3.1 on files with \0 in them. + ['null-1', {IN=>"a\0a\n"}, {OUT=>"a\0a\n"}], + + # Make sure counts are interpreted as decimal. + # Before 2.0f, these would have been interpreted as octal + ['no-oct-1', '-08', {IN=>"\n"x12}, {OUT=>"\n"x8}], + ['no-oct-2', '-010', {IN=>"\n"x12}, {OUT=>"\n"x10}], + ['no-oct-3', '-n 08', {IN=>"\n"x12}, {OUT=>"\n"x8}], + ['no-oct-4', '-c 08', {IN=>"\n"x12}, {OUT=>"\n"x8}], +); + +@Tests = triple_test \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/help-version b/tests/misc/help-version deleted file mode 100755 index f2ac0e9bb..000000000 --- a/tests/misc/help-version +++ /dev/null @@ -1,281 +0,0 @@ -#! /bin/sh -# Make sure all of these programs work properly -# when invoked with --help or --version. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Ensure that $SHELL is set to *some* value and exported. -# This is required for dircolors, which would fail e.g., when -# invoked via debuild (which removes SHELL from the environment). -test "x$SHELL" = x && SHELL=/bin/sh -export SHELL - -. "${srcdir=.}/init.sh"; path_prepend_ ../src - -expected_failure_status_chroot=125 -expected_failure_status_env=125 -expected_failure_status_nice=125 -expected_failure_status_nohup=125 -expected_failure_status_stdbuf=125 -expected_failure_status_timeout=125 -expected_failure_status_printenv=2 -expected_failure_status_tty=3 -expected_failure_status_sort=2 -expected_failure_status_expr=3 -expected_failure_status_lbracket=2 -expected_failure_status_dir=2 -expected_failure_status_ls=2 -expected_failure_status_vdir=2 - -expected_failure_status_cmp=2 -expected_failure_status_zcmp=2 -expected_failure_status_sdiff=2 -expected_failure_status_diff3=2 -expected_failure_status_diff=2 -expected_failure_status_zdiff=2 -expected_failure_status_zgrep=2 -expected_failure_status_zegrep=2 -expected_failure_status_zfgrep=2 - -expected_failure_status_grep=2 -expected_failure_status_egrep=2 -expected_failure_status_fgrep=2 - -test "$built_programs" \ - || fail_ "built_programs not specified!?!" - -test "$VERSION" \ - || fail_ "set envvar VERSION; it is required for a PATH sanity-check" - -# Extract version from --version output of the first program -for i in $built_programs; do - v=$(env $i --version | sed -n '1s/.* //p;q') - break -done - -# Ensure that it matches $VERSION. -test "x$v" = "x$VERSION" \ - || fail_ "--version-\$VERSION mismatch" - -for lang in C fr da; do - for i in $built_programs; do - - # Skip 'test'; it doesn't accept --help or --version. - test $i = test && continue; - - # false fails even when invoked with --help or --version. - if test $i = false; then - env LC_MESSAGES=$lang $i --help >/dev/null && fail=1 - env LC_MESSAGES=$lang $i --version >/dev/null && fail=1 - continue - fi - - # The just-built install executable is always named 'ginstall'. - test $i = install && i=ginstall - - # Make sure they exit successfully, under normal conditions. - env $i --help > h-$i || fail=1 - env $i --version >/dev/null || fail=1 - - # Make sure they mention the bug-reporting address in --help output. - grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1 - rm -f h-$i - - # Make sure they fail upon 'disk full' error. - if test -w /dev/full && test -c /dev/full; then - env $i --help >/dev/full 2>/dev/null && fail=1 - env $i --version >/dev/full 2>/dev/null && fail=1 - status=$? - test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//") - eval "expected=\$expected_failure_status_$prog" - test x$expected = x && expected=1 - if test $status = $expected; then - : # ok - else - fail=1 - echo "*** $i: bad exit status '$status' (expected $expected)," 1>&2 - echo " with --help or --version output redirected to /dev/full" 1>&2 - fi - fi - done -done - -bigZ_in=bigZ-in.Z -zin=zin.gz -zin2=zin2.gz - -tmp=tmp-$$ -tmp_in=in-$$ -tmp_in2=in2-$$ -tmp_dir=dir-$$ -tmp_out=out-$$ -mkdir $tmp || fail=1 -cd $tmp || fail=1 - -comm_setup () { args="$tmp_in $tmp_in"; } -csplit_setup () { args="$tmp_in //"; } -cut_setup () { args='-f 1'; } -join_setup () { args="$tmp_in $tmp_in"; } -tr_setup () { args='a a'; } - -chmod_setup () { args="a+x $tmp_in"; } -# Punt on these. -chgrp_setup () { args=--version; } -chown_setup () { args=--version; } -mkfifo_setup () { args=--version; } -mknod_setup () { args=--version; } -# Punt on uptime, since it fails (e.g., failing to get boot time) -# on some systems, and we shouldn't let that stop 'make check'. -uptime_setup () { args=--version; } - -# Create a file in the current directory, not in $TMPDIR. -mktemp_setup () { args=mktemp.XXXX; } - -cmp_setup () { args="$tmp_in $tmp_in2"; } - -# Tell dd not to print the line with transfer rate and total. -# The transfer rate would vary between runs. -dd_setup () { args=status=noxfer; } - -zdiff_setup () { args="$zin $zin2"; } -zcmp_setup () { args="$zin $zin2"; } -zcat_setup () { args=$zin; } -gunzip_setup () { args=$zin; } -zmore_setup () { args=$zin; } -zless_setup () { args=$zin; } -znew_setup () { args=$bigZ_in; } -zforce_setup () { args=$zin; } -zgrep_setup () { args="z $zin"; } -zegrep_setup () { args="z $zin"; } -zfgrep_setup () { args="z $zin"; } -gzexe_setup () { args=$tmp_in; } - -# We know that $tmp_in contains a "0" -grep_setup () { args="0 $tmp_in"; } -egrep_setup () { args="0 $tmp_in"; } -fgrep_setup () { args="0 $tmp_in"; } - -diff_setup () { args="$tmp_in $tmp_in2"; } -sdiff_setup () { args="$tmp_in $tmp_in2"; } -diff3_setup () { args="$tmp_in $tmp_in2 $tmp_in2"; } -cp_setup () { args="$tmp_in $tmp_in2"; } -ln_setup () { args="$tmp_in ln-target"; } -ginstall_setup () { args="$tmp_in $tmp_in2"; } -mv_setup () { args="$tmp_in $tmp_in2"; } -mkdir_setup () { args=$tmp_dir/subdir; } -realpath_setup () { args=$tmp_in; } -rmdir_setup () { args=$tmp_dir; } -rm_setup () { args=$tmp_in; } -shred_setup () { args=$tmp_in; } -touch_setup () { args=$tmp_in2; } -truncate_setup () { args="--reference=$tmp_in $tmp_in2"; } - -mkid_setup () { printf 'f(){}\ntypedef int t;\n' > f.c; args=. ; } -lid_setup () { args=; } -fid_setup () { args=f.c; } -fnid_setup () { args=; } -xtokid_setup () { args=; } -aid_setup () { args=f; } -eid_setup () { args=--version; } -gid_setup () { args=f; } -defid_setup () { args=t; } - -basename_setup () { args=$tmp_in; } -dirname_setup () { args=$tmp_in; } -expr_setup () { args=foo; } - -# Punt, in case GNU 'id' hasn't been installed yet. -groups_setup () { args=--version; } - -pathchk_setup () { args=$tmp_in; } -yes_setup () { args=--version; } -logname_setup () { args=--version; } -nohup_setup () { args=--version; } -printf_setup () { args=foo; } -seq_setup () { args=10; } -sleep_setup () { args=0; } -stdbuf_setup () { args="-oL true"; } -timeout_setup () { args=--version; } - -# I'd rather not run sync, since it spins up disks that I've -# deliberately caused to spin down (but not unmounted). -sync_setup () { args=--version; } - -test_setup () { args=foo; } - -# This is necessary in the unusual event that there is -# no valid entry in /etc/mtab. -df_setup () { args=/; } - -# This is necessary in the unusual event that getpwuid (getuid ()) fails. -id_setup () { args=-u; } - -# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh. -kill_setup () { - env sleep 31.5 & - args=$! -} - -link_setup () { args="$tmp_in link-target"; } -unlink_setup () { args=$tmp_in; } - -readlink_setup () { - ln -s . slink - args=slink; -} - -stat_setup () { args=$tmp_in; } -unlink_setup () { args=$tmp_in; } -lbracket_setup () { args=": ]"; } - -parted_setup () { args="-s $tmp_in mklabel gpt" - dd if=/dev/null of=$tmp_in seek=2000; } - -# Ensure that each program "works" (exits successfully) when doing -# something more than --help or --version. -for i in $built_programs; do - # Skip these. - case $i in chroot|stty|tty|false|chcon|runcon) continue;; esac - - rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out $bigZ_in $zin $zin2 - echo z |gzip > $zin - cp $zin $zin2 - cp $zin $bigZ_in - - # This is sort of kludgey: use numbers so this is valid input for factor, - # and two tokens so it's valid input for tsort. - echo 2147483647 0 > $tmp_in - # Make $tmp_in2 identical. Then, using $tmp_in and $tmp_in2 as arguments - # to the likes of cmp and diff makes them exit successfully. - cp $tmp_in $tmp_in2 - mkdir $tmp_dir - # echo ================== $i - test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//") - if type ${prog}_setup > /dev/null 2>&1; then - ${prog}_setup - else - args= - fi - if env $i $args < $tmp_in > $tmp_out; then - : # ok - else - echo FAIL: $i - fail=1 - fi - rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir -done - -Exit $fail diff --git a/tests/misc/help-version.sh b/tests/misc/help-version.sh new file mode 100755 index 000000000..f2ac0e9bb --- /dev/null +++ b/tests/misc/help-version.sh @@ -0,0 +1,281 @@ +#! /bin/sh +# Make sure all of these programs work properly +# when invoked with --help or --version. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Ensure that $SHELL is set to *some* value and exported. +# This is required for dircolors, which would fail e.g., when +# invoked via debuild (which removes SHELL from the environment). +test "x$SHELL" = x && SHELL=/bin/sh +export SHELL + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +expected_failure_status_chroot=125 +expected_failure_status_env=125 +expected_failure_status_nice=125 +expected_failure_status_nohup=125 +expected_failure_status_stdbuf=125 +expected_failure_status_timeout=125 +expected_failure_status_printenv=2 +expected_failure_status_tty=3 +expected_failure_status_sort=2 +expected_failure_status_expr=3 +expected_failure_status_lbracket=2 +expected_failure_status_dir=2 +expected_failure_status_ls=2 +expected_failure_status_vdir=2 + +expected_failure_status_cmp=2 +expected_failure_status_zcmp=2 +expected_failure_status_sdiff=2 +expected_failure_status_diff3=2 +expected_failure_status_diff=2 +expected_failure_status_zdiff=2 +expected_failure_status_zgrep=2 +expected_failure_status_zegrep=2 +expected_failure_status_zfgrep=2 + +expected_failure_status_grep=2 +expected_failure_status_egrep=2 +expected_failure_status_fgrep=2 + +test "$built_programs" \ + || fail_ "built_programs not specified!?!" + +test "$VERSION" \ + || fail_ "set envvar VERSION; it is required for a PATH sanity-check" + +# Extract version from --version output of the first program +for i in $built_programs; do + v=$(env $i --version | sed -n '1s/.* //p;q') + break +done + +# Ensure that it matches $VERSION. +test "x$v" = "x$VERSION" \ + || fail_ "--version-\$VERSION mismatch" + +for lang in C fr da; do + for i in $built_programs; do + + # Skip 'test'; it doesn't accept --help or --version. + test $i = test && continue; + + # false fails even when invoked with --help or --version. + if test $i = false; then + env LC_MESSAGES=$lang $i --help >/dev/null && fail=1 + env LC_MESSAGES=$lang $i --version >/dev/null && fail=1 + continue + fi + + # The just-built install executable is always named 'ginstall'. + test $i = install && i=ginstall + + # Make sure they exit successfully, under normal conditions. + env $i --help > h-$i || fail=1 + env $i --version >/dev/null || fail=1 + + # Make sure they mention the bug-reporting address in --help output. + grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1 + rm -f h-$i + + # Make sure they fail upon 'disk full' error. + if test -w /dev/full && test -c /dev/full; then + env $i --help >/dev/full 2>/dev/null && fail=1 + env $i --version >/dev/full 2>/dev/null && fail=1 + status=$? + test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//") + eval "expected=\$expected_failure_status_$prog" + test x$expected = x && expected=1 + if test $status = $expected; then + : # ok + else + fail=1 + echo "*** $i: bad exit status '$status' (expected $expected)," 1>&2 + echo " with --help or --version output redirected to /dev/full" 1>&2 + fi + fi + done +done + +bigZ_in=bigZ-in.Z +zin=zin.gz +zin2=zin2.gz + +tmp=tmp-$$ +tmp_in=in-$$ +tmp_in2=in2-$$ +tmp_dir=dir-$$ +tmp_out=out-$$ +mkdir $tmp || fail=1 +cd $tmp || fail=1 + +comm_setup () { args="$tmp_in $tmp_in"; } +csplit_setup () { args="$tmp_in //"; } +cut_setup () { args='-f 1'; } +join_setup () { args="$tmp_in $tmp_in"; } +tr_setup () { args='a a'; } + +chmod_setup () { args="a+x $tmp_in"; } +# Punt on these. +chgrp_setup () { args=--version; } +chown_setup () { args=--version; } +mkfifo_setup () { args=--version; } +mknod_setup () { args=--version; } +# Punt on uptime, since it fails (e.g., failing to get boot time) +# on some systems, and we shouldn't let that stop 'make check'. +uptime_setup () { args=--version; } + +# Create a file in the current directory, not in $TMPDIR. +mktemp_setup () { args=mktemp.XXXX; } + +cmp_setup () { args="$tmp_in $tmp_in2"; } + +# Tell dd not to print the line with transfer rate and total. +# The transfer rate would vary between runs. +dd_setup () { args=status=noxfer; } + +zdiff_setup () { args="$zin $zin2"; } +zcmp_setup () { args="$zin $zin2"; } +zcat_setup () { args=$zin; } +gunzip_setup () { args=$zin; } +zmore_setup () { args=$zin; } +zless_setup () { args=$zin; } +znew_setup () { args=$bigZ_in; } +zforce_setup () { args=$zin; } +zgrep_setup () { args="z $zin"; } +zegrep_setup () { args="z $zin"; } +zfgrep_setup () { args="z $zin"; } +gzexe_setup () { args=$tmp_in; } + +# We know that $tmp_in contains a "0" +grep_setup () { args="0 $tmp_in"; } +egrep_setup () { args="0 $tmp_in"; } +fgrep_setup () { args="0 $tmp_in"; } + +diff_setup () { args="$tmp_in $tmp_in2"; } +sdiff_setup () { args="$tmp_in $tmp_in2"; } +diff3_setup () { args="$tmp_in $tmp_in2 $tmp_in2"; } +cp_setup () { args="$tmp_in $tmp_in2"; } +ln_setup () { args="$tmp_in ln-target"; } +ginstall_setup () { args="$tmp_in $tmp_in2"; } +mv_setup () { args="$tmp_in $tmp_in2"; } +mkdir_setup () { args=$tmp_dir/subdir; } +realpath_setup () { args=$tmp_in; } +rmdir_setup () { args=$tmp_dir; } +rm_setup () { args=$tmp_in; } +shred_setup () { args=$tmp_in; } +touch_setup () { args=$tmp_in2; } +truncate_setup () { args="--reference=$tmp_in $tmp_in2"; } + +mkid_setup () { printf 'f(){}\ntypedef int t;\n' > f.c; args=. ; } +lid_setup () { args=; } +fid_setup () { args=f.c; } +fnid_setup () { args=; } +xtokid_setup () { args=; } +aid_setup () { args=f; } +eid_setup () { args=--version; } +gid_setup () { args=f; } +defid_setup () { args=t; } + +basename_setup () { args=$tmp_in; } +dirname_setup () { args=$tmp_in; } +expr_setup () { args=foo; } + +# Punt, in case GNU 'id' hasn't been installed yet. +groups_setup () { args=--version; } + +pathchk_setup () { args=$tmp_in; } +yes_setup () { args=--version; } +logname_setup () { args=--version; } +nohup_setup () { args=--version; } +printf_setup () { args=foo; } +seq_setup () { args=10; } +sleep_setup () { args=0; } +stdbuf_setup () { args="-oL true"; } +timeout_setup () { args=--version; } + +# I'd rather not run sync, since it spins up disks that I've +# deliberately caused to spin down (but not unmounted). +sync_setup () { args=--version; } + +test_setup () { args=foo; } + +# This is necessary in the unusual event that there is +# no valid entry in /etc/mtab. +df_setup () { args=/; } + +# This is necessary in the unusual event that getpwuid (getuid ()) fails. +id_setup () { args=-u; } + +# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh. +kill_setup () { + env sleep 31.5 & + args=$! +} + +link_setup () { args="$tmp_in link-target"; } +unlink_setup () { args=$tmp_in; } + +readlink_setup () { + ln -s . slink + args=slink; +} + +stat_setup () { args=$tmp_in; } +unlink_setup () { args=$tmp_in; } +lbracket_setup () { args=": ]"; } + +parted_setup () { args="-s $tmp_in mklabel gpt" + dd if=/dev/null of=$tmp_in seek=2000; } + +# Ensure that each program "works" (exits successfully) when doing +# something more than --help or --version. +for i in $built_programs; do + # Skip these. + case $i in chroot|stty|tty|false|chcon|runcon) continue;; esac + + rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out $bigZ_in $zin $zin2 + echo z |gzip > $zin + cp $zin $zin2 + cp $zin $bigZ_in + + # This is sort of kludgey: use numbers so this is valid input for factor, + # and two tokens so it's valid input for tsort. + echo 2147483647 0 > $tmp_in + # Make $tmp_in2 identical. Then, using $tmp_in and $tmp_in2 as arguments + # to the likes of cmp and diff makes them exit successfully. + cp $tmp_in $tmp_in2 + mkdir $tmp_dir + # echo ================== $i + test $i = [ && prog=lbracket || prog=$(echo $i|sed "s/$EXEEXT$//") + if type ${prog}_setup > /dev/null 2>&1; then + ${prog}_setup + else + args= + fi + if env $i $args < $tmp_in > $tmp_out; then + : # ok + else + echo FAIL: $i + fail=1 + fi + rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir +done + +Exit $fail diff --git a/tests/misc/id-context b/tests/misc/id-context deleted file mode 100755 index 73645a0ec..000000000 --- a/tests/misc/id-context +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Ensure that "id" outputs SELinux context only without specified user -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ id -# Require selinux - when selinux is disabled, id never prints scontext. -require_selinux_ - - -# Check without specified user, context string should be present. -id | grep context= >/dev/null || fail=1 - -# Check with specified user, no context string should be present. -# But if the current user is nameless, skip this part. -id -nu > /dev/null \ - && id $(id -nu) | grep context= >/dev/null && fail=1 - -Exit $fail diff --git a/tests/misc/id-context.sh b/tests/misc/id-context.sh new file mode 100755 index 000000000..73645a0ec --- /dev/null +++ b/tests/misc/id-context.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Ensure that "id" outputs SELinux context only without specified user +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ id +# Require selinux - when selinux is disabled, id never prints scontext. +require_selinux_ + + +# Check without specified user, context string should be present. +id | grep context= >/dev/null || fail=1 + +# Check with specified user, no context string should be present. +# But if the current user is nameless, skip this part. +id -nu > /dev/null \ + && id $(id -nu) | grep context= >/dev/null && fail=1 + +Exit $fail diff --git a/tests/misc/id-groups b/tests/misc/id-groups deleted file mode 100755 index 815dd5529..000000000 --- a/tests/misc/id-groups +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# Ensure that "id" outputs groups for a user -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ id - -id -G $(id -nu) || fail=1 - -Exit $fail diff --git a/tests/misc/id-groups.sh b/tests/misc/id-groups.sh new file mode 100755 index 000000000..815dd5529 --- /dev/null +++ b/tests/misc/id-groups.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Ensure that "id" outputs groups for a user +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ id + +id -G $(id -nu) || fail=1 + +Exit $fail diff --git a/tests/misc/id-setgid b/tests/misc/id-setgid deleted file mode 100755 index 12fab381b..000000000 --- a/tests/misc/id-setgid +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Verify that id -G prints the right group when run set-GID. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ id -require_root_ - -g=$(id -u $NON_ROOT_USERNAME) || framework_failure_ - -# Construct a different group number. -gp1=$(expr $g + 1) - -echo $gp1 > exp || framework_failure_ - -setuidgid -g $gp1 $NON_ROOT_USERNAME env PATH="$PATH" id -G > out || fail=1 -compare exp out || fail=1 -# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g - -Exit $fail diff --git a/tests/misc/id-setgid.sh b/tests/misc/id-setgid.sh new file mode 100755 index 000000000..12fab381b --- /dev/null +++ b/tests/misc/id-setgid.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Verify that id -G prints the right group when run set-GID. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ id +require_root_ + +g=$(id -u $NON_ROOT_USERNAME) || framework_failure_ + +# Construct a different group number. +gp1=$(expr $g + 1) + +echo $gp1 > exp || framework_failure_ + +setuidgid -g $gp1 $NON_ROOT_USERNAME env PATH="$PATH" id -G > out || fail=1 +compare exp out || fail=1 +# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g + +Exit $fail diff --git a/tests/misc/invalid-opt b/tests/misc/invalid-opt deleted file mode 100755 index 8f7024c6f..000000000 --- a/tests/misc/invalid-opt +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/perl -# exercise the 'invalid option' handling code in each program - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -require 5.003; -use strict; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my %exit_status = - ( - ls => 2, - dir => 2, - vdir => 2, - test => 2, - chroot => 125, - echo => 0, - env => 125, - expr => 0, - nice => 125, - nohup => 125, - sort => 2, - stdbuf => 125, - test => 0, - timeout => 125, - true => 0, - tty => 2, - printf => 0, - printenv => 2, - ); - -my %expected_out = - ( - echo => "-/\n", - expr => "-/\n", - printf => "-/", - ); - -my %expected_err = - ( - false => '', - stty => '', - ); - -my $fail = 0; -my @built_programs = split ' ', $ENV{built_programs}; -foreach my $prog (@built_programs) - { - $prog eq '[' - and next; - - my $try = "Try '$prog --help' for more information.\n"; - my $x = $exit_status{$prog}; - defined $x - or $x = 1; - - my $out = $expected_out{$prog}; - defined $out - or $out = ''; - - my $err = $expected_err{$prog}; - defined $err - or $err = $x == 0 ? '' : "$prog: invalid option -- /\n$try"; - - # Accommodate different syntax in glibc's getopt - # diagnostics by filtering out single quotes. - # Also accommodate BSD getopt. - my $err_subst = "s,'/',/,; s,unknown,invalid,"; - - # Depending on how this script is run, stty emits different - # diagnostics. Don't bother checking them. - $prog eq 'stty' - and $err_subst = 's/(.|\n)*//ms'; - - my @Tests = (["$prog-invalid-opt", '-/', {OUT=>$out}, - {ERR_SUBST => $err_subst}, - {EXIT=>$x}, {ERR=>$err}]); - - my $save_temps = $ENV{DEBUG}; - my $verbose = $ENV{VERBOSE}; - - my $f = run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose); - $f - and $fail = 1; - } - -exit $fail; diff --git a/tests/misc/invalid-opt.pl b/tests/misc/invalid-opt.pl new file mode 100755 index 000000000..8f7024c6f --- /dev/null +++ b/tests/misc/invalid-opt.pl @@ -0,0 +1,102 @@ +#!/usr/bin/perl +# exercise the 'invalid option' handling code in each program + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +require 5.003; +use strict; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my %exit_status = + ( + ls => 2, + dir => 2, + vdir => 2, + test => 2, + chroot => 125, + echo => 0, + env => 125, + expr => 0, + nice => 125, + nohup => 125, + sort => 2, + stdbuf => 125, + test => 0, + timeout => 125, + true => 0, + tty => 2, + printf => 0, + printenv => 2, + ); + +my %expected_out = + ( + echo => "-/\n", + expr => "-/\n", + printf => "-/", + ); + +my %expected_err = + ( + false => '', + stty => '', + ); + +my $fail = 0; +my @built_programs = split ' ', $ENV{built_programs}; +foreach my $prog (@built_programs) + { + $prog eq '[' + and next; + + my $try = "Try '$prog --help' for more information.\n"; + my $x = $exit_status{$prog}; + defined $x + or $x = 1; + + my $out = $expected_out{$prog}; + defined $out + or $out = ''; + + my $err = $expected_err{$prog}; + defined $err + or $err = $x == 0 ? '' : "$prog: invalid option -- /\n$try"; + + # Accommodate different syntax in glibc's getopt + # diagnostics by filtering out single quotes. + # Also accommodate BSD getopt. + my $err_subst = "s,'/',/,; s,unknown,invalid,"; + + # Depending on how this script is run, stty emits different + # diagnostics. Don't bother checking them. + $prog eq 'stty' + and $err_subst = 's/(.|\n)*//ms'; + + my @Tests = (["$prog-invalid-opt", '-/', {OUT=>$out}, + {ERR_SUBST => $err_subst}, + {EXIT=>$x}, {ERR=>$err}]); + + my $save_temps = $ENV{DEBUG}; + my $verbose = $ENV{VERBOSE}; + + my $f = run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose); + $f + and $fail = 1; + } + +exit $fail; diff --git a/tests/misc/join b/tests/misc/join deleted file mode 100755 index 62074b7be..000000000 --- a/tests/misc/join +++ /dev/null @@ -1,315 +0,0 @@ -#!/usr/bin/perl -# Test join. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $limits = getlimits (); - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = 'join'; - -my $delim = chr 0247; -sub t_subst ($) -{ - (my $s = $_[0]) =~ s/:/$delim/g; - return $s; -} - -my @tv = ( -# test name -# flags file-1 file-2 expected output expected return code -# -['1a', '-a1', ["a 1\n", "b\n"], "a 1\n", 0], -['1b', '-a2', ["a 1\n", "b\n"], "b\n", 0], # Got "\n" -['1c', '-a1 -a2', ["a 1\n", "b\n"], "a 1\nb\n", 0], # Got "a 1\n\n" -['1d', '-a1', ["a 1\nb\n", "b\n"], "a 1\nb\n", 0], -['1e', '-a2', ["a 1\nb\n", "b\n"], "b\n", 0], -['1f', '-a2', ["b\n", "a\nb\n"], "a\nb\n", 0], - -['2a', '-a1 -e .', ["a\nb\nc\n", "a x y\nb\nc\n"], "a x y\nb\nc\n", 0], -['2b', '-a1 -e . -o 2.1,2.2,2.3', ["a\nb\nc\n", "a x y\nb\nc\n"], - "a x y\nb . .\nc . .\n", 0], -['2c', '-a1 -e . -o 2.1,2.2,2.3', ["a\nb\nc\nd\n", "a x y\nb\nc\n"], - "a x y\nb . .\nc . .\n. . .\n", 0], - -['3a', '-t:', ["a:1\nb:1\n", "a:2:\nb:2:\n"], "a:1:2:\nb:1:2:\n", 0], - -# operate on whole line (as sort does by default) -['3b', '-t ""', ["a 1\nb 1\n", "a 1\nb 2\n"], "a 1\n", 0], -# use NUL as the field delimiter -['3c', '-t "\\0"', ["a\0a\n", "a\0b\n"], "a\0a\0b\n", 0], - -# Just like -a1 and -a2 when there are no pairable lines -['4a', '-v 1', ["a 1\n", "b\n"], "a 1\n", 0], -['4b', '-v 2', ["a 1\n", "b\n"], "b\n", 0], - -['4c', '-v 1', ["a 1\nb\n", "b\n"], "a 1\n", 0], -['4d', '-v 2', ["a 1\nb\n", "b\n"], "", 0], -['4e', '-v 2', ["b\n", "a 1\nb\n"], "a 1\n", 0], -['5a', '-a1 -e - -o 1.1,2.2', - ["a 1\nb 2\n", "a 11\nb\n"], "a 11\nb -\n", 0], -['5b', '-a1 -e - -o 1.1,2.2', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15"], - "apr 06\naug 14\ndec -\nfeb 15\n", 0], -['5c', '-a1 -e - -o 1.1,2.2', - ["aug 20\ndec 18\n", "aug 14\ndate\nfeb 15"], - "aug 14\ndec -\n", 0], -['5d', '-a1 -e - -o 1.1,2.2', - ["dec 18\n", ""], "dec -\n", 0], -['5e', '-a2 -e - -o 1.1,2.2', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15\n"], - "apr 06\naug 14\n- -\nfeb 15\n", 0], -['5f', '-a2 -e - -o 2.2,1.1', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15\n"], - "06 apr\n14 aug\n- -\n15 feb\n", 0], -['5g', '-a1 -e - -o 2.2,1.1', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15\n"], - "06 apr\n14 aug\n- dec\n15 feb\n", 0], - -['5h', '-a1 -e - -o 2.2,1.1', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], - "06 apr\n14 aug\n- dec\n- feb\n", 0], -['5i', '-a1 -e - -o 1.1,2.2', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], - "apr 06\naug 14\ndec -\nfeb -\n", 0], - -['5j', '-a2 -e - -o 2.2,1.1', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], - "06 apr\n14 aug\n- -\n", 0], -['5k', '-a2 -e - -o 2.2,1.1', - ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], - "06 apr\n14 aug\n- -\n", 0], - -['5l', '-a1 -e - -o 2.2,1.1', - ["apr 15\naug 20\ndec 18\n", "apr 06\naug 14\ndate\nfeb 15\n"], - "06 apr\n14 aug\n- dec\n", 0], -['5m', '-a2 -e - -o 2.2,1.1', - ["apr 15\naug 20\ndec 18\n", "apr 06\naug 14\ndate\nfeb 15\n"], - "06 apr\n14 aug\n- -\n15 -\n", 0], - -['6a', '-e -', - ["a 1\nb 2\nd 4\n", "a 21\nb 22\nc 23\nf 26\n"], - "a 1 21\nb 2 22\n", 0], -['6b', '-a1 -e -', - ["a 1\nb 2\nd 4\n", "a 21\nb 22\nc 23\nf 26\n"], - "a 1 21\nb 2 22\nd 4\n", 0], -['6c', '-a1 -e -', - ["a 21\nb 22\nc 23\nf 26\n", "a 1\nb 2\nd 4\n"], - "a 21 1\nb 22 2\nc 23\nf 26\n", 0], - -['7a', '-a1 -e . -o 2.7', - ["a\nb\nc\n", "a x y\nb\nc\n"], ".\n.\n.\n", 0], - -['8a', '-a1 -e . -o 0,1.2', - ["a\nb\nc\nd G\n", "a x y\nb\nc\ne\n"], - "a .\nb .\nc .\nd G\n", 0], -['8b', '-a1 -a2 -e . -o 0,1.2', - ["a\nb\nc\nd G\n", "a x y\nb\nc\ne\n"], - "a .\nb .\nc .\nd G\ne .\n", 0], - -# From David Dyck -['9a', '', [" a 1\n b 2\n", " a Y\n b Z\n"], "a 1 Y\nb 2 Z\n", 0], - -# -o 'auto' -['10a', '-a1 -a2 -e . -o auto', - ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], - "a 1 2 3 4\nb 1 . 3 4\nc . . 3 4\nd 1 2 . .\n", 0], -['10b', '-a1 -a2 -j3 -e . -o auto', - ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], - "2 a 1 . .\n. b 1 . .\n2 d 1 . .\n4 . . a 3\n4 . . b 3\n4 . . c 3\n"], -['10c', '-a1 -1 1 -2 4 -e. -o auto', - ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], - "a 1 2 . . .\nb 1 . . . .\nd 1 2 . . .\n"], -['10d', '-a2 -1 1 -2 4 -e. -o auto', - ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], - ". . . a 3 4\n. . . b 3 4\n. . . c 3 4\n"], -['10e', '-o auto', - ["a 1 2\nb 1 2 discard\n", "a 3 4\nb 3 4 discard\n"], - "a 1 2 3 4\nb 1 2 3 4\n"], -['10f', '-t, -o auto', - ["a,1,,2\nb,1,2\n", "a,3,4\nb,3,4\n"], - "a,1,,2,3,4\nb,1,2,,3,4\n"], - -# For -v2, print the match field correctly with the default output format, -# when that match field is different between file 1 and file 2. Fixed in 8.10 -['v2-order', '-v2 -2 2', ["", "2 1\n"], "1 2\n", 0], - -# From Tim Smithers: fixed in 1.22l -['trailing-sp', '-t: -1 1 -2 1', ["a:x \n", "a:y \n"], "a:x :y \n", 0], - -# From Paul Eggert: fixed in 1.22n -['sp-vs-blank', '', ["\f 1\n", "\f 2\n"], "\f 1 2\n", 0], - -# From Paul Eggert: fixed in 1.22n (this would fail on Solaris7, -# with LC_ALL set to en_US). -# Unfortunately, that Solaris7's en_US locale folds case (making -# the first input file sorted) is not portable, so this test would -# fail on e.g. Linux systems, because the input to join isn't sorted. -# ['lc-collate', '', ["a 1a\nB 1B\n", "B 2B\n"], "B 1B 2B\n", 0], - -# Based on a report from Antonio Rendas. Fixed in 2.0.9. -['8-bit-t', t_subst "-t:", - [t_subst "a:1\nb:1\n", t_subst "a:2:\nb:2:\n"], - t_subst "a:1:2:\nb:1:2:\n", 0], - -# fields > SIZE_MAX are silently interpreted as SIZE_MAX -['bigfield1', "-1 $limits->{UINTMAX_OFLOW} -2 2", - ["a\n", "b\n"], " a b\n", 0], -['bigfield2', "-1 $limits->{SIZE_OFLOW} -2 2", - ["a\n", "b\n"], " a b\n", 0], - -# FIXME: change this to ensure the diagnostic makes sense -['invalid-j', '-j x', {}, "", 1, - "$prog: invalid field number: 'x'\n"], - -# With ordering check, inputs in order -['chkodr-1', '--check-order', - [" a 1\n b 2\n", " a Y\n b Z\n"], "a 1 Y\nb 2 Z\n", 0], - -# Without check, inputs in order -['chkodr-2', '--nocheck-order', - [" a 1\n b 2\n", " a Y\n b Z\n"], "a 1 Y\nb 2 Z\n", 0], - -# Without check, both inputs out of order (in fact, in reverse order) -# but all pairable. Support for this is a GNU extension. -['chkodr-3', '--nocheck-order', - [" b 1\n a 2\n", " b Y\n a Z\n"], "b 1 Y\na 2 Z\n", 0], - -# The extension should work without --nocheck-order, since that is the -# default. -['chkodr-4', '', - [" b 1\n a 2\n", " b Y\n a Z\n"], "b 1 Y\na 2 Z\n", 0], - -# With check, both inputs out of order (in fact, in reverse order) -['chkodr-5', '--check-order', - [" b 1\n a 2\n", " b Y\n a Z\n"], "", 1, - "$prog: chkodr-5.1:2: is not sorted: a 2\n"], - -# Similar, but with only file 2 not sorted. -['chkodr-5b', '--check-order', - [" a 2\n b 1\n", " b Y\n a Z\n"], "", 1, - "$prog: chkodr-5b.2:2: is not sorted: a Z\n"], - -# Similar, but with the offending line having length 0 (excluding newline). -['chkodr-5c', '--check-order', - [" a 2\n b 1\n", " b Y\n\n"], "", 1, - "$prog: chkodr-5c.2:2: is not sorted: \n"], - -# Similar, but elicit a warning for each input file (without --check-order). -['chkodr-5d', '', - ["a\nx\n\n", "b\ny\n\n"], "", 1, - "$prog: chkodr-5d.1:3: is not sorted: \n" . - "$prog: chkodr-5d.2:3: is not sorted: \n"], - -# Similar, but make it so each offending line has no newline. -['chkodr-5e', '', - ["a\nx\no", "b\ny\np"], "", 1, - "$prog: chkodr-5e.1:3: is not sorted: o\n" . - "$prog: chkodr-5e.2:3: is not sorted: p\n"], - -# Without order check, both inputs out of order and some lines -# unpairable. This is NOT supported by the GNU extension. All that -# we really care about for this test is that the return status is -# zero, since that is the only way to actually verify that the -# --nocheck-order option had any effect. We don't actually want to -# guarantee that join produces this output on stdout. -['chkodr-6', '--nocheck-order', - [" b 1\n a 2\n", " b Y\n c Z\n"], "b 1 Y\n", 0], - -# Before 6.10.143, this would mistakenly fail with the diagnostic: -# join: File 1 is not in sorted order -['chkodr-7', '-12', ["2 a\n1 b\n", "2 c\n1 d"], "", 0], - -# After 8.9, join doesn't report disorder by default -# when comparing against an empty input file. -['chkodr-8', '', ["2 a\n1 b\n", ""], "", 0], - -# Test '--header' feature -['header-1', '--header', - [ "ID Name\n1 A\n2 B\n", "ID Color\n1 red\n"], "ID Name Color\n1 A red\n", 0], - -# '--header' with '--check-order' : The header line is out-of-order but the -# actual data is in order. This join should succeed. -['header-2', '--header --check-order', - ["ID Name\n1 A\n2 B\n", "ID Color\n2 green\n"], - "ID Name Color\n2 B green\n", 0], - -# '--header' with '--check-order' : The header line is out-of-order AND the -# actual data out-of-order. This join should fail. -['header-3', '--header --check-order', - ["ID Name\n2 B\n1 A\n", "ID Color\n2 blue\n"], "ID Name Color\n", 1, - "$prog: header-3.1:3: is not sorted: 1 A\n"], - -# '--header' with specific output format '-o'. -# output header line should respect the requested format -['header-4', '--header -o "0,1.3,2.2"', - ["ID Group Name\n1 Foo A\n2 Bar B\n", "ID Color\n2 blue\n"], - "ID Name Color\n2 B blue\n", 0], - -# '--header' always outputs headers from the first file -# even if the headers from the second file don't match -['header-5', '--header', - [ "ID1 Name\n1 A\n2 B\n", "ID2 Color\n1 red\n"], - "ID1 Name Color\n1 A red\n", 0], - -# '--header' doesn't check order of a header -# even if there is no header in the second file -['header-6', '--header -a1', - [ "ID1 Name\n1 A\n", ""], - "ID1 Name\n1 A\n", 0], - -); - -# Convert the above old-style test vectors to the newer -# format used by Coreutils.pm. - -my @Tests; -foreach my $t (@tv) - { - my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t; - my $new_ent = [$test_name, $flags]; - if (!ref $in) - { - push @$new_ent, {IN=>$in}; - } - elsif (ref $in eq 'HASH') - { - # ignore - } - else - { - foreach my $e (@$in) - { - push @$new_ent, {IN=>$e}; - } - } - push @$new_ent, {OUT=>$exp}; - $ret - and push @$new_ent, {EXIT=>$ret}, {ERR=>$err_msg}; - push @Tests, $new_ent; - } - -@Tests = triple_test \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/join.pl b/tests/misc/join.pl new file mode 100755 index 000000000..62074b7be --- /dev/null +++ b/tests/misc/join.pl @@ -0,0 +1,315 @@ +#!/usr/bin/perl +# Test join. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $limits = getlimits (); + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = 'join'; + +my $delim = chr 0247; +sub t_subst ($) +{ + (my $s = $_[0]) =~ s/:/$delim/g; + return $s; +} + +my @tv = ( +# test name +# flags file-1 file-2 expected output expected return code +# +['1a', '-a1', ["a 1\n", "b\n"], "a 1\n", 0], +['1b', '-a2', ["a 1\n", "b\n"], "b\n", 0], # Got "\n" +['1c', '-a1 -a2', ["a 1\n", "b\n"], "a 1\nb\n", 0], # Got "a 1\n\n" +['1d', '-a1', ["a 1\nb\n", "b\n"], "a 1\nb\n", 0], +['1e', '-a2', ["a 1\nb\n", "b\n"], "b\n", 0], +['1f', '-a2', ["b\n", "a\nb\n"], "a\nb\n", 0], + +['2a', '-a1 -e .', ["a\nb\nc\n", "a x y\nb\nc\n"], "a x y\nb\nc\n", 0], +['2b', '-a1 -e . -o 2.1,2.2,2.3', ["a\nb\nc\n", "a x y\nb\nc\n"], + "a x y\nb . .\nc . .\n", 0], +['2c', '-a1 -e . -o 2.1,2.2,2.3', ["a\nb\nc\nd\n", "a x y\nb\nc\n"], + "a x y\nb . .\nc . .\n. . .\n", 0], + +['3a', '-t:', ["a:1\nb:1\n", "a:2:\nb:2:\n"], "a:1:2:\nb:1:2:\n", 0], + +# operate on whole line (as sort does by default) +['3b', '-t ""', ["a 1\nb 1\n", "a 1\nb 2\n"], "a 1\n", 0], +# use NUL as the field delimiter +['3c', '-t "\\0"', ["a\0a\n", "a\0b\n"], "a\0a\0b\n", 0], + +# Just like -a1 and -a2 when there are no pairable lines +['4a', '-v 1', ["a 1\n", "b\n"], "a 1\n", 0], +['4b', '-v 2', ["a 1\n", "b\n"], "b\n", 0], + +['4c', '-v 1', ["a 1\nb\n", "b\n"], "a 1\n", 0], +['4d', '-v 2', ["a 1\nb\n", "b\n"], "", 0], +['4e', '-v 2', ["b\n", "a 1\nb\n"], "a 1\n", 0], +['5a', '-a1 -e - -o 1.1,2.2', + ["a 1\nb 2\n", "a 11\nb\n"], "a 11\nb -\n", 0], +['5b', '-a1 -e - -o 1.1,2.2', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15"], + "apr 06\naug 14\ndec -\nfeb 15\n", 0], +['5c', '-a1 -e - -o 1.1,2.2', + ["aug 20\ndec 18\n", "aug 14\ndate\nfeb 15"], + "aug 14\ndec -\n", 0], +['5d', '-a1 -e - -o 1.1,2.2', + ["dec 18\n", ""], "dec -\n", 0], +['5e', '-a2 -e - -o 1.1,2.2', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15\n"], + "apr 06\naug 14\n- -\nfeb 15\n", 0], +['5f', '-a2 -e - -o 2.2,1.1', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15\n"], + "06 apr\n14 aug\n- -\n15 feb\n", 0], +['5g', '-a1 -e - -o 2.2,1.1', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\nfeb 15\n"], + "06 apr\n14 aug\n- dec\n15 feb\n", 0], + +['5h', '-a1 -e - -o 2.2,1.1', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], + "06 apr\n14 aug\n- dec\n- feb\n", 0], +['5i', '-a1 -e - -o 1.1,2.2', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], + "apr 06\naug 14\ndec -\nfeb -\n", 0], + +['5j', '-a2 -e - -o 2.2,1.1', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], + "06 apr\n14 aug\n- -\n", 0], +['5k', '-a2 -e - -o 2.2,1.1', + ["apr 15\naug 20\ndec 18\nfeb 05\n", "apr 06\naug 14\ndate\n"], + "06 apr\n14 aug\n- -\n", 0], + +['5l', '-a1 -e - -o 2.2,1.1', + ["apr 15\naug 20\ndec 18\n", "apr 06\naug 14\ndate\nfeb 15\n"], + "06 apr\n14 aug\n- dec\n", 0], +['5m', '-a2 -e - -o 2.2,1.1', + ["apr 15\naug 20\ndec 18\n", "apr 06\naug 14\ndate\nfeb 15\n"], + "06 apr\n14 aug\n- -\n15 -\n", 0], + +['6a', '-e -', + ["a 1\nb 2\nd 4\n", "a 21\nb 22\nc 23\nf 26\n"], + "a 1 21\nb 2 22\n", 0], +['6b', '-a1 -e -', + ["a 1\nb 2\nd 4\n", "a 21\nb 22\nc 23\nf 26\n"], + "a 1 21\nb 2 22\nd 4\n", 0], +['6c', '-a1 -e -', + ["a 21\nb 22\nc 23\nf 26\n", "a 1\nb 2\nd 4\n"], + "a 21 1\nb 22 2\nc 23\nf 26\n", 0], + +['7a', '-a1 -e . -o 2.7', + ["a\nb\nc\n", "a x y\nb\nc\n"], ".\n.\n.\n", 0], + +['8a', '-a1 -e . -o 0,1.2', + ["a\nb\nc\nd G\n", "a x y\nb\nc\ne\n"], + "a .\nb .\nc .\nd G\n", 0], +['8b', '-a1 -a2 -e . -o 0,1.2', + ["a\nb\nc\nd G\n", "a x y\nb\nc\ne\n"], + "a .\nb .\nc .\nd G\ne .\n", 0], + +# From David Dyck +['9a', '', [" a 1\n b 2\n", " a Y\n b Z\n"], "a 1 Y\nb 2 Z\n", 0], + +# -o 'auto' +['10a', '-a1 -a2 -e . -o auto', + ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], + "a 1 2 3 4\nb 1 . 3 4\nc . . 3 4\nd 1 2 . .\n", 0], +['10b', '-a1 -a2 -j3 -e . -o auto', + ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], + "2 a 1 . .\n. b 1 . .\n2 d 1 . .\n4 . . a 3\n4 . . b 3\n4 . . c 3\n"], +['10c', '-a1 -1 1 -2 4 -e. -o auto', + ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], + "a 1 2 . . .\nb 1 . . . .\nd 1 2 . . .\n"], +['10d', '-a2 -1 1 -2 4 -e. -o auto', + ["a 1 2\nb 1\nd 1 2\n", "a 3 4\nb 3 4\nc 3 4\n"], + ". . . a 3 4\n. . . b 3 4\n. . . c 3 4\n"], +['10e', '-o auto', + ["a 1 2\nb 1 2 discard\n", "a 3 4\nb 3 4 discard\n"], + "a 1 2 3 4\nb 1 2 3 4\n"], +['10f', '-t, -o auto', + ["a,1,,2\nb,1,2\n", "a,3,4\nb,3,4\n"], + "a,1,,2,3,4\nb,1,2,,3,4\n"], + +# For -v2, print the match field correctly with the default output format, +# when that match field is different between file 1 and file 2. Fixed in 8.10 +['v2-order', '-v2 -2 2', ["", "2 1\n"], "1 2\n", 0], + +# From Tim Smithers: fixed in 1.22l +['trailing-sp', '-t: -1 1 -2 1', ["a:x \n", "a:y \n"], "a:x :y \n", 0], + +# From Paul Eggert: fixed in 1.22n +['sp-vs-blank', '', ["\f 1\n", "\f 2\n"], "\f 1 2\n", 0], + +# From Paul Eggert: fixed in 1.22n (this would fail on Solaris7, +# with LC_ALL set to en_US). +# Unfortunately, that Solaris7's en_US locale folds case (making +# the first input file sorted) is not portable, so this test would +# fail on e.g. Linux systems, because the input to join isn't sorted. +# ['lc-collate', '', ["a 1a\nB 1B\n", "B 2B\n"], "B 1B 2B\n", 0], + +# Based on a report from Antonio Rendas. Fixed in 2.0.9. +['8-bit-t', t_subst "-t:", + [t_subst "a:1\nb:1\n", t_subst "a:2:\nb:2:\n"], + t_subst "a:1:2:\nb:1:2:\n", 0], + +# fields > SIZE_MAX are silently interpreted as SIZE_MAX +['bigfield1', "-1 $limits->{UINTMAX_OFLOW} -2 2", + ["a\n", "b\n"], " a b\n", 0], +['bigfield2', "-1 $limits->{SIZE_OFLOW} -2 2", + ["a\n", "b\n"], " a b\n", 0], + +# FIXME: change this to ensure the diagnostic makes sense +['invalid-j', '-j x', {}, "", 1, + "$prog: invalid field number: 'x'\n"], + +# With ordering check, inputs in order +['chkodr-1', '--check-order', + [" a 1\n b 2\n", " a Y\n b Z\n"], "a 1 Y\nb 2 Z\n", 0], + +# Without check, inputs in order +['chkodr-2', '--nocheck-order', + [" a 1\n b 2\n", " a Y\n b Z\n"], "a 1 Y\nb 2 Z\n", 0], + +# Without check, both inputs out of order (in fact, in reverse order) +# but all pairable. Support for this is a GNU extension. +['chkodr-3', '--nocheck-order', + [" b 1\n a 2\n", " b Y\n a Z\n"], "b 1 Y\na 2 Z\n", 0], + +# The extension should work without --nocheck-order, since that is the +# default. +['chkodr-4', '', + [" b 1\n a 2\n", " b Y\n a Z\n"], "b 1 Y\na 2 Z\n", 0], + +# With check, both inputs out of order (in fact, in reverse order) +['chkodr-5', '--check-order', + [" b 1\n a 2\n", " b Y\n a Z\n"], "", 1, + "$prog: chkodr-5.1:2: is not sorted: a 2\n"], + +# Similar, but with only file 2 not sorted. +['chkodr-5b', '--check-order', + [" a 2\n b 1\n", " b Y\n a Z\n"], "", 1, + "$prog: chkodr-5b.2:2: is not sorted: a Z\n"], + +# Similar, but with the offending line having length 0 (excluding newline). +['chkodr-5c', '--check-order', + [" a 2\n b 1\n", " b Y\n\n"], "", 1, + "$prog: chkodr-5c.2:2: is not sorted: \n"], + +# Similar, but elicit a warning for each input file (without --check-order). +['chkodr-5d', '', + ["a\nx\n\n", "b\ny\n\n"], "", 1, + "$prog: chkodr-5d.1:3: is not sorted: \n" . + "$prog: chkodr-5d.2:3: is not sorted: \n"], + +# Similar, but make it so each offending line has no newline. +['chkodr-5e', '', + ["a\nx\no", "b\ny\np"], "", 1, + "$prog: chkodr-5e.1:3: is not sorted: o\n" . + "$prog: chkodr-5e.2:3: is not sorted: p\n"], + +# Without order check, both inputs out of order and some lines +# unpairable. This is NOT supported by the GNU extension. All that +# we really care about for this test is that the return status is +# zero, since that is the only way to actually verify that the +# --nocheck-order option had any effect. We don't actually want to +# guarantee that join produces this output on stdout. +['chkodr-6', '--nocheck-order', + [" b 1\n a 2\n", " b Y\n c Z\n"], "b 1 Y\n", 0], + +# Before 6.10.143, this would mistakenly fail with the diagnostic: +# join: File 1 is not in sorted order +['chkodr-7', '-12', ["2 a\n1 b\n", "2 c\n1 d"], "", 0], + +# After 8.9, join doesn't report disorder by default +# when comparing against an empty input file. +['chkodr-8', '', ["2 a\n1 b\n", ""], "", 0], + +# Test '--header' feature +['header-1', '--header', + [ "ID Name\n1 A\n2 B\n", "ID Color\n1 red\n"], "ID Name Color\n1 A red\n", 0], + +# '--header' with '--check-order' : The header line is out-of-order but the +# actual data is in order. This join should succeed. +['header-2', '--header --check-order', + ["ID Name\n1 A\n2 B\n", "ID Color\n2 green\n"], + "ID Name Color\n2 B green\n", 0], + +# '--header' with '--check-order' : The header line is out-of-order AND the +# actual data out-of-order. This join should fail. +['header-3', '--header --check-order', + ["ID Name\n2 B\n1 A\n", "ID Color\n2 blue\n"], "ID Name Color\n", 1, + "$prog: header-3.1:3: is not sorted: 1 A\n"], + +# '--header' with specific output format '-o'. +# output header line should respect the requested format +['header-4', '--header -o "0,1.3,2.2"', + ["ID Group Name\n1 Foo A\n2 Bar B\n", "ID Color\n2 blue\n"], + "ID Name Color\n2 B blue\n", 0], + +# '--header' always outputs headers from the first file +# even if the headers from the second file don't match +['header-5', '--header', + [ "ID1 Name\n1 A\n2 B\n", "ID2 Color\n1 red\n"], + "ID1 Name Color\n1 A red\n", 0], + +# '--header' doesn't check order of a header +# even if there is no header in the second file +['header-6', '--header -a1', + [ "ID1 Name\n1 A\n", ""], + "ID1 Name\n1 A\n", 0], + +); + +# Convert the above old-style test vectors to the newer +# format used by Coreutils.pm. + +my @Tests; +foreach my $t (@tv) + { + my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t; + my $new_ent = [$test_name, $flags]; + if (!ref $in) + { + push @$new_ent, {IN=>$in}; + } + elsif (ref $in eq 'HASH') + { + # ignore + } + else + { + foreach my $e (@$in) + { + push @$new_ent, {IN=>$e}; + } + } + push @$new_ent, {OUT=>$exp}; + $ret + and push @$new_ent, {EXIT=>$ret}, {ERR=>$err_msg}; + push @Tests, $new_ent; + } + +@Tests = triple_test \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc deleted file mode 100755 index 71647f9d6..000000000 --- a/tests/misc/ls-misc +++ /dev/null @@ -1,341 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $ME = $0) =~ s|.*/||; -my $prog = 'ls'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $saved_ls_colors; - -sub push_ls_colors($) -{ - $saved_ls_colors = $ENV{LS_COLORS} || ''; - $ENV{LS_COLORS} = $_[0]; -} - -sub restore_ls_colors() -{ - $ENV{LS_COLORS} = $saved_ls_colors; -} - -# If the string $S is a well-behaved file name, simply return it. -# If it contains white space, quotes, etc., quote it, and return the new string. -sub shell_quote($) -{ - my ($s) = @_; - if ($s =~ m![^\w+/.,-]!) - { - # Convert each single quote to '\'' - $s =~ s/\'/\'\\\'\'/g; - # Then single quote the string. - $s = "'$s'"; - } - return $s; -} - -# Set up files used by the setuid-etc tests; skip this entire test if -# that cannot be done. -sub setuid_setup() -{ - my $test = shell_quote "$ENV{abs_top_builddir}/src/test"; - system (qq(touch setuid && chmod u+s setuid && $test -u setuid && - touch setgid && chmod g+s setgid && $test -g setgid && - mkdir sticky && chmod +t sticky && $test -k sticky && - mkdir owt && chmod +t,o+w owt && $test -k owt && - mkdir owr && chmod o+w owr)) == 0 - or CuSkip::skip "$ME: cannot create setuid/setgid/sticky files," - . "so can't run this test\n"; -} - -sub mk_file(@) -{ - foreach my $f (@_) - { - open (F, '>', $f) && close F - or die "creating $f: $!\n"; - } -} - -sub mkdir_d {mkdir 'd',0755 or die "d: $!\n"} -sub rmdir_d {rmdir 'd' or die "d: $!\n"} -my $mkdir = {PRE => sub {mkdir_d}}; -my $rmdir = {POST => sub {rmdir_d}}; -my $mkdir_reg = {PRE => sub {mkdir_d; mk_file 'd/f' }}; -my $rmdir_reg = {POST => sub {unlink 'd/f' or die "d/f: $!\n"; - rmdir 'd' or die "d: $!\n"}}; - -my $mkdir2 = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; - mkdir 'd/e',0755 or die "d/e: $!\n" }}; -my $rmdir2 = {POST => sub {rmdir 'd/e' or die "d/e: $!\n"; - rmdir 'd' or die "d: $!\n" }}; - -my $target = {PRE => sub { - mkdir 'd',0755 or die "d: $!\n"; - symlink '.', 'd/X' or die "d/X: $!\n"; - push_ls_colors('ln=target') - }}; -my $target2 = {POST => sub {unlink 'd/X' or die "d/X: $!\n"; - rmdir 'd' or die "d: $!\n"; - restore_ls_colors - }}; -my $slink_d = {PRE => sub {symlink '/', 'd' or die "d: $!\n"; - push_ls_colors('ln=01;36:di=01;34:or=40;31;01') - }}; -my $unlink_d = {POST => sub {unlink 'd' or die "d: $!\n"; restore_ls_colors}}; - -my $mkdir_d_slink = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; - symlink '/', 'd/s' or die "d/s: $!\n" }}; -my $rmdir_d_slink = {POST => sub {unlink 'd/s' or die "d/s: $!\n"; - rmdir 'd' or die "d: $!\n" }}; - -sub make_j_d () -{ - mkdir 'j', 0700 or die "creating j: $!\n"; - mk_file 'j/d'; - chmod 0555, 'j/d' or die "making j/d executable: $!\n"; -} - -my @v1 = (qw(0 9 A Z a z), 'zz~', 'zz', 'zz.~1~', 'zz.0'); -my @v_files = ((map { ".$_" } @v1), @v1); -my $exe_in_subdir = {PRE => sub { make_j_d (); push_ls_colors('ex=01;32') }}; -my $remove_j = {POST => sub {unlink 'j/d' or die "j/d: $!\n"; - rmdir 'j' or die "j: $!\n"; - restore_ls_colors }}; - -my $e = "\e[0m"; -my $q_bell = {IN => {"q\a" => ''}}; -my @Tests = - ( - # test-name options input expected-output - # - # quoting tests............................................ - ['q-', $q_bell, {OUT => "q\a\n"}, {EXIT => 0}], - ['q-N', '-N', $q_bell, {OUT => "q\a\n"}, {ERR => ''}], - ['q-q', '-q', $q_bell, {OUT => "q?\n"}], - ['q-Q', '-Q', $q_bell, {OUT => "\"q\\a\"\n"}], - - ['q-lit-q', '--quoting=literal -q', $q_bell, {OUT => "q?\n"}], - ['q-qs-lit', '--quoting=literal', $q_bell, {OUT => "q\a\n"}], - ['q-qs-sh', '--quoting=shell', $q_bell, {OUT => "q\a\n"}], - ['q-qs-sh-a', '--quoting=shell-always', $q_bell, {OUT => "'q\a'\n"}], - ['q-qs-c', '--quoting=c', $q_bell, {OUT => "\"q\\a\"\n"}], - ['q-qs-esc', '--quoting=escape', $q_bell, {OUT => "q\\a\n"}], - ['q-qs-c-1', '--quoting=c', - {IN => {"t\004" => ''}}, {OUT => "\"t\\004\"\n"}], - - ['emptydir', 'd', {OUT => ''}, $mkdir, $rmdir], - ['emptydir-x2', 'd d', {OUT => "d:\n\nd:\n"}, $mkdir, $rmdir], - ['emptydir-R', '-R d', {OUT => "d:\n"}, $mkdir, $rmdir], - - # test 'ls -R .' ............................................ - ['R-dot', '--ignore="[a-ce-zA-Z]*" -R .', {OUT => ".:\nd\n\n\./d:\n"}, - $mkdir, $rmdir], - - ['slink-dir-F', '-F d', {OUT => "d@\n"}, $slink_d, $unlink_d], - ['slink-dir-dF', '-dF d', {OUT => "d@\n"}, $slink_d, $unlink_d], - ['slinkdir-dFH', '-dFH d', {OUT => "d/\n"}, $slink_d, $unlink_d], - ['slinkdir-dFL', '-dFL d', {OUT => "d/\n"}, $slink_d, $unlink_d], - - # Test for a bug that was fixed in coreutils-4.5.4. - ['sl-F-color', '-F --color=always d', - {OUT => "$e\e[01;36md$e\@\n"}, - $slink_d, $unlink_d], - ['sl-dF-color', '-dF --color=always d', - {OUT => "$e\e[01;36md$e\@\n"}, - $slink_d, $unlink_d], - - # A listing with no output should have no color sequences at all. - ['no-c-empty', '--color=always d', {OUT => ""}, $mkdir, $rmdir], - # A listing with only regular files should have no color sequences at all. - ['no-c-reg', '--color=always d', {OUT => "f\n"}, $mkdir_reg, $rmdir_reg], - - # Test for a bug fixed after coreutils-6.9. - ['sl-target', '--color=always d', - {OUT => "$e\e[01;34mX$e\n"}, $target, $target2], - - # Test for another bug fixed after coreutils-6.9. - # This one bites only for a system/file system with d_type support. - ['sl-dangle', '--color=always d', - {OUT => "$e\e[40;31;01mX$e\n"}, - {PRE => sub { - mkdir 'd',0755 or die "d: $!\n"; - symlink 'non-existent', 'd/X' or die "d/X: $!\n"; - push_ls_colors('or=40;31;01') - }}, - {POST => sub {unlink 'd/X' or die "d/X: $!\n"; - rmdir 'd' or die "d: $!\n"; - restore_ls_colors; }}, - ], - - # Test for a bug fixed after coreutils-8.2. - ['sl-dangle2', '-o --time-style=+:TIME: --color=always l', - {OUT_SUBST => 's/.*:TIME: //'}, - {OUT => "l -> nowhere\n"}, - {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; - push_ls_colors('ln=target') - }}, - {POST => sub {unlink 'l' or die "l: $!\n"; - restore_ls_colors; }}, - ], - ['sl-dangle3', '-o --time-style=+:TIME: --color=always l', - {OUT_SUBST => 's/.*:TIME: //'}, - {OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n"}, - {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; - push_ls_colors('ln=target:or=40:mi=34:') - }}, - {POST => sub {unlink 'l' or die "l: $!\n"; - restore_ls_colors; }}, - ], - ['sl-dangle4', '-o --time-style=+:TIME: --color=always l', - {OUT_SUBST => 's/.*:TIME: //'}, - {OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n"}, - {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; - push_ls_colors('ln=34:mi=35:or=36:') - }}, - {POST => sub {unlink 'l' or die "l: $!\n"; - restore_ls_colors; }}, - ], - ['sl-dangle5', '-o --time-style=+:TIME: --color=always l', - {OUT_SUBST => 's/.*:TIME: //'}, - {OUT => "$e\e[34ml$e -> \e[35mnowhere$e\n"}, - {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; - push_ls_colors('ln=34:mi=35:') - }}, - {POST => sub {unlink 'l' or die "l: $!\n"; - restore_ls_colors; }}, - ], - - # Test for a bug fixed after coreutils-8.13 - # where 'argetm' was errenously printed for dangling links - # when ln=target was used in LS_COLORS - ['sl-dangle6', '-L --color=always d', - {OUT => "s\n"}, - {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; - symlink 'dangle', 'd/s' or die "d/s: $!\n"; - push_ls_colors('ln=target') - }}, - {POST => sub {unlink 'd/s' or die "d/s: $!\n"; - rmdir 'd' or die "d: $!\n"; - restore_ls_colors; }}, - {ERR => "ls: cannot access d/s: No such file or directory\n"}, - {EXIT => 1} - ], - # Related to the above fix, is this case where - # the code simulates "linkok". In this case "linkmode" - # should always be zero, and hence not trigger any - # issues with type being set to C_LINK - ['sl-dangle7', '--color=always d', - {OUT => "$e\e[ms$e\n"}, - {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; - symlink 'dangle', 'd/s' or die "d/s: $!\n"; - push_ls_colors('ln=target:or=:ex=:') - }}, - {POST => sub {unlink 'd/s' or die "d/s: $!\n"; - rmdir 'd' or die "d: $!\n"; - restore_ls_colors; }}, - ], - # Another case with simulated "linkok", that does - # actually use the value of 'ln' from $LS_COLORS. - # This path is not taken though when 'ln=target'. - ['sl-dangle8', '--color=always s', - {OUT => "$e\e[1;36ms$e\n"}, - {PRE => sub {symlink 'dangle', 's' or die "s: $!\n"; - push_ls_colors('ln=1;36:or=:') - }}, - {POST => sub {unlink 's' or die "s: $!\n"; - restore_ls_colors; }}, - ], - - # Test for a bug that was introduced in coreutils-4.5.4; fixed in 4.5.5. - # To demonstrate it, the file in question (with executable bit set) - # must not be a command line argument. - ['color-exe1', '--color=always j', - {OUT => "$e\e[01;32md$e\n"}, - $exe_in_subdir, $remove_j], - - # From Stéphane Chazelas. - ['no-a-isdir-b', 'no-dir d', - {OUT => "d:\n"}, - {ERR => "ls: cannot access no-dir: No such file or directory\n"}, - $mkdir, $rmdir, {EXIT => 2}], - - ['recursive-2', '-R d', {OUT => "d:\ne\n\nd/e:\n"}, $mkdir2, $rmdir2], - - ['setuid-etc', '-1 -d --color=always owr owt setgid setuid sticky', - {OUT => - "$e\e[34;42mowr$e\n" - . "\e[30;42mowt$e\n" - . "\e[30;43msetgid$e\n" - . "\e[37;41msetuid$e\n" - . "\e[37;44msticky$e\n" - }, - - {POST => sub { - unlink qw(setuid setgid); - foreach my $dir (qw(owr owt sticky)) {rmdir $dir} }}, - ], - - # For 5.97 and earlier, --file-type acted like --indicator-style=slash. - ['file-type', '--file-type d', {OUT => "s@\n"}, - $mkdir_d_slink, $rmdir_d_slink], - - # 7.1 had a regression in how -v -a ordered some files - ['version-sort', '-v -A ' . join (' ', @v_files), - {OUT => join ("\n", @v_files) . "\n"}, - {PRE => sub { mk_file @v_files }}, - {POST => sub { unlink @v_files }}, - ], - - # Test for the ls -1U bug fixed in coreutils-7.5. - # It is triggered only with -1U and with two or more arguments, - # at least one of which is a nonempty directory. - ['multi-arg-U1', '-U1 d no-such', - {OUT => "d:\nf\n"}, - {ERR_SUBST=>'s/ch:.*/ch:/'}, - {ERR => "$prog: cannot access no-such:\n"}, - $mkdir_reg, - $rmdir_reg, - {EXIT => 2}, - ], - ); - -umask 022; - -# Start with an unset LS_COLORS environment variable. -delete $ENV{LS_COLORS}; - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -setuid_setup; -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -$fail - and exit 1; - -# Be careful to use the just-build dircolors. -my $env = qx/dircolors -b/; -$env =~ s/^LS_COLORS=\'//; -$env =~ s/\';.*//sm; -$ENV{LS_COLORS} = $env; - -setuid_setup; -$fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/ls-misc.pl b/tests/misc/ls-misc.pl new file mode 100755 index 000000000..71647f9d6 --- /dev/null +++ b/tests/misc/ls-misc.pl @@ -0,0 +1,341 @@ +#!/usr/bin/perl + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $ME = $0) =~ s|.*/||; +my $prog = 'ls'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $saved_ls_colors; + +sub push_ls_colors($) +{ + $saved_ls_colors = $ENV{LS_COLORS} || ''; + $ENV{LS_COLORS} = $_[0]; +} + +sub restore_ls_colors() +{ + $ENV{LS_COLORS} = $saved_ls_colors; +} + +# If the string $S is a well-behaved file name, simply return it. +# If it contains white space, quotes, etc., quote it, and return the new string. +sub shell_quote($) +{ + my ($s) = @_; + if ($s =~ m![^\w+/.,-]!) + { + # Convert each single quote to '\'' + $s =~ s/\'/\'\\\'\'/g; + # Then single quote the string. + $s = "'$s'"; + } + return $s; +} + +# Set up files used by the setuid-etc tests; skip this entire test if +# that cannot be done. +sub setuid_setup() +{ + my $test = shell_quote "$ENV{abs_top_builddir}/src/test"; + system (qq(touch setuid && chmod u+s setuid && $test -u setuid && + touch setgid && chmod g+s setgid && $test -g setgid && + mkdir sticky && chmod +t sticky && $test -k sticky && + mkdir owt && chmod +t,o+w owt && $test -k owt && + mkdir owr && chmod o+w owr)) == 0 + or CuSkip::skip "$ME: cannot create setuid/setgid/sticky files," + . "so can't run this test\n"; +} + +sub mk_file(@) +{ + foreach my $f (@_) + { + open (F, '>', $f) && close F + or die "creating $f: $!\n"; + } +} + +sub mkdir_d {mkdir 'd',0755 or die "d: $!\n"} +sub rmdir_d {rmdir 'd' or die "d: $!\n"} +my $mkdir = {PRE => sub {mkdir_d}}; +my $rmdir = {POST => sub {rmdir_d}}; +my $mkdir_reg = {PRE => sub {mkdir_d; mk_file 'd/f' }}; +my $rmdir_reg = {POST => sub {unlink 'd/f' or die "d/f: $!\n"; + rmdir 'd' or die "d: $!\n"}}; + +my $mkdir2 = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; + mkdir 'd/e',0755 or die "d/e: $!\n" }}; +my $rmdir2 = {POST => sub {rmdir 'd/e' or die "d/e: $!\n"; + rmdir 'd' or die "d: $!\n" }}; + +my $target = {PRE => sub { + mkdir 'd',0755 or die "d: $!\n"; + symlink '.', 'd/X' or die "d/X: $!\n"; + push_ls_colors('ln=target') + }}; +my $target2 = {POST => sub {unlink 'd/X' or die "d/X: $!\n"; + rmdir 'd' or die "d: $!\n"; + restore_ls_colors + }}; +my $slink_d = {PRE => sub {symlink '/', 'd' or die "d: $!\n"; + push_ls_colors('ln=01;36:di=01;34:or=40;31;01') + }}; +my $unlink_d = {POST => sub {unlink 'd' or die "d: $!\n"; restore_ls_colors}}; + +my $mkdir_d_slink = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; + symlink '/', 'd/s' or die "d/s: $!\n" }}; +my $rmdir_d_slink = {POST => sub {unlink 'd/s' or die "d/s: $!\n"; + rmdir 'd' or die "d: $!\n" }}; + +sub make_j_d () +{ + mkdir 'j', 0700 or die "creating j: $!\n"; + mk_file 'j/d'; + chmod 0555, 'j/d' or die "making j/d executable: $!\n"; +} + +my @v1 = (qw(0 9 A Z a z), 'zz~', 'zz', 'zz.~1~', 'zz.0'); +my @v_files = ((map { ".$_" } @v1), @v1); +my $exe_in_subdir = {PRE => sub { make_j_d (); push_ls_colors('ex=01;32') }}; +my $remove_j = {POST => sub {unlink 'j/d' or die "j/d: $!\n"; + rmdir 'j' or die "j: $!\n"; + restore_ls_colors }}; + +my $e = "\e[0m"; +my $q_bell = {IN => {"q\a" => ''}}; +my @Tests = + ( + # test-name options input expected-output + # + # quoting tests............................................ + ['q-', $q_bell, {OUT => "q\a\n"}, {EXIT => 0}], + ['q-N', '-N', $q_bell, {OUT => "q\a\n"}, {ERR => ''}], + ['q-q', '-q', $q_bell, {OUT => "q?\n"}], + ['q-Q', '-Q', $q_bell, {OUT => "\"q\\a\"\n"}], + + ['q-lit-q', '--quoting=literal -q', $q_bell, {OUT => "q?\n"}], + ['q-qs-lit', '--quoting=literal', $q_bell, {OUT => "q\a\n"}], + ['q-qs-sh', '--quoting=shell', $q_bell, {OUT => "q\a\n"}], + ['q-qs-sh-a', '--quoting=shell-always', $q_bell, {OUT => "'q\a'\n"}], + ['q-qs-c', '--quoting=c', $q_bell, {OUT => "\"q\\a\"\n"}], + ['q-qs-esc', '--quoting=escape', $q_bell, {OUT => "q\\a\n"}], + ['q-qs-c-1', '--quoting=c', + {IN => {"t\004" => ''}}, {OUT => "\"t\\004\"\n"}], + + ['emptydir', 'd', {OUT => ''}, $mkdir, $rmdir], + ['emptydir-x2', 'd d', {OUT => "d:\n\nd:\n"}, $mkdir, $rmdir], + ['emptydir-R', '-R d', {OUT => "d:\n"}, $mkdir, $rmdir], + + # test 'ls -R .' ............................................ + ['R-dot', '--ignore="[a-ce-zA-Z]*" -R .', {OUT => ".:\nd\n\n\./d:\n"}, + $mkdir, $rmdir], + + ['slink-dir-F', '-F d', {OUT => "d@\n"}, $slink_d, $unlink_d], + ['slink-dir-dF', '-dF d', {OUT => "d@\n"}, $slink_d, $unlink_d], + ['slinkdir-dFH', '-dFH d', {OUT => "d/\n"}, $slink_d, $unlink_d], + ['slinkdir-dFL', '-dFL d', {OUT => "d/\n"}, $slink_d, $unlink_d], + + # Test for a bug that was fixed in coreutils-4.5.4. + ['sl-F-color', '-F --color=always d', + {OUT => "$e\e[01;36md$e\@\n"}, + $slink_d, $unlink_d], + ['sl-dF-color', '-dF --color=always d', + {OUT => "$e\e[01;36md$e\@\n"}, + $slink_d, $unlink_d], + + # A listing with no output should have no color sequences at all. + ['no-c-empty', '--color=always d', {OUT => ""}, $mkdir, $rmdir], + # A listing with only regular files should have no color sequences at all. + ['no-c-reg', '--color=always d', {OUT => "f\n"}, $mkdir_reg, $rmdir_reg], + + # Test for a bug fixed after coreutils-6.9. + ['sl-target', '--color=always d', + {OUT => "$e\e[01;34mX$e\n"}, $target, $target2], + + # Test for another bug fixed after coreutils-6.9. + # This one bites only for a system/file system with d_type support. + ['sl-dangle', '--color=always d', + {OUT => "$e\e[40;31;01mX$e\n"}, + {PRE => sub { + mkdir 'd',0755 or die "d: $!\n"; + symlink 'non-existent', 'd/X' or die "d/X: $!\n"; + push_ls_colors('or=40;31;01') + }}, + {POST => sub {unlink 'd/X' or die "d/X: $!\n"; + rmdir 'd' or die "d: $!\n"; + restore_ls_colors; }}, + ], + + # Test for a bug fixed after coreutils-8.2. + ['sl-dangle2', '-o --time-style=+:TIME: --color=always l', + {OUT_SUBST => 's/.*:TIME: //'}, + {OUT => "l -> nowhere\n"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=target') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + ['sl-dangle3', '-o --time-style=+:TIME: --color=always l', + {OUT_SUBST => 's/.*:TIME: //'}, + {OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=target:or=40:mi=34:') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + ['sl-dangle4', '-o --time-style=+:TIME: --color=always l', + {OUT_SUBST => 's/.*:TIME: //'}, + {OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=34:mi=35:or=36:') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + ['sl-dangle5', '-o --time-style=+:TIME: --color=always l', + {OUT_SUBST => 's/.*:TIME: //'}, + {OUT => "$e\e[34ml$e -> \e[35mnowhere$e\n"}, + {PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n"; + push_ls_colors('ln=34:mi=35:') + }}, + {POST => sub {unlink 'l' or die "l: $!\n"; + restore_ls_colors; }}, + ], + + # Test for a bug fixed after coreutils-8.13 + # where 'argetm' was errenously printed for dangling links + # when ln=target was used in LS_COLORS + ['sl-dangle6', '-L --color=always d', + {OUT => "s\n"}, + {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; + symlink 'dangle', 'd/s' or die "d/s: $!\n"; + push_ls_colors('ln=target') + }}, + {POST => sub {unlink 'd/s' or die "d/s: $!\n"; + rmdir 'd' or die "d: $!\n"; + restore_ls_colors; }}, + {ERR => "ls: cannot access d/s: No such file or directory\n"}, + {EXIT => 1} + ], + # Related to the above fix, is this case where + # the code simulates "linkok". In this case "linkmode" + # should always be zero, and hence not trigger any + # issues with type being set to C_LINK + ['sl-dangle7', '--color=always d', + {OUT => "$e\e[ms$e\n"}, + {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; + symlink 'dangle', 'd/s' or die "d/s: $!\n"; + push_ls_colors('ln=target:or=:ex=:') + }}, + {POST => sub {unlink 'd/s' or die "d/s: $!\n"; + rmdir 'd' or die "d: $!\n"; + restore_ls_colors; }}, + ], + # Another case with simulated "linkok", that does + # actually use the value of 'ln' from $LS_COLORS. + # This path is not taken though when 'ln=target'. + ['sl-dangle8', '--color=always s', + {OUT => "$e\e[1;36ms$e\n"}, + {PRE => sub {symlink 'dangle', 's' or die "s: $!\n"; + push_ls_colors('ln=1;36:or=:') + }}, + {POST => sub {unlink 's' or die "s: $!\n"; + restore_ls_colors; }}, + ], + + # Test for a bug that was introduced in coreutils-4.5.4; fixed in 4.5.5. + # To demonstrate it, the file in question (with executable bit set) + # must not be a command line argument. + ['color-exe1', '--color=always j', + {OUT => "$e\e[01;32md$e\n"}, + $exe_in_subdir, $remove_j], + + # From Stéphane Chazelas. + ['no-a-isdir-b', 'no-dir d', + {OUT => "d:\n"}, + {ERR => "ls: cannot access no-dir: No such file or directory\n"}, + $mkdir, $rmdir, {EXIT => 2}], + + ['recursive-2', '-R d', {OUT => "d:\ne\n\nd/e:\n"}, $mkdir2, $rmdir2], + + ['setuid-etc', '-1 -d --color=always owr owt setgid setuid sticky', + {OUT => + "$e\e[34;42mowr$e\n" + . "\e[30;42mowt$e\n" + . "\e[30;43msetgid$e\n" + . "\e[37;41msetuid$e\n" + . "\e[37;44msticky$e\n" + }, + + {POST => sub { + unlink qw(setuid setgid); + foreach my $dir (qw(owr owt sticky)) {rmdir $dir} }}, + ], + + # For 5.97 and earlier, --file-type acted like --indicator-style=slash. + ['file-type', '--file-type d', {OUT => "s@\n"}, + $mkdir_d_slink, $rmdir_d_slink], + + # 7.1 had a regression in how -v -a ordered some files + ['version-sort', '-v -A ' . join (' ', @v_files), + {OUT => join ("\n", @v_files) . "\n"}, + {PRE => sub { mk_file @v_files }}, + {POST => sub { unlink @v_files }}, + ], + + # Test for the ls -1U bug fixed in coreutils-7.5. + # It is triggered only with -1U and with two or more arguments, + # at least one of which is a nonempty directory. + ['multi-arg-U1', '-U1 d no-such', + {OUT => "d:\nf\n"}, + {ERR_SUBST=>'s/ch:.*/ch:/'}, + {ERR => "$prog: cannot access no-such:\n"}, + $mkdir_reg, + $rmdir_reg, + {EXIT => 2}, + ], + ); + +umask 022; + +# Start with an unset LS_COLORS environment variable. +delete $ENV{LS_COLORS}; + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +setuid_setup; +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +$fail + and exit 1; + +# Be careful to use the just-build dircolors. +my $env = qx/dircolors -b/; +$env =~ s/^LS_COLORS=\'//; +$env =~ s/\';.*//sm; +$ENV{LS_COLORS} = $env; + +setuid_setup; +$fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/ls-time b/tests/misc/ls-time deleted file mode 100755 index 7d1f205fc..000000000 --- a/tests/misc/ls-time +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/sh -# Test some of ls's sorting options. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ls - -# Avoid any possible glitches due to daylight-saving changes near the -# time stamps used during the test. -TZ=UTC0 -export TZ - -t1='1998-01-15 21:00' -t2='1998-01-15 22:00' -t3='1998-01-15 23:00' - -u1='1998-01-14 11:00' -u2='1998-01-14 12:00' -u3='1998-01-14 13:00' - -touch -m -d "$t3" a || framework_failure_ -touch -m -d "$t2" b || framework_failure_ -touch -m -d "$t1" c || framework_failure_ - -touch -a -d "$u3" c || framework_failure_ -touch -a -d "$u2" b || framework_failure_ -# Make sure A has ctime at least 1 second more recent than C's. -sleep 2 -touch -a -d "$u1" a || framework_failure_ -# Updating the atime is usually enough to update the ctime, but on -# Solaris 10's tmpfs, ctime is not updated, so force an update here: -{ ln a a-ctime && rm a-ctime; } || framework_failure_ - - -# A has ctime more recent than C. -set $(ls -c a c) -test "$*" = 'a c' || fail=1 - -# Sleep so long in an attempt to avoid spurious failures -# due to NFS caching and/or clock skew. -sleep 2 - -# Create a link, updating c's ctime. -ln c d || framework_failure_ - -# Before we go any further, verify that touch's -m option works. -set -- $(ls --full -l a) -case "$*" in - *" $t3:00.000000000 +0000 a") ;; - *) - # This might be what's making HPUX 11 systems fail this test. - cat >&2 << EOF -A basic test of touch -m has just failed, so the subsequent -tests in this file will not be run. - -In the output below, the date of last modification for 'a' should -have been $t3. -EOF - ls --full -l a - framework_failure_ - ;; -esac - -# Ensure that touch's -a option works. -set -- $(ls --full -lu a) -case "$*" in - *" $u1:00.000000000 +0000 a") ;; - *) - # This might be what's making HPUX 11 systems fail this test. - cat >&2 << EOF -A fundamental touch -a test has just failed, so the subsequent -tests in this file will not be run. - -In the output below, the date of last access for 'a' should -have been $u1. -EOF - ls --full -lu a - Exit 77 - ;; -esac - -set $(ls -ut a b c) -test "$*" = 'c b a' && : || fail=1 -test $fail = 1 && ls -l --full-time --time=access a b c - -set $(ls -t a b c) -test "$*" = 'a b c' && : || fail=1 -test $fail = 1 && ls -l --full-time a b c - -# Now, C should have ctime more recent than A. -set $(ls -ct a c) -if test "$*" = 'c a'; then - : ok -else - # In spite of documentation, (e.g., stat(2)), neither link nor chmod - # update a file's st_ctime on SunOS4.1.4. - cat >&2 << \EOF -failed ls ctime test -- this failure is expected at least for SunOS4.1.4 -and for tmpfs file systems on Solaris 5.5.1. -It is also expected to fail on a btrfs file system until -http://bugzilla.redhat.com/591068 is addressed. - -In the output below, 'c' should have had a ctime more recent than -that of 'a', but does not. -EOF - #' - ls -ctl --full-time a c - fail=1 -fi - -# This check is ineffective if: -# en_US locale is not on the system. -# The system en_US message catalog has a specific TIME_FMT translation, -# which was inadvertently the case between coreutils 8.1 and 8.5 inclusive. - -if gettext --version >/dev/null 2>&1; then - - default_tf1='%b %e %Y' - en_tf1=$(LC_ALL=en_US gettext coreutils "$default_tf1") - - if test "$default_tf1" = "$en_tf1"; then - LC_ALL=en_US ls -l c >en_output - ls -l --time-style=long-iso c >liso_output - if compare en_output liso_output; then - fail=1 - echo "Long ISO TIME_FMT being used for en_US locale." >&2 - fi - fi -fi - -Exit $fail diff --git a/tests/misc/ls-time.sh b/tests/misc/ls-time.sh new file mode 100755 index 000000000..7d1f205fc --- /dev/null +++ b/tests/misc/ls-time.sh @@ -0,0 +1,145 @@ +#!/bin/sh +# Test some of ls's sorting options. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ls + +# Avoid any possible glitches due to daylight-saving changes near the +# time stamps used during the test. +TZ=UTC0 +export TZ + +t1='1998-01-15 21:00' +t2='1998-01-15 22:00' +t3='1998-01-15 23:00' + +u1='1998-01-14 11:00' +u2='1998-01-14 12:00' +u3='1998-01-14 13:00' + +touch -m -d "$t3" a || framework_failure_ +touch -m -d "$t2" b || framework_failure_ +touch -m -d "$t1" c || framework_failure_ + +touch -a -d "$u3" c || framework_failure_ +touch -a -d "$u2" b || framework_failure_ +# Make sure A has ctime at least 1 second more recent than C's. +sleep 2 +touch -a -d "$u1" a || framework_failure_ +# Updating the atime is usually enough to update the ctime, but on +# Solaris 10's tmpfs, ctime is not updated, so force an update here: +{ ln a a-ctime && rm a-ctime; } || framework_failure_ + + +# A has ctime more recent than C. +set $(ls -c a c) +test "$*" = 'a c' || fail=1 + +# Sleep so long in an attempt to avoid spurious failures +# due to NFS caching and/or clock skew. +sleep 2 + +# Create a link, updating c's ctime. +ln c d || framework_failure_ + +# Before we go any further, verify that touch's -m option works. +set -- $(ls --full -l a) +case "$*" in + *" $t3:00.000000000 +0000 a") ;; + *) + # This might be what's making HPUX 11 systems fail this test. + cat >&2 << EOF +A basic test of touch -m has just failed, so the subsequent +tests in this file will not be run. + +In the output below, the date of last modification for 'a' should +have been $t3. +EOF + ls --full -l a + framework_failure_ + ;; +esac + +# Ensure that touch's -a option works. +set -- $(ls --full -lu a) +case "$*" in + *" $u1:00.000000000 +0000 a") ;; + *) + # This might be what's making HPUX 11 systems fail this test. + cat >&2 << EOF +A fundamental touch -a test has just failed, so the subsequent +tests in this file will not be run. + +In the output below, the date of last access for 'a' should +have been $u1. +EOF + ls --full -lu a + Exit 77 + ;; +esac + +set $(ls -ut a b c) +test "$*" = 'c b a' && : || fail=1 +test $fail = 1 && ls -l --full-time --time=access a b c + +set $(ls -t a b c) +test "$*" = 'a b c' && : || fail=1 +test $fail = 1 && ls -l --full-time a b c + +# Now, C should have ctime more recent than A. +set $(ls -ct a c) +if test "$*" = 'c a'; then + : ok +else + # In spite of documentation, (e.g., stat(2)), neither link nor chmod + # update a file's st_ctime on SunOS4.1.4. + cat >&2 << \EOF +failed ls ctime test -- this failure is expected at least for SunOS4.1.4 +and for tmpfs file systems on Solaris 5.5.1. +It is also expected to fail on a btrfs file system until +http://bugzilla.redhat.com/591068 is addressed. + +In the output below, 'c' should have had a ctime more recent than +that of 'a', but does not. +EOF + #' + ls -ctl --full-time a c + fail=1 +fi + +# This check is ineffective if: +# en_US locale is not on the system. +# The system en_US message catalog has a specific TIME_FMT translation, +# which was inadvertently the case between coreutils 8.1 and 8.5 inclusive. + +if gettext --version >/dev/null 2>&1; then + + default_tf1='%b %e %Y' + en_tf1=$(LC_ALL=en_US gettext coreutils "$default_tf1") + + if test "$default_tf1" = "$en_tf1"; then + LC_ALL=en_US ls -l c >en_output + ls -l --time-style=long-iso c >liso_output + if compare en_output liso_output; then + fail=1 + echo "Long ISO TIME_FMT being used for en_US locale." >&2 + fi + fi +fi + +Exit $fail diff --git a/tests/misc/md5sum b/tests/misc/md5sum deleted file mode 100755 index 946eee865..000000000 --- a/tests/misc/md5sum +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/perl -# Basic tests for "md5sum". - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'md5sum'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $degenerate = "d41d8cd98f00b204e9800998ecf8427e"; - -my @Tests = - ( - ['1', {IN=> {f=> ''}}, {OUT=>"$degenerate f\n"}], - ['2', {IN=> {f=> 'a'}}, {OUT=>"0cc175b9c0f1b6a831c399e269772661 f\n"}], - ['3', {IN=> {f=> 'abc'}}, {OUT=>"900150983cd24fb0d6963f7d28e17f72 f\n"}], - ['4', {IN=> {f=> 'message digest'}}, - {OUT=>"f96b697d7cb7938d525a2f31aaf161d0 f\n"}], - ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, - {OUT=>"c3fcd3d76192e4007dfb496cca67e13b f\n"}], - ['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"d174ab98d277d9f5a5611c2c9f419d9f f\n"}], - ['7', {IN=> {f=> '1234567890' x 8}}, - {OUT=>"57edf4a22be3c955ac49da2e2107b67a f\n"}], - ['backslash', {IN=> {".\\foo"=> ''}}, - {OUT=>"\\$degenerate .\\\\foo\n"}], - ['check-1', '--check', {AUX=> {f=> ''}}, - {IN=> {'f.md5' => "$degenerate f\n"}}, - {OUT=>"f: OK\n"}], - - # Same as above, but with an added empty line, to provoke --strict. - ['ck-strict-1', '--check --strict', {AUX=> {f=> ''}}, - {IN=> {'f.md5' => "$degenerate f\n\n"}}, - {OUT=>"f: OK\n"}, - {ERR=>"md5sum: " - . "WARNING: 1 line is improperly formatted\n"}, - {EXIT=> 1}], - - # As above, but with the invalid line first, to ensure that following - # lines are processed in spite of the preceding invalid input line. - ['ck-strict-2', '--check --strict', {AUX=> {f=> ''}}, - {IN=> {'in.md5' => "\n$degenerate f\n"}}, - {OUT=>"f: OK\n"}, - {ERR=>"md5sum: " - . "WARNING: 1 line is improperly formatted\n"}, - {EXIT=> 1}], - ['check-2', '--check', '--status', {IN=>{'f.md5' => "$degenerate f\n"}}, - {AUX=> {f=> 'foo'}}, {EXIT=> 1}], - ['check-quiet1', '--check', '--quiet', {AUX=> {f=> ''}}, - {IN=> {'f.md5' => "$degenerate f\n"}}, - {OUT=>""}], - ['check-quiet2', '--check', '--quiet', - {IN=>{'f.md5' => "$degenerate f\n"}}, - {AUX=> {f=> 'foo'}}, {OUT=>"f: FAILED\n"}, - {ERR=>"md5sum: WARNING: 1 computed" - . " checksum did NOT match\n"}, - {EXIT=> 1}], - # Exercise new-after-8.6, easier-to-translate diagnostics. - ['check-multifail', '--check', - {IN=>{'f.md5' => - "$degenerate f\n" - . "$degenerate f\n" - . "invalid\n" }}, - {AUX=> {f=> 'foo'}}, - {OUT=>"f: FAILED\nf: FAILED\n"}, - {ERR=>"md5sum: WARNING: 1 line is improperly formatted\n" - . "md5sum: WARNING: 2 computed checksums did NOT match\n"}, - {EXIT=> 1}], - # Similar to the above, but use --warn to evoke one more diagnostic. - ['check-multifail-warn', '--check', '--warn', - {IN=>{'f.md5' => - "$degenerate f\n" - . "$degenerate f\n" - . "invalid\n" }}, - {AUX=> {f=> 'foo'}}, - {OUT=>"f: FAILED\nf: FAILED\n"}, - {ERR=>"md5sum: f.md5: 3: improperly formatted MD5 checksum line\n" - . "md5sum: WARNING: 1 line is improperly formatted\n" - . "md5sum: WARNING: 2 computed checksums did NOT match\n"}, - {EXIT=> 1}], - # The sha1sum and md5sum drivers share a lot of code. - # Ensure that md5sum does *not* share the part that makes - # sha1sum accept BSD format. - ['check-bsd', '--check', {IN=> {'f.sha1' => "SHA1 (f) = $degenerate\n"}}, - {AUX=> {f=> ''}}, - {ERR=>"md5sum: f.sha1: no properly formatted " - . "MD5 checksum lines found\n"}, - {EXIT=> 1}], - ['check-bsd2', '--check', {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, - {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], - ['check-bsd3', '--check', '--status', - {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, - {AUX=> {f=> 'bar'}}, {EXIT=> 1}], - ['check-openssl', '--check', {IN=> {'f.sha1' => "SHA1(f)= $degenerate\n"}}, - {AUX=> {f=> ''}}, - {ERR=>"md5sum: f.sha1: no properly formatted " - . "MD5 checksum lines found\n"}, - {EXIT=> 1}], - ['check-openssl2', '--check', {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}}, - {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], - ['check-openssl3', '--check', '--status', - {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}}, - {AUX=> {f=> 'bar'}}, {EXIT=> 1}], - ['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1}, - {ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}], - - # Ensure that when there's a NUL byte among the checksum hex digits - # we detect the invalid formatting and don't even open the file. - # Up to coreutils-6.10, this would report: - # h: FAILED - # md5sum: WARNING: 1 of 1 computed checksum did NOT match - ['nul-in-cksum', '--check', {IN=> {'h'=>("\0"x32)." h\n"}}, {EXIT=> 1}, - {ERR=> "$prog: h: no properly formatted MD5 checksum lines found\n"}], - ); - -# Insert the '--text' argument for each test. -my $t; -foreach $t (@Tests) - { - splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/md5sum-bsd b/tests/misc/md5sum-bsd deleted file mode 100755 index ce4117679..000000000 --- a/tests/misc/md5sum-bsd +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh -# 'md5sum' tests for generation and checking of -# BSD traditional and alternate formats (md5 [-r]) - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ md5sum - -## BSD alternate format tests ## - -# Ensure we can --check BSD alternate format. -# Note we start this list with a name -# that's unambiguous in BSD format. -# I.E. one not starting with ' ' or '*' -for i in 'a' ' b' '*c' 'dd' ' '; do - echo "$i" > "$i" - md5sum "$i" >> check.md5sum -done -sed 's/ / /' check.md5sum > check.md5 - -# Note only a single format is supported per run -md5sum --strict -c check.md5sum || fail=1 -md5sum --strict -c check.md5 || fail=1 - -# If we skip the first entry in the BSD format checksums -# then it'll be detected as standard format and error. -# This unlikely caveat was thought better than mandating -# an option to avoid the ambiguity. -tail -n+2 check.md5 | md5sum --strict -c && fail=1 - - -## BSD traditional format tests (--tag option) ## - -# Ensure --tag and --check are mutually exclusive -md5sum --tag --check /dev/null && fail=1 - -# Ensure --tag and --text are mutually exclusive -# We don't support --text with BSD tradition format, -# as that would complicate the output format, -# while providing little benefit over --text processing -# available with the default md5sum output format. -md5sum --tag --text /dev/null && fail=1 - -# Ensure we can --check BSD traditional format we produce -rm check.md5 -for i in 'a' ' b' '*c' 'dd' ' '; do - echo "$i" > "$i" - md5sum --tag "$i" >> check.md5 -done -md5sum --strict -c check.md5 || fail=1 - -# Ensure we can --check BSD traditional format we produce -# with the GNU extension of escaped newlines -nl=' -' -tab=' ' -rm check.md5 -for i in 'a\b' 'a\' "a${nl}b" "a${tab}b"; do - :> "$i" - md5sum --tag "$i" >> check.md5 -done -md5sum --strict -c check.md5 || fail=1 - -# Ensure BSD traditional format with GNU extension escapes -# is in the expected format -ex_file='test -\\file' -ex_output='\MD5 (test\n\\\\file) = d41d8cd98f00b204e9800998ecf8427e' -touch "$ex_file" -printf "%s\n" "$ex_output" > exp -md5sum --tag "$ex_file" > out -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/md5sum-bsd.sh b/tests/misc/md5sum-bsd.sh new file mode 100755 index 000000000..ce4117679 --- /dev/null +++ b/tests/misc/md5sum-bsd.sh @@ -0,0 +1,88 @@ +#!/bin/sh +# 'md5sum' tests for generation and checking of +# BSD traditional and alternate formats (md5 [-r]) + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ md5sum + +## BSD alternate format tests ## + +# Ensure we can --check BSD alternate format. +# Note we start this list with a name +# that's unambiguous in BSD format. +# I.E. one not starting with ' ' or '*' +for i in 'a' ' b' '*c' 'dd' ' '; do + echo "$i" > "$i" + md5sum "$i" >> check.md5sum +done +sed 's/ / /' check.md5sum > check.md5 + +# Note only a single format is supported per run +md5sum --strict -c check.md5sum || fail=1 +md5sum --strict -c check.md5 || fail=1 + +# If we skip the first entry in the BSD format checksums +# then it'll be detected as standard format and error. +# This unlikely caveat was thought better than mandating +# an option to avoid the ambiguity. +tail -n+2 check.md5 | md5sum --strict -c && fail=1 + + +## BSD traditional format tests (--tag option) ## + +# Ensure --tag and --check are mutually exclusive +md5sum --tag --check /dev/null && fail=1 + +# Ensure --tag and --text are mutually exclusive +# We don't support --text with BSD tradition format, +# as that would complicate the output format, +# while providing little benefit over --text processing +# available with the default md5sum output format. +md5sum --tag --text /dev/null && fail=1 + +# Ensure we can --check BSD traditional format we produce +rm check.md5 +for i in 'a' ' b' '*c' 'dd' ' '; do + echo "$i" > "$i" + md5sum --tag "$i" >> check.md5 +done +md5sum --strict -c check.md5 || fail=1 + +# Ensure we can --check BSD traditional format we produce +# with the GNU extension of escaped newlines +nl=' +' +tab=' ' +rm check.md5 +for i in 'a\b' 'a\' "a${nl}b" "a${tab}b"; do + :> "$i" + md5sum --tag "$i" >> check.md5 +done +md5sum --strict -c check.md5 || fail=1 + +# Ensure BSD traditional format with GNU extension escapes +# is in the expected format +ex_file='test +\\file' +ex_output='\MD5 (test\n\\\\file) = d41d8cd98f00b204e9800998ecf8427e' +touch "$ex_file" +printf "%s\n" "$ex_output" > exp +md5sum --tag "$ex_file" > out +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/md5sum-newline b/tests/misc/md5sum-newline deleted file mode 100755 index 777241ff8..000000000 --- a/tests/misc/md5sum-newline +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/perl -# Newline tests for "md5sum". - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $ME = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# See if we can create a file name that contains a newline. -# Use system, since Perl doesn't let you do this with "open". -system ('touch', "a\nb") == 0 - or CuSkip::skip "$ME: failed to create newline-containing file name\n"; - -my $degenerate = "d41d8cd98f00b204e9800998ecf8427e"; -my $t = '--text'; - -my @Tests = - ( - ['newline', $t, {IN=> {"a\nb"=> ''}}, {OUT=>"\\$degenerate a\\nb\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'md5sum'; -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/md5sum-newline.pl b/tests/misc/md5sum-newline.pl new file mode 100755 index 000000000..777241ff8 --- /dev/null +++ b/tests/misc/md5sum-newline.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +# Newline tests for "md5sum". + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $ME = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# See if we can create a file name that contains a newline. +# Use system, since Perl doesn't let you do this with "open". +system ('touch', "a\nb") == 0 + or CuSkip::skip "$ME: failed to create newline-containing file name\n"; + +my $degenerate = "d41d8cd98f00b204e9800998ecf8427e"; +my $t = '--text'; + +my @Tests = + ( + ['newline', $t, {IN=> {"a\nb"=> ''}}, {OUT=>"\\$degenerate a\\nb\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'md5sum'; +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/md5sum-parallel b/tests/misc/md5sum-parallel deleted file mode 100755 index 0bf5fa9ca..000000000 --- a/tests/misc/md5sum-parallel +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Ensure that md5sum prints each checksum atomically -# so that concurrent md5sums don't intersperse their output - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ md5sum - -(mkdir tmp && cd tmp && seq 500 | xargs touch) - -# This will output at least 16KiB per process -# and start 3 processes, with 2 running concurrently, -# which triggers often on Fedora 11 at least. -(find tmp tmp tmp -type f | xargs -n500 -P2 md5sum) | -sed -n '/[0-9a-f]\{32\} /!p' | -grep . > /dev/null && fail=1 - -Exit $fail diff --git a/tests/misc/md5sum-parallel.sh b/tests/misc/md5sum-parallel.sh new file mode 100755 index 000000000..0bf5fa9ca --- /dev/null +++ b/tests/misc/md5sum-parallel.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Ensure that md5sum prints each checksum atomically +# so that concurrent md5sums don't intersperse their output + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ md5sum + +(mkdir tmp && cd tmp && seq 500 | xargs touch) + +# This will output at least 16KiB per process +# and start 3 processes, with 2 running concurrently, +# which triggers often on Fedora 11 at least. +(find tmp tmp tmp -type f | xargs -n500 -P2 md5sum) | +sed -n '/[0-9a-f]\{32\} /!p' | +grep . > /dev/null && fail=1 + +Exit $fail diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl new file mode 100755 index 000000000..946eee865 --- /dev/null +++ b/tests/misc/md5sum.pl @@ -0,0 +1,143 @@ +#!/usr/bin/perl +# Basic tests for "md5sum". + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'md5sum'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $degenerate = "d41d8cd98f00b204e9800998ecf8427e"; + +my @Tests = + ( + ['1', {IN=> {f=> ''}}, {OUT=>"$degenerate f\n"}], + ['2', {IN=> {f=> 'a'}}, {OUT=>"0cc175b9c0f1b6a831c399e269772661 f\n"}], + ['3', {IN=> {f=> 'abc'}}, {OUT=>"900150983cd24fb0d6963f7d28e17f72 f\n"}], + ['4', {IN=> {f=> 'message digest'}}, + {OUT=>"f96b697d7cb7938d525a2f31aaf161d0 f\n"}], + ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, + {OUT=>"c3fcd3d76192e4007dfb496cca67e13b f\n"}], + ['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, + {OUT=>"d174ab98d277d9f5a5611c2c9f419d9f f\n"}], + ['7', {IN=> {f=> '1234567890' x 8}}, + {OUT=>"57edf4a22be3c955ac49da2e2107b67a f\n"}], + ['backslash', {IN=> {".\\foo"=> ''}}, + {OUT=>"\\$degenerate .\\\\foo\n"}], + ['check-1', '--check', {AUX=> {f=> ''}}, + {IN=> {'f.md5' => "$degenerate f\n"}}, + {OUT=>"f: OK\n"}], + + # Same as above, but with an added empty line, to provoke --strict. + ['ck-strict-1', '--check --strict', {AUX=> {f=> ''}}, + {IN=> {'f.md5' => "$degenerate f\n\n"}}, + {OUT=>"f: OK\n"}, + {ERR=>"md5sum: " + . "WARNING: 1 line is improperly formatted\n"}, + {EXIT=> 1}], + + # As above, but with the invalid line first, to ensure that following + # lines are processed in spite of the preceding invalid input line. + ['ck-strict-2', '--check --strict', {AUX=> {f=> ''}}, + {IN=> {'in.md5' => "\n$degenerate f\n"}}, + {OUT=>"f: OK\n"}, + {ERR=>"md5sum: " + . "WARNING: 1 line is improperly formatted\n"}, + {EXIT=> 1}], + ['check-2', '--check', '--status', {IN=>{'f.md5' => "$degenerate f\n"}}, + {AUX=> {f=> 'foo'}}, {EXIT=> 1}], + ['check-quiet1', '--check', '--quiet', {AUX=> {f=> ''}}, + {IN=> {'f.md5' => "$degenerate f\n"}}, + {OUT=>""}], + ['check-quiet2', '--check', '--quiet', + {IN=>{'f.md5' => "$degenerate f\n"}}, + {AUX=> {f=> 'foo'}}, {OUT=>"f: FAILED\n"}, + {ERR=>"md5sum: WARNING: 1 computed" + . " checksum did NOT match\n"}, + {EXIT=> 1}], + # Exercise new-after-8.6, easier-to-translate diagnostics. + ['check-multifail', '--check', + {IN=>{'f.md5' => + "$degenerate f\n" + . "$degenerate f\n" + . "invalid\n" }}, + {AUX=> {f=> 'foo'}}, + {OUT=>"f: FAILED\nf: FAILED\n"}, + {ERR=>"md5sum: WARNING: 1 line is improperly formatted\n" + . "md5sum: WARNING: 2 computed checksums did NOT match\n"}, + {EXIT=> 1}], + # Similar to the above, but use --warn to evoke one more diagnostic. + ['check-multifail-warn', '--check', '--warn', + {IN=>{'f.md5' => + "$degenerate f\n" + . "$degenerate f\n" + . "invalid\n" }}, + {AUX=> {f=> 'foo'}}, + {OUT=>"f: FAILED\nf: FAILED\n"}, + {ERR=>"md5sum: f.md5: 3: improperly formatted MD5 checksum line\n" + . "md5sum: WARNING: 1 line is improperly formatted\n" + . "md5sum: WARNING: 2 computed checksums did NOT match\n"}, + {EXIT=> 1}], + # The sha1sum and md5sum drivers share a lot of code. + # Ensure that md5sum does *not* share the part that makes + # sha1sum accept BSD format. + ['check-bsd', '--check', {IN=> {'f.sha1' => "SHA1 (f) = $degenerate\n"}}, + {AUX=> {f=> ''}}, + {ERR=>"md5sum: f.sha1: no properly formatted " + . "MD5 checksum lines found\n"}, + {EXIT=> 1}], + ['check-bsd2', '--check', {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, + {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], + ['check-bsd3', '--check', '--status', + {IN=> {'f.md5' => "MD5 (f) = $degenerate\n"}}, + {AUX=> {f=> 'bar'}}, {EXIT=> 1}], + ['check-openssl', '--check', {IN=> {'f.sha1' => "SHA1(f)= $degenerate\n"}}, + {AUX=> {f=> ''}}, + {ERR=>"md5sum: f.sha1: no properly formatted " + . "MD5 checksum lines found\n"}, + {EXIT=> 1}], + ['check-openssl2', '--check', {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}}, + {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], + ['check-openssl3', '--check', '--status', + {IN=> {'f.md5' => "MD5(f)= $degenerate\n"}}, + {AUX=> {f=> 'bar'}}, {EXIT=> 1}], + ['bsd-segv', '--check', {IN=> {'z' => "MD5 ("}}, {EXIT=> 1}, + {ERR=> "$prog: z: no properly formatted MD5 checksum lines found\n"}], + + # Ensure that when there's a NUL byte among the checksum hex digits + # we detect the invalid formatting and don't even open the file. + # Up to coreutils-6.10, this would report: + # h: FAILED + # md5sum: WARNING: 1 of 1 computed checksum did NOT match + ['nul-in-cksum', '--check', {IN=> {'h'=>("\0"x32)." h\n"}}, {EXIT=> 1}, + {ERR=> "$prog: h: no properly formatted MD5 checksum lines found\n"}], + ); + +# Insert the '--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/mknod b/tests/misc/mknod deleted file mode 100755 index b9e33ad2d..000000000 --- a/tests/misc/mknod +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Ensure that mknod, mkfifo, mkdir -m MODE work with a restrictive umask - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mknod - -# Ensure fifos are supported -mkfifo_or_skip_ fifo - -umask 777 - -mknod -m 734 f1 p || fail=1 -mode=$(ls -dgo f1|cut -b-10) -test $mode = prwx-wxr-- || fail=1 - -mkfifo -m 734 f2 || fail=1 -mode=$(ls -dgo f2|cut -b-10) -test $mode = prwx-wxr-- || fail=1 - -mkdir -m 734 f3 || fail=1 -mode=$(ls -dgo f3|cut -b-10) -test $mode = drwx-wxr-- || test $mode = drwx-wsr-- || fail=1 - -Exit $fail diff --git a/tests/misc/mknod.sh b/tests/misc/mknod.sh new file mode 100755 index 000000000..b9e33ad2d --- /dev/null +++ b/tests/misc/mknod.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Ensure that mknod, mkfifo, mkdir -m MODE work with a restrictive umask + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mknod + +# Ensure fifos are supported +mkfifo_or_skip_ fifo + +umask 777 + +mknod -m 734 f1 p || fail=1 +mode=$(ls -dgo f1|cut -b-10) +test $mode = prwx-wxr-- || fail=1 + +mkfifo -m 734 f2 || fail=1 +mode=$(ls -dgo f2|cut -b-10) +test $mode = prwx-wxr-- || fail=1 + +mkdir -m 734 f3 || fail=1 +mode=$(ls -dgo f3|cut -b-10) +test $mode = drwx-wxr-- || test $mode = drwx-wsr-- || fail=1 + +Exit $fail diff --git a/tests/misc/mktemp b/tests/misc/mktemp deleted file mode 100755 index 49dfde494..000000000 --- a/tests/misc/mktemp +++ /dev/null @@ -1,204 +0,0 @@ -#!/usr/bin/perl -# Test "mktemp". - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $ME = $0) =~ s|.*/||; - -sub check_tmp($$) -{ - my ($file, $file_or_dir) = @_; - - my (undef, undef, $mode, undef) = stat $file - or die "$ME: failed to stat $file: $!\n"; - my $required_mode; - if ($file_or_dir eq 'D') { - -d $file or die "$ME: $file isn't a directory\n"; - -x $file or die "$ME: $file isn't owner-searchable\n"; - $required_mode = 0700; - } elsif ($file_or_dir eq 'F') { - -f $file or die "$ME: $file isn't a regular file\n"; - $required_mode = 0600; - } - -r $file or die "$ME: $file isn't owner-readable\n"; - -w $file or die "$ME: $file isn't owner-writable\n"; - ($mode & 0777) == $required_mode - or die "$ME: $file doesn't have required permissions\n"; - - $file_or_dir eq 'D' - and do { rmdir $file or die "$ME: failed to rmdir $file: $!\n" }; - $file_or_dir eq 'F' - and do { unlink $file or die "$ME: failed to unlink $file: $!\n" }; -} - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; -my $prog = 'mktemp'; -my $bad_dir = 'no/such/dir'; - -my @Tests = - ( - # test-name, [option, option, ...] {OUT=>"expected-output"} - # - ['too-many', 'a b', - {ERR=>"$prog: too many templates\n" - . "Try '$prog --help' for more information.\n"}, {EXIT => 1} ], - ['too-many-q', '-q a b', {EXIT => 1} ], - - ['too-few-x', 'foo.XX', {EXIT => 1}, - {ERR=>"$prog: too few X's in template 'foo.XX'\n"}], - ['too-few-xq', '-q foo.XX', {EXIT => 1} ], - - ['1f', 'bar.XXXX', {OUT => "bar.ZZZZ\n"}, - {OUT_SUBST => 's,\.....$,.ZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }} - ], - - ['2f', '-- -XXXX', {OUT => "-ZZZZ\n"}, - {OUT_SUBST => 's,-....$,-ZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }} - ], - - # Create a temporary directory. - ['1d', '-d f.XXXX', {OUT => "f.ZZZZ\n"}, - {OUT_SUBST => 's,\.....$,.ZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'D'; }} - ], - - # Use a template consisting solely of X's - ['1d-allX', '-d XXXX', {OUT => "ZZZZ\n"}, - {PRE => sub {mkdir 'XXXX',0755 or die "XXXX: $!\n"}}, - {OUT_SUBST => 's,^....$,ZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'D'; rmdir 'XXXX' or die "rmdir XXXX: $!\n"; }} - ], - - # Test -u - ['uf', '-u f.XXXX', {OUT => "f.ZZZZ\n"}, - {OUT_SUBST => 's,\.....$,.ZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - -e $f and die "dry-run created file"; }}], - ['ud', '-d --dry-run d.XXXX', {OUT => "d.ZZZZ\n"}, - {OUT_SUBST => 's,\.....$,.ZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - -e $f and die "dry-run created directory"; }}], - - # Test bad templates - ['invalid-tl', '-t a/bXXXX', - {ERR=>"$prog: invalid template, 'a/bXXXX', " - . "contains directory separator\n"}, {EXIT => 1} ], - - ['invalid-t2', '--tmpdir=a /bXXXX', - {ERR=>"$prog: invalid template, '/bXXXX'; " - . "with --tmpdir, it may not be absolute\n"}, {EXIT => 1} ], - - # Suffix after X. - ['suffix1f', 'aXXXXb', {OUT=>"aZZZZb\n"}, - {OUT_SUBST=>'s,a....b,aZZZZb,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }}], - ['suffix1d', '-d aXXXXb', {OUT=>"aZZZZb\n"}, - {OUT_SUBST=>'s,a....b,aZZZZb,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'D'; }}], - ['suffix1u', '-u aXXXXb', {OUT=>"aZZZZb\n"}, - {OUT_SUBST=>'s,a....b,aZZZZb,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - -e $f and die "dry-run created file"; }}], - - ['suffix2f', 'aXXXXaaXXXXa', {OUT=>"aXXXXaaZZZZa\n"}, - {OUT_SUBST=>'s,a....a$,aZZZZa,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }}], - ['suffix2d', '-d --suffix= aXXXXaaXXXX', {OUT=>"aXXXXaaZZZZ\n"}, - {OUT_SUBST=>'s,a....$,aZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'D'; }}], - - ['suffix3f', '--suffix=b aXXXX', {OUT=>"aZZZZb\n"}, - {OUT_SUBST=>'s,a....b,aZZZZb,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }}], - - ['suffix4f', '--suffix=X aXXXX', {OUT=>"aZZZZX\n"}, - {OUT_SUBST=>'s,^a....,aZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }}], - - ['suffix5f', '--suffix /b aXXXX', {EXIT=>1}, - {ERR=>"$prog: invalid suffix '/b', contains directory separator\n"}], - - ['suffix6f', 'aXXXX/b', {EXIT=>1}, - {ERR=>"$prog: invalid suffix '/b', contains directory separator\n"}], - ['suffix6f-q', '-q aXXXX/b', {EXIT=>1}], - - ['suffix7f', '--suffix= aXXXXb', {EXIT=>1}, - {ERR=>"$prog: with --suffix, template 'aXXXXb' must end in X\n"}], - ['suffix7f-q', '-q --suffix= aXXXXb', {EXIT=>1}], - ['suffix7d', '-d --suffix=aXXXXb ""', {EXIT=>1}, - {ERR=>"$prog: with --suffix, template '' must end in X\n"}], - - ['suffix8f', 'aXXXX --suffix=b', {OUT=>"aZZZZb\n"}, - {OUT_SUBST=>'s,^a....,aZZZZ,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }}], - - ['suffix9f', 'aXXXX --suffix=b', {EXIT=>1}, - {ENV=>"POSIXLY_CORRECT=1"}, - {ERR=>"$prog: too many templates\n" - . "Try '$prog --help' for more information.\n"}], - - ['suffix10f', 'aXXb', {EXIT => 1}, - {ERR=>"$prog: too few X's in template 'aXXb'\n"}], - ['suffix10d', '-d --suffix=X aXX', {EXIT => 1}, - {ERR=>"$prog: too few X's in template 'aXXX'\n"}], - - ['suffix11f', '--suffix=.txt', {OUT=>"./tmp.ZZZZZZZZZZ.txt\n"}, - {ENV=>"TMPDIR=."}, - {OUT_SUBST=>'s,\..{10}\.,.ZZZZZZZZZZ.,'}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; }}], - - - # Test template with subdirectory - ['tmp-w-slash', '--tmpdir=. a/bXXXX', - {PRE => sub {mkdir 'a',0755 or die "a: $!\n"}}, - {OUT_SUBST => 's,b....$,bZZZZ,'}, - {OUT => "./a/bZZZZ\n"}, - {POST => sub { my ($f) = @_; defined $f or return; chomp $f; - check_tmp $f, 'F'; unlink $f; rmdir 'a' or die "rmdir a: $!\n" }} - ], - - ['pipe-bad-tmpdir', - {ENV => "TMPDIR=$bad_dir"}, - {ERR_SUBST => "s,($bad_dir/)[^']+': .*,\$1...,"}, - {ERR => "$prog: failed to create file via template '$bad_dir/...\n"}, - {EXIT => 1}], - ['pipe-bad-tmpdir-u', '-u', {OUT => "$bad_dir/tmp.ZZZZZZZZZZ\n"}, - {ENV => "TMPDIR=$bad_dir"}, - {OUT_SUBST => 's,\..{10}$,.ZZZZZZZZZZ,'}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/mktemp.pl b/tests/misc/mktemp.pl new file mode 100755 index 000000000..49dfde494 --- /dev/null +++ b/tests/misc/mktemp.pl @@ -0,0 +1,204 @@ +#!/usr/bin/perl +# Test "mktemp". + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $ME = $0) =~ s|.*/||; + +sub check_tmp($$) +{ + my ($file, $file_or_dir) = @_; + + my (undef, undef, $mode, undef) = stat $file + or die "$ME: failed to stat $file: $!\n"; + my $required_mode; + if ($file_or_dir eq 'D') { + -d $file or die "$ME: $file isn't a directory\n"; + -x $file or die "$ME: $file isn't owner-searchable\n"; + $required_mode = 0700; + } elsif ($file_or_dir eq 'F') { + -f $file or die "$ME: $file isn't a regular file\n"; + $required_mode = 0600; + } + -r $file or die "$ME: $file isn't owner-readable\n"; + -w $file or die "$ME: $file isn't owner-writable\n"; + ($mode & 0777) == $required_mode + or die "$ME: $file doesn't have required permissions\n"; + + $file_or_dir eq 'D' + and do { rmdir $file or die "$ME: failed to rmdir $file: $!\n" }; + $file_or_dir eq 'F' + and do { unlink $file or die "$ME: failed to unlink $file: $!\n" }; +} + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; +my $prog = 'mktemp'; +my $bad_dir = 'no/such/dir'; + +my @Tests = + ( + # test-name, [option, option, ...] {OUT=>"expected-output"} + # + ['too-many', 'a b', + {ERR=>"$prog: too many templates\n" + . "Try '$prog --help' for more information.\n"}, {EXIT => 1} ], + ['too-many-q', '-q a b', {EXIT => 1} ], + + ['too-few-x', 'foo.XX', {EXIT => 1}, + {ERR=>"$prog: too few X's in template 'foo.XX'\n"}], + ['too-few-xq', '-q foo.XX', {EXIT => 1} ], + + ['1f', 'bar.XXXX', {OUT => "bar.ZZZZ\n"}, + {OUT_SUBST => 's,\.....$,.ZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }} + ], + + ['2f', '-- -XXXX', {OUT => "-ZZZZ\n"}, + {OUT_SUBST => 's,-....$,-ZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }} + ], + + # Create a temporary directory. + ['1d', '-d f.XXXX', {OUT => "f.ZZZZ\n"}, + {OUT_SUBST => 's,\.....$,.ZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'D'; }} + ], + + # Use a template consisting solely of X's + ['1d-allX', '-d XXXX', {OUT => "ZZZZ\n"}, + {PRE => sub {mkdir 'XXXX',0755 or die "XXXX: $!\n"}}, + {OUT_SUBST => 's,^....$,ZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'D'; rmdir 'XXXX' or die "rmdir XXXX: $!\n"; }} + ], + + # Test -u + ['uf', '-u f.XXXX', {OUT => "f.ZZZZ\n"}, + {OUT_SUBST => 's,\.....$,.ZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + -e $f and die "dry-run created file"; }}], + ['ud', '-d --dry-run d.XXXX', {OUT => "d.ZZZZ\n"}, + {OUT_SUBST => 's,\.....$,.ZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + -e $f and die "dry-run created directory"; }}], + + # Test bad templates + ['invalid-tl', '-t a/bXXXX', + {ERR=>"$prog: invalid template, 'a/bXXXX', " + . "contains directory separator\n"}, {EXIT => 1} ], + + ['invalid-t2', '--tmpdir=a /bXXXX', + {ERR=>"$prog: invalid template, '/bXXXX'; " + . "with --tmpdir, it may not be absolute\n"}, {EXIT => 1} ], + + # Suffix after X. + ['suffix1f', 'aXXXXb', {OUT=>"aZZZZb\n"}, + {OUT_SUBST=>'s,a....b,aZZZZb,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }}], + ['suffix1d', '-d aXXXXb', {OUT=>"aZZZZb\n"}, + {OUT_SUBST=>'s,a....b,aZZZZb,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'D'; }}], + ['suffix1u', '-u aXXXXb', {OUT=>"aZZZZb\n"}, + {OUT_SUBST=>'s,a....b,aZZZZb,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + -e $f and die "dry-run created file"; }}], + + ['suffix2f', 'aXXXXaaXXXXa', {OUT=>"aXXXXaaZZZZa\n"}, + {OUT_SUBST=>'s,a....a$,aZZZZa,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }}], + ['suffix2d', '-d --suffix= aXXXXaaXXXX', {OUT=>"aXXXXaaZZZZ\n"}, + {OUT_SUBST=>'s,a....$,aZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'D'; }}], + + ['suffix3f', '--suffix=b aXXXX', {OUT=>"aZZZZb\n"}, + {OUT_SUBST=>'s,a....b,aZZZZb,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }}], + + ['suffix4f', '--suffix=X aXXXX', {OUT=>"aZZZZX\n"}, + {OUT_SUBST=>'s,^a....,aZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }}], + + ['suffix5f', '--suffix /b aXXXX', {EXIT=>1}, + {ERR=>"$prog: invalid suffix '/b', contains directory separator\n"}], + + ['suffix6f', 'aXXXX/b', {EXIT=>1}, + {ERR=>"$prog: invalid suffix '/b', contains directory separator\n"}], + ['suffix6f-q', '-q aXXXX/b', {EXIT=>1}], + + ['suffix7f', '--suffix= aXXXXb', {EXIT=>1}, + {ERR=>"$prog: with --suffix, template 'aXXXXb' must end in X\n"}], + ['suffix7f-q', '-q --suffix= aXXXXb', {EXIT=>1}], + ['suffix7d', '-d --suffix=aXXXXb ""', {EXIT=>1}, + {ERR=>"$prog: with --suffix, template '' must end in X\n"}], + + ['suffix8f', 'aXXXX --suffix=b', {OUT=>"aZZZZb\n"}, + {OUT_SUBST=>'s,^a....,aZZZZ,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }}], + + ['suffix9f', 'aXXXX --suffix=b', {EXIT=>1}, + {ENV=>"POSIXLY_CORRECT=1"}, + {ERR=>"$prog: too many templates\n" + . "Try '$prog --help' for more information.\n"}], + + ['suffix10f', 'aXXb', {EXIT => 1}, + {ERR=>"$prog: too few X's in template 'aXXb'\n"}], + ['suffix10d', '-d --suffix=X aXX', {EXIT => 1}, + {ERR=>"$prog: too few X's in template 'aXXX'\n"}], + + ['suffix11f', '--suffix=.txt', {OUT=>"./tmp.ZZZZZZZZZZ.txt\n"}, + {ENV=>"TMPDIR=."}, + {OUT_SUBST=>'s,\..{10}\.,.ZZZZZZZZZZ.,'}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; }}], + + + # Test template with subdirectory + ['tmp-w-slash', '--tmpdir=. a/bXXXX', + {PRE => sub {mkdir 'a',0755 or die "a: $!\n"}}, + {OUT_SUBST => 's,b....$,bZZZZ,'}, + {OUT => "./a/bZZZZ\n"}, + {POST => sub { my ($f) = @_; defined $f or return; chomp $f; + check_tmp $f, 'F'; unlink $f; rmdir 'a' or die "rmdir a: $!\n" }} + ], + + ['pipe-bad-tmpdir', + {ENV => "TMPDIR=$bad_dir"}, + {ERR_SUBST => "s,($bad_dir/)[^']+': .*,\$1...,"}, + {ERR => "$prog: failed to create file via template '$bad_dir/...\n"}, + {EXIT => 1}], + ['pipe-bad-tmpdir-u', '-u', {OUT => "$bad_dir/tmp.ZZZZZZZZZZ\n"}, + {ENV => "TMPDIR=$bad_dir"}, + {OUT_SUBST => 's,\..{10}$,.ZZZZZZZZZZ,'}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/nice b/tests/misc/nice deleted file mode 100755 index ac8ea04ea..000000000 --- a/tests/misc/nice +++ /dev/null @@ -1,94 +0,0 @@ -#! /bin/sh -# Test "nice". - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ nice - -tests=' -0 empty 10 -1 -1 1 -2 -12 12 -3 -1:-2 2 -4 -n:1 1 -5 -n:1:-2 2 -6 -n:1:-+12 12 -7 -2:-n:1 1 -8 -2:-n:12 12 -9 -+1 1 -10 -+12 12 -11 -+1:-+12 12 -12 -n:+1 1 -13 --1:-2 2 -14 --1:-2:-13 13 -15 --1:-n:2 2 -16 --1:-n:2:-3 3 -17 --1:-n:2:-13 13 -18 -n:-1:-12 12 -19 --1:-12 12 -NA LAST NA -' -set $tests - -# Require that this test be run at 'nice' level 0. -niceness=$(nice) -if test "$niceness" = 0; then - : ok -else - skip_ "this test must be run at nice level 0" -fi - -while :; do - test_name=$1 - args=$2 - expected_result=$3 - test $args = empty && args='' - test x$args = xLAST && break - args=$(echo x$args|tr : ' '|sed 's/^x//') - if test "$VERBOSE" = yes; then - #echo "testing \$(nice $args nice\) = $expected_result ..." - echo "test $test_name... " | tr -d '\n' - fi - test x$(nice $args nice 2> /dev/null) = x$expected_result \ - && ok=ok || ok=FAIL fail=1 - test "$VERBOSE" = yes && echo $ok - shift; shift; shift -done - -# Test negative niceness - command must be run whether or not change happens. -if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then - # unprivileged user - warn about failure to change - nice -n -1 true 2> err || fail=1 - test -s err || fail=1 - mv err exp || framework_failure_ - nice --1 true 2> err || fail=1 - compare exp err || fail=1 - # Failure to write advisory message is fatal. Buggy through coreutils 8.0. - if test -w /dev/full && test -c /dev/full; then - nice -n -1 nice > out 2> /dev/full - test $? = 125 || fail=1 - test -s out && fail=1 - fi -else - # superuser - change succeeds - nice -n -1 nice 2> err || fail=1 - test -s err && fail=1 - test x$(nice -n -1 nice) = x-1 || fail=1 - test x$(nice --1 nice) = x-1 || fail=1 -fi - -Exit $fail diff --git a/tests/misc/nice-fail b/tests/misc/nice-fail deleted file mode 100755 index 599c981f2..000000000 --- a/tests/misc/nice-fail +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Verify that internal failure in nice gives exact status. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ nice - - -# These tests verify exact status of internal failure. -nice -n 1 # missing command -test $? = 125 || fail=1 -nice --- # unknown option -test $? = 125 || fail=1 -nice -n 1a # invalid adjustment -test $? = 125 || fail=1 -nice sh -c 'exit 2' # exit status propagation -test $? = 2 || fail=2 -nice . # invalid command -test $? = 126 || fail=1 -nice no_such # no such command -test $? = 127 || fail=1 - -Exit $fail diff --git a/tests/misc/nice-fail.sh b/tests/misc/nice-fail.sh new file mode 100755 index 000000000..599c981f2 --- /dev/null +++ b/tests/misc/nice-fail.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Verify that internal failure in nice gives exact status. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ nice + + +# These tests verify exact status of internal failure. +nice -n 1 # missing command +test $? = 125 || fail=1 +nice --- # unknown option +test $? = 125 || fail=1 +nice -n 1a # invalid adjustment +test $? = 125 || fail=1 +nice sh -c 'exit 2' # exit status propagation +test $? = 2 || fail=2 +nice . # invalid command +test $? = 126 || fail=1 +nice no_such # no such command +test $? = 127 || fail=1 + +Exit $fail diff --git a/tests/misc/nice.sh b/tests/misc/nice.sh new file mode 100755 index 000000000..ac8ea04ea --- /dev/null +++ b/tests/misc/nice.sh @@ -0,0 +1,94 @@ +#! /bin/sh +# Test "nice". + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ nice + +tests=' +0 empty 10 +1 -1 1 +2 -12 12 +3 -1:-2 2 +4 -n:1 1 +5 -n:1:-2 2 +6 -n:1:-+12 12 +7 -2:-n:1 1 +8 -2:-n:12 12 +9 -+1 1 +10 -+12 12 +11 -+1:-+12 12 +12 -n:+1 1 +13 --1:-2 2 +14 --1:-2:-13 13 +15 --1:-n:2 2 +16 --1:-n:2:-3 3 +17 --1:-n:2:-13 13 +18 -n:-1:-12 12 +19 --1:-12 12 +NA LAST NA +' +set $tests + +# Require that this test be run at 'nice' level 0. +niceness=$(nice) +if test "$niceness" = 0; then + : ok +else + skip_ "this test must be run at nice level 0" +fi + +while :; do + test_name=$1 + args=$2 + expected_result=$3 + test $args = empty && args='' + test x$args = xLAST && break + args=$(echo x$args|tr : ' '|sed 's/^x//') + if test "$VERBOSE" = yes; then + #echo "testing \$(nice $args nice\) = $expected_result ..." + echo "test $test_name... " | tr -d '\n' + fi + test x$(nice $args nice 2> /dev/null) = x$expected_result \ + && ok=ok || ok=FAIL fail=1 + test "$VERBOSE" = yes && echo $ok + shift; shift; shift +done + +# Test negative niceness - command must be run whether or not change happens. +if test x$(nice -n -1 nice 2> /dev/null) = x0 ; then + # unprivileged user - warn about failure to change + nice -n -1 true 2> err || fail=1 + test -s err || fail=1 + mv err exp || framework_failure_ + nice --1 true 2> err || fail=1 + compare exp err || fail=1 + # Failure to write advisory message is fatal. Buggy through coreutils 8.0. + if test -w /dev/full && test -c /dev/full; then + nice -n -1 nice > out 2> /dev/full + test $? = 125 || fail=1 + test -s out && fail=1 + fi +else + # superuser - change succeeds + nice -n -1 nice 2> err || fail=1 + test -s err && fail=1 + test x$(nice -n -1 nice) = x-1 || fail=1 + test x$(nice --1 nice) = x-1 || fail=1 +fi + +Exit $fail diff --git a/tests/misc/nl b/tests/misc/nl deleted file mode 100755 index b5a4ac635..000000000 --- a/tests/misc/nl +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# exercise nl functionality - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ nl - - -echo a | nl > out || fail=1 -echo b | nl -s%n >> out || fail=1 -echo c | nl -n ln >> out || fail=1 -echo d | nl -n rn >> out || fail=1 -echo e | nl -n rz >> out || fail=1 -echo === >> out -printf 'a\n\n' | nl > t || fail=1; cat -A t >> out -cat <<\EOF > exp - 1 a - 1%nb -1 c - 1 d -000001 e -=== - 1^Ia$ - $ -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/nl.sh b/tests/misc/nl.sh new file mode 100755 index 000000000..b5a4ac635 --- /dev/null +++ b/tests/misc/nl.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# exercise nl functionality + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ nl + + +echo a | nl > out || fail=1 +echo b | nl -s%n >> out || fail=1 +echo c | nl -n ln >> out || fail=1 +echo d | nl -n rn >> out || fail=1 +echo e | nl -n rz >> out || fail=1 +echo === >> out +printf 'a\n\n' | nl > t || fail=1; cat -A t >> out +cat <<\EOF > exp + 1 a + 1%nb +1 c + 1 d +000001 e +=== + 1^Ia$ + $ +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/nohup b/tests/misc/nohup deleted file mode 100755 index 76f676d81..000000000 --- a/tests/misc/nohup +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/sh -# test nohup - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ nohup - - -nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1 - -# Be careful. The results of the above nohup command -# change depending on whether stdin and stdout are redirected. -if test -t 1; then - test "$(cat nohup.out)" = stdout || fail=1 - if test -t 0; then - echo 'nohup: ignoring input and appending output to 'nohup.out'\' - else - echo 'nohup: appending output to 'nohup.out'\' - fi >exp || fail=1 -else - # Here it should not even exist. - test -f nohup.out && fail=1 - if test -t 0; then - echo 'nohup: ignoring input' >exp - else - rm -f exp - fi || fail=1 -fi -echo 'stderr' >> exp || fail=1 - -compare exp err || fail=1 -rm -f nohup.out err exp -# ---------------------- - -# Be careful. The results of the following nohup command -# change depending on whether stderr is redirected. -nohup sh -c 'echo stdout; echo stderr 1>&2' >out || fail=1 -if test -t 2; then - test "$(cat out|tr '\n' -)" = stdout-stderr- || fail=1 -else - test "$(cat out|tr '\n' -)" = stdout- || fail=1 -fi -# It must *not* exist. -test -f nohup.out && fail=1 -rm -f nohup.out err -# ---------------------- - -# Bug present through coreutils 8.0: failure to print advisory message -# to stderr must be fatal. Requires stdout to be terminal. -if test -w /dev/full && test -c /dev/full; then -( - exec >/dev/tty - test -t 1 || exit 0 - nohup echo hi 2> /dev/full - test $? = 125 || fail=1 - test -f nohup.out || fail=1 - test -s nohup.out && fail=1 - rm -f nohup.out - exit $fail -) || fail=1 -fi - -nohup no-such-command 2> err -errno=$? -if test -t 1; then - test $errno = 127 || fail=1 - # It must exist. - test -f nohup.out || fail=1 - # It must be empty. - test -s nohup.out && fail=1 -fi - -cat <<\EOF > exp || fail=1 -nohup: appending output to 'nohup.out' -nohup: cannot run command 'no-such-command': No such file or directory -EOF -# Disable these comparisons. Too much variation in 2nd line. -# compare exp err || fail=1 -rm -f nohup.out err exp -# ---------------------- - -touch k; chmod 0 k -nohup ./k 2> err -errno=$? -test $errno = 126 || fail=1 -if test -t 1; then - # It must exist. - test -f nohup.out || fail=1 - # It must be empty. - test -s nohup.out && fail=1 -fi - -cat <<\EOF > exp || fail=1 -nohup: appending output to 'nohup.out' -nohup: cannot run command './k': Permission denied -EOF -# Disable these comparisons. Too much variation in 2nd line. -# compare exp err || fail=1 - -# Make sure it fails with exit status of 125 when given too few arguments, -# except that POSIX requires 127 in this case. -nohup >/dev/null 2>&1 -test $? = 125 || fail=1 -POSIXLY_CORRECT=1 nohup >/dev/null 2>&1 -test $? = 127 || fail=1 - -Exit $fail diff --git a/tests/misc/nohup.sh b/tests/misc/nohup.sh new file mode 100755 index 000000000..76f676d81 --- /dev/null +++ b/tests/misc/nohup.sh @@ -0,0 +1,121 @@ +#!/bin/sh +# test nohup + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ nohup + + +nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1 + +# Be careful. The results of the above nohup command +# change depending on whether stdin and stdout are redirected. +if test -t 1; then + test "$(cat nohup.out)" = stdout || fail=1 + if test -t 0; then + echo 'nohup: ignoring input and appending output to 'nohup.out'\' + else + echo 'nohup: appending output to 'nohup.out'\' + fi >exp || fail=1 +else + # Here it should not even exist. + test -f nohup.out && fail=1 + if test -t 0; then + echo 'nohup: ignoring input' >exp + else + rm -f exp + fi || fail=1 +fi +echo 'stderr' >> exp || fail=1 + +compare exp err || fail=1 +rm -f nohup.out err exp +# ---------------------- + +# Be careful. The results of the following nohup command +# change depending on whether stderr is redirected. +nohup sh -c 'echo stdout; echo stderr 1>&2' >out || fail=1 +if test -t 2; then + test "$(cat out|tr '\n' -)" = stdout-stderr- || fail=1 +else + test "$(cat out|tr '\n' -)" = stdout- || fail=1 +fi +# It must *not* exist. +test -f nohup.out && fail=1 +rm -f nohup.out err +# ---------------------- + +# Bug present through coreutils 8.0: failure to print advisory message +# to stderr must be fatal. Requires stdout to be terminal. +if test -w /dev/full && test -c /dev/full; then +( + exec >/dev/tty + test -t 1 || exit 0 + nohup echo hi 2> /dev/full + test $? = 125 || fail=1 + test -f nohup.out || fail=1 + test -s nohup.out && fail=1 + rm -f nohup.out + exit $fail +) || fail=1 +fi + +nohup no-such-command 2> err +errno=$? +if test -t 1; then + test $errno = 127 || fail=1 + # It must exist. + test -f nohup.out || fail=1 + # It must be empty. + test -s nohup.out && fail=1 +fi + +cat <<\EOF > exp || fail=1 +nohup: appending output to 'nohup.out' +nohup: cannot run command 'no-such-command': No such file or directory +EOF +# Disable these comparisons. Too much variation in 2nd line. +# compare exp err || fail=1 +rm -f nohup.out err exp +# ---------------------- + +touch k; chmod 0 k +nohup ./k 2> err +errno=$? +test $errno = 126 || fail=1 +if test -t 1; then + # It must exist. + test -f nohup.out || fail=1 + # It must be empty. + test -s nohup.out && fail=1 +fi + +cat <<\EOF > exp || fail=1 +nohup: appending output to 'nohup.out' +nohup: cannot run command './k': Permission denied +EOF +# Disable these comparisons. Too much variation in 2nd line. +# compare exp err || fail=1 + +# Make sure it fails with exit status of 125 when given too few arguments, +# except that POSIX requires 127 in this case. +nohup >/dev/null 2>&1 +test $? = 125 || fail=1 +POSIXLY_CORRECT=1 nohup >/dev/null 2>&1 +test $? = 127 || fail=1 + +Exit $fail diff --git a/tests/misc/nproc-avail b/tests/misc/nproc-avail deleted file mode 100755 index cf0846cc9..000000000 --- a/tests/misc/nproc-avail +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Ensure that "nproc" is less than or equal to "nproc --all". - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ nproc - -all=$(nproc --all) -available=$(OMP_NUM_THREADS= nproc) - -test $available -le $all || fail=1 - -Exit $fail diff --git a/tests/misc/nproc-avail.sh b/tests/misc/nproc-avail.sh new file mode 100755 index 000000000..cf0846cc9 --- /dev/null +++ b/tests/misc/nproc-avail.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Ensure that "nproc" is less than or equal to "nproc --all". + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ nproc + +all=$(nproc --all) +available=$(OMP_NUM_THREADS= nproc) + +test $available -le $all || fail=1 + +Exit $fail diff --git a/tests/misc/nproc-positive b/tests/misc/nproc-positive deleted file mode 100755 index d930fb892..000000000 --- a/tests/misc/nproc-positive +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# Ensure that nproc prints a number > 0 - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ nproc - -for mode in --all ''; do - procs=$(nproc $mode) - test "$procs" -gt 0 || fail=1 -done - -for i in -1000 0 1 1000; do - procs=$(OMP_NUM_THREADS=$i nproc) - test "$procs" -gt 0 || fail=1 -done - -for i in 0 ' 1' 1000; do - procs=$(nproc --ignore="$i") - test "$procs" -gt 0 || fail=1 -done - -for i in -1 N; do - nproc --ignore=$i && fail=1 -done - -procs=$(OMP_NUM_THREADS=42 nproc --ignore=40) -test "$procs" -eq 2 || fail=1 - -Exit $fail diff --git a/tests/misc/nproc-positive.sh b/tests/misc/nproc-positive.sh new file mode 100755 index 000000000..d930fb892 --- /dev/null +++ b/tests/misc/nproc-positive.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Ensure that nproc prints a number > 0 + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ nproc + +for mode in --all ''; do + procs=$(nproc $mode) + test "$procs" -gt 0 || fail=1 +done + +for i in -1000 0 1 1000; do + procs=$(OMP_NUM_THREADS=$i nproc) + test "$procs" -gt 0 || fail=1 +done + +for i in 0 ' 1' 1000; do + procs=$(nproc --ignore="$i") + test "$procs" -gt 0 || fail=1 +done + +for i in -1 N; do + nproc --ignore=$i && fail=1 +done + +procs=$(OMP_NUM_THREADS=42 nproc --ignore=40) +test "$procs" -eq 2 || fail=1 + +Exit $fail diff --git a/tests/misc/od b/tests/misc/od deleted file mode 100755 index 46d4601d6..000000000 --- a/tests/misc/od +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/perl -# Exercise od - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# Use a file in /proc whose size is not likely to -# change between the wc and od invocations. -my $proc_file = '/proc/version'; --f $proc_file - or $proc_file = '/dev/null'; - -# Count the bytes in $proc_file, _by reading_. -my $len = 0; -open FH, '<', $proc_file - or die "$program_name: can't open '$proc_file' for reading: $!\n"; -while (defined (my $line = )) - { - $len += length $line; - } -close FH; -my $proc_file_byte_count = $len; - -my @Tests = - ( - # Skip the exact length of the input file. - # Up to coreutils-6.9, this would ignore the "-j 1". - ['j-bug1', '-c -j 1 -An', {IN=>{g=>'a'}}, {OUT=>''}], - ['j-bug2', '-c -j 2 -An', {IN=>{g=>'a'}}, {IN=>{h=>'b'}}, {OUT=>''}], - # Skip the sum of the lengths of the first three inputs. - ['j-bug3', '-c -j 3 -An', {IN=>{g=>'a'}}, {IN=>{h=>'b'}}, - {IN=>{i=>'c'}}, {OUT=>''}], - # Skip the sum of the lengths of the first three inputs, printing the 4th. - ['j-bug4', '-c -j 3 -An', {IN=>{g=>'a'}}, {IN=>{h=>'b'}}, - {IN=>{i=>'c'}}, {IN=>{j=>'d'}}, {OUT=>" d\n"}], - - # Ensure that od -j doesn't fseek across a nonempty file in /proc, - # even if the kernel reports that the file has stat.st_size = 0. - ['j-proc', "-An -c -j $proc_file_byte_count $proc_file", - {IN=>{f2=>'e'}}, {OUT=>" e\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'od'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/od-N b/tests/misc/od-N deleted file mode 100755 index 00d956a5f..000000000 --- a/tests/misc/od-N +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Verify that 'od -N N' reads no more than N bytes of input. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ od - -echo abcdefg > in || framework_failure_ - - -(od -An -N3 -c; od -An -N3 -c) < in > out -cat < exp || fail=1 - a b c - d e f -EOF -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/od-N.sh b/tests/misc/od-N.sh new file mode 100755 index 000000000..00d956a5f --- /dev/null +++ b/tests/misc/od-N.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Verify that 'od -N N' reads no more than N bytes of input. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ od + +echo abcdefg > in || framework_failure_ + + +(od -An -N3 -c; od -An -N3 -c) < in > out +cat < exp || fail=1 + a b c + d e f +EOF +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/od-float b/tests/misc/od-float deleted file mode 100755 index a23a8f358..000000000 --- a/tests/misc/od-float +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# Test od on floating-point values. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ od - -export LC_ALL=C - -# Test for a bug in coreutils up through 8.7: od was losing -# information when asked to parse floating-point values. The numeric -# tests are valid only on Intel-like hosts, but that should be good -# enough to detect regressions, as they are designed to succeed on -# non-Intel-like hosts. Also, test for another bug in coreutils 8.7 -# on x86: sometimes there was no space between the columns. - -set x $(echo aaaabaaa | tr ab '\376\377' | od -t fF) || - framework_failure_ -case "$*" in -*0-*) fail=1;; -esac -case $3,$4 in --1.694740e+38,-1.694740e+38) fail=1;; -esac - -set x $(echo aaaaaaaabaaaaaaa | tr ab '\376\377' | od -t fD) || - framework_failure_ -case "$*" in -*0-*) fail=1;; -esac -case $3,$4 in --5.314010372517808e+303,-5.314010372517808e+303) fail=1;; -esac - -set x $(echo aaaaaaaaaaaaaaaabaaaaaaaaaaaaaaa | tr ab '\376\377' | od -t fL) || - framework_failure_ -case "$*" in -*0-*) fail=1;; -esac -case $3,$4 in --1.023442870282055988e+4855,-1.023442870282055988e+4855) fail=1;; -esac - -Exit $fail diff --git a/tests/misc/od-float.sh b/tests/misc/od-float.sh new file mode 100755 index 000000000..a23a8f358 --- /dev/null +++ b/tests/misc/od-float.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Test od on floating-point values. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ od + +export LC_ALL=C + +# Test for a bug in coreutils up through 8.7: od was losing +# information when asked to parse floating-point values. The numeric +# tests are valid only on Intel-like hosts, but that should be good +# enough to detect regressions, as they are designed to succeed on +# non-Intel-like hosts. Also, test for another bug in coreutils 8.7 +# on x86: sometimes there was no space between the columns. + +set x $(echo aaaabaaa | tr ab '\376\377' | od -t fF) || + framework_failure_ +case "$*" in +*0-*) fail=1;; +esac +case $3,$4 in +-1.694740e+38,-1.694740e+38) fail=1;; +esac + +set x $(echo aaaaaaaabaaaaaaa | tr ab '\376\377' | od -t fD) || + framework_failure_ +case "$*" in +*0-*) fail=1;; +esac +case $3,$4 in +-5.314010372517808e+303,-5.314010372517808e+303) fail=1;; +esac + +set x $(echo aaaaaaaaaaaaaaaabaaaaaaaaaaaaaaa | tr ab '\376\377' | od -t fL) || + framework_failure_ +case "$*" in +*0-*) fail=1;; +esac +case $3,$4 in +-1.023442870282055988e+4855,-1.023442870282055988e+4855) fail=1;; +esac + +Exit $fail diff --git a/tests/misc/od-multiple-t b/tests/misc/od-multiple-t deleted file mode 100755 index 049273cdf..000000000 --- a/tests/misc/od-multiple-t +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# verify that multiple -t specifiers to od align well -# This would fail before coreutils-6.13. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ od - -# Choose 48 bytes for the input, as that is lcm for 1, 2, 4, 8, 12, 16; -# we don't anticipate any other native object size on modern hardware. -seq 19 > in || framework_failure_ -test $(wc -c < in) -eq 48 || framework_failure_ - - -list='a c dC dS dI dL oC oS oI oL uC uS uI uL xC xS xI xL fF fD fL' -for format1 in $list; do - for format2 in $list; do - od -An -t${format1}z -t${format2}z in > out-raw || fail=1 - linewidth=$(head -n1 out-raw | wc -c) - linecount=$(wc -l < out-raw) - echo $format1 $format2 $(wc -c < out-raw) >> out - echo $format1 $format2 $(expr $linewidth '*' $linecount) >> exp - done -done - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/od-multiple-t.sh b/tests/misc/od-multiple-t.sh new file mode 100755 index 000000000..049273cdf --- /dev/null +++ b/tests/misc/od-multiple-t.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# verify that multiple -t specifiers to od align well +# This would fail before coreutils-6.13. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ od + +# Choose 48 bytes for the input, as that is lcm for 1, 2, 4, 8, 12, 16; +# we don't anticipate any other native object size on modern hardware. +seq 19 > in || framework_failure_ +test $(wc -c < in) -eq 48 || framework_failure_ + + +list='a c dC dS dI dL oC oS oI oL uC uS uI uL xC xS xI xL fF fD fL' +for format1 in $list; do + for format2 in $list; do + od -An -t${format1}z -t${format2}z in > out-raw || fail=1 + linewidth=$(head -n1 out-raw | wc -c) + linecount=$(wc -l < out-raw) + echo $format1 $format2 $(wc -c < out-raw) >> out + echo $format1 $format2 $(expr $linewidth '*' $linecount) >> exp + done +done + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/od-x8 b/tests/misc/od-x8 deleted file mode 100755 index 98a9fe979..000000000 --- a/tests/misc/od-x8 +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# verify that od -t x8 works properly -# This would fail before coreutils-4.5.2. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ od - -od -t x8 /dev/null >/dev/null || - skip_ "od lacks support for 8-byte quantities" - -echo abcdefgh |tr -d '\n' > in || framework_failure_ - - -od -An -t x8 in > out-raw || fail=1 -sed 's/^ //;s/\(..\)/\1 /g;s/ $//' out-raw \ - | tr ' ' '\n' \ - | sort -n \ - > out - -od -An -t x1 in \ - | sed 's/^ //' \ - | tr ' ' '\n' \ - | sort -n \ - > exp - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/od-x8.sh b/tests/misc/od-x8.sh new file mode 100755 index 000000000..98a9fe979 --- /dev/null +++ b/tests/misc/od-x8.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# verify that od -t x8 works properly +# This would fail before coreutils-4.5.2. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ od + +od -t x8 /dev/null >/dev/null || + skip_ "od lacks support for 8-byte quantities" + +echo abcdefgh |tr -d '\n' > in || framework_failure_ + + +od -An -t x8 in > out-raw || fail=1 +sed 's/^ //;s/\(..\)/\1 /g;s/ $//' out-raw \ + | tr ' ' '\n' \ + | sort -n \ + > out + +od -An -t x1 in \ + | sed 's/^ //' \ + | tr ' ' '\n' \ + | sort -n \ + > exp + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/od.pl b/tests/misc/od.pl new file mode 100755 index 000000000..46d4601d6 --- /dev/null +++ b/tests/misc/od.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +# Exercise od + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# Use a file in /proc whose size is not likely to +# change between the wc and od invocations. +my $proc_file = '/proc/version'; +-f $proc_file + or $proc_file = '/dev/null'; + +# Count the bytes in $proc_file, _by reading_. +my $len = 0; +open FH, '<', $proc_file + or die "$program_name: can't open '$proc_file' for reading: $!\n"; +while (defined (my $line = )) + { + $len += length $line; + } +close FH; +my $proc_file_byte_count = $len; + +my @Tests = + ( + # Skip the exact length of the input file. + # Up to coreutils-6.9, this would ignore the "-j 1". + ['j-bug1', '-c -j 1 -An', {IN=>{g=>'a'}}, {OUT=>''}], + ['j-bug2', '-c -j 2 -An', {IN=>{g=>'a'}}, {IN=>{h=>'b'}}, {OUT=>''}], + # Skip the sum of the lengths of the first three inputs. + ['j-bug3', '-c -j 3 -An', {IN=>{g=>'a'}}, {IN=>{h=>'b'}}, + {IN=>{i=>'c'}}, {OUT=>''}], + # Skip the sum of the lengths of the first three inputs, printing the 4th. + ['j-bug4', '-c -j 3 -An', {IN=>{g=>'a'}}, {IN=>{h=>'b'}}, + {IN=>{i=>'c'}}, {IN=>{j=>'d'}}, {OUT=>" d\n"}], + + # Ensure that od -j doesn't fseek across a nonempty file in /proc, + # even if the kernel reports that the file has stat.st_size = 0. + ['j-proc', "-An -c -j $proc_file_byte_count $proc_file", + {IN=>{f2=>'e'}}, {OUT=>" e\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'od'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/paste b/tests/misc/paste deleted file mode 100755 index 3d5b41196..000000000 --- a/tests/misc/paste +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl -# Test paste. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = 'paste'; -my $msg = "$prog: delimiter list ends with an unescaped backslash: "; - -my @Tests = - ( - # Ensure that paste properly handles files lacking a final newline. - ['no-nl-1', {IN=>"a"}, {IN=>"b"}, {OUT=>"a\tb\n"}], - ['no-nl-2', {IN=>"a\n"}, {IN=>"b"}, {OUT=>"a\tb\n"}], - ['no-nl-3', {IN=>"a"}, {IN=>"b\n"}, {OUT=>"a\tb\n"}], - ['no-nl-4', {IN=>"a\n"}, {IN=>"b\n"}, {OUT=>"a\tb\n"}], - - # Same as above, but with a two lines in each input file and - # the addition of the -d option to make SPACE be the output delimiter. - ['no-nla1', '-d" "', {IN=>"1\na"}, {IN=>"2\nb"}, {OUT=>"1 2\na b\n"}], - ['no-nla2', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb"}, {OUT=>"1 2\na b\n"}], - ['no-nla3', '-d" "', {IN=>"1\na"}, {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}], - ['no-nla4', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}], - - # Specifying a delimiter with a trailing backslash would overrun a - # malloc'd buffer. - ['delim-bs1', q!-d'\'!, {IN=>{'a'x50=>''}}, {EXIT => 1}, - # We print a single backslash into the expected output, so need four - # (two, each escaped) here. - {ERR => $msg . q!\\\\! . "\n"} ], - - # Prior to coreutils-5.1.2, this sort of abuse would make paste - # scribble on command-line arguments. With paste from coreutils-5.1.0, - # this example would mangle the first file name argument, if it contains - # accepted backslash-escapes: - # $ paste -d\\ '123\b\b\b.....@' 2>&1 |cat -A - # paste: 23^H^H^H.....@...@: No such file or directory$ - ['delim-bs2', q!-d'\'!, {IN=>{'123\b\b\b.....@'=>''}}, {EXIT => 1}, - {ERR => $msg . q!\\\\! . "\n"} ], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/paste.pl b/tests/misc/paste.pl new file mode 100755 index 000000000..3d5b41196 --- /dev/null +++ b/tests/misc/paste.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl +# Test paste. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = 'paste'; +my $msg = "$prog: delimiter list ends with an unescaped backslash: "; + +my @Tests = + ( + # Ensure that paste properly handles files lacking a final newline. + ['no-nl-1', {IN=>"a"}, {IN=>"b"}, {OUT=>"a\tb\n"}], + ['no-nl-2', {IN=>"a\n"}, {IN=>"b"}, {OUT=>"a\tb\n"}], + ['no-nl-3', {IN=>"a"}, {IN=>"b\n"}, {OUT=>"a\tb\n"}], + ['no-nl-4', {IN=>"a\n"}, {IN=>"b\n"}, {OUT=>"a\tb\n"}], + + # Same as above, but with a two lines in each input file and + # the addition of the -d option to make SPACE be the output delimiter. + ['no-nla1', '-d" "', {IN=>"1\na"}, {IN=>"2\nb"}, {OUT=>"1 2\na b\n"}], + ['no-nla2', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb"}, {OUT=>"1 2\na b\n"}], + ['no-nla3', '-d" "', {IN=>"1\na"}, {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}], + ['no-nla4', '-d" "', {IN=>"1\na\n"}, {IN=>"2\nb\n"}, {OUT=>"1 2\na b\n"}], + + # Specifying a delimiter with a trailing backslash would overrun a + # malloc'd buffer. + ['delim-bs1', q!-d'\'!, {IN=>{'a'x50=>''}}, {EXIT => 1}, + # We print a single backslash into the expected output, so need four + # (two, each escaped) here. + {ERR => $msg . q!\\\\! . "\n"} ], + + # Prior to coreutils-5.1.2, this sort of abuse would make paste + # scribble on command-line arguments. With paste from coreutils-5.1.0, + # this example would mangle the first file name argument, if it contains + # accepted backslash-escapes: + # $ paste -d\\ '123\b\b\b.....@' 2>&1 |cat -A + # paste: 23^H^H^H.....@...@: No such file or directory$ + ['delim-bs2', q!-d'\'!, {IN=>{'123\b\b\b.....@'=>''}}, {EXIT => 1}, + {ERR => $msg . q!\\\\! . "\n"} ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/pathchk1 b/tests/misc/pathchk1 deleted file mode 100755 index 373b545de..000000000 --- a/tests/misc/pathchk1 +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# pathchk tests - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ pathchk -skip_if_root_ - -touch file || framework_failure_ - - -# This should exit nonzero. Before 2.0.13, it gave a diagnostic, -# but exited successfully. -pathchk file/x > /dev/null 2>&1 && fail=1 - -# This should exit nonzero. Through 5.3.0 it exited with status zero. -pathchk -p '' > /dev/null 2>&1 && fail=1 - -# This tests the new -P option. -pathchk -P '' > /dev/null 2>&1 && fail=1 -pathchk -P -- - > /dev/null 2>&1 && fail=1 -pathchk -p -P x/- > /dev/null 2>&1 && fail=1 - -Exit $fail diff --git a/tests/misc/pathchk1.sh b/tests/misc/pathchk1.sh new file mode 100755 index 000000000..373b545de --- /dev/null +++ b/tests/misc/pathchk1.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# pathchk tests + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ pathchk +skip_if_root_ + +touch file || framework_failure_ + + +# This should exit nonzero. Before 2.0.13, it gave a diagnostic, +# but exited successfully. +pathchk file/x > /dev/null 2>&1 && fail=1 + +# This should exit nonzero. Through 5.3.0 it exited with status zero. +pathchk -p '' > /dev/null 2>&1 && fail=1 + +# This tests the new -P option. +pathchk -P '' > /dev/null 2>&1 && fail=1 +pathchk -P -- - > /dev/null 2>&1 && fail=1 +pathchk -p -P x/- > /dev/null 2>&1 && fail=1 + +Exit $fail diff --git a/tests/misc/pr b/tests/misc/pr deleted file mode 100755 index 0f25e2531..000000000 --- a/tests/misc/pr +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/perl -# Exercise a bug with pr -m -s - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -$ENV{PROG} = 'pr'; -my $ME = $ENV{PROG}; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['merge-w-tabs', '-m -s -t', - {IN=>{1=>"a\tb\tc\n"}}, - {IN=>{2=>"m\tn\to\n"}}, - {IN=>{3=>"x\ty\tz\n"}}, - {OUT=>join("\t", qw(a b c m n o x y z)) . "\n"} ], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/pr.pl b/tests/misc/pr.pl new file mode 100755 index 000000000..0f25e2531 --- /dev/null +++ b/tests/misc/pr.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl +# Exercise a bug with pr -m -s + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +$ENV{PROG} = 'pr'; +my $ME = $ENV{PROG}; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['merge-w-tabs', '-m -s -t', + {IN=>{1=>"a\tb\tc\n"}}, + {IN=>{2=>"m\tn\to\n"}}, + {IN=>{3=>"x\ty\tz\n"}}, + {OUT=>join("\t", qw(a b c m n o x y z)) . "\n"} ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n"; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/printenv b/tests/misc/printenv deleted file mode 100755 index bbce8ef0e..000000000 --- a/tests/misc/printenv +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -# Verify behavior of printenv. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ printenv - -# Without arguments, printenv behaves like env. Some shells provide -# printenv as a builtin, so we must invoke it via "env". -# But beware of $_, set by many shells to the last command run. -# Also, filter out LD_PRELOAD, which is set when running under valgrind. -env | grep -Ev '^(_|LD_PRELOAD=)' > exp || framework_failure_ -env -- printenv | grep -Ev '^(_|LD_PRELOAD=)' > out || fail=1 -compare exp out || fail=1 - -# POSIX is clear that environ may, but need not be, sorted. -# Environment variable values may contain newlines, which cannot be -# observed by merely inspecting output from printenv. -if env -- printenv | grep '^ENV_TEST' >/dev/null ; then - skip_ "environment has potential interference from ENV_TEST*" -fi - -# Printing a single variable's value. -env -- printenv ENV_TEST > out -test $? = 1 || fail=1 -test -s out && fail=1 -echo a > exp || framework_failure_ -ENV_TEST=a env -- printenv ENV_TEST > out || fail=1 -compare exp out || fail=1 - -# Printing multiple variables. Order follows command line. -ENV_TEST1=a ENV_TEST2=b env -- printenv ENV_TEST2 ENV_TEST1 ENV_TEST2 > out \ - || fail=1 -ENV_TEST1=a ENV_TEST2=b env -- printenv ENV_TEST1 ENV_TEST2 >> out || fail=1 -cat < exp || framework_failure_ -b -a -b -a -b -EOF -compare exp out || fail=1 - -# Exit status reflects missing variable, but remaining arguments processed. -ENV_TEST1=a env -- printenv ENV_TEST2 ENV_TEST1 > out -test $? = 1 || fail=1 -ENV_TEST1=a env -- printenv ENV_TEST1 ENV_TEST2 >> out -test $? = 1 || fail=1 -cat < exp || framework_failure_ -a -a -EOF -compare exp out || fail=1 - -# Non-standard environment variable name. Shells won't create it, but -# env can, and printenv must be able to deal with it. -echo b > exp || framework_failure_ -env -- -a=b printenv -- -a > out || fail=1 -compare exp out || fail=1 - -# Silently reject invalid env-var names. -# Bug present through coreutils 8.0. -env a=b=c printenv a=b > out -test $? = 1 || fail=1 -test -s out && fail=1 - -Exit $fail diff --git a/tests/misc/printenv.sh b/tests/misc/printenv.sh new file mode 100755 index 000000000..bbce8ef0e --- /dev/null +++ b/tests/misc/printenv.sh @@ -0,0 +1,81 @@ +#!/bin/sh +# Verify behavior of printenv. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ printenv + +# Without arguments, printenv behaves like env. Some shells provide +# printenv as a builtin, so we must invoke it via "env". +# But beware of $_, set by many shells to the last command run. +# Also, filter out LD_PRELOAD, which is set when running under valgrind. +env | grep -Ev '^(_|LD_PRELOAD=)' > exp || framework_failure_ +env -- printenv | grep -Ev '^(_|LD_PRELOAD=)' > out || fail=1 +compare exp out || fail=1 + +# POSIX is clear that environ may, but need not be, sorted. +# Environment variable values may contain newlines, which cannot be +# observed by merely inspecting output from printenv. +if env -- printenv | grep '^ENV_TEST' >/dev/null ; then + skip_ "environment has potential interference from ENV_TEST*" +fi + +# Printing a single variable's value. +env -- printenv ENV_TEST > out +test $? = 1 || fail=1 +test -s out && fail=1 +echo a > exp || framework_failure_ +ENV_TEST=a env -- printenv ENV_TEST > out || fail=1 +compare exp out || fail=1 + +# Printing multiple variables. Order follows command line. +ENV_TEST1=a ENV_TEST2=b env -- printenv ENV_TEST2 ENV_TEST1 ENV_TEST2 > out \ + || fail=1 +ENV_TEST1=a ENV_TEST2=b env -- printenv ENV_TEST1 ENV_TEST2 >> out || fail=1 +cat < exp || framework_failure_ +b +a +b +a +b +EOF +compare exp out || fail=1 + +# Exit status reflects missing variable, but remaining arguments processed. +ENV_TEST1=a env -- printenv ENV_TEST2 ENV_TEST1 > out +test $? = 1 || fail=1 +ENV_TEST1=a env -- printenv ENV_TEST1 ENV_TEST2 >> out +test $? = 1 || fail=1 +cat < exp || framework_failure_ +a +a +EOF +compare exp out || fail=1 + +# Non-standard environment variable name. Shells won't create it, but +# env can, and printenv must be able to deal with it. +echo b > exp || framework_failure_ +env -- -a=b printenv -- -a > out || fail=1 +compare exp out || fail=1 + +# Silently reject invalid env-var names. +# Bug present through coreutils 8.0. +env a=b=c printenv a=b > out +test $? = 1 || fail=1 +test -s out && fail=1 + +Exit $fail diff --git a/tests/misc/printf b/tests/misc/printf deleted file mode 100755 index 987e452ae..000000000 --- a/tests/misc/printf +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/sh -# basic tests for printf - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -prog='env printf' - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ printf - -getlimits_ - - -# Verify the 3 methods of specifying "Escape": -test $($prog "\x1b\n\33\n\e\n" | uniq -u) && fail=1 - -# This would fail (by printing the '--') for printf in sh-utils -# and in coreutils 4.5.1. -$prog -- 'foo\n' > out || fail=1 -cat <<\EOF > exp -foo -EOF - -compare exp out || fail=1 - -rm -f out exp -# Until coreutils-4.5.10, this would elicit a segfault. -$prog '1 %*sy\n' -3 x > out || fail=1 - -# Until coreutils 5.2.2, this would succeed. -if POSIXLY_CORRECT=1 $prog '2 \x' >/dev/null 2>&1; then - fail=1 -else - echo '2 failed, as expected' >> out -fi - -# Until coreutils-4.5.12, these would fail. -$prog '3 \x40\n' >> out || fail=1 -POSIXLY_CORRECT=1 \ -$prog '4 \x40\n' >> out || fail=1 -$prog '5 % +d\n' 234 >> out || fail=1 - -# This should print "6 !\n", but don't rely on '!' being the -# one-byte representation of octal 041. With printf prior to -# coreutils-5.0.1, it would print six bytes: "6 \41\n". -$prog '6 \41\n' | tr '\41' '!' >> out - -# Note that as of coreutils-5.0.1, printf with a format of '\0002x' -# prints a NUL byte followed by the digit '2' and an 'x'. -# By contrast bash's printf outputs the same thing as $(printf '\2x') does. -$prog '7 \2y \02y \002y \0002y\n' |tr '\0\2' '*=' >> out - -$prog '8 %b %b %b %b\n' '\1y' '\01y' '\001y' '\0001y'|tr '\1' = >> out - -$prog '9 %*dx\n' -2 0 >>out || fail=1 - -$prog '10 %.*dx\n' $INT_UFLOW 0 >>out || fail=1 -$prog '%.*dx\n' $INT_OFLOW 0 >>out 2> /dev/null && fail=1 - -$prog '11 %*c\n' 2 x >>out || fail=1 - -$prog '%#d\n' 0 >>out 2> /dev/null && fail=1 - -$prog '%0s\n' 0 >>out 2> /dev/null && fail=1 - -$prog '%.9c\n' 0 >>out 2> /dev/null && fail=1 - -$prog '%'\''s\n' 0 >>out 2> /dev/null && fail=1 - -cat <<\EOF > exp -1 x y -2 failed, as expected -3 @ -4 @ -5 +234 -6 ! -7 =y =y =y *2y -8 =y =y =y =y -9 0 x -10 0x -11 x -EOF - -compare exp out || fail=1 - -# Verify handling of single quote chars (\' or \") - -$prog '%d\n' '"a' >out 2>err # valid -$prog '%d\n' '"a"' >>out 2>>err # invalid -$prog '%d\n' '"' >>out 2>>err # invalid -$prog '%d\n' 'a' >>out 2>>err # invalid - -cat < exp -97 -97 -0 -0 -EOF - -# POSIX says strtoimax *may* set errno to EINVAL in the latter -# two cases. So far, that happens at least on MacOS X 10.5. -# Map that output to the more common expected output. -sed 's/: Invalid.*/: expected a numeric value/' err > k && mv k err - -cat < exp_err -printf: warning: ": character(s) following character constant have been ignored -printf: ": expected a numeric value -printf: a: expected a numeric value -EOF - -compare exp out || fail=1 -compare exp_err err || fail=1 - -Exit $fail diff --git a/tests/misc/printf-cov b/tests/misc/printf-cov deleted file mode 100755 index 64f2d95bb..000000000 --- a/tests/misc/printf-cov +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/perl -# improve printf.c test coverage - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'printf'; -my $try = "Try '$prog --help' for more information.\n"; -my $pow_2_31 = 2**31; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = -( - ['no-args', {EXIT=>1}, {ERR=>"$prog: missing operand\n$try"}], - ['no-arg2', '--', {EXIT=>1}, {ERR=>"$prog: missing operand\n$try"}], - ['escape-1', q('\a\b\f\n\r\t\v\z\c'), {OUT=>"\a\b\f\n\r\t\x0b\\z"}], - ['hex-ucX', '%X 999', {OUT=>"3E7"}], - ['hex-ucXw', '%4X 999', {OUT=>" 3E7"}], - ['hex-ucXp', '%.4X 999', {OUT=>"03E7"}], - ['hex-ucXwp', '%5.4X 999', {OUT=>" 03E7"}], - ['hex-vw', '%*X 4 42', {OUT=>" 2A"}], - ['hex-vp', '%.*X 4 42', {OUT=>"002A"}], - ['hex-vwvp', '%*.*X 3 2 15', {OUT=>" 0F"}], - ['b', q('nl\ntab\tx'), {OUT=>"nl\ntab\tx"}], - ['c1', '%c 123', {OUT=>"1"}], - ['cw', '%\*c 3 123', {OUT=>" 1"}], - ['d-ucXwp', '%5.4d 999', {OUT=>" 0999"}], - ['d-vw', '%*d 4 42', {OUT=>" 42"}], - ['d-vp', '%.*d 4 42', {OUT=>"0042"}], - ['d-vwvp', '%*.*d 3 2 15', {OUT=>" 15"}], - ['d-neg-prec', '%.*d -3 15', {OUT=>"15"}], - ['d-big-prec', "%.*d $pow_2_31 15", # INT_MAX - {EXIT=>1}, {ERR=>"$prog: invalid precision: $pow_2_31\n"}], - ['d-big-fwidth', "%*d $pow_2_31 15", # INT_MAX - {EXIT=>1}, {ERR=>"$prog: invalid field width: $pow_2_31\n"}], - ['F', '%F 1', {OUT=>"1.000000"}], - ['LF', '%LF 1', {OUT=>"1.000000"}], - ['E', '%E 2', {OUT=>"2.000000E+00"}], - ['LE', '%LE 2', {OUT=>"2.000000E+00"}], - ['s', '%s x', {OUT=>"x"}], - ['sw', '%\*s 2 x', {OUT=>" x"}], - ['sp', '%.\*s 2 abcd', {OUT=>"ab"}], - ['swp', '%\*.\*s 2 2 abcd', {OUT=>"ab"}], - ['sw-no-args', '%\*s'], - ['sw-no-args2', '%.\*s'], - ['G-ucXwp', '%5.4G 3', {OUT=>" 3"}], - ['G-vw', '%*G 4 42', {OUT=>" 42"}], - ['G-vp', '%.*G 4 42', {OUT=>"42"}], - ['G-vwvp', '%*.*G 5 3 15', {OUT=>" 15"}], - ['esc', q('\xaa\0377'), {OUT=>"\xaa\0377"}], - ['esc-bad-hex', q('\x'), {EXIT=>1}, - {ERR=>"$prog: missing hexadecimal number in escape\n"}], - # ['u4', q('\u09ac'), {OUT=>"\xe0a6ac"}], - ['u-invalid', q('\u0000'), {EXIT=>1}, - {ERR=>"$prog: invalid universal character name \\u0000\n"}], - ['u-missing', q('\u'), {EXIT=>1}, - {ERR=>"$prog: missing hexadecimal number in escape\n"}], - ['d-invalid', '%d no-num', {OUT=>'0'}, {EXIT=>1}, - # Depending on the strtol implementation we expect one of these: - # no-num: Invalid argument (FreeBSD6) - # no-num: expected a numeric value (glibc, Solaris 10) - {ERR_SUBST => 's/Invalid argument$/expected a numeric value/'}, - {ERR=>"$prog: no-num: expected a numeric value\n"}], - ['d-bad-suffix', '%d 9z', {OUT=>'9'}, {EXIT=>1}, - {ERR=>"$prog: 9z: value not completely converted\n"}], - ['d-out-of-range', '%d '.('9'x30), {EXIT=>1}, - {OUT=>"inaccurate"}, {OUT_SUBST => 's/\d+/inaccurate/'}, - {ERR=>"$prog: 9...9\n"}, {ERR_SUBST => 's/9+.*/9...9/'}], - ['excess', 'B 1', {OUT=>'B'}, - {ERR=>"$prog: warning: ignoring excess arguments, starting with '1'\n"}], - ['percent', '%%', {OUT=>'%'}], - ['d-sp', q('% d' 33), {OUT=>' 33'}], - ['d-plus', q('%+d' 33), {OUT=>'+33'}], - ['d-minus', q('%-d' 33), {OUT=> '33'}], - ['d-zero', q('%02d' 1), {OUT=> '01'}], - ['d-quote', q("%'d" 3333), {OUT=> '3333'}, {OUT_SUBST => 'tr/3//c'}], - ['d-hash', q("%#d" 3333), {EXIT=>1}, - {ERR=>"$prog: %#d: invalid conversion specification\n"}], -); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/printf-cov.pl b/tests/misc/printf-cov.pl new file mode 100755 index 000000000..64f2d95bb --- /dev/null +++ b/tests/misc/printf-cov.pl @@ -0,0 +1,101 @@ +#!/usr/bin/perl +# improve printf.c test coverage + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'printf'; +my $try = "Try '$prog --help' for more information.\n"; +my $pow_2_31 = 2**31; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = +( + ['no-args', {EXIT=>1}, {ERR=>"$prog: missing operand\n$try"}], + ['no-arg2', '--', {EXIT=>1}, {ERR=>"$prog: missing operand\n$try"}], + ['escape-1', q('\a\b\f\n\r\t\v\z\c'), {OUT=>"\a\b\f\n\r\t\x0b\\z"}], + ['hex-ucX', '%X 999', {OUT=>"3E7"}], + ['hex-ucXw', '%4X 999', {OUT=>" 3E7"}], + ['hex-ucXp', '%.4X 999', {OUT=>"03E7"}], + ['hex-ucXwp', '%5.4X 999', {OUT=>" 03E7"}], + ['hex-vw', '%*X 4 42', {OUT=>" 2A"}], + ['hex-vp', '%.*X 4 42', {OUT=>"002A"}], + ['hex-vwvp', '%*.*X 3 2 15', {OUT=>" 0F"}], + ['b', q('nl\ntab\tx'), {OUT=>"nl\ntab\tx"}], + ['c1', '%c 123', {OUT=>"1"}], + ['cw', '%\*c 3 123', {OUT=>" 1"}], + ['d-ucXwp', '%5.4d 999', {OUT=>" 0999"}], + ['d-vw', '%*d 4 42', {OUT=>" 42"}], + ['d-vp', '%.*d 4 42', {OUT=>"0042"}], + ['d-vwvp', '%*.*d 3 2 15', {OUT=>" 15"}], + ['d-neg-prec', '%.*d -3 15', {OUT=>"15"}], + ['d-big-prec', "%.*d $pow_2_31 15", # INT_MAX + {EXIT=>1}, {ERR=>"$prog: invalid precision: $pow_2_31\n"}], + ['d-big-fwidth', "%*d $pow_2_31 15", # INT_MAX + {EXIT=>1}, {ERR=>"$prog: invalid field width: $pow_2_31\n"}], + ['F', '%F 1', {OUT=>"1.000000"}], + ['LF', '%LF 1', {OUT=>"1.000000"}], + ['E', '%E 2', {OUT=>"2.000000E+00"}], + ['LE', '%LE 2', {OUT=>"2.000000E+00"}], + ['s', '%s x', {OUT=>"x"}], + ['sw', '%\*s 2 x', {OUT=>" x"}], + ['sp', '%.\*s 2 abcd', {OUT=>"ab"}], + ['swp', '%\*.\*s 2 2 abcd', {OUT=>"ab"}], + ['sw-no-args', '%\*s'], + ['sw-no-args2', '%.\*s'], + ['G-ucXwp', '%5.4G 3', {OUT=>" 3"}], + ['G-vw', '%*G 4 42', {OUT=>" 42"}], + ['G-vp', '%.*G 4 42', {OUT=>"42"}], + ['G-vwvp', '%*.*G 5 3 15', {OUT=>" 15"}], + ['esc', q('\xaa\0377'), {OUT=>"\xaa\0377"}], + ['esc-bad-hex', q('\x'), {EXIT=>1}, + {ERR=>"$prog: missing hexadecimal number in escape\n"}], + # ['u4', q('\u09ac'), {OUT=>"\xe0a6ac"}], + ['u-invalid', q('\u0000'), {EXIT=>1}, + {ERR=>"$prog: invalid universal character name \\u0000\n"}], + ['u-missing', q('\u'), {EXIT=>1}, + {ERR=>"$prog: missing hexadecimal number in escape\n"}], + ['d-invalid', '%d no-num', {OUT=>'0'}, {EXIT=>1}, + # Depending on the strtol implementation we expect one of these: + # no-num: Invalid argument (FreeBSD6) + # no-num: expected a numeric value (glibc, Solaris 10) + {ERR_SUBST => 's/Invalid argument$/expected a numeric value/'}, + {ERR=>"$prog: no-num: expected a numeric value\n"}], + ['d-bad-suffix', '%d 9z', {OUT=>'9'}, {EXIT=>1}, + {ERR=>"$prog: 9z: value not completely converted\n"}], + ['d-out-of-range', '%d '.('9'x30), {EXIT=>1}, + {OUT=>"inaccurate"}, {OUT_SUBST => 's/\d+/inaccurate/'}, + {ERR=>"$prog: 9...9\n"}, {ERR_SUBST => 's/9+.*/9...9/'}], + ['excess', 'B 1', {OUT=>'B'}, + {ERR=>"$prog: warning: ignoring excess arguments, starting with '1'\n"}], + ['percent', '%%', {OUT=>'%'}], + ['d-sp', q('% d' 33), {OUT=>' 33'}], + ['d-plus', q('%+d' 33), {OUT=>'+33'}], + ['d-minus', q('%-d' 33), {OUT=> '33'}], + ['d-zero', q('%02d' 1), {OUT=> '01'}], + ['d-quote', q("%'d" 3333), {OUT=> '3333'}, {OUT_SUBST => 'tr/3//c'}], + ['d-hash', q("%#d" 3333), {EXIT=>1}, + {ERR=>"$prog: %#d: invalid conversion specification\n"}], +); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/printf-hex b/tests/misc/printf-hex deleted file mode 100755 index 23a218faf..000000000 --- a/tests/misc/printf-hex +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# make sure that only two hex. digits are consumed in a \xHHH sequence - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ printf - -env printf '\x7e3\n' > out || fail=1 -cat <<\EOF > exp -~3 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/printf-hex.sh b/tests/misc/printf-hex.sh new file mode 100755 index 000000000..23a218faf --- /dev/null +++ b/tests/misc/printf-hex.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# make sure that only two hex. digits are consumed in a \xHHH sequence + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ printf + +env printf '\x7e3\n' > out || fail=1 +cat <<\EOF > exp +~3 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/printf-surprise b/tests/misc/printf-surprise deleted file mode 100755 index b6f627598..000000000 --- a/tests/misc/printf-surprise +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# Detect printf(3) failure even when it doesn't set stream error indicator - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -prog=printf - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ printf - -require_ulimit_ - - -# Up to coreutils-6.9, "printf %.Nf 0" would encounter an ENOMEM internal -# error from glibc's printf(3) function whenever N was large relative to -# the size of available memory. As of Oct 2007, that internal stream- -# related failure was not reflected (for any libc I know of) in the usual -# stream error indicator that is tested by ferror. The result was that -# while the printf command obviously failed (generated no output), -# it mistakenly exited successfully (exit status of 0). - -# Testing it is tricky, because there is so much variance -# in quality for this corner of printf(3) implementations. -# Most implementations do attempt to allocate N bytes of storage. -# Using the maximum value for N (2^31-1) causes glibc-2.7 to try to -# allocate almost 2^64 bytes, while freeBSD 6.1's implementation -# correctly outputs almost 2GB worth of 0's, which takes too long. -# We want to test implementations that allocate N bytes, but without -# triggering the above extremes. - -# Some other versions of glibc-2.7 have a snprintf function that segfaults -# when an internal (technically unnecessary!) memory allocation fails. - -# The compromise is to limit virtual memory to something reasonable, -# and to make an N-byte-allocating-printf require more than that, thus -# triggering the printf(3) misbehavior -- which, btw, is required by ISO C99. - -mkfifo_or_skip_ fifo - -# Disable MALLOC_PERTURB_, to avoid triggering this bug -# http://bugs.debian.org/481543#77 -export MALLOC_PERTURB_=0 - -head -c 10 fifo > out & - -# Choosing the virtual memory limit, 11000 is enough, but 10000 is too -# little and provokes a "memory exhausted" diagnostic on FreeBSD 9.0-p3. -( ulimit -v 15000; env $prog %20000000f 0 2>err-msg > fifo ) -exit=$? - -# Map this longer, and rarer, diagnostic to the common one. -# printf: cannot perform formatted output: Cannot allocate memory" \ -sed 's/cannot perform .*/write error/' err-msg > k && mv k err-msg -err_msg=$(cat err-msg|tr '\n' :) - -# By some bug, on Solaris 11 (5.11 snv_86), err_msg ends up -# containing '1> fifo:printf: write error:'. Recognize that, too. - -case $err_msg in - "$prog: write error:"*) diagnostic=y ;; - "1> fifo:$prog: write error:") diagnostic=y ;; - '') diagnostic=n ;; - *) diagnostic=unexpected ;; -esac -n_out=$(wc -c < out) - -case $n_out:$diagnostic:$exit in - 10:n:0) ;; # ok, succeeds w/no diagnostic: FreeBSD 6.1 - 0:y:1) ;; # ok, glibc-2.8 and newer, when printf(3) fails with ENOMEM - - # With MALLOC_PERTURB_=0, this no longer happens. - # *:139) # segfault; known bug at least in debian unstable's libc6 2.7-11 - # echo 1>&2 "$0: bug in snprintf causes low-mem use of printf to segfault" - # fail=77;; - - # 10:y) ;; # Fail: doesn't happen: nobody succeeds with a diagnostic - # 0:n) ;; # Fail pre-patch: no output, no diag - *) fail=1;; -esac - -Exit $fail diff --git a/tests/misc/printf-surprise.sh b/tests/misc/printf-surprise.sh new file mode 100755 index 000000000..b6f627598 --- /dev/null +++ b/tests/misc/printf-surprise.sh @@ -0,0 +1,94 @@ +#!/bin/sh +# Detect printf(3) failure even when it doesn't set stream error indicator + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +prog=printf + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ printf + +require_ulimit_ + + +# Up to coreutils-6.9, "printf %.Nf 0" would encounter an ENOMEM internal +# error from glibc's printf(3) function whenever N was large relative to +# the size of available memory. As of Oct 2007, that internal stream- +# related failure was not reflected (for any libc I know of) in the usual +# stream error indicator that is tested by ferror. The result was that +# while the printf command obviously failed (generated no output), +# it mistakenly exited successfully (exit status of 0). + +# Testing it is tricky, because there is so much variance +# in quality for this corner of printf(3) implementations. +# Most implementations do attempt to allocate N bytes of storage. +# Using the maximum value for N (2^31-1) causes glibc-2.7 to try to +# allocate almost 2^64 bytes, while freeBSD 6.1's implementation +# correctly outputs almost 2GB worth of 0's, which takes too long. +# We want to test implementations that allocate N bytes, but without +# triggering the above extremes. + +# Some other versions of glibc-2.7 have a snprintf function that segfaults +# when an internal (technically unnecessary!) memory allocation fails. + +# The compromise is to limit virtual memory to something reasonable, +# and to make an N-byte-allocating-printf require more than that, thus +# triggering the printf(3) misbehavior -- which, btw, is required by ISO C99. + +mkfifo_or_skip_ fifo + +# Disable MALLOC_PERTURB_, to avoid triggering this bug +# http://bugs.debian.org/481543#77 +export MALLOC_PERTURB_=0 + +head -c 10 fifo > out & + +# Choosing the virtual memory limit, 11000 is enough, but 10000 is too +# little and provokes a "memory exhausted" diagnostic on FreeBSD 9.0-p3. +( ulimit -v 15000; env $prog %20000000f 0 2>err-msg > fifo ) +exit=$? + +# Map this longer, and rarer, diagnostic to the common one. +# printf: cannot perform formatted output: Cannot allocate memory" \ +sed 's/cannot perform .*/write error/' err-msg > k && mv k err-msg +err_msg=$(cat err-msg|tr '\n' :) + +# By some bug, on Solaris 11 (5.11 snv_86), err_msg ends up +# containing '1> fifo:printf: write error:'. Recognize that, too. + +case $err_msg in + "$prog: write error:"*) diagnostic=y ;; + "1> fifo:$prog: write error:") diagnostic=y ;; + '') diagnostic=n ;; + *) diagnostic=unexpected ;; +esac +n_out=$(wc -c < out) + +case $n_out:$diagnostic:$exit in + 10:n:0) ;; # ok, succeeds w/no diagnostic: FreeBSD 6.1 + 0:y:1) ;; # ok, glibc-2.8 and newer, when printf(3) fails with ENOMEM + + # With MALLOC_PERTURB_=0, this no longer happens. + # *:139) # segfault; known bug at least in debian unstable's libc6 2.7-11 + # echo 1>&2 "$0: bug in snprintf causes low-mem use of printf to segfault" + # fail=77;; + + # 10:y) ;; # Fail: doesn't happen: nobody succeeds with a diagnostic + # 0:n) ;; # Fail pre-patch: no output, no diag + *) fail=1;; +esac + +Exit $fail diff --git a/tests/misc/printf.sh b/tests/misc/printf.sh new file mode 100755 index 000000000..987e452ae --- /dev/null +++ b/tests/misc/printf.sh @@ -0,0 +1,127 @@ +#!/bin/sh +# basic tests for printf + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +prog='env printf' + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ printf + +getlimits_ + + +# Verify the 3 methods of specifying "Escape": +test $($prog "\x1b\n\33\n\e\n" | uniq -u) && fail=1 + +# This would fail (by printing the '--') for printf in sh-utils +# and in coreutils 4.5.1. +$prog -- 'foo\n' > out || fail=1 +cat <<\EOF > exp +foo +EOF + +compare exp out || fail=1 + +rm -f out exp +# Until coreutils-4.5.10, this would elicit a segfault. +$prog '1 %*sy\n' -3 x > out || fail=1 + +# Until coreutils 5.2.2, this would succeed. +if POSIXLY_CORRECT=1 $prog '2 \x' >/dev/null 2>&1; then + fail=1 +else + echo '2 failed, as expected' >> out +fi + +# Until coreutils-4.5.12, these would fail. +$prog '3 \x40\n' >> out || fail=1 +POSIXLY_CORRECT=1 \ +$prog '4 \x40\n' >> out || fail=1 +$prog '5 % +d\n' 234 >> out || fail=1 + +# This should print "6 !\n", but don't rely on '!' being the +# one-byte representation of octal 041. With printf prior to +# coreutils-5.0.1, it would print six bytes: "6 \41\n". +$prog '6 \41\n' | tr '\41' '!' >> out + +# Note that as of coreutils-5.0.1, printf with a format of '\0002x' +# prints a NUL byte followed by the digit '2' and an 'x'. +# By contrast bash's printf outputs the same thing as $(printf '\2x') does. +$prog '7 \2y \02y \002y \0002y\n' |tr '\0\2' '*=' >> out + +$prog '8 %b %b %b %b\n' '\1y' '\01y' '\001y' '\0001y'|tr '\1' = >> out + +$prog '9 %*dx\n' -2 0 >>out || fail=1 + +$prog '10 %.*dx\n' $INT_UFLOW 0 >>out || fail=1 +$prog '%.*dx\n' $INT_OFLOW 0 >>out 2> /dev/null && fail=1 + +$prog '11 %*c\n' 2 x >>out || fail=1 + +$prog '%#d\n' 0 >>out 2> /dev/null && fail=1 + +$prog '%0s\n' 0 >>out 2> /dev/null && fail=1 + +$prog '%.9c\n' 0 >>out 2> /dev/null && fail=1 + +$prog '%'\''s\n' 0 >>out 2> /dev/null && fail=1 + +cat <<\EOF > exp +1 x y +2 failed, as expected +3 @ +4 @ +5 +234 +6 ! +7 =y =y =y *2y +8 =y =y =y =y +9 0 x +10 0x +11 x +EOF + +compare exp out || fail=1 + +# Verify handling of single quote chars (\' or \") + +$prog '%d\n' '"a' >out 2>err # valid +$prog '%d\n' '"a"' >>out 2>>err # invalid +$prog '%d\n' '"' >>out 2>>err # invalid +$prog '%d\n' 'a' >>out 2>>err # invalid + +cat < exp +97 +97 +0 +0 +EOF + +# POSIX says strtoimax *may* set errno to EINVAL in the latter +# two cases. So far, that happens at least on MacOS X 10.5. +# Map that output to the more common expected output. +sed 's/: Invalid.*/: expected a numeric value/' err > k && mv k err + +cat < exp_err +printf: warning: ": character(s) following character constant have been ignored +printf: ": expected a numeric value +printf: a: expected a numeric value +EOF + +compare exp out || fail=1 +compare exp_err err || fail=1 + +Exit $fail diff --git a/tests/misc/ptx b/tests/misc/ptx deleted file mode 100755 index 50ee0e8d6..000000000 --- a/tests/misc/ptx +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'ptx'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = -( -["1tok", '-w10', {IN=>"bar\n"}, {OUT=>" bar\n"}], -["2tok", '-w10', {IN=>"foo bar\n"}, {OUT=>" / bar\n foo/\n"}], - -# with coreutils-6.12 and earlier, this would infloop with -wN, N < 10 -["narrow", '-w2', {IN=>"qux\n"}, {OUT=>" qux\n"}], -["narrow-g", '-g1 -w2', {IN=>"ta\n"}, {OUT=>" ta\n"}], - -# with coreutils-6.12 and earlier, this would act like "ptx F1 F1" -["2files", '-g1 -w1', {IN=>{F1=>"a"}}, {IN=>{F2=>"b"}}, {OUT=>" a\n b\n"}], -); - -@Tests = triple_test \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/ptx-overrun b/tests/misc/ptx-overrun deleted file mode 100755 index e7eaf0b3d..000000000 --- a/tests/misc/ptx-overrun +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Trigger a heap-clobbering bug in ptx from coreutils-6.10 and earlier. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ ptx - -# Using a long file name makes an abort more likely. -# Even with no file name, valgrind detects the buffer overrun. -f=01234567890123456789012345678901234567890123456789 -touch $f empty || framework_failure_ - - -# Specifying a regular expression ending in a lone backslash -# would cause ptx to write beyond the end of a malloc'd buffer. -ptx -F '\' $f < /dev/null > out || fail=1 -ptx -S 'foo\' $f < /dev/null >> out || fail=1 -ptx -W 'bar\\\' $f < /dev/null >> out || fail=1 -compare out empty || fail=1 - -Exit $fail diff --git a/tests/misc/ptx-overrun.sh b/tests/misc/ptx-overrun.sh new file mode 100755 index 000000000..e7eaf0b3d --- /dev/null +++ b/tests/misc/ptx-overrun.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Trigger a heap-clobbering bug in ptx from coreutils-6.10 and earlier. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ ptx + +# Using a long file name makes an abort more likely. +# Even with no file name, valgrind detects the buffer overrun. +f=01234567890123456789012345678901234567890123456789 +touch $f empty || framework_failure_ + + +# Specifying a regular expression ending in a lone backslash +# would cause ptx to write beyond the end of a malloc'd buffer. +ptx -F '\' $f < /dev/null > out || fail=1 +ptx -S 'foo\' $f < /dev/null >> out || fail=1 +ptx -W 'bar\\\' $f < /dev/null >> out || fail=1 +compare out empty || fail=1 + +Exit $fail diff --git a/tests/misc/ptx.pl b/tests/misc/ptx.pl new file mode 100755 index 000000000..50ee0e8d6 --- /dev/null +++ b/tests/misc/ptx.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'ptx'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = +( +["1tok", '-w10', {IN=>"bar\n"}, {OUT=>" bar\n"}], +["2tok", '-w10', {IN=>"foo bar\n"}, {OUT=>" / bar\n foo/\n"}], + +# with coreutils-6.12 and earlier, this would infloop with -wN, N < 10 +["narrow", '-w2', {IN=>"qux\n"}, {OUT=>" qux\n"}], +["narrow-g", '-g1 -w2', {IN=>"ta\n"}, {OUT=>" ta\n"}], + +# with coreutils-6.12 and earlier, this would act like "ptx F1 F1" +["2files", '-g1 -w1', {IN=>{F1=>"a"}}, {IN=>{F2=>"b"}}, {OUT=>" a\n b\n"}], +); + +@Tests = triple_test \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long deleted file mode 100755 index 051509a7d..000000000 --- a/tests/misc/pwd-long +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh -# -*- perl -*- -# Ensure that pwd works even when run from a very deep directory. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ pwd - -require_readable_root_ -require_perl_ - -ARGV_0=$0 -export ARGV_0 - -# Don't use CuTmpdir here, since File::Temp's use of rmtree can't -# remove the deep tree we create. -$PERL -Tw -I"$abs_srcdir" -MCuSkip -- - <<\EOF - -# Show that pwd works even when the length of the resulting -# directory name is longer than PATH_MAX. -use strict; - -(my $ME = $ENV{ARGV_0}) =~ s|.*/||; - -sub normalize_to_cwd_relative ($$$) -{ - my ($dir, $dev, $ino) = @_; - my $slash = -1; - my $next_slash; - while (1) - { - $slash = index $dir, '/', $slash + 1; - $slash <= -1 - and die "$ME: $dir does not contain old CWD\n"; - my $dir_prefix = $slash ? substr ($dir, 0, $slash) : '/'; - my ($d, $i) = (stat $dir_prefix)[0, 1]; - defined $d && defined $i - or die "$ME: $dir_prefix: stat failed: $!\n"; - $d eq $dev && $i eq $ino - and return substr $dir, $slash + 1; - } -} - -# Set up a safe, well-known environment -delete @ENV{qw(BASH_ENV CDPATH ENV)}; -$ENV{IFS} = ''; - -# Taint checking requires a sanitized $PATH. This script performs no $PATH -# search, so on most Unix-based systems, it is fine simply to clear $ENV{PATH}. -# However, on Cygwin, it's used to find cygwin1.dll, so set it. -$ENV{PATH} = '/bin:/usr/bin'; - -# Save CWD's device and inode numbers. -my ($dev, $ino) = (stat '.')[0, 1]; - -# Construct the expected "."-relative part of pwd's output. -my $z = 'z' x 31; -my $n = 256; -my $expected = "/$z" x $n; -# Remove the leading "/". -substr ($expected, 0, 1) = ''; - -my $i = 0; -do - { - mkdir $z, 0700 - or CuSkip::skip "$ME: skipping this test; cannot create long " - . "directory name at depth $i: $!\n"; - chdir $z - } -until (++$i == $n); - -my $abs_top_builddir = $ENV{abs_top_builddir}; -$abs_top_builddir - or die "$ME: envvar abs_top_builddir not defined\n"; -my $build_src_dir = "$abs_top_builddir/src"; -$build_src_dir =~ m!^([-+.:/\w]+)$! - or CuSkip::skip "$ME: skipping this test; odd build source directory name:\n" - . "$build_src_dir\n"; -$build_src_dir = $1; - -my $pwd_binary = "$build_src_dir/pwd"; - --x $pwd_binary - or die "$ME: $pwd_binary is not an executable file\n"; -chomp (my $actual = qx!$pwd_binary!); - -# Convert the absolute name from pwd into a $CWD-relative name. -# This is necessary in order to avoid a spurious failure when run -# from a directory in a bind-mounted partition. What happens is -# pwd reads a ".." that contains two or more entries with identical -# dev,ino that match the ones we're looking for, and it chooses a -# name that does not correspond to the one already recorded in $CWD. -$actual = normalize_to_cwd_relative $actual, $dev, $ino; - -if ($expected ne $actual) - { - my $e_len = length $expected; - my $a_len = length $actual; - warn "expected len: $e_len\n"; - warn "actual len: $a_len\n"; - warn "expected: $expected\n"; - warn "actual: $actual\n"; - exit 1; - } -EOF - -fail=$? - -Exit $fail diff --git a/tests/misc/pwd-long.sh b/tests/misc/pwd-long.sh new file mode 100755 index 000000000..051509a7d --- /dev/null +++ b/tests/misc/pwd-long.sh @@ -0,0 +1,124 @@ +#!/bin/sh +# -*- perl -*- +# Ensure that pwd works even when run from a very deep directory. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ pwd + +require_readable_root_ +require_perl_ + +ARGV_0=$0 +export ARGV_0 + +# Don't use CuTmpdir here, since File::Temp's use of rmtree can't +# remove the deep tree we create. +$PERL -Tw -I"$abs_srcdir" -MCuSkip -- - <<\EOF + +# Show that pwd works even when the length of the resulting +# directory name is longer than PATH_MAX. +use strict; + +(my $ME = $ENV{ARGV_0}) =~ s|.*/||; + +sub normalize_to_cwd_relative ($$$) +{ + my ($dir, $dev, $ino) = @_; + my $slash = -1; + my $next_slash; + while (1) + { + $slash = index $dir, '/', $slash + 1; + $slash <= -1 + and die "$ME: $dir does not contain old CWD\n"; + my $dir_prefix = $slash ? substr ($dir, 0, $slash) : '/'; + my ($d, $i) = (stat $dir_prefix)[0, 1]; + defined $d && defined $i + or die "$ME: $dir_prefix: stat failed: $!\n"; + $d eq $dev && $i eq $ino + and return substr $dir, $slash + 1; + } +} + +# Set up a safe, well-known environment +delete @ENV{qw(BASH_ENV CDPATH ENV)}; +$ENV{IFS} = ''; + +# Taint checking requires a sanitized $PATH. This script performs no $PATH +# search, so on most Unix-based systems, it is fine simply to clear $ENV{PATH}. +# However, on Cygwin, it's used to find cygwin1.dll, so set it. +$ENV{PATH} = '/bin:/usr/bin'; + +# Save CWD's device and inode numbers. +my ($dev, $ino) = (stat '.')[0, 1]; + +# Construct the expected "."-relative part of pwd's output. +my $z = 'z' x 31; +my $n = 256; +my $expected = "/$z" x $n; +# Remove the leading "/". +substr ($expected, 0, 1) = ''; + +my $i = 0; +do + { + mkdir $z, 0700 + or CuSkip::skip "$ME: skipping this test; cannot create long " + . "directory name at depth $i: $!\n"; + chdir $z + } +until (++$i == $n); + +my $abs_top_builddir = $ENV{abs_top_builddir}; +$abs_top_builddir + or die "$ME: envvar abs_top_builddir not defined\n"; +my $build_src_dir = "$abs_top_builddir/src"; +$build_src_dir =~ m!^([-+.:/\w]+)$! + or CuSkip::skip "$ME: skipping this test; odd build source directory name:\n" + . "$build_src_dir\n"; +$build_src_dir = $1; + +my $pwd_binary = "$build_src_dir/pwd"; + +-x $pwd_binary + or die "$ME: $pwd_binary is not an executable file\n"; +chomp (my $actual = qx!$pwd_binary!); + +# Convert the absolute name from pwd into a $CWD-relative name. +# This is necessary in order to avoid a spurious failure when run +# from a directory in a bind-mounted partition. What happens is +# pwd reads a ".." that contains two or more entries with identical +# dev,ino that match the ones we're looking for, and it chooses a +# name that does not correspond to the one already recorded in $CWD. +$actual = normalize_to_cwd_relative $actual, $dev, $ino; + +if ($expected ne $actual) + { + my $e_len = length $expected; + my $a_len = length $actual; + warn "expected len: $e_len\n"; + warn "actual len: $a_len\n"; + warn "expected: $expected\n"; + warn "actual: $actual\n"; + exit 1; + } +EOF + +fail=$? + +Exit $fail diff --git a/tests/misc/pwd-option b/tests/misc/pwd-option deleted file mode 100755 index a7a4737e5..000000000 --- a/tests/misc/pwd-option +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh -# Ensure that pwd options work. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ pwd - -mkdir -p a/b || framework_failure_ -ln -s a/b c || framework_failure_ -base=$(env -- pwd) - -# Remove any logical paths from $PWD. -cd "$base" || framework_failure_ -test "x$PWD" = "x$base" || framework_failure_ - -# Enter a logical directory. -cd c || framework_failure_ -test "x$PWD" = "x$base/c" || skip_ "cd does not properly update \$PWD" - -env -- pwd -L > out || fail=1 -printf %s\\n "$base/c" > exp || fail=1 - -env -- pwd --logical -P >> out || fail=1 -printf %s\\n "$base/a/b" >> exp || fail=1 - -env -- pwd --physical >> out || fail=1 -printf %s\\n "$base/a/b" >> exp || fail=1 - -# By default, we use -P unless POSIXLY_CORRECT. -env -- pwd >> out || fail=1 -printf %s\\n "$base/a/b" >> exp || fail=1 - -env -- POSIXLY_CORRECT=1 pwd >> out || fail=1 -printf %s\\n "$base/c" >> exp || fail=1 - -# Make sure we reject bogus values, and silently fall back to -P. -env -- PWD="$PWD/." pwd -L >> out || fail=1 -printf %s\\n "$base/a/b" >> exp || fail=1 - -env -- PWD=bogus pwd -L >> out || fail=1 -printf %s\\n "$base/a/b" >> exp || fail=1 - -env -- PWD="$base/a/../c" pwd -L >> out || fail=1 -printf %s\\n "$base/a/b" >> exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/pwd-option.sh b/tests/misc/pwd-option.sh new file mode 100755 index 000000000..a7a4737e5 --- /dev/null +++ b/tests/misc/pwd-option.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# Ensure that pwd options work. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ pwd + +mkdir -p a/b || framework_failure_ +ln -s a/b c || framework_failure_ +base=$(env -- pwd) + +# Remove any logical paths from $PWD. +cd "$base" || framework_failure_ +test "x$PWD" = "x$base" || framework_failure_ + +# Enter a logical directory. +cd c || framework_failure_ +test "x$PWD" = "x$base/c" || skip_ "cd does not properly update \$PWD" + +env -- pwd -L > out || fail=1 +printf %s\\n "$base/c" > exp || fail=1 + +env -- pwd --logical -P >> out || fail=1 +printf %s\\n "$base/a/b" >> exp || fail=1 + +env -- pwd --physical >> out || fail=1 +printf %s\\n "$base/a/b" >> exp || fail=1 + +# By default, we use -P unless POSIXLY_CORRECT. +env -- pwd >> out || fail=1 +printf %s\\n "$base/a/b" >> exp || fail=1 + +env -- POSIXLY_CORRECT=1 pwd >> out || fail=1 +printf %s\\n "$base/c" >> exp || fail=1 + +# Make sure we reject bogus values, and silently fall back to -P. +env -- PWD="$PWD/." pwd -L >> out || fail=1 +printf %s\\n "$base/a/b" >> exp || fail=1 + +env -- PWD=bogus pwd -L >> out || fail=1 +printf %s\\n "$base/a/b" >> exp || fail=1 + +env -- PWD="$base/a/../c" pwd -L >> out || fail=1 +printf %s\\n "$base/a/b" >> exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/readlink-fp-loop b/tests/misc/readlink-fp-loop deleted file mode 100755 index 65fab7827..000000000 --- a/tests/misc/readlink-fp-loop +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -# readlink from 6.9 would fail with a false-positive symlink loop error - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ readlink -cwd=$("$abs_top_builddir/src/pwd") - -# To trigger this bug, we have to construct a name/situation during -# the resolution of which the code dereferences the same symlink (S) -# two different times with no actual loop. In addition, arrange -# so that the second and fourth calls to readlink operate on S. - -ln -s s p || framework_failure_ -ln -s d s || framework_failure_ -mkdir d || framework_failure_ -echo 2 > d/2 || framework_failure_ -ln -s ../s/2 d/1 || framework_failure_ - -# With coreutils-6.9, this would fail with ELOOP. -readlink -v -e p/1 > out || fail=1 -# readlink -e d/2 > exp || fail=1 -echo "$cwd/d/2" > exp || fail=1 -compare exp out || fail=1 - -# Construct a real loop and make sure readlink still detects it. -ln -sf ../s/1 d/2 || framework_failure_ -readlink -v -e p/1 2> out && fail=1 -readlink_msg=$(cat out) -case $readlink_msg in - 'readlink: p/1: '*) ;; - *) fail=1;; -esac -symlink_loop_msg=${readlink_msg#'readlink: p/1: '} - -# Exercise the hash table code. -ln -nsf ../s/3 d/2 || framework_failure_ -ln -nsf ../p/4 d/3 || framework_failure_ -ln -nsf ../p/5 d/4 || framework_failure_ -ln -nsf ../p/6 d/5 || framework_failure_ -ln -nsf ../p/7 d/6 || framework_failure_ -ln -nsf ../p/8 d/7 || framework_failure_ -echo x > d/8 || framework_failure_ -readlink -v -e p/1 > out || fail=1 -echo "$cwd/d/8" > exp || fail=1 -compare exp out || fail=1 - -# A trivial loop -ln -s loop loop -readlink -v -e loop 2> out && fail=1 -echo "readlink: loop: $symlink_loop_msg" > exp || framework_failure_ -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/readlink-fp-loop.sh b/tests/misc/readlink-fp-loop.sh new file mode 100755 index 000000000..65fab7827 --- /dev/null +++ b/tests/misc/readlink-fp-loop.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# readlink from 6.9 would fail with a false-positive symlink loop error + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ readlink +cwd=$("$abs_top_builddir/src/pwd") + +# To trigger this bug, we have to construct a name/situation during +# the resolution of which the code dereferences the same symlink (S) +# two different times with no actual loop. In addition, arrange +# so that the second and fourth calls to readlink operate on S. + +ln -s s p || framework_failure_ +ln -s d s || framework_failure_ +mkdir d || framework_failure_ +echo 2 > d/2 || framework_failure_ +ln -s ../s/2 d/1 || framework_failure_ + +# With coreutils-6.9, this would fail with ELOOP. +readlink -v -e p/1 > out || fail=1 +# readlink -e d/2 > exp || fail=1 +echo "$cwd/d/2" > exp || fail=1 +compare exp out || fail=1 + +# Construct a real loop and make sure readlink still detects it. +ln -sf ../s/1 d/2 || framework_failure_ +readlink -v -e p/1 2> out && fail=1 +readlink_msg=$(cat out) +case $readlink_msg in + 'readlink: p/1: '*) ;; + *) fail=1;; +esac +symlink_loop_msg=${readlink_msg#'readlink: p/1: '} + +# Exercise the hash table code. +ln -nsf ../s/3 d/2 || framework_failure_ +ln -nsf ../p/4 d/3 || framework_failure_ +ln -nsf ../p/5 d/4 || framework_failure_ +ln -nsf ../p/6 d/5 || framework_failure_ +ln -nsf ../p/7 d/6 || framework_failure_ +ln -nsf ../p/8 d/7 || framework_failure_ +echo x > d/8 || framework_failure_ +readlink -v -e p/1 > out || fail=1 +echo "$cwd/d/8" > exp || fail=1 +compare exp out || fail=1 + +# A trivial loop +ln -s loop loop +readlink -v -e loop 2> out && fail=1 +echo "readlink: loop: $symlink_loop_msg" > exp || framework_failure_ +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/readlink-root b/tests/misc/readlink-root deleted file mode 100755 index f69bad6ad..000000000 --- a/tests/misc/readlink-root +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# tests for canonicalize-existing mode (readlink -e) on /. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ readlink - -stat_single=$(stat -c %d:%i /) || framework_failure_ -stat_double=$(stat -c %d:%i //) || framework_failure_ -double_slash=// -if test x"$stat_single" = x"$stat_double"; then - double_slash=/ -fi - -test -d /dev || framework_failure_ - -ln -s / one || framework_failure_ -ln -s // two || framework_failure_ -ln -s /// three || framework_failure_ -ln -s /./..// one-dots || framework_failure_ -ln -s //./..// two-dots || framework_failure_ -ln -s ///./..// three-dots || framework_failure_ -ln -s /dev one-dev || framework_failure_ -ln -s //dev two-dev || framework_failure_ -ln -s ///dev three-dev || framework_failure_ - -cat >exp < out - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/readlink-root.sh b/tests/misc/readlink-root.sh new file mode 100755 index 000000000..f69bad6ad --- /dev/null +++ b/tests/misc/readlink-root.sh @@ -0,0 +1,92 @@ +#!/bin/sh +# tests for canonicalize-existing mode (readlink -e) on /. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ readlink + +stat_single=$(stat -c %d:%i /) || framework_failure_ +stat_double=$(stat -c %d:%i //) || framework_failure_ +double_slash=// +if test x"$stat_single" = x"$stat_double"; then + double_slash=/ +fi + +test -d /dev || framework_failure_ + +ln -s / one || framework_failure_ +ln -s // two || framework_failure_ +ln -s /// three || framework_failure_ +ln -s /./..// one-dots || framework_failure_ +ln -s //./..// two-dots || framework_failure_ +ln -s ///./..// three-dots || framework_failure_ +ln -s /dev one-dev || framework_failure_ +ln -s //dev two-dev || framework_failure_ +ln -s ///dev three-dev || framework_failure_ + +cat >exp < out + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/realpath b/tests/misc/realpath deleted file mode 100755 index 9484ac4c8..000000000 --- a/tests/misc/realpath +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/sh -# Validate realpath operation - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ realpath - -stat_single=$(stat -c %d:%i /) || framework_failure_ -stat_double=$(stat -c %d:%i //) || framework_failure_ -double_slash=// -if test x"$stat_single" = x"$stat_double"; then - double_slash=/ -fi -nl=' -' - -test -d /dev || framework_failure_ - -# Setup dir, file, symlink structure - -mkdir -p dir1/dir2 || framework_failure_ -ln -s dir1/dir2 ldir2 || framework_failure_ -touch dir1/f dir1/dir2/f || framework_failure_ -ln -s / one || framework_failure_ -ln -s // two || framework_failure_ -ln -s /// three || framework_failure_ - -# Basic operation -realpath -Pqz . >/dev/null || fail=1 -# Operand is required -realpath >/dev/null && fail=1 -realpath --relative-base . --relative-to . && fail=1 -realpath --relative-base . && fail=1 - -# -e --relative-* require directories -realpath -e --relative-to=dir1/f --relative-base=. . && fail=1 -realpath -e --relative-to=dir1/ --relative-base=. . || fail=1 - -# Note NUL params are unconditionally rejected by canonicalize_filename_mode -realpath -m '' && fail=1 -realpath --relative-base= --relative-to=. . && fail=1 - -# symlink resolution -this=$(realpath .) -test "$(realpath ldir2/..)" = "$this/dir1" || fail=1 -test "$(realpath -L ldir2/..)" = "$this" || fail=1 -test "$(realpath -s ldir2)" = "$this/ldir2" || fail=1 - -# relative string handling -test $(realpath -m --relative-to=prefix prefixed/1) = '../prefixed/1' || fail=1 -test $(realpath -m --relative-to=prefixed prefix/1) = '../prefix/1' || fail=1 -test $(realpath -m --relative-to=prefixed prefixed/1) = '1' || fail=1 - -# Ensure no redundant trailing '/' present, as was the case in v8.15 -test $(realpath -sm --relative-to=/usr /) = '..' || fail=1 -# Ensure no redundant leading '../' present, as was the case in v8.15 -test $(realpath -sm --relative-to=/ /usr) = 'usr' || fail=1 - -# Ensure --relative-base works -out=$(realpath -sm --relative-base=/usr --relative-to=/usr /tmp /usr) || fail=1 -test "$out" = "/tmp$nl." || fail=1 -out=$(realpath -sm --relative-base=/ --relative-to=/ / /usr) || fail=1 -test "$out" = ".${nl}usr" || fail=1 -# --relative-to defaults to the value of --relative-base -out=$(realpath -sm --relative-base=/usr /tmp /usr) || fail=1 -test "$out" = "/tmp$nl." || fail=1 -out=$(realpath -sm --relative-base=/ / /usr) || fail=1 -test "$out" = ".${nl}usr" || fail=1 -# For now, --relative-base must be a prefix of --relative-to, or all output -# will be absolute (compare to MacOS 'relpath -d dir start end'). -out=$(realpath -sm --relative-base=/usr/local --relative-to=/usr \ - /usr /usr/local) || fail=1 -test "$out" = "/usr${nl}/usr/local" || fail=1 - -# Ensure // is handled correctly. -test "$(realpath / // ///)" = "/$nl$double_slash$nl/" || fail=1 -test "$(realpath one two three)" = "/$nl$double_slash$nl/" || fail=1 -out=$(realpath -sm --relative-to=/ / // /dev //dev) || fail=1 -if test $double_slash = //; then - test "$out" = ".$nl//${nl}dev$nl//dev" || fail=1 -else - test "$out" = ".$nl.${nl}dev${nl}dev" || fail=1 -fi -out=$(realpath -sm --relative-to=// / // /dev //dev) || fail=1 -if test $double_slash = //; then - test "$out" = "/$nl.$nl/dev${nl}dev" || fail=1 -else - test "$out" = ".$nl.${nl}dev${nl}dev" || fail=1 -fi -out=$(realpath --relative-base=/ --relative-to=// / //) || fail=1 -if test $double_slash = //; then - test "$out" = "/$nl//" || fail=1 -else - test "$out" = ".$nl." || fail=1 -fi - -Exit $fail diff --git a/tests/misc/realpath.sh b/tests/misc/realpath.sh new file mode 100755 index 000000000..9484ac4c8 --- /dev/null +++ b/tests/misc/realpath.sh @@ -0,0 +1,111 @@ +#!/bin/sh +# Validate realpath operation + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ realpath + +stat_single=$(stat -c %d:%i /) || framework_failure_ +stat_double=$(stat -c %d:%i //) || framework_failure_ +double_slash=// +if test x"$stat_single" = x"$stat_double"; then + double_slash=/ +fi +nl=' +' + +test -d /dev || framework_failure_ + +# Setup dir, file, symlink structure + +mkdir -p dir1/dir2 || framework_failure_ +ln -s dir1/dir2 ldir2 || framework_failure_ +touch dir1/f dir1/dir2/f || framework_failure_ +ln -s / one || framework_failure_ +ln -s // two || framework_failure_ +ln -s /// three || framework_failure_ + +# Basic operation +realpath -Pqz . >/dev/null || fail=1 +# Operand is required +realpath >/dev/null && fail=1 +realpath --relative-base . --relative-to . && fail=1 +realpath --relative-base . && fail=1 + +# -e --relative-* require directories +realpath -e --relative-to=dir1/f --relative-base=. . && fail=1 +realpath -e --relative-to=dir1/ --relative-base=. . || fail=1 + +# Note NUL params are unconditionally rejected by canonicalize_filename_mode +realpath -m '' && fail=1 +realpath --relative-base= --relative-to=. . && fail=1 + +# symlink resolution +this=$(realpath .) +test "$(realpath ldir2/..)" = "$this/dir1" || fail=1 +test "$(realpath -L ldir2/..)" = "$this" || fail=1 +test "$(realpath -s ldir2)" = "$this/ldir2" || fail=1 + +# relative string handling +test $(realpath -m --relative-to=prefix prefixed/1) = '../prefixed/1' || fail=1 +test $(realpath -m --relative-to=prefixed prefix/1) = '../prefix/1' || fail=1 +test $(realpath -m --relative-to=prefixed prefixed/1) = '1' || fail=1 + +# Ensure no redundant trailing '/' present, as was the case in v8.15 +test $(realpath -sm --relative-to=/usr /) = '..' || fail=1 +# Ensure no redundant leading '../' present, as was the case in v8.15 +test $(realpath -sm --relative-to=/ /usr) = 'usr' || fail=1 + +# Ensure --relative-base works +out=$(realpath -sm --relative-base=/usr --relative-to=/usr /tmp /usr) || fail=1 +test "$out" = "/tmp$nl." || fail=1 +out=$(realpath -sm --relative-base=/ --relative-to=/ / /usr) || fail=1 +test "$out" = ".${nl}usr" || fail=1 +# --relative-to defaults to the value of --relative-base +out=$(realpath -sm --relative-base=/usr /tmp /usr) || fail=1 +test "$out" = "/tmp$nl." || fail=1 +out=$(realpath -sm --relative-base=/ / /usr) || fail=1 +test "$out" = ".${nl}usr" || fail=1 +# For now, --relative-base must be a prefix of --relative-to, or all output +# will be absolute (compare to MacOS 'relpath -d dir start end'). +out=$(realpath -sm --relative-base=/usr/local --relative-to=/usr \ + /usr /usr/local) || fail=1 +test "$out" = "/usr${nl}/usr/local" || fail=1 + +# Ensure // is handled correctly. +test "$(realpath / // ///)" = "/$nl$double_slash$nl/" || fail=1 +test "$(realpath one two three)" = "/$nl$double_slash$nl/" || fail=1 +out=$(realpath -sm --relative-to=/ / // /dev //dev) || fail=1 +if test $double_slash = //; then + test "$out" = ".$nl//${nl}dev$nl//dev" || fail=1 +else + test "$out" = ".$nl.${nl}dev${nl}dev" || fail=1 +fi +out=$(realpath -sm --relative-to=// / // /dev //dev) || fail=1 +if test $double_slash = //; then + test "$out" = "/$nl.$nl/dev${nl}dev" || fail=1 +else + test "$out" = ".$nl.${nl}dev${nl}dev" || fail=1 +fi +out=$(realpath --relative-base=/ --relative-to=// / //) || fail=1 +if test $double_slash = //; then + test "$out" = "/$nl//" || fail=1 +else + test "$out" = ".$nl." || fail=1 +fi + +Exit $fail diff --git a/tests/misc/runcon-no-reorder b/tests/misc/runcon-no-reorder deleted file mode 100755 index 351896ef8..000000000 --- a/tests/misc/runcon-no-reorder +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# Ensure that runcon does not reorder its arguments. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ runcon - -diag='runcon: runcon may be used only on a SELinux kernel' -echo "$diag" > exp || framework_failure_ - - -# This test works even on systems without SELinux. -# On such a system it fails with the above diagnostic, which is fine. -# Before the no-reorder change, it would have failed with a diagnostic -# about -j being an invalid option. -runcon $(id -Z) true -j 2> out && : > exp - -# When run on a system with no /selinux/context (i.e., in a chroot), -# it chcon fails with this: "runcon: invalid context: \ -# root:system_r:unconfined_t:s0-s0:c0.c1023: No such file or directory" -# That diagnostic is ok, too, so map it to the more common one. -case $(cat out) in - 'runcon: invalid context: '*) echo "$diag" > out;; -esac - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/runcon-no-reorder.sh b/tests/misc/runcon-no-reorder.sh new file mode 100755 index 000000000..351896ef8 --- /dev/null +++ b/tests/misc/runcon-no-reorder.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Ensure that runcon does not reorder its arguments. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ runcon + +diag='runcon: runcon may be used only on a SELinux kernel' +echo "$diag" > exp || framework_failure_ + + +# This test works even on systems without SELinux. +# On such a system it fails with the above diagnostic, which is fine. +# Before the no-reorder change, it would have failed with a diagnostic +# about -j being an invalid option. +runcon $(id -Z) true -j 2> out && : > exp + +# When run on a system with no /selinux/context (i.e., in a chroot), +# it chcon fails with this: "runcon: invalid context: \ +# root:system_r:unconfined_t:s0-s0:c0.c1023: No such file or directory" +# That diagnostic is ok, too, so map it to the more common one. +case $(cat out) in + 'runcon: invalid context: '*) echo "$diag" > out;; +esac + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/selinux b/tests/misc/selinux deleted file mode 100755 index 12ae15f4e..000000000 --- a/tests/misc/selinux +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# Test SELinux-related options. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ chcon cp ls mv stat - -require_root_ -require_selinux_ -skip_if_mcstransd_is_running_ - -# Create a regular file, dir, fifo. -touch f || framework_failure_ -mkdir d s1 s2 || framework_failure_ -mkfifo_or_skip_ p - - -# special context that works both with and without mcstransd -ctx=root:object_r:tmp_t:s0 - -chcon $ctx f d p || - skip_ '"chcon '$ctx' ..." failed' - -# inspect that context with both ls -Z and stat. -for i in d f p; do - c=$(ls -dogZ $i|cut -d' ' -f3); test x$c = x$ctx || fail=1 - c=$(stat --printf %C $i); test x$c = x$ctx || fail=1 -done - -# ensure that ls -l output includes the ".". -c=$(ls -l f|cut -c11); test "$c" = . || fail=1 - -# Copy each to a new directory and ensure that context is preserved. -cp -r --preserve=all d f p s1 || fail=1 -for i in d f p; do - c=$(stat --printf %C s1/$i); test x$c = x$ctx || fail=1 -done - -# Now, move each to a new directory and ensure that context is preserved. -mv d f p s2 || fail=1 -for i in d f p; do - c=$(stat --printf %C s2/$i); test x$c = x$ctx || fail=1 -done - -Exit $fail diff --git a/tests/misc/selinux.sh b/tests/misc/selinux.sh new file mode 100755 index 000000000..12ae15f4e --- /dev/null +++ b/tests/misc/selinux.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# Test SELinux-related options. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ chcon cp ls mv stat + +require_root_ +require_selinux_ +skip_if_mcstransd_is_running_ + +# Create a regular file, dir, fifo. +touch f || framework_failure_ +mkdir d s1 s2 || framework_failure_ +mkfifo_or_skip_ p + + +# special context that works both with and without mcstransd +ctx=root:object_r:tmp_t:s0 + +chcon $ctx f d p || + skip_ '"chcon '$ctx' ..." failed' + +# inspect that context with both ls -Z and stat. +for i in d f p; do + c=$(ls -dogZ $i|cut -d' ' -f3); test x$c = x$ctx || fail=1 + c=$(stat --printf %C $i); test x$c = x$ctx || fail=1 +done + +# ensure that ls -l output includes the ".". +c=$(ls -l f|cut -c11); test "$c" = . || fail=1 + +# Copy each to a new directory and ensure that context is preserved. +cp -r --preserve=all d f p s1 || fail=1 +for i in d f p; do + c=$(stat --printf %C s1/$i); test x$c = x$ctx || fail=1 +done + +# Now, move each to a new directory and ensure that context is preserved. +mv d f p s2 || fail=1 +for i in d f p; do + c=$(stat --printf %C s2/$i); test x$c = x$ctx || fail=1 +done + +Exit $fail diff --git a/tests/misc/seq b/tests/misc/seq deleted file mode 100755 index 2517d9993..000000000 --- a/tests/misc/seq +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/perl -# Test "seq". - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = 'seq'; -my $try_help = "Try '$prog --help' for more information.\n"; - -my $locale = $ENV{LOCALE_FR_UTF8}; -! defined $locale || $locale eq 'none' - and $locale = 'C'; - -my @Tests = - ( - ['onearg-1', qw(10), {OUT => [(1..10)]}], - ['onearg-2', qw(-1)], - ['empty-rev', qw(1 -1 3)], - ['neg-1', qw(-10 10 10), {OUT => [qw(-10 0 10)]}], - # ['neg-2', qw(-.1 .1 .11), {OUT => [qw(-0.1 0.0 0.1)]}], - ['neg-3', qw(1 -1 0), {OUT => [qw(1 0)]}], - ['neg-4', qw(1 -1 -1), {OUT => [qw(1 0 -1)]}], - - ['float-1', qw(0.8 0.1 0.9), {OUT => [qw(0.8 0.9)]}], - ['float-2', qw(0.1 0.99 1.99), {OUT => [qw(0.10 1.09)]}], - ['float-3', qw(10.8 0.1 10.95), {OUT => [qw(10.8 10.9)]}], - ['float-4', qw(0.1 -0.1 -0.2), {OUT => [qw(0.1 0.0 -0.1 -0.2)]}, - {OUT_SUBST => 's,^-0\.0$,0.0,'}, - ], - ['float-5', qw(0.8 1e-1 0.9), {OUT => [qw(0.8 0.9)]}], - # Don't append lots of zeros to that 0.9000...; for example, changing the - # number to 0.90000000000000000000 tickles a bug in Solaris 8 strtold - # that would cause the test to fail. - ['float-6', qw(0.8 0.1 0.9000000000000), {OUT => [qw(0.8 0.9)]}], - - ['wid-1', qw(.8 1e-2 .81), {OUT => [qw(0.80 0.81)]}], - ['wid-2', qw(.89999 1e-7 .8999901), {OUT => [qw(0.8999900 0.8999901)]}], - - ['eq-wid-1', qw(-w 1 -1 -1), {OUT => [qw(01 00 -1)]}], - # Prior to 2.0g, this test would fail on e.g., HPUX systems - # because it'd end up using %3.1f as the format instead of %4.1f. - ['eq-wid-2', qw(-w -.1 .1 .11),{OUT => [qw(-0.1 00.0 00.1)]}], - ['eq-wid-3', qw(-w 1 3.0), {OUT => [qw(1 2 3)]}], - ['eq-wid-4', qw(-w .8 1e-2 .81), {OUT => [qw(0.80 0.81)]}], - ['eq-wid-5', qw(-w 1 .5 2), {OUT => [qw(1.0 1.5 2.0)]}], - ['eq-wid-6', qw(-w +1 2), {OUT => [qw(1 2)]}], - ['eq-wid-7', qw(-w " .1" " .1"), {OUT => [qw(0.1)]}], - ['eq-wid-8', qw(-w 9 0.5 10), {OUT => [qw(09.0 09.5 10.0)]}], - - # Prior to coreutils-4.5.11, some of these were not accepted. - ['fmt-1', qw(-f %2.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}], - ['fmt-2', qw(-f %0.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}], - ['fmt-3', qw(-f %.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}], - - ['fmt-4', qw(-f %3.0f 1 2), {OUT => [' 1', ' 2']}], - ['fmt-5', qw(-f %-3.0f 1 2), {OUT => ['1 ', '2 ']}], - ['fmt-6', qw(-f %+3.0f 1 2), {OUT => [' +1', ' +2']}], - ['fmt-7', qw(-f %0+3.0f 1 2), {OUT => [qw(+01 +02)]}], - ['fmt-8', qw(-f %0+.0f 1 2), {OUT => [qw(+1 +2)]}], - ['fmt-9', '-f "% -3.0f"', qw(-1 0), {OUT => ['-1 ', ' 0 ']}], - ['fmt-a', '-f "% -.0f"',qw(-1 0), {OUT => ['-1', ' 0']}], - ['fmt-b', qw(-f %%%g%% 1), {OUT => ['%1%']}], - - # In coreutils-[6.0..6.9], this would mistakenly succeed and print "%Lg". - ['fmt-c', qw(-f %%g 1), {EXIT => 1}, - {ERR => "seq: format '%%g' has no % directive\n"}], - - # In coreutils-6.9..6.10, this would fail with an erroneous diagnostic: - # "seq: memory exhausted". In coreutils-6.0..6.8, it would mistakenly - # succeed and print a blank line. - ['fmt-eos1', qw(-f % 1), {EXIT => 1}, - {ERR => "seq: format '%' ends in %\n"}], - ['fmt-eos2', qw(-f %g% 1), {EXIT => 1}, - {ERR => "seq: format '%g%' has too many % directives\n"}], - - ['fmt-d', qw(-f "" 1), {EXIT => 1}, - {ERR => "seq: format '' has no % directive\n"}], - ['fmt-e', qw(-f %g%g 1), {EXIT => 1}, - {ERR => "seq: format '%g%g' has too many % directives\n"}], - - # With coreutils-6.12 and earlier, with a UTF8 numeric locale that uses - # something other than "." as the decimal point, this use of seq would - # fail to print the "2,0" endpoint. - ['locale-dec-pt', qw(-0.1 0.1 2), - {OUT => [qw(-0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 - 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0)]}, - - {ENV => "LC_ALL=$locale"}, - {OUT_SUBST => 's/,/./g'}, - ], - ); - -# Append a newline to each entry in the OUT array. -my $t; -foreach $t (@Tests) - { - my $e; - foreach $e (@$t) - { - $e->{OUT} = join ("\n", @{$e->{OUT}}) . "\n" - if ref $e eq 'HASH' and exists $e->{OUT}; - } - } - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/seq-long-double b/tests/misc/seq-long-double deleted file mode 100755 index 5a511d709..000000000 --- a/tests/misc/seq-long-double +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# Test for this fix: 461231f022bdb3ee392622d31dc475034adceeb2. -# Ensure that seq prints exactly two numbers for a 2-number integral -# range at the limit of floating point precision. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ seq -getlimits_ - -# Run this test only with glibc and sizeof (long double) > sizeof (double). -# Otherwise, there are known failures: -# http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14939/focus=14944 -cat <<\EOF > long.c -#include -#if defined __GNU_LIBRARY__ && __GLIBC__ >= 2 -int foo[sizeof (long double) - sizeof (double) - 1]; -#else -"run this test only with glibc" -#endif -EOF -$CC -c long.c \ - || skip_ \ - 'this test runs only on systems with glibc and long double != double' - -a=$INTMAX_MAX -b=$INTMAX_OFLOW - -seq $a $b > out || fail=1 -printf "$a\n$b\n" > exp || fail=1 -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/seq-long-double.sh b/tests/misc/seq-long-double.sh new file mode 100755 index 000000000..5a511d709 --- /dev/null +++ b/tests/misc/seq-long-double.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Test for this fix: 461231f022bdb3ee392622d31dc475034adceeb2. +# Ensure that seq prints exactly two numbers for a 2-number integral +# range at the limit of floating point precision. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ seq +getlimits_ + +# Run this test only with glibc and sizeof (long double) > sizeof (double). +# Otherwise, there are known failures: +# http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14939/focus=14944 +cat <<\EOF > long.c +#include +#if defined __GNU_LIBRARY__ && __GLIBC__ >= 2 +int foo[sizeof (long double) - sizeof (double) - 1]; +#else +"run this test only with glibc" +#endif +EOF +$CC -c long.c \ + || skip_ \ + 'this test runs only on systems with glibc and long double != double' + +a=$INTMAX_MAX +b=$INTMAX_OFLOW + +seq $a $b > out || fail=1 +printf "$a\n$b\n" > exp || fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/seq.pl b/tests/misc/seq.pl new file mode 100755 index 000000000..2517d9993 --- /dev/null +++ b/tests/misc/seq.pl @@ -0,0 +1,128 @@ +#!/usr/bin/perl +# Test "seq". + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = 'seq'; +my $try_help = "Try '$prog --help' for more information.\n"; + +my $locale = $ENV{LOCALE_FR_UTF8}; +! defined $locale || $locale eq 'none' + and $locale = 'C'; + +my @Tests = + ( + ['onearg-1', qw(10), {OUT => [(1..10)]}], + ['onearg-2', qw(-1)], + ['empty-rev', qw(1 -1 3)], + ['neg-1', qw(-10 10 10), {OUT => [qw(-10 0 10)]}], + # ['neg-2', qw(-.1 .1 .11), {OUT => [qw(-0.1 0.0 0.1)]}], + ['neg-3', qw(1 -1 0), {OUT => [qw(1 0)]}], + ['neg-4', qw(1 -1 -1), {OUT => [qw(1 0 -1)]}], + + ['float-1', qw(0.8 0.1 0.9), {OUT => [qw(0.8 0.9)]}], + ['float-2', qw(0.1 0.99 1.99), {OUT => [qw(0.10 1.09)]}], + ['float-3', qw(10.8 0.1 10.95), {OUT => [qw(10.8 10.9)]}], + ['float-4', qw(0.1 -0.1 -0.2), {OUT => [qw(0.1 0.0 -0.1 -0.2)]}, + {OUT_SUBST => 's,^-0\.0$,0.0,'}, + ], + ['float-5', qw(0.8 1e-1 0.9), {OUT => [qw(0.8 0.9)]}], + # Don't append lots of zeros to that 0.9000...; for example, changing the + # number to 0.90000000000000000000 tickles a bug in Solaris 8 strtold + # that would cause the test to fail. + ['float-6', qw(0.8 0.1 0.9000000000000), {OUT => [qw(0.8 0.9)]}], + + ['wid-1', qw(.8 1e-2 .81), {OUT => [qw(0.80 0.81)]}], + ['wid-2', qw(.89999 1e-7 .8999901), {OUT => [qw(0.8999900 0.8999901)]}], + + ['eq-wid-1', qw(-w 1 -1 -1), {OUT => [qw(01 00 -1)]}], + # Prior to 2.0g, this test would fail on e.g., HPUX systems + # because it'd end up using %3.1f as the format instead of %4.1f. + ['eq-wid-2', qw(-w -.1 .1 .11),{OUT => [qw(-0.1 00.0 00.1)]}], + ['eq-wid-3', qw(-w 1 3.0), {OUT => [qw(1 2 3)]}], + ['eq-wid-4', qw(-w .8 1e-2 .81), {OUT => [qw(0.80 0.81)]}], + ['eq-wid-5', qw(-w 1 .5 2), {OUT => [qw(1.0 1.5 2.0)]}], + ['eq-wid-6', qw(-w +1 2), {OUT => [qw(1 2)]}], + ['eq-wid-7', qw(-w " .1" " .1"), {OUT => [qw(0.1)]}], + ['eq-wid-8', qw(-w 9 0.5 10), {OUT => [qw(09.0 09.5 10.0)]}], + + # Prior to coreutils-4.5.11, some of these were not accepted. + ['fmt-1', qw(-f %2.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}], + ['fmt-2', qw(-f %0.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}], + ['fmt-3', qw(-f %.1f 1.5 .5 2),{OUT => [qw(1.5 2.0)]}], + + ['fmt-4', qw(-f %3.0f 1 2), {OUT => [' 1', ' 2']}], + ['fmt-5', qw(-f %-3.0f 1 2), {OUT => ['1 ', '2 ']}], + ['fmt-6', qw(-f %+3.0f 1 2), {OUT => [' +1', ' +2']}], + ['fmt-7', qw(-f %0+3.0f 1 2), {OUT => [qw(+01 +02)]}], + ['fmt-8', qw(-f %0+.0f 1 2), {OUT => [qw(+1 +2)]}], + ['fmt-9', '-f "% -3.0f"', qw(-1 0), {OUT => ['-1 ', ' 0 ']}], + ['fmt-a', '-f "% -.0f"',qw(-1 0), {OUT => ['-1', ' 0']}], + ['fmt-b', qw(-f %%%g%% 1), {OUT => ['%1%']}], + + # In coreutils-[6.0..6.9], this would mistakenly succeed and print "%Lg". + ['fmt-c', qw(-f %%g 1), {EXIT => 1}, + {ERR => "seq: format '%%g' has no % directive\n"}], + + # In coreutils-6.9..6.10, this would fail with an erroneous diagnostic: + # "seq: memory exhausted". In coreutils-6.0..6.8, it would mistakenly + # succeed and print a blank line. + ['fmt-eos1', qw(-f % 1), {EXIT => 1}, + {ERR => "seq: format '%' ends in %\n"}], + ['fmt-eos2', qw(-f %g% 1), {EXIT => 1}, + {ERR => "seq: format '%g%' has too many % directives\n"}], + + ['fmt-d', qw(-f "" 1), {EXIT => 1}, + {ERR => "seq: format '' has no % directive\n"}], + ['fmt-e', qw(-f %g%g 1), {EXIT => 1}, + {ERR => "seq: format '%g%g' has too many % directives\n"}], + + # With coreutils-6.12 and earlier, with a UTF8 numeric locale that uses + # something other than "." as the decimal point, this use of seq would + # fail to print the "2,0" endpoint. + ['locale-dec-pt', qw(-0.1 0.1 2), + {OUT => [qw(-0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 + 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0)]}, + + {ENV => "LC_ALL=$locale"}, + {OUT_SUBST => 's/,/./g'}, + ], + ); + +# Append a newline to each entry in the OUT array. +my $t; +foreach $t (@Tests) + { + my $e; + foreach $e (@$t) + { + $e->{OUT} = join ("\n", @{$e->{OUT}}) . "\n" + if ref $e eq 'HASH' and exists $e->{OUT}; + } + } + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sha1sum b/tests/misc/sha1sum deleted file mode 100755 index 2b08c7fc0..000000000 --- a/tests/misc/sha1sum +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/perl -# Test "sha1sum". - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'sha1sum'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $sha_degenerate = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; - -my @Tests = - ( - ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], - ['s2', {IN=> {f=> 'a'}}, - {OUT=>"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 f\n"}], - ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"a9993e364706816aba3e25717850c26c9cd0d89d f\n"}], - ['s4', - {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, - {OUT=>"84983e441c3bd26ebaae4aa1f95129e5e54670f1 f\n"}], - ['s5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, - {OUT=>"32d10c7b8cf96570ca04ce37f2a19d84240d3a89 f\n"}], - ['s6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"761c457bf73b14d27e9e9265c46f4b4dda11f940 f\n"}], - ['s7', {IN=> {f=> '1234567890' x 8}}, - {OUT=>"50abf5706a150990a08b2c5ea40fa0e585554732 f\n"}], - ['million-a', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"34aa973cd4c4daa4f61eeb2bdbad27316534016f f\n"}], - ['bs-sha', {IN=> {".\\foo"=> ''}}, - {OUT=>"\\$sha_degenerate .\\\\foo\n"}], - # The sha1sum and md5sum drivers share a lot of code. - # Ensure that sha1sum does *not* share the part that makes - # md5sum accept BSD format. - ['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}}, - {AUX=> {f=> ''}}, - {ERR=>"sha1sum: f.md5: no properly formatted " - . "SHA1 checksum lines found\n"}, - {EXIT=> 1}], - ['check-bsd2', '--check', - {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, - {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], - ['check-bsd3', '--check', '--status', - {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, - {AUX=> {f=> 'bar'}}, {EXIT=> 1}], - ['check-openssl', '--check', - {IN=> {'f.md5' => "MD5(f)= $sha_degenerate\n"}}, - {AUX=> {f=> ''}}, - {ERR=>"sha1sum: f.md5: no properly formatted " - . "SHA1 checksum lines found\n"}, - {EXIT=> 1}], - ['check-openssl2', '--check', - {IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}}, - {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], - ['check-openssl3', '--check', '--status', - {IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}}, - {AUX=> {f=> 'bar'}}, {EXIT=> 1}], - ['bsd-segv', '--check', {IN=> {'z' => "SHA1 ("}}, {EXIT=> 1}, - {ERR=> "$prog: z: no properly formatted SHA1 checksum lines found\n"}], - ); - -# Insert the '--text' argument for each test. -my $t; -foreach $t (@Tests) - { - splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sha1sum-vec b/tests/misc/sha1sum-vec deleted file mode 100755 index 48da107de..000000000 --- a/tests/misc/sha1sum-vec +++ /dev/null @@ -1,534 +0,0 @@ -#!/usr/bin/perl -# Sample vectors for "sha1sum". - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# The data from which these tests were derived came from here: -# http://csrc.nist.gov/cryptval/shs/sha1-vectors.zip - -my @Tests = - ( - ['1', {IN=> {f=> '0 1 ^'}}, - {OUT=>'DA39A3EE5E6B4B0D3255BFEF95601890AFD80709'}], - ['2', {IN=> {f=> '5 0 2 1 2 1 2 ^'}}, - {OUT=>'3CDF2936DA2FC556BFA533AB1EB59CE710AC80E5'}], - ['3', {IN=> {f=> '5 0 1 3 4 4 4 ^'}}, - {OUT=>'19C1E2048FA7393CFBF2D310AD8209EC11D996E5'}], - ['4', {IN=> {f=> '7 0 4 3 4 4 1 4 4 ^'}}, - {OUT=>'CA775D8C80FAA6F87FA62BECA6CA6089D63B56E5'}], - ['5', {IN=> {f=> '10 0 4 1 5 3 4 4 3 1 3 4 ^'}}, - {OUT=>'71AC973D0E4B50AE9E5043FF4D615381120A25A0'}], - ['6', {IN=> {f=> '10 0 3 1 6 5 5 1 3 6 6 4 ^'}}, - {OUT=>'A6B5B9F854CFB76701C3BDDBF374B3094EA49CBA'}], - ['7', {IN=> {f=> '13 1 3 2 5 3 3 3 4 6 6 1 4 6 2 ^'}}, - {OUT=>'D87A0EE74E4B9AD72E6847C87BDEEB3D07844380'}], - ['8', {IN=> {f=> '16 1 3 5 5 1 2 1 3 3 6 3 5 2 3 5 7 2 ^'}}, - {OUT=>'1976B8DD509FE66BF09C9A8D33534D4EF4F63BFD'}], - ['9', {IN=> {f=> '15 1 8 1 5 3 2 7 4 5 6 7 3 3 1 6 3 ^'}}, - {OUT=>'5A78F439B6DB845BB8A558E4CEB106CD7B7FF783'}], - ['10', {IN=> {f=> '15 1 4 6 8 2 1 4 2 5 1 6 8 8 6 4 7 ^'}}, - {OUT=>'F871BCE62436C1E280357416695EE2EF9B83695C'}], - ['11', {IN=> {f=> '18 1 1 2 7 3 8 6 7 5 4 3 4 3 5 3 3 2 6 8 ^'}}, - {OUT=>'62B243D1B780E1D31CF1BA2DE3F01C72AEEA0E47'}], - ['12', {IN=> {f=> '16 0 9 8 1 8 1 7 6 7 7 1 2 6 9 5 4 7 ^'}}, - {OUT=>'1698994A273404848E56E7FDA4457B5900DE1342'}], - ['13', {IN=> {f=> '18 0 7 1 7 3 9 4 7 7 5 2 8 1 7 8 2 7 2 9 ^'}}, - {OUT=>'056F4CDC02791DA7ED1EB2303314F7667518DEEF'}], - ['14', {IN=> {f=> '19 1 2 3 1 8 8 6 9 10 3 10 8 9 2 4 1 5 1 5 9 ^'}}, - {OUT=>'9FE2DA967BD8441EEA1C32DF68DDAA9DC1FC8E4B'}], - ['15', {IN=> {f=> '19 1 8 5 4 8 1 3 9 5 7 7 2 7 2 7 8 7 4 8 10 ^'}}, - {OUT=>'73A31777B4ACE9384EFA8BBEAD45C51A71ABA6DD'}], - ['16', {IN=> {f=> '20 1 1 9 7 4 1 4 5 1 10 8 6 4 4 9 9 9 8 2 9 10 ^'}}, - {OUT=>'3F9D7C4E2384EDDABFF5DD8A31E23DE3D03F42AC'}], - ['17', {IN=> {f=> '19 1 11 6 7 7 2 6 2 6 10 6 9 10 5 11 1 6 8 11 4 ^'}}, - {OUT=>'4814908F72B93FFD011135BEE347DE9A08DA838F'}], - ['18', {IN=> {f=> '22 0 10 5 10 3 7 8 9 9 1 1 1 10 2 1 5 10 2 9 9 9 7 8 ^'}}, - {OUT=>'0978374B67A412A3102C5AA0B10E1A6596FC68EB'}], - ['19', {IN=> {f=> '21 0 1 10 1 6 9 4 2 5 2 11 8 12 12 9 8 1 3 10 7 11 12 ^'}}, - {OUT=>'44AD6CB618BD935460D46D3F921D87B99AB91C1E'}], - ['20', {IN=> {f=> '24 1 3 9 5 12 3 4 2 9 12 11 6 6 1 1 9 5 9 1 4 9 4 10 8 9 ^'}}, - {OUT=>'02DC989AF265B09CF8485640842128DCF95E9F39'}], - ['21', {IN=> {f=> '25 1 3 2 3 11 1 12 5 6 2 7 8 4 8 8 9 9 8 4 9 1 4 8 10 9 9 ^'}}, - {OUT=>'67507B8D497B35D6E99FC01976D73F54AECA75CF'}], - ['22', {IN=> {f=> '23 0 11 10 7 10 10 6 10 9 4 5 10 5 8 4 1 10 12 4 6 1 8 11 6 ^'}}, - {OUT=>'1EAE0373C1317CB60C36A42A867B716039D441F5'}], - ['23', {IN=> {f=> '22 0 12 8 10 4 3 8 5 5 7 11 13 11 12 11 4 12 3 6 5 11 10 5 ^'}}, - {OUT=>'9C3834589E5BFFAC9F50950E0199B3EC2620BEC8'}], - ['24', {IN=> {f=> '26 1 10 9 6 9 7 2 10 4 4 5 5 2 12 13 5 3 1 10 1 4 7 8 13 13 12 9 ^'}}, - {OUT=>'209F7ABC7F3B878EE46CDF3A1FBB9C21C3474F32'}], - ['25', {IN=> {f=> '31 0 2 6 5 4 7 3 10 6 13 6 3 9 6 2 10 5 3 8 4 1 11 3 5 3 7 11 1 12 9 12 5 ^'}}, - {OUT=>'05FC054B00D97753A9B3E2DA8FBBA3EE808CEF22'}], - ['26', {IN=> {f=> '27 1 14 5 1 3 7 2 3 9 3 4 14 4 4 10 8 5 14 1 11 12 12 10 4 13 7 11 9 ^'}}, - {OUT=>'0C4980EA3A46C757DFBFC5BAA38AC6C8E72DDCE7'}], - ['27', {IN=> {f=> '30 1 4 9 5 5 8 9 5 10 4 2 4 7 9 9 6 3 5 1 8 3 2 13 3 14 9 8 9 10 14 10 ^'}}, - {OUT=>'96A460D2972D276928B69864445BEA353BDCFFD2'}], - ['28', {IN=> {f=> '27 0 12 9 5 8 7 2 14 12 3 8 14 6 6 4 7 5 7 10 7 11 10 1 9 6 7 12 14 ^'}}, - {OUT=>'F3EF04D8FA8C6FA9850F394A4554C080956FA64B'}], - ['29', {IN=> {f=> '24 0 12 9 9 2 11 13 12 11 11 6 14 13 10 5 6 8 10 4 3 11 11 14 5 14 ^'}}, - {OUT=>'F2A31D875D1D7B30874D416C4D2EA6BAF0FFBAFE'}], - ['30', {IN=> {f=> '24 0 15 4 5 3 8 12 15 8 14 15 9 12 12 3 10 13 6 11 10 4 13 14 8 8 ^'}}, - {OUT=>'F4942D3B9E9588DCFDC6312A84DF75D05F111C20'}], - ['31', {IN=> {f=> '28 1 1 8 1 5 11 4 9 12 4 13 15 5 9 11 7 14 11 1 11 7 8 8 11 1 13 15 12 13 ^'}}, - {OUT=>'310207DF35B014E4676D30806FA34424813734DD'}], - ['32', {IN=> {f=> '32 1 5 8 3 8 10 7 8 1 5 13 12 14 5 3 6 4 12 15 6 6 10 11 13 9 1 11 6 10 3 7 14 2 ^'}}, - {OUT=>'4DA1955B2FA7C7E74E3F47D7360CE530BBF57CA3'}], - ['33', {IN=> {f=> '31 0 10 3 5 1 14 11 11 16 1 2 2 11 6 13 15 12 6 5 16 2 14 2 10 12 2 5 5 6 10 13 15 ^'}}, - {OUT=>'74C4BC5B26FB4A08602D40CCEC6C6161B6C11478'}], - ['34', {IN=> {f=> '34 0 3 10 8 16 9 5 12 15 4 11 13 3 6 5 10 8 1 3 9 3 11 1 2 16 12 10 6 1 9 1 16 5 6 14 ^'}}, - {OUT=>'0B103CE297338DFC7395F7715EE47539B556DDB6'}], - ['35', {IN=> {f=> '30 1 1 12 4 4 2 15 13 15 11 15 5 11 9 7 15 16 6 16 12 3 2 10 16 5 5 7 1 7 11 16 ^'}}, - {OUT=>'EFC72D99E3D2311CE14190C0B726BDC68F4B0821'}], - ['36', {IN=> {f=> '34 0 7 9 11 2 5 5 5 4 13 13 14 4 7 12 6 4 8 2 9 9 13 13 3 3 6 7 16 7 6 15 5 8 15 14 ^'}}, - {OUT=>'660EDAC0A8F4CE33DA0D8DBAE597650E97687250'}], - ['37', {IN=> {f=> '36 1 4 6 16 15 11 14 14 4 7 10 3 4 10 3 6 7 14 4 6 6 5 2 7 8 16 2 12 16 10 14 3 2 3 7 14 3 ^'}}, - {OUT=>'FE0A55A988B3B93946A63EB36B23785A5E6EFC3E'}], - ['38', {IN=> {f=> '32 0 15 10 9 1 14 10 14 6 6 16 3 2 3 8 3 12 8 11 17 3 9 7 16 14 4 11 15 5 13 9 5 17 ^'}}, - {OUT=>'0CBDF2A5781C59F907513147A0DE3CC774B54BF3'}], - ['39', {IN=> {f=> '30 0 17 17 13 8 2 6 8 16 1 12 5 17 2 9 8 10 13 14 11 17 12 5 14 9 11 9 11 4 11 12 ^'}}, - {OUT=>'663E40FEE5A44BFCB1C99EA5935A6B5BC9F583B0'}], - ['40', {IN=> {f=> '30 1 16 6 10 5 8 3 17 16 14 1 15 15 15 6 13 2 11 6 13 11 13 4 6 7 11 11 12 16 13 16 ^'}}, - {OUT=>'00162134256952DD9AE6B51EFB159B35C3C138C7'}], - ['41', {IN=> {f=> '33 1 16 16 14 16 2 4 16 11 6 15 7 4 17 6 5 7 6 3 14 16 5 17 11 13 1 1 14 13 3 6 14 5 16 ^'}}, - {OUT=>'CEB88E4736E354416E2010FC1061B3B53B81664B'}], - ['42', {IN=> {f=> '39 1 2 16 13 7 8 6 2 15 1 9 12 4 4 11 13 7 2 11 9 18 4 5 4 8 2 14 9 9 1 8 13 11 15 8 5 9 10 16 7 ^'}}, - {OUT=>'A6A2C4B6BCC41DDC67278F3DF4D8D0B9DD7784EF'}], - ['43', {IN=> {f=> '34 0 2 7 1 1 17 13 6 11 10 8 5 12 15 6 15 10 12 4 18 1 2 8 11 12 16 10 12 18 11 16 12 11 17 6 ^'}}, - {OUT=>'C23D083CD8820B57800A869F5F261D45E02DC55D'}], - ['44', {IN=> {f=> '34 1 4 7 13 7 10 7 10 6 1 12 7 18 11 18 2 10 15 10 14 8 18 9 9 12 12 3 13 12 6 4 9 17 13 17 ^'}}, - {OUT=>'E8AC31927B78DDEC41A31CA7A44EB7177165E7AB'}], - ['45', {IN=> {f=> '40 0 5 7 3 2 1 17 14 4 16 6 13 1 13 6 6 10 1 3 18 3 11 7 9 5 7 11 17 1 9 16 5 15 10 17 3 8 15 17 8 12 ^'}}, - {OUT=>'E864EC5DBAB0F9FF6984AB6AD43A8C9B81CC9F9C'}], - ['46', {IN=> {f=> '40 0 11 3 15 17 11 1 1 4 3 14 18 4 2 18 8 15 6 4 6 3 15 11 16 10 17 17 9 6 3 2 6 16 4 9 12 6 8 1 11 17 ^'}}, - {OUT=>'CFED6269069417A84D6DE2347220F4B858BCD530'}], - ['47', {IN=> {f=> '37 1 2 19 12 8 16 14 2 9 16 2 6 6 7 9 10 9 11 9 14 11 15 5 16 9 2 17 2 8 15 8 4 3 14 14 16 16 12 ^'}}, - {OUT=>'D9217BFB46C96348722C3783D29D4B1A3FEDA38C'}], - ['48', {IN=> {f=> '37 1 11 10 16 12 11 7 14 14 14 6 10 10 1 6 13 19 5 6 4 7 12 12 10 5 10 15 15 8 5 13 17 13 5 6 14 1 19 ^'}}, - {OUT=>'DEC24E5554F79697218D317315FA986229CE3350'}], - ['49', {IN=> {f=> '38 1 2 6 5 17 9 11 18 18 8 6 13 15 3 3 15 5 13 18 3 2 5 5 14 7 13 4 17 7 2 17 3 18 15 7 15 16 18 11 ^'}}, - {OUT=>'83A099DF7071437BA5495A5B0BFBFEFE1C0EF7F3'}], - ['50', {IN=> {f=> '38 1 12 8 6 3 17 12 13 19 15 9 7 17 16 15 3 11 11 5 2 13 19 16 2 4 16 7 8 1 2 9 17 12 3 5 18 19 11 9 ^'}}, - {OUT=>'AA3198E30891A83E33CE3BFA0587D86A197D4F80'}], - ['51', {IN=> {f=> '39 1 14 16 14 8 9 16 5 1 6 3 17 18 16 9 1 15 9 10 9 19 1 3 3 20 11 13 17 1 19 8 3 4 3 7 1 14 19 19 19 ^'}}, - {OUT=>'9B6ACBEB4989CBEE7015C7D515A75672FFDE3442'}], - ['52', {IN=> {f=> '37 1 18 13 11 5 18 4 19 10 6 19 11 17 10 10 7 9 13 16 9 10 18 4 12 5 16 5 20 12 3 8 10 1 18 1 6 20 14 ^'}}, - {OUT=>'B021EB08A436B02658EAA7BA3C88D49F1219C035'}], - ['53', {IN=> {f=> '36 0 8 9 6 12 11 7 7 3 17 13 6 20 17 9 20 16 10 12 17 8 11 8 11 10 5 10 14 18 8 19 9 12 12 2 20 19 ^'}}, - {OUT=>'CAE36DAB8AEA29F62E0855D9CB3CD8E7D39094B1'}], - ['54', {IN=> {f=> '39 0 12 16 20 3 9 9 19 17 13 13 4 17 2 11 7 14 3 6 16 13 10 13 5 16 10 2 8 2 17 19 4 17 7 19 6 9 15 15 6 ^'}}, - {OUT=>'02DE8BA699F3C1B0CB5AD89A01F2346E630459D7'}], - ['55', {IN=> {f=> '43 0 7 2 18 5 7 18 5 2 15 7 11 10 9 3 2 14 19 3 11 8 18 15 5 3 5 12 15 16 10 17 7 19 16 2 1 16 6 3 19 12 5 18 16 ^'}}, - {OUT=>'88021458847DD39B4495368F7254941859FAD44B'}], - ['56', {IN=> {f=> '49 1 9 11 2 1 12 11 14 12 14 10 4 11 6 8 16 7 5 11 20 8 17 4 14 4 15 3 2 2 4 3 2 3 14 15 10 2 12 7 3 7 20 20 19 10 2 3 1 10 20 ^'}}, - {OUT=>'91A165295C666FE85C2ADBC5A10329DAF0CB81A0'}], - ['57', {IN=> {f=> '36 0 19 20 12 5 19 21 5 21 11 14 19 1 17 8 9 4 19 3 17 1 14 21 14 7 6 5 20 14 21 20 4 6 21 7 11 12 ^'}}, - {OUT=>'4B31312EAF8B506811151A9DBD162961F7548C4B'}], - ['58', {IN=> {f=> '41 0 12 9 11 6 16 18 18 10 11 20 6 12 11 5 7 21 19 18 6 15 21 10 4 14 9 19 10 3 3 5 13 1 8 12 3 13 9 7 10 17 14 ^'}}, - {OUT=>'3FE70971B20558F7E9BAC303ED2BC14BDE659A62'}], - ['59', {IN=> {f=> '45 0 10 6 8 3 17 18 3 21 19 6 17 15 4 9 15 9 15 14 4 7 14 8 10 13 4 11 10 7 6 21 1 14 5 11 7 7 2 13 13 3 9 13 8 14 20 ^'}}, - {OUT=>'93FB769D5BF49D6C563685954E2AECC024DC02D6'}], - ['60', {IN=> {f=> '39 1 3 7 18 4 9 9 5 15 13 17 10 15 16 20 8 19 9 10 9 1 19 14 21 2 18 13 10 4 18 16 4 21 15 10 18 19 3 12 18 ^'}}, - {OUT=>'BC8827C3E614D515E83DEA503989DEA4FDA6EA13'}], - ['61', {IN=> {f=> '41 0 14 4 13 11 1 11 1 10 2 12 4 21 10 21 18 9 2 16 7 20 6 7 12 19 20 1 13 12 10 8 21 15 7 19 13 6 8 19 20 18 19 ^'}}, - {OUT=>'E83868DBE4A389AB48E61CFC4ED894F32AE112AC'}], - ['62', {IN=> {f=> '37 0 11 18 1 17 14 15 20 16 20 8 2 17 10 4 21 5 19 19 14 22 21 18 13 14 1 3 12 11 11 4 22 13 5 18 7 21 21 ^'}}, - {OUT=>'55C95459CDE4B33791B4B2BCAAF840930AF3F3BD'}], - ['63', {IN=> {f=> '48 0 9 22 19 12 8 16 5 17 5 9 1 2 9 6 12 6 1 7 4 3 15 1 14 1 12 3 10 2 10 14 21 13 17 6 6 17 1 21 2 14 16 17 9 11 20 21 11 18 ^'}}, - {OUT=>'36BB0E2BA438A3E03214D9ED2B28A4D5C578FCAA'}], - ['64', {IN=> {f=> '50 1 12 8 20 13 2 9 20 9 14 10 1 16 2 22 6 4 16 14 15 1 12 4 14 9 21 3 3 9 8 21 15 14 8 4 14 4 2 3 8 12 8 6 1 2 18 20 15 3 19 10 ^'}}, - {OUT=>'3ACBF874199763EBA20F3789DFC59572ACA4CF33'}], - ['65', {IN=> {f=> '44 0 10 20 14 6 3 4 21 1 12 4 18 2 6 7 6 9 20 14 10 10 19 17 21 12 15 17 7 10 11 8 10 12 1 19 19 9 18 21 4 18 11 9 22 5 ^'}}, - {OUT=>'86BE037C4D509C9202020767D860DAB039CADACE'}], - ['66', {IN=> {f=> '47 0 15 8 15 3 5 6 2 19 12 17 4 20 8 11 20 2 18 4 16 20 12 9 9 6 16 21 16 3 16 18 3 19 5 16 2 4 2 12 11 15 11 14 17 2 10 18 8 ^'}}, - {OUT=>'51B57D7080A87394EEC3EB2E0B242E553F2827C9'}], - ['67', {IN=> {f=> '48 1 5 13 3 21 5 3 6 18 18 10 1 21 21 7 1 13 12 19 1 14 6 8 21 19 21 11 19 13 2 13 4 1 10 22 16 4 9 4 10 16 3 7 15 11 9 13 17 12 ^'}}, - {OUT=>'1EFBFA78866315CE6A71E457F3A750A38FACAB41'}], - ['68', {IN=> {f=> '45 0 14 7 6 2 20 3 6 19 19 10 2 22 12 17 12 1 20 7 7 15 20 6 18 8 3 14 23 18 15 4 7 5 23 15 7 14 10 10 19 17 2 4 15 17 21 ^'}}, - {OUT=>'57D6CB41AEEC20236F365B3A490C61D0CFA39611'}], - ['69', {IN=> {f=> '45 1 15 11 8 9 17 5 12 18 14 6 20 17 21 12 16 9 22 9 20 15 2 22 11 2 6 11 9 8 2 4 14 19 3 21 21 23 8 2 11 4 8 4 20 22 11 ^'}}, - {OUT=>'C532CB64B4BA826372BCCF2B4B5793D5B88BB715'}], - ['70', {IN=> {f=> '38 0 21 18 22 10 19 9 14 17 23 21 10 7 15 13 16 5 4 10 13 14 20 23 12 20 23 18 10 12 8 21 11 6 12 7 19 14 18 17 ^'}}, - {OUT=>'15833B5631032663E783686A209C6A2B47A1080E'}], - ['71', {IN=> {f=> '40 0 18 22 6 9 22 5 23 13 6 8 23 20 22 5 22 15 19 20 9 9 1 13 13 10 14 13 5 22 14 21 9 21 19 14 14 4 18 13 12 14 ^'}}, - {OUT=>'D04F2043C96E10CD83B574B1E1C217052CD4A6B2'}], - ['72', {IN=> {f=> '48 1 7 3 15 5 17 14 23 14 5 17 22 11 1 8 13 23 6 21 3 6 11 7 23 8 6 21 4 4 22 19 13 8 5 19 7 5 23 1 4 19 11 23 11 21 14 1 3 21 ^'}}, - {OUT=>'E8882627C64DB743F7DB8B4413DD033FC63BEB20'}], - ['73', {IN=> {f=> '43 0 22 14 11 7 18 16 17 24 12 12 3 13 19 16 22 4 16 4 6 23 8 18 11 2 3 20 22 9 21 8 23 1 23 20 7 16 13 23 4 13 3 7 22 ^'}}, - {OUT=>'CD2D32286B8867BC124A0AF2236FC74BE3622199'}], - ['74', {IN=> {f=> '47 1 23 6 13 19 2 3 7 2 9 9 15 6 13 4 22 6 19 20 1 9 7 14 1 15 3 23 24 22 18 12 12 17 19 10 8 11 22 12 10 2 20 15 18 17 18 7 19 ^'}}, - {OUT=>'019B70D745375091ED5C7B218445EC986D0F5A82'}], - ['75', {IN=> {f=> '47 1 12 21 6 12 4 7 18 17 3 2 14 24 14 1 23 1 11 15 10 6 18 20 7 1 8 1 16 6 20 23 23 21 10 10 12 24 10 11 23 2 12 23 9 3 24 24 10 ^'}}, - {OUT=>'E5FF5FEC1DADBAED02BF2DAD4026BE6A96B3F2AF'}], - ['76', {IN=> {f=> '52 0 14 10 18 15 14 5 16 11 22 2 15 24 8 22 1 4 24 9 10 15 3 9 5 4 17 15 9 12 19 19 1 3 10 6 8 3 17 8 18 24 19 3 4 15 4 9 2 24 5 20 13 13 ^'}}, - {OUT=>'6F4E23B3F2E2C068D13921FE4E5E053FFED4E146'}], - ['77', {IN=> {f=> '42 0 20 17 19 22 13 8 10 19 15 11 1 14 17 20 22 10 7 11 16 9 21 22 17 23 12 15 4 24 7 21 18 2 21 16 1 19 18 20 11 3 15 17 ^'}}, - {OUT=>'25E179602A575C915067566FBA6DA930E97F8678'}], - ['78', {IN=> {f=> '50 0 18 1 6 14 5 5 5 19 13 10 24 19 16 24 15 13 2 19 15 24 21 17 4 13 17 1 1 9 1 10 2 18 1 21 19 5 18 12 2 22 16 23 15 19 6 18 9 1 23 5 ^'}}, - {OUT=>'67DED0E68E235C8A523E051E86108EEB757EFBFD'}], - ['79', {IN=> {f=> '51 0 21 13 14 11 18 12 13 3 19 9 20 22 20 2 11 12 6 1 12 16 18 2 9 8 4 3 11 17 11 5 4 19 16 11 23 13 18 1 20 8 2 16 16 21 4 19 5 5 20 24 16 ^'}}, - {OUT=>'AF78536EA83C822796745556D62A3EE82C7BE098'}], - ['80', {IN=> {f=> '53 1 20 25 17 11 8 4 19 25 17 7 16 21 6 4 8 2 15 9 2 9 19 3 6 3 3 10 25 13 15 7 8 20 21 12 10 12 5 24 11 20 3 13 13 16 9 13 10 3 9 16 3 7 25 ^'}}, - {OUT=>'64D7AC52E47834BE72455F6C64325F9C358B610D'}], - ['81', {IN=> {f=> '49 1 9 9 14 2 13 17 25 2 18 5 19 23 9 25 9 10 23 12 12 7 13 8 15 7 1 6 21 2 8 7 6 16 14 14 12 15 13 24 10 15 11 10 8 14 15 21 25 21 25 ^'}}, - {OUT=>'9D4866BAA3639C13E541F250FFA3D8BC157A491F'}], - ['82', {IN=> {f=> '47 0 9 18 20 22 21 20 11 14 23 22 10 13 14 8 19 12 2 11 20 23 13 4 10 6 5 7 23 11 3 16 8 21 4 8 18 5 12 14 8 6 20 19 24 8 23 17 23 ^'}}, - {OUT=>'2E258811961D3EB876F30E7019241A01F9517BEC'}], - ['83', {IN=> {f=> '48 1 7 19 1 18 1 14 22 13 14 5 8 22 18 14 25 17 11 12 22 2 12 12 16 12 13 18 17 12 17 14 18 8 25 9 23 5 3 8 14 24 17 7 3 3 23 17 22 19 ^'}}, - {OUT=>'8E0EBC487146F83BC9077A1630E0FB3AB3C89E63'}], - ['84', {IN=> {f=> '51 1 19 17 16 22 24 14 16 20 23 20 9 19 16 7 12 16 5 8 9 7 10 21 24 10 11 19 1 21 14 14 19 3 22 8 12 20 1 18 5 6 5 12 14 1 1 11 9 22 3 24 4 ^'}}, - {OUT=>'CE8953741FFF3425D2311FBBF4AB481B669DEF70'}], - ['85', {IN=> {f=> '52 1 6 1 11 16 1 12 8 11 11 17 10 22 7 3 10 2 6 4 24 16 24 19 4 5 18 11 12 9 20 21 25 2 21 18 10 20 25 21 3 17 17 5 8 22 25 19 8 10 19 7 11 18 ^'}}, - {OUT=>'789D1D2DAB52086BD90C0E137E2515ED9C6B59B5'}], - ['86', {IN=> {f=> '44 0 26 14 21 25 25 4 9 13 5 8 9 21 8 12 26 24 9 24 15 1 23 22 16 14 8 22 15 19 24 20 7 8 15 24 12 4 4 23 21 13 19 15 21 12 ^'}}, - {OUT=>'B76CE7472700DD68D6328B7AA8437FB051D15745'}], - ['87', {IN=> {f=> '59 1 15 7 3 21 20 8 22 14 23 26 19 2 10 18 3 5 3 1 9 15 15 3 7 13 23 9 7 1 13 17 14 25 9 16 2 2 6 13 7 19 25 17 1 5 21 2 7 22 5 6 25 3 12 19 6 2 4 24 17 ^'}}, - {OUT=>'F218669B596C5FFB0B1C14BD03C467FC873230A0'}], - ['88', {IN=> {f=> '60 0 9 18 20 19 4 11 14 1 6 8 26 6 9 22 4 10 2 7 21 9 8 24 25 14 22 12 22 3 23 3 3 20 6 11 23 6 1 7 5 18 5 15 25 26 1 1 10 11 11 4 12 11 20 3 14 2 3 2 23 15 ^'}}, - {OUT=>'1FF3BDBE0D504CB0CDFAB17E6C37ABA6B3CFFDED'}], - ['89', {IN=> {f=> '49 0 12 17 24 11 8 6 24 16 15 22 21 14 6 12 20 19 5 5 12 11 6 23 2 16 23 7 24 6 21 2 17 17 5 25 11 25 20 25 24 18 6 12 19 25 7 6 5 2 25 ^'}}, - {OUT=>'2F3CBACBB14405A4652ED52793C1814FD8C4FCE0'}], - ['90', {IN=> {f=> '54 1 12 16 1 15 7 1 26 19 19 13 20 11 17 6 20 5 24 24 1 21 11 9 20 21 15 10 19 26 3 2 6 7 12 9 10 8 14 10 15 5 17 8 21 1 20 25 6 19 8 3 22 16 16 20 ^'}}, - {OUT=>'982C8AB6CE164F481915AF59AAED9FFF2A391752'}], - ['91', {IN=> {f=> '63 0 17 13 11 10 17 15 12 6 13 14 17 4 12 10 24 5 13 24 3 5 2 5 11 14 8 5 10 17 16 8 4 14 21 15 3 6 17 25 8 2 3 3 19 10 13 22 22 8 2 13 25 17 2 1 19 1 14 20 2 5 4 15 24 ^'}}, - {OUT=>'5CD92012D488A07ECE0E47901D0E083B6BD93E3F'}], - ['92', {IN=> {f=> '49 0 14 20 7 25 20 26 20 16 7 17 17 22 1 13 6 5 1 18 14 15 23 15 10 5 19 18 18 26 12 13 3 25 12 21 16 24 4 16 3 6 26 26 10 20 13 1 20 24 15 ^'}}, - {OUT=>'69603FEC02920851D4B3B8782E07B92BB2963009'}], - ['93', {IN=> {f=> '56 0 3 8 14 5 5 7 11 13 11 26 11 4 26 17 20 19 11 10 3 10 14 9 6 9 7 16 10 4 4 19 19 2 26 13 19 17 15 24 15 4 21 22 13 13 12 22 2 14 20 5 18 7 17 24 20 20 ^'}}, - {OUT=>'3E90F76437B1EA44CF98A08D83EA24CECF6E6191'}], - ['94', {IN=> {f=> '58 1 6 17 9 20 2 10 19 3 22 4 1 11 3 5 3 21 11 15 12 23 26 5 2 27 6 5 16 6 3 2 23 5 3 20 20 4 24 2 18 21 7 14 10 27 23 6 24 6 19 23 3 9 22 16 21 17 19 23 ^'}}, - {OUT=>'34C09F107C42D990EB4881D4BF2DDDCAB01563AE'}], - ['95', {IN=> {f=> '58 1 17 7 21 19 6 16 15 15 20 14 2 25 19 14 18 19 7 9 1 14 11 10 16 3 23 14 26 10 11 1 18 1 12 24 19 19 1 7 2 3 24 7 12 9 2 8 16 20 24 5 26 26 4 9 2 7 25 17 ^'}}, - {OUT=>'474BE0E5892EB2382109BFC5E3C8249A9283B03D'}], - ['96', {IN=> {f=> '54 1 8 12 18 14 26 7 17 18 4 20 1 16 14 21 26 4 6 8 24 11 25 15 24 16 23 4 10 23 21 24 15 10 9 26 7 14 24 21 6 20 5 17 16 17 1 3 12 1 4 13 3 9 21 26 ^'}}, - {OUT=>'A04B4F75051786682483252438F6A75BF4705EC6'}], - ['97', {IN=> {f=> '56 1 7 18 11 1 19 20 23 12 12 27 13 13 15 16 13 1 16 15 12 26 3 16 16 8 17 13 21 4 6 5 19 14 16 4 16 11 14 18 18 27 9 13 21 3 26 22 3 7 6 4 26 3 15 8 25 21 ^'}}, - {OUT=>'BE88A6716083EB50ED9416719D6A247661299383'}], - ['98', {IN=> {f=> '50 1 20 13 9 11 20 6 11 21 27 25 20 7 4 18 26 16 27 5 12 19 7 23 6 25 25 2 11 13 25 21 18 17 6 12 14 13 24 11 14 19 26 27 25 6 1 15 4 7 27 15 ^'}}, - {OUT=>'C67E38717FEE1A5F65EC6C7C7C42AFC00CD37F04'}], - ['99', {IN=> {f=> '51 0 15 16 26 27 23 14 12 28 22 15 8 19 2 20 13 1 24 2 25 1 6 19 19 8 11 24 24 21 13 27 5 11 28 17 7 25 6 23 24 14 25 12 5 13 26 2 5 8 10 16 17 ^'}}, - {OUT=>'959AC4082388E19E9BE5DE571C047EF10C174A8D'}], - ['100', {IN=> {f=> '58 1 5 26 18 19 21 3 12 11 13 4 14 22 22 14 16 13 3 22 16 23 5 19 6 13 10 26 17 27 26 4 3 25 6 14 2 3 5 7 23 11 22 8 25 2 9 25 18 17 8 2 14 4 19 1 5 27 13 24 ^'}}, - {OUT=>'BAA7AA7B7753FA0ABDC4A541842B5D238D949F0A'}], - ['101', {IN=> {f=> '53 0 2 27 28 2 17 23 10 27 18 26 7 22 16 3 27 1 26 21 28 10 3 6 2 2 10 17 13 16 6 17 21 23 13 20 22 5 6 11 12 12 8 23 13 17 9 23 20 3 28 27 12 17 22 ^'}}, - {OUT=>'351394DCEBC08155D100FCD488578E6AE71D0E9C'}], - ['102', {IN=> {f=> '59 0 28 19 5 21 4 27 8 1 19 14 20 6 7 9 1 6 22 3 19 26 14 8 6 7 19 15 23 1 17 16 6 26 14 5 22 25 4 7 10 16 21 10 18 19 24 16 23 8 3 17 28 18 10 2 5 3 21 21 15 ^'}}, - {OUT=>'AB8BE94C5AF60D9477EF1252D604E58E27B2A9EE'}], - ['103', {IN=> {f=> '58 0 6 24 1 4 24 18 10 22 1 21 12 5 4 4 20 25 24 26 8 25 11 2 7 27 22 19 4 18 27 10 28 4 12 24 8 16 12 11 16 17 25 8 12 16 1 9 9 10 5 24 23 18 5 14 18 8 4 28 ^'}}, - {OUT=>'3429EC74A695FDD3228F152564952308AFE0680A'}], - ['104', {IN=> {f=> '61 0 5 17 8 28 1 22 4 11 3 2 17 3 14 9 27 13 18 24 9 8 7 28 25 14 21 27 24 6 18 16 2 12 15 9 14 10 1 8 17 4 6 15 26 11 15 2 28 20 26 16 3 7 5 8 9 26 10 12 25 11 22 ^'}}, - {OUT=>'907FA46C029BC67EAA8E4F46E3C2A232F85BD122'}], - ['105', {IN=> {f=> '53 0 9 13 24 15 20 2 4 8 2 22 20 19 4 15 14 28 13 25 10 10 12 28 24 22 26 28 15 9 11 26 19 22 27 2 21 8 20 23 26 12 10 21 9 15 13 25 7 26 1 13 5 9 20 ^'}}, - {OUT=>'2644C87D1FBBBC0FC8D65F64BCA2492DA15BAAE4'}], - ['106', {IN=> {f=> '58 0 3 9 21 22 7 1 23 28 1 2 8 22 12 18 28 5 18 14 7 11 17 20 20 7 21 13 8 28 21 22 2 16 20 15 28 9 3 22 13 10 23 4 16 11 14 1 10 8 14 14 15 18 13 12 21 18 25 28 ^'}}, - {OUT=>'110A3EEB408756E2E81ABAF4C5DCD4D4C6AFCF6D'}], - ['107', {IN=> {f=> '60 1 29 20 2 29 22 8 16 20 4 12 9 6 12 16 16 7 9 20 29 11 9 4 1 15 25 16 29 10 22 7 2 8 5 18 14 23 24 4 6 26 3 11 6 12 1 7 14 24 14 6 10 21 16 23 29 25 6 14 17 24 ^'}}, - {OUT=>'CD4FDC35FAC7E1ADB5DE40F47F256EF74D584959'}], - ['108', {IN=> {f=> '64 0 12 10 5 10 15 25 8 15 3 7 13 25 16 14 1 29 22 26 15 27 9 1 8 8 28 6 13 5 13 3 15 5 23 8 23 2 5 5 4 17 13 14 7 17 12 27 3 18 5 7 5 26 18 15 22 28 16 13 7 2 23 19 25 15 ^'}}, - {OUT=>'8E6E273208AC256F9ECCF296F3F5A37BC8A0F9F7'}], - ['109', {IN=> {f=> '56 1 17 7 16 25 23 11 11 15 2 13 9 26 2 24 26 7 28 11 2 29 7 22 23 5 28 19 1 27 29 1 24 11 18 20 3 13 11 7 3 15 17 24 1 18 13 6 3 25 27 16 28 18 24 8 23 22 ^'}}, - {OUT=>'FE0606100BDBC268DB39B503E0FDFE3766185828'}], - ['110', {IN=> {f=> '51 1 29 28 6 28 14 12 28 27 22 4 14 25 1 3 9 7 11 14 15 16 10 19 12 19 11 20 13 28 4 27 28 7 27 12 4 28 21 17 22 20 17 15 15 23 22 13 12 21 22 21 29 ^'}}, - {OUT=>'6C63C3E58047BCDB35A17F74EEBA4E9B14420809'}], - ['111', {IN=> {f=> '64 1 12 14 12 18 27 8 7 4 9 14 16 15 8 11 21 20 10 10 21 23 20 2 11 23 1 11 1 5 3 23 16 15 27 14 5 16 3 22 2 3 24 3 19 29 4 4 10 8 20 14 15 1 26 12 27 25 4 28 22 11 19 19 24 9 ^'}}, - {OUT=>'BCC2BD305F0BCDA8CF2D478EF9FE080486CB265F'}], - ['112', {IN=> {f=> '60 1 20 8 9 5 25 19 17 19 15 7 24 24 21 3 20 16 8 3 17 28 18 29 9 23 9 10 29 4 12 24 15 5 8 22 17 29 12 3 8 29 15 21 21 4 7 20 7 10 7 26 10 16 24 6 7 12 8 12 15 17 ^'}}, - {OUT=>'CE5223FD3DD920A3B666481D5625B16457DCB5E8'}], - ['113', {IN=> {f=> '60 0 9 17 11 28 12 26 26 6 29 13 10 20 6 23 10 4 3 26 26 14 20 20 25 14 13 15 24 14 11 4 23 27 24 20 9 16 17 24 13 12 6 1 14 26 25 7 8 21 1 19 3 2 2 17 21 13 5 9 21 11 ^'}}, - {OUT=>'948886776E42E4F5FAE1B2D0C906AC3759E3F8B0'}], - ['114', {IN=> {f=> '54 0 25 1 27 24 6 23 16 5 1 20 29 22 25 9 25 10 3 28 28 25 19 18 16 24 14 15 5 28 12 28 26 29 2 15 15 9 5 18 19 22 12 15 4 6 15 24 16 9 4 26 25 18 27 12 ^'}}, - {OUT=>'4C12A51FCFE242F832E3D7329304B11B75161EFB'}], - ['115', {IN=> {f=> '61 1 20 4 26 12 3 22 1 22 30 3 28 10 9 24 14 29 6 30 3 10 20 14 6 3 19 21 21 28 16 18 11 30 11 20 30 1 9 8 11 5 19 10 24 4 22 4 2 26 5 15 20 8 3 13 30 18 8 1 25 28 19 ^'}}, - {OUT=>'C54BDD2050504D92F551D378AD5FC72C9ED03932'}], - ['116', {IN=> {f=> '56 1 20 15 21 18 18 12 16 13 24 9 21 2 28 6 1 23 9 18 27 27 4 9 13 10 8 14 16 15 12 11 14 21 14 10 11 25 17 17 30 21 13 27 26 26 22 14 13 17 21 19 9 9 20 23 13 28 ^'}}, - {OUT=>'8F53E8FA79EA09FD1B682AF5ED1515ECA965604C'}], - ['117', {IN=> {f=> '59 1 10 28 24 10 22 27 23 27 8 17 14 6 4 21 26 15 1 8 29 27 6 28 15 3 27 25 25 14 19 13 29 8 24 2 8 2 4 12 19 11 10 6 26 14 22 24 30 10 11 12 2 12 17 23 8 8 12 28 12 ^'}}, - {OUT=>'2D7E17F6294524CE78B33EAB72CDD08E5FF6E313'}], - ['118', {IN=> {f=> '56 0 14 28 2 17 4 8 3 26 9 23 21 30 30 20 4 13 28 29 9 3 17 7 19 30 28 1 2 20 9 12 24 15 30 20 27 3 23 11 6 29 25 23 26 17 20 10 22 15 23 6 25 5 4 30 2 29 ^'}}, - {OUT=>'64582B4B57F782C9302BFE7D07F74AA176627A3A'}], - ['119', {IN=> {f=> '63 1 23 15 27 14 26 1 1 7 19 12 7 6 20 18 14 4 15 17 28 7 11 7 8 9 22 17 12 5 23 18 25 18 6 12 26 30 12 30 14 3 1 18 10 20 27 21 8 6 24 26 20 11 24 7 2 4 18 15 14 30 16 19 14 ^'}}, - {OUT=>'6D88795B71D3E386BBD1EB830FB9F161BA98869F'}], - ['120', {IN=> {f=> '52 0 27 15 4 19 25 29 29 7 14 18 9 11 9 27 11 15 29 9 28 20 2 30 26 21 17 8 28 17 22 29 24 8 11 18 29 15 6 7 27 27 17 24 18 23 11 19 8 30 5 24 22 24 ^'}}, - {OUT=>'86AD34A6463F12CEE6DE9596ABA72F0DF1397FD1'}], - ['121', {IN=> {f=> '66 1 25 15 28 23 5 10 21 5 8 7 3 10 19 17 6 9 15 29 10 7 4 1 16 21 16 29 13 18 5 3 8 15 8 21 29 20 5 27 2 13 27 7 7 30 2 18 26 10 2 5 29 21 15 25 26 24 8 12 20 3 9 10 30 7 12 29 ^'}}, - {OUT=>'7EB46685A57C0D466152DC339C8122548C757ED1'}], - ['122', {IN=> {f=> '53 1 30 26 20 11 22 19 27 2 16 10 6 4 24 17 20 25 20 15 8 23 23 20 30 18 16 3 30 15 26 23 28 7 21 8 7 31 31 14 26 18 3 1 26 28 15 25 11 31 3 25 9 21 30 ^'}}, - {OUT=>'E7A98FB0692684054407CC221ABC60C199D6F52A'}], - ['123', {IN=> {f=> '67 0 2 6 14 4 9 5 28 8 17 22 1 4 8 7 10 14 19 10 14 8 27 9 24 26 4 30 11 8 19 5 21 7 2 27 20 16 20 20 22 14 13 16 26 14 10 3 25 22 25 23 21 10 15 15 29 8 13 4 2 13 22 20 7 4 20 31 23 ^'}}, - {OUT=>'34DF1306662206FD0A5FC2969A4BEEC4EB0197F7'}], - ['124', {IN=> {f=> '65 0 2 2 28 13 19 14 12 23 27 6 2 14 2 22 6 25 30 29 31 13 14 16 31 12 16 30 5 14 31 11 4 1 1 25 21 13 26 22 21 5 22 14 29 1 21 3 14 30 4 2 29 12 15 23 3 15 5 1 6 23 22 13 1 14 23 ^'}}, - {OUT=>'56CF7EBF08D10F0CB9FE7EE3B63A5C3A02BCB450'}], - ['125', {IN=> {f=> '59 1 25 5 15 6 13 3 22 11 23 31 24 6 5 20 4 14 3 29 8 29 19 7 29 23 25 28 19 11 15 27 21 14 1 19 20 26 12 7 12 1 18 13 29 28 23 29 14 23 7 1 9 29 24 5 30 18 5 25 30 ^'}}, - {OUT=>'3BAE5CB8226642088DA760A6F78B0CF8EDDEA9F1'}], - ['126', {IN=> {f=> '55 1 31 25 13 7 24 25 24 1 12 19 9 7 6 28 20 14 28 21 19 31 20 20 6 24 18 27 24 4 18 21 1 31 15 1 15 2 27 4 26 25 4 23 19 2 31 22 30 21 22 5 27 12 30 28 31 ^'}}, - {OUT=>'6475DF681E061FA506672C27CBABFA9AA6DDFF62'}], - ['127', {IN=> {f=> '62 0 27 15 18 14 25 15 17 7 28 11 28 29 30 1 17 12 10 2 18 20 21 2 11 12 5 4 12 25 14 5 5 24 22 18 31 15 22 29 11 3 21 31 21 27 3 28 7 10 25 2 15 30 9 30 7 22 15 9 3 20 24 14 ^'}}, - {OUT=>'79D81991FA4E4957C8062753439DBFD47BBB277D'}], - ['128', {IN=> {f=> '60 0 28 14 18 9 27 14 22 27 31 10 8 14 7 15 7 20 5 26 1 29 7 17 17 8 3 13 27 18 8 31 27 28 22 22 17 19 18 18 11 19 13 25 10 19 6 28 4 31 23 10 18 26 31 5 10 13 12 8 15 27 ^'}}, - {OUT=>'BAE224477B20302E881F5249F52EC6C34DA8ECEF'}], - ['129', {IN=> {f=> '60 1 24 22 4 29 22 31 28 20 4 16 21 3 1 15 5 15 6 30 3 29 29 7 27 20 2 20 31 22 26 9 29 16 4 26 32 17 20 14 28 17 19 6 24 11 26 28 5 18 15 8 16 20 21 4 9 12 4 8 17 29 ^'}}, - {OUT=>'EDE4DEB4293CFE4138C2C056B7C46FF821CC0ACC'}], - ['130', {IN=> {f=> '69 1 5 3 11 15 12 24 31 23 1 6 28 2 8 31 6 7 30 5 19 23 12 6 9 31 19 17 24 25 22 6 12 16 3 7 9 9 11 29 4 11 2 5 13 29 10 12 30 32 18 28 18 27 3 30 4 4 26 6 13 31 13 2 11 7 24 4 17 29 12 ^'}}, - {OUT=>'A771FA5C812BD0C9596D869EC99E4F4AC988B13F'}], - ['131', {IN=> {f=> '95 0 21 19 21 23 11 42 36 2 13 4 1 33 22 16 27 9 4 33 16 3 30 15 11 32 13 17 38 32 9 38 4 36 15 32 27 19 42 18 6 36 22 10 29 12 25 40 15 29 23 28 30 4 8 11 24 9 10 31 28 43 23 16 29 33 5 40 26 3 19 12 36 43 5 35 37 5 14 11 45 35 16 10 8 32 4 15 35 26 2 39 22 37 22 30 29 ^'}}, - {OUT=>'E99D566212BBBCEEE903946F6100C9C96039A8F4'}], - ['132', {IN=> {f=> '106 1 18 14 51 2 6 32 51 9 32 50 44 46 51 8 11 53 45 55 16 10 3 52 8 20 20 46 46 13 32 2 46 50 43 25 54 9 31 29 2 47 15 29 24 45 44 18 37 14 28 39 36 44 47 16 50 10 44 24 53 35 22 40 20 15 51 22 18 22 42 6 54 49 38 21 7 13 30 16 7 52 16 22 13 38 7 11 44 33 9 25 13 37 42 14 45 53 30 38 5 25 5 35 38 22 28 53 ^'}}, - {OUT=>'B48CE6B1D13903E3925AE0C88CB931388C013F9C'}], - ['133', {IN=> {f=> '127 0 58 35 43 28 5 28 63 8 12 25 9 47 53 29 62 7 37 2 3 48 5 12 55 56 28 35 12 63 6 58 27 27 48 44 35 14 17 22 56 10 8 1 16 15 42 63 14 51 57 19 41 7 8 56 47 34 52 22 48 60 43 9 1 52 4 21 49 61 18 50 23 13 46 62 23 45 62 9 56 18 23 31 8 30 27 36 13 38 4 58 53 47 24 18 41 58 19 12 18 52 42 29 44 45 26 63 34 32 41 64 15 26 55 19 2 49 6 30 53 13 54 12 53 37 12 37 43 ^'}}, - {OUT=>'E647D5BAF670D4BF3AFC0A6B72A2424B0C64F194'}], - ['134', {IN=> {f=> '148 0 60 4 51 47 58 38 17 63 33 23 28 43 12 69 70 33 17 12 50 18 18 36 45 2 67 4 45 20 4 33 38 29 45 8 22 58 39 71 38 32 53 35 19 53 31 29 51 35 4 63 18 33 26 47 70 9 64 62 63 30 15 1 35 28 16 40 20 14 50 33 19 38 30 27 55 10 16 46 47 7 55 12 53 26 56 33 29 55 25 17 48 43 21 43 18 24 63 27 68 46 38 33 35 10 18 11 27 5 9 58 35 70 36 36 39 47 2 10 66 47 5 18 21 44 71 51 57 3 22 7 56 55 28 25 14 40 16 24 48 37 66 50 24 45 18 39 53 55 ^'}}, - {OUT=>'65C1CD932A06B05CD0B43AFB3BC7891F6BCEF45C'}], - ['135', {IN=> {f=> '165 1 15 62 35 29 15 40 19 76 67 4 5 71 46 61 26 8 77 48 1 23 12 60 40 24 44 33 29 42 73 66 49 61 20 30 1 54 52 42 39 64 23 65 37 24 20 11 26 66 22 77 22 57 7 38 57 33 61 73 7 64 1 49 35 76 14 27 21 45 68 38 58 73 13 72 47 73 33 8 66 23 38 4 56 77 47 10 71 13 20 31 41 6 51 3 18 17 61 47 14 48 76 46 28 34 43 1 56 4 25 7 65 41 1 34 37 23 59 59 27 26 13 15 14 75 60 14 1 28 59 26 65 61 16 23 17 28 6 19 2 35 49 30 29 48 2 63 73 59 1 3 76 41 11 19 18 43 54 63 67 51 4 9 78 60 66 ^'}}, - {OUT=>'70FFAE353A5CD0F8A65A8B2746D0F16281B25EC7'}], - ['136', {IN=> {f=> '181 0 18 19 84 17 12 10 57 18 77 51 52 16 39 74 49 52 63 38 72 2 15 64 83 62 49 56 11 26 68 58 83 33 23 50 63 71 53 27 84 22 39 41 52 58 11 64 7 60 45 70 22 5 73 38 30 30 48 21 75 80 40 21 8 53 9 26 30 34 81 71 71 51 23 75 33 41 23 32 5 8 66 40 72 40 16 66 45 14 48 34 21 41 27 3 55 27 37 23 41 65 4 57 51 74 22 19 75 42 16 19 46 16 10 48 20 19 37 41 14 57 9 17 55 38 5 60 7 46 20 43 36 39 52 20 10 62 45 23 46 7 35 75 29 70 35 36 34 25 12 15 84 26 10 6 71 29 79 33 32 25 59 76 82 64 58 7 8 19 41 74 2 53 65 24 1 55 51 36 21 79 7 ^'}}, - {OUT=>'CC8221F2B829B8CF39646BF46888317C3EB378EA'}], - ['137', {IN=> {f=> '184 1 60 66 66 6 3 9 73 12 7 40 70 18 71 70 65 51 14 14 27 50 9 87 81 50 22 19 40 37 16 79 12 34 37 76 82 10 61 7 81 49 67 26 45 82 50 81 63 45 69 31 31 76 51 9 59 34 51 54 34 83 10 33 51 86 81 82 69 18 8 22 64 19 86 62 58 33 37 17 34 5 29 83 42 76 50 54 66 39 9 1 36 43 17 65 6 35 56 72 71 83 88 10 1 8 87 22 6 21 78 25 89 43 62 40 55 85 31 89 74 63 46 28 24 26 31 17 7 8 27 19 12 85 17 20 27 77 10 2 54 80 17 52 74 76 69 78 11 20 80 4 29 24 85 75 18 39 23 70 83 29 57 67 72 70 33 4 15 46 42 2 69 13 53 33 69 64 33 64 14 40 69 59 78 54 ^'}}, - {OUT=>'26ACCC2D6D51FF7BF3E5895588907765111BB69B'}], - ['138', {IN=> {f=> '193 1 68 43 95 53 38 58 55 28 20 16 67 48 17 86 32 44 68 67 28 16 14 79 25 15 72 67 50 80 18 30 10 75 1 60 45 87 78 28 95 49 63 70 59 26 6 51 73 60 65 18 26 8 87 5 58 31 25 57 40 46 78 57 34 78 61 36 66 57 38 80 22 32 68 71 30 74 37 81 66 77 66 55 2 51 24 93 61 40 68 45 61 12 63 24 89 59 52 72 43 20 20 69 36 40 88 46 9 62 55 77 84 20 18 6 77 15 52 39 75 3 26 4 85 17 62 29 11 92 46 58 29 59 28 42 80 71 96 2 49 85 37 63 4 61 14 2 53 87 25 86 6 75 76 93 41 39 93 92 42 56 41 63 26 28 18 77 11 50 78 79 1 12 12 91 29 13 58 5 56 92 66 59 4 39 47 95 5 5 62 33 13 80 27 ^'}}, - {OUT=>'01072915B8E868D9B28E759CF2BC1AEA4BB92165'}], - ['139', {IN=> {f=> '203 1 35 28 11 7 20 7 17 3 3 30 89 13 65 56 66 63 22 82 16 31 55 56 77 91 91 71 101 13 10 85 101 95 17 99 98 91 33 14 20 48 32 7 64 29 38 35 25 4 95 23 34 1 85 81 23 31 96 71 84 50 15 79 47 25 51 45 35 66 19 61 60 9 31 93 64 70 30 42 86 53 1 71 46 42 22 38 96 10 99 34 76 26 55 73 63 63 97 23 92 81 64 46 1 30 31 35 86 91 88 64 87 16 37 69 84 94 60 100 3 47 52 8 71 87 57 29 76 43 18 45 46 15 65 12 44 42 66 60 15 68 19 58 39 62 76 9 92 101 57 32 4 34 15 41 62 32 89 71 43 35 31 41 21 17 82 33 96 27 62 29 82 57 46 62 15 24 99 37 83 40 52 46 56 80 98 3 91 74 6 27 7 58 94 10 41 79 97 84 77 74 26 99 35 ^'}}, - {OUT=>'3016115711D74236ADF0C371E47992F87A428598'}], - ['140', {IN=> {f=> '212 1 26 101 17 91 45 97 80 59 102 30 68 4 85 9 4 39 16 18 85 70 11 87 62 72 78 38 3 41 53 82 82 35 18 13 94 64 52 39 77 59 26 9 65 46 64 98 32 29 86 79 16 63 54 76 56 98 16 98 78 22 72 33 103 104 52 84 12 65 15 85 101 97 84 31 51 26 100 100 38 80 13 2 78 7 24 44 84 103 27 7 28 16 33 99 25 103 54 14 42 62 87 92 27 22 42 5 52 100 84 73 72 63 24 48 56 52 23 5 17 76 31 1 95 58 43 60 50 62 30 23 35 79 20 35 3 72 32 45 51 87 41 84 27 79 77 70 102 15 54 15 100 8 52 69 105 3 30 84 42 93 66 89 69 74 24 33 42 97 4 38 99 106 13 93 6 106 74 100 54 45 21 59 56 37 9 50 32 75 79 31 77 9 61 1 8 68 6 60 81 7 100 99 14 61 48 25 73 26 70 72 94 34 ^'}}, - {OUT=>'BF30417999C1368F008C1F19FECA4D18A5E1C3C9'}], - ['141', {IN=> {f=> '233 0 11 98 110 88 35 110 35 64 49 88 93 28 85 6 78 65 90 52 24 97 51 39 51 59 23 1 3 49 33 11 78 27 35 55 64 5 102 4 70 25 56 58 38 66 11 31 96 66 104 59 41 86 58 29 79 41 40 72 51 12 92 34 52 44 69 104 21 97 89 96 48 21 4 61 40 28 67 34 23 85 44 22 62 52 33 84 23 30 73 74 4 79 12 81 47 80 53 47 89 40 19 80 62 34 61 29 41 95 43 1 70 63 55 53 18 19 13 48 10 19 89 49 4 52 53 56 76 10 8 104 77 15 28 38 75 109 3 85 90 8 40 8 93 90 43 39 14 60 17 36 78 56 105 80 35 75 36 58 82 50 100 98 45 74 13 66 95 72 71 95 34 14 98 72 33 38 37 52 6 14 107 59 3 29 61 67 98 92 5 93 17 98 36 87 41 75 71 57 88 17 25 91 84 3 58 20 92 69 51 50 36 31 14 25 18 30 18 1 41 104 30 82 59 87 70 34 96 28 47 62 81 103 48 ^'}}, - {OUT=>'62BA49087185F2742C26E1C1F4844112178BF673'}], - ['142', {IN=> {f=> '234 1 63 90 108 108 102 64 82 88 4 111 76 97 22 1 108 41 34 91 33 20 25 24 26 8 83 11 31 7 85 109 106 4 105 85 68 28 33 99 53 8 16 12 11 74 17 83 66 70 16 30 9 67 68 34 24 81 47 92 72 47 37 33 38 92 17 8 28 88 22 62 69 32 89 75 3 72 96 85 13 105 24 38 37 94 115 83 72 108 114 24 93 76 103 60 99 102 9 43 10 59 95 46 33 93 15 26 69 44 2 86 107 55 45 61 65 92 66 9 55 39 70 83 29 98 67 13 111 15 20 31 62 8 2 51 20 19 33 44 14 115 71 112 97 10 41 28 53 51 26 57 15 38 98 55 106 22 56 31 50 95 107 110 84 70 10 108 96 73 100 25 36 55 88 71 63 96 30 90 96 79 22 7 30 23 28 59 89 8 51 99 47 86 34 18 43 65 98 104 107 49 7 79 71 8 57 21 29 80 2 74 78 44 57 9 61 22 13 68 52 91 74 98 43 30 58 68 95 101 72 102 76 42 99 61 ^'}}, - {OUT=>'E1F6B9536F384DD3098285BBFD495A474140DC5A'}], - ['143', {IN=> {f=> '249 0 27 117 45 119 80 2 59 52 8 76 20 94 102 69 96 42 46 106 67 9 110 89 71 69 34 31 15 85 16 29 100 82 37 62 68 95 108 44 23 114 34 36 56 93 11 30 96 12 31 67 14 114 14 66 70 30 81 46 53 119 85 6 104 47 92 72 70 5 70 15 115 68 105 33 97 13 85 106 14 61 29 22 86 45 57 69 91 38 38 28 66 13 60 95 103 3 15 5 113 38 23 62 5 65 94 107 73 104 37 47 102 117 3 78 35 7 95 56 78 45 52 28 46 43 37 32 53 19 55 29 47 97 76 115 83 71 11 45 62 73 99 116 2 24 116 7 28 41 2 29 37 52 23 5 118 79 31 57 89 61 24 101 78 50 93 73 41 7 33 45 47 24 1 48 73 36 3 25 87 46 28 108 54 68 53 67 119 28 36 118 104 42 88 27 112 4 74 85 1 63 39 97 71 74 75 76 10 49 12 79 11 50 103 118 94 117 118 37 27 12 94 60 28 51 47 82 110 17 15 105 23 52 43 12 21 22 81 41 12 74 90 42 108 117 98 67 4 69 85 ^'}}, - {OUT=>'B522DAE1D67726EBA7C4136D4E2F6D6D645AC43E'}], - ['144', {IN=> {f=> '243 0 76 81 26 101 13 68 62 106 87 19 98 32 81 63 79 93 31 121 123 75 52 11 66 41 54 87 38 5 104 62 51 38 55 29 31 120 44 16 48 94 46 105 91 66 78 27 43 6 64 2 55 79 75 84 113 22 4 113 109 31 33 17 96 11 29 63 98 103 107 116 34 14 9 95 38 18 51 75 33 109 118 55 66 4 76 7 75 70 82 74 23 1 26 69 40 112 99 47 65 31 70 119 52 103 88 85 86 28 16 12 76 25 22 78 64 21 86 27 61 77 72 108 2 18 106 119 121 54 16 85 72 2 73 26 88 66 60 80 35 24 117 63 24 44 67 52 122 119 33 72 16 99 98 69 54 19 42 28 53 114 32 117 81 100 57 49 123 56 21 68 80 53 95 1 45 95 107 98 87 1 27 24 99 116 16 67 1 113 91 84 25 40 25 72 3 28 90 87 112 80 16 117 45 77 36 90 105 59 88 122 64 108 108 71 98 18 50 115 93 105 77 35 6 46 55 47 102 4 26 87 111 120 81 113 4 57 105 3 84 94 115 61 73 ^'}}, - {OUT=>'E9A021C3EB0B9F2C710554D4BF21B19F78E09478'}], - ['145', {IN=> {f=> '255 1 91 47 51 9 57 9 55 94 61 61 68 46 107 6 35 81 114 78 96 74 14 89 73 67 67 69 113 107 11 98 113 109 20 92 17 67 70 88 57 10 124 9 60 122 93 91 45 7 15 24 51 5 98 115 24 49 90 104 117 66 128 94 64 80 12 43 91 46 111 59 58 77 30 14 88 60 123 68 41 44 68 40 104 118 41 43 93 90 105 92 16 127 26 54 125 114 79 71 24 48 21 25 118 40 103 49 91 44 67 65 25 119 109 18 48 23 69 112 38 61 64 87 84 104 119 110 122 92 22 1 8 83 34 100 32 62 41 46 112 34 102 76 56 39 4 127 30 13 19 110 124 7 16 128 95 4 124 11 104 116 126 49 95 3 55 96 70 90 101 4 122 96 75 118 39 128 99 92 18 42 20 87 83 35 75 111 61 67 71 28 101 9 56 34 105 95 71 23 73 71 26 57 15 23 76 55 99 89 128 98 117 68 43 88 62 38 62 39 2 83 36 15 26 60 128 96 73 74 10 1 12 42 22 2 77 33 33 32 57 13 14 82 57 12 39 3 58 80 14 87 85 44 69 109 119 ^'}}, - {OUT=>'DF13573188F3BF705E697A3E1F580145F2183377'}], - ['146', {IN=> {f=> '283 0 102 55 53 41 60 88 25 67 58 76 44 22 68 118 108 40 95 96 81 90 85 28 77 18 11 37 72 93 60 110 124 119 95 131 91 37 109 126 8 73 69 72 80 17 83 5 76 20 32 15 10 1 103 18 22 116 98 9 51 104 102 44 33 15 12 24 31 89 1 6 28 101 8 64 72 106 30 5 52 89 111 39 108 64 85 17 57 124 22 105 78 115 3 40 108 66 108 77 128 103 44 35 38 13 95 10 111 63 98 117 61 51 126 69 96 70 70 59 39 13 97 33 112 2 77 7 123 70 83 29 66 67 49 79 19 104 115 14 60 2 55 40 71 33 28 114 51 91 17 46 45 128 57 87 62 25 115 38 50 55 90 74 8 51 102 79 43 94 36 122 94 12 41 36 25 104 91 24 7 99 80 30 126 32 63 122 107 114 27 28 79 41 12 35 51 115 122 70 22 79 65 2 88 27 17 59 15 23 44 57 5 65 6 26 78 80 125 93 84 100 45 22 129 68 36 111 74 118 11 50 42 120 47 21 8 86 112 26 67 60 99 45 93 47 8 38 59 52 56 124 20 82 18 117 24 18 46 106 19 117 26 41 47 45 130 7 15 1 4 5 100 10 85 50 44 11 48 92 119 108 42 118 125 ^'}}, - {OUT=>'188835CFE52ECFA0C4135C2825F245DC29973970'}], - ['147', {IN=> {f=> '272 0 8 61 99 70 96 20 87 123 134 82 22 2 110 118 33 86 5 7 5 94 56 15 60 96 54 13 22 55 99 4 25 105 17 37 69 10 38 117 117 30 70 13 9 109 115 62 94 52 66 117 100 135 7 75 23 5 81 110 31 118 29 1 62 11 41 88 109 119 102 37 3 30 123 47 31 56 134 29 124 116 118 99 21 56 77 91 23 37 135 81 44 51 67 95 51 133 30 57 67 116 122 48 100 7 132 97 106 69 93 4 95 125 102 103 119 81 57 133 96 37 118 50 117 113 81 127 17 45 103 32 121 129 60 43 65 127 30 36 132 110 52 53 35 71 12 76 22 72 130 112 99 76 26 21 73 63 63 97 23 58 115 132 114 1 132 31 35 18 23 54 30 53 118 37 35 84 94 60 100 3 47 18 110 105 87 57 63 76 43 52 45 46 49 65 12 10 42 66 60 117 34 19 92 5 28 76 9 126 101 125 32 38 34 15 7 62 32 21 3 43 69 31 109 123 51 116 135 130 129 130 63 14 57 80 62 15 126 31 105 83 108 120 80 124 46 98 105 91 6 6 27 7 58 128 78 7 79 63 84 77 74 128 65 61 95 121 17 24 123 117 51 122 ^'}}, - {OUT=>'41B615A34EE2CEC9D84A91B141CFAB115821950B'}], - ['148', {IN=> {f=> '284 0 44 71 43 20 126 58 53 47 98 18 19 119 93 29 70 39 94 112 44 115 135 98 82 10 67 29 102 113 68 80 19 75 1 91 114 87 80 7 40 37 86 120 16 104 136 117 82 138 32 65 114 119 137 121 8 12 46 126 26 119 73 130 60 76 113 100 14 133 26 116 34 120 80 95 84 53 15 24 44 51 4 10 23 77 24 99 66 37 54 63 42 136 21 34 76 5 17 128 101 1 59 40 113 112 32 97 31 93 105 79 91 18 39 1 103 132 51 68 124 111 13 97 43 128 69 84 85 72 15 12 26 87 16 16 92 101 13 77 4 118 89 103 56 42 16 60 44 39 126 46 18 83 93 41 105 3 82 106 115 91 6 4 54 115 15 120 109 113 48 41 9 95 20 62 67 105 111 25 132 7 116 46 138 44 83 61 124 131 35 107 6 109 81 114 67 41 137 77 56 74 73 34 12 14 69 52 11 98 47 54 83 81 6 1 15 88 35 139 80 83 49 89 27 47 130 92 133 87 51 112 76 49 109 49 57 93 73 22 117 50 64 58 97 139 36 131 111 133 58 33 8 88 55 38 90 46 30 118 57 29 82 74 41 117 38 46 94 92 5 105 15 117 70 103 68 60 120 48 21 110 85 40 81 66 ^'}}, - {OUT=>'AB3DD6221D2AFE6613B815DA1C389EEC74AA0337'}], - ['149', {IN=> {f=> '291 0 46 113 52 134 79 74 64 57 18 23 9 52 8 16 103 57 138 59 59 65 92 2 7 130 92 8 34 40 86 131 140 100 112 4 42 1 110 108 43 37 15 67 19 35 94 61 130 98 35 88 34 65 104 56 126 118 50 87 10 81 109 90 86 118 32 6 114 88 39 38 39 62 3 12 134 72 137 35 75 81 115 106 140 112 11 123 41 103 45 95 84 71 107 13 26 110 96 62 16 109 84 59 53 38 27 8 28 13 32 137 17 138 41 122 36 99 65 99 83 36 112 29 49 70 96 126 136 131 116 3 18 17 126 142 14 37 141 141 123 42 13 20 83 42 139 83 54 49 58 42 7 137 29 48 16 121 127 34 52 140 106 128 58 36 124 83 24 69 54 61 112 17 6 95 97 24 57 86 124 59 71 119 67 1 109 54 68 49 57 132 32 5 71 113 40 80 104 75 106 133 31 126 130 104 62 9 39 44 66 116 141 135 96 132 19 41 121 126 124 77 8 4 60 82 6 101 124 89 51 123 48 40 85 77 21 112 10 69 66 115 87 16 108 30 84 65 80 103 32 131 134 73 47 10 63 39 50 93 37 135 114 69 48 34 58 23 27 133 37 9 40 98 41 115 99 70 83 29 42 67 133 55 79 80 91 122 12 2 115 112 47 ^'}}, - {OUT=>'0706D414B4AA7FB4A9051AA70D6856A7264054FB'}], - ['150', {IN=> {f=> '293 1 33 13 99 138 1 42 89 118 87 113 99 12 134 142 100 38 5 55 75 14 110 108 42 64 130 79 138 62 64 69 57 11 123 25 59 16 111 94 24 65 30 51 119 48 107 92 84 69 28 136 143 54 20 6 70 47 142 64 4 65 59 73 99 134 146 102 125 116 57 137 137 72 48 128 78 5 80 63 54 85 30 22 129 68 21 21 74 28 128 107 27 60 2 93 95 71 37 11 37 15 39 102 3 104 65 80 59 52 113 34 20 67 60 27 81 135 46 106 106 102 68 128 17 15 100 124 15 43 136 122 100 67 142 35 14 53 120 2 89 93 99 73 9 122 39 77 15 96 90 43 79 134 60 92 105 55 96 31 119 77 97 72 23 140 38 30 43 83 136 88 107 117 72 109 118 58 91 119 73 95 100 59 138 123 54 49 143 50 133 66 106 45 80 88 42 93 5 59 77 101 74 110 104 40 92 19 77 76 86 102 129 3 144 101 139 134 56 90 18 91 94 85 55 10 137 11 58 1 107 113 70 22 7 56 29 143 111 8 46 45 116 122 129 89 7 121 53 95 14 49 118 62 125 91 37 97 15 35 100 63 140 63 50 51 58 26 127 6 45 59 102 121 114 85 141 135 10 72 19 106 66 66 41 53 13 38 1 21 103 50 108 46 119 ^'}}, - {OUT=>'3CBF8151F3A00B1D5A809CBB8C4F3135055A6BD1'}], - ['151', {IN=> {f=> '297 1 46 31 132 112 28 63 124 97 129 43 40 72 99 107 132 137 96 139 99 145 121 144 118 37 81 39 94 60 55 109 47 109 110 75 42 12 139 137 43 128 106 107 19 126 12 101 148 127 15 117 125 125 62 96 13 76 70 96 101 110 138 8 95 76 143 17 32 97 79 149 39 31 94 123 21 41 135 55 84 70 33 135 118 50 62 121 81 1 45 144 93 60 5 64 137 8 105 91 82 67 27 113 119 53 18 98 79 48 84 32 135 128 5 1 20 76 17 85 108 72 36 141 140 49 150 105 104 3 149 14 54 18 148 64 49 125 37 28 28 101 22 104 91 32 82 117 12 114 69 58 2 58 115 9 108 47 59 65 14 92 7 4 86 98 16 82 92 95 38 94 10 10 48 97 104 66 115 97 142 115 122 119 40 97 16 32 47 34 88 89 26 50 12 76 80 51 40 9 133 24 44 40 122 84 108 22 142 140 99 44 15 54 8 42 125 150 130 21 79 124 62 46 119 15 29 91 57 150 42 138 71 61 68 80 114 6 1 70 121 18 35 113 56 87 86 10 73 14 29 41 72 89 1 133 87 101 123 59 90 142 77 133 52 78 48 34 138 134 27 17 60 131 147 61 93 148 39 132 49 62 71 36 91 4 139 49 100 120 43 113 144 30 94 73 127 40 125 ^'}}, - {OUT=>'DA5D6A0319272BBCCEA63ACFA6799756FFDA6840'}], - ['152', {IN=> {f=> '313 1 35 97 95 76 105 88 32 138 30 69 61 40 47 21 107 6 39 81 114 53 125 53 147 14 4 73 146 96 98 13 136 11 98 117 138 153 67 146 71 99 88 7 139 24 13 35 47 97 145 74 36 119 3 51 84 48 119 53 49 15 79 17 120 103 148 64 30 41 97 120 75 111 63 58 131 134 18 13 10 48 18 16 48 43 15 54 18 41 47 122 144 80 92 145 77 1 33 89 54 46 78 48 21 54 43 40 53 24 16 73 42 94 29 44 34 151 152 23 123 12 142 140 43 37 88 29 19 35 72 96 151 130 62 112 34 36 91 120 50 112 138 2 105 60 68 137 131 5 17 19 139 74 11 120 78 149 58 128 15 104 16 126 78 20 57 134 71 49 90 76 108 126 100 54 68 39 132 153 42 147 146 124 62 87 35 75 61 65 46 100 82 105 113 31 63 5 95 54 71 77 127 150 80 36 144 2 130 59 74 39 3 152 121 122 18 117 12 117 141 118 135 62 36 69 5 39 53 150 52 153 143 30 66 96 126 131 56 137 8 7 86 142 14 7 111 141 93 136 137 134 43 12 89 23 44 9 152 146 121 97 19 38 110 91 67 14 32 110 66 68 8 130 84 73 118 59 24 41 72 121 150 55 37 138 27 104 66 124 9 51 109 47 125 109 148 8 29 47 72 146 149 61 93 10 20 54 15 76 133 125 106 110 67 ^'}}, - {OUT=>'FB4429C95F6277B346D3B389413758DFFFEEDC98'}], - ['153', {IN=> {f=> '330 0 23 9 26 136 27 51 115 122 44 106 6 146 108 113 85 51 8 96 47 56 137 62 59 89 143 71 140 14 85 156 139 99 154 30 53 115 35 147 108 148 58 52 28 103 19 92 95 152 152 10 11 13 155 67 11 83 101 69 153 152 45 141 14 120 129 140 119 59 2 89 73 70 83 29 16 67 81 29 1 54 65 96 117 2 37 47 128 33 3 89 108 98 139 49 78 27 103 39 119 94 132 90 38 132 55 65 131 90 58 2 54 100 69 118 22 44 19 7 148 93 25 29 123 81 64 131 55 30 1 89 38 97 82 64 9 28 86 123 151 10 133 40 154 102 4 111 65 9 63 59 124 116 72 105 76 57 137 97 32 145 108 78 112 50 43 34 75 20 22 129 68 11 118 74 125 118 57 17 20 129 53 65 61 144 1 17 142 156 52 100 54 15 20 59 52 63 131 20 57 124 31 125 46 106 76 92 8 98 154 152 80 114 15 140 136 112 100 17 92 25 151 150 80 99 69 83 49 43 156 102 19 57 122 96 30 3 39 134 40 32 75 5 76 127 138 99 17 57 52 150 130 18 127 33 23 116 107 78 77 77 42 69 68 48 41 69 33 75 40 49 128 103 4 146 93 10 83 66 96 152 30 38 12 33 5 39 47 41 34 60 74 20 42 156 67 46 56 102 89 3 124 81 99 104 56 50 8 61 74 55 15 87 108 28 138 47 93 60 2 124 46 126 103 91 145 36 25 116 122 51 ^'}}, - {OUT=>'2C6E30D9C895B42DCCCFC84C906EC88C09B20DE1'}], - ['154', {IN=> {f=> '322 0 75 7 107 158 81 105 154 90 20 125 77 114 69 92 7 58 21 98 154 50 128 149 117 127 153 45 3 18 121 86 29 71 79 101 2 5 22 143 10 27 53 146 157 148 112 33 22 80 123 24 147 1 112 82 159 63 74 97 109 33 151 32 89 87 132 117 46 129 59 115 91 114 118 37 21 9 94 60 25 89 47 79 110 55 12 143 99 87 43 88 56 57 160 76 12 71 128 77 146 117 95 105 42 66 3 76 20 76 101 100 118 149 45 26 143 148 32 57 39 129 19 31 84 123 1 152 135 5 54 30 13 125 68 30 62 101 51 142 5 94 83 20 116 24 107 109 105 91 42 17 27 93 69 3 139 68 79 38 84 2 85 128 126 122 131 46 17 35 98 42 26 111 100 29 120 55 84 114 109 145 14 18 138 14 9 85 7 18 129 91 2 94 51 133 82 87 123 64 39 8 103 38 75 110 78 7 9 45 115 42 138 135 86 78 16 62 52 75 159 54 151 121 149 77 74 16 85 47 102 105 82 119 10 67 137 153 148 135 28 49 26 151 153 36 80 11 130 113 24 44 30 102 24 58 133 122 140 99 24 156 54 119 42 115 140 90 132 19 94 2 157 99 136 19 71 7 130 153 108 51 21 58 70 74 137 1 40 111 149 5 103 6 27 76 141 23 125 140 1 72 29 152 103 87 51 93 29 80 132 77 123 153 68 159 14 98 114 158 121 158 81 131 ^'}}, - {OUT=>'3DE3189A5E19F225CDCE254DFF23DACD22C61363'}], - ['155', {IN=> {f=> '322 0 35 93 109 125 119 10 10 19 135 26 4 74 135 35 120 129 113 92 17 29 47 88 14 159 149 87 45 36 75 68 22 138 20 59 61 144 151 11 107 6 153 81 114 43 85 157 97 148 118 73 126 56 58 137 96 11 98 67 98 103 57 146 21 59 88 151 139 148 127 25 17 47 115 34 160 109 107 51 64 28 69 13 49 149 69 141 90 93 118 64 10 1 67 80 35 111 13 58 101 124 132 147 154 18 162 6 162 33 5 34 142 41 161 82 114 70 92 145 57 155 137 114 79 44 36 48 48 21 14 13 40 33 14 150 33 32 54 143 14 4 101 142 23 93 136 132 120 147 17 38 163 143 5 52 46 151 130 32 72 34 124 150 51 100 112 128 126 65 10 28 87 81 159 131 19 99 54 125 110 58 119 28 78 129 104 140 126 38 154 27 114 61 153 90 66 98 76 50 158 48 39 82 123 22 147 136 114 52 37 35 75 41 15 150 60 52 55 103 21 23 129 95 24 71 47 97 130 50 140 144 106 100 9 64 19 117 122 71 92 8 77 156 97 121 98 85 2 36 39 109 143 23 120 156 133 93 154 36 66 116 131 160 127 162 161 46 142 14 141 81 141 63 86 117 104 3 146 39 127 34 133 102 106 91 57 9 28 60 61 7 158 12 80 26 8 122 80 44 63 68 49 158 21 32 81 150 15 141 108 161 64 46 124 123 31 99 27 105 109 98 112 144 ^'}}, - {OUT=>'93530A9BC9A817F6922518A73A1505C411D05DA2'}], - ['156', {IN=> {f=> '336 1 34 161 107 149 48 67 138 109 156 104 37 133 60 80 84 81 160 9 16 96 164 1 95 112 4 86 163 116 98 103 55 31 8 56 37 36 127 32 9 89 103 31 100 161 85 106 119 89 154 43 115 162 137 108 128 38 42 155 103 9 62 65 102 122 10 138 160 125 47 158 43 91 69 123 132 35 121 4 110 89 130 69 29 139 69 53 70 83 29 163 67 41 9 108 34 45 76 87 2 144 164 98 33 160 79 78 48 89 9 38 134 93 146 79 54 122 80 38 112 55 55 101 70 8 129 44 70 59 98 149 24 136 124 138 63 25 166 83 51 34 91 45 30 118 59 28 87 72 44 116 28 36 103 101 113 10 114 62 111 71 65 126 53 19 114 86 42 85 36 57 137 57 159 95 88 78 72 20 23 14 65 10 22 129 68 1 68 74 75 108 7 7 147 109 13 35 51 104 158 164 122 126 2 50 4 132 127 59 52 13 81 20 47 107 74 148 115 46 106 46 82 115 68 144 142 60 104 15 90 136 102 100 134 42 15 141 100 40 49 49 73 166 13 156 82 166 37 82 96 137 130 166 134 20 139 45 122 56 107 98 79 124 17 32 130 120 165 77 23 130 96 67 68 47 37 12 29 18 38 158 19 160 55 147 39 118 83 121 96 43 137 33 66 86 112 147 155 149 140 5 19 17 148 161 10 44 159 146 57 16 26 102 49 3 104 61 59 74 56 10 165 31 54 25 142 157 37 58 165 128 154 73 50 149 94 137 ^'}}, - {OUT=>'E31354345F832D31E05C1B842D405D4BD4588EC8'}], - ['157', {IN=> {f=> '330 1 61 51 65 132 23 169 116 122 14 66 7 98 131 72 69 127 72 163 125 68 69 51 47 159 31 164 71 118 50 83 113 81 127 153 45 137 134 121 68 163 26 43 65 127 166 138 98 144 18 53 137 139 148 76 158 4 62 78 167 102 144 94 55 141 63 29 97 91 24 115 166 80 69 132 99 1 120 23 88 64 87 118 37 137 152 94 60 168 71 47 52 110 37 155 125 63 42 43 52 11 12 151 31 12 44 110 32 128 117 68 87 24 39 164 76 145 58 101 91 100 140 151 143 130 32 21 3 111 1 31 75 123 153 116 135 130 27 164 165 116 23 12 62 83 24 133 139 49 74 154 80 158 80 64 105 91 6 142 27 75 24 128 112 41 79 29 84 145 40 128 99 95 95 19 17 160 89 15 17 84 64 11 93 10 66 78 73 127 148 18 129 139 143 49 150 9 84 82 154 85 15 88 82 60 87 19 12 133 58 20 39 65 51 141 134 27 70 167 120 117 86 60 16 44 16 57 132 18 142 85 104 59 47 141 58 2 66 96 46 119 153 40 110 126 103 90 144 13 26 106 144 80 145 134 103 95 24 44 21 84 140 13 97 104 140 99 6 147 54 83 42 106 131 54 96 135 67 118 121 81 109 10 53 132 112 117 81 33 155 49 61 38 119 1 13 102 131 148 94 131 143 67 123 148 89 104 135 72 145 152 76 87 6 66 2 71 123 77 114 108 59 123 166 62 96 140 94 149 116 169 ^'}}, - {OUT=>'3FF76957E80B60CF74D015AD431FCA147B3AF232'}], - ['158', {IN=> {f=> '349 0 125 17 93 82 80 110 156 147 156 99 154 4 29 90 163 120 84 113 56 8 157 29 61 169 141 113 78 48 50 13 138 11 50 61 99 106 2 107 6 117 81 114 34 49 112 52 130 82 73 108 20 22 110 60 11 98 22 62 58 48 146 149 23 88 142 139 121 91 16 163 2 88 171 133 100 62 51 46 10 24 150 49 131 60 114 63 84 91 64 165 138 40 44 172 111 141 58 74 115 96 129 145 164 153 170 126 24 169 16 115 41 125 46 87 61 92 145 39 155 92 78 70 35 27 21 48 21 151 159 40 15 5 132 170 23 18 107 160 150 56 133 23 66 109 123 102 102 172 166 145 116 151 34 1 151 130 5 36 34 97 114 15 82 128 112 119 99 29 138 165 42 36 159 95 19 63 36 89 101 40 92 1 33 93 104 113 126 2 136 96 52 108 90 57 89 31 5 113 30 39 37 96 4 147 127 105 43 165 35 75 23 143 105 24 25 10 94 12 160 102 95 170 71 20 70 112 23 95 144 61 73 137 55 1 81 95 26 65 172 41 147 79 103 80 40 121 36 12 64 98 169 93 111 115 48 127 9 39 107 131 115 118 162 161 10 142 14 123 54 141 36 41 99 77 140 128 167 82 25 106 57 70 64 21 19 15 34 126 149 167 53 163 127 86 35 8 54 23 40 140 3 169 45 150 152 96 81 143 28 28 124 87 13 90 9 87 109 53 67 164 28 131 89 149 42 55 126 79 132 74 19 133 30 68 72 75 148 9 10 72 152 144 83 106 153 74 163 98 152 ^'}}, - {OUT=>'34AE3B806BE143A84DCE82E4B830EB7D3D2BAC69'}], - ['159', {IN=> {f=> '375 1 94 28 13 8 20 28 18 118 5 140 89 67 171 64 152 85 61 101 80 154 149 34 115 135 128 108 110 20 33 128 103 35 38 57 95 10 111 151 98 29 149 7 82 69 96 114 26 103 171 101 53 121 24 2 121 51 35 70 83 29 154 67 5 167 63 16 27 58 60 2 99 128 71 33 160 70 51 3 44 149 2 89 84 101 43 18 113 71 38 94 55 46 74 52 139 102 35 43 50 80 122 6 100 88 129 36 25 148 47 24 7 55 36 30 82 32 19 78 63 26 71 28 167 85 56 167 95 159 78 26 66 35 65 90 44 159 105 59 15 67 57 137 21 132 50 70 78 36 169 5 172 56 1 22 129 68 168 23 74 30 99 138 174 120 91 153 8 42 68 158 155 104 99 133 5 135 96 82 59 52 144 36 20 38 62 29 112 106 46 106 19 73 70 41 135 133 42 95 15 45 136 93 100 98 173 6 132 55 4 4 31 64 130 162 156 64 157 19 46 96 92 103 139 134 2 94 18 86 38 89 62 61 79 157 14 112 111 156 32 14 85 78 31 59 20 1 161 169 149 29 122 150 133 37 102 30 109 65 85 51 174 110 164 66 77 76 111 119 131 95 5 1 166 103 134 141 17 158 123 137 48 165 175 102 13 3 86 43 23 47 56 150 165 4 36 174 115 157 168 13 147 119 109 55 41 140 67 27 31 27 53 126 17 163 116 122 160 60 7 92 113 66 45 109 60 151 125 62 39 39 17 153 13 152 53 94 50 53 89 57 127 153 45 119 104 121 56 145 172 19 41 103 166 108 68 126 12 53 131 127 148 52 134 168 50 48 155 72 132 82 37 129 63 175 160 ^'}}, - {OUT=>'D7447E53D66BB5E4C26E8B41F83EFD107BF4ADDA'}], - ['160', {IN=> {f=> '366 1 73 15 79 139 71 51 132 81 135 111 166 61 37 60 118 37 92 134 94 60 150 53 47 25 110 19 137 107 27 176 43 16 145 146 142 165 12 17 92 166 110 117 41 69 6 12 164 76 109 40 101 82 82 131 134 115 143 112 32 164 146 93 162 31 66 123 144 80 135 94 137 156 107 157 173 62 65 176 124 112 4 65 127 44 131 53 19 105 91 149 106 27 57 158 92 85 14 79 20 84 127 174 128 72 68 59 171 17 124 80 167 8 57 28 172 66 144 48 42 37 109 121 18 120 103 116 13 132 39 73 145 76 158 43 82 33 51 153 164 97 13 2 3 20 24 114 98 9 25 131 102 99 86 42 16 26 159 39 105 161 133 49 59 41 20 105 31 136 30 87 10 119 135 13 83 99 58 45 99 156 26 61 135 143 80 118 107 76 77 24 44 12 66 95 147 61 86 140 99 167 138 54 47 42 97 122 18 60 90 40 73 85 63 82 1 35 96 94 81 54 15 128 40 52 2 101 1 165 93 113 130 85 95 98 58 105 112 53 68 108 72 100 152 49 87 140 39 154 62 114 77 105 63 50 87 157 26 78 122 67 140 71 170 119 5 93 64 50 104 144 129 138 75 130 4 178 60 139 120 54 113 32 2 133 17 43 163 129 89 72 149 155 30 38 7 138 5 44 61 69 76 175 107 6 93 81 114 28 25 82 22 118 58 73 96 175 177 92 36 11 98 171 38 28 42 146 125 178 88 136 139 103 67 10 151 151 70 153 115 94 32 51 34 177 173 132 49 119 54 96 45 78 73 64 159 120 22 20 154 111 117 58 56 109 72 143 ^'}}, - {OUT=>'77DD2A4482705BC2E9DC96EC0A13395771AC850C'}], - ['161', {IN=> {f=> '372 1 136 146 144 170 90 15 169 180 88 41 89 10 60 52 92 145 21 155 47 42 61 26 18 176 48 21 124 141 40 179 178 114 143 14 164 71 142 132 11 124 23 39 82 114 84 57 163 130 127 89 133 16 138 151 130 160 34 70 78 161 64 92 112 110 72 175 102 138 179 173 159 59 19 27 18 53 92 22 65 156 170 57 104 86 126 148 118 155 78 43 63 90 48 80 168 142 68 12 39 174 69 168 147 118 96 34 129 35 75 5 107 60 170 180 147 85 3 133 75 95 152 71 175 43 94 178 50 144 16 46 101 46 165 45 68 163 38 172 5 138 61 85 62 177 76 36 167 19 53 151 66 66 97 3 100 164 12 98 131 70 109 162 161 156 142 14 105 27 141 9 178 81 50 113 110 131 37 16 79 12 34 37 167 173 10 152 7 81 140 158 26 136 82 50 172 154 45 160 31 122 167 142 9 150 125 51 54 125 174 10 124 51 177 81 173 69 109 8 22 155 19 86 62 149 33 37 108 34 96 29 174 133 167 50 54 66 130 9 1 36 134 108 65 97 126 56 163 71 83 88 10 1 8 178 22 6 112 169 116 89 43 153 40 146 85 31 89 74 154 137 28 115 117 122 108 98 8 27 110 103 176 17 20 27 77 10 93 145 80 17 143 165 76 69 78 102 20 91 171 95 29 115 176 166 109 39 23 70 83 29 148 67 163 161 33 4 15 46 42 2 69 104 53 33 160 64 33 155 14 131 160 59 78 71 19 176 107 65 38 82 55 40 56 40 115 84 29 25 44 68 104 176 76 64 123 18 25 136 23 6 171 31 30 30 58 14 13 72 57 14 41 177 ^'}}, - {OUT=>'EAA1465DB1F59DE3F25EB8629602B568E693BB57'}], - ['162', {IN=> {f=> '363 0 135 69 16 167 79 143 46 178 26 3 65 58 36 135 97 35 175 51 152 57 137 173 108 10 54 78 4 153 173 164 48 177 22 129 68 168 167 74 174 91 106 174 96 75 129 168 34 36 158 147 88 75 101 149 103 64 42 59 52 112 180 20 30 22 173 80 98 46 106 179 65 30 17 127 125 26 87 15 5 136 85 100 66 141 182 124 15 156 148 15 56 98 146 156 48 149 3 14 96 52 79 115 134 170 54 178 54 22 73 30 45 39 133 182 96 103 148 176 6 45 62 183 51 180 153 145 145 117 21 90 118 109 21 62 22 101 49 53 11 142 86 132 66 69 44 79 87 115 55 5 169 150 63 110 109 177 150 91 129 40 149 159 102 165 3 70 27 175 23 56 126 165 164 20 158 91 157 136 157 131 111 69 39 33 132 43 19 175 179 37 118 9 155 116 122 128 52 7 84 89 58 13 85 44 135 125 54 183 23 161 145 173 136 29 62 50 13 57 25 127 153 45 95 64 121 40 121 140 171 9 71 166 68 28 102 4 53 123 111 148 20 102 160 34 8 139 32 116 66 13 113 63 143 97 63 10 59 124 66 41 132 71 115 106 151 46 22 45 118 37 67 124 94 60 140 43 47 10 110 9 127 97 7 156 43 180 125 126 137 145 12 2 82 146 100 117 26 59 180 181 164 76 89 30 101 77 72 126 114 95 143 102 32 149 131 83 157 31 61 123 139 60 135 74 169 122 151 102 137 168 62 55 166 119 97 163 60 112 24 116 38 178 105 91 134 86 27 47 138 72 70 183 79 15 84 117 154 128 57 53 39 161 88 ^'}}, - {OUT=>'9329D5B40E0DC43AA25FED69A0FA9C211A948411'}], - ['163', {IN=> {f=> '393 1 92 72 151 33 183 164 42 112 32 10 5 93 97 18 112 71 92 168 116 179 186 65 137 68 134 3 82 9 19 121 148 65 160 173 158 167 90 66 180 172 99 86 83 86 26 16 10 135 23 81 137 125 17 19 25 183 73 7 104 185 79 165 119 119 176 59 75 18 5 59 132 26 21 127 119 80 94 83 52 61 24 44 4 50 55 115 29 70 140 99 159 130 54 15 42 89 114 173 28 50 16 33 53 47 58 180 19 64 78 49 30 186 104 32 44 157 85 1 149 85 97 114 77 63 58 50 89 80 21 36 84 72 60 152 25 87 108 15 138 54 106 77 97 23 42 55 149 181 62 106 43 132 31 138 111 176 93 40 10 96 128 105 114 43 98 4 146 20 107 120 14 113 181 101 1 19 155 113 57 64 117 131 6 22 186 138 184 36 61 29 36 175 107 6 61 81 114 20 180 42 169 102 26 73 80 151 153 68 4 11 98 139 6 175 34 146 93 154 88 128 139 79 35 2 135 119 46 129 91 86 179 51 18 169 141 108 49 103 46 72 21 70 49 64 151 96 185 175 130 111 85 58 32 101 40 101 131 136 139 170 70 10 169 175 73 41 69 177 45 47 92 145 11 155 22 22 56 21 13 166 48 21 109 131 40 174 178 104 128 9 149 51 132 122 173 119 23 24 67 109 74 32 158 110 117 74 123 6 118 151 130 150 167 34 55 58 146 54 72 112 105 57 160 82 123 159 153 159 39 19 7 8 33 87 12 50 146 150 37 104 71 126 133 108 145 68 38 38 90 43 75 148 122 43 2 39 154 54 163 147 113 91 29 109 35 75 182 87 35 155 170 127 80 185 118 60 95 142 71 165 28 84 168 25 144 178 31 81 41 160 25 53 143 ^'}}, - {OUT=>'E94C0B6AA62AA08C625FAF817DDF8F51EC645273'}], - ['164', {IN=> {f=> '381 1 14 172 163 130 45 69 46 145 36 36 151 169 13 135 42 26 81 153 76 148 178 90 131 30 101 162 161 132 142 14 89 3 141 175 146 65 26 89 94 99 187 8 55 162 2 13 143 173 2 120 173 41 132 150 2 112 42 18 140 130 37 128 23 106 159 118 167 150 101 11 30 109 150 184 124 19 169 73 165 53 109 158 172 147 11 46 38 149 25 21 92 184 64 179 158 133 135 34 38 58 114 9 183 4 118 76 49 89 102 40 163 47 75 80 176 175 8 154 14 180 104 153 84 89 11 129 8 138 85 181 73 66 154 121 20 115 93 114 108 82 182 19 86 103 176 183 186 177 53 10 69 137 56 1 135 141 68 69 54 86 12 75 171 87 187 107 144 150 93 23 7 70 83 29 140 67 139 153 183 178 189 30 18 2 29 72 29 33 160 56 9 123 164 107 136 19 70 31 177 152 99 57 38 66 55 32 32 24 83 60 21 1 36 52 80 168 44 32 115 184 25 120 181 172 155 189 22 30 26 180 5 64 49 188 1 28 111 57 176 167 67 131 22 160 186 169 65 34 30 117 91 17 163 39 134 57 137 155 90 170 42 78 170 141 167 158 42 177 22 129 68 168 143 74 150 85 82 174 78 63 111 156 28 12 158 141 76 57 77 125 79 40 12 59 52 88 156 20 24 182 149 56 92 46 106 167 59 189 121 119 14 81 15 165 136 79 100 42 117 182 118 175 138 124 3 50 74 134 156 36 143 181 180 96 22 61 97 134 164 24 166 30 10 61 6 33 9 115 176 84 97 142 152 15 50 165 45 168 135 133 127 93 15 66 94 91 9 32 16 95 37 29 171 118 68 108 66 63 20 55 186 ^'}}, - {OUT=>'7FF02B909D82AD668E31E547E0FB66CB8E213771'}], - ['165', {IN=> {f=> '396 1 97 10 5 160 132 18 83 73 159 141 55 120 31 131 141 102 138 3 52 9 148 189 56 99 165 146 2 140 64 157 100 121 113 102 24 21 24 123 16 10 139 152 19 109 146 116 122 92 43 7 75 62 49 170 58 26 117 125 45 147 5 125 136 155 118 2 26 50 161 21 182 127 153 45 68 19 121 22 94 104 144 166 35 166 23 176 75 188 53 114 93 148 177 66 151 16 156 121 180 98 48 179 95 63 107 97 45 1 23 97 57 23 132 53 79 97 124 19 188 18 118 37 22 106 94 60 122 25 47 176 110 184 109 79 164 120 43 153 89 90 128 109 12 168 64 110 82 117 192 41 171 163 164 76 53 12 101 68 54 117 78 59 143 84 32 122 104 65 148 31 52 123 130 24 135 38 151 95 142 93 101 159 62 37 148 110 70 127 51 85 181 89 11 142 105 91 107 50 27 29 102 36 43 165 79 6 84 99 118 128 30 26 3 143 17 68 66 139 187 15 165 158 24 88 20 179 174 81 79 18 106 47 74 150 104 179 162 59 131 62 116 166 82 184 188 97 136 41 136 167 140 143 175 72 42 174 148 75 74 71 86 14 16 191 117 11 63 119 119 186 182 13 171 49 182 80 167 73 147 119 107 164 41 57 181 168 29 114 26 184 121 101 80 76 65 34 49 24 44 191 38 25 91 5 58 140 99 153 124 54 184 42 83 108 155 4 20 191 3 29 35 40 180 7 40 66 25 12 180 86 26 38 139 73 1 137 79 85 102 71 39 28 44 77 56 190 12 66 72 30 152 7 87 84 190 126 48 100 77 91 186 36 31 143 163 50 94 25 126 1 114 105 170 93 22 173 90 116 87 96 19 74 4 122 183 83 120 177 113 169 181 77 182 1 149 186 ^'}}, - {OUT=>'5BB3570858FA1744123BAC2873B0BB9810F53FA1'}], - ['166', {IN=> {f=> '384 1 25 56 85 107 177 6 186 138 184 28 61 184 191 175 107 6 29 81 114 12 156 2 137 86 189 73 64 127 129 44 167 11 98 107 169 143 26 146 61 130 88 120 139 55 3 189 119 87 22 105 67 78 147 51 2 161 109 84 49 87 38 48 192 62 25 64 143 72 169 151 106 111 53 58 8 93 8 85 123 120 131 170 38 2 169 167 49 41 37 153 21 39 92 145 190 155 177 185 48 13 5 150 48 21 85 115 40 166 178 88 104 1 125 19 116 106 141 111 23 43 101 58 187 150 78 101 50 107 185 86 151 130 134 143 34 31 26 122 38 40 112 97 33 136 50 99 127 121 159 7 19 170 187 1 79 191 26 130 118 5 104 47 126 109 92 129 52 30 193 90 35 67 116 90 3 181 39 122 30 155 147 105 83 21 77 35 75 174 55 190 131 154 95 72 185 94 36 95 126 71 149 4 68 152 180 144 146 7 49 33 152 188 29 111 194 172 148 125 35 59 36 125 11 36 141 149 183 125 27 1 71 133 61 138 168 85 131 5 96 162 161 117 142 14 79 183 141 165 126 55 11 74 84 79 167 3 40 142 177 193 128 173 192 100 163 16 127 145 182 97 17 193 120 115 32 108 18 96 154 103 152 150 86 181 15 99 135 179 124 194 164 68 160 43 109 138 152 142 6 21 23 149 20 11 82 164 44 159 148 133 115 24 28 53 104 9 183 179 108 56 39 84 87 30 163 32 70 75 166 170 8 139 9 175 99 143 64 89 186 114 183 133 85 161 63 61 154 111 15 115 78 109 108 72 177 14 71 103 176 173 176 157 38 10 54 132 41 186 130 126 63 69 39 76 7 65 171 82 172 102 124 140 83 113 ^'}}, - {OUT=>'905F43940B3591CE39D1145ACB1ECA80AB5E43CD'}], - ['167', {IN=> {f=> '396 1 189 70 83 29 132 67 115 145 151 170 181 14 192 2 187 40 5 33 160 48 183 91 132 83 112 177 62 189 153 128 91 49 38 50 55 24 8 8 51 36 13 175 28 36 56 160 12 107 168 25 104 157 156 139 165 14 30 192 164 195 56 41 180 159 28 79 41 144 167 51 115 188 136 154 145 65 2 22 93 83 191 147 23 110 57 137 131 66 138 26 78 146 125 159 150 34 177 22 129 68 168 111 74 118 77 50 174 54 47 87 140 20 178 158 133 60 33 45 93 47 8 170 59 52 56 124 20 16 150 117 24 84 46 106 151 51 158 173 113 111 196 73 15 133 136 71 100 10 85 182 110 143 114 92 185 42 42 118 156 20 135 173 156 96 180 37 73 134 156 182 150 196 192 45 172 17 167 91 168 68 89 134 120 190 173 34 141 37 152 111 117 103 61 7 34 62 67 191 190 8 87 21 195 139 86 44 76 66 55 186 23 31 87 183 5 155 122 191 68 53 149 136 35 115 26 121 131 102 123 3 42 197 133 179 56 84 165 136 190 130 49 157 80 101 103 97 197 11 19 118 1 5 119 137 9 104 193 141 116 122 72 38 7 70 47 44 155 43 16 107 125 40 127 193 105 131 145 108 185 6 50 141 1 167 127 153 45 53 192 121 12 79 84 129 151 15 166 196 156 60 188 53 109 83 148 162 46 146 6 136 111 160 88 38 169 85 63 87 97 35 194 3 82 52 13 132 43 59 92 109 4 178 3 118 37 195 96 94 60 112 15 47 166 110 179 99 69 149 100 43 138 69 70 123 89 12 158 54 90 72 117 182 31 166 153 164 76 33 2 101 63 44 112 58 39 143 74 32 107 89 55 143 31 47 123 125 4 135 18 141 80 137 88 81 154 187 ^'}}, - {OUT=>'336C79FBD82F33E490C577E3F791C3CBFE842AFF'}], - ['168', {IN=> {f=> '406 0 23 134 103 49 99 44 64 160 68 190 114 105 91 86 22 27 15 74 8 22 151 79 199 84 85 90 128 9 5 175 129 17 40 59 125 187 194 144 151 3 60 6 158 153 67 58 18 99 19 53 129 90 179 134 52 124 55 95 138 82 170 167 69 122 13 108 160 119 115 161 51 14 167 120 47 60 57 86 16 184 96 197 42 98 112 165 154 199 157 21 168 52 146 66 126 119 93 150 20 36 153 140 194 93 26 156 114 80 80 55 44 13 35 24 44 191 24 190 63 177 44 140 99 146 117 54 163 42 76 101 134 176 185 177 168 1 21 19 180 193 12 52 197 191 173 65 19 31 118 59 1 123 72 71 88 64 11 193 37 63 28 169 184 45 72 195 152 186 87 56 176 112 41 93 77 84 158 29 3 136 142 36 80 4 119 166 86 98 163 93 1 145 83 102 66 75 191 46 4 94 155 55 120 149 113 148 181 49 175 180 142 87 5 51 65 92 167 196 186 138 184 23 61 164 171 175 107 6 9 81 114 7 141 177 117 76 174 73 54 112 114 29 152 11 98 87 154 123 21 146 41 115 88 115 139 40 183 189 109 67 7 90 52 73 127 51 192 156 89 69 49 77 33 33 182 57 10 64 138 57 159 136 91 111 33 58 193 88 188 75 118 110 126 170 18 197 169 162 34 41 17 138 6 34 92 145 185 155 157 170 43 8 140 48 21 70 105 40 161 178 78 89 196 110 199 106 96 121 106 23 185 28 96 48 167 145 58 91 35 97 180 66 151 130 124 128 34 16 6 107 28 20 112 92 18 121 30 84 107 101 159 187 19 155 182 181 74 186 11 120 98 185 104 32 126 94 82 119 42 25 173 90 30 62 96 70 178 176 39 102 15 150 147 100 78 16 57 35 75 169 35 170 116 144 75 146 ^'}}, - {OUT=>'5C6D07A6B44F7A75A64F6CE592F3BAE91E022210'}], - ['169', {IN=> {f=> '409 1 185 70 12 95 110 71 133 183 52 136 148 144 114 186 17 25 144 164 5 79 178 172 124 117 19 43 20 93 174 36 125 117 151 109 3 164 55 101 37 122 152 77 131 168 88 162 161 93 142 14 63 167 141 149 94 39 190 50 68 47 135 198 16 110 153 177 104 173 192 68 147 179 119 137 166 73 180 169 88 91 24 76 10 80 146 79 128 150 62 149 194 83 111 171 124 170 156 60 152 27 109 106 120 134 201 184 202 149 12 198 66 132 12 127 132 133 83 8 12 45 88 9 183 155 92 24 23 76 63 14 163 8 62 67 150 162 8 115 1 167 91 127 32 89 162 90 159 125 85 129 47 53 154 95 7 115 54 101 108 56 169 6 47 103 176 157 160 125 14 10 30 124 17 178 122 102 55 69 15 60 202 49 171 74 148 94 92 124 67 200 184 70 83 29 127 67 100 140 131 165 176 4 182 2 167 20 193 33 160 43 173 71 112 68 97 157 57 169 138 113 86 44 38 40 55 19 196 201 31 21 8 165 23 26 41 155 195 183 102 158 25 94 142 146 129 150 9 30 177 154 195 51 36 175 139 28 59 31 124 167 41 105 173 121 134 130 65 185 17 78 78 181 137 13 95 57 137 116 51 118 16 78 131 115 154 145 29 177 22 129 68 168 91 74 98 72 30 174 39 37 72 130 15 163 158 128 50 18 25 73 27 191 150 59 52 36 104 20 11 130 97 4 79 46 106 141 46 138 163 108 106 191 68 15 113 136 66 100 193 65 182 105 123 99 72 180 37 22 108 156 10 130 168 141 96 160 22 58 134 151 162 140 181 187 35 157 7 147 76 163 58 84 129 100 190 153 24 126 32 142 96 107 88 41 2 14 42 52 186 170 3 82 11 180 119 66 29 56 66 50 171 3 11 77 163 5 150 112 128 ^'}}, - {OUT=>'7E0D3E9D33127F4A30EB8D9C134A58409FA8695B'}], - ['170', {IN=> {f=> '413 1 47 25 135 129 7 108 19 107 117 102 102 3 28 190 112 165 56 63 165 122 183 116 28 157 52 73 89 90 169 202 12 111 185 203 91 116 200 97 193 134 116 122 44 31 7 63 26 37 134 22 2 93 125 33 99 186 77 124 131 94 171 183 50 113 178 146 127 153 45 32 164 121 203 58 56 108 130 192 166 168 128 39 188 53 102 69 148 141 18 139 197 108 97 132 74 24 155 71 63 59 97 21 194 180 61 45 204 132 29 31 85 88 188 164 187 118 37 167 82 94 60 98 1 47 152 110 172 85 55 128 72 43 117 41 42 116 61 12 144 40 62 58 117 168 17 159 139 164 76 5 193 101 56 30 105 30 11 143 60 32 86 68 41 136 31 40 123 118 181 135 195 127 59 130 81 53 147 62 13 124 98 34 79 39 49 145 53 180 94 105 91 71 2 27 5 54 193 7 141 79 199 84 75 70 128 199 195 160 119 17 20 54 115 187 184 129 146 193 40 201 143 138 57 43 18 94 204 38 114 80 179 114 47 119 50 80 118 82 160 152 49 112 198 88 155 104 95 151 36 199 162 100 27 50 47 86 195 16 179 81 192 27 83 107 150 134 194 147 1 158 32 131 61 111 119 83 140 5 21 133 120 174 78 26 136 109 65 80 40 29 203 25 24 44 191 14 170 43 162 34 140 99 141 112 54 148 42 71 96 119 161 165 167 148 186 11 4 180 188 197 42 182 181 168 50 14 26 103 49 1 113 67 61 78 59 196 173 32 53 8 154 169 30 72 175 152 176 87 36 166 102 36 88 77 79 138 24 188 131 127 26 70 194 114 146 66 93 158 93 191 125 78 92 51 60 176 26 4 74 135 35 120 129 113 133 181 29 170 170 137 77 190 46 45 77 157 191 186 138 184 18 61 144 151 175 107 6 194 81 114 2 126 110 ^'}}, - {OUT=>'9A5F50DFCFB19286206C229019F0ABF25283028C'}], - ['171', {IN=> {f=> '427 1 85 60 150 73 38 88 90 5 128 11 98 55 130 91 13 146 9 91 88 107 139 16 159 189 93 35 191 66 28 65 95 51 184 148 57 45 49 61 25 9 166 49 194 64 130 33 143 112 67 111 1 58 177 80 164 59 110 94 118 170 194 197 169 154 10 41 193 114 190 26 92 145 177 155 125 146 35 200 124 48 21 46 89 40 153 178 62 65 196 86 175 90 80 89 98 23 169 4 88 32 135 137 26 75 11 81 172 34 151 130 108 104 34 200 182 83 12 196 112 84 202 97 206 60 75 69 159 163 19 131 174 157 66 178 195 104 66 161 104 8 126 70 66 103 26 17 141 90 22 54 64 38 146 168 39 70 199 142 147 92 70 8 25 35 75 161 3 138 92 128 43 59 185 55 205 95 100 71 123 173 42 126 128 144 94 176 205 20 139 149 198 59 168 172 109 112 9 33 10 73 154 36 115 97 131 99 196 144 45 81 22 112 142 72 131 148 83 162 161 78 142 14 53 157 141 139 74 29 180 35 58 27 115 198 1 90 138 167 89 173 192 48 137 159 114 132 156 58 160 154 68 76 19 56 5 70 141 64 113 150 47 129 184 73 96 166 124 155 151 55 147 17 109 86 100 129 201 164 192 149 7 193 56 112 200 107 122 133 63 206 2 40 78 9 183 140 82 4 13 71 48 4 163 201 57 62 140 157 8 100 204 162 86 117 12 89 147 75 144 120 85 109 37 48 154 85 2 115 39 96 108 46 164 1 32 103 176 147 150 105 207 10 15 119 2 173 117 87 50 69 50 202 39 171 69 133 89 72 114 57 195 179 70 83 29 122 67 85 135 111 160 171 202 172 2 147 183 33 160 38 163 51 92 53 82 137 52 149 123 98 81 39 38 30 55 14 186 196 11 6 3 155 18 16 26 150 180 168 97 148 25 84 127 136 119 135 4 30 162 144 195 46 31 170 119 28 190 ^'}}, - {OUT=>'DCA737E269F9D8626D488988C996E06B352C0708'}], - ['172', {IN=> {f=> '443 1 17 96 167 27 91 152 100 106 109 65 164 10 57 71 167 123 209 74 57 137 95 30 90 2 78 110 101 147 138 22 177 22 129 68 168 63 74 70 65 2 174 18 23 51 116 8 142 158 121 36 207 207 45 209 170 122 59 52 8 76 20 4 102 69 186 72 46 106 127 39 110 149 101 99 184 61 15 85 136 59 100 172 37 182 98 95 78 44 173 30 204 94 156 206 123 161 120 96 132 1 37 134 144 134 126 160 180 21 136 203 119 55 156 44 77 122 72 190 125 10 105 25 128 75 93 67 13 205 196 14 31 179 142 206 75 207 159 91 38 8 28 66 43 150 185 193 63 135 5 143 98 143 32 5 125 124 197 103 14 97 107 102 87 3 18 185 97 155 56 48 165 112 178 106 13 157 32 53 79 85 149 197 7 106 175 203 71 101 195 92 193 129 116 122 24 26 7 58 11 32 119 7 202 83 125 28 79 181 57 119 121 84 161 168 50 93 163 131 127 153 45 17 144 121 198 43 36 93 115 177 166 148 108 24 188 53 97 59 148 126 208 134 192 88 87 112 64 14 145 61 63 39 97 11 194 165 46 40 199 132 19 11 80 73 178 154 177 118 37 147 72 94 60 88 201 47 142 110 167 75 45 113 52 43 102 21 22 111 41 12 134 30 42 48 117 158 7 154 129 164 76 195 188 101 51 20 100 10 201 143 50 32 71 53 31 131 31 35 123 113 166 135 180 117 44 125 76 33 142 62 3 114 93 19 59 34 34 130 38 170 74 105 91 56 192 27 205 34 178 202 131 79 199 84 65 50 128 189 185 145 109 17 49 105 187 174 114 141 183 20 196 128 123 47 28 18 89 189 23 99 70 179 94 42 114 45 65 98 82 150 137 29 102 183 68 150 89 75 141 21 184 157 80 7 40 37 86 190 16 174 66 187 12 68 102 135 114 189 137 191 148 12 116 56 96 119 73 130 200 6 113 100 154 63 26 116 104 50 80 25 14 193 83 ^'}}, - {OUT=>'B8FFC1D4972FCE63241E0E77850AC46DDE75DBFA'}], - ['173', {IN=> {f=> '436 1 24 44 191 211 138 11 138 18 140 99 133 104 54 124 42 63 88 95 137 133 151 116 162 208 193 180 180 173 26 158 165 160 26 6 18 79 33 1 97 59 45 62 51 172 141 24 37 189 130 145 6 72 143 152 160 87 4 150 86 28 80 77 71 106 16 164 123 103 10 54 178 106 114 34 85 150 93 175 93 70 76 27 36 152 207 4 42 103 3 120 97 113 109 181 210 162 154 129 61 166 38 13 53 141 183 186 138 184 10 61 112 119 175 107 6 170 81 114 207 102 125 65 50 135 73 28 73 75 203 113 11 98 35 115 71 8 146 202 76 88 102 139 1 144 189 83 15 181 51 13 60 75 51 179 143 37 30 49 51 20 207 156 44 184 64 125 18 133 97 52 111 194 58 167 75 149 49 105 84 113 170 179 197 169 149 208 41 178 99 180 21 92 145 172 155 105 131 30 208 200 114 48 21 31 79 40 148 178 52 50 196 71 160 80 70 69 93 23 159 202 83 22 115 132 6 65 209 71 167 14 151 130 98 89 34 190 167 68 2 181 112 79 192 82 191 45 55 49 159 148 19 116 169 142 61 173 185 94 46 146 104 206 126 55 56 93 16 12 121 90 17 49 44 18 126 163 39 50 189 137 147 87 65 3 5 35 75 156 196 118 77 118 23 54 185 40 195 95 90 71 113 163 32 116 108 144 74 166 190 15 134 134 188 39 158 172 94 107 212 23 53 134 36 105 77 111 89 186 124 35 61 7 102 132 67 131 128 78 162 161 63 142 14 43 147 141 129 54 19 170 20 48 7 95 198 199 70 123 157 74 173 192 28 127 139 109 127 146 43 140 139 48 61 14 36 60 136 49 98 150 32 109 174 63 81 161 124 140 146 50 142 7 109 66 80 124 201 144 182 149 2 188 46 92 185 87 112 133 43 201 205 35 68 9 183 125 72 197 3 66 33 207 163 191 52 57 130 152 8 85 204 157 81 107 205 187 ^'}}, - {OUT=>'E9C9BF41C8549354151B977003CE1D830BE667DB'}], - ['174', {IN=> {f=> '462 1 126 54 123 113 85 81 23 41 154 71 210 115 18 89 108 32 157 209 11 103 176 133 136 77 193 10 209 112 196 166 110 66 43 69 194 36 202 25 171 62 112 82 44 100 43 188 172 70 83 29 115 67 64 128 83 153 164 195 158 2 119 187 169 33 160 31 149 23 64 32 61 109 45 121 102 77 74 32 38 16 55 7 172 189 198 200 211 141 11 2 5 143 159 147 90 134 25 70 106 122 105 114 212 30 141 130 195 39 24 163 91 28 11 7 76 167 17 81 137 85 86 94 65 149 5 42 66 157 113 204 59 57 137 80 15 70 207 78 95 91 142 133 17 177 22 129 68 168 43 74 50 60 197 174 3 13 36 106 3 127 158 116 26 197 192 25 194 155 102 59 52 203 56 20 214 82 49 171 67 46 106 117 34 90 139 96 94 179 56 15 65 136 54 100 157 17 182 93 75 63 24 168 25 189 84 156 201 118 156 105 96 112 201 22 134 139 114 116 145 175 11 121 198 99 40 151 34 72 117 52 190 105 90 20 118 60 83 52 208 205 181 209 16 174 122 206 70 202 144 71 18 208 8 66 38 135 170 178 53 115 5 138 88 123 17 200 115 119 182 98 9 87 97 102 72 3 8 180 82 145 56 33 165 102 173 96 213 157 12 33 69 80 129 192 2 101 165 203 51 86 190 87 193 124 116 122 4 21 7 53 211 27 104 207 197 73 125 23 59 176 37 114 111 74 151 153 50 73 148 116 127 153 45 2 124 121 193 28 16 78 100 162 166 128 88 9 188 53 92 49 148 111 193 129 187 68 77 92 54 4 135 51 63 19 97 1 194 150 31 35 194 132 9 206 75 58 168 144 167 118 37 127 62 94 60 78 196 47 132 110 162 65 35 98 32 43 87 1 2 106 21 12 124 20 22 38 117 148 212 149 119 164 76 180 183 101 46 10 95 205 186 143 40 32 56 38 21 126 31 30 123 108 151 135 165 107 29 120 71 13 137 62 208 104 88 4 39 29 19 115 23 160 54 105 91 41 177 27 200 14 163 124 ^'}}, - {OUT=>'0942908960B54F96CB43452E583F4F9CB66E398A'}], - ['175', {IN=> {f=> '453 0 115 79 199 84 49 18 128 173 169 121 93 17 186 41 89 187 158 90 133 167 206 188 104 99 31 4 18 81 165 217 75 54 179 62 34 106 37 41 66 82 134 113 215 86 159 36 142 65 43 125 215 160 149 48 193 24 21 86 182 16 166 42 179 206 44 94 111 82 181 121 167 132 198 92 48 72 119 57 114 184 200 81 68 122 39 26 84 96 26 80 1 208 177 217 24 44 191 206 118 209 123 8 140 99 128 99 54 109 42 58 83 80 122 113 141 96 147 203 183 180 175 158 16 143 155 155 11 1 13 64 23 1 87 54 35 52 46 157 121 19 27 174 115 130 209 72 123 152 150 87 202 140 76 23 75 77 66 86 11 149 118 88 44 168 101 94 14 80 145 93 165 73 65 66 12 21 137 192 4 22 83 201 120 77 113 94 181 195 157 144 124 51 151 33 211 38 131 178 186 138 184 5 61 92 99 175 107 6 155 81 114 207 87 105 45 40 120 73 18 58 60 193 98 11 98 15 100 51 3 146 187 61 88 97 139 204 129 189 73 213 171 36 216 55 55 51 174 138 17 15 49 41 15 197 146 39 174 64 120 3 123 82 37 111 179 58 157 70 134 39 100 74 108 170 164 197 169 144 198 41 163 84 170 16 92 145 167 155 85 116 25 208 200 104 48 21 16 69 40 143 178 42 35 196 56 145 70 60 49 88 23 149 192 78 12 95 127 204 55 199 61 162 212 151 130 88 74 34 180 152 53 210 166 112 74 182 67 176 30 35 29 159 133 19 101 164 127 56 168 175 84 26 131 104 196 126 40 46 83 6 7 101 90 12 44 24 216 106 158 39 30 179 132 147 82 60 216 203 35 75 151 181 98 62 108 3 49 185 25 185 95 80 71 103 153 22 106 88 144 54 156 175 10 129 119 178 19 148 172 79 102 207 13 208 33 114 36 95 57 91 79 176 104 25 41 210 92 122 62 131 108 73 162 161 48 142 14 33 137 141 119 34 9 160 5 38 205 75 198 189 50 108 112 ^'}}, - {OUT=>'FCE34051C34D4B81B85DDC4B543CDE8007E284B3'}], - ['176', {IN=> {f=> '454 1 53 173 192 113 111 102 120 132 22 112 118 20 40 7 8 213 46 129 28 77 150 11 81 160 49 60 154 124 119 139 43 135 213 109 38 52 117 201 116 168 149 215 181 32 64 164 59 98 133 15 194 198 28 54 9 183 104 58 176 209 59 12 200 163 177 45 50 116 145 8 64 204 150 74 93 184 89 111 39 108 108 85 61 13 36 154 61 210 115 3 84 108 22 152 209 216 103 176 123 126 57 183 10 199 107 186 161 105 51 38 69 184 26 202 15 171 57 97 77 24 90 33 183 167 70 83 29 110 67 49 123 63 148 159 190 148 2 99 172 159 33 160 26 139 3 44 17 46 89 40 101 87 62 69 27 38 6 55 2 162 184 183 190 211 131 6 212 210 138 144 132 85 124 25 60 91 112 95 99 212 30 126 120 195 34 19 158 71 28 211 217 56 167 7 71 122 70 66 79 65 134 27 61 147 103 199 44 57 137 65 50 202 78 80 81 137 128 12 177 22 129 68 168 23 74 30 55 182 174 208 3 21 96 218 112 158 111 16 187 177 5 179 140 82 59 52 188 36 20 214 62 29 156 62 46 106 107 29 70 129 91 89 174 51 15 45 136 49 100 142 217 182 88 55 48 4 163 20 174 74 156 196 113 151 90 96 92 191 7 134 134 94 106 130 170 1 106 193 79 25 146 24 67 112 32 190 85 210 75 15 108 45 73 37 193 205 166 194 1 169 102 206 65 197 129 51 218 198 208 66 33 120 155 163 43 95 5 133 78 103 2 185 105 114 167 93 4 77 87 102 57 3 218 175 67 135 56 18 165 92 168 86 203 157 212 13 59 75 109 187 217 96 155 203 31 71 185 82 193 119 116 122 204 16 7 48 201 22 89 197 192 63 125 18 39 171 17 109 101 64 141 138 50 53 133 101 127 153 45 207 104 121 188 13 216 63 85 147 166 108 68 214 188 53 87 39 148 96 178 124 182 48 67 72 44 214 125 41 63 219 97 211 194 135 16 30 189 132 219 191 70 43 158 181 ^'}}, - {OUT=>'61E8916532503627F4024D13884640A46F1D61D4'}], - ['177', {IN=> {f=> '475 0 153 118 37 99 48 94 60 64 189 47 118 110 155 51 21 77 4 43 66 195 196 99 215 12 110 6 216 24 117 134 205 142 105 164 76 159 176 101 39 218 88 184 165 143 26 32 35 17 7 119 31 23 123 101 130 135 144 93 8 113 64 207 130 62 201 90 81 205 11 22 220 94 2 146 26 105 91 20 156 27 193 208 142 178 107 79 199 84 41 2 128 165 161 109 85 17 174 37 81 187 150 78 129 159 194 184 92 87 23 214 18 77 153 209 63 46 179 46 30 102 33 29 50 82 126 101 203 78 147 20 138 53 27 117 207 148 145 32 181 16 13 86 178 16 162 30 175 198 32 90 99 66 177 113 155 124 186 80 44 60 119 49 106 176 192 65 52 106 27 26 68 92 14 80 211 200 169 213 24 44 191 202 102 197 111 140 99 124 95 54 97 42 54 79 68 110 97 133 80 135 199 175 180 171 146 8 131 147 151 221 219 9 52 15 1 79 50 27 44 42 145 105 15 19 162 103 118 201 72 107 152 142 87 190 132 68 19 71 77 62 70 7 137 114 76 214 36 160 97 78 220 76 141 93 157 57 61 58 9 125 180 4 6 67 189 120 61 113 82 181 183 153 136 120 43 139 29 199 26 123 174 186 138 184 1 61 76 83 175 107 6 143 81 114 207 75 89 29 32 108 73 10 46 48 185 86 11 98 221 88 35 221 146 175 49 88 93 139 196 117 189 65 201 163 24 208 51 39 51 170 134 1 3 49 33 11 189 138 35 166 64 116 213 115 70 25 111 167 58 149 66 122 31 96 66 104 170 152 197 169 140 190 41 151 72 162 12 92 145 163 155 69 104 21 208 200 96 48 21 4 61 40 139 178 34 23 196 44 133 62 52 33 84 23 141 184 74 4 79 123 192 47 191 53 158 200 151 130 80 62 34 172 140 41 206 154 112 70 174 55 164 18 19 13 159 121 19 89 160 115 52 164 167 76 10 119 104 188 126 28 38 75 220 3 85 90 8 40 8 204 90 154 39 14 171 128 147 78 56 216 191 35 75 147 169 82 50 100 209 45 185 13 177 95 150 ^'}}, - {OUT=>'F008D5D7853B6A17B7466CD9E18BD135E520FAF4'}], - ['178', {IN=> {f=> '471 0 71 89 139 8 92 60 144 26 142 154 3 122 98 164 216 134 172 58 95 200 224 201 5 86 36 81 29 63 65 162 76 11 13 196 78 108 55 131 80 66 162 161 27 142 14 19 123 141 105 6 220 146 209 24 184 47 198 175 22 87 133 38 173 192 205 103 91 97 115 122 7 92 103 25 2 213 213 36 124 13 62 150 221 61 150 39 45 149 124 104 134 38 130 208 109 18 32 112 201 96 158 149 215 176 22 44 149 39 88 133 220 189 193 23 44 9 183 89 48 161 204 54 222 195 163 167 40 45 106 140 8 49 204 145 69 83 169 89 96 24 93 103 85 41 3 31 154 51 210 115 213 79 108 12 147 209 206 103 176 113 116 37 173 10 189 102 176 156 100 36 33 69 174 16 202 5 171 52 82 72 4 80 23 178 162 70 83 29 105 67 34 118 43 143 154 185 138 2 79 157 149 33 160 21 129 208 24 2 31 69 35 81 72 47 64 22 38 221 55 222 152 179 168 180 211 121 1 207 200 133 129 117 80 114 25 50 76 102 85 84 212 30 111 110 195 29 14 153 51 28 196 212 36 167 222 61 107 55 46 64 65 119 220 12 56 137 93 194 29 57 137 50 210 30 197 78 65 71 132 123 7 177 22 129 68 168 3 74 10 50 167 174 198 218 6 86 218 97 158 106 6 177 162 210 164 125 62 59 52 173 16 20 214 42 9 141 57 46 106 97 24 50 119 86 84 169 46 15 25 136 44 100 127 202 182 83 35 33 209 158 15 159 64 156 191 108 146 75 96 72 181 217 134 129 74 96 115 165 216 91 188 59 10 141 14 62 107 12 190 65 205 60 10 98 30 63 22 178 205 151 179 211 164 82 206 60 192 114 31 203 188 193 66 28 105 140 148 33 75 5 128 68 83 212 170 95 109 152 88 224 67 77 102 42 3 213 170 52 125 56 3 165 82 163 76 193 157 197 218 49 70 89 182 217 91 145 203 11 56 180 77 193 114 116 122 189 11 7 43 191 17 74 187 187 53 125 13 19 166 222 104 91 54 131 123 50 33 118 86 127 167 ^'}}, - {OUT=>'BD8D2E873CF659B5C77AAC1616827EF8A3B1A3B3'}], - ['179', {IN=> {f=> '480 1 45 193 76 121 181 219 195 42 64 126 166 80 40 200 188 53 80 25 148 75 157 117 175 20 53 44 30 207 111 27 63 198 97 204 194 114 222 23 182 132 212 170 63 22 144 120 143 118 37 79 38 94 60 54 184 47 108 110 150 41 11 62 211 43 51 180 181 94 200 12 100 223 201 14 117 124 200 137 95 164 76 144 171 101 34 213 83 169 150 143 16 32 20 2 224 114 31 18 123 96 115 135 129 83 220 108 59 192 125 62 196 80 76 195 218 17 210 79 214 136 6 105 91 5 141 27 188 193 127 168 97 79 199 84 31 209 128 155 151 94 75 17 159 32 71 187 140 63 124 149 179 179 77 72 13 204 18 72 138 199 48 36 179 26 25 97 28 14 30 82 116 86 188 68 132 133 38 7 107 197 133 140 12 166 6 3 86 173 16 157 15 170 188 17 85 84 46 172 103 140 114 171 65 39 45 119 39 96 166 182 45 32 86 12 26 48 87 226 80 201 190 159 208 24 44 191 197 82 182 96 217 140 99 119 90 54 82 42 49 74 53 95 77 123 60 120 194 165 180 166 131 225 116 137 146 211 219 4 37 5 1 69 45 17 34 37 130 85 10 9 147 88 103 191 72 87 152 132 87 175 122 58 14 66 77 57 50 2 122 109 61 209 26 150 92 58 205 71 136 93 147 37 56 48 212 221 110 165 4 213 47 174 120 41 113 67 181 168 148 126 115 33 124 24 184 11 113 169 186 138 184 223 61 56 63 175 107 6 128 81 114 207 60 69 9 22 93 73 31 33 175 71 11 98 206 73 15 221 146 160 34 88 88 139 186 102 189 55 186 153 9 198 46 19 51 165 129 208 215 49 23 6 179 128 30 156 64 111 203 105 55 10 111 152 58 139 61 107 21 91 56 99 170 137 197 169 135 180 41 136 57 152 7 92 145 158 155 49 89 16 208 200 86 48 21 216 51 40 134 178 24 8 196 29 118 52 42 13 79 23 131 174 69 221 59 118 177 37 181 43 153 185 151 130 70 47 34 162 125 26 201 139 112 65 164 40 149 3 226 220 159 106 19 74 155 100 47 159 157 193 ^'}}, - {OUT=>'B25A04DD425302ED211A1C2412D2410FA10C63B6'}], - ['180', {IN=> {f=> '471 0 211 98 104 174 126 7 24 61 213 225 57 90 1 33 209 183 62 147 39 215 157 121 147 71 49 216 170 35 75 140 148 54 29 86 188 38 185 221 163 95 58 71 81 131 84 44 144 10 134 142 228 118 86 156 204 126 172 46 91 196 220 197 218 70 36 73 13 47 57 154 60 3 226 188 70 100 51 131 64 62 162 161 15 142 14 11 115 141 97 219 216 138 201 16 172 31 198 167 6 75 125 26 173 192 193 95 75 93 111 114 224 76 91 213 13 227 201 213 28 120 1 50 150 213 45 142 31 33 145 124 92 130 34 126 204 109 2 16 108 201 80 150 149 215 172 14 28 137 23 80 133 208 185 189 19 36 9 183 77 40 149 200 50 214 191 163 159 36 41 98 136 8 37 204 141 65 75 157 89 84 12 81 99 85 25 224 27 154 43 210 115 205 75 108 4 143 209 198 103 176 105 108 21 165 10 181 98 168 152 96 24 29 69 166 8 202 226 171 48 70 68 217 72 15 174 158 70 83 29 101 67 22 114 27 139 150 181 130 2 63 145 141 33 160 17 121 196 8 219 19 53 31 65 60 35 60 18 38 217 55 222 144 175 156 172 211 113 226 203 192 129 117 105 76 106 25 42 64 94 77 72 212 30 99 102 195 25 10 149 35 28 184 208 20 167 218 53 95 43 30 52 65 107 220 52 129 85 190 17 57 137 38 202 14 193 78 53 63 128 119 3 177 22 129 68 168 216 74 223 46 155 174 190 214 223 78 218 85 158 102 227 169 150 198 152 113 46 59 52 161 20 214 26 222 129 53 46 106 89 20 34 111 82 80 165 42 15 9 136 40 100 115 190 182 79 19 21 197 154 11 147 56 156 187 104 142 63 96 56 173 209 134 125 58 88 103 161 212 79 184 43 227 137 6 58 103 225 190 49 201 48 6 90 18 55 10 166 205 139 167 203 160 66 206 56 188 102 15 191 180 181 66 24 93 128 136 25 59 5 124 60 67 204 158 87 105 140 84 224 59 69 102 30 3 209 166 40 117 56 220 165 74 159 68 185 157 185 206 41 66 167 ^'}}, - {OUT=>'A404E21588123E0893718B4B44E91414A785B91F'}], - ['181', {IN=> {f=> '490 1 176 217 85 133 203 218 38 174 71 193 108 116 122 171 5 7 37 179 11 56 175 181 41 125 7 226 160 204 98 79 42 119 105 50 9 100 68 127 153 45 185 60 121 177 211 183 30 52 114 166 64 24 192 188 53 76 17 148 63 145 113 171 4 45 28 22 203 103 19 63 186 97 200 194 102 214 19 178 132 208 158 59 10 136 112 135 118 37 63 30 94 60 46 180 47 100 110 146 33 3 50 199 43 39 168 169 90 188 12 92 219 189 6 117 116 196 133 87 164 76 132 167 101 30 209 79 157 138 143 8 32 8 221 220 110 31 14 123 92 103 135 117 75 212 104 55 180 121 62 192 72 72 187 206 13 202 67 206 128 221 105 91 224 129 27 184 181 115 160 89 79 199 84 23 197 128 147 143 82 67 17 147 28 63 187 132 51 120 141 167 175 65 60 5 196 18 68 126 191 36 28 179 10 21 93 24 2 14 82 108 74 176 60 120 215 129 26 222 99 189 121 136 227 154 229 226 86 169 16 153 3 166 180 5 81 72 30 168 95 128 106 159 53 35 33 119 31 88 158 174 29 16 70 26 32 83 218 80 193 182 151 204 24 44 191 193 66 170 84 213 140 99 115 86 54 70 42 45 70 41 83 61 115 44 108 190 157 180 162 119 221 104 129 142 203 219 25 228 1 61 41 9 26 33 118 69 6 1 135 76 91 183 72 71 152 124 87 163 114 50 10 62 77 53 34 229 110 105 49 205 18 142 88 42 193 67 132 93 139 21 52 40 204 213 98 153 4 201 31 162 120 25 113 55 181 156 144 118 111 25 112 20 172 230 105 165 186 138 184 223 61 40 47 175 107 6 116 81 114 207 48 53 224 14 81 73 223 19 21 167 59 11 98 194 61 230 221 146 148 22 88 84 139 178 90 189 47 174 145 228 190 42 3 51 161 125 196 207 49 15 2 171 120 26 148 64 107 195 97 43 229 111 140 58 131 57 95 13 87 48 95 170 125 197 169 131 172 41 124 45 144 3 92 145 154 155 33 77 12 208 200 78 48 21 208 43 40 130 178 16 227 196 17 106 44 34 228 75 23 123 166 65 217 43 114 165 29 173 35 200 ^'}}, - {OUT=>'A1E13BC55BF6DAD83CF3AABDA3287AD68681EA64'}], - ['182', {IN=> {f=> '479 0 167 151 130 58 29 34 150 107 8 195 121 112 59 152 22 131 218 208 202 159 88 19 56 149 82 41 153 145 54 199 86 104 166 126 228 16 53 209 225 41 90 230 29 197 171 46 143 39 203 149 117 147 67 45 216 158 35 75 136 136 38 17 78 176 34 185 213 155 95 50 71 73 123 225 76 28 144 227 126 130 228 114 74 148 192 118 172 34 87 192 216 193 206 54 36 65 230 31 49 146 44 228 214 180 62 92 47 131 48 58 162 161 3 142 14 3 107 141 89 207 212 130 193 8 160 15 198 159 223 63 117 14 173 192 181 87 59 89 107 106 216 60 79 201 1 227 189 213 20 116 222 38 150 205 29 134 23 21 141 124 80 126 30 122 200 109 219 104 201 64 142 149 215 168 6 12 125 7 72 133 196 181 185 15 28 9 183 65 32 137 196 46 206 187 163 151 32 37 90 132 8 25 204 137 61 67 145 89 72 69 95 85 9 220 23 154 35 210 115 197 71 108 229 139 209 190 103 176 97 100 5 157 10 173 94 160 148 92 12 25 69 158 202 222 171 44 58 64 205 64 7 170 154 70 83 29 97 67 10 110 11 135 146 177 122 2 47 133 133 33 160 13 113 184 225 211 7 37 27 49 48 23 56 14 38 213 55 222 136 171 144 164 211 105 226 199 184 125 105 93 72 98 25 34 52 86 69 60 212 30 87 94 195 21 6 145 19 28 172 204 4 167 214 45 83 31 14 40 65 95 220 221 48 121 77 186 5 57 137 26 194 231 189 78 41 55 124 115 232 177 22 129 68 168 204 74 211 42 143 174 182 210 215 70 218 73 158 98 223 161 138 186 140 101 30 59 52 149 217 20 214 10 210 117 49 46 106 81 16 18 103 78 76 161 38 15 226 136 36 100 103 178 182 75 3 9 185 150 7 135 48 156 183 100 138 51 96 40 165 201 134 121 42 80 91 157 208 67 180 27 219 133 231 54 99 213 190 33 197 36 2 82 6 47 231 154 205 127 155 195 156 50 206 52 184 90 232 179 172 169 66 20 81 116 124 17 43 5 120 52 51 196 146 79 101 128 80 224 65 ^'}}, - {OUT=>'D5FD35FFABED6733C92365929DF0FB4CAE864D15'}], - ['183', {IN=> {f=> '503 1 55 102 9 3 202 159 19 103 56 206 165 60 152 54 171 157 164 185 27 59 45 171 217 80 123 203 203 23 169 66 193 103 116 122 156 7 32 169 6 41 165 176 31 125 2 211 155 189 93 69 32 109 90 50 225 85 53 127 153 45 175 40 121 172 201 168 15 37 99 166 44 4 182 188 53 71 7 148 48 130 108 166 220 35 8 12 198 93 9 63 171 97 195 194 87 204 14 173 132 203 143 54 231 126 102 125 118 37 43 20 94 60 36 175 47 90 110 141 23 229 35 184 43 24 153 154 85 173 12 82 214 174 232 117 106 191 128 77 164 76 117 162 101 25 204 74 142 123 143 234 32 229 211 215 105 31 9 123 87 88 135 102 65 202 99 50 165 116 62 187 62 67 177 191 8 192 52 196 118 206 105 91 214 114 27 179 166 100 150 79 79 199 84 13 182 128 137 133 67 57 17 132 23 53 187 122 36 115 131 152 170 50 45 231 186 18 63 111 181 21 18 179 226 16 88 19 223 230 82 98 59 161 50 105 200 124 11 207 89 179 106 131 212 139 224 221 86 164 16 148 224 161 170 226 76 57 10 163 85 113 96 144 38 30 18 119 21 78 148 164 9 232 50 221 26 12 78 208 80 183 172 141 199 24 44 191 188 46 155 69 208 140 99 110 81 54 55 42 40 65 26 68 41 105 24 93 185 147 180 157 104 216 89 119 137 193 219 231 10 223 1 51 36 235 16 28 103 49 1 227 120 61 76 173 72 51 152 114 87 148 104 40 5 57 77 48 14 229 95 100 34 200 8 132 83 22 178 62 127 93 129 1 47 30 194 203 83 138 4 186 11 147 120 5 113 40 181 141 139 108 106 15 97 15 157 220 95 160 186 138 184 223 61 20 27 175 107 6 101 81 114 207 33 33 209 4 66 73 218 4 6 157 44 11 98 179 46 215 221 146 133 7 88 79 139 168 75 189 37 159 135 218 180 37 219 51 156 120 181 197 49 5 233 161 110 21 138 64 102 185 87 28 219 111 125 58 121 52 80 3 82 38 90 170 110 197 169 126 162 41 109 30 134 234 92 145 149 155 13 62 7 208 200 68 48 21 198 33 40 125 178 6 217 196 2 91 34 24 213 70 23 113 161 ^'}}, - {OUT=>'C12E9C280EE9C079E0506FF89F9B20536E0A83EF'}], - ['184', {IN=> {f=> '470 0 58 210 15 107 144 15 159 21 142 152 151 130 48 14 34 140 92 231 190 106 112 54 142 7 116 208 193 187 159 73 19 41 144 67 36 148 135 44 184 71 104 156 126 218 6 43 204 225 21 90 230 24 182 156 26 138 39 188 139 112 147 62 40 216 143 35 75 131 121 18 2 68 161 29 185 203 145 95 40 71 63 113 220 66 8 144 212 116 115 228 109 59 138 177 108 172 19 82 187 211 188 191 34 36 55 215 11 39 136 24 223 199 170 52 82 42 131 28 53 162 161 226 142 14 231 97 141 79 192 207 120 183 236 145 233 198 149 208 48 107 237 173 192 166 77 39 84 102 96 206 40 64 186 224 227 174 213 10 111 212 23 150 195 9 124 13 6 136 124 65 121 25 117 195 109 204 218 99 201 44 132 149 215 163 234 230 110 225 62 133 181 176 180 10 18 9 183 50 22 122 191 41 196 182 163 141 27 32 80 127 8 10 204 132 56 57 130 89 57 223 54 90 85 227 215 18 154 25 210 115 187 66 108 224 134 209 180 103 176 87 90 223 147 10 163 89 150 143 87 235 20 69 148 228 202 217 171 39 43 59 190 54 235 165 149 70 83 29 92 67 233 105 229 130 141 172 112 2 27 118 123 33 160 8 103 169 210 201 230 17 22 29 33 8 51 9 38 208 55 222 126 166 129 154 211 95 226 194 174 120 90 78 67 88 25 24 37 76 59 45 212 30 72 84 195 16 1 140 237 28 157 199 222 167 209 35 68 16 232 25 65 80 220 211 43 111 67 181 228 57 137 11 184 216 184 78 26 45 119 110 232 177 22 129 68 168 189 74 196 37 128 174 172 205 205 60 218 58 158 93 218 151 123 171 125 86 10 59 52 134 202 20 214 228 195 102 44 46 106 71 11 236 93 73 71 156 33 15 211 136 31 100 88 163 182 70 221 232 170 145 2 120 38 156 178 95 133 36 96 20 155 191 134 116 22 70 76 152 203 52 175 7 209 128 226 49 94 198 190 13 192 21 235 72 229 37 221 139 205 112 140 185 151 30 206 47 179 75 217 101 ^'}}, - {OUT=>'E22769DC00748A9BBD6C05BBC8E81F2CD1DC4E2D'}], - ['185', {IN=> {f=> '502 0 158 148 66 13 60 95 103 3 15 5 113 38 23 182 125 65 94 107 73 224 37 47 102 237 3 198 155 7 95 56 198 165 52 148 46 163 157 152 173 19 55 29 167 217 76 115 203 191 11 165 62 193 99 116 122 144 236 7 28 161 2 29 157 172 23 125 238 199 151 177 89 61 24 101 78 50 213 73 41 127 153 45 167 24 121 168 193 156 3 25 87 166 28 228 174 188 53 67 239 148 36 118 104 162 208 27 232 4 194 85 1 63 159 97 191 194 75 196 10 169 132 199 131 50 223 118 94 117 118 37 27 12 94 60 28 171 47 82 110 137 15 225 23 172 43 12 141 142 81 161 12 74 210 162 228 117 98 187 124 69 164 76 105 158 101 21 200 70 130 111 143 230 32 221 203 211 101 31 5 123 83 76 135 90 57 194 95 46 153 112 62 183 54 63 169 179 4 184 40 188 110 194 105 91 206 102 27 175 154 88 142 71 79 199 84 5 170 128 129 125 55 49 17 120 19 45 187 114 24 111 123 140 166 38 33 227 178 18 59 99 173 9 10 179 214 12 84 15 215 218 82 90 47 149 42 93 188 120 239 195 81 171 94 127 200 127 220 217 86 160 16 144 216 157 162 218 72 45 234 159 77 101 88 132 26 26 6 119 13 70 140 156 233 220 34 213 26 236 74 200 80 175 164 133 195 24 44 191 184 30 143 57 204 140 99 106 77 54 43 42 36 61 14 56 25 97 8 81 181 139 180 153 92 212 77 111 133 185 219 231 238 219 1 43 32 231 8 24 91 33 237 223 108 49 64 165 72 35 152 106 87 136 96 32 1 53 77 44 238 229 83 96 22 196 124 79 6 166 58 123 93 121 225 43 22 186 195 71 126 4 174 235 135 120 229 113 28 181 129 135 100 102 7 85 11 145 212 87 156 186 138 184 223 61 4 11 175 107 6 89 81 114 207 21 17 197 236 54 73 214 232 234 149 32 11 98 167 34 203 221 146 121 235 88 75 139 160 63 189 29 147 127 210 172 33 207 51 152 116 169 189 49 237 233 153 102 17 130 64 98 177 79 16 211 111 113 58 113 48 68 235 78 30 86 170 98 197 169 122 154 41 97 18 126 234 92 145 145 155 237 50 209 ^'}}, - {OUT=>'F29835A93475740E888E8C14318F3CA45A3C8606'}], - ['186', {IN=> {f=> '481 1 208 200 56 48 21 186 21 40 119 178 236 205 196 226 73 22 12 195 64 23 101 144 54 206 241 103 132 7 151 13 138 140 151 130 40 2 34 132 80 223 186 94 112 50 134 237 104 200 181 175 159 61 19 29 140 55 32 144 127 36 172 59 104 148 126 210 240 35 200 225 5 90 230 20 170 144 10 134 39 176 131 108 147 58 36 216 131 35 75 127 109 2 232 60 149 25 185 195 137 95 32 71 55 105 216 58 234 144 200 108 103 228 105 47 130 165 100 172 7 78 183 207 184 179 18 36 47 203 237 31 128 8 219 187 162 44 74 38 131 12 49 162 161 218 142 14 227 89 141 71 180 203 112 175 232 133 221 198 141 196 36 99 229 173 192 154 69 23 80 98 88 198 24 52 174 216 227 162 213 2 107 204 11 150 187 235 116 5 236 132 124 53 117 21 113 191 109 192 206 95 201 28 124 149 215 159 230 218 98 213 54 133 169 172 176 6 10 9 183 38 14 110 187 37 188 178 163 133 23 28 72 123 8 240 204 128 52 49 118 89 45 215 42 86 85 215 211 14 154 17 210 115 179 62 108 220 130 209 172 103 176 79 82 211 139 10 155 85 142 139 83 227 16 69 140 224 202 213 171 35 31 55 178 46 231 161 145 70 83 29 88 67 225 101 217 126 137 168 104 2 11 106 115 33 160 4 95 157 198 193 222 1 18 13 21 238 47 5 38 204 55 222 118 162 117 146 211 87 226 190 166 116 78 66 63 80 25 16 25 68 51 33 212 30 60 76 195 12 239 136 225 28 145 195 210 167 205 27 56 4 220 13 65 68 220 203 39 103 59 177 220 57 137 241 176 204 180 78 14 37 115 106 232 177 22 129 68 168 177 74 184 33 116 174 164 201 197 52 218 46 158 89 214 143 111 159 113 74 236 59 52 122 190 20 214 216 183 90 40 46 106 63 7 224 85 69 67 152 29 15 199 136 27 100 76 151 182 66 209 224 158 141 240 108 30 156 174 91 129 24 96 4 147 183 134 112 6 62 64 148 199 40 171 233 201 124 222 45 90 186 190 239 188 9 235 64 221 29 213 127 178 ^'}}, - {OUT=>'1A1D77C6D0F97C4B620FAA90F3F8644408E4B13D'}], - ['187', {IN=> {f=> '508 1 94 122 173 145 6 206 41 173 57 199 146 150 136 66 9 48 83 91 239 243 5 109 30 7 174 113 57 90 95 69 224 29 39 102 229 3 194 151 239 87 56 190 165 44 144 38 155 157 140 161 11 51 13 163 217 72 107 203 179 243 161 58 193 95 116 122 132 236 7 24 153 242 17 149 168 15 125 238 187 147 165 85 53 16 93 66 50 201 61 29 127 153 45 159 8 121 164 185 144 235 13 75 166 12 216 166 188 53 63 235 148 24 106 100 158 196 19 220 240 190 77 237 63 147 97 187 194 63 188 6 165 132 195 119 46 215 110 86 109 118 37 11 4 94 60 20 167 47 74 110 133 7 221 11 160 43 129 130 77 149 12 66 206 150 224 117 90 183 120 61 164 76 93 154 101 17 196 66 118 99 143 226 32 213 195 207 97 31 1 123 79 64 135 78 49 186 91 42 141 108 62 179 46 59 161 167 176 28 180 102 182 105 91 198 90 27 171 142 76 134 63 79 199 84 241 158 128 121 117 43 41 17 108 15 37 187 106 12 107 115 128 162 26 21 223 170 18 55 87 165 241 2 179 202 8 80 11 207 206 82 82 35 137 34 81 176 116 231 183 73 163 82 123 188 115 216 213 86 156 16 140 208 153 154 210 68 33 222 155 69 89 80 120 14 22 238 119 5 62 132 148 221 208 18 205 26 224 70 192 80 167 156 125 191 24 44 191 180 14 131 45 200 140 99 102 73 54 31 42 32 57 2 44 9 89 236 69 177 131 180 149 80 208 65 103 129 177 219 231 230 215 1 35 28 227 20 79 17 237 219 96 37 52 157 72 19 152 98 87 124 88 24 241 49 77 40 226 229 71 92 10 192 236 116 75 234 154 54 119 93 113 213 39 14 178 187 59 114 4 162 223 123 120 217 113 16 181 117 131 92 98 243 73 7 133 204 79 152 186 138 184 223 61 232 239 175 107 6 77 81 114 207 9 1 185 232 42 73 210 224 226 141 20 11 98 155 22 191 221 146 109 227 88 71 139 152 51 189 21 135 119 202 164 29 195 51 148 112 157 181 49 233 233 145 94 13 122 64 94 169 71 4 203 111 101 58 105 44 56 231 74 22 82 170 86 197 169 118 146 41 85 6 118 234 92 145 141 149 ^'}}, - {OUT=>'4EC84870E9BDD25F523C6DFB6EDD605052CA4EAA'}], - ['188', {IN=> {f=> '484 1 219 32 243 208 200 48 48 21 178 13 40 115 178 232 197 196 218 61 14 4 183 60 23 93 136 50 202 229 99 120 245 143 5 134 128 151 130 32 236 34 124 68 215 182 82 112 46 126 229 92 192 169 163 159 49 19 17 136 43 28 140 119 28 160 47 104 140 126 202 236 27 196 225 235 90 230 16 158 132 240 130 39 164 123 104 147 54 32 216 119 35 75 123 97 232 224 52 137 21 185 187 129 95 24 71 47 97 212 50 222 144 188 100 91 228 101 35 122 153 92 172 241 74 179 203 180 167 2 36 39 191 225 23 120 238 215 175 154 36 66 34 131 242 45 162 161 210 142 14 223 81 141 63 168 199 104 167 228 121 209 198 133 184 24 91 221 173 192 142 61 7 76 94 80 190 8 40 162 208 227 150 213 240 103 196 245 150 179 223 108 243 228 128 124 41 113 17 109 187 109 180 194 91 201 12 116 149 215 155 226 206 86 201 46 133 157 168 172 2 2 9 183 26 6 98 183 33 180 174 163 125 19 24 64 119 8 232 204 124 48 41 106 89 33 207 30 82 85 203 207 10 154 9 210 115 171 58 108 216 126 209 164 103 176 71 74 199 131 10 147 81 134 135 79 219 12 69 132 220 202 209 171 31 19 51 166 38 227 157 141 70 83 29 84 67 217 97 205 122 133 164 96 2 241 94 107 33 160 87 145 186 185 214 231 14 243 9 230 43 1 38 200 55 222 110 158 105 138 211 79 226 186 158 112 66 54 59 72 25 8 13 60 43 21 212 30 48 68 195 8 239 132 213 28 133 191 198 167 201 19 44 238 208 1 65 56 220 195 35 95 51 173 212 57 137 233 168 192 176 78 2 29 111 102 232 177 22 129 68 168 165 74 172 29 104 174 156 197 189 44 218 34 158 85 210 135 99 147 101 62 224 59 52 110 178 20 214 204 171 78 36 46 106 55 3 212 77 65 63 148 25 15 187 136 23 100 64 139 182 62 197 216 146 137 240 96 22 156 170 87 125 12 96 234 139 175 134 108 236 54 52 144 195 28 167 221 193 120 218 41 86 174 190 227 184 243 235 56 213 21 205 115 205 71 ^'}}, - {OUT=>'D689513FED08B80C39B67371959BC4E3FECB0537'}], - ['189', {IN=> {f=> '506 0 110 165 141 238 206 37 169 45 187 134 142 124 66 5 36 71 79 235 231 5 105 22 239 166 101 49 86 83 65 224 21 31 102 221 3 190 147 231 79 56 182 165 36 140 30 147 157 128 149 3 47 245 159 217 68 99 203 167 235 157 54 193 91 116 122 120 236 7 20 145 242 5 141 164 7 125 238 175 143 153 81 45 8 85 54 50 189 49 17 127 153 45 151 240 121 160 177 132 227 1 63 166 244 204 158 188 53 59 231 148 12 94 96 154 184 11 208 236 186 69 233 63 135 97 183 194 51 180 2 161 132 191 107 42 207 102 78 101 118 37 243 244 94 60 12 163 47 66 110 129 247 217 247 148 43 236 117 118 73 137 12 58 202 138 220 117 82 179 116 53 164 76 81 150 101 13 192 62 106 87 143 222 32 205 187 203 93 31 245 123 75 52 135 66 41 178 87 38 129 104 62 175 38 55 153 155 244 168 16 172 94 170 105 91 190 78 27 167 130 64 126 55 79 199 84 237 146 128 113 109 31 33 17 96 11 29 187 98 103 107 116 158 14 9 219 162 18 51 75 157 233 242 179 190 4 76 7 199 194 82 74 23 125 26 69 164 112 223 171 65 155 70 119 176 103 212 209 86 152 16 136 200 149 146 202 64 21 210 151 61 77 72 108 2 18 230 119 245 54 124 140 209 196 2 197 26 212 66 184 80 159 148 117 187 24 44 191 176 246 119 33 196 140 99 98 69 54 19 42 28 53 238 32 241 81 224 57 173 123 180 145 68 204 53 95 125 169 219 231 222 211 1 27 24 223 240 16 67 1 237 215 84 25 40 149 72 3 152 90 87 112 80 16 241 45 77 36 214 229 59 88 246 188 232 108 71 222 142 50 115 93 105 201 35 6 170 179 47 102 4 150 211 111 120 205 113 4 181 105 127 84 94 239 61 3 121 196 71 148 186 138 184 223 61 220 227 175 107 6 65 81 114 207 245 233 173 228 30 73 206 216 218 133 8 11 98 143 10 179 221 146 97 219 88 67 139 144 39 189 13 123 111 194 156 25 183 51 144 108 145 173 49 229 233 137 86 9 114 64 90 161 63 240 195 111 89 58 97 40 44 227 70 14 78 170 74 197 169 114 138 41 73 242 110 234 177 ^'}}, - {OUT=>'C4FED58F209FC3C34AD19F86A6DACADC86C04D33'}], - ['190', {IN=> {f=> '491 0 145 135 155 207 20 243 208 200 40 48 21 170 5 40 111 178 228 189 196 210 49 6 246 171 56 23 85 128 46 198 217 95 108 241 135 247 130 116 151 130 24 228 34 116 56 207 178 70 112 42 118 221 80 184 157 151 159 37 19 5 132 31 24 136 111 20 148 35 104 132 126 194 232 19 192 225 223 90 230 12 146 120 228 126 39 152 115 100 147 50 28 216 107 35 75 119 85 220 216 44 125 17 185 179 121 95 16 71 39 89 208 42 210 144 176 92 79 228 97 23 114 141 84 172 233 70 175 199 176 155 236 36 31 179 213 15 112 226 211 163 146 28 58 30 131 230 41 162 161 202 142 14 219 73 141 55 156 195 96 159 224 109 197 198 125 172 12 83 213 173 192 130 53 241 72 90 72 182 242 28 150 200 227 138 213 236 99 188 237 150 171 211 100 239 220 124 124 29 109 13 105 183 109 168 182 87 201 246 108 149 215 151 222 194 74 189 38 133 145 164 168 248 244 9 183 14 248 86 179 29 172 170 163 117 15 20 56 115 8 224 204 120 44 33 94 89 21 199 18 78 85 191 203 6 154 1 210 115 163 54 108 212 122 209 156 103 176 63 66 187 123 10 139 77 126 131 75 211 8 69 124 216 202 205 171 27 7 47 154 30 223 153 137 70 83 29 80 67 209 93 193 118 129 160 88 2 229 82 99 33 160 246 79 133 174 177 206 219 10 231 247 222 39 247 38 196 55 222 102 154 93 130 211 71 226 182 150 108 54 42 55 64 25 1 52 35 9 212 30 36 60 195 4 239 128 201 28 121 187 186 167 197 11 32 230 196 239 65 44 220 187 31 87 43 169 204 57 137 225 160 180 172 78 240 21 107 98 232 177 22 129 68 168 153 74 160 25 92 174 148 193 181 36 218 22 158 81 206 127 87 135 89 50 212 59 52 98 166 20 214 192 159 66 32 46 106 47 249 200 69 61 59 144 21 15 175 136 19 100 52 127 182 58 185 208 134 133 240 84 14 156 166 83 121 96 222 131 167 134 104 224 46 40 140 191 16 163 209 185 116 214 37 82 162 190 215 180 235 235 48 205 13 197 103 205 76 104 161 139 232 146 ^'}}, - {OUT=>'051888C6D00029C176DE792B84DECE2DC1C74B00'}], - ['191', {IN=> {f=> '516 0 33 165 33 175 122 134 112 66 1 24 59 67 231 219 5 101 14 227 158 89 41 82 71 61 224 13 23 102 213 3 186 143 223 71 56 174 165 28 136 22 139 157 116 137 247 43 233 155 217 64 91 203 155 227 153 50 193 87 116 122 108 236 7 16 137 242 245 133 160 251 125 238 163 139 141 77 37 77 42 50 177 37 5 127 153 45 143 228 121 156 169 120 219 241 51 166 232 192 150 188 53 55 227 148 82 92 150 172 3 196 232 182 61 229 63 123 97 179 194 39 172 250 157 132 187 95 38 199 94 70 93 118 37 231 240 94 60 4 159 47 58 110 125 243 213 239 136 43 228 105 106 69 125 12 50 198 126 216 117 74 175 112 45 164 76 69 146 101 9 188 58 94 75 143 218 32 197 179 199 89 31 245 123 71 40 135 54 33 170 83 34 117 100 62 171 30 51 145 143 244 160 4 164 86 158 105 91 182 66 27 163 118 52 118 47 79 199 84 233 134 128 105 101 19 25 17 84 7 21 187 90 240 99 99 104 154 2 249 215 154 18 47 63 149 225 238 179 178 72 3 191 182 82 66 11 113 18 57 152 108 215 159 57 147 58 115 164 91 208 205 86 148 16 132 192 145 138 194 60 9 198 147 53 65 64 96 242 14 222 119 241 46 116 132 197 184 238 189 26 200 62 176 80 151 140 109 183 24 44 191 172 234 107 21 192 140 99 94 65 54 7 42 24 49 230 20 229 73 212 45 169 115 180 141 56 200 41 87 121 161 219 231 214 207 1 19 20 219 236 12 55 237 237 211 72 13 28 141 72 239 152 82 87 100 72 8 241 41 77 32 202 229 47 84 238 184 228 100 67 210 130 46 111 93 97 189 31 250 162 171 35 90 4 138 199 99 120 193 113 244 181 93 123 76 90 235 49 251 109 188 63 144 186 138 184 223 61 208 215 175 107 6 53 81 114 207 237 221 161 224 18 73 202 208 210 125 248 11 98 131 250 167 221 146 85 211 88 63 139 136 27 189 5 111 103 186 148 21 171 51 140 104 133 165 49 225 233 129 78 5 106 64 86 153 55 232 187 111 77 58 89 36 32 223 66 6 74 170 62 197 169 110 130 41 61 234 102 234 92 145 133 155 201 14 243 208 200 36 48 21 166 1 40 109 178 147 ^'}}, - {OUT=>'1A3540BEE05518505827954F58B751C475AEECE0'}], - ['192', {IN=> {f=> '522 0 179 196 200 34 251 241 156 51 23 75 118 41 193 202 90 93 236 125 242 125 101 151 130 14 218 34 106 41 197 173 55 112 37 108 211 65 174 142 136 159 22 19 245 127 16 19 131 101 10 133 20 104 122 126 184 227 9 187 225 208 90 230 7 131 105 213 121 39 137 105 95 147 45 23 216 92 35 75 114 70 205 206 34 110 12 185 169 111 95 6 71 29 79 203 32 195 144 161 82 64 228 92 8 104 126 74 172 223 65 170 194 171 140 221 36 21 164 198 5 102 211 206 148 136 18 48 25 131 215 36 162 161 192 142 14 214 63 141 45 141 190 86 149 219 94 182 198 115 157 252 73 203 173 192 115 43 226 67 85 62 172 227 13 135 190 227 123 213 231 94 178 227 150 161 196 90 234 210 119 124 14 104 8 100 178 109 153 167 82 201 231 98 149 215 146 217 179 59 174 28 133 130 159 163 248 239 9 183 254 243 71 174 24 162 165 163 107 10 15 46 110 8 214 204 115 39 23 79 89 6 189 3 73 85 176 198 1 154 246 210 115 153 49 108 207 117 209 146 103 176 53 56 172 113 10 129 72 116 126 70 201 3 69 114 211 202 200 171 22 247 42 139 20 218 148 132 70 83 29 75 67 199 88 178 113 124 155 78 2 214 67 89 33 160 246 69 118 159 167 196 204 5 216 237 212 34 247 38 191 55 222 92 149 78 120 211 61 226 177 140 103 39 27 50 54 25 245 241 42 25 249 212 30 21 50 195 254 239 123 186 28 106 182 171 167 192 1 17 220 181 229 65 29 220 177 26 77 33 164 194 57 137 215 150 165 167 78 230 11 102 93 232 177 22 129 68 168 138 74 145 20 77 174 138 188 171 26 218 7 158 76 201 117 72 120 74 35 197 59 52 83 151 20 214 177 144 51 27 46 106 37 249 185 59 56 54 139 16 15 160 136 14 100 37 112 182 53 170 198 119 128 240 69 4 156 161 78 116 240 96 207 121 157 134 99 209 36 25 135 186 1 158 194 175 111 209 32 77 147 190 200 175 225 235 38 195 3 187 88 205 61 89 151 134 217 206 30 162 24 166 113 128 103 66 253 15 50 58 228 210 5 98 8 218 152 80 35 79 62 58 224 7 17 102 207 3 183 140 217 65 56 168 165 22 133 16 133 157 107 128 244 12 ^'}}, - {OUT=>'DFA19180359D5A7A38E842F172359CAF4208FC05'}], - ['193', {IN=> {f=> '517 1 218 150 217 59 81 203 140 217 148 45 193 82 116 122 93 236 7 11 127 242 235 123 155 246 125 238 148 134 126 72 27 247 67 27 50 162 22 247 127 153 45 133 213 121 151 159 105 209 231 36 166 217 177 140 188 53 50 222 148 242 67 87 145 157 250 181 227 177 51 224 63 108 97 174 194 24 162 250 152 132 182 80 33 189 84 60 83 118 37 216 235 94 60 251 154 47 48 110 120 238 208 229 121 43 218 90 91 64 110 12 40 193 111 211 117 64 170 107 35 164 76 54 141 101 4 183 53 79 60 143 213 32 187 169 194 84 31 245 123 66 25 135 39 23 160 78 29 102 95 62 166 20 46 135 128 244 150 246 154 76 143 105 91 172 51 27 158 103 37 108 37 79 199 84 228 119 128 95 91 4 15 17 69 2 11 187 80 230 94 89 89 149 244 239 210 144 18 42 48 139 215 233 179 163 252 67 255 181 167 82 56 253 98 8 42 137 103 205 144 47 137 43 110 149 76 203 200 86 143 16 127 182 140 128 184 55 251 183 142 43 50 54 81 232 9 212 119 236 36 106 122 182 169 223 179 26 185 57 166 80 141 130 99 178 24 44 191 167 219 92 6 187 140 99 89 60 54 249 42 19 44 220 5 214 63 197 30 164 105 180 136 41 195 26 77 116 151 219 231 204 202 1 9 15 214 231 7 40 222 237 206 57 255 13 131 72 224 152 72 87 85 62 255 241 36 77 27 187 229 32 79 228 179 223 90 62 195 115 41 106 93 87 174 26 245 152 161 20 75 4 123 184 84 120 178 113 234 181 78 118 66 85 230 34 251 94 178 53 139 186 138 184 223 61 193 200 175 107 6 38 81 114 207 227 206 146 219 3 73 197 198 200 115 238 11 98 116 240 152 221 146 70 201 88 58 139 126 12 189 252 96 93 176 138 16 156 51 135 99 118 155 49 220 233 119 68 96 64 81 143 45 222 177 111 62 58 79 31 17 218 61 253 69 170 47 197 169 105 120 41 46 224 92 234 92 145 128 155 186 256 243 208 200 26 48 21 156 248 40 104 178 221 175 196 196 28 249 239 150 49 23 71 114 39 191 196 88 87 234 121 240 123 95 151 130 10 214 34 102 35 193 171 49 112 35 104 207 59 170 136 130 159 16 19 241 125 213 ^'}}, - {OUT=>'7B0FA84EBBCFF7D7F4500F73D79660C4A3431B67'}], - ['194', {IN=> {f=> '529 1 15 127 93 2 121 8 104 114 126 176 223 1 183 225 196 90 230 3 119 93 201 117 39 125 97 91 147 41 19 216 80 35 75 110 58 193 198 26 98 8 185 161 103 95 257 71 21 71 199 24 183 144 149 74 52 228 88 255 96 114 66 172 215 61 166 190 167 128 209 36 13 152 186 256 94 199 202 136 128 10 40 21 131 203 32 162 161 184 142 14 210 55 141 37 129 186 78 141 215 82 170 198 107 145 244 65 195 173 192 103 35 214 63 81 54 164 215 1 123 182 227 111 213 227 90 170 219 150 153 184 82 230 202 115 124 2 100 4 96 174 109 141 155 78 201 219 90 149 215 142 213 167 47 162 20 133 118 155 159 248 235 9 183 246 239 59 170 20 154 161 163 99 6 11 38 106 8 206 204 111 35 15 67 89 253 181 250 69 85 164 194 256 154 242 210 115 145 45 108 203 113 209 138 103 176 45 48 160 105 10 121 68 108 122 66 193 258 69 106 207 202 196 171 18 239 38 127 12 214 144 128 70 83 29 71 67 191 84 166 109 120 151 70 2 202 55 81 33 160 246 61 106 147 159 188 192 1 204 229 204 30 247 38 187 55 222 84 145 66 112 211 53 226 173 132 99 27 15 46 46 25 241 233 34 17 241 212 30 9 42 195 254 239 119 174 28 94 178 159 167 188 252 5 212 169 221 65 17 220 169 22 69 25 160 186 57 137 207 142 153 163 78 222 3 98 89 232 177 22 129 68 168 126 74 133 16 65 174 130 184 163 18 218 254 158 72 197 109 60 108 62 23 185 59 52 71 139 20 214 165 132 39 23 46 106 29 249 173 51 52 50 135 12 15 148 136 10 100 25 100 182 49 158 190 107 124 240 57 255 156 157 74 112 232 96 195 113 149 134 95 197 28 13 131 182 248 154 182 167 107 205 28 73 135 190 188 171 217 235 30 187 254 179 76 205 49 77 143 130 205 206 26 158 12 154 101 120 91 66 253 3 38 46 224 198 5 94 206 144 68 27 75 50 54 224 258 9 102 199 3 179 136 209 57 56 160 165 14 129 8 125 157 95 116 240 36 212 148 217 57 77 203 134 213 146 43 193 80 116 122 87 236 7 9 123 242 231 119 153 244 125 238 142 132 120 70 23 245 63 21 50 156 16 243 127 153 45 129 207 121 149 155 99 205 227 30 166 211 57 ^'}}, - {OUT=>'9E886081C9ACAAD0F97B10810D1DE6FCDCE6B5F4'}], - ['195', {IN=> {f=> '548 0 134 188 53 47 219 148 236 58 84 142 148 247 172 224 174 45 221 63 99 97 171 194 15 156 250 149 132 179 71 30 183 78 54 77 118 37 207 232 94 60 248 151 47 42 110 117 235 205 223 112 43 212 81 82 61 101 12 34 190 102 208 117 58 167 104 29 164 76 45 138 101 1 180 50 70 51 143 210 32 181 163 191 81 31 245 123 63 16 135 30 17 154 75 26 93 92 62 163 14 43 129 119 244 144 240 148 70 134 105 91 166 42 27 155 94 28 102 31 79 199 84 225 110 128 89 85 255 9 17 60 259 5 187 74 224 91 83 80 146 238 233 207 138 18 39 39 133 209 230 179 154 252 64 255 175 158 82 50 247 89 2 33 128 100 199 135 41 131 34 107 140 67 200 197 86 140 16 124 176 137 122 178 52 245 174 139 37 41 48 72 226 6 206 119 233 30 100 116 173 160 214 173 26 176 54 160 80 135 124 93 175 24 44 191 164 210 83 257 184 140 99 86 57 54 243 42 16 41 214 256 205 57 188 21 161 99 180 133 32 192 17 71 113 145 219 231 198 199 1 3 12 211 228 4 31 213 237 203 48 249 4 125 72 215 152 66 87 76 56 252 241 33 77 24 178 229 23 76 222 176 220 84 59 186 106 38 103 93 81 165 23 242 146 155 11 66 4 114 175 75 120 169 113 228 181 69 115 60 82 227 25 251 85 172 47 136 186 138 184 223 61 184 191 175 107 6 29 81 114 207 221 197 137 216 254 73 194 192 194 109 232 11 98 107 234 143 221 146 61 195 88 55 139 120 3 189 249 87 87 170 132 13 147 51 132 96 109 149 49 217 233 113 62 257 90 64 78 137 39 216 171 111 53 58 73 28 8 215 58 250 66 170 38 197 169 102 114 41 37 218 86 234 92 145 125 155 177 250 243 208 200 20 48 21 150 245 40 101 178 218 169 196 190 19 246 236 141 46 23 65 108 36 188 187 85 78 231 115 237 120 86 151 130 4 208 34 96 26 187 168 40 112 32 98 201 50 164 127 121 159 7 19 235 122 1 14 126 91 118 5 104 112 126 174 222 259 182 225 193 90 230 2 116 90 198 116 39 122 95 90 147 40 18 216 77 35 75 109 55 190 196 24 95 7 185 159 101 95 256 71 19 69 198 22 180 144 146 72 49 228 87 253 94 111 64 172 213 60 165 189 166 125 206 36 11 149 183 255 92 196 201 133 126 8 38 20 131 213 ^'}}, - {OUT=>'A4D46E4BA0AE4B012F75B1B50D0534D578AE9CB6'}], - ['196', {IN=> {f=> '547 0 29 162 161 178 142 14 207 49 141 31 120 183 72 135 212 73 161 198 101 136 238 59 189 173 192 94 29 205 60 78 48 158 206 254 114 176 227 102 213 224 87 164 213 150 147 175 76 227 196 112 124 255 97 1 93 171 109 132 146 75 201 210 84 149 215 139 210 158 38 153 14 133 109 152 156 248 232 9 183 240 236 50 167 17 148 158 163 93 3 8 32 103 8 200 204 108 32 9 58 89 247 175 244 66 85 155 191 256 154 239 210 115 139 42 108 200 110 209 132 103 176 39 42 151 99 10 115 65 102 119 63 187 258 69 100 204 202 193 171 15 233 35 118 6 211 141 125 70 83 29 68 67 185 81 157 106 117 148 64 2 193 46 75 33 160 246 55 97 138 153 182 183 260 195 223 198 27 247 38 184 55 222 78 142 57 106 211 47 226 170 126 96 18 6 43 40 25 238 227 28 11 235 212 30 36 195 254 239 116 165 28 85 175 150 167 185 249 258 206 160 215 65 8 220 163 19 63 19 157 180 57 137 201 136 144 160 78 216 259 95 86 232 177 22 129 68 168 117 74 124 13 56 174 124 181 157 12 218 248 158 69 194 103 51 99 53 14 176 59 52 62 130 20 214 156 123 30 20 46 106 23 249 164 45 49 47 132 9 15 139 136 7 100 16 91 182 46 149 184 98 121 240 48 252 156 154 71 109 226 96 186 107 143 134 92 188 22 4 128 179 242 151 173 161 104 202 25 70 126 190 179 168 211 235 24 181 251 173 67 205 40 68 137 127 196 206 23 155 3 145 92 114 82 66 253 256 29 37 221 189 5 91 256 197 138 59 21 72 41 51 224 255 3 102 193 3 176 133 203 51 56 154 165 8 126 2 119 157 86 107 237 33 203 145 217 54 71 203 125 207 143 40 193 77 116 122 78 236 7 6 117 242 225 113 150 241 125 238 133 129 111 67 17 242 57 12 50 147 7 237 127 153 45 123 198 121 146 149 90 199 221 21 166 202 162 130 188 53 45 217 148 232 52 82 140 142 245 166 222 172 41 219 63 93 97 169 194 9 152 250 147 132 177 65 28 179 74 50 73 118 37 201 230 94 60 246 149 47 38 110 115 233 203 219 106 43 208 75 76 59 95 12 30 188 96 206 117 54 165 102 25 164 76 39 136 101 261 178 48 64 45 143 208 32 177 159 189 79 31 245 123 61 10 135 24 13 150 73 24 87 90 62 161 10 41 125 209 ^'}}, - {OUT=>'6342B199EE64C7B2C9CBCD4F2DCB65ACEF51516F'}], - ['197', {IN=> {f=> '542 1 244 136 232 140 62 122 105 91 158 30 27 151 82 16 94 23 79 199 84 221 98 128 81 77 247 1 17 48 259 261 187 66 216 87 75 68 142 230 225 203 130 18 35 27 125 201 226 179 142 252 60 255 167 146 82 42 239 77 258 21 116 96 191 123 33 123 22 103 128 55 196 193 86 136 16 120 168 133 114 170 48 237 162 135 29 29 40 60 218 2 198 119 229 22 92 108 161 148 202 165 26 164 50 152 80 127 116 85 171 24 44 191 160 198 71 249 180 140 99 82 53 54 235 42 12 37 206 248 193 49 176 9 157 91 180 129 20 188 5 63 109 137 219 231 190 195 1 259 8 207 224 19 201 237 199 36 241 256 117 72 203 152 58 87 64 48 248 241 29 77 20 166 229 11 72 214 172 216 76 55 174 94 34 99 93 73 153 19 238 138 147 263 54 4 102 163 63 120 157 113 220 181 57 111 52 78 223 13 251 73 164 39 132 186 138 184 223 61 172 179 175 107 6 17 81 114 207 213 185 125 212 246 73 190 184 186 101 224 11 98 95 226 131 221 146 49 187 88 51 139 112 255 189 245 75 79 162 124 9 135 51 128 92 97 141 49 213 233 105 54 257 82 64 74 129 31 208 163 111 41 58 65 24 260 211 54 246 62 170 26 197 169 98 106 41 25 210 78 234 92 145 121 155 165 242 243 208 200 12 48 21 142 241 40 97 178 214 161 196 182 7 242 232 129 42 23 57 100 32 184 175 81 66 227 107 233 116 74 151 130 260 200 34 88 14 179 164 28 112 28 90 193 38 156 115 109 159 259 19 227 118 253 10 122 83 256 106 257 104 104 126 166 218 255 178 225 181 90 230 262 104 78 186 112 39 110 87 86 147 36 14 216 65 35 75 105 43 178 188 16 83 3 185 151 93 95 252 71 11 61 194 14 168 144 134 64 37 228 83 245 86 99 56 172 205 56 161 185 162 113 194 36 3 137 171 251 84 184 197 121 118 30 16 131 188 27 162 161 174 142 14 205 45 141 27 114 181 68 131 210 67 155 198 97 130 234 55 185 173 192 88 25 199 58 76 44 154 200 250 108 172 227 96 213 222 85 160 209 150 143 169 72 225 192 110 124 251 95 263 91 169 109 126 140 73 201 204 80 149 215 137 208 152 32 147 10 133 103 150 154 248 230 9 183 236 234 44 165 15 144 156 163 89 1 6 28 101 8 196 204 106 164 ^'}}, - {OUT=>'AABFD63688EB678357869130083E1B52F6EA861D'}], - ['198', {IN=> {f=> '567 0 1 46 89 239 167 236 62 85 143 187 256 154 235 210 115 131 38 108 196 106 209 124 103 176 31 34 139 91 10 107 61 94 115 59 179 258 69 92 200 202 189 171 11 225 31 106 264 207 137 121 70 83 29 64 67 177 77 145 102 113 144 56 2 181 34 67 33 160 246 47 85 126 145 174 171 260 183 215 190 23 247 38 180 55 222 70 138 45 98 211 39 226 166 118 92 6 260 39 32 25 234 219 20 3 227 212 30 254 28 195 254 239 112 153 28 73 171 138 167 181 245 250 198 148 207 65 262 220 155 15 55 11 153 172 57 137 193 128 132 156 78 208 255 91 82 232 177 22 129 68 168 105 74 112 9 44 174 116 177 149 4 218 240 158 65 190 95 39 87 41 2 164 59 52 50 118 20 214 144 111 18 16 46 106 15 249 152 37 45 43 128 5 15 127 136 3 100 4 79 182 42 137 176 86 117 240 36 248 156 150 67 105 218 96 174 99 135 134 88 176 14 258 124 175 234 147 161 153 100 198 21 66 114 190 167 164 203 235 16 173 247 165 55 205 28 56 129 123 184 206 19 151 257 133 80 106 70 66 253 248 17 25 217 177 5 87 252 185 130 47 13 68 29 47 224 251 261 102 185 3 172 129 195 43 56 146 165 122 260 111 157 74 95 233 29 191 141 217 50 63 203 113 199 139 36 193 73 116 122 66 236 7 2 109 242 217 105 146 237 125 238 121 125 99 63 9 238 49 50 135 261 229 127 153 45 115 186 121 142 141 78 191 213 9 166 190 150 122 188 53 41 213 148 224 40 78 136 130 241 154 218 168 33 215 63 81 97 165 194 263 144 250 143 132 173 53 24 171 66 42 65 118 37 189 226 94 60 242 145 47 30 110 111 229 199 211 94 43 200 63 64 55 83 12 22 184 84 202 117 46 161 98 17 164 76 27 132 101 261 174 44 52 33 143 204 32 169 151 185 75 31 245 123 57 264 135 12 5 142 69 20 75 86 62 157 2 37 117 101 244 132 228 136 58 116 105 91 154 24 27 149 76 10 90 19 79 199 84 219 92 128 77 73 243 263 17 42 259 259 187 62 212 85 71 62 140 226 221 201 126 18 33 21 121 197 224 179 136 252 58 255 163 140 82 38 235 71 256 15 110 94 187 117 29 119 16 101 122 49 194 191 86 134 16 118 164 131 110 166 46 233 156 133 25 23 36 54 214 194 119 227 18 88 104 155 142 196 161 26 158 48 148 80 123 112 81 169 24 44 191 158 192 65 245 178 140 223 ^'}}, - {OUT=>'F732B7372DAF44801F81EFFE3108726239837936'}], - ['199', {IN=> {f=> '551 1 78 49 54 227 42 8 33 198 240 181 41 164 265 153 83 180 125 8 184 261 55 105 129 219 231 182 191 1 255 4 203 220 264 7 189 237 195 24 233 248 109 72 191 152 50 87 52 40 244 241 25 77 16 154 229 267 68 206 168 212 68 51 162 82 30 95 93 65 141 15 234 130 139 255 42 4 90 151 51 120 145 113 212 181 45 107 44 74 219 1 251 61 156 31 128 186 138 184 223 61 160 167 175 107 6 5 81 114 207 205 173 113 208 238 73 186 176 178 93 216 11 98 83 218 119 221 146 37 179 88 47 139 104 247 189 241 63 71 154 116 5 123 51 124 88 85 133 49 209 233 97 46 257 74 64 70 121 23 200 155 111 29 58 57 20 252 207 50 242 58 170 14 197 169 94 98 41 13 202 70 234 92 145 117 155 153 234 243 208 200 4 48 21 134 237 40 93 178 210 153 196 174 263 238 228 117 38 23 49 92 28 180 163 77 54 223 99 229 112 62 151 130 256 192 34 80 2 171 160 16 112 24 82 185 26 148 103 97 159 251 19 219 114 245 6 118 75 252 94 249 104 96 126 158 214 251 174 225 169 90 230 262 92 66 174 108 39 98 79 82 147 32 10 216 53 35 75 101 31 166 180 8 71 267 185 143 85 95 248 71 3 53 190 6 156 144 122 56 25 228 79 237 78 87 48 172 197 52 157 181 158 101 182 36 263 125 159 247 76 172 193 109 110 260 22 12 131 176 23 162 161 166 142 14 201 37 141 19 102 177 60 123 206 55 143 198 89 118 226 47 177 173 192 76 17 187 54 72 36 146 188 242 96 164 227 84 213 218 81 152 201 150 135 157 64 221 184 106 124 243 91 263 87 165 109 114 128 69 201 192 72 149 215 133 204 140 20 135 2 133 91 146 150 248 226 9 183 228 230 32 161 11 136 152 163 81 265 2 20 97 8 188 204 102 26 265 40 89 235 163 232 60 85 137 185 256 154 233 210 115 127 36 108 194 104 209 120 103 176 27 30 133 87 10 103 59 90 113 57 175 258 69 88 198 202 187 171 9 221 29 100 262 205 135 119 70 83 29 62 67 173 75 139 100 111 142 52 2 175 28 63 33 160 246 43 79 120 141 170 165 260 177 211 186 21 247 38 178 55 222 66 136 39 94 211 35 226 164 114 90 256 37 28 25 232 215 16 267 223 212 30 250 24 195 254 239 110 147 28 67 169 132 167 179 243 246 194 142 203 65 263 ^'}}, - {OUT=>'5E9347FE4574CDCB80281ED092191199BADD7B42'}], - ['200', {IN=> {f=> '578 0 220 147 11 47 3 149 164 57 137 185 120 120 152 78 200 251 87 78 232 177 22 129 68 168 93 74 100 5 32 174 108 173 141 266 218 232 158 61 186 87 27 75 29 260 152 59 52 38 106 20 214 132 99 6 12 46 106 7 249 140 29 41 39 124 1 15 115 136 269 100 262 67 182 38 125 168 74 113 240 24 244 156 146 63 101 210 96 162 91 127 134 84 164 6 250 120 171 226 143 149 145 96 194 17 62 102 190 155 160 195 235 8 165 243 157 43 205 16 44 121 119 172 206 15 147 249 121 68 98 58 66 253 240 5 13 213 165 5 83 248 173 122 35 5 64 17 43 224 247 257 102 177 3 168 125 187 35 56 138 165 262 118 256 103 157 62 83 229 25 179 137 217 46 55 203 101 191 135 32 193 69 116 122 54 236 7 268 101 242 209 97 142 233 125 238 109 121 87 59 1 234 41 258 50 123 253 221 127 153 45 107 174 121 138 133 66 183 205 267 166 178 138 114 188 53 37 209 148 216 28 74 132 118 237 142 214 164 25 211 63 69 97 161 194 255 136 250 139 132 169 41 20 163 58 34 57 118 37 177 222 94 60 238 141 47 22 110 107 225 195 203 82 43 192 51 52 51 71 12 14 180 72 198 117 38 157 94 9 164 76 15 128 101 261 170 40 40 21 143 200 32 161 143 181 71 31 245 123 53 256 135 267 134 65 16 63 82 62 153 264 33 109 89 244 124 220 128 50 104 105 91 146 12 27 145 64 268 82 11 79 199 84 215 80 128 69 65 235 259 17 30 259 255 187 54 204 81 63 50 136 218 213 197 118 18 29 9 113 189 220 179 124 252 54 255 155 128 82 30 227 59 252 3 98 90 179 105 21 111 4 97 110 37 190 187 86 130 16 114 156 127 102 158 42 225 144 129 17 11 28 42 206 266 186 119 223 10 80 96 143 130 184 153 26 146 44 140 80 115 104 73 165 24 44 191 154 180 53 237 174 140 99 76 47 54 223 42 6 31 194 236 175 37 158 261 151 79 180 123 2 182 257 51 103 125 219 231 178 189 1 253 2 201 218 264 1 183 237 193 18 229 244 105 72 185 152 46 87 46 36 242 241 23 77 14 148 229 263 66 202 166 210 64 49 156 76 28 93 93 61 135 13 232 126 135 251 36 4 84 145 45 120 139 113 208 181 39 105 40 72 217 265 251 55 152 27 126 186 138 184 223 61 154 161 175 107 6 269 81 114 207 201 167 107 206 234 73 184 172 174 89 212 11 98 77 214 113 221 146 31 175 88 45 139 100 243 189 213 ^'}}, - {OUT=>'D5776B7DFFF75C1358ABDBBB3F27A20BB6CA7C55'}], - ['201', {IN=> {f=> '578 1 51 63 146 108 1 111 51 120 84 73 125 49 205 233 89 38 257 66 64 66 113 15 192 147 111 17 58 49 16 244 203 46 238 54 170 2 197 169 90 90 41 1 194 62 234 92 145 113 155 141 226 243 208 200 268 48 21 126 233 40 89 178 206 145 196 166 255 234 224 105 34 23 41 84 24 176 151 73 42 219 91 225 108 50 151 130 252 184 34 72 262 163 156 4 112 20 74 177 14 140 91 85 159 243 19 211 110 237 2 114 67 248 82 241 104 88 126 150 210 247 170 225 157 90 230 262 80 54 162 104 39 86 71 78 147 28 6 216 41 35 75 97 19 154 172 59 267 185 135 77 95 244 71 267 45 186 270 144 144 110 48 13 228 75 229 70 75 40 172 189 48 153 177 154 89 170 36 259 113 147 243 68 160 189 97 102 256 14 8 131 164 19 162 161 158 142 14 197 29 141 11 90 173 52 115 202 43 131 198 81 106 218 39 169 173 192 64 9 175 50 68 28 138 176 234 84 156 227 72 213 214 77 144 193 150 127 145 56 217 176 102 124 235 87 263 83 161 109 102 116 65 201 180 64 149 215 129 200 128 8 123 266 133 79 142 146 248 222 9 183 220 226 20 157 7 128 148 163 73 265 270 12 93 8 180 204 98 22 261 28 89 227 155 224 56 85 125 181 256 154 229 210 115 119 32 108 190 100 209 112 103 176 19 22 121 79 10 95 55 82 109 53 167 258 69 80 194 202 183 171 5 213 25 88 258 201 131 115 70 83 29 58 67 165 71 127 96 107 138 44 2 163 16 55 33 160 246 35 67 108 133 162 153 260 165 203 178 17 247 38 174 55 222 58 132 27 86 211 27 226 160 106 86 260 248 33 20 25 228 207 8 263 215 212 30 242 16 195 254 239 106 135 28 55 165 120 167 175 239 238 186 130 195 65 250 220 143 9 43 271 147 160 57 137 181 116 114 150 78 196 249 85 76 232 177 22 129 68 168 87 74 94 3 26 174 104 171 137 264 218 228 158 59 184 83 21 69 23 256 146 59 52 32 100 20 214 126 93 10 46 106 3 249 134 25 39 37 122 271 15 109 136 269 100 258 61 182 36 119 164 68 111 240 18 242 156 144 61 99 206 96 156 87 123 134 82 158 2 246 118 169 222 141 143 141 94 192 15 60 96 190 149 158 191 235 4 161 241 153 37 205 10 38 117 117 166 206 13 145 245 115 62 94 52 66 253 236 271 7 211 159 5 81 246 167 118 29 1 62 11 41 224 245 255 102 173 3 166 123 183 31 56 134 165 260 116 254 81 ^'}}, - {OUT=>'022B7ADA472FB7A9DA9219621C9C5F563D3792F6'}], - ['202', {IN=> {f=> '583 1 157 50 71 225 21 167 133 217 42 47 203 89 183 131 28 193 65 116 122 42 236 7 268 93 242 201 89 138 229 125 238 97 117 75 55 267 230 33 250 50 111 245 213 127 153 45 99 162 121 134 125 54 175 197 259 166 166 126 106 188 53 33 205 148 208 16 70 128 106 233 130 210 160 17 207 63 57 97 157 194 247 128 250 135 132 165 29 16 155 50 26 49 118 37 165 218 94 60 234 137 47 14 110 103 221 191 195 70 43 184 39 40 47 59 12 6 176 60 194 117 30 153 90 1 164 76 3 124 101 261 166 36 28 9 143 196 32 153 135 177 67 31 245 123 49 248 135 262 263 126 61 12 51 78 62 149 260 29 101 77 244 116 212 120 42 92 105 91 138 27 141 52 260 74 3 79 199 84 211 68 128 61 57 227 255 17 18 259 251 187 46 196 77 55 38 132 210 205 193 110 18 25 271 105 181 216 179 112 252 50 255 147 116 82 22 219 47 248 265 86 86 171 93 13 103 266 93 98 25 186 183 86 126 16 110 148 123 94 150 38 217 132 125 9 273 20 30 198 266 178 119 219 2 72 88 131 118 172 145 26 134 40 132 80 107 96 65 161 24 44 191 150 168 41 229 170 140 99 72 43 54 215 42 2 27 186 228 163 29 146 253 147 71 180 119 264 178 249 43 99 117 219 231 170 185 1 249 272 197 214 264 263 171 237 189 6 221 236 97 72 173 152 38 87 34 28 238 241 19 77 10 136 229 255 62 194 162 206 56 45 144 64 24 89 93 53 123 9 228 118 127 243 24 4 72 133 33 120 127 113 200 181 27 101 32 68 213 257 251 43 144 19 122 186 138 184 223 61 142 149 175 107 6 261 81 114 207 193 155 95 202 226 73 180 164 166 81 204 11 98 65 206 101 221 146 19 167 88 41 139 92 235 189 235 45 59 142 104 273 105 51 118 82 67 121 49 203 233 85 34 257 62 64 64 109 11 188 143 111 11 58 45 14 240 201 44 236 52 170 270 197 169 88 86 41 269 190 58 234 92 145 111 155 135 222 243 208 200 266 48 21 122 231 40 87 178 204 141 196 162 251 232 222 99 32 23 37 80 22 174 145 71 36 217 87 223 106 44 151 130 250 180 34 68 258 159 154 272 112 18 70 173 8 136 85 79 159 239 19 207 108 233 112 63 246 76 237 104 84 126 146 208 245 168 225 151 90 230 262 74 48 156 102 39 80 67 76 147 26 4 216 35 35 75 95 13 148 168 270 53 267 185 131 73 95 242 71 265 41 184 268 138 144 104 44 7 228 73 225 66 69 36 272 ^'}}, - {OUT=>'7F1DE4ECA20362DA624653D225A5B3F7964A9FF2'}], - ['203', {IN=> {f=> '588 0 181 44 149 173 150 77 158 36 255 101 135 239 60 148 185 85 94 252 6 4 131 152 15 162 161 150 142 14 193 21 141 3 78 169 44 107 198 31 119 198 73 94 210 31 161 173 192 52 1 163 46 64 20 130 164 226 72 148 227 60 213 210 73 136 185 150 119 133 48 213 168 98 124 227 83 263 79 157 109 90 104 61 201 168 56 149 215 125 196 116 272 111 262 133 67 138 142 248 218 9 183 212 222 8 153 3 120 144 163 65 265 270 4 89 8 172 204 94 18 257 16 89 219 147 216 52 85 113 177 256 154 225 210 115 111 28 108 186 96 209 104 103 176 11 14 109 71 10 87 51 74 105 49 159 258 69 72 190 202 179 171 1 205 21 76 254 197 127 111 70 83 29 54 67 157 67 115 92 103 134 36 2 151 4 47 33 160 246 27 55 96 125 154 141 260 153 195 170 13 247 38 170 55 222 50 128 15 78 211 19 226 156 98 82 252 240 29 12 25 224 199 259 207 212 30 234 8 195 254 239 102 123 28 43 161 108 167 171 235 230 178 118 187 65 242 220 135 5 35 267 143 152 57 137 173 108 102 146 78 188 245 81 72 232 177 22 129 68 168 75 74 82 275 14 174 96 167 129 260 218 220 158 55 180 75 9 57 11 248 134 59 52 20 88 20 214 114 81 264 6 46 106 271 249 122 17 35 33 118 271 15 97 136 269 100 250 49 182 32 107 156 56 107 240 6 238 156 140 57 95 198 96 144 79 115 134 78 146 270 238 114 165 214 137 131 133 90 188 11 56 84 190 137 154 183 235 272 153 237 145 25 205 274 26 109 113 154 206 9 141 237 103 50 86 40 66 253 228 263 271 207 147 5 77 242 155 110 17 269 58 275 37 224 241 251 102 165 3 162 119 175 23 56 126 165 256 112 250 91 157 44 65 223 19 161 131 217 40 43 203 83 179 129 26 193 63 116 122 36 236 7 268 89 242 197 85 136 227 125 238 91 115 69 53 265 228 29 246 50 105 241 209 127 153 45 95 156 121 132 121 48 171 193 255 166 160 120 102 188 53 31 203 148 204 10 68 126 100 231 124 208 158 13 205 63 51 97 155 194 243 124 250 133 132 163 23 14 151 46 22 45 118 37 159 216 94 60 232 135 47 10 110 101 219 189 191 64 43 180 33 34 45 53 12 2 174 54 192 117 26 151 88 273 164 76 273 122 101 261 164 34 22 3 143 194 32 149 131 175 65 31 245 123 47 244 135 258 261 122 59 10 45 76 62 147 258 27 97 71 244 112 208 116 38 86 105 91 134 270 27 139 46 256 70 275 79 199 160 ^'}}, - {OUT=>'CA0F2B1BFB4469C11ED006A994734F0F2F5EFD17'}], - ['204', {IN=> {f=> '594 0 207 56 128 53 49 219 251 17 6 259 247 187 38 188 73 47 26 128 202 197 189 102 18 21 263 97 173 212 179 100 252 46 255 139 104 82 14 211 35 244 257 74 82 163 81 5 95 258 89 86 13 182 179 86 122 16 106 140 119 86 142 34 209 120 121 1 265 12 18 190 266 170 119 215 272 64 80 119 106 160 137 26 122 36 124 80 99 88 57 157 24 44 191 146 156 29 221 166 140 99 68 39 54 207 42 276 23 178 220 151 21 134 245 143 63 180 115 256 174 241 35 95 109 219 231 162 181 1 245 272 193 210 264 255 159 237 185 272 213 228 89 72 161 152 30 87 22 20 234 241 15 77 6 124 229 247 58 186 158 202 48 41 132 52 20 85 93 45 111 5 224 110 119 235 12 4 60 121 21 120 115 113 192 181 15 97 24 64 209 249 251 31 136 11 118 186 138 184 223 61 130 137 175 107 6 253 81 114 207 185 143 83 198 218 73 176 156 158 73 196 11 98 53 198 89 221 146 7 159 88 37 139 84 227 189 231 33 51 134 96 273 93 51 114 78 55 113 49 199 233 77 26 257 54 64 60 101 3 180 135 111 277 58 37 10 232 197 40 232 48 170 262 197 169 84 78 41 261 182 50 234 92 145 107 155 123 214 243 208 200 262 48 21 114 227 40 83 178 200 133 196 154 243 228 218 87 28 23 29 72 18 170 133 67 24 213 79 219 102 32 151 130 246 172 34 60 250 151 150 264 112 14 62 165 274 128 73 67 159 231 19 199 104 225 274 108 55 242 64 229 104 76 126 138 204 241 164 225 139 90 230 262 62 36 144 98 39 68 59 72 147 22 216 23 35 75 91 1 136 160 266 41 267 185 123 65 95 238 71 261 33 180 264 126 144 92 36 273 228 69 217 58 57 28 172 177 42 147 171 148 71 152 36 253 95 129 237 56 142 183 79 90 250 2 2 131 146 13 162 161 146 142 14 191 17 141 277 72 167 40 103 196 25 113 198 69 88 206 27 157 173 192 46 275 157 44 62 16 126 158 222 66 144 227 54 213 208 71 132 181 150 115 127 44 211 164 96 124 223 81 263 77 155 109 84 98 59 201 162 52 149 215 123 194 110 268 105 260 133 61 136 140 248 216 9 183 208 220 2 151 1 116 142 163 61 265 270 87 8 168 204 92 16 255 10 89 215 143 212 50 85 107 175 256 154 223 210 115 107 26 108 184 94 209 100 103 176 7 10 103 67 10 83 49 70 103 47 155 258 69 68 188 202 177 171 277 201 19 70 252 195 125 109 70 83 29 52 67 153 65 109 90 101 132 32 2 145 276 43 33 160 246 23 259 ^'}}, - {OUT=>'833D63F5C2EA0CD43EC15F2B9DD97FF12B030479'}], - ['205', {IN=> {f=> '600 1 87 119 148 132 260 144 189 164 10 247 38 167 55 222 44 125 6 72 211 13 226 153 92 79 246 234 26 6 25 221 193 273 256 201 212 30 228 2 195 254 239 99 114 28 34 158 99 167 168 232 224 172 109 181 65 236 220 129 2 29 264 140 146 57 137 167 102 93 143 78 182 242 78 69 232 177 22 129 68 168 66 74 73 275 5 174 90 164 123 257 218 214 158 52 177 69 48 2 242 125 59 52 11 79 20 214 105 72 258 3 46 106 268 249 113 11 32 30 115 271 15 88 136 269 100 244 40 182 29 98 150 47 104 240 276 235 156 137 54 92 192 96 135 73 109 134 75 137 267 232 111 162 208 134 122 127 87 185 8 53 75 190 128 151 177 235 269 147 234 139 16 205 268 17 103 110 145 206 6 138 231 94 41 80 31 66 253 222 257 265 204 138 5 74 239 146 104 8 266 55 269 34 224 238 248 102 159 3 159 116 169 17 56 120 165 253 109 247 85 157 35 56 220 16 152 128 217 37 37 203 74 173 126 23 193 60 116 122 27 236 7 268 83 242 191 79 133 224 125 238 82 112 60 50 262 225 23 240 50 96 235 203 127 153 45 89 147 121 129 115 39 165 187 249 166 151 111 96 188 53 28 200 148 198 1 65 123 91 228 115 205 155 7 202 63 42 97 152 194 237 118 250 130 132 160 14 11 145 40 16 39 118 37 150 213 94 60 229 132 47 4 110 98 216 186 185 55 43 174 24 25 42 44 12 275 171 45 189 117 20 148 85 270 164 76 267 119 101 261 161 31 13 273 143 191 32 143 125 172 62 31 245 123 44 238 135 252 258 116 56 7 36 73 62 144 255 24 91 62 244 106 202 110 32 77 105 91 128 264 27 136 37 250 64 272 79 199 84 206 53 128 51 47 217 250 17 3 259 246 187 36 186 72 45 23 127 200 195 188 100 18 20 261 95 171 211 179 97 252 45 255 137 101 82 12 209 32 243 255 71 81 161 78 3 93 256 88 83 10 181 178 86 121 16 105 138 118 84 140 33 207 117 120 278 263 10 15 188 266 168 119 214 271 62 78 116 103 157 135 26 119 35 122 80 97 86 55 156 24 44 191 145 153 26 219 165 140 99 67 38 54 205 42 276 22 176 218 148 19 131 243 142 61 180 114 254 173 239 33 94 107 219 231 160 180 1 244 272 192 209 264 253 156 237 184 270 211 226 87 72 158 152 28 87 19 18 233 241 14 77 5 121 229 245 57 184 157 201 46 40 129 49 19 84 93 43 108 4 223 108 117 233 9 4 57 118 18 120 112 113 190 181 12 96 22 63 208 247 251 28 134 9 117 186 138 184 223 61 127 216 ^'}}, - {OUT=>'14FD356190416C00592B86FF7CA50B622F85593A'}], - ['206', {IN=> {f=> '590 1 175 107 6 247 81 114 207 179 134 74 195 212 73 173 150 152 67 190 11 98 44 192 80 221 146 279 153 88 34 139 78 221 189 228 24 45 128 90 273 84 51 111 75 46 107 49 196 233 71 20 257 48 64 57 95 278 174 129 111 271 58 31 7 226 194 37 229 45 170 256 197 169 81 72 41 255 176 44 234 92 145 104 155 114 208 243 208 200 259 48 21 108 224 40 80 178 197 127 196 148 237 225 215 78 25 23 23 66 15 167 124 64 15 210 73 216 99 23 151 130 243 166 34 54 244 145 147 258 112 11 56 159 268 122 64 58 159 225 19 193 101 219 274 105 49 239 55 223 104 70 126 132 201 238 161 225 130 90 230 262 53 27 135 95 39 59 53 69 147 19 278 216 14 35 75 88 273 127 154 263 32 267 185 117 59 95 235 71 258 27 177 261 117 144 83 30 267 228 66 211 52 48 22 172 171 39 144 168 145 62 143 36 250 86 120 234 50 133 180 70 84 247 277 280 131 137 10 162 161 140 142 14 188 11 141 274 63 164 34 97 193 16 104 198 63 79 200 21 151 173 192 37 272 148 41 59 10 120 149 216 57 138 227 45 213 205 68 126 175 150 109 118 38 208 158 93 124 217 78 263 74 152 109 75 89 56 201 153 46 149 215 120 191 101 262 96 257 133 52 133 137 248 213 9 183 202 217 274 148 279 110 139 163 55 265 270 275 84 8 162 204 89 13 252 1 89 209 137 206 47 85 98 172 256 154 220 210 115 101 23 108 181 91 209 94 103 176 1 4 94 61 10 77 46 64 100 44 149 258 69 62 185 202 174 171 277 195 16 61 249 192 122 106 70 83 29 49 67 147 62 100 87 98 129 26 2 136 270 37 33 160 246 17 40 81 115 144 126 260 138 185 160 8 247 38 165 55 222 40 123 68 211 9 226 151 88 77 242 230 24 2 25 219 189 271 254 197 212 30 224 279 195 254 239 97 108 28 28 156 93 167 166 230 220 168 103 177 65 232 220 125 25 262 138 142 57 137 163 98 87 141 78 178 240 76 67 232 177 22 129 68 168 60 74 67 275 280 174 86 162 119 255 218 210 158 50 175 65 275 42 277 238 119 59 52 5 73 20 214 99 66 254 1 46 106 266 249 107 7 30 28 113 271 15 82 136 269 100 240 34 182 27 92 146 41 102 240 272 233 156 135 52 90 188 96 129 69 105 134 73 131 265 228 109 160 204 132 116 123 85 183 6 51 69 190 122 149 173 235 267 143 232 135 10 205 264 11 99 108 139 206 4 136 227 88 35 76 25 66 253 218 253 261 202 132 5 72 237 140 203 ^'}}, - {OUT=>'4AB6B57EDDEF1CE935622F935C1619AE7C1667D6'}], - ['207', {IN=> {f=> '620 0 279 262 51 261 30 224 234 244 102 151 3 155 112 161 9 56 112 165 249 105 243 77 157 23 44 216 12 140 124 217 33 29 203 62 165 122 19 193 56 116 122 15 236 7 268 75 242 183 71 129 220 125 238 70 108 48 46 258 221 15 232 50 84 227 195 127 153 45 81 135 121 125 107 27 157 179 241 166 139 99 88 188 53 24 196 148 190 272 61 119 79 224 103 201 151 282 198 63 30 97 148 194 229 110 250 126 132 156 2 7 137 32 8 31 118 37 138 209 94 60 225 128 47 279 110 94 212 182 177 43 43 166 12 13 38 32 12 271 167 33 185 117 12 144 81 266 164 76 259 115 101 261 157 27 1 265 143 187 32 135 117 168 58 31 245 123 40 230 135 244 254 108 52 3 24 69 62 140 251 20 83 50 244 98 194 102 24 65 105 91 120 256 27 132 25 242 56 268 79 199 84 202 41 128 43 39 209 246 17 274 259 242 187 28 178 68 37 11 123 192 187 184 92 18 16 253 87 163 207 179 85 252 41 255 129 89 82 4 201 20 239 247 59 77 153 66 278 85 248 84 71 281 177 174 86 117 16 101 130 114 76 132 29 199 105 116 274 255 2 3 180 266 160 119 210 267 54 70 104 91 145 127 26 107 31 114 80 89 78 47 152 24 44 191 141 141 14 211 161 140 99 63 34 54 197 42 276 18 168 210 136 11 119 235 138 53 180 110 246 169 231 25 90 99 219 231 152 176 1 240 272 188 205 264 245 144 237 180 262 203 218 79 72 146 152 20 87 7 10 229 241 10 77 1 109 229 237 53 176 153 197 38 36 117 37 15 80 93 35 96 219 100 109 225 280 4 45 106 6 120 100 113 182 181 92 14 59 204 239 251 16 126 1 113 186 138 184 223 61 115 122 175 107 6 243 81 114 207 175 128 68 193 208 73 171 146 148 63 186 11 98 38 188 74 221 146 275 149 88 32 139 74 217 189 226 18 41 124 86 273 78 51 109 73 40 103 49 194 233 67 16 257 44 64 55 91 276 170 125 111 267 58 27 5 222 192 35 227 43 170 252 197 169 79 68 41 251 172 40 234 92 145 102 155 108 204 243 208 200 257 48 21 104 222 40 78 178 195 123 196 144 233 223 213 72 23 23 19 62 13 165 118 62 9 208 69 214 97 17 151 130 241 162 34 50 240 141 145 254 112 9 52 155 264 118 58 52 159 221 19 189 99 215 274 103 45 237 49 219 104 66 126 128 199 236 159 225 124 90 230 262 47 21 129 93 39 53 49 67 147 17 278 216 8 35 75 86 269 121 150 261 26 267 185 113 55 95 233 71 256 23 175 259 111 144 77 26 263 228 64 207 48 42 18 172 167 37 142 166 143 56 137 36 248 80 114 232 46 127 257 ^'}}, - {OUT=>'B456A6A968ACD66CAA974F96A9A916E700AA3C5D'}], - ['208', {IN=> {f=> '605 1 58 76 243 273 280 131 125 6 162 161 132 142 14 184 3 141 270 51 160 26 89 189 4 92 198 55 67 192 13 143 173 192 25 268 136 37 55 2 112 137 208 45 130 227 33 213 201 64 118 167 150 101 106 30 204 150 89 124 209 74 263 70 148 109 63 77 52 201 141 38 149 215 116 187 89 254 84 253 133 40 129 133 248 209 9 183 194 213 266 144 279 102 135 163 47 265 270 271 80 8 154 204 85 9 248 274 89 201 129 198 43 85 86 168 256 154 216 210 115 93 19 108 177 87 209 86 103 176 278 281 82 53 10 69 42 56 96 40 141 258 69 54 181 202 170 171 277 187 12 49 245 188 118 102 70 83 29 45 67 139 58 88 83 94 125 18 2 124 262 29 33 160 246 9 28 69 107 136 114 260 126 177 152 4 247 38 161 55 222 32 119 273 60 211 1 226 147 80 73 234 222 20 279 25 215 181 267 250 189 212 30 216 275 195 254 239 93 96 28 16 152 81 167 162 226 212 160 91 169 65 224 220 117 281 17 258 134 134 57 137 155 90 75 137 78 170 236 72 63 232 177 22 129 68 168 48 74 55 275 272 174 78 158 111 251 218 202 158 46 171 57 267 30 269 230 107 59 52 278 61 20 214 87 54 246 282 46 106 262 249 95 284 26 24 109 271 15 70 136 269 100 232 22 182 23 80 138 29 98 240 264 229 156 131 48 86 180 96 117 61 97 134 69 119 261 220 105 156 196 128 104 115 81 179 2 47 57 190 110 145 165 235 263 135 228 127 283 205 256 284 91 104 127 206 132 219 76 23 68 13 66 253 210 245 253 198 120 5 68 233 128 92 275 260 49 257 28 224 232 242 102 147 3 153 110 157 5 56 108 165 247 103 241 73 157 17 38 214 10 134 122 217 31 25 203 56 161 120 17 193 54 116 122 9 236 7 268 71 242 179 67 127 218 125 238 64 106 42 44 256 219 11 228 50 78 223 191 127 153 45 77 129 121 123 103 21 153 175 237 166 133 93 84 188 53 22 194 148 186 268 59 117 73 222 97 199 149 280 196 63 24 97 146 194 225 106 250 124 132 154 281 5 133 28 4 27 118 37 132 207 94 60 223 126 47 277 110 92 210 180 173 37 43 162 6 7 36 26 12 269 165 27 183 117 8 142 79 264 164 76 255 113 101 261 155 25 280 261 143 185 32 131 113 166 56 31 245 123 38 226 135 240 252 104 50 1 18 67 62 138 249 18 79 44 244 94 190 98 20 59 105 91 116 252 27 130 19 238 52 266 79 199 84 200 35 128 39 35 205 244 17 270 259 240 187 24 174 66 33 5 121 188 183 182 88 18 14 249 83 159 205 179 79 252 186 ^'}}, - {OUT=>'FD1C257FE046B2A27E2F0CD55ED2DECA845F01D7'}], - ['209', {IN=> {f=> '615 0 255 121 77 82 283 193 8 235 239 47 73 145 54 274 77 240 80 59 273 173 170 86 113 16 97 122 110 68 124 25 191 93 112 270 247 281 278 172 266 152 119 206 263 46 62 92 79 133 119 26 95 27 106 80 81 70 39 148 24 44 191 137 129 2 203 157 140 99 59 30 54 189 42 276 14 160 202 124 3 107 227 134 45 180 106 238 165 223 17 86 91 219 231 144 172 1 236 272 184 201 264 237 132 237 176 254 195 210 71 72 134 152 12 87 282 2 225 241 6 77 284 97 229 229 49 168 149 193 30 32 105 25 11 76 93 27 84 283 215 92 101 217 272 4 33 94 281 120 88 113 174 181 275 88 6 55 200 231 251 4 118 280 109 186 138 184 223 61 103 110 175 107 6 235 81 114 207 167 116 56 189 200 73 167 138 140 55 178 11 98 26 180 62 221 146 267 141 88 28 139 66 209 189 222 6 33 116 78 273 66 51 105 69 28 95 49 190 233 59 8 257 36 64 51 83 272 162 117 111 259 58 19 1 214 188 31 223 39 170 244 197 169 75 60 41 243 164 32 234 92 145 98 155 96 196 243 208 200 253 48 21 96 218 40 74 178 191 115 196 136 225 219 209 60 19 23 11 54 9 161 106 58 284 204 61 210 93 5 151 130 237 154 34 42 232 133 141 246 112 5 44 147 256 110 46 40 159 213 19 181 95 207 274 99 37 233 37 211 104 58 126 120 195 232 155 225 112 90 230 262 35 9 117 89 39 41 41 63 147 13 278 216 283 35 75 82 261 109 142 257 14 267 185 105 47 95 229 71 252 15 171 255 99 144 65 18 255 228 60 199 40 30 10 172 159 33 138 162 139 44 125 36 244 68 102 228 38 115 174 52 72 241 271 280 131 119 4 162 161 128 142 14 182 286 141 268 45 158 22 85 187 285 86 198 51 61 188 9 139 173 192 19 266 130 35 53 285 108 131 204 39 126 227 27 213 199 62 114 163 150 97 100 26 202 146 87 124 205 72 263 68 146 109 57 71 50 201 135 34 149 215 114 185 83 250 78 251 133 34 127 131 248 207 9 183 190 211 262 142 279 98 133 163 43 265 270 269 78 8 150 204 83 7 246 270 89 197 125 194 41 85 80 166 256 154 214 210 115 89 17 108 175 85 209 82 103 176 276 279 76 49 10 65 40 52 94 38 137 258 69 50 179 202 168 171 277 183 10 43 243 186 116 100 70 83 29 43 67 135 56 82 81 92 123 14 2 118 258 25 33 160 246 5 22 63 103 132 108 260 120 173 148 2 247 38 159 55 222 28 117 269 56 211 284 226 145 76 71 230 218 18 277 25 213 177 265 248 185 212 30 212 273 195 254 239 91 90 28 10 150 75 167 160 224 175 ^'}}, - {OUT=>'66E0D01780F1063E2929EAAD74826BC64060E38C'}], - ['210', {IN=> {f=> '613 0 152 79 161 65 216 220 109 281 9 254 130 126 57 137 147 82 63 133 78 162 232 68 59 232 177 22 129 68 168 36 74 43 275 264 174 70 154 103 247 218 194 158 42 167 49 259 18 261 222 95 59 52 270 49 20 214 75 42 238 282 46 106 258 249 83 280 22 20 105 271 15 58 136 269 100 224 10 182 19 68 130 17 94 240 256 225 156 127 44 82 172 96 105 53 89 134 65 107 257 212 101 152 188 124 92 107 77 175 287 43 45 190 98 141 157 235 259 127 224 119 275 205 248 276 83 100 115 206 285 128 211 64 11 60 1 66 253 202 237 245 194 108 5 64 229 116 84 267 256 45 249 24 224 228 238 102 139 3 149 106 149 286 56 100 165 243 99 237 65 157 5 26 210 6 122 118 217 27 17 203 44 153 116 13 193 50 116 122 286 236 7 268 63 242 171 59 123 214 125 238 52 102 30 40 252 215 3 220 50 66 215 183 127 153 45 69 117 121 119 95 9 145 167 229 166 121 81 76 188 53 18 190 148 178 260 55 113 61 218 85 195 145 276 192 63 12 97 142 194 217 98 250 120 132 150 273 1 125 20 285 19 118 37 120 203 94 60 219 122 47 273 110 88 206 176 165 25 43 154 283 284 32 14 12 265 161 15 179 117 138 75 260 164 76 247 109 101 261 151 21 272 253 143 181 32 123 105 162 52 31 245 123 34 218 135 232 248 96 46 286 6 63 62 134 245 14 71 32 244 86 182 90 12 47 105 91 108 244 27 126 7 230 44 262 79 199 84 196 23 128 31 27 197 240 17 262 259 236 187 16 166 62 25 282 117 180 175 178 80 18 10 241 75 151 201 179 67 252 35 255 117 71 82 281 189 2 233 235 41 71 141 48 272 73 236 78 53 269 171 168 86 111 16 95 118 108 64 120 23 187 87 110 268 243 279 274 168 266 148 119 204 261 42 58 86 73 127 115 26 89 25 102 80 77 66 35 146 24 44 191 135 123 285 199 155 140 99 57 28 54 185 42 276 12 156 198 118 288 101 223 132 41 180 104 234 163 219 13 84 87 219 231 140 170 1 234 272 182 199 264 233 126 237 174 250 191 206 67 72 128 152 8 87 278 287 223 241 4 77 284 91 229 225 47 164 147 191 26 30 99 19 9 74 93 23 78 283 213 88 97 213 268 4 27 88 277 120 82 113 170 181 271 86 2 53 198 227 251 287 114 278 107 186 138 184 223 61 97 104 175 107 6 231 81 114 207 163 110 50 187 196 73 165 134 136 51 174 11 98 20 176 56 221 146 263 137 88 26 139 62 205 189 220 29 112 74 273 60 51 103 67 22 91 49 188 233 55 4 257 32 64 49 79 270 158 113 111 255 58 15 288 210 213 ^'}}, - {OUT=>'A8478DF406F179FD4EF97F4574D7F99EA1CE9EB8'}], - ['211', {IN=> {f=> '624 1 28 220 36 170 238 197 169 72 54 41 237 158 26 234 92 145 95 155 87 190 243 208 200 250 48 21 90 215 40 71 178 188 109 196 130 219 216 206 51 16 23 5 48 6 158 97 55 278 201 55 207 90 286 151 130 234 148 34 36 226 127 138 240 112 2 38 141 250 104 37 31 159 207 19 175 92 201 274 96 31 230 28 205 104 52 126 114 192 229 152 225 103 90 230 262 26 108 86 39 32 35 60 147 10 278 216 277 35 75 79 255 100 136 254 5 267 185 99 41 95 226 71 249 9 168 252 90 144 56 12 249 228 57 193 34 21 4 172 153 30 135 159 136 35 116 36 241 59 93 225 32 106 171 43 66 238 268 280 131 110 1 162 161 122 142 14 179 283 141 265 36 155 16 79 184 279 77 198 45 52 182 3 133 173 192 10 263 121 32 50 282 102 122 198 30 120 227 18 213 196 59 108 157 150 91 91 20 199 140 84 124 199 69 263 65 143 109 48 62 47 201 126 28 149 215 111 182 74 244 69 248 133 25 124 128 248 204 9 183 184 208 256 139 279 92 130 163 37 265 270 266 75 8 144 204 80 4 243 264 89 191 119 188 38 85 71 163 256 154 211 210 115 83 14 108 172 82 209 76 103 176 273 276 67 43 10 59 37 46 91 35 131 258 69 44 176 202 165 171 277 177 7 34 240 183 113 97 70 83 29 40 67 129 53 73 78 89 120 8 2 109 252 19 33 160 246 289 13 54 97 126 99 260 111 167 142 289 247 38 156 55 222 22 114 263 50 211 281 226 142 70 68 224 212 15 274 25 210 171 262 245 179 212 30 206 270 195 254 239 88 81 28 1 147 66 167 157 221 202 150 76 159 65 214 220 107 281 7 253 129 124 57 137 145 80 60 132 78 160 231 67 58 232 177 22 129 68 168 33 74 40 275 262 174 68 153 101 246 218 192 158 41 166 47 257 15 259 220 92 59 52 268 46 20 214 72 39 236 282 46 106 257 249 80 279 21 19 104 271 15 55 136 269 100 222 7 182 18 65 128 14 93 240 254 224 156 126 43 81 170 96 102 51 87 134 64 104 256 210 100 151 186 123 89 105 76 174 287 42 42 190 95 140 155 235 258 125 223 117 273 205 246 274 81 99 112 206 285 127 209 61 8 58 288 66 253 200 235 243 193 105 5 63 228 113 82 265 255 44 247 23 224 227 237 102 137 3 148 105 147 285 56 98 165 242 98 236 63 157 2 23 209 5 119 117 217 26 15 203 41 151 115 12 193 49 116 122 284 236 7 268 61 242 169 57 122 213 125 238 49 101 27 39 251 214 1 218 50 63 213 181 127 153 45 67 114 121 118 93 6 143 165 227 166 118 78 74 188 53 17 189 148 176 258 54 112 58 217 82 194 144 275 191 141 ^'}}, - {OUT=>'248E58CF09A372114FC2F93B09C5FC14F3D0059E'}], - ['212', {IN=> {f=> '628 1 3 97 139 194 211 92 250 117 132 147 267 290 119 14 282 13 118 37 111 200 94 60 216 119 47 270 110 85 203 173 159 16 43 148 277 278 29 5 12 262 158 6 176 117 286 135 72 257 164 76 241 106 101 261 148 18 266 247 143 178 32 117 99 159 49 31 245 123 31 212 135 226 245 90 43 286 289 60 62 131 242 11 65 23 244 80 176 84 6 38 105 91 102 238 27 123 290 224 38 259 79 199 84 193 14 128 25 21 191 237 17 256 259 233 187 10 160 59 19 276 114 174 169 175 74 18 7 235 69 145 198 179 58 252 32 255 111 62 82 278 183 285 230 229 32 68 135 39 269 67 230 75 44 263 168 165 86 108 16 92 112 105 58 114 20 181 78 107 265 237 276 268 162 266 142 119 201 258 36 52 77 64 118 109 26 80 22 96 80 71 60 29 143 24 44 191 132 114 279 193 152 140 99 54 25 54 179 42 276 9 150 192 109 285 92 217 129 35 180 101 228 160 213 7 81 81 219 231 134 167 1 231 272 179 196 264 227 117 237 171 244 185 200 61 72 119 152 2 87 272 284 220 241 1 77 284 82 229 219 44 158 144 188 20 27 90 10 6 71 93 17 69 283 210 82 91 207 262 4 18 79 271 120 73 113 164 181 265 83 288 50 195 221 251 281 108 275 104 186 138 184 223 61 88 95 175 107 6 225 81 114 207 157 101 41 184 190 73 162 128 130 45 168 11 98 11 170 47 221 146 257 131 88 23 139 56 199 189 217 283 23 106 68 273 51 51 100 64 13 85 49 185 233 49 290 257 26 64 46 73 267 152 107 111 249 58 9 288 204 183 26 218 34 170 234 197 169 70 50 41 233 154 22 234 92 145 93 155 81 186 243 208 200 248 48 21 86 213 40 69 178 186 105 196 126 215 214 204 45 14 23 1 44 4 156 91 53 274 199 51 205 88 282 151 130 232 144 34 32 222 123 136 236 112 34 137 246 100 31 25 159 203 19 171 90 197 274 94 27 228 22 201 104 48 126 110 190 227 150 225 97 90 230 262 20 286 102 84 39 26 31 58 147 8 278 216 273 35 75 77 251 94 132 252 291 267 185 95 37 95 224 71 247 5 166 250 84 144 50 8 245 228 55 189 30 15 172 149 28 133 157 134 29 110 36 239 53 87 223 28 100 169 37 62 236 266 280 131 104 291 162 161 118 142 14 177 281 141 263 30 153 12 75 182 275 71 198 41 46 178 291 129 173 192 4 261 115 30 48 280 98 116 194 24 116 227 12 213 194 57 104 153 150 87 85 16 197 136 82 124 195 67 263 63 141 109 42 56 45 201 120 24 149 215 109 180 68 240 63 246 133 19 122 126 248 202 9 183 180 206 252 137 279 88 128 163 33 265 270 264 73 8 140 204 78 2 241 76 ^'}}, - {OUT=>'F15767DE91796A6816977EFA4FCED4B7FD9B8A57'}], - ['213', {IN=> {f=> '622 0 89 183 111 180 34 85 59 159 256 154 207 210 115 75 10 108 168 78 209 68 103 176 269 272 55 35 10 51 33 38 87 31 123 258 69 36 172 202 161 171 277 169 3 22 236 179 109 93 70 83 29 36 67 121 49 61 74 85 116 2 97 244 11 33 160 246 285 1 42 89 118 87 260 99 159 134 289 247 38 152 55 222 14 110 255 42 211 277 226 138 62 64 216 204 11 270 25 206 163 258 241 171 212 30 198 266 195 254 239 84 69 28 283 143 54 167 153 217 194 142 64 151 65 206 220 99 281 293 249 125 116 57 137 137 72 48 128 78 152 227 63 54 232 177 22 129 68 168 21 74 28 275 254 174 60 149 93 242 218 184 158 37 162 39 249 3 251 212 80 59 52 260 34 20 214 60 27 228 282 46 106 253 249 68 275 17 15 100 271 15 43 136 269 100 214 289 182 14 53 120 2 89 240 246 220 156 122 39 77 162 96 90 43 79 134 60 92 252 202 96 147 178 119 77 97 72 170 287 38 30 190 83 136 147 235 254 117 219 109 265 205 238 266 73 95 100 206 285 123 201 49 290 50 280 66 253 192 227 235 189 93 5 59 224 101 74 257 251 40 239 19 224 223 233 102 129 3 144 101 139 281 56 90 165 238 94 232 55 157 284 11 205 1 107 113 217 22 7 203 29 143 111 8 193 45 116 122 276 236 7 268 53 242 161 49 118 209 125 238 37 97 15 35 247 210 287 210 50 51 205 173 127 153 45 59 102 121 114 85 288 135 157 219 166 106 66 66 188 53 13 185 148 168 250 50 108 46 213 70 190 140 271 187 63 291 97 137 194 207 88 250 115 132 145 263 290 115 10 280 9 118 37 105 198 94 60 214 117 47 268 110 83 201 171 155 10 43 144 273 274 27 293 12 260 156 174 117 284 133 70 255 164 76 237 104 101 261 146 16 262 243 143 176 32 113 95 157 47 31 245 123 29 208 135 222 243 86 41 286 285 58 62 129 240 9 61 17 244 76 172 80 2 32 105 91 98 234 27 121 286 220 34 257 79 199 84 191 8 128 21 17 187 235 17 252 259 231 187 6 156 57 15 272 112 170 165 173 70 18 5 231 65 141 196 179 52 252 30 255 107 56 82 276 179 281 228 225 26 66 131 33 267 63 226 73 38 259 166 163 86 106 16 90 108 103 54 110 18 177 72 105 263 233 274 264 158 266 138 119 199 256 32 48 71 58 112 105 26 74 20 92 80 67 56 25 141 24 44 191 130 108 275 189 150 140 99 52 23 54 175 42 276 7 146 188 103 283 86 213 127 31 180 99 224 158 209 3 79 77 219 231 130 165 1 229 272 177 194 264 223 111 237 169 240 181 196 57 72 113 152 292 87 268 282 218 241 293 77 284 76 229 80 ^'}}, - {OUT=>'36A6BC5E680E15675D9696338C88B36248BBBAF4'}], - ['214', {IN=> {f=> '635 1 40 150 140 184 12 23 78 294 2 67 93 9 57 283 206 74 83 199 254 4 6 67 263 120 61 113 156 181 257 79 284 46 191 213 251 273 100 271 100 186 138 184 223 61 76 83 175 107 6 217 81 114 207 149 89 29 180 182 73 158 120 122 37 160 11 98 295 162 35 221 146 249 123 88 19 139 48 191 189 213 275 15 98 60 273 39 51 96 60 1 77 49 181 233 41 286 257 18 64 42 65 263 144 99 111 241 58 1 288 196 179 22 214 30 170 226 197 169 66 42 41 225 146 14 234 92 145 89 155 69 178 243 208 200 244 48 21 78 209 40 65 178 182 97 196 118 207 210 200 33 10 23 289 36 152 79 49 266 195 43 201 84 274 151 130 228 136 34 24 214 115 132 228 112 292 26 129 238 92 19 13 159 195 19 163 86 189 274 90 19 224 10 193 104 40 126 102 186 223 146 225 85 90 230 262 8 278 90 80 39 14 23 54 147 4 278 216 265 35 75 73 243 82 124 248 283 267 185 87 29 95 220 71 243 293 162 246 72 144 38 237 228 51 181 22 3 288 172 141 24 129 153 130 17 98 36 235 41 75 219 20 88 165 25 54 232 262 280 131 92 291 162 161 110 142 14 173 277 141 259 18 149 4 67 178 267 59 198 33 34 170 287 121 173 192 288 257 103 26 44 276 90 104 186 12 108 227 213 190 53 96 145 150 79 73 8 193 128 78 124 187 63 263 59 137 109 30 44 41 201 108 16 149 215 105 176 56 232 51 242 133 7 118 122 248 198 9 183 172 202 244 133 279 80 124 163 25 265 270 260 69 8 132 204 74 294 237 252 89 179 107 176 32 85 53 157 256 154 205 210 115 71 8 108 166 76 209 64 103 176 267 270 49 31 10 47 31 34 85 29 119 258 69 32 170 202 159 171 277 165 1 16 234 177 107 91 70 83 29 34 67 117 47 55 72 83 114 292 2 91 240 7 33 160 246 283 291 36 85 114 81 260 93 155 130 289 247 38 150 55 222 10 108 251 38 211 275 226 136 58 62 212 200 9 268 25 204 159 256 239 167 212 30 194 264 195 254 239 82 63 28 279 141 48 167 151 215 190 138 58 147 65 202 220 95 281 291 247 123 112 57 137 133 68 42 126 78 148 225 61 52 232 177 22 129 68 168 15 74 22 275 250 174 56 147 89 240 218 180 158 35 160 35 245 293 247 208 74 59 52 256 28 20 214 54 21 224 282 46 106 251 249 62 273 15 13 98 271 15 37 136 269 100 210 285 182 12 47 116 292 87 240 242 218 156 120 37 75 158 96 84 39 75 134 58 86 250 198 94 145 174 117 71 93 70 168 287 36 24 190 77 134 143 235 252 113 217 105 261 205 234 262 69 93 94 206 285 121 197 43 286 46 276 66 253 188 223 231 187 87 5 57 222 95 285 ^'}}, - {OUT=>'4DEA6251B2A6DF017A8093AB066EE3863A4EC369'}], - ['215', {IN=> {f=> '636 0 251 248 37 233 16 224 220 230 102 123 3 141 98 133 278 56 84 165 235 91 229 49 157 278 2 202 295 98 110 217 19 1 203 20 137 108 5 193 42 116 122 270 236 7 268 47 242 155 43 115 206 125 238 28 94 6 32 244 207 284 204 50 42 199 167 127 153 45 53 93 121 111 79 282 129 151 213 166 97 57 60 188 53 10 182 148 162 244 47 105 37 210 61 187 137 268 184 63 285 97 134 194 201 82 250 112 132 142 257 290 109 4 277 3 118 37 96 195 94 60 211 114 47 265 110 80 198 168 149 1 43 138 267 268 24 287 12 257 153 288 171 117 281 130 67 252 164 76 231 101 101 261 143 13 256 237 143 173 32 107 89 154 44 31 245 123 26 202 135 216 240 80 38 286 279 55 62 126 237 6 55 8 244 70 166 74 293 23 105 91 92 228 27 118 280 214 28 254 79 199 84 188 296 128 15 11 181 232 17 246 259 228 187 150 54 9 266 109 164 159 170 64 18 2 225 59 135 193 179 43 252 27 255 101 47 82 273 173 275 225 219 17 63 125 24 264 57 220 70 29 253 163 160 86 103 16 87 102 100 48 104 15 171 63 102 260 227 271 258 152 266 132 119 196 253 26 42 62 49 103 99 26 65 17 86 80 61 50 19 138 24 44 191 127 99 269 183 147 140 99 49 20 54 169 42 276 4 140 182 94 280 77 207 124 25 180 96 218 155 203 294 76 71 219 231 124 162 1 226 272 174 191 264 217 102 237 166 234 175 190 51 72 104 152 289 87 262 279 215 241 293 77 284 67 229 209 39 148 139 183 10 22 75 292 1 66 93 7 54 283 205 72 81 197 252 4 3 64 261 120 58 113 154 181 255 78 283 45 190 211 251 271 98 270 99 186 138 184 223 61 73 80 175 107 6 215 81 114 207 147 86 26 179 180 73 157 118 120 35 158 11 98 293 160 32 221 146 247 121 88 18 139 46 189 189 212 273 13 96 58 273 36 51 95 59 295 75 49 180 233 39 285 257 16 64 41 63 262 142 97 111 239 58 296 288 194 178 21 213 29 170 224 197 169 65 40 41 223 144 12 234 92 145 88 155 66 176 243 208 200 243 48 21 76 208 40 64 178 181 95 196 116 205 209 199 30 9 23 288 34 296 151 76 48 264 194 41 200 83 272 151 130 227 134 34 22 212 113 131 226 112 292 24 127 236 90 16 10 159 193 19 161 85 187 274 89 17 223 7 191 104 38 126 100 185 222 145 225 82 90 230 262 5 276 87 79 39 11 21 53 147 3 278 216 263 35 75 72 241 79 122 247 281 267 185 85 27 95 219 71 242 292 161 245 69 144 35 295 235 228 50 179 20 287 172 139 23 128 152 129 14 95 36 234 38 72 218 18 85 164 22 52 231 261 280 131 89 291 162 161 108 142 14 172 276 91 ^'}}, - {OUT=>'D30E70E357D57E3D82CA554B8A3D58DFF528FA94'}], - ['216', {IN=> {f=> '635 1 256 9 146 297 61 175 261 50 198 27 25 164 284 115 173 192 282 254 94 23 41 273 84 95 180 3 102 227 290 213 187 50 90 139 150 73 64 2 190 122 75 124 181 60 263 56 134 109 21 35 38 201 99 10 149 215 102 173 47 226 42 239 133 297 115 119 248 195 9 183 166 199 238 130 279 74 121 163 19 265 270 257 66 8 126 204 71 294 234 246 89 173 101 170 29 85 44 154 256 154 202 210 115 65 5 108 163 73 209 58 103 176 264 267 40 25 10 41 28 28 82 26 113 258 69 26 167 202 156 171 277 159 297 7 231 174 104 88 70 83 29 31 67 111 44 46 69 80 111 289 2 82 234 1 33 160 246 280 285 27 79 108 72 260 84 149 124 289 247 38 147 55 222 4 105 245 32 211 272 226 133 52 59 206 194 6 265 25 201 153 253 236 161 212 30 188 261 195 254 239 79 54 28 273 138 39 167 148 212 184 132 49 141 65 196 220 89 281 288 244 120 106 57 137 127 62 33 123 78 142 222 58 49 232 177 22 129 68 168 6 74 13 275 244 174 50 144 83 237 218 174 158 32 157 29 239 287 241 202 65 59 52 250 19 20 214 45 12 218 282 46 106 248 249 53 270 12 10 95 271 15 28 136 269 100 204 279 182 9 38 110 286 84 240 236 215 156 117 34 72 152 96 75 33 69 134 55 77 247 192 91 142 168 114 62 87 67 165 287 33 15 190 68 131 137 235 249 107 214 99 255 205 228 256 63 90 85 206 285 118 191 34 280 40 270 66 253 182 217 225 184 78 5 54 219 86 64 247 246 35 229 14 224 218 228 102 119 3 139 96 129 276 56 80 165 233 89 227 45 157 274 295 200 295 92 108 217 17 296 203 14 133 106 3 193 40 116 122 266 236 7 268 43 242 151 39 113 204 125 238 22 92 30 242 205 282 200 50 36 195 163 127 153 45 49 87 121 109 75 278 125 147 209 166 91 51 56 188 53 8 180 148 158 240 45 103 31 208 55 185 135 266 182 63 281 97 132 194 197 78 250 110 132 140 253 290 105 275 298 118 37 90 193 94 60 209 112 47 263 110 78 196 166 145 294 43 134 263 264 22 283 12 255 151 284 169 117 279 128 65 250 164 76 227 99 101 261 141 11 252 233 143 171 32 103 85 152 42 31 245 123 24 198 135 212 238 76 36 286 275 53 62 124 235 4 51 2 244 66 162 70 291 17 105 91 88 224 27 116 276 210 24 252 79 199 84 186 292 128 11 7 177 230 17 242 259 226 187 295 146 52 5 262 107 160 155 168 60 18 221 55 131 191 179 37 252 25 255 97 41 82 271 169 271 223 215 11 61 121 18 262 53 216 68 23 249 161 158 86 101 16 85 98 98 44 100 13 167 57 100 258 223 269 254 148 266 128 119 194 251 22 38 56 43 275 ^'}}, - {OUT=>'70CA84D827F7FD61446233F88CF2F990B0F3E2AA'}], - ['217', {IN=> {f=> '642 0 91 26 53 13 78 80 53 42 11 134 24 44 191 123 87 261 175 143 140 99 45 16 54 161 42 276 132 174 82 276 65 199 120 17 180 92 210 151 195 290 72 63 219 231 116 158 1 222 272 170 187 264 209 90 237 162 226 167 182 43 72 92 152 285 87 254 275 211 241 293 77 284 55 229 201 35 140 135 179 2 18 63 284 298 62 93 300 42 283 201 64 73 189 244 4 292 52 253 120 46 113 146 181 247 74 279 41 186 203 251 263 90 266 95 186 138 184 223 61 61 68 175 107 6 207 81 114 207 139 74 14 175 172 73 153 110 112 27 150 11 98 285 152 20 221 146 239 113 88 14 139 38 181 189 208 265 5 88 50 273 24 51 91 55 287 67 49 176 233 31 281 257 8 64 37 55 258 134 89 111 231 58 292 288 186 174 17 209 25 170 216 197 169 61 32 41 215 136 4 234 92 145 84 155 54 168 243 208 200 239 48 21 68 204 40 60 178 177 87 196 108 197 205 195 18 5 23 284 26 296 147 64 44 256 190 33 196 79 264 151 130 223 126 34 14 204 105 127 218 112 292 16 119 228 82 4 299 159 185 19 153 81 179 274 85 9 219 296 183 104 30 126 92 181 218 141 225 70 90 230 262 294 268 75 75 39 300 13 49 147 300 278 216 255 35 75 68 233 67 114 243 273 267 185 77 19 95 215 71 238 288 157 241 57 144 23 291 227 228 46 171 12 289 283 172 131 19 124 148 125 2 83 36 230 26 60 214 10 73 160 10 44 227 257 280 131 77 291 162 161 100 142 14 168 272 141 254 3 144 295 57 173 257 44 198 23 19 160 282 111 173 192 278 252 88 21 39 271 80 89 176 298 98 227 286 213 185 48 86 135 150 69 58 299 188 118 73 124 177 58 263 54 132 109 15 29 36 201 93 6 149 215 100 171 41 222 36 237 133 293 113 117 248 193 9 183 162 197 234 128 279 70 119 163 15 265 270 255 64 8 122 204 69 294 232 242 89 169 97 166 27 85 38 152 256 154 200 210 115 61 3 108 161 71 209 54 103 176 262 265 34 21 10 37 26 24 80 24 109 258 69 22 165 202 154 171 277 155 297 1 229 172 102 86 70 83 29 29 67 107 42 40 67 78 109 287 2 76 230 298 33 160 246 278 281 21 75 104 66 260 78 145 120 289 247 38 145 55 222 103 241 28 211 270 226 131 48 57 202 190 4 263 25 199 149 251 234 157 212 30 184 259 195 254 239 77 48 28 269 136 33 167 146 210 180 128 43 137 65 192 220 85 281 286 242 118 102 57 137 123 58 27 121 78 138 220 56 47 232 177 22 129 68 168 74 7 275 240 174 46 142 79 235 218 170 158 30 155 25 235 283 237 198 59 59 52 246 13 20 214 39 6 214 282 46 106 246 249 47 268 10 8 93 271 15 22 136 269 100 200 275 42 ^'}}, - {OUT=>'8D500C9CFDE0288530A2106B70BED39326C52C3C'}], - ['218', {IN=> {f=> '644 0 6 29 104 280 81 240 230 212 156 114 31 69 146 96 66 27 63 134 52 68 244 186 88 139 162 111 53 81 64 162 287 30 6 190 59 128 131 235 246 101 211 93 249 205 222 250 57 87 76 206 285 115 185 25 274 34 264 66 253 176 211 219 181 69 5 51 216 77 58 241 243 32 223 11 224 215 225 102 113 3 136 93 123 273 56 74 165 230 86 224 39 157 268 289 197 295 83 105 217 14 293 203 5 127 103 193 37 116 122 260 236 7 268 37 242 145 33 110 201 125 238 13 89 293 27 239 202 279 194 50 27 189 157 127 153 45 43 78 121 106 69 272 119 141 203 166 82 42 50 188 53 5 177 148 152 234 42 100 22 205 46 182 132 263 179 63 275 97 129 194 191 72 250 107 132 137 247 290 99 296 272 295 118 37 81 190 94 60 206 109 47 260 110 75 193 163 139 288 43 128 257 258 19 277 12 252 148 278 166 117 276 125 62 247 164 76 221 96 101 261 138 8 246 227 143 168 32 97 79 149 39 31 245 123 21 192 135 206 235 70 33 286 269 50 62 121 232 1 45 295 244 60 156 64 288 8 105 91 82 218 27 113 270 204 18 249 79 199 84 183 286 128 5 1 171 227 17 236 259 223 187 292 140 49 301 256 104 154 149 165 54 18 299 215 49 125 188 179 28 252 22 255 91 32 82 268 163 265 220 209 2 58 115 9 259 47 210 65 14 243 158 155 86 98 16 82 92 95 38 94 10 161 48 97 255 217 266 248 142 266 122 119 191 248 16 32 47 34 88 89 26 50 12 76 80 51 40 9 133 24 44 191 122 84 259 173 142 140 99 44 15 54 159 42 276 301 130 172 79 275 62 197 119 15 180 91 208 150 193 289 71 61 219 231 114 157 1 221 272 169 186 264 207 87 237 161 224 165 180 41 72 89 152 284 87 252 274 210 241 293 77 284 52 229 199 34 138 134 178 17 60 282 298 61 93 299 39 283 200 62 71 187 242 4 290 49 251 120 43 113 144 181 245 73 278 40 185 201 251 261 88 265 94 186 138 184 223 61 58 65 175 107 6 205 81 114 207 137 71 11 174 170 73 152 108 110 25 148 11 98 283 150 17 221 146 237 111 88 13 139 36 179 189 207 263 3 86 48 273 21 51 90 54 285 65 49 175 233 29 280 257 6 64 36 53 257 132 87 111 229 58 291 288 184 173 16 208 24 170 214 197 169 60 30 41 213 134 2 234 92 145 83 155 51 166 243 208 200 238 48 21 66 203 40 59 178 176 85 196 106 195 204 194 15 4 23 283 24 296 146 61 43 254 189 31 195 78 262 151 130 222 124 34 12 202 103 126 216 112 292 14 117 226 80 1 297 159 183 19 151 80 177 274 84 7 218 294 181 104 28 126 90 180 217 140 225 67 90 230 262 292 266 72 74 39 298 11 48 147 300 278 216 253 265 ^'}}, - {OUT=>'F3D4D139EDFC24596377BC97A96FB7621F27FFC7'}], - ['219', {IN=> {f=> '638 1 75 65 227 58 108 240 267 267 185 71 13 95 212 71 235 285 154 238 48 144 14 288 221 228 43 165 6 283 280 172 125 16 121 145 122 297 74 36 227 17 51 211 4 64 157 1 38 224 254 280 131 68 291 162 161 94 142 14 165 269 141 251 298 141 292 51 170 251 35 198 17 10 154 279 105 173 192 272 249 79 18 36 268 74 80 170 292 92 227 280 213 182 45 80 129 150 63 49 296 185 112 70 124 171 55 263 51 129 109 6 20 33 201 84 149 215 97 168 32 216 27 234 133 287 110 114 248 190 9 183 156 194 228 125 279 64 116 163 9 265 270 252 61 8 116 204 66 294 229 236 89 163 91 160 24 85 29 149 256 154 197 210 115 55 108 158 68 209 48 103 176 259 262 25 15 10 31 23 18 77 21 103 258 69 16 162 202 151 171 277 149 297 296 226 169 99 83 70 83 29 26 67 101 39 31 64 75 106 284 2 67 224 295 33 160 246 275 275 12 69 98 57 260 69 139 114 289 247 38 142 55 222 298 100 235 22 211 267 226 128 42 54 196 184 1 260 25 196 143 248 231 151 212 30 178 256 195 254 239 74 39 28 263 133 24 167 143 207 174 122 34 131 65 186 220 79 281 283 239 115 96 57 137 117 52 18 118 78 132 217 53 44 232 177 22 129 68 168 295 74 302 275 234 174 40 139 73 232 218 164 158 27 152 19 229 277 231 192 50 59 52 240 4 20 214 30 301 208 282 46 106 243 249 38 265 7 5 90 271 15 13 136 269 100 194 269 182 4 23 100 276 79 240 226 210 156 112 29 67 142 96 60 23 59 134 50 62 242 182 86 137 158 109 47 77 62 160 287 28 190 53 126 127 235 244 97 209 89 245 205 218 246 53 85 70 206 285 113 181 19 270 30 260 66 253 172 207 215 179 63 5 49 214 71 54 237 241 30 219 9 224 213 223 102 109 3 134 91 119 271 56 70 165 228 84 222 35 157 264 285 195 295 77 103 217 12 291 203 303 123 101 302 193 35 116 122 256 236 7 268 33 242 141 29 108 199 125 238 7 87 289 25 237 200 277 190 50 21 185 153 127 153 45 39 72 121 104 65 268 115 137 199 166 76 36 46 188 53 3 175 148 148 230 40 98 16 203 40 180 130 261 177 63 271 97 127 194 187 68 250 105 132 135 243 290 95 294 270 293 118 37 75 188 94 60 204 107 47 258 110 73 191 161 135 284 43 124 253 254 17 273 12 250 146 274 164 117 274 123 60 245 164 76 217 94 101 261 136 6 242 223 143 166 32 93 75 147 37 31 245 123 19 188 135 202 233 66 31 286 265 48 62 119 230 303 41 291 244 56 152 60 286 2 105 91 78 214 27 111 266 200 14 247 79 199 84 181 282 128 1 301 167 225 17 232 259 221 187 290 136 47 299 252 102 150 145 163 157 ^'}}, - {OUT=>'5509BAFFAC6D507860CEFC5AB5832CB63CD4B687'}], - ['220', {IN=> {f=> '653 0 18 299 207 41 117 184 179 16 252 18 255 83 20 82 264 155 257 216 201 296 54 107 303 255 39 202 61 2 235 154 151 86 94 16 78 84 91 30 86 6 153 36 93 251 209 262 240 134 266 114 119 187 244 8 24 35 22 76 81 26 38 8 68 80 43 32 1 129 24 44 191 118 72 251 165 138 140 99 40 11 54 151 42 276 301 122 164 67 271 50 189 115 7 180 87 200 146 185 285 67 53 219 231 106 153 1 217 272 165 182 264 199 75 237 157 216 157 172 33 72 77 152 280 87 244 270 206 241 293 77 284 40 229 191 30 130 130 174 298 13 48 274 298 57 93 295 27 283 196 54 63 179 234 4 282 37 243 120 31 113 136 181 237 69 274 36 181 193 251 253 80 261 90 186 138 184 223 61 46 53 175 107 6 197 81 114 207 129 59 305 170 162 73 148 100 102 17 140 11 98 275 142 5 221 146 229 103 88 9 139 28 171 189 203 255 301 78 40 273 9 51 86 50 277 57 49 171 233 21 276 257 304 64 32 45 253 124 79 111 221 58 287 288 176 169 12 204 20 170 206 197 169 56 22 41 205 126 300 234 92 145 79 155 39 158 243 208 200 234 48 21 58 199 40 55 178 172 77 196 98 187 200 190 3 23 279 16 296 142 49 39 246 185 23 191 74 254 151 130 218 116 34 4 194 95 122 208 112 292 6 109 218 72 295 289 159 175 19 143 76 169 274 80 305 214 286 173 104 20 126 82 176 213 136 225 55 90 230 262 284 258 60 70 39 290 3 44 147 300 278 216 245 35 75 63 223 52 104 238 263 267 185 67 9 95 210 71 233 283 152 236 42 144 8 286 217 228 41 161 2 279 278 172 121 14 119 143 120 293 68 36 225 11 45 209 58 155 301 34 222 252 280 131 62 291 162 161 90 142 14 163 267 141 249 294 139 290 47 168 247 29 198 13 4 150 277 101 173 192 268 247 73 16 34 266 70 74 166 288 88 227 276 213 180 43 76 125 150 59 43 294 183 108 68 124 167 53 263 49 127 109 14 31 201 78 302 149 215 95 166 26 212 21 232 133 283 108 112 248 188 9 183 152 192 224 123 279 60 114 163 5 265 270 250 59 8 112 204 64 294 227 232 89 159 87 156 22 85 23 147 256 154 195 210 115 51 304 108 156 66 209 44 103 176 257 260 19 11 10 27 21 14 75 19 99 258 69 12 160 202 149 171 277 145 297 292 224 167 97 81 70 83 29 24 67 97 37 25 62 73 104 282 2 61 220 293 33 160 246 273 271 6 65 94 51 260 63 135 110 289 247 38 140 55 222 296 98 231 18 211 265 226 126 38 52 192 180 305 258 25 194 139 246 229 147 212 30 174 254 195 254 239 72 33 28 259 131 18 167 141 205 170 118 28 127 65 182 220 75 281 281 237 113 92 57 137 113 48 12 116 78 128 215 51 42 232 177 22 129 68 168 291 161 ^'}}, - {OUT=>'0C0AEA0C2FD7A620C77866B1A177481E26B4F592'}], - ['221', {IN=> {f=> '653 0 296 275 228 174 34 136 67 229 218 158 158 24 149 13 223 271 225 186 41 59 52 234 302 20 214 21 295 202 282 46 106 240 249 29 262 4 2 87 271 15 4 136 269 100 188 263 182 1 14 94 270 76 240 220 207 156 109 26 64 136 96 51 17 53 134 47 53 239 176 83 134 152 106 38 71 59 157 287 25 298 190 44 123 121 235 241 91 206 83 239 205 212 240 47 82 61 206 285 110 175 10 264 24 254 66 253 166 201 209 176 54 5 46 211 62 48 231 238 27 213 6 224 210 220 102 103 3 131 88 113 268 56 64 165 225 81 219 29 157 258 279 192 295 68 100 217 9 288 203 297 117 98 302 193 32 116 122 250 236 7 268 27 242 135 23 105 196 125 238 305 84 283 22 234 197 274 184 50 12 179 147 127 153 45 33 63 121 101 59 262 109 131 193 166 67 27 40 188 53 172 148 142 224 37 95 7 200 31 177 127 258 174 63 265 97 124 194 181 62 250 102 132 132 237 290 89 291 267 290 118 37 66 185 94 60 201 104 47 255 110 70 188 158 129 278 43 118 247 248 14 267 12 247 143 268 161 117 271 120 57 242 164 76 211 91 101 261 133 3 236 217 143 163 32 87 69 144 34 31 245 123 16 182 135 196 230 60 28 286 259 45 62 116 227 303 35 285 244 50 146 54 283 300 105 91 72 208 27 108 260 194 8 244 79 199 84 178 276 128 302 298 161 222 17 226 259 218 187 287 130 44 296 246 99 144 139 160 44 18 299 205 39 115 183 179 13 252 17 255 81 17 82 263 153 255 215 199 294 53 105 301 254 37 200 60 306 233 153 150 86 93 16 77 82 90 28 84 5 151 33 92 250 207 261 238 132 266 112 119 186 243 6 22 32 19 73 79 26 35 7 66 80 41 30 306 128 24 44 191 117 69 249 163 137 140 99 39 10 54 149 42 276 301 120 162 64 270 47 187 114 5 180 86 198 145 183 284 66 51 219 231 104 152 1 216 272 164 181 264 197 72 237 156 214 155 170 31 72 74 152 279 87 242 269 205 241 293 77 284 37 229 189 29 128 129 173 297 12 45 272 298 56 93 294 24 283 195 52 61 177 232 4 280 34 241 120 28 113 134 181 235 68 273 35 180 191 251 251 78 260 89 186 138 184 223 61 43 50 175 107 6 195 81 114 207 127 56 303 169 160 73 147 98 100 15 138 11 98 273 140 2 221 146 227 101 88 8 139 26 169 189 202 253 300 76 38 273 6 51 85 49 275 55 49 170 233 19 275 257 303 64 31 43 252 122 77 111 219 58 286 288 174 168 11 203 19 170 204 197 169 55 20 41 203 124 299 234 92 145 78 155 36 156 243 208 200 233 48 21 56 198 40 54 178 171 75 196 96 185 199 189 306 23 278 14 296 141 46 38 244 184 21 190 73 252 151 130 217 114 34 2 192 93 121 206 112 292 4 107 216 70 293 112 ^'}}, - {OUT=>'149176007FEE58A591E3F00F8DB658B605F8390C'}], - ['222', {IN=> {f=> '646 1 159 169 19 137 73 163 274 77 302 211 280 167 104 14 126 76 173 210 133 225 46 90 230 262 278 252 51 67 39 284 306 41 147 300 278 216 239 35 75 60 217 43 98 235 257 267 185 61 3 95 207 71 230 280 149 233 33 144 308 283 211 228 38 155 305 273 275 172 115 11 116 140 117 287 59 36 222 2 36 206 303 49 152 295 28 219 249 280 131 53 291 162 161 84 142 14 160 264 141 246 288 136 287 41 165 241 20 198 7 304 144 274 95 173 192 262 244 64 13 31 263 64 65 160 282 82 227 270 213 177 40 70 119 150 53 34 291 180 102 65 124 161 50 263 46 124 109 300 5 28 201 69 299 149 215 92 163 17 206 12 229 133 277 105 109 248 185 9 183 146 189 218 120 279 54 111 163 308 265 270 247 56 8 106 204 61 294 224 226 89 153 81 150 19 85 14 144 256 154 192 210 115 45 304 108 153 63 209 38 103 176 254 257 10 5 10 21 18 8 72 16 93 258 69 6 157 202 146 171 277 139 297 286 221 164 94 78 70 83 29 21 67 91 34 16 59 70 101 279 2 52 214 290 33 160 246 270 265 306 59 88 42 260 54 129 104 289 247 38 137 55 222 293 95 225 12 211 262 226 123 32 49 186 174 305 255 25 191 133 243 226 141 212 30 168 251 195 254 239 69 24 28 253 128 9 167 138 202 164 112 19 121 65 176 220 69 281 278 234 110 86 57 137 107 42 3 113 78 122 212 48 39 232 177 22 129 68 168 285 74 292 275 224 174 30 134 63 227 218 154 158 22 147 9 219 267 221 182 35 59 52 230 298 20 214 15 291 198 282 46 106 238 249 23 260 2 85 271 15 307 136 269 100 184 259 182 308 8 90 266 74 240 216 205 156 107 24 62 132 96 45 13 49 134 45 47 237 172 81 132 148 104 32 67 57 155 287 23 294 190 38 121 117 235 239 87 204 79 235 205 208 236 43 80 55 206 285 108 171 4 260 20 250 66 253 162 197 205 174 48 5 44 209 56 44 227 236 25 209 4 224 208 218 102 99 3 129 86 109 266 56 60 165 223 79 217 25 157 254 275 190 295 62 98 217 7 286 203 293 113 96 302 193 30 116 122 246 236 7 268 23 242 131 19 103 194 125 238 301 82 279 20 232 195 272 180 50 6 175 143 127 153 45 29 57 121 99 55 258 105 127 189 166 61 21 36 188 53 307 170 148 138 220 35 93 1 198 25 175 125 256 172 63 261 97 122 194 177 58 250 100 132 130 233 290 85 289 265 288 118 37 60 183 94 60 199 102 47 253 110 68 186 156 125 274 43 114 243 244 12 263 12 245 141 264 159 117 269 118 55 240 164 76 207 89 101 261 131 1 232 213 143 161 32 83 65 142 32 31 245 123 14 178 135 192 228 56 26 286 255 43 62 114 225 303 31 281 244 46 142 50 281 296 105 91 238 ^'}}, - {OUT=>'17C0D7B0256159F3626786FFDB20237AE154FA84'}], - ['223', {IN=> {f=> '647 0 200 27 104 252 186 240 79 199 84 174 268 128 298 294 153 218 17 218 259 214 187 283 122 40 292 238 95 136 131 156 36 18 299 197 31 107 179 179 1 252 13 255 73 5 82 259 145 247 211 191 286 49 97 293 250 29 192 56 298 225 149 146 86 89 16 73 74 86 20 76 1 143 21 88 246 199 257 230 124 266 104 119 182 239 309 14 20 7 61 71 26 23 3 58 80 33 22 302 124 24 44 191 113 57 241 155 133 140 99 35 6 54 141 42 276 301 112 154 52 266 35 179 110 308 180 82 190 141 175 280 62 43 219 231 96 148 1 212 272 160 177 264 189 60 237 152 206 147 162 23 72 62 152 275 87 234 265 201 241 293 77 284 25 229 181 25 120 125 169 293 8 33 264 298 52 93 290 12 283 191 44 53 169 224 4 272 22 233 120 16 113 126 181 227 64 269 31 176 183 251 243 70 256 85 186 138 184 223 61 31 38 175 107 6 187 81 114 207 119 44 295 165 152 73 143 90 92 7 130 11 98 265 132 301 221 146 219 93 88 4 139 18 161 189 198 245 296 68 30 273 305 51 81 45 267 47 49 166 233 11 271 257 299 64 27 35 248 114 69 111 211 58 282 288 166 164 7 199 15 170 196 197 169 51 12 41 195 116 295 234 92 145 74 155 24 148 243 208 200 229 48 21 48 194 40 50 178 167 67 196 88 177 195 185 299 306 23 274 6 296 137 34 34 236 180 13 186 69 244 151 130 213 106 34 305 184 85 117 198 112 292 307 99 208 62 285 279 159 165 19 133 71 159 274 75 300 209 276 163 104 10 126 72 171 208 131 225 40 90 230 262 274 248 45 65 39 280 304 39 147 300 278 216 235 35 75 58 213 37 94 233 253 267 185 57 310 95 205 71 228 278 147 231 27 144 304 281 207 228 36 151 303 269 273 172 111 9 114 138 115 283 53 36 220 307 30 204 301 43 150 291 24 217 247 280 131 47 291 162 161 80 142 14 158 262 141 244 284 134 285 37 163 237 14 198 3 300 140 272 91 173 192 258 242 58 11 29 261 60 59 156 278 78 227 266 213 175 38 66 115 150 49 28 289 178 98 63 124 157 48 263 44 122 109 296 310 26 201 63 297 149 215 90 161 11 202 6 227 133 273 103 107 248 183 9 183 142 187 214 118 279 50 109 163 306 265 270 245 54 8 102 204 59 294 222 222 89 149 77 146 17 85 8 142 256 154 190 210 115 41 304 108 151 61 209 34 103 176 252 255 4 1 10 17 16 4 70 14 89 258 69 2 155 202 144 171 277 135 297 282 219 162 92 76 70 83 29 19 67 87 32 10 57 68 99 277 2 46 210 288 33 160 246 268 261 302 55 84 36 260 48 125 100 289 247 38 135 55 222 291 93 221 8 211 260 226 121 28 47 182 170 305 253 25 189 129 241 224 137 212 30 164 249 195 254 239 86 ^'}}, - {OUT=>'741A58618ABEB1D983D67AFDCBC49AA397A3B8E0'}], - ['224', {IN=> {f=> '665 0 15 28 247 125 167 135 199 158 106 10 115 65 170 220 63 281 275 231 107 80 57 137 101 36 306 110 78 116 209 45 36 232 177 22 129 68 168 279 74 286 275 218 174 24 131 57 224 218 148 158 19 144 3 213 261 215 176 26 59 52 224 292 20 214 6 285 192 282 46 106 235 249 14 257 311 309 82 271 15 301 136 269 100 178 253 182 308 311 84 260 71 240 210 202 156 104 21 59 126 96 36 7 43 134 42 38 234 166 78 129 142 101 23 61 54 152 287 20 288 190 29 118 111 235 236 81 201 73 229 205 202 230 37 77 46 206 285 105 165 307 254 14 244 66 253 156 191 199 171 39 5 41 206 47 38 221 233 22 203 1 224 205 215 102 93 3 126 83 103 263 56 54 165 220 76 214 19 157 248 269 187 295 53 95 217 4 283 203 287 107 93 302 193 27 116 122 240 236 7 268 17 242 125 13 100 191 125 238 295 79 273 17 229 192 269 174 50 309 169 137 127 153 45 23 48 121 96 49 252 99 121 183 166 52 12 30 188 53 307 167 148 132 214 32 90 304 195 16 172 122 253 169 63 255 97 119 194 171 52 250 97 132 127 227 290 79 286 262 285 118 37 51 180 94 60 196 99 47 250 110 65 183 153 119 268 43 108 237 238 9 257 12 242 138 258 156 117 266 115 52 237 164 76 201 86 101 261 128 310 226 207 143 158 32 77 59 139 29 31 245 123 11 172 135 186 225 50 23 286 249 40 62 111 222 303 25 275 244 40 136 44 278 290 105 91 62 198 27 103 250 184 310 239 79 199 84 173 266 128 297 293 151 217 17 216 259 213 187 282 120 39 291 236 94 134 129 155 34 18 299 195 29 105 178 179 310 252 12 255 71 2 82 258 143 245 210 189 284 48 95 291 249 27 190 55 296 223 148 145 86 88 16 72 72 85 18 74 141 18 87 245 197 256 228 122 266 102 119 181 238 308 12 17 4 58 69 26 20 2 56 80 31 20 301 123 24 44 191 112 54 239 153 132 140 99 34 5 54 139 42 276 301 110 152 49 265 32 177 109 307 180 81 188 140 173 279 61 41 219 231 94 147 1 211 272 159 176 264 187 57 237 151 204 145 160 21 72 59 152 274 87 232 264 200 241 293 77 284 22 229 179 24 118 124 168 292 7 30 262 298 51 93 289 9 283 190 42 51 167 222 4 270 19 231 120 13 113 124 181 225 63 268 30 175 181 251 241 68 255 84 186 138 184 223 61 28 35 175 107 6 185 81 114 207 117 41 293 164 150 73 142 88 90 5 128 11 98 263 130 299 221 146 217 91 88 3 139 16 159 189 197 243 295 66 28 273 303 51 80 44 265 45 49 165 233 9 270 257 298 64 26 33 247 112 67 111 209 58 281 288 164 163 6 198 14 170 194 197 169 50 10 41 193 114 294 234 92 145 73 155 21 146 243 208 200 228 48 21 46 193 40 49 178 166 65 196 86 175 194 184 297 306 23 273 206 ^'}}, - {OUT=>'B738D6B3409EB9ED2F1719B84D13F7C36169CDEC'}], - ['225', {IN=> {f=> '641 0 296 134 25 31 230 177 7 183 66 238 151 130 210 100 34 302 178 79 114 192 112 292 304 93 202 56 279 273 159 159 19 127 68 153 274 72 297 206 270 157 104 4 126 66 168 205 128 225 31 90 230 262 268 242 36 62 39 274 301 36 147 300 278 216 229 35 75 55 207 28 88 230 247 267 185 51 307 95 202 71 225 275 144 228 18 144 298 278 201 228 33 145 300 263 270 172 105 6 111 135 112 277 44 36 217 301 21 201 298 34 147 285 18 214 244 280 131 38 291 162 161 74 142 14 155 259 141 241 278 131 282 31 160 231 5 198 311 294 134 269 85 173 192 252 239 49 8 26 258 54 50 150 272 72 227 260 213 172 35 60 109 150 43 19 286 175 92 60 124 151 45 263 41 119 109 290 304 23 201 54 294 149 215 87 158 2 196 311 224 133 267 100 104 248 180 9 183 136 184 208 115 279 44 106 163 303 265 270 242 51 8 96 204 56 294 219 216 89 143 71 140 14 85 313 139 256 154 187 210 115 35 304 108 148 58 209 28 103 176 249 252 309 309 10 11 13 312 67 11 83 258 69 310 152 202 141 171 277 129 297 276 216 159 89 73 70 83 29 16 67 81 29 1 54 65 96 274 2 37 204 285 33 160 246 265 255 296 49 78 27 260 39 119 94 289 247 38 132 55 222 288 90 215 2 211 257 226 118 22 44 176 164 305 250 25 186 123 238 221 131 212 30 158 246 195 254 239 64 9 28 243 123 308 167 133 197 154 102 4 111 65 166 220 59 281 273 229 105 76 57 137 97 32 302 108 78 112 207 43 34 232 177 22 129 68 168 275 74 282 275 214 174 20 129 53 222 218 144 158 17 142 313 209 257 211 172 20 59 52 220 288 20 214 281 188 282 46 106 233 249 8 255 311 309 80 271 15 297 136 269 100 174 249 182 308 307 80 256 69 240 206 200 156 102 19 57 122 96 30 3 39 134 40 32 232 162 76 127 138 99 17 57 52 150 287 18 284 190 23 116 107 235 234 77 199 69 225 205 198 226 33 75 40 206 285 103 161 303 250 10 240 66 253 152 187 195 169 33 5 39 204 41 34 217 231 20 199 313 224 203 213 102 89 3 124 81 99 261 56 50 165 218 74 212 15 157 244 265 185 295 47 93 217 2 281 203 283 103 91 302 193 25 116 122 236 236 7 268 13 242 121 9 98 189 125 238 291 77 269 15 227 190 267 170 50 305 165 133 127 153 45 19 42 121 94 45 248 95 117 179 166 46 6 26 188 53 307 165 148 128 210 30 88 300 193 10 170 120 251 167 63 251 97 117 194 167 48 250 95 132 125 223 290 75 284 260 283 118 37 45 178 94 60 194 97 47 248 110 63 181 151 115 264 43 104 233 234 7 253 12 240 136 254 154 117 264 113 50 235 164 76 197 84 101 261 126 310 222 203 143 276 ^'}}, - {OUT=>'3D33DE31F64055D3B128AC9A6AA3F92DFD4F5330'}], - ['226', {IN=> {f=> '656 0 32 69 51 135 25 31 245 123 7 164 135 178 221 42 19 286 241 36 62 107 218 303 17 267 244 32 128 36 274 282 105 91 54 190 27 99 242 176 306 235 79 199 84 169 258 128 293 289 143 213 17 208 259 209 187 278 112 35 287 228 90 126 121 151 26 18 299 187 21 97 174 179 302 252 8 255 63 306 82 254 135 237 206 181 276 44 87 283 245 19 182 51 288 215 144 141 86 84 16 68 64 81 10 66 312 133 6 83 241 189 252 220 114 266 94 119 177 234 304 4 5 308 46 61 26 8 314 48 80 23 12 297 119 24 44 191 108 42 231 145 128 140 99 30 1 54 131 42 276 301 102 144 37 261 20 169 105 303 180 77 180 136 165 275 57 33 219 231 86 143 1 207 272 155 172 264 179 45 237 147 196 137 152 13 72 47 152 270 87 224 260 196 241 293 77 284 10 229 171 20 110 120 164 288 3 18 254 298 47 93 285 313 283 186 34 43 159 214 4 262 7 223 120 1 113 116 181 217 59 264 26 171 173 251 233 60 251 80 186 138 184 223 61 16 23 175 107 6 177 81 114 207 109 29 285 160 142 73 138 80 82 313 120 11 98 255 122 291 221 146 209 83 88 315 139 8 151 189 193 235 291 58 20 273 295 51 76 40 257 37 49 161 233 1 266 257 294 64 22 25 243 104 59 111 201 58 277 288 156 159 2 194 10 170 186 197 169 46 2 41 185 106 290 234 92 145 69 155 9 138 243 208 200 224 48 21 38 189 40 45 178 162 57 196 78 167 190 180 289 306 23 269 312 296 132 19 29 226 175 3 181 64 234 151 130 208 96 34 300 174 75 112 188 112 292 302 89 198 52 275 269 159 155 19 123 66 149 274 70 295 204 266 153 104 126 62 166 203 126 225 25 90 230 262 264 238 30 60 39 270 299 34 147 300 278 216 225 35 75 53 203 22 84 228 243 267 185 47 305 95 200 71 223 273 142 226 12 144 294 276 197 228 31 141 298 259 268 172 101 4 109 133 110 273 38 36 215 297 15 199 296 28 145 281 14 212 242 280 131 32 291 162 161 70 142 14 153 257 141 239 274 129 280 27 158 227 315 198 309 290 130 267 81 173 192 248 237 43 6 24 256 50 44 146 268 68 227 256 213 170 33 56 105 150 39 13 284 173 88 58 124 147 43 263 39 117 109 286 300 21 201 48 292 149 215 85 156 312 192 307 222 133 263 98 102 248 178 9 183 132 182 204 113 279 40 104 163 301 265 270 240 49 8 92 204 54 294 217 212 89 139 67 136 12 85 309 137 256 154 185 210 115 31 304 108 146 56 209 24 103 176 247 250 305 307 10 7 11 310 65 9 79 258 69 308 150 202 139 171 277 125 297 272 214 157 87 71 70 83 29 14 67 77 27 311 52 63 94 272 2 31 200 283 33 160 246 263 251 292 45 74 21 260 33 115 90 289 247 38 130 55 222 286 88 211 227 ^'}}, - {OUT=>'B6925F4DF94949B8844C867428BA3DEDF4CF2B51'}], - ['227', {IN=> {f=> '668 0 211 254 226 115 16 41 170 158 305 247 25 183 117 235 218 125 212 30 152 243 195 254 239 61 28 237 120 302 167 130 194 148 96 312 105 65 160 220 53 281 270 226 102 70 57 137 91 26 296 105 78 106 204 40 31 232 177 22 129 68 168 269 74 276 275 208 174 14 126 47 219 218 138 158 14 139 310 203 251 205 166 11 59 52 214 282 20 214 308 275 182 282 46 106 230 249 316 252 311 309 77 271 15 291 136 269 100 168 243 182 308 301 74 250 66 240 200 197 156 99 16 54 116 96 21 314 33 134 37 23 229 156 73 124 132 96 8 51 49 147 287 15 278 190 14 113 101 235 231 71 196 63 219 205 192 220 27 72 31 206 285 100 155 297 244 4 234 66 253 146 181 189 166 24 5 36 201 32 28 211 228 17 193 313 224 200 210 102 83 3 121 78 93 258 56 44 165 215 71 209 9 157 238 259 182 295 38 90 217 316 278 203 277 97 88 302 193 22 116 122 230 236 7 268 7 242 115 3 95 186 125 238 285 74 263 12 224 187 264 164 50 299 159 127 127 153 45 13 33 121 91 39 242 89 111 173 166 37 314 20 188 53 307 162 148 122 204 27 85 294 190 1 167 117 248 164 63 245 97 114 194 161 42 250 92 132 122 217 290 69 281 257 280 118 37 36 175 94 60 191 94 47 245 110 60 178 148 109 258 43 98 227 228 4 247 12 237 133 248 151 117 261 110 47 232 164 76 191 81 101 261 123 310 216 197 143 153 32 67 49 134 24 31 245 123 6 162 135 176 220 40 18 286 239 35 62 106 217 303 15 265 244 30 126 34 273 280 105 91 52 188 27 98 240 174 305 234 79 199 84 168 256 128 292 288 141 212 17 206 259 208 187 277 110 34 286 226 89 124 119 150 24 18 299 185 19 95 173 179 300 252 7 255 61 304 82 253 133 235 205 179 274 43 85 281 244 17 180 50 286 213 143 140 86 83 16 67 62 80 8 64 312 131 3 82 240 187 251 218 112 266 92 119 176 233 303 2 2 306 43 59 26 5 314 46 80 21 10 296 118 24 44 191 107 39 229 143 127 140 99 29 54 129 42 276 301 100 142 34 260 17 167 104 302 180 76 178 135 163 274 56 31 219 231 84 142 1 206 272 154 171 264 177 42 237 146 194 135 150 11 72 44 152 269 87 222 259 195 241 293 77 284 7 229 169 19 108 119 163 287 2 15 252 298 46 93 284 311 283 185 32 41 157 212 4 260 4 221 120 315 113 114 181 215 58 263 25 170 171 251 231 58 250 79 186 138 184 223 61 13 20 175 107 6 175 81 114 207 107 26 283 159 140 73 137 78 80 312 118 11 98 253 120 289 221 146 207 81 88 315 139 6 149 189 192 233 290 56 18 273 293 51 75 39 255 35 49 160 233 316 265 257 293 64 21 23 242 102 57 111 199 58 276 288 154 158 1 193 9 170 184 197 169 45 41 183 104 289 234 92 145 68 155 6 136 243 208 203 ^'}}, - {OUT=>'CF5E7256292ABEC431D8E8B9CBEAF22AF072377E'}], - ['228', {IN=> {f=> '656 0 221 48 21 32 186 40 42 178 159 51 196 72 161 187 177 283 306 23 266 309 296 129 10 26 220 172 316 178 61 228 151 130 205 90 34 297 168 69 109 182 112 292 299 83 192 46 269 263 159 149 19 117 63 143 274 67 292 201 260 147 104 313 126 56 163 200 123 225 16 90 230 262 258 232 21 57 39 264 296 31 147 300 278 216 219 35 75 50 197 13 78 225 237 267 185 41 302 95 197 71 220 270 139 223 3 144 288 273 191 228 28 135 295 253 265 172 95 1 106 130 107 267 29 36 212 291 6 196 293 19 142 275 8 209 239 280 131 23 291 162 161 64 142 14 150 254 141 236 268 126 277 21 155 221 309 198 306 284 124 264 75 173 192 242 234 34 3 21 253 44 35 140 262 62 227 250 213 167 30 50 99 150 33 4 281 170 82 55 124 141 40 263 36 114 109 280 294 18 201 39 289 149 215 82 153 306 186 301 219 133 257 95 99 248 175 9 183 126 179 198 110 279 34 101 163 298 265 270 237 46 8 86 204 51 294 214 206 89 133 61 130 9 85 303 134 256 154 182 210 115 25 304 108 143 53 209 18 103 176 244 247 299 304 10 1 8 307 62 6 73 258 69 305 147 202 136 171 277 119 297 266 211 154 84 68 70 83 29 11 67 71 24 305 49 60 91 269 2 22 194 280 33 160 246 260 245 286 39 68 12 260 24 109 84 289 247 38 127 55 222 283 85 205 311 211 252 226 113 12 39 166 154 305 245 25 181 113 233 216 121 212 30 148 241 195 254 239 59 313 28 233 118 298 167 128 192 144 92 308 101 65 156 220 49 281 268 224 100 66 57 137 87 22 292 103 78 102 202 38 29 232 177 22 129 68 168 265 74 272 275 204 174 10 124 43 217 218 134 158 12 137 308 199 247 201 162 5 59 52 210 278 20 214 304 271 178 282 46 106 228 249 312 250 311 309 75 271 15 287 136 269 100 164 239 182 308 297 70 246 64 240 196 195 156 97 14 52 112 96 15 312 29 134 35 17 227 152 71 122 128 94 2 47 47 145 287 13 274 190 8 111 97 235 229 67 194 59 215 205 188 216 23 70 25 206 285 98 151 293 240 230 66 253 142 177 185 164 18 5 34 199 26 24 207 226 15 189 313 224 198 208 102 79 3 119 76 89 256 56 40 165 213 69 207 5 157 234 255 180 295 32 88 217 316 276 203 273 93 86 302 193 20 116 122 226 236 7 268 3 242 111 318 93 184 125 238 281 72 259 10 222 185 262 160 50 295 155 123 127 153 45 9 27 121 89 35 238 85 107 169 166 31 310 16 188 53 307 160 148 118 200 25 83 290 188 314 165 115 246 162 63 241 97 112 194 157 38 250 90 132 120 213 290 65 279 255 278 118 37 30 173 94 60 189 92 47 243 110 58 176 146 105 254 43 94 223 224 2 243 12 235 131 244 149 117 259 108 45 230 164 76 187 79 101 261 109 ^'}}, - {OUT=>'975DCE94902923977F129C0E4ACF40AD28DDB9AA'}], - ['229', {IN=> {f=> '656 0 310 208 189 143 149 32 59 41 130 20 31 245 123 2 154 135 168 216 32 14 286 231 31 62 102 213 303 7 257 244 22 118 26 269 272 105 91 44 180 27 94 232 166 301 230 79 199 84 164 248 128 288 284 133 208 17 198 259 204 187 273 102 30 282 218 85 116 111 146 16 18 299 177 11 87 169 179 292 252 3 255 53 296 82 249 125 227 201 171 266 39 77 273 240 9 172 46 278 205 139 136 86 79 16 63 54 76 56 312 123 312 78 236 179 247 210 104 266 84 119 172 229 299 315 311 298 31 51 26 314 314 38 80 13 2 292 114 24 44 191 103 27 221 135 123 140 99 25 317 54 121 42 276 301 92 134 22 256 5 159 100 298 180 72 170 131 155 270 52 23 219 231 76 138 1 202 272 150 167 264 169 30 237 142 186 127 142 3 72 32 152 265 87 214 255 191 241 293 77 284 316 229 161 15 100 115 159 283 319 3 244 298 42 93 280 303 283 181 24 33 149 204 4 252 313 213 120 307 113 106 181 207 54 259 21 166 163 251 223 50 246 75 186 138 184 223 61 1 8 175 107 6 167 81 114 207 99 14 275 155 132 73 133 70 72 308 110 11 98 245 112 281 221 146 199 73 88 315 139 319 141 189 188 225 286 48 10 273 285 51 71 35 247 27 49 156 233 312 261 257 289 64 17 15 238 94 49 111 191 58 272 288 146 154 318 189 5 170 176 197 169 41 313 41 175 96 285 234 92 145 64 155 315 128 243 208 200 219 48 21 28 184 40 40 178 157 47 196 68 157 185 175 279 306 23 264 307 296 127 4 24 216 170 314 176 59 224 151 130 203 86 34 295 164 65 107 178 112 292 297 79 188 42 265 259 159 145 19 113 61 139 274 65 290 199 256 143 104 311 126 52 161 198 121 225 10 90 230 262 254 228 15 55 39 260 294 29 147 300 278 216 215 35 75 48 193 7 74 223 233 267 185 37 300 95 195 71 218 268 137 221 318 144 284 271 187 228 26 131 293 249 263 172 91 320 104 128 105 263 23 36 210 287 194 291 13 140 271 4 207 237 280 131 17 291 162 161 60 142 14 148 252 141 234 264 124 275 17 153 217 305 198 304 280 120 262 71 173 192 238 232 28 1 19 251 40 29 136 258 58 227 246 213 165 28 46 95 150 29 319 279 168 78 53 124 137 38 263 34 112 109 276 290 16 201 33 287 149 215 80 151 302 182 297 217 133 253 93 97 248 173 9 183 122 177 194 108 279 30 99 163 296 265 270 235 44 8 82 204 49 294 212 202 89 129 57 126 7 85 299 132 256 154 180 210 115 21 304 108 141 51 209 14 103 176 242 245 295 302 10 318 6 305 60 4 69 258 69 303 145 202 134 171 277 115 297 262 209 152 82 66 70 83 29 9 67 67 22 301 47 58 89 267 2 16 190 278 33 160 246 258 241 282 35 64 6 260 18 105 80 289 247 38 125 55 292 ^'}}, - {OUT=>'333B0259B18CE64D6B52CF563DD3041E5F63A516'}], - ); - -sub binary_expand ($$) -{ - my ($test_name, $line) = @_; - my ($n, $b, $rest) = split ' ', $line, 3; - defined $n && defined $b or die "$test_name: too few args\n"; - my @a = split ' ', $rest, $n + 1; - my $caret = pop @a; - $caret eq '^' or die "test $test_name: @a missing '^'\n"; - $b eq '1' || $b eq '0' or die "test $test_name: bad 'b'=$b\n"; - my $n_bad = @a; - @a == $n or - die "test $test_name: wrong number of args (expected $n, found $n_bad)\n"; - my $bit_string = ''; - foreach my $a (@a) - { - $bit_string .= $b x $a; - $b = 1 - $b; - } - my $t = pack ("B*", $bit_string); - # print "$bit_string\n $t\n"; - return $t; -} - -my $t; -foreach $t (@Tests) - { - # Expand each input. - my $in = $t->[1]->{IN}; - $in->{f} = binary_expand $t->[0], $in->{f}; - - # Convert each expected output string to lower case, and append " f\n". - my $h = $t->[2]; - $h->{OUT} = lc $h->{OUT} . " f\n"; - - # Insert the '--text' argument for each test. - splice @$t, 1, 0, '--text'; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'sha1sum'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sha1sum-vec.pl b/tests/misc/sha1sum-vec.pl new file mode 100755 index 000000000..48da107de --- /dev/null +++ b/tests/misc/sha1sum-vec.pl @@ -0,0 +1,534 @@ +#!/usr/bin/perl +# Sample vectors for "sha1sum". + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# The data from which these tests were derived came from here: +# http://csrc.nist.gov/cryptval/shs/sha1-vectors.zip + +my @Tests = + ( + ['1', {IN=> {f=> '0 1 ^'}}, + {OUT=>'DA39A3EE5E6B4B0D3255BFEF95601890AFD80709'}], + ['2', {IN=> {f=> '5 0 2 1 2 1 2 ^'}}, + {OUT=>'3CDF2936DA2FC556BFA533AB1EB59CE710AC80E5'}], + ['3', {IN=> {f=> '5 0 1 3 4 4 4 ^'}}, + {OUT=>'19C1E2048FA7393CFBF2D310AD8209EC11D996E5'}], + ['4', {IN=> {f=> '7 0 4 3 4 4 1 4 4 ^'}}, + {OUT=>'CA775D8C80FAA6F87FA62BECA6CA6089D63B56E5'}], + ['5', {IN=> {f=> '10 0 4 1 5 3 4 4 3 1 3 4 ^'}}, + {OUT=>'71AC973D0E4B50AE9E5043FF4D615381120A25A0'}], + ['6', {IN=> {f=> '10 0 3 1 6 5 5 1 3 6 6 4 ^'}}, + {OUT=>'A6B5B9F854CFB76701C3BDDBF374B3094EA49CBA'}], + ['7', {IN=> {f=> '13 1 3 2 5 3 3 3 4 6 6 1 4 6 2 ^'}}, + {OUT=>'D87A0EE74E4B9AD72E6847C87BDEEB3D07844380'}], + ['8', {IN=> {f=> '16 1 3 5 5 1 2 1 3 3 6 3 5 2 3 5 7 2 ^'}}, + {OUT=>'1976B8DD509FE66BF09C9A8D33534D4EF4F63BFD'}], + ['9', {IN=> {f=> '15 1 8 1 5 3 2 7 4 5 6 7 3 3 1 6 3 ^'}}, + {OUT=>'5A78F439B6DB845BB8A558E4CEB106CD7B7FF783'}], + ['10', {IN=> {f=> '15 1 4 6 8 2 1 4 2 5 1 6 8 8 6 4 7 ^'}}, + {OUT=>'F871BCE62436C1E280357416695EE2EF9B83695C'}], + ['11', {IN=> {f=> '18 1 1 2 7 3 8 6 7 5 4 3 4 3 5 3 3 2 6 8 ^'}}, + {OUT=>'62B243D1B780E1D31CF1BA2DE3F01C72AEEA0E47'}], + ['12', {IN=> {f=> '16 0 9 8 1 8 1 7 6 7 7 1 2 6 9 5 4 7 ^'}}, + {OUT=>'1698994A273404848E56E7FDA4457B5900DE1342'}], + ['13', {IN=> {f=> '18 0 7 1 7 3 9 4 7 7 5 2 8 1 7 8 2 7 2 9 ^'}}, + {OUT=>'056F4CDC02791DA7ED1EB2303314F7667518DEEF'}], + ['14', {IN=> {f=> '19 1 2 3 1 8 8 6 9 10 3 10 8 9 2 4 1 5 1 5 9 ^'}}, + {OUT=>'9FE2DA967BD8441EEA1C32DF68DDAA9DC1FC8E4B'}], + ['15', {IN=> {f=> '19 1 8 5 4 8 1 3 9 5 7 7 2 7 2 7 8 7 4 8 10 ^'}}, + {OUT=>'73A31777B4ACE9384EFA8BBEAD45C51A71ABA6DD'}], + ['16', {IN=> {f=> '20 1 1 9 7 4 1 4 5 1 10 8 6 4 4 9 9 9 8 2 9 10 ^'}}, + {OUT=>'3F9D7C4E2384EDDABFF5DD8A31E23DE3D03F42AC'}], + ['17', {IN=> {f=> '19 1 11 6 7 7 2 6 2 6 10 6 9 10 5 11 1 6 8 11 4 ^'}}, + {OUT=>'4814908F72B93FFD011135BEE347DE9A08DA838F'}], + ['18', {IN=> {f=> '22 0 10 5 10 3 7 8 9 9 1 1 1 10 2 1 5 10 2 9 9 9 7 8 ^'}}, + {OUT=>'0978374B67A412A3102C5AA0B10E1A6596FC68EB'}], + ['19', {IN=> {f=> '21 0 1 10 1 6 9 4 2 5 2 11 8 12 12 9 8 1 3 10 7 11 12 ^'}}, + {OUT=>'44AD6CB618BD935460D46D3F921D87B99AB91C1E'}], + ['20', {IN=> {f=> '24 1 3 9 5 12 3 4 2 9 12 11 6 6 1 1 9 5 9 1 4 9 4 10 8 9 ^'}}, + {OUT=>'02DC989AF265B09CF8485640842128DCF95E9F39'}], + ['21', {IN=> {f=> '25 1 3 2 3 11 1 12 5 6 2 7 8 4 8 8 9 9 8 4 9 1 4 8 10 9 9 ^'}}, + {OUT=>'67507B8D497B35D6E99FC01976D73F54AECA75CF'}], + ['22', {IN=> {f=> '23 0 11 10 7 10 10 6 10 9 4 5 10 5 8 4 1 10 12 4 6 1 8 11 6 ^'}}, + {OUT=>'1EAE0373C1317CB60C36A42A867B716039D441F5'}], + ['23', {IN=> {f=> '22 0 12 8 10 4 3 8 5 5 7 11 13 11 12 11 4 12 3 6 5 11 10 5 ^'}}, + {OUT=>'9C3834589E5BFFAC9F50950E0199B3EC2620BEC8'}], + ['24', {IN=> {f=> '26 1 10 9 6 9 7 2 10 4 4 5 5 2 12 13 5 3 1 10 1 4 7 8 13 13 12 9 ^'}}, + {OUT=>'209F7ABC7F3B878EE46CDF3A1FBB9C21C3474F32'}], + ['25', {IN=> {f=> '31 0 2 6 5 4 7 3 10 6 13 6 3 9 6 2 10 5 3 8 4 1 11 3 5 3 7 11 1 12 9 12 5 ^'}}, + {OUT=>'05FC054B00D97753A9B3E2DA8FBBA3EE808CEF22'}], + ['26', {IN=> {f=> '27 1 14 5 1 3 7 2 3 9 3 4 14 4 4 10 8 5 14 1 11 12 12 10 4 13 7 11 9 ^'}}, + {OUT=>'0C4980EA3A46C757DFBFC5BAA38AC6C8E72DDCE7'}], + ['27', {IN=> {f=> '30 1 4 9 5 5 8 9 5 10 4 2 4 7 9 9 6 3 5 1 8 3 2 13 3 14 9 8 9 10 14 10 ^'}}, + {OUT=>'96A460D2972D276928B69864445BEA353BDCFFD2'}], + ['28', {IN=> {f=> '27 0 12 9 5 8 7 2 14 12 3 8 14 6 6 4 7 5 7 10 7 11 10 1 9 6 7 12 14 ^'}}, + {OUT=>'F3EF04D8FA8C6FA9850F394A4554C080956FA64B'}], + ['29', {IN=> {f=> '24 0 12 9 9 2 11 13 12 11 11 6 14 13 10 5 6 8 10 4 3 11 11 14 5 14 ^'}}, + {OUT=>'F2A31D875D1D7B30874D416C4D2EA6BAF0FFBAFE'}], + ['30', {IN=> {f=> '24 0 15 4 5 3 8 12 15 8 14 15 9 12 12 3 10 13 6 11 10 4 13 14 8 8 ^'}}, + {OUT=>'F4942D3B9E9588DCFDC6312A84DF75D05F111C20'}], + ['31', {IN=> {f=> '28 1 1 8 1 5 11 4 9 12 4 13 15 5 9 11 7 14 11 1 11 7 8 8 11 1 13 15 12 13 ^'}}, + {OUT=>'310207DF35B014E4676D30806FA34424813734DD'}], + ['32', {IN=> {f=> '32 1 5 8 3 8 10 7 8 1 5 13 12 14 5 3 6 4 12 15 6 6 10 11 13 9 1 11 6 10 3 7 14 2 ^'}}, + {OUT=>'4DA1955B2FA7C7E74E3F47D7360CE530BBF57CA3'}], + ['33', {IN=> {f=> '31 0 10 3 5 1 14 11 11 16 1 2 2 11 6 13 15 12 6 5 16 2 14 2 10 12 2 5 5 6 10 13 15 ^'}}, + {OUT=>'74C4BC5B26FB4A08602D40CCEC6C6161B6C11478'}], + ['34', {IN=> {f=> '34 0 3 10 8 16 9 5 12 15 4 11 13 3 6 5 10 8 1 3 9 3 11 1 2 16 12 10 6 1 9 1 16 5 6 14 ^'}}, + {OUT=>'0B103CE297338DFC7395F7715EE47539B556DDB6'}], + ['35', {IN=> {f=> '30 1 1 12 4 4 2 15 13 15 11 15 5 11 9 7 15 16 6 16 12 3 2 10 16 5 5 7 1 7 11 16 ^'}}, + {OUT=>'EFC72D99E3D2311CE14190C0B726BDC68F4B0821'}], + ['36', {IN=> {f=> '34 0 7 9 11 2 5 5 5 4 13 13 14 4 7 12 6 4 8 2 9 9 13 13 3 3 6 7 16 7 6 15 5 8 15 14 ^'}}, + {OUT=>'660EDAC0A8F4CE33DA0D8DBAE597650E97687250'}], + ['37', {IN=> {f=> '36 1 4 6 16 15 11 14 14 4 7 10 3 4 10 3 6 7 14 4 6 6 5 2 7 8 16 2 12 16 10 14 3 2 3 7 14 3 ^'}}, + {OUT=>'FE0A55A988B3B93946A63EB36B23785A5E6EFC3E'}], + ['38', {IN=> {f=> '32 0 15 10 9 1 14 10 14 6 6 16 3 2 3 8 3 12 8 11 17 3 9 7 16 14 4 11 15 5 13 9 5 17 ^'}}, + {OUT=>'0CBDF2A5781C59F907513147A0DE3CC774B54BF3'}], + ['39', {IN=> {f=> '30 0 17 17 13 8 2 6 8 16 1 12 5 17 2 9 8 10 13 14 11 17 12 5 14 9 11 9 11 4 11 12 ^'}}, + {OUT=>'663E40FEE5A44BFCB1C99EA5935A6B5BC9F583B0'}], + ['40', {IN=> {f=> '30 1 16 6 10 5 8 3 17 16 14 1 15 15 15 6 13 2 11 6 13 11 13 4 6 7 11 11 12 16 13 16 ^'}}, + {OUT=>'00162134256952DD9AE6B51EFB159B35C3C138C7'}], + ['41', {IN=> {f=> '33 1 16 16 14 16 2 4 16 11 6 15 7 4 17 6 5 7 6 3 14 16 5 17 11 13 1 1 14 13 3 6 14 5 16 ^'}}, + {OUT=>'CEB88E4736E354416E2010FC1061B3B53B81664B'}], + ['42', {IN=> {f=> '39 1 2 16 13 7 8 6 2 15 1 9 12 4 4 11 13 7 2 11 9 18 4 5 4 8 2 14 9 9 1 8 13 11 15 8 5 9 10 16 7 ^'}}, + {OUT=>'A6A2C4B6BCC41DDC67278F3DF4D8D0B9DD7784EF'}], + ['43', {IN=> {f=> '34 0 2 7 1 1 17 13 6 11 10 8 5 12 15 6 15 10 12 4 18 1 2 8 11 12 16 10 12 18 11 16 12 11 17 6 ^'}}, + {OUT=>'C23D083CD8820B57800A869F5F261D45E02DC55D'}], + ['44', {IN=> {f=> '34 1 4 7 13 7 10 7 10 6 1 12 7 18 11 18 2 10 15 10 14 8 18 9 9 12 12 3 13 12 6 4 9 17 13 17 ^'}}, + {OUT=>'E8AC31927B78DDEC41A31CA7A44EB7177165E7AB'}], + ['45', {IN=> {f=> '40 0 5 7 3 2 1 17 14 4 16 6 13 1 13 6 6 10 1 3 18 3 11 7 9 5 7 11 17 1 9 16 5 15 10 17 3 8 15 17 8 12 ^'}}, + {OUT=>'E864EC5DBAB0F9FF6984AB6AD43A8C9B81CC9F9C'}], + ['46', {IN=> {f=> '40 0 11 3 15 17 11 1 1 4 3 14 18 4 2 18 8 15 6 4 6 3 15 11 16 10 17 17 9 6 3 2 6 16 4 9 12 6 8 1 11 17 ^'}}, + {OUT=>'CFED6269069417A84D6DE2347220F4B858BCD530'}], + ['47', {IN=> {f=> '37 1 2 19 12 8 16 14 2 9 16 2 6 6 7 9 10 9 11 9 14 11 15 5 16 9 2 17 2 8 15 8 4 3 14 14 16 16 12 ^'}}, + {OUT=>'D9217BFB46C96348722C3783D29D4B1A3FEDA38C'}], + ['48', {IN=> {f=> '37 1 11 10 16 12 11 7 14 14 14 6 10 10 1 6 13 19 5 6 4 7 12 12 10 5 10 15 15 8 5 13 17 13 5 6 14 1 19 ^'}}, + {OUT=>'DEC24E5554F79697218D317315FA986229CE3350'}], + ['49', {IN=> {f=> '38 1 2 6 5 17 9 11 18 18 8 6 13 15 3 3 15 5 13 18 3 2 5 5 14 7 13 4 17 7 2 17 3 18 15 7 15 16 18 11 ^'}}, + {OUT=>'83A099DF7071437BA5495A5B0BFBFEFE1C0EF7F3'}], + ['50', {IN=> {f=> '38 1 12 8 6 3 17 12 13 19 15 9 7 17 16 15 3 11 11 5 2 13 19 16 2 4 16 7 8 1 2 9 17 12 3 5 18 19 11 9 ^'}}, + {OUT=>'AA3198E30891A83E33CE3BFA0587D86A197D4F80'}], + ['51', {IN=> {f=> '39 1 14 16 14 8 9 16 5 1 6 3 17 18 16 9 1 15 9 10 9 19 1 3 3 20 11 13 17 1 19 8 3 4 3 7 1 14 19 19 19 ^'}}, + {OUT=>'9B6ACBEB4989CBEE7015C7D515A75672FFDE3442'}], + ['52', {IN=> {f=> '37 1 18 13 11 5 18 4 19 10 6 19 11 17 10 10 7 9 13 16 9 10 18 4 12 5 16 5 20 12 3 8 10 1 18 1 6 20 14 ^'}}, + {OUT=>'B021EB08A436B02658EAA7BA3C88D49F1219C035'}], + ['53', {IN=> {f=> '36 0 8 9 6 12 11 7 7 3 17 13 6 20 17 9 20 16 10 12 17 8 11 8 11 10 5 10 14 18 8 19 9 12 12 2 20 19 ^'}}, + {OUT=>'CAE36DAB8AEA29F62E0855D9CB3CD8E7D39094B1'}], + ['54', {IN=> {f=> '39 0 12 16 20 3 9 9 19 17 13 13 4 17 2 11 7 14 3 6 16 13 10 13 5 16 10 2 8 2 17 19 4 17 7 19 6 9 15 15 6 ^'}}, + {OUT=>'02DE8BA699F3C1B0CB5AD89A01F2346E630459D7'}], + ['55', {IN=> {f=> '43 0 7 2 18 5 7 18 5 2 15 7 11 10 9 3 2 14 19 3 11 8 18 15 5 3 5 12 15 16 10 17 7 19 16 2 1 16 6 3 19 12 5 18 16 ^'}}, + {OUT=>'88021458847DD39B4495368F7254941859FAD44B'}], + ['56', {IN=> {f=> '49 1 9 11 2 1 12 11 14 12 14 10 4 11 6 8 16 7 5 11 20 8 17 4 14 4 15 3 2 2 4 3 2 3 14 15 10 2 12 7 3 7 20 20 19 10 2 3 1 10 20 ^'}}, + {OUT=>'91A165295C666FE85C2ADBC5A10329DAF0CB81A0'}], + ['57', {IN=> {f=> '36 0 19 20 12 5 19 21 5 21 11 14 19 1 17 8 9 4 19 3 17 1 14 21 14 7 6 5 20 14 21 20 4 6 21 7 11 12 ^'}}, + {OUT=>'4B31312EAF8B506811151A9DBD162961F7548C4B'}], + ['58', {IN=> {f=> '41 0 12 9 11 6 16 18 18 10 11 20 6 12 11 5 7 21 19 18 6 15 21 10 4 14 9 19 10 3 3 5 13 1 8 12 3 13 9 7 10 17 14 ^'}}, + {OUT=>'3FE70971B20558F7E9BAC303ED2BC14BDE659A62'}], + ['59', {IN=> {f=> '45 0 10 6 8 3 17 18 3 21 19 6 17 15 4 9 15 9 15 14 4 7 14 8 10 13 4 11 10 7 6 21 1 14 5 11 7 7 2 13 13 3 9 13 8 14 20 ^'}}, + {OUT=>'93FB769D5BF49D6C563685954E2AECC024DC02D6'}], + ['60', {IN=> {f=> '39 1 3 7 18 4 9 9 5 15 13 17 10 15 16 20 8 19 9 10 9 1 19 14 21 2 18 13 10 4 18 16 4 21 15 10 18 19 3 12 18 ^'}}, + {OUT=>'BC8827C3E614D515E83DEA503989DEA4FDA6EA13'}], + ['61', {IN=> {f=> '41 0 14 4 13 11 1 11 1 10 2 12 4 21 10 21 18 9 2 16 7 20 6 7 12 19 20 1 13 12 10 8 21 15 7 19 13 6 8 19 20 18 19 ^'}}, + {OUT=>'E83868DBE4A389AB48E61CFC4ED894F32AE112AC'}], + ['62', {IN=> {f=> '37 0 11 18 1 17 14 15 20 16 20 8 2 17 10 4 21 5 19 19 14 22 21 18 13 14 1 3 12 11 11 4 22 13 5 18 7 21 21 ^'}}, + {OUT=>'55C95459CDE4B33791B4B2BCAAF840930AF3F3BD'}], + ['63', {IN=> {f=> '48 0 9 22 19 12 8 16 5 17 5 9 1 2 9 6 12 6 1 7 4 3 15 1 14 1 12 3 10 2 10 14 21 13 17 6 6 17 1 21 2 14 16 17 9 11 20 21 11 18 ^'}}, + {OUT=>'36BB0E2BA438A3E03214D9ED2B28A4D5C578FCAA'}], + ['64', {IN=> {f=> '50 1 12 8 20 13 2 9 20 9 14 10 1 16 2 22 6 4 16 14 15 1 12 4 14 9 21 3 3 9 8 21 15 14 8 4 14 4 2 3 8 12 8 6 1 2 18 20 15 3 19 10 ^'}}, + {OUT=>'3ACBF874199763EBA20F3789DFC59572ACA4CF33'}], + ['65', {IN=> {f=> '44 0 10 20 14 6 3 4 21 1 12 4 18 2 6 7 6 9 20 14 10 10 19 17 21 12 15 17 7 10 11 8 10 12 1 19 19 9 18 21 4 18 11 9 22 5 ^'}}, + {OUT=>'86BE037C4D509C9202020767D860DAB039CADACE'}], + ['66', {IN=> {f=> '47 0 15 8 15 3 5 6 2 19 12 17 4 20 8 11 20 2 18 4 16 20 12 9 9 6 16 21 16 3 16 18 3 19 5 16 2 4 2 12 11 15 11 14 17 2 10 18 8 ^'}}, + {OUT=>'51B57D7080A87394EEC3EB2E0B242E553F2827C9'}], + ['67', {IN=> {f=> '48 1 5 13 3 21 5 3 6 18 18 10 1 21 21 7 1 13 12 19 1 14 6 8 21 19 21 11 19 13 2 13 4 1 10 22 16 4 9 4 10 16 3 7 15 11 9 13 17 12 ^'}}, + {OUT=>'1EFBFA78866315CE6A71E457F3A750A38FACAB41'}], + ['68', {IN=> {f=> '45 0 14 7 6 2 20 3 6 19 19 10 2 22 12 17 12 1 20 7 7 15 20 6 18 8 3 14 23 18 15 4 7 5 23 15 7 14 10 10 19 17 2 4 15 17 21 ^'}}, + {OUT=>'57D6CB41AEEC20236F365B3A490C61D0CFA39611'}], + ['69', {IN=> {f=> '45 1 15 11 8 9 17 5 12 18 14 6 20 17 21 12 16 9 22 9 20 15 2 22 11 2 6 11 9 8 2 4 14 19 3 21 21 23 8 2 11 4 8 4 20 22 11 ^'}}, + {OUT=>'C532CB64B4BA826372BCCF2B4B5793D5B88BB715'}], + ['70', {IN=> {f=> '38 0 21 18 22 10 19 9 14 17 23 21 10 7 15 13 16 5 4 10 13 14 20 23 12 20 23 18 10 12 8 21 11 6 12 7 19 14 18 17 ^'}}, + {OUT=>'15833B5631032663E783686A209C6A2B47A1080E'}], + ['71', {IN=> {f=> '40 0 18 22 6 9 22 5 23 13 6 8 23 20 22 5 22 15 19 20 9 9 1 13 13 10 14 13 5 22 14 21 9 21 19 14 14 4 18 13 12 14 ^'}}, + {OUT=>'D04F2043C96E10CD83B574B1E1C217052CD4A6B2'}], + ['72', {IN=> {f=> '48 1 7 3 15 5 17 14 23 14 5 17 22 11 1 8 13 23 6 21 3 6 11 7 23 8 6 21 4 4 22 19 13 8 5 19 7 5 23 1 4 19 11 23 11 21 14 1 3 21 ^'}}, + {OUT=>'E8882627C64DB743F7DB8B4413DD033FC63BEB20'}], + ['73', {IN=> {f=> '43 0 22 14 11 7 18 16 17 24 12 12 3 13 19 16 22 4 16 4 6 23 8 18 11 2 3 20 22 9 21 8 23 1 23 20 7 16 13 23 4 13 3 7 22 ^'}}, + {OUT=>'CD2D32286B8867BC124A0AF2236FC74BE3622199'}], + ['74', {IN=> {f=> '47 1 23 6 13 19 2 3 7 2 9 9 15 6 13 4 22 6 19 20 1 9 7 14 1 15 3 23 24 22 18 12 12 17 19 10 8 11 22 12 10 2 20 15 18 17 18 7 19 ^'}}, + {OUT=>'019B70D745375091ED5C7B218445EC986D0F5A82'}], + ['75', {IN=> {f=> '47 1 12 21 6 12 4 7 18 17 3 2 14 24 14 1 23 1 11 15 10 6 18 20 7 1 8 1 16 6 20 23 23 21 10 10 12 24 10 11 23 2 12 23 9 3 24 24 10 ^'}}, + {OUT=>'E5FF5FEC1DADBAED02BF2DAD4026BE6A96B3F2AF'}], + ['76', {IN=> {f=> '52 0 14 10 18 15 14 5 16 11 22 2 15 24 8 22 1 4 24 9 10 15 3 9 5 4 17 15 9 12 19 19 1 3 10 6 8 3 17 8 18 24 19 3 4 15 4 9 2 24 5 20 13 13 ^'}}, + {OUT=>'6F4E23B3F2E2C068D13921FE4E5E053FFED4E146'}], + ['77', {IN=> {f=> '42 0 20 17 19 22 13 8 10 19 15 11 1 14 17 20 22 10 7 11 16 9 21 22 17 23 12 15 4 24 7 21 18 2 21 16 1 19 18 20 11 3 15 17 ^'}}, + {OUT=>'25E179602A575C915067566FBA6DA930E97F8678'}], + ['78', {IN=> {f=> '50 0 18 1 6 14 5 5 5 19 13 10 24 19 16 24 15 13 2 19 15 24 21 17 4 13 17 1 1 9 1 10 2 18 1 21 19 5 18 12 2 22 16 23 15 19 6 18 9 1 23 5 ^'}}, + {OUT=>'67DED0E68E235C8A523E051E86108EEB757EFBFD'}], + ['79', {IN=> {f=> '51 0 21 13 14 11 18 12 13 3 19 9 20 22 20 2 11 12 6 1 12 16 18 2 9 8 4 3 11 17 11 5 4 19 16 11 23 13 18 1 20 8 2 16 16 21 4 19 5 5 20 24 16 ^'}}, + {OUT=>'AF78536EA83C822796745556D62A3EE82C7BE098'}], + ['80', {IN=> {f=> '53 1 20 25 17 11 8 4 19 25 17 7 16 21 6 4 8 2 15 9 2 9 19 3 6 3 3 10 25 13 15 7 8 20 21 12 10 12 5 24 11 20 3 13 13 16 9 13 10 3 9 16 3 7 25 ^'}}, + {OUT=>'64D7AC52E47834BE72455F6C64325F9C358B610D'}], + ['81', {IN=> {f=> '49 1 9 9 14 2 13 17 25 2 18 5 19 23 9 25 9 10 23 12 12 7 13 8 15 7 1 6 21 2 8 7 6 16 14 14 12 15 13 24 10 15 11 10 8 14 15 21 25 21 25 ^'}}, + {OUT=>'9D4866BAA3639C13E541F250FFA3D8BC157A491F'}], + ['82', {IN=> {f=> '47 0 9 18 20 22 21 20 11 14 23 22 10 13 14 8 19 12 2 11 20 23 13 4 10 6 5 7 23 11 3 16 8 21 4 8 18 5 12 14 8 6 20 19 24 8 23 17 23 ^'}}, + {OUT=>'2E258811961D3EB876F30E7019241A01F9517BEC'}], + ['83', {IN=> {f=> '48 1 7 19 1 18 1 14 22 13 14 5 8 22 18 14 25 17 11 12 22 2 12 12 16 12 13 18 17 12 17 14 18 8 25 9 23 5 3 8 14 24 17 7 3 3 23 17 22 19 ^'}}, + {OUT=>'8E0EBC487146F83BC9077A1630E0FB3AB3C89E63'}], + ['84', {IN=> {f=> '51 1 19 17 16 22 24 14 16 20 23 20 9 19 16 7 12 16 5 8 9 7 10 21 24 10 11 19 1 21 14 14 19 3 22 8 12 20 1 18 5 6 5 12 14 1 1 11 9 22 3 24 4 ^'}}, + {OUT=>'CE8953741FFF3425D2311FBBF4AB481B669DEF70'}], + ['85', {IN=> {f=> '52 1 6 1 11 16 1 12 8 11 11 17 10 22 7 3 10 2 6 4 24 16 24 19 4 5 18 11 12 9 20 21 25 2 21 18 10 20 25 21 3 17 17 5 8 22 25 19 8 10 19 7 11 18 ^'}}, + {OUT=>'789D1D2DAB52086BD90C0E137E2515ED9C6B59B5'}], + ['86', {IN=> {f=> '44 0 26 14 21 25 25 4 9 13 5 8 9 21 8 12 26 24 9 24 15 1 23 22 16 14 8 22 15 19 24 20 7 8 15 24 12 4 4 23 21 13 19 15 21 12 ^'}}, + {OUT=>'B76CE7472700DD68D6328B7AA8437FB051D15745'}], + ['87', {IN=> {f=> '59 1 15 7 3 21 20 8 22 14 23 26 19 2 10 18 3 5 3 1 9 15 15 3 7 13 23 9 7 1 13 17 14 25 9 16 2 2 6 13 7 19 25 17 1 5 21 2 7 22 5 6 25 3 12 19 6 2 4 24 17 ^'}}, + {OUT=>'F218669B596C5FFB0B1C14BD03C467FC873230A0'}], + ['88', {IN=> {f=> '60 0 9 18 20 19 4 11 14 1 6 8 26 6 9 22 4 10 2 7 21 9 8 24 25 14 22 12 22 3 23 3 3 20 6 11 23 6 1 7 5 18 5 15 25 26 1 1 10 11 11 4 12 11 20 3 14 2 3 2 23 15 ^'}}, + {OUT=>'1FF3BDBE0D504CB0CDFAB17E6C37ABA6B3CFFDED'}], + ['89', {IN=> {f=> '49 0 12 17 24 11 8 6 24 16 15 22 21 14 6 12 20 19 5 5 12 11 6 23 2 16 23 7 24 6 21 2 17 17 5 25 11 25 20 25 24 18 6 12 19 25 7 6 5 2 25 ^'}}, + {OUT=>'2F3CBACBB14405A4652ED52793C1814FD8C4FCE0'}], + ['90', {IN=> {f=> '54 1 12 16 1 15 7 1 26 19 19 13 20 11 17 6 20 5 24 24 1 21 11 9 20 21 15 10 19 26 3 2 6 7 12 9 10 8 14 10 15 5 17 8 21 1 20 25 6 19 8 3 22 16 16 20 ^'}}, + {OUT=>'982C8AB6CE164F481915AF59AAED9FFF2A391752'}], + ['91', {IN=> {f=> '63 0 17 13 11 10 17 15 12 6 13 14 17 4 12 10 24 5 13 24 3 5 2 5 11 14 8 5 10 17 16 8 4 14 21 15 3 6 17 25 8 2 3 3 19 10 13 22 22 8 2 13 25 17 2 1 19 1 14 20 2 5 4 15 24 ^'}}, + {OUT=>'5CD92012D488A07ECE0E47901D0E083B6BD93E3F'}], + ['92', {IN=> {f=> '49 0 14 20 7 25 20 26 20 16 7 17 17 22 1 13 6 5 1 18 14 15 23 15 10 5 19 18 18 26 12 13 3 25 12 21 16 24 4 16 3 6 26 26 10 20 13 1 20 24 15 ^'}}, + {OUT=>'69603FEC02920851D4B3B8782E07B92BB2963009'}], + ['93', {IN=> {f=> '56 0 3 8 14 5 5 7 11 13 11 26 11 4 26 17 20 19 11 10 3 10 14 9 6 9 7 16 10 4 4 19 19 2 26 13 19 17 15 24 15 4 21 22 13 13 12 22 2 14 20 5 18 7 17 24 20 20 ^'}}, + {OUT=>'3E90F76437B1EA44CF98A08D83EA24CECF6E6191'}], + ['94', {IN=> {f=> '58 1 6 17 9 20 2 10 19 3 22 4 1 11 3 5 3 21 11 15 12 23 26 5 2 27 6 5 16 6 3 2 23 5 3 20 20 4 24 2 18 21 7 14 10 27 23 6 24 6 19 23 3 9 22 16 21 17 19 23 ^'}}, + {OUT=>'34C09F107C42D990EB4881D4BF2DDDCAB01563AE'}], + ['95', {IN=> {f=> '58 1 17 7 21 19 6 16 15 15 20 14 2 25 19 14 18 19 7 9 1 14 11 10 16 3 23 14 26 10 11 1 18 1 12 24 19 19 1 7 2 3 24 7 12 9 2 8 16 20 24 5 26 26 4 9 2 7 25 17 ^'}}, + {OUT=>'474BE0E5892EB2382109BFC5E3C8249A9283B03D'}], + ['96', {IN=> {f=> '54 1 8 12 18 14 26 7 17 18 4 20 1 16 14 21 26 4 6 8 24 11 25 15 24 16 23 4 10 23 21 24 15 10 9 26 7 14 24 21 6 20 5 17 16 17 1 3 12 1 4 13 3 9 21 26 ^'}}, + {OUT=>'A04B4F75051786682483252438F6A75BF4705EC6'}], + ['97', {IN=> {f=> '56 1 7 18 11 1 19 20 23 12 12 27 13 13 15 16 13 1 16 15 12 26 3 16 16 8 17 13 21 4 6 5 19 14 16 4 16 11 14 18 18 27 9 13 21 3 26 22 3 7 6 4 26 3 15 8 25 21 ^'}}, + {OUT=>'BE88A6716083EB50ED9416719D6A247661299383'}], + ['98', {IN=> {f=> '50 1 20 13 9 11 20 6 11 21 27 25 20 7 4 18 26 16 27 5 12 19 7 23 6 25 25 2 11 13 25 21 18 17 6 12 14 13 24 11 14 19 26 27 25 6 1 15 4 7 27 15 ^'}}, + {OUT=>'C67E38717FEE1A5F65EC6C7C7C42AFC00CD37F04'}], + ['99', {IN=> {f=> '51 0 15 16 26 27 23 14 12 28 22 15 8 19 2 20 13 1 24 2 25 1 6 19 19 8 11 24 24 21 13 27 5 11 28 17 7 25 6 23 24 14 25 12 5 13 26 2 5 8 10 16 17 ^'}}, + {OUT=>'959AC4082388E19E9BE5DE571C047EF10C174A8D'}], + ['100', {IN=> {f=> '58 1 5 26 18 19 21 3 12 11 13 4 14 22 22 14 16 13 3 22 16 23 5 19 6 13 10 26 17 27 26 4 3 25 6 14 2 3 5 7 23 11 22 8 25 2 9 25 18 17 8 2 14 4 19 1 5 27 13 24 ^'}}, + {OUT=>'BAA7AA7B7753FA0ABDC4A541842B5D238D949F0A'}], + ['101', {IN=> {f=> '53 0 2 27 28 2 17 23 10 27 18 26 7 22 16 3 27 1 26 21 28 10 3 6 2 2 10 17 13 16 6 17 21 23 13 20 22 5 6 11 12 12 8 23 13 17 9 23 20 3 28 27 12 17 22 ^'}}, + {OUT=>'351394DCEBC08155D100FCD488578E6AE71D0E9C'}], + ['102', {IN=> {f=> '59 0 28 19 5 21 4 27 8 1 19 14 20 6 7 9 1 6 22 3 19 26 14 8 6 7 19 15 23 1 17 16 6 26 14 5 22 25 4 7 10 16 21 10 18 19 24 16 23 8 3 17 28 18 10 2 5 3 21 21 15 ^'}}, + {OUT=>'AB8BE94C5AF60D9477EF1252D604E58E27B2A9EE'}], + ['103', {IN=> {f=> '58 0 6 24 1 4 24 18 10 22 1 21 12 5 4 4 20 25 24 26 8 25 11 2 7 27 22 19 4 18 27 10 28 4 12 24 8 16 12 11 16 17 25 8 12 16 1 9 9 10 5 24 23 18 5 14 18 8 4 28 ^'}}, + {OUT=>'3429EC74A695FDD3228F152564952308AFE0680A'}], + ['104', {IN=> {f=> '61 0 5 17 8 28 1 22 4 11 3 2 17 3 14 9 27 13 18 24 9 8 7 28 25 14 21 27 24 6 18 16 2 12 15 9 14 10 1 8 17 4 6 15 26 11 15 2 28 20 26 16 3 7 5 8 9 26 10 12 25 11 22 ^'}}, + {OUT=>'907FA46C029BC67EAA8E4F46E3C2A232F85BD122'}], + ['105', {IN=> {f=> '53 0 9 13 24 15 20 2 4 8 2 22 20 19 4 15 14 28 13 25 10 10 12 28 24 22 26 28 15 9 11 26 19 22 27 2 21 8 20 23 26 12 10 21 9 15 13 25 7 26 1 13 5 9 20 ^'}}, + {OUT=>'2644C87D1FBBBC0FC8D65F64BCA2492DA15BAAE4'}], + ['106', {IN=> {f=> '58 0 3 9 21 22 7 1 23 28 1 2 8 22 12 18 28 5 18 14 7 11 17 20 20 7 21 13 8 28 21 22 2 16 20 15 28 9 3 22 13 10 23 4 16 11 14 1 10 8 14 14 15 18 13 12 21 18 25 28 ^'}}, + {OUT=>'110A3EEB408756E2E81ABAF4C5DCD4D4C6AFCF6D'}], + ['107', {IN=> {f=> '60 1 29 20 2 29 22 8 16 20 4 12 9 6 12 16 16 7 9 20 29 11 9 4 1 15 25 16 29 10 22 7 2 8 5 18 14 23 24 4 6 26 3 11 6 12 1 7 14 24 14 6 10 21 16 23 29 25 6 14 17 24 ^'}}, + {OUT=>'CD4FDC35FAC7E1ADB5DE40F47F256EF74D584959'}], + ['108', {IN=> {f=> '64 0 12 10 5 10 15 25 8 15 3 7 13 25 16 14 1 29 22 26 15 27 9 1 8 8 28 6 13 5 13 3 15 5 23 8 23 2 5 5 4 17 13 14 7 17 12 27 3 18 5 7 5 26 18 15 22 28 16 13 7 2 23 19 25 15 ^'}}, + {OUT=>'8E6E273208AC256F9ECCF296F3F5A37BC8A0F9F7'}], + ['109', {IN=> {f=> '56 1 17 7 16 25 23 11 11 15 2 13 9 26 2 24 26 7 28 11 2 29 7 22 23 5 28 19 1 27 29 1 24 11 18 20 3 13 11 7 3 15 17 24 1 18 13 6 3 25 27 16 28 18 24 8 23 22 ^'}}, + {OUT=>'FE0606100BDBC268DB39B503E0FDFE3766185828'}], + ['110', {IN=> {f=> '51 1 29 28 6 28 14 12 28 27 22 4 14 25 1 3 9 7 11 14 15 16 10 19 12 19 11 20 13 28 4 27 28 7 27 12 4 28 21 17 22 20 17 15 15 23 22 13 12 21 22 21 29 ^'}}, + {OUT=>'6C63C3E58047BCDB35A17F74EEBA4E9B14420809'}], + ['111', {IN=> {f=> '64 1 12 14 12 18 27 8 7 4 9 14 16 15 8 11 21 20 10 10 21 23 20 2 11 23 1 11 1 5 3 23 16 15 27 14 5 16 3 22 2 3 24 3 19 29 4 4 10 8 20 14 15 1 26 12 27 25 4 28 22 11 19 19 24 9 ^'}}, + {OUT=>'BCC2BD305F0BCDA8CF2D478EF9FE080486CB265F'}], + ['112', {IN=> {f=> '60 1 20 8 9 5 25 19 17 19 15 7 24 24 21 3 20 16 8 3 17 28 18 29 9 23 9 10 29 4 12 24 15 5 8 22 17 29 12 3 8 29 15 21 21 4 7 20 7 10 7 26 10 16 24 6 7 12 8 12 15 17 ^'}}, + {OUT=>'CE5223FD3DD920A3B666481D5625B16457DCB5E8'}], + ['113', {IN=> {f=> '60 0 9 17 11 28 12 26 26 6 29 13 10 20 6 23 10 4 3 26 26 14 20 20 25 14 13 15 24 14 11 4 23 27 24 20 9 16 17 24 13 12 6 1 14 26 25 7 8 21 1 19 3 2 2 17 21 13 5 9 21 11 ^'}}, + {OUT=>'948886776E42E4F5FAE1B2D0C906AC3759E3F8B0'}], + ['114', {IN=> {f=> '54 0 25 1 27 24 6 23 16 5 1 20 29 22 25 9 25 10 3 28 28 25 19 18 16 24 14 15 5 28 12 28 26 29 2 15 15 9 5 18 19 22 12 15 4 6 15 24 16 9 4 26 25 18 27 12 ^'}}, + {OUT=>'4C12A51FCFE242F832E3D7329304B11B75161EFB'}], + ['115', {IN=> {f=> '61 1 20 4 26 12 3 22 1 22 30 3 28 10 9 24 14 29 6 30 3 10 20 14 6 3 19 21 21 28 16 18 11 30 11 20 30 1 9 8 11 5 19 10 24 4 22 4 2 26 5 15 20 8 3 13 30 18 8 1 25 28 19 ^'}}, + {OUT=>'C54BDD2050504D92F551D378AD5FC72C9ED03932'}], + ['116', {IN=> {f=> '56 1 20 15 21 18 18 12 16 13 24 9 21 2 28 6 1 23 9 18 27 27 4 9 13 10 8 14 16 15 12 11 14 21 14 10 11 25 17 17 30 21 13 27 26 26 22 14 13 17 21 19 9 9 20 23 13 28 ^'}}, + {OUT=>'8F53E8FA79EA09FD1B682AF5ED1515ECA965604C'}], + ['117', {IN=> {f=> '59 1 10 28 24 10 22 27 23 27 8 17 14 6 4 21 26 15 1 8 29 27 6 28 15 3 27 25 25 14 19 13 29 8 24 2 8 2 4 12 19 11 10 6 26 14 22 24 30 10 11 12 2 12 17 23 8 8 12 28 12 ^'}}, + {OUT=>'2D7E17F6294524CE78B33EAB72CDD08E5FF6E313'}], + ['118', {IN=> {f=> '56 0 14 28 2 17 4 8 3 26 9 23 21 30 30 20 4 13 28 29 9 3 17 7 19 30 28 1 2 20 9 12 24 15 30 20 27 3 23 11 6 29 25 23 26 17 20 10 22 15 23 6 25 5 4 30 2 29 ^'}}, + {OUT=>'64582B4B57F782C9302BFE7D07F74AA176627A3A'}], + ['119', {IN=> {f=> '63 1 23 15 27 14 26 1 1 7 19 12 7 6 20 18 14 4 15 17 28 7 11 7 8 9 22 17 12 5 23 18 25 18 6 12 26 30 12 30 14 3 1 18 10 20 27 21 8 6 24 26 20 11 24 7 2 4 18 15 14 30 16 19 14 ^'}}, + {OUT=>'6D88795B71D3E386BBD1EB830FB9F161BA98869F'}], + ['120', {IN=> {f=> '52 0 27 15 4 19 25 29 29 7 14 18 9 11 9 27 11 15 29 9 28 20 2 30 26 21 17 8 28 17 22 29 24 8 11 18 29 15 6 7 27 27 17 24 18 23 11 19 8 30 5 24 22 24 ^'}}, + {OUT=>'86AD34A6463F12CEE6DE9596ABA72F0DF1397FD1'}], + ['121', {IN=> {f=> '66 1 25 15 28 23 5 10 21 5 8 7 3 10 19 17 6 9 15 29 10 7 4 1 16 21 16 29 13 18 5 3 8 15 8 21 29 20 5 27 2 13 27 7 7 30 2 18 26 10 2 5 29 21 15 25 26 24 8 12 20 3 9 10 30 7 12 29 ^'}}, + {OUT=>'7EB46685A57C0D466152DC339C8122548C757ED1'}], + ['122', {IN=> {f=> '53 1 30 26 20 11 22 19 27 2 16 10 6 4 24 17 20 25 20 15 8 23 23 20 30 18 16 3 30 15 26 23 28 7 21 8 7 31 31 14 26 18 3 1 26 28 15 25 11 31 3 25 9 21 30 ^'}}, + {OUT=>'E7A98FB0692684054407CC221ABC60C199D6F52A'}], + ['123', {IN=> {f=> '67 0 2 6 14 4 9 5 28 8 17 22 1 4 8 7 10 14 19 10 14 8 27 9 24 26 4 30 11 8 19 5 21 7 2 27 20 16 20 20 22 14 13 16 26 14 10 3 25 22 25 23 21 10 15 15 29 8 13 4 2 13 22 20 7 4 20 31 23 ^'}}, + {OUT=>'34DF1306662206FD0A5FC2969A4BEEC4EB0197F7'}], + ['124', {IN=> {f=> '65 0 2 2 28 13 19 14 12 23 27 6 2 14 2 22 6 25 30 29 31 13 14 16 31 12 16 30 5 14 31 11 4 1 1 25 21 13 26 22 21 5 22 14 29 1 21 3 14 30 4 2 29 12 15 23 3 15 5 1 6 23 22 13 1 14 23 ^'}}, + {OUT=>'56CF7EBF08D10F0CB9FE7EE3B63A5C3A02BCB450'}], + ['125', {IN=> {f=> '59 1 25 5 15 6 13 3 22 11 23 31 24 6 5 20 4 14 3 29 8 29 19 7 29 23 25 28 19 11 15 27 21 14 1 19 20 26 12 7 12 1 18 13 29 28 23 29 14 23 7 1 9 29 24 5 30 18 5 25 30 ^'}}, + {OUT=>'3BAE5CB8226642088DA760A6F78B0CF8EDDEA9F1'}], + ['126', {IN=> {f=> '55 1 31 25 13 7 24 25 24 1 12 19 9 7 6 28 20 14 28 21 19 31 20 20 6 24 18 27 24 4 18 21 1 31 15 1 15 2 27 4 26 25 4 23 19 2 31 22 30 21 22 5 27 12 30 28 31 ^'}}, + {OUT=>'6475DF681E061FA506672C27CBABFA9AA6DDFF62'}], + ['127', {IN=> {f=> '62 0 27 15 18 14 25 15 17 7 28 11 28 29 30 1 17 12 10 2 18 20 21 2 11 12 5 4 12 25 14 5 5 24 22 18 31 15 22 29 11 3 21 31 21 27 3 28 7 10 25 2 15 30 9 30 7 22 15 9 3 20 24 14 ^'}}, + {OUT=>'79D81991FA4E4957C8062753439DBFD47BBB277D'}], + ['128', {IN=> {f=> '60 0 28 14 18 9 27 14 22 27 31 10 8 14 7 15 7 20 5 26 1 29 7 17 17 8 3 13 27 18 8 31 27 28 22 22 17 19 18 18 11 19 13 25 10 19 6 28 4 31 23 10 18 26 31 5 10 13 12 8 15 27 ^'}}, + {OUT=>'BAE224477B20302E881F5249F52EC6C34DA8ECEF'}], + ['129', {IN=> {f=> '60 1 24 22 4 29 22 31 28 20 4 16 21 3 1 15 5 15 6 30 3 29 29 7 27 20 2 20 31 22 26 9 29 16 4 26 32 17 20 14 28 17 19 6 24 11 26 28 5 18 15 8 16 20 21 4 9 12 4 8 17 29 ^'}}, + {OUT=>'EDE4DEB4293CFE4138C2C056B7C46FF821CC0ACC'}], + ['130', {IN=> {f=> '69 1 5 3 11 15 12 24 31 23 1 6 28 2 8 31 6 7 30 5 19 23 12 6 9 31 19 17 24 25 22 6 12 16 3 7 9 9 11 29 4 11 2 5 13 29 10 12 30 32 18 28 18 27 3 30 4 4 26 6 13 31 13 2 11 7 24 4 17 29 12 ^'}}, + {OUT=>'A771FA5C812BD0C9596D869EC99E4F4AC988B13F'}], + ['131', {IN=> {f=> '95 0 21 19 21 23 11 42 36 2 13 4 1 33 22 16 27 9 4 33 16 3 30 15 11 32 13 17 38 32 9 38 4 36 15 32 27 19 42 18 6 36 22 10 29 12 25 40 15 29 23 28 30 4 8 11 24 9 10 31 28 43 23 16 29 33 5 40 26 3 19 12 36 43 5 35 37 5 14 11 45 35 16 10 8 32 4 15 35 26 2 39 22 37 22 30 29 ^'}}, + {OUT=>'E99D566212BBBCEEE903946F6100C9C96039A8F4'}], + ['132', {IN=> {f=> '106 1 18 14 51 2 6 32 51 9 32 50 44 46 51 8 11 53 45 55 16 10 3 52 8 20 20 46 46 13 32 2 46 50 43 25 54 9 31 29 2 47 15 29 24 45 44 18 37 14 28 39 36 44 47 16 50 10 44 24 53 35 22 40 20 15 51 22 18 22 42 6 54 49 38 21 7 13 30 16 7 52 16 22 13 38 7 11 44 33 9 25 13 37 42 14 45 53 30 38 5 25 5 35 38 22 28 53 ^'}}, + {OUT=>'B48CE6B1D13903E3925AE0C88CB931388C013F9C'}], + ['133', {IN=> {f=> '127 0 58 35 43 28 5 28 63 8 12 25 9 47 53 29 62 7 37 2 3 48 5 12 55 56 28 35 12 63 6 58 27 27 48 44 35 14 17 22 56 10 8 1 16 15 42 63 14 51 57 19 41 7 8 56 47 34 52 22 48 60 43 9 1 52 4 21 49 61 18 50 23 13 46 62 23 45 62 9 56 18 23 31 8 30 27 36 13 38 4 58 53 47 24 18 41 58 19 12 18 52 42 29 44 45 26 63 34 32 41 64 15 26 55 19 2 49 6 30 53 13 54 12 53 37 12 37 43 ^'}}, + {OUT=>'E647D5BAF670D4BF3AFC0A6B72A2424B0C64F194'}], + ['134', {IN=> {f=> '148 0 60 4 51 47 58 38 17 63 33 23 28 43 12 69 70 33 17 12 50 18 18 36 45 2 67 4 45 20 4 33 38 29 45 8 22 58 39 71 38 32 53 35 19 53 31 29 51 35 4 63 18 33 26 47 70 9 64 62 63 30 15 1 35 28 16 40 20 14 50 33 19 38 30 27 55 10 16 46 47 7 55 12 53 26 56 33 29 55 25 17 48 43 21 43 18 24 63 27 68 46 38 33 35 10 18 11 27 5 9 58 35 70 36 36 39 47 2 10 66 47 5 18 21 44 71 51 57 3 22 7 56 55 28 25 14 40 16 24 48 37 66 50 24 45 18 39 53 55 ^'}}, + {OUT=>'65C1CD932A06B05CD0B43AFB3BC7891F6BCEF45C'}], + ['135', {IN=> {f=> '165 1 15 62 35 29 15 40 19 76 67 4 5 71 46 61 26 8 77 48 1 23 12 60 40 24 44 33 29 42 73 66 49 61 20 30 1 54 52 42 39 64 23 65 37 24 20 11 26 66 22 77 22 57 7 38 57 33 61 73 7 64 1 49 35 76 14 27 21 45 68 38 58 73 13 72 47 73 33 8 66 23 38 4 56 77 47 10 71 13 20 31 41 6 51 3 18 17 61 47 14 48 76 46 28 34 43 1 56 4 25 7 65 41 1 34 37 23 59 59 27 26 13 15 14 75 60 14 1 28 59 26 65 61 16 23 17 28 6 19 2 35 49 30 29 48 2 63 73 59 1 3 76 41 11 19 18 43 54 63 67 51 4 9 78 60 66 ^'}}, + {OUT=>'70FFAE353A5CD0F8A65A8B2746D0F16281B25EC7'}], + ['136', {IN=> {f=> '181 0 18 19 84 17 12 10 57 18 77 51 52 16 39 74 49 52 63 38 72 2 15 64 83 62 49 56 11 26 68 58 83 33 23 50 63 71 53 27 84 22 39 41 52 58 11 64 7 60 45 70 22 5 73 38 30 30 48 21 75 80 40 21 8 53 9 26 30 34 81 71 71 51 23 75 33 41 23 32 5 8 66 40 72 40 16 66 45 14 48 34 21 41 27 3 55 27 37 23 41 65 4 57 51 74 22 19 75 42 16 19 46 16 10 48 20 19 37 41 14 57 9 17 55 38 5 60 7 46 20 43 36 39 52 20 10 62 45 23 46 7 35 75 29 70 35 36 34 25 12 15 84 26 10 6 71 29 79 33 32 25 59 76 82 64 58 7 8 19 41 74 2 53 65 24 1 55 51 36 21 79 7 ^'}}, + {OUT=>'CC8221F2B829B8CF39646BF46888317C3EB378EA'}], + ['137', {IN=> {f=> '184 1 60 66 66 6 3 9 73 12 7 40 70 18 71 70 65 51 14 14 27 50 9 87 81 50 22 19 40 37 16 79 12 34 37 76 82 10 61 7 81 49 67 26 45 82 50 81 63 45 69 31 31 76 51 9 59 34 51 54 34 83 10 33 51 86 81 82 69 18 8 22 64 19 86 62 58 33 37 17 34 5 29 83 42 76 50 54 66 39 9 1 36 43 17 65 6 35 56 72 71 83 88 10 1 8 87 22 6 21 78 25 89 43 62 40 55 85 31 89 74 63 46 28 24 26 31 17 7 8 27 19 12 85 17 20 27 77 10 2 54 80 17 52 74 76 69 78 11 20 80 4 29 24 85 75 18 39 23 70 83 29 57 67 72 70 33 4 15 46 42 2 69 13 53 33 69 64 33 64 14 40 69 59 78 54 ^'}}, + {OUT=>'26ACCC2D6D51FF7BF3E5895588907765111BB69B'}], + ['138', {IN=> {f=> '193 1 68 43 95 53 38 58 55 28 20 16 67 48 17 86 32 44 68 67 28 16 14 79 25 15 72 67 50 80 18 30 10 75 1 60 45 87 78 28 95 49 63 70 59 26 6 51 73 60 65 18 26 8 87 5 58 31 25 57 40 46 78 57 34 78 61 36 66 57 38 80 22 32 68 71 30 74 37 81 66 77 66 55 2 51 24 93 61 40 68 45 61 12 63 24 89 59 52 72 43 20 20 69 36 40 88 46 9 62 55 77 84 20 18 6 77 15 52 39 75 3 26 4 85 17 62 29 11 92 46 58 29 59 28 42 80 71 96 2 49 85 37 63 4 61 14 2 53 87 25 86 6 75 76 93 41 39 93 92 42 56 41 63 26 28 18 77 11 50 78 79 1 12 12 91 29 13 58 5 56 92 66 59 4 39 47 95 5 5 62 33 13 80 27 ^'}}, + {OUT=>'01072915B8E868D9B28E759CF2BC1AEA4BB92165'}], + ['139', {IN=> {f=> '203 1 35 28 11 7 20 7 17 3 3 30 89 13 65 56 66 63 22 82 16 31 55 56 77 91 91 71 101 13 10 85 101 95 17 99 98 91 33 14 20 48 32 7 64 29 38 35 25 4 95 23 34 1 85 81 23 31 96 71 84 50 15 79 47 25 51 45 35 66 19 61 60 9 31 93 64 70 30 42 86 53 1 71 46 42 22 38 96 10 99 34 76 26 55 73 63 63 97 23 92 81 64 46 1 30 31 35 86 91 88 64 87 16 37 69 84 94 60 100 3 47 52 8 71 87 57 29 76 43 18 45 46 15 65 12 44 42 66 60 15 68 19 58 39 62 76 9 92 101 57 32 4 34 15 41 62 32 89 71 43 35 31 41 21 17 82 33 96 27 62 29 82 57 46 62 15 24 99 37 83 40 52 46 56 80 98 3 91 74 6 27 7 58 94 10 41 79 97 84 77 74 26 99 35 ^'}}, + {OUT=>'3016115711D74236ADF0C371E47992F87A428598'}], + ['140', {IN=> {f=> '212 1 26 101 17 91 45 97 80 59 102 30 68 4 85 9 4 39 16 18 85 70 11 87 62 72 78 38 3 41 53 82 82 35 18 13 94 64 52 39 77 59 26 9 65 46 64 98 32 29 86 79 16 63 54 76 56 98 16 98 78 22 72 33 103 104 52 84 12 65 15 85 101 97 84 31 51 26 100 100 38 80 13 2 78 7 24 44 84 103 27 7 28 16 33 99 25 103 54 14 42 62 87 92 27 22 42 5 52 100 84 73 72 63 24 48 56 52 23 5 17 76 31 1 95 58 43 60 50 62 30 23 35 79 20 35 3 72 32 45 51 87 41 84 27 79 77 70 102 15 54 15 100 8 52 69 105 3 30 84 42 93 66 89 69 74 24 33 42 97 4 38 99 106 13 93 6 106 74 100 54 45 21 59 56 37 9 50 32 75 79 31 77 9 61 1 8 68 6 60 81 7 100 99 14 61 48 25 73 26 70 72 94 34 ^'}}, + {OUT=>'BF30417999C1368F008C1F19FECA4D18A5E1C3C9'}], + ['141', {IN=> {f=> '233 0 11 98 110 88 35 110 35 64 49 88 93 28 85 6 78 65 90 52 24 97 51 39 51 59 23 1 3 49 33 11 78 27 35 55 64 5 102 4 70 25 56 58 38 66 11 31 96 66 104 59 41 86 58 29 79 41 40 72 51 12 92 34 52 44 69 104 21 97 89 96 48 21 4 61 40 28 67 34 23 85 44 22 62 52 33 84 23 30 73 74 4 79 12 81 47 80 53 47 89 40 19 80 62 34 61 29 41 95 43 1 70 63 55 53 18 19 13 48 10 19 89 49 4 52 53 56 76 10 8 104 77 15 28 38 75 109 3 85 90 8 40 8 93 90 43 39 14 60 17 36 78 56 105 80 35 75 36 58 82 50 100 98 45 74 13 66 95 72 71 95 34 14 98 72 33 38 37 52 6 14 107 59 3 29 61 67 98 92 5 93 17 98 36 87 41 75 71 57 88 17 25 91 84 3 58 20 92 69 51 50 36 31 14 25 18 30 18 1 41 104 30 82 59 87 70 34 96 28 47 62 81 103 48 ^'}}, + {OUT=>'62BA49087185F2742C26E1C1F4844112178BF673'}], + ['142', {IN=> {f=> '234 1 63 90 108 108 102 64 82 88 4 111 76 97 22 1 108 41 34 91 33 20 25 24 26 8 83 11 31 7 85 109 106 4 105 85 68 28 33 99 53 8 16 12 11 74 17 83 66 70 16 30 9 67 68 34 24 81 47 92 72 47 37 33 38 92 17 8 28 88 22 62 69 32 89 75 3 72 96 85 13 105 24 38 37 94 115 83 72 108 114 24 93 76 103 60 99 102 9 43 10 59 95 46 33 93 15 26 69 44 2 86 107 55 45 61 65 92 66 9 55 39 70 83 29 98 67 13 111 15 20 31 62 8 2 51 20 19 33 44 14 115 71 112 97 10 41 28 53 51 26 57 15 38 98 55 106 22 56 31 50 95 107 110 84 70 10 108 96 73 100 25 36 55 88 71 63 96 30 90 96 79 22 7 30 23 28 59 89 8 51 99 47 86 34 18 43 65 98 104 107 49 7 79 71 8 57 21 29 80 2 74 78 44 57 9 61 22 13 68 52 91 74 98 43 30 58 68 95 101 72 102 76 42 99 61 ^'}}, + {OUT=>'E1F6B9536F384DD3098285BBFD495A474140DC5A'}], + ['143', {IN=> {f=> '249 0 27 117 45 119 80 2 59 52 8 76 20 94 102 69 96 42 46 106 67 9 110 89 71 69 34 31 15 85 16 29 100 82 37 62 68 95 108 44 23 114 34 36 56 93 11 30 96 12 31 67 14 114 14 66 70 30 81 46 53 119 85 6 104 47 92 72 70 5 70 15 115 68 105 33 97 13 85 106 14 61 29 22 86 45 57 69 91 38 38 28 66 13 60 95 103 3 15 5 113 38 23 62 5 65 94 107 73 104 37 47 102 117 3 78 35 7 95 56 78 45 52 28 46 43 37 32 53 19 55 29 47 97 76 115 83 71 11 45 62 73 99 116 2 24 116 7 28 41 2 29 37 52 23 5 118 79 31 57 89 61 24 101 78 50 93 73 41 7 33 45 47 24 1 48 73 36 3 25 87 46 28 108 54 68 53 67 119 28 36 118 104 42 88 27 112 4 74 85 1 63 39 97 71 74 75 76 10 49 12 79 11 50 103 118 94 117 118 37 27 12 94 60 28 51 47 82 110 17 15 105 23 52 43 12 21 22 81 41 12 74 90 42 108 117 98 67 4 69 85 ^'}}, + {OUT=>'B522DAE1D67726EBA7C4136D4E2F6D6D645AC43E'}], + ['144', {IN=> {f=> '243 0 76 81 26 101 13 68 62 106 87 19 98 32 81 63 79 93 31 121 123 75 52 11 66 41 54 87 38 5 104 62 51 38 55 29 31 120 44 16 48 94 46 105 91 66 78 27 43 6 64 2 55 79 75 84 113 22 4 113 109 31 33 17 96 11 29 63 98 103 107 116 34 14 9 95 38 18 51 75 33 109 118 55 66 4 76 7 75 70 82 74 23 1 26 69 40 112 99 47 65 31 70 119 52 103 88 85 86 28 16 12 76 25 22 78 64 21 86 27 61 77 72 108 2 18 106 119 121 54 16 85 72 2 73 26 88 66 60 80 35 24 117 63 24 44 67 52 122 119 33 72 16 99 98 69 54 19 42 28 53 114 32 117 81 100 57 49 123 56 21 68 80 53 95 1 45 95 107 98 87 1 27 24 99 116 16 67 1 113 91 84 25 40 25 72 3 28 90 87 112 80 16 117 45 77 36 90 105 59 88 122 64 108 108 71 98 18 50 115 93 105 77 35 6 46 55 47 102 4 26 87 111 120 81 113 4 57 105 3 84 94 115 61 73 ^'}}, + {OUT=>'E9A021C3EB0B9F2C710554D4BF21B19F78E09478'}], + ['145', {IN=> {f=> '255 1 91 47 51 9 57 9 55 94 61 61 68 46 107 6 35 81 114 78 96 74 14 89 73 67 67 69 113 107 11 98 113 109 20 92 17 67 70 88 57 10 124 9 60 122 93 91 45 7 15 24 51 5 98 115 24 49 90 104 117 66 128 94 64 80 12 43 91 46 111 59 58 77 30 14 88 60 123 68 41 44 68 40 104 118 41 43 93 90 105 92 16 127 26 54 125 114 79 71 24 48 21 25 118 40 103 49 91 44 67 65 25 119 109 18 48 23 69 112 38 61 64 87 84 104 119 110 122 92 22 1 8 83 34 100 32 62 41 46 112 34 102 76 56 39 4 127 30 13 19 110 124 7 16 128 95 4 124 11 104 116 126 49 95 3 55 96 70 90 101 4 122 96 75 118 39 128 99 92 18 42 20 87 83 35 75 111 61 67 71 28 101 9 56 34 105 95 71 23 73 71 26 57 15 23 76 55 99 89 128 98 117 68 43 88 62 38 62 39 2 83 36 15 26 60 128 96 73 74 10 1 12 42 22 2 77 33 33 32 57 13 14 82 57 12 39 3 58 80 14 87 85 44 69 109 119 ^'}}, + {OUT=>'DF13573188F3BF705E697A3E1F580145F2183377'}], + ['146', {IN=> {f=> '283 0 102 55 53 41 60 88 25 67 58 76 44 22 68 118 108 40 95 96 81 90 85 28 77 18 11 37 72 93 60 110 124 119 95 131 91 37 109 126 8 73 69 72 80 17 83 5 76 20 32 15 10 1 103 18 22 116 98 9 51 104 102 44 33 15 12 24 31 89 1 6 28 101 8 64 72 106 30 5 52 89 111 39 108 64 85 17 57 124 22 105 78 115 3 40 108 66 108 77 128 103 44 35 38 13 95 10 111 63 98 117 61 51 126 69 96 70 70 59 39 13 97 33 112 2 77 7 123 70 83 29 66 67 49 79 19 104 115 14 60 2 55 40 71 33 28 114 51 91 17 46 45 128 57 87 62 25 115 38 50 55 90 74 8 51 102 79 43 94 36 122 94 12 41 36 25 104 91 24 7 99 80 30 126 32 63 122 107 114 27 28 79 41 12 35 51 115 122 70 22 79 65 2 88 27 17 59 15 23 44 57 5 65 6 26 78 80 125 93 84 100 45 22 129 68 36 111 74 118 11 50 42 120 47 21 8 86 112 26 67 60 99 45 93 47 8 38 59 52 56 124 20 82 18 117 24 18 46 106 19 117 26 41 47 45 130 7 15 1 4 5 100 10 85 50 44 11 48 92 119 108 42 118 125 ^'}}, + {OUT=>'188835CFE52ECFA0C4135C2825F245DC29973970'}], + ['147', {IN=> {f=> '272 0 8 61 99 70 96 20 87 123 134 82 22 2 110 118 33 86 5 7 5 94 56 15 60 96 54 13 22 55 99 4 25 105 17 37 69 10 38 117 117 30 70 13 9 109 115 62 94 52 66 117 100 135 7 75 23 5 81 110 31 118 29 1 62 11 41 88 109 119 102 37 3 30 123 47 31 56 134 29 124 116 118 99 21 56 77 91 23 37 135 81 44 51 67 95 51 133 30 57 67 116 122 48 100 7 132 97 106 69 93 4 95 125 102 103 119 81 57 133 96 37 118 50 117 113 81 127 17 45 103 32 121 129 60 43 65 127 30 36 132 110 52 53 35 71 12 76 22 72 130 112 99 76 26 21 73 63 63 97 23 58 115 132 114 1 132 31 35 18 23 54 30 53 118 37 35 84 94 60 100 3 47 18 110 105 87 57 63 76 43 52 45 46 49 65 12 10 42 66 60 117 34 19 92 5 28 76 9 126 101 125 32 38 34 15 7 62 32 21 3 43 69 31 109 123 51 116 135 130 129 130 63 14 57 80 62 15 126 31 105 83 108 120 80 124 46 98 105 91 6 6 27 7 58 128 78 7 79 63 84 77 74 128 65 61 95 121 17 24 123 117 51 122 ^'}}, + {OUT=>'41B615A34EE2CEC9D84A91B141CFAB115821950B'}], + ['148', {IN=> {f=> '284 0 44 71 43 20 126 58 53 47 98 18 19 119 93 29 70 39 94 112 44 115 135 98 82 10 67 29 102 113 68 80 19 75 1 91 114 87 80 7 40 37 86 120 16 104 136 117 82 138 32 65 114 119 137 121 8 12 46 126 26 119 73 130 60 76 113 100 14 133 26 116 34 120 80 95 84 53 15 24 44 51 4 10 23 77 24 99 66 37 54 63 42 136 21 34 76 5 17 128 101 1 59 40 113 112 32 97 31 93 105 79 91 18 39 1 103 132 51 68 124 111 13 97 43 128 69 84 85 72 15 12 26 87 16 16 92 101 13 77 4 118 89 103 56 42 16 60 44 39 126 46 18 83 93 41 105 3 82 106 115 91 6 4 54 115 15 120 109 113 48 41 9 95 20 62 67 105 111 25 132 7 116 46 138 44 83 61 124 131 35 107 6 109 81 114 67 41 137 77 56 74 73 34 12 14 69 52 11 98 47 54 83 81 6 1 15 88 35 139 80 83 49 89 27 47 130 92 133 87 51 112 76 49 109 49 57 93 73 22 117 50 64 58 97 139 36 131 111 133 58 33 8 88 55 38 90 46 30 118 57 29 82 74 41 117 38 46 94 92 5 105 15 117 70 103 68 60 120 48 21 110 85 40 81 66 ^'}}, + {OUT=>'AB3DD6221D2AFE6613B815DA1C389EEC74AA0337'}], + ['149', {IN=> {f=> '291 0 46 113 52 134 79 74 64 57 18 23 9 52 8 16 103 57 138 59 59 65 92 2 7 130 92 8 34 40 86 131 140 100 112 4 42 1 110 108 43 37 15 67 19 35 94 61 130 98 35 88 34 65 104 56 126 118 50 87 10 81 109 90 86 118 32 6 114 88 39 38 39 62 3 12 134 72 137 35 75 81 115 106 140 112 11 123 41 103 45 95 84 71 107 13 26 110 96 62 16 109 84 59 53 38 27 8 28 13 32 137 17 138 41 122 36 99 65 99 83 36 112 29 49 70 96 126 136 131 116 3 18 17 126 142 14 37 141 141 123 42 13 20 83 42 139 83 54 49 58 42 7 137 29 48 16 121 127 34 52 140 106 128 58 36 124 83 24 69 54 61 112 17 6 95 97 24 57 86 124 59 71 119 67 1 109 54 68 49 57 132 32 5 71 113 40 80 104 75 106 133 31 126 130 104 62 9 39 44 66 116 141 135 96 132 19 41 121 126 124 77 8 4 60 82 6 101 124 89 51 123 48 40 85 77 21 112 10 69 66 115 87 16 108 30 84 65 80 103 32 131 134 73 47 10 63 39 50 93 37 135 114 69 48 34 58 23 27 133 37 9 40 98 41 115 99 70 83 29 42 67 133 55 79 80 91 122 12 2 115 112 47 ^'}}, + {OUT=>'0706D414B4AA7FB4A9051AA70D6856A7264054FB'}], + ['150', {IN=> {f=> '293 1 33 13 99 138 1 42 89 118 87 113 99 12 134 142 100 38 5 55 75 14 110 108 42 64 130 79 138 62 64 69 57 11 123 25 59 16 111 94 24 65 30 51 119 48 107 92 84 69 28 136 143 54 20 6 70 47 142 64 4 65 59 73 99 134 146 102 125 116 57 137 137 72 48 128 78 5 80 63 54 85 30 22 129 68 21 21 74 28 128 107 27 60 2 93 95 71 37 11 37 15 39 102 3 104 65 80 59 52 113 34 20 67 60 27 81 135 46 106 106 102 68 128 17 15 100 124 15 43 136 122 100 67 142 35 14 53 120 2 89 93 99 73 9 122 39 77 15 96 90 43 79 134 60 92 105 55 96 31 119 77 97 72 23 140 38 30 43 83 136 88 107 117 72 109 118 58 91 119 73 95 100 59 138 123 54 49 143 50 133 66 106 45 80 88 42 93 5 59 77 101 74 110 104 40 92 19 77 76 86 102 129 3 144 101 139 134 56 90 18 91 94 85 55 10 137 11 58 1 107 113 70 22 7 56 29 143 111 8 46 45 116 122 129 89 7 121 53 95 14 49 118 62 125 91 37 97 15 35 100 63 140 63 50 51 58 26 127 6 45 59 102 121 114 85 141 135 10 72 19 106 66 66 41 53 13 38 1 21 103 50 108 46 119 ^'}}, + {OUT=>'3CBF8151F3A00B1D5A809CBB8C4F3135055A6BD1'}], + ['151', {IN=> {f=> '297 1 46 31 132 112 28 63 124 97 129 43 40 72 99 107 132 137 96 139 99 145 121 144 118 37 81 39 94 60 55 109 47 109 110 75 42 12 139 137 43 128 106 107 19 126 12 101 148 127 15 117 125 125 62 96 13 76 70 96 101 110 138 8 95 76 143 17 32 97 79 149 39 31 94 123 21 41 135 55 84 70 33 135 118 50 62 121 81 1 45 144 93 60 5 64 137 8 105 91 82 67 27 113 119 53 18 98 79 48 84 32 135 128 5 1 20 76 17 85 108 72 36 141 140 49 150 105 104 3 149 14 54 18 148 64 49 125 37 28 28 101 22 104 91 32 82 117 12 114 69 58 2 58 115 9 108 47 59 65 14 92 7 4 86 98 16 82 92 95 38 94 10 10 48 97 104 66 115 97 142 115 122 119 40 97 16 32 47 34 88 89 26 50 12 76 80 51 40 9 133 24 44 40 122 84 108 22 142 140 99 44 15 54 8 42 125 150 130 21 79 124 62 46 119 15 29 91 57 150 42 138 71 61 68 80 114 6 1 70 121 18 35 113 56 87 86 10 73 14 29 41 72 89 1 133 87 101 123 59 90 142 77 133 52 78 48 34 138 134 27 17 60 131 147 61 93 148 39 132 49 62 71 36 91 4 139 49 100 120 43 113 144 30 94 73 127 40 125 ^'}}, + {OUT=>'DA5D6A0319272BBCCEA63ACFA6799756FFDA6840'}], + ['152', {IN=> {f=> '313 1 35 97 95 76 105 88 32 138 30 69 61 40 47 21 107 6 39 81 114 53 125 53 147 14 4 73 146 96 98 13 136 11 98 117 138 153 67 146 71 99 88 7 139 24 13 35 47 97 145 74 36 119 3 51 84 48 119 53 49 15 79 17 120 103 148 64 30 41 97 120 75 111 63 58 131 134 18 13 10 48 18 16 48 43 15 54 18 41 47 122 144 80 92 145 77 1 33 89 54 46 78 48 21 54 43 40 53 24 16 73 42 94 29 44 34 151 152 23 123 12 142 140 43 37 88 29 19 35 72 96 151 130 62 112 34 36 91 120 50 112 138 2 105 60 68 137 131 5 17 19 139 74 11 120 78 149 58 128 15 104 16 126 78 20 57 134 71 49 90 76 108 126 100 54 68 39 132 153 42 147 146 124 62 87 35 75 61 65 46 100 82 105 113 31 63 5 95 54 71 77 127 150 80 36 144 2 130 59 74 39 3 152 121 122 18 117 12 117 141 118 135 62 36 69 5 39 53 150 52 153 143 30 66 96 126 131 56 137 8 7 86 142 14 7 111 141 93 136 137 134 43 12 89 23 44 9 152 146 121 97 19 38 110 91 67 14 32 110 66 68 8 130 84 73 118 59 24 41 72 121 150 55 37 138 27 104 66 124 9 51 109 47 125 109 148 8 29 47 72 146 149 61 93 10 20 54 15 76 133 125 106 110 67 ^'}}, + {OUT=>'FB4429C95F6277B346D3B389413758DFFFEEDC98'}], + ['153', {IN=> {f=> '330 0 23 9 26 136 27 51 115 122 44 106 6 146 108 113 85 51 8 96 47 56 137 62 59 89 143 71 140 14 85 156 139 99 154 30 53 115 35 147 108 148 58 52 28 103 19 92 95 152 152 10 11 13 155 67 11 83 101 69 153 152 45 141 14 120 129 140 119 59 2 89 73 70 83 29 16 67 81 29 1 54 65 96 117 2 37 47 128 33 3 89 108 98 139 49 78 27 103 39 119 94 132 90 38 132 55 65 131 90 58 2 54 100 69 118 22 44 19 7 148 93 25 29 123 81 64 131 55 30 1 89 38 97 82 64 9 28 86 123 151 10 133 40 154 102 4 111 65 9 63 59 124 116 72 105 76 57 137 97 32 145 108 78 112 50 43 34 75 20 22 129 68 11 118 74 125 118 57 17 20 129 53 65 61 144 1 17 142 156 52 100 54 15 20 59 52 63 131 20 57 124 31 125 46 106 76 92 8 98 154 152 80 114 15 140 136 112 100 17 92 25 151 150 80 99 69 83 49 43 156 102 19 57 122 96 30 3 39 134 40 32 75 5 76 127 138 99 17 57 52 150 130 18 127 33 23 116 107 78 77 77 42 69 68 48 41 69 33 75 40 49 128 103 4 146 93 10 83 66 96 152 30 38 12 33 5 39 47 41 34 60 74 20 42 156 67 46 56 102 89 3 124 81 99 104 56 50 8 61 74 55 15 87 108 28 138 47 93 60 2 124 46 126 103 91 145 36 25 116 122 51 ^'}}, + {OUT=>'2C6E30D9C895B42DCCCFC84C906EC88C09B20DE1'}], + ['154', {IN=> {f=> '322 0 75 7 107 158 81 105 154 90 20 125 77 114 69 92 7 58 21 98 154 50 128 149 117 127 153 45 3 18 121 86 29 71 79 101 2 5 22 143 10 27 53 146 157 148 112 33 22 80 123 24 147 1 112 82 159 63 74 97 109 33 151 32 89 87 132 117 46 129 59 115 91 114 118 37 21 9 94 60 25 89 47 79 110 55 12 143 99 87 43 88 56 57 160 76 12 71 128 77 146 117 95 105 42 66 3 76 20 76 101 100 118 149 45 26 143 148 32 57 39 129 19 31 84 123 1 152 135 5 54 30 13 125 68 30 62 101 51 142 5 94 83 20 116 24 107 109 105 91 42 17 27 93 69 3 139 68 79 38 84 2 85 128 126 122 131 46 17 35 98 42 26 111 100 29 120 55 84 114 109 145 14 18 138 14 9 85 7 18 129 91 2 94 51 133 82 87 123 64 39 8 103 38 75 110 78 7 9 45 115 42 138 135 86 78 16 62 52 75 159 54 151 121 149 77 74 16 85 47 102 105 82 119 10 67 137 153 148 135 28 49 26 151 153 36 80 11 130 113 24 44 30 102 24 58 133 122 140 99 24 156 54 119 42 115 140 90 132 19 94 2 157 99 136 19 71 7 130 153 108 51 21 58 70 74 137 1 40 111 149 5 103 6 27 76 141 23 125 140 1 72 29 152 103 87 51 93 29 80 132 77 123 153 68 159 14 98 114 158 121 158 81 131 ^'}}, + {OUT=>'3DE3189A5E19F225CDCE254DFF23DACD22C61363'}], + ['155', {IN=> {f=> '322 0 35 93 109 125 119 10 10 19 135 26 4 74 135 35 120 129 113 92 17 29 47 88 14 159 149 87 45 36 75 68 22 138 20 59 61 144 151 11 107 6 153 81 114 43 85 157 97 148 118 73 126 56 58 137 96 11 98 67 98 103 57 146 21 59 88 151 139 148 127 25 17 47 115 34 160 109 107 51 64 28 69 13 49 149 69 141 90 93 118 64 10 1 67 80 35 111 13 58 101 124 132 147 154 18 162 6 162 33 5 34 142 41 161 82 114 70 92 145 57 155 137 114 79 44 36 48 48 21 14 13 40 33 14 150 33 32 54 143 14 4 101 142 23 93 136 132 120 147 17 38 163 143 5 52 46 151 130 32 72 34 124 150 51 100 112 128 126 65 10 28 87 81 159 131 19 99 54 125 110 58 119 28 78 129 104 140 126 38 154 27 114 61 153 90 66 98 76 50 158 48 39 82 123 22 147 136 114 52 37 35 75 41 15 150 60 52 55 103 21 23 129 95 24 71 47 97 130 50 140 144 106 100 9 64 19 117 122 71 92 8 77 156 97 121 98 85 2 36 39 109 143 23 120 156 133 93 154 36 66 116 131 160 127 162 161 46 142 14 141 81 141 63 86 117 104 3 146 39 127 34 133 102 106 91 57 9 28 60 61 7 158 12 80 26 8 122 80 44 63 68 49 158 21 32 81 150 15 141 108 161 64 46 124 123 31 99 27 105 109 98 112 144 ^'}}, + {OUT=>'93530A9BC9A817F6922518A73A1505C411D05DA2'}], + ['156', {IN=> {f=> '336 1 34 161 107 149 48 67 138 109 156 104 37 133 60 80 84 81 160 9 16 96 164 1 95 112 4 86 163 116 98 103 55 31 8 56 37 36 127 32 9 89 103 31 100 161 85 106 119 89 154 43 115 162 137 108 128 38 42 155 103 9 62 65 102 122 10 138 160 125 47 158 43 91 69 123 132 35 121 4 110 89 130 69 29 139 69 53 70 83 29 163 67 41 9 108 34 45 76 87 2 144 164 98 33 160 79 78 48 89 9 38 134 93 146 79 54 122 80 38 112 55 55 101 70 8 129 44 70 59 98 149 24 136 124 138 63 25 166 83 51 34 91 45 30 118 59 28 87 72 44 116 28 36 103 101 113 10 114 62 111 71 65 126 53 19 114 86 42 85 36 57 137 57 159 95 88 78 72 20 23 14 65 10 22 129 68 1 68 74 75 108 7 7 147 109 13 35 51 104 158 164 122 126 2 50 4 132 127 59 52 13 81 20 47 107 74 148 115 46 106 46 82 115 68 144 142 60 104 15 90 136 102 100 134 42 15 141 100 40 49 49 73 166 13 156 82 166 37 82 96 137 130 166 134 20 139 45 122 56 107 98 79 124 17 32 130 120 165 77 23 130 96 67 68 47 37 12 29 18 38 158 19 160 55 147 39 118 83 121 96 43 137 33 66 86 112 147 155 149 140 5 19 17 148 161 10 44 159 146 57 16 26 102 49 3 104 61 59 74 56 10 165 31 54 25 142 157 37 58 165 128 154 73 50 149 94 137 ^'}}, + {OUT=>'E31354345F832D31E05C1B842D405D4BD4588EC8'}], + ['157', {IN=> {f=> '330 1 61 51 65 132 23 169 116 122 14 66 7 98 131 72 69 127 72 163 125 68 69 51 47 159 31 164 71 118 50 83 113 81 127 153 45 137 134 121 68 163 26 43 65 127 166 138 98 144 18 53 137 139 148 76 158 4 62 78 167 102 144 94 55 141 63 29 97 91 24 115 166 80 69 132 99 1 120 23 88 64 87 118 37 137 152 94 60 168 71 47 52 110 37 155 125 63 42 43 52 11 12 151 31 12 44 110 32 128 117 68 87 24 39 164 76 145 58 101 91 100 140 151 143 130 32 21 3 111 1 31 75 123 153 116 135 130 27 164 165 116 23 12 62 83 24 133 139 49 74 154 80 158 80 64 105 91 6 142 27 75 24 128 112 41 79 29 84 145 40 128 99 95 95 19 17 160 89 15 17 84 64 11 93 10 66 78 73 127 148 18 129 139 143 49 150 9 84 82 154 85 15 88 82 60 87 19 12 133 58 20 39 65 51 141 134 27 70 167 120 117 86 60 16 44 16 57 132 18 142 85 104 59 47 141 58 2 66 96 46 119 153 40 110 126 103 90 144 13 26 106 144 80 145 134 103 95 24 44 21 84 140 13 97 104 140 99 6 147 54 83 42 106 131 54 96 135 67 118 121 81 109 10 53 132 112 117 81 33 155 49 61 38 119 1 13 102 131 148 94 131 143 67 123 148 89 104 135 72 145 152 76 87 6 66 2 71 123 77 114 108 59 123 166 62 96 140 94 149 116 169 ^'}}, + {OUT=>'3FF76957E80B60CF74D015AD431FCA147B3AF232'}], + ['158', {IN=> {f=> '349 0 125 17 93 82 80 110 156 147 156 99 154 4 29 90 163 120 84 113 56 8 157 29 61 169 141 113 78 48 50 13 138 11 50 61 99 106 2 107 6 117 81 114 34 49 112 52 130 82 73 108 20 22 110 60 11 98 22 62 58 48 146 149 23 88 142 139 121 91 16 163 2 88 171 133 100 62 51 46 10 24 150 49 131 60 114 63 84 91 64 165 138 40 44 172 111 141 58 74 115 96 129 145 164 153 170 126 24 169 16 115 41 125 46 87 61 92 145 39 155 92 78 70 35 27 21 48 21 151 159 40 15 5 132 170 23 18 107 160 150 56 133 23 66 109 123 102 102 172 166 145 116 151 34 1 151 130 5 36 34 97 114 15 82 128 112 119 99 29 138 165 42 36 159 95 19 63 36 89 101 40 92 1 33 93 104 113 126 2 136 96 52 108 90 57 89 31 5 113 30 39 37 96 4 147 127 105 43 165 35 75 23 143 105 24 25 10 94 12 160 102 95 170 71 20 70 112 23 95 144 61 73 137 55 1 81 95 26 65 172 41 147 79 103 80 40 121 36 12 64 98 169 93 111 115 48 127 9 39 107 131 115 118 162 161 10 142 14 123 54 141 36 41 99 77 140 128 167 82 25 106 57 70 64 21 19 15 34 126 149 167 53 163 127 86 35 8 54 23 40 140 3 169 45 150 152 96 81 143 28 28 124 87 13 90 9 87 109 53 67 164 28 131 89 149 42 55 126 79 132 74 19 133 30 68 72 75 148 9 10 72 152 144 83 106 153 74 163 98 152 ^'}}, + {OUT=>'34AE3B806BE143A84DCE82E4B830EB7D3D2BAC69'}], + ['159', {IN=> {f=> '375 1 94 28 13 8 20 28 18 118 5 140 89 67 171 64 152 85 61 101 80 154 149 34 115 135 128 108 110 20 33 128 103 35 38 57 95 10 111 151 98 29 149 7 82 69 96 114 26 103 171 101 53 121 24 2 121 51 35 70 83 29 154 67 5 167 63 16 27 58 60 2 99 128 71 33 160 70 51 3 44 149 2 89 84 101 43 18 113 71 38 94 55 46 74 52 139 102 35 43 50 80 122 6 100 88 129 36 25 148 47 24 7 55 36 30 82 32 19 78 63 26 71 28 167 85 56 167 95 159 78 26 66 35 65 90 44 159 105 59 15 67 57 137 21 132 50 70 78 36 169 5 172 56 1 22 129 68 168 23 74 30 99 138 174 120 91 153 8 42 68 158 155 104 99 133 5 135 96 82 59 52 144 36 20 38 62 29 112 106 46 106 19 73 70 41 135 133 42 95 15 45 136 93 100 98 173 6 132 55 4 4 31 64 130 162 156 64 157 19 46 96 92 103 139 134 2 94 18 86 38 89 62 61 79 157 14 112 111 156 32 14 85 78 31 59 20 1 161 169 149 29 122 150 133 37 102 30 109 65 85 51 174 110 164 66 77 76 111 119 131 95 5 1 166 103 134 141 17 158 123 137 48 165 175 102 13 3 86 43 23 47 56 150 165 4 36 174 115 157 168 13 147 119 109 55 41 140 67 27 31 27 53 126 17 163 116 122 160 60 7 92 113 66 45 109 60 151 125 62 39 39 17 153 13 152 53 94 50 53 89 57 127 153 45 119 104 121 56 145 172 19 41 103 166 108 68 126 12 53 131 127 148 52 134 168 50 48 155 72 132 82 37 129 63 175 160 ^'}}, + {OUT=>'D7447E53D66BB5E4C26E8B41F83EFD107BF4ADDA'}], + ['160', {IN=> {f=> '366 1 73 15 79 139 71 51 132 81 135 111 166 61 37 60 118 37 92 134 94 60 150 53 47 25 110 19 137 107 27 176 43 16 145 146 142 165 12 17 92 166 110 117 41 69 6 12 164 76 109 40 101 82 82 131 134 115 143 112 32 164 146 93 162 31 66 123 144 80 135 94 137 156 107 157 173 62 65 176 124 112 4 65 127 44 131 53 19 105 91 149 106 27 57 158 92 85 14 79 20 84 127 174 128 72 68 59 171 17 124 80 167 8 57 28 172 66 144 48 42 37 109 121 18 120 103 116 13 132 39 73 145 76 158 43 82 33 51 153 164 97 13 2 3 20 24 114 98 9 25 131 102 99 86 42 16 26 159 39 105 161 133 49 59 41 20 105 31 136 30 87 10 119 135 13 83 99 58 45 99 156 26 61 135 143 80 118 107 76 77 24 44 12 66 95 147 61 86 140 99 167 138 54 47 42 97 122 18 60 90 40 73 85 63 82 1 35 96 94 81 54 15 128 40 52 2 101 1 165 93 113 130 85 95 98 58 105 112 53 68 108 72 100 152 49 87 140 39 154 62 114 77 105 63 50 87 157 26 78 122 67 140 71 170 119 5 93 64 50 104 144 129 138 75 130 4 178 60 139 120 54 113 32 2 133 17 43 163 129 89 72 149 155 30 38 7 138 5 44 61 69 76 175 107 6 93 81 114 28 25 82 22 118 58 73 96 175 177 92 36 11 98 171 38 28 42 146 125 178 88 136 139 103 67 10 151 151 70 153 115 94 32 51 34 177 173 132 49 119 54 96 45 78 73 64 159 120 22 20 154 111 117 58 56 109 72 143 ^'}}, + {OUT=>'77DD2A4482705BC2E9DC96EC0A13395771AC850C'}], + ['161', {IN=> {f=> '372 1 136 146 144 170 90 15 169 180 88 41 89 10 60 52 92 145 21 155 47 42 61 26 18 176 48 21 124 141 40 179 178 114 143 14 164 71 142 132 11 124 23 39 82 114 84 57 163 130 127 89 133 16 138 151 130 160 34 70 78 161 64 92 112 110 72 175 102 138 179 173 159 59 19 27 18 53 92 22 65 156 170 57 104 86 126 148 118 155 78 43 63 90 48 80 168 142 68 12 39 174 69 168 147 118 96 34 129 35 75 5 107 60 170 180 147 85 3 133 75 95 152 71 175 43 94 178 50 144 16 46 101 46 165 45 68 163 38 172 5 138 61 85 62 177 76 36 167 19 53 151 66 66 97 3 100 164 12 98 131 70 109 162 161 156 142 14 105 27 141 9 178 81 50 113 110 131 37 16 79 12 34 37 167 173 10 152 7 81 140 158 26 136 82 50 172 154 45 160 31 122 167 142 9 150 125 51 54 125 174 10 124 51 177 81 173 69 109 8 22 155 19 86 62 149 33 37 108 34 96 29 174 133 167 50 54 66 130 9 1 36 134 108 65 97 126 56 163 71 83 88 10 1 8 178 22 6 112 169 116 89 43 153 40 146 85 31 89 74 154 137 28 115 117 122 108 98 8 27 110 103 176 17 20 27 77 10 93 145 80 17 143 165 76 69 78 102 20 91 171 95 29 115 176 166 109 39 23 70 83 29 148 67 163 161 33 4 15 46 42 2 69 104 53 33 160 64 33 155 14 131 160 59 78 71 19 176 107 65 38 82 55 40 56 40 115 84 29 25 44 68 104 176 76 64 123 18 25 136 23 6 171 31 30 30 58 14 13 72 57 14 41 177 ^'}}, + {OUT=>'EAA1465DB1F59DE3F25EB8629602B568E693BB57'}], + ['162', {IN=> {f=> '363 0 135 69 16 167 79 143 46 178 26 3 65 58 36 135 97 35 175 51 152 57 137 173 108 10 54 78 4 153 173 164 48 177 22 129 68 168 167 74 174 91 106 174 96 75 129 168 34 36 158 147 88 75 101 149 103 64 42 59 52 112 180 20 30 22 173 80 98 46 106 179 65 30 17 127 125 26 87 15 5 136 85 100 66 141 182 124 15 156 148 15 56 98 146 156 48 149 3 14 96 52 79 115 134 170 54 178 54 22 73 30 45 39 133 182 96 103 148 176 6 45 62 183 51 180 153 145 145 117 21 90 118 109 21 62 22 101 49 53 11 142 86 132 66 69 44 79 87 115 55 5 169 150 63 110 109 177 150 91 129 40 149 159 102 165 3 70 27 175 23 56 126 165 164 20 158 91 157 136 157 131 111 69 39 33 132 43 19 175 179 37 118 9 155 116 122 128 52 7 84 89 58 13 85 44 135 125 54 183 23 161 145 173 136 29 62 50 13 57 25 127 153 45 95 64 121 40 121 140 171 9 71 166 68 28 102 4 53 123 111 148 20 102 160 34 8 139 32 116 66 13 113 63 143 97 63 10 59 124 66 41 132 71 115 106 151 46 22 45 118 37 67 124 94 60 140 43 47 10 110 9 127 97 7 156 43 180 125 126 137 145 12 2 82 146 100 117 26 59 180 181 164 76 89 30 101 77 72 126 114 95 143 102 32 149 131 83 157 31 61 123 139 60 135 74 169 122 151 102 137 168 62 55 166 119 97 163 60 112 24 116 38 178 105 91 134 86 27 47 138 72 70 183 79 15 84 117 154 128 57 53 39 161 88 ^'}}, + {OUT=>'9329D5B40E0DC43AA25FED69A0FA9C211A948411'}], + ['163', {IN=> {f=> '393 1 92 72 151 33 183 164 42 112 32 10 5 93 97 18 112 71 92 168 116 179 186 65 137 68 134 3 82 9 19 121 148 65 160 173 158 167 90 66 180 172 99 86 83 86 26 16 10 135 23 81 137 125 17 19 25 183 73 7 104 185 79 165 119 119 176 59 75 18 5 59 132 26 21 127 119 80 94 83 52 61 24 44 4 50 55 115 29 70 140 99 159 130 54 15 42 89 114 173 28 50 16 33 53 47 58 180 19 64 78 49 30 186 104 32 44 157 85 1 149 85 97 114 77 63 58 50 89 80 21 36 84 72 60 152 25 87 108 15 138 54 106 77 97 23 42 55 149 181 62 106 43 132 31 138 111 176 93 40 10 96 128 105 114 43 98 4 146 20 107 120 14 113 181 101 1 19 155 113 57 64 117 131 6 22 186 138 184 36 61 29 36 175 107 6 61 81 114 20 180 42 169 102 26 73 80 151 153 68 4 11 98 139 6 175 34 146 93 154 88 128 139 79 35 2 135 119 46 129 91 86 179 51 18 169 141 108 49 103 46 72 21 70 49 64 151 96 185 175 130 111 85 58 32 101 40 101 131 136 139 170 70 10 169 175 73 41 69 177 45 47 92 145 11 155 22 22 56 21 13 166 48 21 109 131 40 174 178 104 128 9 149 51 132 122 173 119 23 24 67 109 74 32 158 110 117 74 123 6 118 151 130 150 167 34 55 58 146 54 72 112 105 57 160 82 123 159 153 159 39 19 7 8 33 87 12 50 146 150 37 104 71 126 133 108 145 68 38 38 90 43 75 148 122 43 2 39 154 54 163 147 113 91 29 109 35 75 182 87 35 155 170 127 80 185 118 60 95 142 71 165 28 84 168 25 144 178 31 81 41 160 25 53 143 ^'}}, + {OUT=>'E94C0B6AA62AA08C625FAF817DDF8F51EC645273'}], + ['164', {IN=> {f=> '381 1 14 172 163 130 45 69 46 145 36 36 151 169 13 135 42 26 81 153 76 148 178 90 131 30 101 162 161 132 142 14 89 3 141 175 146 65 26 89 94 99 187 8 55 162 2 13 143 173 2 120 173 41 132 150 2 112 42 18 140 130 37 128 23 106 159 118 167 150 101 11 30 109 150 184 124 19 169 73 165 53 109 158 172 147 11 46 38 149 25 21 92 184 64 179 158 133 135 34 38 58 114 9 183 4 118 76 49 89 102 40 163 47 75 80 176 175 8 154 14 180 104 153 84 89 11 129 8 138 85 181 73 66 154 121 20 115 93 114 108 82 182 19 86 103 176 183 186 177 53 10 69 137 56 1 135 141 68 69 54 86 12 75 171 87 187 107 144 150 93 23 7 70 83 29 140 67 139 153 183 178 189 30 18 2 29 72 29 33 160 56 9 123 164 107 136 19 70 31 177 152 99 57 38 66 55 32 32 24 83 60 21 1 36 52 80 168 44 32 115 184 25 120 181 172 155 189 22 30 26 180 5 64 49 188 1 28 111 57 176 167 67 131 22 160 186 169 65 34 30 117 91 17 163 39 134 57 137 155 90 170 42 78 170 141 167 158 42 177 22 129 68 168 143 74 150 85 82 174 78 63 111 156 28 12 158 141 76 57 77 125 79 40 12 59 52 88 156 20 24 182 149 56 92 46 106 167 59 189 121 119 14 81 15 165 136 79 100 42 117 182 118 175 138 124 3 50 74 134 156 36 143 181 180 96 22 61 97 134 164 24 166 30 10 61 6 33 9 115 176 84 97 142 152 15 50 165 45 168 135 133 127 93 15 66 94 91 9 32 16 95 37 29 171 118 68 108 66 63 20 55 186 ^'}}, + {OUT=>'7FF02B909D82AD668E31E547E0FB66CB8E213771'}], + ['165', {IN=> {f=> '396 1 97 10 5 160 132 18 83 73 159 141 55 120 31 131 141 102 138 3 52 9 148 189 56 99 165 146 2 140 64 157 100 121 113 102 24 21 24 123 16 10 139 152 19 109 146 116 122 92 43 7 75 62 49 170 58 26 117 125 45 147 5 125 136 155 118 2 26 50 161 21 182 127 153 45 68 19 121 22 94 104 144 166 35 166 23 176 75 188 53 114 93 148 177 66 151 16 156 121 180 98 48 179 95 63 107 97 45 1 23 97 57 23 132 53 79 97 124 19 188 18 118 37 22 106 94 60 122 25 47 176 110 184 109 79 164 120 43 153 89 90 128 109 12 168 64 110 82 117 192 41 171 163 164 76 53 12 101 68 54 117 78 59 143 84 32 122 104 65 148 31 52 123 130 24 135 38 151 95 142 93 101 159 62 37 148 110 70 127 51 85 181 89 11 142 105 91 107 50 27 29 102 36 43 165 79 6 84 99 118 128 30 26 3 143 17 68 66 139 187 15 165 158 24 88 20 179 174 81 79 18 106 47 74 150 104 179 162 59 131 62 116 166 82 184 188 97 136 41 136 167 140 143 175 72 42 174 148 75 74 71 86 14 16 191 117 11 63 119 119 186 182 13 171 49 182 80 167 73 147 119 107 164 41 57 181 168 29 114 26 184 121 101 80 76 65 34 49 24 44 191 38 25 91 5 58 140 99 153 124 54 184 42 83 108 155 4 20 191 3 29 35 40 180 7 40 66 25 12 180 86 26 38 139 73 1 137 79 85 102 71 39 28 44 77 56 190 12 66 72 30 152 7 87 84 190 126 48 100 77 91 186 36 31 143 163 50 94 25 126 1 114 105 170 93 22 173 90 116 87 96 19 74 4 122 183 83 120 177 113 169 181 77 182 1 149 186 ^'}}, + {OUT=>'5BB3570858FA1744123BAC2873B0BB9810F53FA1'}], + ['166', {IN=> {f=> '384 1 25 56 85 107 177 6 186 138 184 28 61 184 191 175 107 6 29 81 114 12 156 2 137 86 189 73 64 127 129 44 167 11 98 107 169 143 26 146 61 130 88 120 139 55 3 189 119 87 22 105 67 78 147 51 2 161 109 84 49 87 38 48 192 62 25 64 143 72 169 151 106 111 53 58 8 93 8 85 123 120 131 170 38 2 169 167 49 41 37 153 21 39 92 145 190 155 177 185 48 13 5 150 48 21 85 115 40 166 178 88 104 1 125 19 116 106 141 111 23 43 101 58 187 150 78 101 50 107 185 86 151 130 134 143 34 31 26 122 38 40 112 97 33 136 50 99 127 121 159 7 19 170 187 1 79 191 26 130 118 5 104 47 126 109 92 129 52 30 193 90 35 67 116 90 3 181 39 122 30 155 147 105 83 21 77 35 75 174 55 190 131 154 95 72 185 94 36 95 126 71 149 4 68 152 180 144 146 7 49 33 152 188 29 111 194 172 148 125 35 59 36 125 11 36 141 149 183 125 27 1 71 133 61 138 168 85 131 5 96 162 161 117 142 14 79 183 141 165 126 55 11 74 84 79 167 3 40 142 177 193 128 173 192 100 163 16 127 145 182 97 17 193 120 115 32 108 18 96 154 103 152 150 86 181 15 99 135 179 124 194 164 68 160 43 109 138 152 142 6 21 23 149 20 11 82 164 44 159 148 133 115 24 28 53 104 9 183 179 108 56 39 84 87 30 163 32 70 75 166 170 8 139 9 175 99 143 64 89 186 114 183 133 85 161 63 61 154 111 15 115 78 109 108 72 177 14 71 103 176 173 176 157 38 10 54 132 41 186 130 126 63 69 39 76 7 65 171 82 172 102 124 140 83 113 ^'}}, + {OUT=>'905F43940B3591CE39D1145ACB1ECA80AB5E43CD'}], + ['167', {IN=> {f=> '396 1 189 70 83 29 132 67 115 145 151 170 181 14 192 2 187 40 5 33 160 48 183 91 132 83 112 177 62 189 153 128 91 49 38 50 55 24 8 8 51 36 13 175 28 36 56 160 12 107 168 25 104 157 156 139 165 14 30 192 164 195 56 41 180 159 28 79 41 144 167 51 115 188 136 154 145 65 2 22 93 83 191 147 23 110 57 137 131 66 138 26 78 146 125 159 150 34 177 22 129 68 168 111 74 118 77 50 174 54 47 87 140 20 178 158 133 60 33 45 93 47 8 170 59 52 56 124 20 16 150 117 24 84 46 106 151 51 158 173 113 111 196 73 15 133 136 71 100 10 85 182 110 143 114 92 185 42 42 118 156 20 135 173 156 96 180 37 73 134 156 182 150 196 192 45 172 17 167 91 168 68 89 134 120 190 173 34 141 37 152 111 117 103 61 7 34 62 67 191 190 8 87 21 195 139 86 44 76 66 55 186 23 31 87 183 5 155 122 191 68 53 149 136 35 115 26 121 131 102 123 3 42 197 133 179 56 84 165 136 190 130 49 157 80 101 103 97 197 11 19 118 1 5 119 137 9 104 193 141 116 122 72 38 7 70 47 44 155 43 16 107 125 40 127 193 105 131 145 108 185 6 50 141 1 167 127 153 45 53 192 121 12 79 84 129 151 15 166 196 156 60 188 53 109 83 148 162 46 146 6 136 111 160 88 38 169 85 63 87 97 35 194 3 82 52 13 132 43 59 92 109 4 178 3 118 37 195 96 94 60 112 15 47 166 110 179 99 69 149 100 43 138 69 70 123 89 12 158 54 90 72 117 182 31 166 153 164 76 33 2 101 63 44 112 58 39 143 74 32 107 89 55 143 31 47 123 125 4 135 18 141 80 137 88 81 154 187 ^'}}, + {OUT=>'336C79FBD82F33E490C577E3F791C3CBFE842AFF'}], + ['168', {IN=> {f=> '406 0 23 134 103 49 99 44 64 160 68 190 114 105 91 86 22 27 15 74 8 22 151 79 199 84 85 90 128 9 5 175 129 17 40 59 125 187 194 144 151 3 60 6 158 153 67 58 18 99 19 53 129 90 179 134 52 124 55 95 138 82 170 167 69 122 13 108 160 119 115 161 51 14 167 120 47 60 57 86 16 184 96 197 42 98 112 165 154 199 157 21 168 52 146 66 126 119 93 150 20 36 153 140 194 93 26 156 114 80 80 55 44 13 35 24 44 191 24 190 63 177 44 140 99 146 117 54 163 42 76 101 134 176 185 177 168 1 21 19 180 193 12 52 197 191 173 65 19 31 118 59 1 123 72 71 88 64 11 193 37 63 28 169 184 45 72 195 152 186 87 56 176 112 41 93 77 84 158 29 3 136 142 36 80 4 119 166 86 98 163 93 1 145 83 102 66 75 191 46 4 94 155 55 120 149 113 148 181 49 175 180 142 87 5 51 65 92 167 196 186 138 184 23 61 164 171 175 107 6 9 81 114 7 141 177 117 76 174 73 54 112 114 29 152 11 98 87 154 123 21 146 41 115 88 115 139 40 183 189 109 67 7 90 52 73 127 51 192 156 89 69 49 77 33 33 182 57 10 64 138 57 159 136 91 111 33 58 193 88 188 75 118 110 126 170 18 197 169 162 34 41 17 138 6 34 92 145 185 155 157 170 43 8 140 48 21 70 105 40 161 178 78 89 196 110 199 106 96 121 106 23 185 28 96 48 167 145 58 91 35 97 180 66 151 130 124 128 34 16 6 107 28 20 112 92 18 121 30 84 107 101 159 187 19 155 182 181 74 186 11 120 98 185 104 32 126 94 82 119 42 25 173 90 30 62 96 70 178 176 39 102 15 150 147 100 78 16 57 35 75 169 35 170 116 144 75 146 ^'}}, + {OUT=>'5C6D07A6B44F7A75A64F6CE592F3BAE91E022210'}], + ['169', {IN=> {f=> '409 1 185 70 12 95 110 71 133 183 52 136 148 144 114 186 17 25 144 164 5 79 178 172 124 117 19 43 20 93 174 36 125 117 151 109 3 164 55 101 37 122 152 77 131 168 88 162 161 93 142 14 63 167 141 149 94 39 190 50 68 47 135 198 16 110 153 177 104 173 192 68 147 179 119 137 166 73 180 169 88 91 24 76 10 80 146 79 128 150 62 149 194 83 111 171 124 170 156 60 152 27 109 106 120 134 201 184 202 149 12 198 66 132 12 127 132 133 83 8 12 45 88 9 183 155 92 24 23 76 63 14 163 8 62 67 150 162 8 115 1 167 91 127 32 89 162 90 159 125 85 129 47 53 154 95 7 115 54 101 108 56 169 6 47 103 176 157 160 125 14 10 30 124 17 178 122 102 55 69 15 60 202 49 171 74 148 94 92 124 67 200 184 70 83 29 127 67 100 140 131 165 176 4 182 2 167 20 193 33 160 43 173 71 112 68 97 157 57 169 138 113 86 44 38 40 55 19 196 201 31 21 8 165 23 26 41 155 195 183 102 158 25 94 142 146 129 150 9 30 177 154 195 51 36 175 139 28 59 31 124 167 41 105 173 121 134 130 65 185 17 78 78 181 137 13 95 57 137 116 51 118 16 78 131 115 154 145 29 177 22 129 68 168 91 74 98 72 30 174 39 37 72 130 15 163 158 128 50 18 25 73 27 191 150 59 52 36 104 20 11 130 97 4 79 46 106 141 46 138 163 108 106 191 68 15 113 136 66 100 193 65 182 105 123 99 72 180 37 22 108 156 10 130 168 141 96 160 22 58 134 151 162 140 181 187 35 157 7 147 76 163 58 84 129 100 190 153 24 126 32 142 96 107 88 41 2 14 42 52 186 170 3 82 11 180 119 66 29 56 66 50 171 3 11 77 163 5 150 112 128 ^'}}, + {OUT=>'7E0D3E9D33127F4A30EB8D9C134A58409FA8695B'}], + ['170', {IN=> {f=> '413 1 47 25 135 129 7 108 19 107 117 102 102 3 28 190 112 165 56 63 165 122 183 116 28 157 52 73 89 90 169 202 12 111 185 203 91 116 200 97 193 134 116 122 44 31 7 63 26 37 134 22 2 93 125 33 99 186 77 124 131 94 171 183 50 113 178 146 127 153 45 32 164 121 203 58 56 108 130 192 166 168 128 39 188 53 102 69 148 141 18 139 197 108 97 132 74 24 155 71 63 59 97 21 194 180 61 45 204 132 29 31 85 88 188 164 187 118 37 167 82 94 60 98 1 47 152 110 172 85 55 128 72 43 117 41 42 116 61 12 144 40 62 58 117 168 17 159 139 164 76 5 193 101 56 30 105 30 11 143 60 32 86 68 41 136 31 40 123 118 181 135 195 127 59 130 81 53 147 62 13 124 98 34 79 39 49 145 53 180 94 105 91 71 2 27 5 54 193 7 141 79 199 84 75 70 128 199 195 160 119 17 20 54 115 187 184 129 146 193 40 201 143 138 57 43 18 94 204 38 114 80 179 114 47 119 50 80 118 82 160 152 49 112 198 88 155 104 95 151 36 199 162 100 27 50 47 86 195 16 179 81 192 27 83 107 150 134 194 147 1 158 32 131 61 111 119 83 140 5 21 133 120 174 78 26 136 109 65 80 40 29 203 25 24 44 191 14 170 43 162 34 140 99 141 112 54 148 42 71 96 119 161 165 167 148 186 11 4 180 188 197 42 182 181 168 50 14 26 103 49 1 113 67 61 78 59 196 173 32 53 8 154 169 30 72 175 152 176 87 36 166 102 36 88 77 79 138 24 188 131 127 26 70 194 114 146 66 93 158 93 191 125 78 92 51 60 176 26 4 74 135 35 120 129 113 133 181 29 170 170 137 77 190 46 45 77 157 191 186 138 184 18 61 144 151 175 107 6 194 81 114 2 126 110 ^'}}, + {OUT=>'9A5F50DFCFB19286206C229019F0ABF25283028C'}], + ['171', {IN=> {f=> '427 1 85 60 150 73 38 88 90 5 128 11 98 55 130 91 13 146 9 91 88 107 139 16 159 189 93 35 191 66 28 65 95 51 184 148 57 45 49 61 25 9 166 49 194 64 130 33 143 112 67 111 1 58 177 80 164 59 110 94 118 170 194 197 169 154 10 41 193 114 190 26 92 145 177 155 125 146 35 200 124 48 21 46 89 40 153 178 62 65 196 86 175 90 80 89 98 23 169 4 88 32 135 137 26 75 11 81 172 34 151 130 108 104 34 200 182 83 12 196 112 84 202 97 206 60 75 69 159 163 19 131 174 157 66 178 195 104 66 161 104 8 126 70 66 103 26 17 141 90 22 54 64 38 146 168 39 70 199 142 147 92 70 8 25 35 75 161 3 138 92 128 43 59 185 55 205 95 100 71 123 173 42 126 128 144 94 176 205 20 139 149 198 59 168 172 109 112 9 33 10 73 154 36 115 97 131 99 196 144 45 81 22 112 142 72 131 148 83 162 161 78 142 14 53 157 141 139 74 29 180 35 58 27 115 198 1 90 138 167 89 173 192 48 137 159 114 132 156 58 160 154 68 76 19 56 5 70 141 64 113 150 47 129 184 73 96 166 124 155 151 55 147 17 109 86 100 129 201 164 192 149 7 193 56 112 200 107 122 133 63 206 2 40 78 9 183 140 82 4 13 71 48 4 163 201 57 62 140 157 8 100 204 162 86 117 12 89 147 75 144 120 85 109 37 48 154 85 2 115 39 96 108 46 164 1 32 103 176 147 150 105 207 10 15 119 2 173 117 87 50 69 50 202 39 171 69 133 89 72 114 57 195 179 70 83 29 122 67 85 135 111 160 171 202 172 2 147 183 33 160 38 163 51 92 53 82 137 52 149 123 98 81 39 38 30 55 14 186 196 11 6 3 155 18 16 26 150 180 168 97 148 25 84 127 136 119 135 4 30 162 144 195 46 31 170 119 28 190 ^'}}, + {OUT=>'DCA737E269F9D8626D488988C996E06B352C0708'}], + ['172', {IN=> {f=> '443 1 17 96 167 27 91 152 100 106 109 65 164 10 57 71 167 123 209 74 57 137 95 30 90 2 78 110 101 147 138 22 177 22 129 68 168 63 74 70 65 2 174 18 23 51 116 8 142 158 121 36 207 207 45 209 170 122 59 52 8 76 20 4 102 69 186 72 46 106 127 39 110 149 101 99 184 61 15 85 136 59 100 172 37 182 98 95 78 44 173 30 204 94 156 206 123 161 120 96 132 1 37 134 144 134 126 160 180 21 136 203 119 55 156 44 77 122 72 190 125 10 105 25 128 75 93 67 13 205 196 14 31 179 142 206 75 207 159 91 38 8 28 66 43 150 185 193 63 135 5 143 98 143 32 5 125 124 197 103 14 97 107 102 87 3 18 185 97 155 56 48 165 112 178 106 13 157 32 53 79 85 149 197 7 106 175 203 71 101 195 92 193 129 116 122 24 26 7 58 11 32 119 7 202 83 125 28 79 181 57 119 121 84 161 168 50 93 163 131 127 153 45 17 144 121 198 43 36 93 115 177 166 148 108 24 188 53 97 59 148 126 208 134 192 88 87 112 64 14 145 61 63 39 97 11 194 165 46 40 199 132 19 11 80 73 178 154 177 118 37 147 72 94 60 88 201 47 142 110 167 75 45 113 52 43 102 21 22 111 41 12 134 30 42 48 117 158 7 154 129 164 76 195 188 101 51 20 100 10 201 143 50 32 71 53 31 131 31 35 123 113 166 135 180 117 44 125 76 33 142 62 3 114 93 19 59 34 34 130 38 170 74 105 91 56 192 27 205 34 178 202 131 79 199 84 65 50 128 189 185 145 109 17 49 105 187 174 114 141 183 20 196 128 123 47 28 18 89 189 23 99 70 179 94 42 114 45 65 98 82 150 137 29 102 183 68 150 89 75 141 21 184 157 80 7 40 37 86 190 16 174 66 187 12 68 102 135 114 189 137 191 148 12 116 56 96 119 73 130 200 6 113 100 154 63 26 116 104 50 80 25 14 193 83 ^'}}, + {OUT=>'B8FFC1D4972FCE63241E0E77850AC46DDE75DBFA'}], + ['173', {IN=> {f=> '436 1 24 44 191 211 138 11 138 18 140 99 133 104 54 124 42 63 88 95 137 133 151 116 162 208 193 180 180 173 26 158 165 160 26 6 18 79 33 1 97 59 45 62 51 172 141 24 37 189 130 145 6 72 143 152 160 87 4 150 86 28 80 77 71 106 16 164 123 103 10 54 178 106 114 34 85 150 93 175 93 70 76 27 36 152 207 4 42 103 3 120 97 113 109 181 210 162 154 129 61 166 38 13 53 141 183 186 138 184 10 61 112 119 175 107 6 170 81 114 207 102 125 65 50 135 73 28 73 75 203 113 11 98 35 115 71 8 146 202 76 88 102 139 1 144 189 83 15 181 51 13 60 75 51 179 143 37 30 49 51 20 207 156 44 184 64 125 18 133 97 52 111 194 58 167 75 149 49 105 84 113 170 179 197 169 149 208 41 178 99 180 21 92 145 172 155 105 131 30 208 200 114 48 21 31 79 40 148 178 52 50 196 71 160 80 70 69 93 23 159 202 83 22 115 132 6 65 209 71 167 14 151 130 98 89 34 190 167 68 2 181 112 79 192 82 191 45 55 49 159 148 19 116 169 142 61 173 185 94 46 146 104 206 126 55 56 93 16 12 121 90 17 49 44 18 126 163 39 50 189 137 147 87 65 3 5 35 75 156 196 118 77 118 23 54 185 40 195 95 90 71 113 163 32 116 108 144 74 166 190 15 134 134 188 39 158 172 94 107 212 23 53 134 36 105 77 111 89 186 124 35 61 7 102 132 67 131 128 78 162 161 63 142 14 43 147 141 129 54 19 170 20 48 7 95 198 199 70 123 157 74 173 192 28 127 139 109 127 146 43 140 139 48 61 14 36 60 136 49 98 150 32 109 174 63 81 161 124 140 146 50 142 7 109 66 80 124 201 144 182 149 2 188 46 92 185 87 112 133 43 201 205 35 68 9 183 125 72 197 3 66 33 207 163 191 52 57 130 152 8 85 204 157 81 107 205 187 ^'}}, + {OUT=>'E9C9BF41C8549354151B977003CE1D830BE667DB'}], + ['174', {IN=> {f=> '462 1 126 54 123 113 85 81 23 41 154 71 210 115 18 89 108 32 157 209 11 103 176 133 136 77 193 10 209 112 196 166 110 66 43 69 194 36 202 25 171 62 112 82 44 100 43 188 172 70 83 29 115 67 64 128 83 153 164 195 158 2 119 187 169 33 160 31 149 23 64 32 61 109 45 121 102 77 74 32 38 16 55 7 172 189 198 200 211 141 11 2 5 143 159 147 90 134 25 70 106 122 105 114 212 30 141 130 195 39 24 163 91 28 11 7 76 167 17 81 137 85 86 94 65 149 5 42 66 157 113 204 59 57 137 80 15 70 207 78 95 91 142 133 17 177 22 129 68 168 43 74 50 60 197 174 3 13 36 106 3 127 158 116 26 197 192 25 194 155 102 59 52 203 56 20 214 82 49 171 67 46 106 117 34 90 139 96 94 179 56 15 65 136 54 100 157 17 182 93 75 63 24 168 25 189 84 156 201 118 156 105 96 112 201 22 134 139 114 116 145 175 11 121 198 99 40 151 34 72 117 52 190 105 90 20 118 60 83 52 208 205 181 209 16 174 122 206 70 202 144 71 18 208 8 66 38 135 170 178 53 115 5 138 88 123 17 200 115 119 182 98 9 87 97 102 72 3 8 180 82 145 56 33 165 102 173 96 213 157 12 33 69 80 129 192 2 101 165 203 51 86 190 87 193 124 116 122 4 21 7 53 211 27 104 207 197 73 125 23 59 176 37 114 111 74 151 153 50 73 148 116 127 153 45 2 124 121 193 28 16 78 100 162 166 128 88 9 188 53 92 49 148 111 193 129 187 68 77 92 54 4 135 51 63 19 97 1 194 150 31 35 194 132 9 206 75 58 168 144 167 118 37 127 62 94 60 78 196 47 132 110 162 65 35 98 32 43 87 1 2 106 21 12 124 20 22 38 117 148 212 149 119 164 76 180 183 101 46 10 95 205 186 143 40 32 56 38 21 126 31 30 123 108 151 135 165 107 29 120 71 13 137 62 208 104 88 4 39 29 19 115 23 160 54 105 91 41 177 27 200 14 163 124 ^'}}, + {OUT=>'0942908960B54F96CB43452E583F4F9CB66E398A'}], + ['175', {IN=> {f=> '453 0 115 79 199 84 49 18 128 173 169 121 93 17 186 41 89 187 158 90 133 167 206 188 104 99 31 4 18 81 165 217 75 54 179 62 34 106 37 41 66 82 134 113 215 86 159 36 142 65 43 125 215 160 149 48 193 24 21 86 182 16 166 42 179 206 44 94 111 82 181 121 167 132 198 92 48 72 119 57 114 184 200 81 68 122 39 26 84 96 26 80 1 208 177 217 24 44 191 206 118 209 123 8 140 99 128 99 54 109 42 58 83 80 122 113 141 96 147 203 183 180 175 158 16 143 155 155 11 1 13 64 23 1 87 54 35 52 46 157 121 19 27 174 115 130 209 72 123 152 150 87 202 140 76 23 75 77 66 86 11 149 118 88 44 168 101 94 14 80 145 93 165 73 65 66 12 21 137 192 4 22 83 201 120 77 113 94 181 195 157 144 124 51 151 33 211 38 131 178 186 138 184 5 61 92 99 175 107 6 155 81 114 207 87 105 45 40 120 73 18 58 60 193 98 11 98 15 100 51 3 146 187 61 88 97 139 204 129 189 73 213 171 36 216 55 55 51 174 138 17 15 49 41 15 197 146 39 174 64 120 3 123 82 37 111 179 58 157 70 134 39 100 74 108 170 164 197 169 144 198 41 163 84 170 16 92 145 167 155 85 116 25 208 200 104 48 21 16 69 40 143 178 42 35 196 56 145 70 60 49 88 23 149 192 78 12 95 127 204 55 199 61 162 212 151 130 88 74 34 180 152 53 210 166 112 74 182 67 176 30 35 29 159 133 19 101 164 127 56 168 175 84 26 131 104 196 126 40 46 83 6 7 101 90 12 44 24 216 106 158 39 30 179 132 147 82 60 216 203 35 75 151 181 98 62 108 3 49 185 25 185 95 80 71 103 153 22 106 88 144 54 156 175 10 129 119 178 19 148 172 79 102 207 13 208 33 114 36 95 57 91 79 176 104 25 41 210 92 122 62 131 108 73 162 161 48 142 14 33 137 141 119 34 9 160 5 38 205 75 198 189 50 108 112 ^'}}, + {OUT=>'FCE34051C34D4B81B85DDC4B543CDE8007E284B3'}], + ['176', {IN=> {f=> '454 1 53 173 192 113 111 102 120 132 22 112 118 20 40 7 8 213 46 129 28 77 150 11 81 160 49 60 154 124 119 139 43 135 213 109 38 52 117 201 116 168 149 215 181 32 64 164 59 98 133 15 194 198 28 54 9 183 104 58 176 209 59 12 200 163 177 45 50 116 145 8 64 204 150 74 93 184 89 111 39 108 108 85 61 13 36 154 61 210 115 3 84 108 22 152 209 216 103 176 123 126 57 183 10 199 107 186 161 105 51 38 69 184 26 202 15 171 57 97 77 24 90 33 183 167 70 83 29 110 67 49 123 63 148 159 190 148 2 99 172 159 33 160 26 139 3 44 17 46 89 40 101 87 62 69 27 38 6 55 2 162 184 183 190 211 131 6 212 210 138 144 132 85 124 25 60 91 112 95 99 212 30 126 120 195 34 19 158 71 28 211 217 56 167 7 71 122 70 66 79 65 134 27 61 147 103 199 44 57 137 65 50 202 78 80 81 137 128 12 177 22 129 68 168 23 74 30 55 182 174 208 3 21 96 218 112 158 111 16 187 177 5 179 140 82 59 52 188 36 20 214 62 29 156 62 46 106 107 29 70 129 91 89 174 51 15 45 136 49 100 142 217 182 88 55 48 4 163 20 174 74 156 196 113 151 90 96 92 191 7 134 134 94 106 130 170 1 106 193 79 25 146 24 67 112 32 190 85 210 75 15 108 45 73 37 193 205 166 194 1 169 102 206 65 197 129 51 218 198 208 66 33 120 155 163 43 95 5 133 78 103 2 185 105 114 167 93 4 77 87 102 57 3 218 175 67 135 56 18 165 92 168 86 203 157 212 13 59 75 109 187 217 96 155 203 31 71 185 82 193 119 116 122 204 16 7 48 201 22 89 197 192 63 125 18 39 171 17 109 101 64 141 138 50 53 133 101 127 153 45 207 104 121 188 13 216 63 85 147 166 108 68 214 188 53 87 39 148 96 178 124 182 48 67 72 44 214 125 41 63 219 97 211 194 135 16 30 189 132 219 191 70 43 158 181 ^'}}, + {OUT=>'61E8916532503627F4024D13884640A46F1D61D4'}], + ['177', {IN=> {f=> '475 0 153 118 37 99 48 94 60 64 189 47 118 110 155 51 21 77 4 43 66 195 196 99 215 12 110 6 216 24 117 134 205 142 105 164 76 159 176 101 39 218 88 184 165 143 26 32 35 17 7 119 31 23 123 101 130 135 144 93 8 113 64 207 130 62 201 90 81 205 11 22 220 94 2 146 26 105 91 20 156 27 193 208 142 178 107 79 199 84 41 2 128 165 161 109 85 17 174 37 81 187 150 78 129 159 194 184 92 87 23 214 18 77 153 209 63 46 179 46 30 102 33 29 50 82 126 101 203 78 147 20 138 53 27 117 207 148 145 32 181 16 13 86 178 16 162 30 175 198 32 90 99 66 177 113 155 124 186 80 44 60 119 49 106 176 192 65 52 106 27 26 68 92 14 80 211 200 169 213 24 44 191 202 102 197 111 140 99 124 95 54 97 42 54 79 68 110 97 133 80 135 199 175 180 171 146 8 131 147 151 221 219 9 52 15 1 79 50 27 44 42 145 105 15 19 162 103 118 201 72 107 152 142 87 190 132 68 19 71 77 62 70 7 137 114 76 214 36 160 97 78 220 76 141 93 157 57 61 58 9 125 180 4 6 67 189 120 61 113 82 181 183 153 136 120 43 139 29 199 26 123 174 186 138 184 1 61 76 83 175 107 6 143 81 114 207 75 89 29 32 108 73 10 46 48 185 86 11 98 221 88 35 221 146 175 49 88 93 139 196 117 189 65 201 163 24 208 51 39 51 170 134 1 3 49 33 11 189 138 35 166 64 116 213 115 70 25 111 167 58 149 66 122 31 96 66 104 170 152 197 169 140 190 41 151 72 162 12 92 145 163 155 69 104 21 208 200 96 48 21 4 61 40 139 178 34 23 196 44 133 62 52 33 84 23 141 184 74 4 79 123 192 47 191 53 158 200 151 130 80 62 34 172 140 41 206 154 112 70 174 55 164 18 19 13 159 121 19 89 160 115 52 164 167 76 10 119 104 188 126 28 38 75 220 3 85 90 8 40 8 204 90 154 39 14 171 128 147 78 56 216 191 35 75 147 169 82 50 100 209 45 185 13 177 95 150 ^'}}, + {OUT=>'F008D5D7853B6A17B7466CD9E18BD135E520FAF4'}], + ['178', {IN=> {f=> '471 0 71 89 139 8 92 60 144 26 142 154 3 122 98 164 216 134 172 58 95 200 224 201 5 86 36 81 29 63 65 162 76 11 13 196 78 108 55 131 80 66 162 161 27 142 14 19 123 141 105 6 220 146 209 24 184 47 198 175 22 87 133 38 173 192 205 103 91 97 115 122 7 92 103 25 2 213 213 36 124 13 62 150 221 61 150 39 45 149 124 104 134 38 130 208 109 18 32 112 201 96 158 149 215 176 22 44 149 39 88 133 220 189 193 23 44 9 183 89 48 161 204 54 222 195 163 167 40 45 106 140 8 49 204 145 69 83 169 89 96 24 93 103 85 41 3 31 154 51 210 115 213 79 108 12 147 209 206 103 176 113 116 37 173 10 189 102 176 156 100 36 33 69 174 16 202 5 171 52 82 72 4 80 23 178 162 70 83 29 105 67 34 118 43 143 154 185 138 2 79 157 149 33 160 21 129 208 24 2 31 69 35 81 72 47 64 22 38 221 55 222 152 179 168 180 211 121 1 207 200 133 129 117 80 114 25 50 76 102 85 84 212 30 111 110 195 29 14 153 51 28 196 212 36 167 222 61 107 55 46 64 65 119 220 12 56 137 93 194 29 57 137 50 210 30 197 78 65 71 132 123 7 177 22 129 68 168 3 74 10 50 167 174 198 218 6 86 218 97 158 106 6 177 162 210 164 125 62 59 52 173 16 20 214 42 9 141 57 46 106 97 24 50 119 86 84 169 46 15 25 136 44 100 127 202 182 83 35 33 209 158 15 159 64 156 191 108 146 75 96 72 181 217 134 129 74 96 115 165 216 91 188 59 10 141 14 62 107 12 190 65 205 60 10 98 30 63 22 178 205 151 179 211 164 82 206 60 192 114 31 203 188 193 66 28 105 140 148 33 75 5 128 68 83 212 170 95 109 152 88 224 67 77 102 42 3 213 170 52 125 56 3 165 82 163 76 193 157 197 218 49 70 89 182 217 91 145 203 11 56 180 77 193 114 116 122 189 11 7 43 191 17 74 187 187 53 125 13 19 166 222 104 91 54 131 123 50 33 118 86 127 167 ^'}}, + {OUT=>'BD8D2E873CF659B5C77AAC1616827EF8A3B1A3B3'}], + ['179', {IN=> {f=> '480 1 45 193 76 121 181 219 195 42 64 126 166 80 40 200 188 53 80 25 148 75 157 117 175 20 53 44 30 207 111 27 63 198 97 204 194 114 222 23 182 132 212 170 63 22 144 120 143 118 37 79 38 94 60 54 184 47 108 110 150 41 11 62 211 43 51 180 181 94 200 12 100 223 201 14 117 124 200 137 95 164 76 144 171 101 34 213 83 169 150 143 16 32 20 2 224 114 31 18 123 96 115 135 129 83 220 108 59 192 125 62 196 80 76 195 218 17 210 79 214 136 6 105 91 5 141 27 188 193 127 168 97 79 199 84 31 209 128 155 151 94 75 17 159 32 71 187 140 63 124 149 179 179 77 72 13 204 18 72 138 199 48 36 179 26 25 97 28 14 30 82 116 86 188 68 132 133 38 7 107 197 133 140 12 166 6 3 86 173 16 157 15 170 188 17 85 84 46 172 103 140 114 171 65 39 45 119 39 96 166 182 45 32 86 12 26 48 87 226 80 201 190 159 208 24 44 191 197 82 182 96 217 140 99 119 90 54 82 42 49 74 53 95 77 123 60 120 194 165 180 166 131 225 116 137 146 211 219 4 37 5 1 69 45 17 34 37 130 85 10 9 147 88 103 191 72 87 152 132 87 175 122 58 14 66 77 57 50 2 122 109 61 209 26 150 92 58 205 71 136 93 147 37 56 48 212 221 110 165 4 213 47 174 120 41 113 67 181 168 148 126 115 33 124 24 184 11 113 169 186 138 184 223 61 56 63 175 107 6 128 81 114 207 60 69 9 22 93 73 31 33 175 71 11 98 206 73 15 221 146 160 34 88 88 139 186 102 189 55 186 153 9 198 46 19 51 165 129 208 215 49 23 6 179 128 30 156 64 111 203 105 55 10 111 152 58 139 61 107 21 91 56 99 170 137 197 169 135 180 41 136 57 152 7 92 145 158 155 49 89 16 208 200 86 48 21 216 51 40 134 178 24 8 196 29 118 52 42 13 79 23 131 174 69 221 59 118 177 37 181 43 153 185 151 130 70 47 34 162 125 26 201 139 112 65 164 40 149 3 226 220 159 106 19 74 155 100 47 159 157 193 ^'}}, + {OUT=>'B25A04DD425302ED211A1C2412D2410FA10C63B6'}], + ['180', {IN=> {f=> '471 0 211 98 104 174 126 7 24 61 213 225 57 90 1 33 209 183 62 147 39 215 157 121 147 71 49 216 170 35 75 140 148 54 29 86 188 38 185 221 163 95 58 71 81 131 84 44 144 10 134 142 228 118 86 156 204 126 172 46 91 196 220 197 218 70 36 73 13 47 57 154 60 3 226 188 70 100 51 131 64 62 162 161 15 142 14 11 115 141 97 219 216 138 201 16 172 31 198 167 6 75 125 26 173 192 193 95 75 93 111 114 224 76 91 213 13 227 201 213 28 120 1 50 150 213 45 142 31 33 145 124 92 130 34 126 204 109 2 16 108 201 80 150 149 215 172 14 28 137 23 80 133 208 185 189 19 36 9 183 77 40 149 200 50 214 191 163 159 36 41 98 136 8 37 204 141 65 75 157 89 84 12 81 99 85 25 224 27 154 43 210 115 205 75 108 4 143 209 198 103 176 105 108 21 165 10 181 98 168 152 96 24 29 69 166 8 202 226 171 48 70 68 217 72 15 174 158 70 83 29 101 67 22 114 27 139 150 181 130 2 63 145 141 33 160 17 121 196 8 219 19 53 31 65 60 35 60 18 38 217 55 222 144 175 156 172 211 113 226 203 192 129 117 105 76 106 25 42 64 94 77 72 212 30 99 102 195 25 10 149 35 28 184 208 20 167 218 53 95 43 30 52 65 107 220 52 129 85 190 17 57 137 38 202 14 193 78 53 63 128 119 3 177 22 129 68 168 216 74 223 46 155 174 190 214 223 78 218 85 158 102 227 169 150 198 152 113 46 59 52 161 20 214 26 222 129 53 46 106 89 20 34 111 82 80 165 42 15 9 136 40 100 115 190 182 79 19 21 197 154 11 147 56 156 187 104 142 63 96 56 173 209 134 125 58 88 103 161 212 79 184 43 227 137 6 58 103 225 190 49 201 48 6 90 18 55 10 166 205 139 167 203 160 66 206 56 188 102 15 191 180 181 66 24 93 128 136 25 59 5 124 60 67 204 158 87 105 140 84 224 59 69 102 30 3 209 166 40 117 56 220 165 74 159 68 185 157 185 206 41 66 167 ^'}}, + {OUT=>'A404E21588123E0893718B4B44E91414A785B91F'}], + ['181', {IN=> {f=> '490 1 176 217 85 133 203 218 38 174 71 193 108 116 122 171 5 7 37 179 11 56 175 181 41 125 7 226 160 204 98 79 42 119 105 50 9 100 68 127 153 45 185 60 121 177 211 183 30 52 114 166 64 24 192 188 53 76 17 148 63 145 113 171 4 45 28 22 203 103 19 63 186 97 200 194 102 214 19 178 132 208 158 59 10 136 112 135 118 37 63 30 94 60 46 180 47 100 110 146 33 3 50 199 43 39 168 169 90 188 12 92 219 189 6 117 116 196 133 87 164 76 132 167 101 30 209 79 157 138 143 8 32 8 221 220 110 31 14 123 92 103 135 117 75 212 104 55 180 121 62 192 72 72 187 206 13 202 67 206 128 221 105 91 224 129 27 184 181 115 160 89 79 199 84 23 197 128 147 143 82 67 17 147 28 63 187 132 51 120 141 167 175 65 60 5 196 18 68 126 191 36 28 179 10 21 93 24 2 14 82 108 74 176 60 120 215 129 26 222 99 189 121 136 227 154 229 226 86 169 16 153 3 166 180 5 81 72 30 168 95 128 106 159 53 35 33 119 31 88 158 174 29 16 70 26 32 83 218 80 193 182 151 204 24 44 191 193 66 170 84 213 140 99 115 86 54 70 42 45 70 41 83 61 115 44 108 190 157 180 162 119 221 104 129 142 203 219 25 228 1 61 41 9 26 33 118 69 6 1 135 76 91 183 72 71 152 124 87 163 114 50 10 62 77 53 34 229 110 105 49 205 18 142 88 42 193 67 132 93 139 21 52 40 204 213 98 153 4 201 31 162 120 25 113 55 181 156 144 118 111 25 112 20 172 230 105 165 186 138 184 223 61 40 47 175 107 6 116 81 114 207 48 53 224 14 81 73 223 19 21 167 59 11 98 194 61 230 221 146 148 22 88 84 139 178 90 189 47 174 145 228 190 42 3 51 161 125 196 207 49 15 2 171 120 26 148 64 107 195 97 43 229 111 140 58 131 57 95 13 87 48 95 170 125 197 169 131 172 41 124 45 144 3 92 145 154 155 33 77 12 208 200 78 48 21 208 43 40 130 178 16 227 196 17 106 44 34 228 75 23 123 166 65 217 43 114 165 29 173 35 200 ^'}}, + {OUT=>'A1E13BC55BF6DAD83CF3AABDA3287AD68681EA64'}], + ['182', {IN=> {f=> '479 0 167 151 130 58 29 34 150 107 8 195 121 112 59 152 22 131 218 208 202 159 88 19 56 149 82 41 153 145 54 199 86 104 166 126 228 16 53 209 225 41 90 230 29 197 171 46 143 39 203 149 117 147 67 45 216 158 35 75 136 136 38 17 78 176 34 185 213 155 95 50 71 73 123 225 76 28 144 227 126 130 228 114 74 148 192 118 172 34 87 192 216 193 206 54 36 65 230 31 49 146 44 228 214 180 62 92 47 131 48 58 162 161 3 142 14 3 107 141 89 207 212 130 193 8 160 15 198 159 223 63 117 14 173 192 181 87 59 89 107 106 216 60 79 201 1 227 189 213 20 116 222 38 150 205 29 134 23 21 141 124 80 126 30 122 200 109 219 104 201 64 142 149 215 168 6 12 125 7 72 133 196 181 185 15 28 9 183 65 32 137 196 46 206 187 163 151 32 37 90 132 8 25 204 137 61 67 145 89 72 69 95 85 9 220 23 154 35 210 115 197 71 108 229 139 209 190 103 176 97 100 5 157 10 173 94 160 148 92 12 25 69 158 202 222 171 44 58 64 205 64 7 170 154 70 83 29 97 67 10 110 11 135 146 177 122 2 47 133 133 33 160 13 113 184 225 211 7 37 27 49 48 23 56 14 38 213 55 222 136 171 144 164 211 105 226 199 184 125 105 93 72 98 25 34 52 86 69 60 212 30 87 94 195 21 6 145 19 28 172 204 4 167 214 45 83 31 14 40 65 95 220 221 48 121 77 186 5 57 137 26 194 231 189 78 41 55 124 115 232 177 22 129 68 168 204 74 211 42 143 174 182 210 215 70 218 73 158 98 223 161 138 186 140 101 30 59 52 149 217 20 214 10 210 117 49 46 106 81 16 18 103 78 76 161 38 15 226 136 36 100 103 178 182 75 3 9 185 150 7 135 48 156 183 100 138 51 96 40 165 201 134 121 42 80 91 157 208 67 180 27 219 133 231 54 99 213 190 33 197 36 2 82 6 47 231 154 205 127 155 195 156 50 206 52 184 90 232 179 172 169 66 20 81 116 124 17 43 5 120 52 51 196 146 79 101 128 80 224 65 ^'}}, + {OUT=>'D5FD35FFABED6733C92365929DF0FB4CAE864D15'}], + ['183', {IN=> {f=> '503 1 55 102 9 3 202 159 19 103 56 206 165 60 152 54 171 157 164 185 27 59 45 171 217 80 123 203 203 23 169 66 193 103 116 122 156 7 32 169 6 41 165 176 31 125 2 211 155 189 93 69 32 109 90 50 225 85 53 127 153 45 175 40 121 172 201 168 15 37 99 166 44 4 182 188 53 71 7 148 48 130 108 166 220 35 8 12 198 93 9 63 171 97 195 194 87 204 14 173 132 203 143 54 231 126 102 125 118 37 43 20 94 60 36 175 47 90 110 141 23 229 35 184 43 24 153 154 85 173 12 82 214 174 232 117 106 191 128 77 164 76 117 162 101 25 204 74 142 123 143 234 32 229 211 215 105 31 9 123 87 88 135 102 65 202 99 50 165 116 62 187 62 67 177 191 8 192 52 196 118 206 105 91 214 114 27 179 166 100 150 79 79 199 84 13 182 128 137 133 67 57 17 132 23 53 187 122 36 115 131 152 170 50 45 231 186 18 63 111 181 21 18 179 226 16 88 19 223 230 82 98 59 161 50 105 200 124 11 207 89 179 106 131 212 139 224 221 86 164 16 148 224 161 170 226 76 57 10 163 85 113 96 144 38 30 18 119 21 78 148 164 9 232 50 221 26 12 78 208 80 183 172 141 199 24 44 191 188 46 155 69 208 140 99 110 81 54 55 42 40 65 26 68 41 105 24 93 185 147 180 157 104 216 89 119 137 193 219 231 10 223 1 51 36 235 16 28 103 49 1 227 120 61 76 173 72 51 152 114 87 148 104 40 5 57 77 48 14 229 95 100 34 200 8 132 83 22 178 62 127 93 129 1 47 30 194 203 83 138 4 186 11 147 120 5 113 40 181 141 139 108 106 15 97 15 157 220 95 160 186 138 184 223 61 20 27 175 107 6 101 81 114 207 33 33 209 4 66 73 218 4 6 157 44 11 98 179 46 215 221 146 133 7 88 79 139 168 75 189 37 159 135 218 180 37 219 51 156 120 181 197 49 5 233 161 110 21 138 64 102 185 87 28 219 111 125 58 121 52 80 3 82 38 90 170 110 197 169 126 162 41 109 30 134 234 92 145 149 155 13 62 7 208 200 68 48 21 198 33 40 125 178 6 217 196 2 91 34 24 213 70 23 113 161 ^'}}, + {OUT=>'C12E9C280EE9C079E0506FF89F9B20536E0A83EF'}], + ['184', {IN=> {f=> '470 0 58 210 15 107 144 15 159 21 142 152 151 130 48 14 34 140 92 231 190 106 112 54 142 7 116 208 193 187 159 73 19 41 144 67 36 148 135 44 184 71 104 156 126 218 6 43 204 225 21 90 230 24 182 156 26 138 39 188 139 112 147 62 40 216 143 35 75 131 121 18 2 68 161 29 185 203 145 95 40 71 63 113 220 66 8 144 212 116 115 228 109 59 138 177 108 172 19 82 187 211 188 191 34 36 55 215 11 39 136 24 223 199 170 52 82 42 131 28 53 162 161 226 142 14 231 97 141 79 192 207 120 183 236 145 233 198 149 208 48 107 237 173 192 166 77 39 84 102 96 206 40 64 186 224 227 174 213 10 111 212 23 150 195 9 124 13 6 136 124 65 121 25 117 195 109 204 218 99 201 44 132 149 215 163 234 230 110 225 62 133 181 176 180 10 18 9 183 50 22 122 191 41 196 182 163 141 27 32 80 127 8 10 204 132 56 57 130 89 57 223 54 90 85 227 215 18 154 25 210 115 187 66 108 224 134 209 180 103 176 87 90 223 147 10 163 89 150 143 87 235 20 69 148 228 202 217 171 39 43 59 190 54 235 165 149 70 83 29 92 67 233 105 229 130 141 172 112 2 27 118 123 33 160 8 103 169 210 201 230 17 22 29 33 8 51 9 38 208 55 222 126 166 129 154 211 95 226 194 174 120 90 78 67 88 25 24 37 76 59 45 212 30 72 84 195 16 1 140 237 28 157 199 222 167 209 35 68 16 232 25 65 80 220 211 43 111 67 181 228 57 137 11 184 216 184 78 26 45 119 110 232 177 22 129 68 168 189 74 196 37 128 174 172 205 205 60 218 58 158 93 218 151 123 171 125 86 10 59 52 134 202 20 214 228 195 102 44 46 106 71 11 236 93 73 71 156 33 15 211 136 31 100 88 163 182 70 221 232 170 145 2 120 38 156 178 95 133 36 96 20 155 191 134 116 22 70 76 152 203 52 175 7 209 128 226 49 94 198 190 13 192 21 235 72 229 37 221 139 205 112 140 185 151 30 206 47 179 75 217 101 ^'}}, + {OUT=>'E22769DC00748A9BBD6C05BBC8E81F2CD1DC4E2D'}], + ['185', {IN=> {f=> '502 0 158 148 66 13 60 95 103 3 15 5 113 38 23 182 125 65 94 107 73 224 37 47 102 237 3 198 155 7 95 56 198 165 52 148 46 163 157 152 173 19 55 29 167 217 76 115 203 191 11 165 62 193 99 116 122 144 236 7 28 161 2 29 157 172 23 125 238 199 151 177 89 61 24 101 78 50 213 73 41 127 153 45 167 24 121 168 193 156 3 25 87 166 28 228 174 188 53 67 239 148 36 118 104 162 208 27 232 4 194 85 1 63 159 97 191 194 75 196 10 169 132 199 131 50 223 118 94 117 118 37 27 12 94 60 28 171 47 82 110 137 15 225 23 172 43 12 141 142 81 161 12 74 210 162 228 117 98 187 124 69 164 76 105 158 101 21 200 70 130 111 143 230 32 221 203 211 101 31 5 123 83 76 135 90 57 194 95 46 153 112 62 183 54 63 169 179 4 184 40 188 110 194 105 91 206 102 27 175 154 88 142 71 79 199 84 5 170 128 129 125 55 49 17 120 19 45 187 114 24 111 123 140 166 38 33 227 178 18 59 99 173 9 10 179 214 12 84 15 215 218 82 90 47 149 42 93 188 120 239 195 81 171 94 127 200 127 220 217 86 160 16 144 216 157 162 218 72 45 234 159 77 101 88 132 26 26 6 119 13 70 140 156 233 220 34 213 26 236 74 200 80 175 164 133 195 24 44 191 184 30 143 57 204 140 99 106 77 54 43 42 36 61 14 56 25 97 8 81 181 139 180 153 92 212 77 111 133 185 219 231 238 219 1 43 32 231 8 24 91 33 237 223 108 49 64 165 72 35 152 106 87 136 96 32 1 53 77 44 238 229 83 96 22 196 124 79 6 166 58 123 93 121 225 43 22 186 195 71 126 4 174 235 135 120 229 113 28 181 129 135 100 102 7 85 11 145 212 87 156 186 138 184 223 61 4 11 175 107 6 89 81 114 207 21 17 197 236 54 73 214 232 234 149 32 11 98 167 34 203 221 146 121 235 88 75 139 160 63 189 29 147 127 210 172 33 207 51 152 116 169 189 49 237 233 153 102 17 130 64 98 177 79 16 211 111 113 58 113 48 68 235 78 30 86 170 98 197 169 122 154 41 97 18 126 234 92 145 145 155 237 50 209 ^'}}, + {OUT=>'F29835A93475740E888E8C14318F3CA45A3C8606'}], + ['186', {IN=> {f=> '481 1 208 200 56 48 21 186 21 40 119 178 236 205 196 226 73 22 12 195 64 23 101 144 54 206 241 103 132 7 151 13 138 140 151 130 40 2 34 132 80 223 186 94 112 50 134 237 104 200 181 175 159 61 19 29 140 55 32 144 127 36 172 59 104 148 126 210 240 35 200 225 5 90 230 20 170 144 10 134 39 176 131 108 147 58 36 216 131 35 75 127 109 2 232 60 149 25 185 195 137 95 32 71 55 105 216 58 234 144 200 108 103 228 105 47 130 165 100 172 7 78 183 207 184 179 18 36 47 203 237 31 128 8 219 187 162 44 74 38 131 12 49 162 161 218 142 14 227 89 141 71 180 203 112 175 232 133 221 198 141 196 36 99 229 173 192 154 69 23 80 98 88 198 24 52 174 216 227 162 213 2 107 204 11 150 187 235 116 5 236 132 124 53 117 21 113 191 109 192 206 95 201 28 124 149 215 159 230 218 98 213 54 133 169 172 176 6 10 9 183 38 14 110 187 37 188 178 163 133 23 28 72 123 8 240 204 128 52 49 118 89 45 215 42 86 85 215 211 14 154 17 210 115 179 62 108 220 130 209 172 103 176 79 82 211 139 10 155 85 142 139 83 227 16 69 140 224 202 213 171 35 31 55 178 46 231 161 145 70 83 29 88 67 225 101 217 126 137 168 104 2 11 106 115 33 160 4 95 157 198 193 222 1 18 13 21 238 47 5 38 204 55 222 118 162 117 146 211 87 226 190 166 116 78 66 63 80 25 16 25 68 51 33 212 30 60 76 195 12 239 136 225 28 145 195 210 167 205 27 56 4 220 13 65 68 220 203 39 103 59 177 220 57 137 241 176 204 180 78 14 37 115 106 232 177 22 129 68 168 177 74 184 33 116 174 164 201 197 52 218 46 158 89 214 143 111 159 113 74 236 59 52 122 190 20 214 216 183 90 40 46 106 63 7 224 85 69 67 152 29 15 199 136 27 100 76 151 182 66 209 224 158 141 240 108 30 156 174 91 129 24 96 4 147 183 134 112 6 62 64 148 199 40 171 233 201 124 222 45 90 186 190 239 188 9 235 64 221 29 213 127 178 ^'}}, + {OUT=>'1A1D77C6D0F97C4B620FAA90F3F8644408E4B13D'}], + ['187', {IN=> {f=> '508 1 94 122 173 145 6 206 41 173 57 199 146 150 136 66 9 48 83 91 239 243 5 109 30 7 174 113 57 90 95 69 224 29 39 102 229 3 194 151 239 87 56 190 165 44 144 38 155 157 140 161 11 51 13 163 217 72 107 203 179 243 161 58 193 95 116 122 132 236 7 24 153 242 17 149 168 15 125 238 187 147 165 85 53 16 93 66 50 201 61 29 127 153 45 159 8 121 164 185 144 235 13 75 166 12 216 166 188 53 63 235 148 24 106 100 158 196 19 220 240 190 77 237 63 147 97 187 194 63 188 6 165 132 195 119 46 215 110 86 109 118 37 11 4 94 60 20 167 47 74 110 133 7 221 11 160 43 129 130 77 149 12 66 206 150 224 117 90 183 120 61 164 76 93 154 101 17 196 66 118 99 143 226 32 213 195 207 97 31 1 123 79 64 135 78 49 186 91 42 141 108 62 179 46 59 161 167 176 28 180 102 182 105 91 198 90 27 171 142 76 134 63 79 199 84 241 158 128 121 117 43 41 17 108 15 37 187 106 12 107 115 128 162 26 21 223 170 18 55 87 165 241 2 179 202 8 80 11 207 206 82 82 35 137 34 81 176 116 231 183 73 163 82 123 188 115 216 213 86 156 16 140 208 153 154 210 68 33 222 155 69 89 80 120 14 22 238 119 5 62 132 148 221 208 18 205 26 224 70 192 80 167 156 125 191 24 44 191 180 14 131 45 200 140 99 102 73 54 31 42 32 57 2 44 9 89 236 69 177 131 180 149 80 208 65 103 129 177 219 231 230 215 1 35 28 227 20 79 17 237 219 96 37 52 157 72 19 152 98 87 124 88 24 241 49 77 40 226 229 71 92 10 192 236 116 75 234 154 54 119 93 113 213 39 14 178 187 59 114 4 162 223 123 120 217 113 16 181 117 131 92 98 243 73 7 133 204 79 152 186 138 184 223 61 232 239 175 107 6 77 81 114 207 9 1 185 232 42 73 210 224 226 141 20 11 98 155 22 191 221 146 109 227 88 71 139 152 51 189 21 135 119 202 164 29 195 51 148 112 157 181 49 233 233 145 94 13 122 64 94 169 71 4 203 111 101 58 105 44 56 231 74 22 82 170 86 197 169 118 146 41 85 6 118 234 92 145 141 149 ^'}}, + {OUT=>'4EC84870E9BDD25F523C6DFB6EDD605052CA4EAA'}], + ['188', {IN=> {f=> '484 1 219 32 243 208 200 48 48 21 178 13 40 115 178 232 197 196 218 61 14 4 183 60 23 93 136 50 202 229 99 120 245 143 5 134 128 151 130 32 236 34 124 68 215 182 82 112 46 126 229 92 192 169 163 159 49 19 17 136 43 28 140 119 28 160 47 104 140 126 202 236 27 196 225 235 90 230 16 158 132 240 130 39 164 123 104 147 54 32 216 119 35 75 123 97 232 224 52 137 21 185 187 129 95 24 71 47 97 212 50 222 144 188 100 91 228 101 35 122 153 92 172 241 74 179 203 180 167 2 36 39 191 225 23 120 238 215 175 154 36 66 34 131 242 45 162 161 210 142 14 223 81 141 63 168 199 104 167 228 121 209 198 133 184 24 91 221 173 192 142 61 7 76 94 80 190 8 40 162 208 227 150 213 240 103 196 245 150 179 223 108 243 228 128 124 41 113 17 109 187 109 180 194 91 201 12 116 149 215 155 226 206 86 201 46 133 157 168 172 2 2 9 183 26 6 98 183 33 180 174 163 125 19 24 64 119 8 232 204 124 48 41 106 89 33 207 30 82 85 203 207 10 154 9 210 115 171 58 108 216 126 209 164 103 176 71 74 199 131 10 147 81 134 135 79 219 12 69 132 220 202 209 171 31 19 51 166 38 227 157 141 70 83 29 84 67 217 97 205 122 133 164 96 2 241 94 107 33 160 87 145 186 185 214 231 14 243 9 230 43 1 38 200 55 222 110 158 105 138 211 79 226 186 158 112 66 54 59 72 25 8 13 60 43 21 212 30 48 68 195 8 239 132 213 28 133 191 198 167 201 19 44 238 208 1 65 56 220 195 35 95 51 173 212 57 137 233 168 192 176 78 2 29 111 102 232 177 22 129 68 168 165 74 172 29 104 174 156 197 189 44 218 34 158 85 210 135 99 147 101 62 224 59 52 110 178 20 214 204 171 78 36 46 106 55 3 212 77 65 63 148 25 15 187 136 23 100 64 139 182 62 197 216 146 137 240 96 22 156 170 87 125 12 96 234 139 175 134 108 236 54 52 144 195 28 167 221 193 120 218 41 86 174 190 227 184 243 235 56 213 21 205 115 205 71 ^'}}, + {OUT=>'D689513FED08B80C39B67371959BC4E3FECB0537'}], + ['189', {IN=> {f=> '506 0 110 165 141 238 206 37 169 45 187 134 142 124 66 5 36 71 79 235 231 5 105 22 239 166 101 49 86 83 65 224 21 31 102 221 3 190 147 231 79 56 182 165 36 140 30 147 157 128 149 3 47 245 159 217 68 99 203 167 235 157 54 193 91 116 122 120 236 7 20 145 242 5 141 164 7 125 238 175 143 153 81 45 8 85 54 50 189 49 17 127 153 45 151 240 121 160 177 132 227 1 63 166 244 204 158 188 53 59 231 148 12 94 96 154 184 11 208 236 186 69 233 63 135 97 183 194 51 180 2 161 132 191 107 42 207 102 78 101 118 37 243 244 94 60 12 163 47 66 110 129 247 217 247 148 43 236 117 118 73 137 12 58 202 138 220 117 82 179 116 53 164 76 81 150 101 13 192 62 106 87 143 222 32 205 187 203 93 31 245 123 75 52 135 66 41 178 87 38 129 104 62 175 38 55 153 155 244 168 16 172 94 170 105 91 190 78 27 167 130 64 126 55 79 199 84 237 146 128 113 109 31 33 17 96 11 29 187 98 103 107 116 158 14 9 219 162 18 51 75 157 233 242 179 190 4 76 7 199 194 82 74 23 125 26 69 164 112 223 171 65 155 70 119 176 103 212 209 86 152 16 136 200 149 146 202 64 21 210 151 61 77 72 108 2 18 230 119 245 54 124 140 209 196 2 197 26 212 66 184 80 159 148 117 187 24 44 191 176 246 119 33 196 140 99 98 69 54 19 42 28 53 238 32 241 81 224 57 173 123 180 145 68 204 53 95 125 169 219 231 222 211 1 27 24 223 240 16 67 1 237 215 84 25 40 149 72 3 152 90 87 112 80 16 241 45 77 36 214 229 59 88 246 188 232 108 71 222 142 50 115 93 105 201 35 6 170 179 47 102 4 150 211 111 120 205 113 4 181 105 127 84 94 239 61 3 121 196 71 148 186 138 184 223 61 220 227 175 107 6 65 81 114 207 245 233 173 228 30 73 206 216 218 133 8 11 98 143 10 179 221 146 97 219 88 67 139 144 39 189 13 123 111 194 156 25 183 51 144 108 145 173 49 229 233 137 86 9 114 64 90 161 63 240 195 111 89 58 97 40 44 227 70 14 78 170 74 197 169 114 138 41 73 242 110 234 177 ^'}}, + {OUT=>'C4FED58F209FC3C34AD19F86A6DACADC86C04D33'}], + ['190', {IN=> {f=> '491 0 145 135 155 207 20 243 208 200 40 48 21 170 5 40 111 178 228 189 196 210 49 6 246 171 56 23 85 128 46 198 217 95 108 241 135 247 130 116 151 130 24 228 34 116 56 207 178 70 112 42 118 221 80 184 157 151 159 37 19 5 132 31 24 136 111 20 148 35 104 132 126 194 232 19 192 225 223 90 230 12 146 120 228 126 39 152 115 100 147 50 28 216 107 35 75 119 85 220 216 44 125 17 185 179 121 95 16 71 39 89 208 42 210 144 176 92 79 228 97 23 114 141 84 172 233 70 175 199 176 155 236 36 31 179 213 15 112 226 211 163 146 28 58 30 131 230 41 162 161 202 142 14 219 73 141 55 156 195 96 159 224 109 197 198 125 172 12 83 213 173 192 130 53 241 72 90 72 182 242 28 150 200 227 138 213 236 99 188 237 150 171 211 100 239 220 124 124 29 109 13 105 183 109 168 182 87 201 246 108 149 215 151 222 194 74 189 38 133 145 164 168 248 244 9 183 14 248 86 179 29 172 170 163 117 15 20 56 115 8 224 204 120 44 33 94 89 21 199 18 78 85 191 203 6 154 1 210 115 163 54 108 212 122 209 156 103 176 63 66 187 123 10 139 77 126 131 75 211 8 69 124 216 202 205 171 27 7 47 154 30 223 153 137 70 83 29 80 67 209 93 193 118 129 160 88 2 229 82 99 33 160 246 79 133 174 177 206 219 10 231 247 222 39 247 38 196 55 222 102 154 93 130 211 71 226 182 150 108 54 42 55 64 25 1 52 35 9 212 30 36 60 195 4 239 128 201 28 121 187 186 167 197 11 32 230 196 239 65 44 220 187 31 87 43 169 204 57 137 225 160 180 172 78 240 21 107 98 232 177 22 129 68 168 153 74 160 25 92 174 148 193 181 36 218 22 158 81 206 127 87 135 89 50 212 59 52 98 166 20 214 192 159 66 32 46 106 47 249 200 69 61 59 144 21 15 175 136 19 100 52 127 182 58 185 208 134 133 240 84 14 156 166 83 121 96 222 131 167 134 104 224 46 40 140 191 16 163 209 185 116 214 37 82 162 190 215 180 235 235 48 205 13 197 103 205 76 104 161 139 232 146 ^'}}, + {OUT=>'051888C6D00029C176DE792B84DECE2DC1C74B00'}], + ['191', {IN=> {f=> '516 0 33 165 33 175 122 134 112 66 1 24 59 67 231 219 5 101 14 227 158 89 41 82 71 61 224 13 23 102 213 3 186 143 223 71 56 174 165 28 136 22 139 157 116 137 247 43 233 155 217 64 91 203 155 227 153 50 193 87 116 122 108 236 7 16 137 242 245 133 160 251 125 238 163 139 141 77 37 77 42 50 177 37 5 127 153 45 143 228 121 156 169 120 219 241 51 166 232 192 150 188 53 55 227 148 82 92 150 172 3 196 232 182 61 229 63 123 97 179 194 39 172 250 157 132 187 95 38 199 94 70 93 118 37 231 240 94 60 4 159 47 58 110 125 243 213 239 136 43 228 105 106 69 125 12 50 198 126 216 117 74 175 112 45 164 76 69 146 101 9 188 58 94 75 143 218 32 197 179 199 89 31 245 123 71 40 135 54 33 170 83 34 117 100 62 171 30 51 145 143 244 160 4 164 86 158 105 91 182 66 27 163 118 52 118 47 79 199 84 233 134 128 105 101 19 25 17 84 7 21 187 90 240 99 99 104 154 2 249 215 154 18 47 63 149 225 238 179 178 72 3 191 182 82 66 11 113 18 57 152 108 215 159 57 147 58 115 164 91 208 205 86 148 16 132 192 145 138 194 60 9 198 147 53 65 64 96 242 14 222 119 241 46 116 132 197 184 238 189 26 200 62 176 80 151 140 109 183 24 44 191 172 234 107 21 192 140 99 94 65 54 7 42 24 49 230 20 229 73 212 45 169 115 180 141 56 200 41 87 121 161 219 231 214 207 1 19 20 219 236 12 55 237 237 211 72 13 28 141 72 239 152 82 87 100 72 8 241 41 77 32 202 229 47 84 238 184 228 100 67 210 130 46 111 93 97 189 31 250 162 171 35 90 4 138 199 99 120 193 113 244 181 93 123 76 90 235 49 251 109 188 63 144 186 138 184 223 61 208 215 175 107 6 53 81 114 207 237 221 161 224 18 73 202 208 210 125 248 11 98 131 250 167 221 146 85 211 88 63 139 136 27 189 5 111 103 186 148 21 171 51 140 104 133 165 49 225 233 129 78 5 106 64 86 153 55 232 187 111 77 58 89 36 32 223 66 6 74 170 62 197 169 110 130 41 61 234 102 234 92 145 133 155 201 14 243 208 200 36 48 21 166 1 40 109 178 147 ^'}}, + {OUT=>'1A3540BEE05518505827954F58B751C475AEECE0'}], + ['192', {IN=> {f=> '522 0 179 196 200 34 251 241 156 51 23 75 118 41 193 202 90 93 236 125 242 125 101 151 130 14 218 34 106 41 197 173 55 112 37 108 211 65 174 142 136 159 22 19 245 127 16 19 131 101 10 133 20 104 122 126 184 227 9 187 225 208 90 230 7 131 105 213 121 39 137 105 95 147 45 23 216 92 35 75 114 70 205 206 34 110 12 185 169 111 95 6 71 29 79 203 32 195 144 161 82 64 228 92 8 104 126 74 172 223 65 170 194 171 140 221 36 21 164 198 5 102 211 206 148 136 18 48 25 131 215 36 162 161 192 142 14 214 63 141 45 141 190 86 149 219 94 182 198 115 157 252 73 203 173 192 115 43 226 67 85 62 172 227 13 135 190 227 123 213 231 94 178 227 150 161 196 90 234 210 119 124 14 104 8 100 178 109 153 167 82 201 231 98 149 215 146 217 179 59 174 28 133 130 159 163 248 239 9 183 254 243 71 174 24 162 165 163 107 10 15 46 110 8 214 204 115 39 23 79 89 6 189 3 73 85 176 198 1 154 246 210 115 153 49 108 207 117 209 146 103 176 53 56 172 113 10 129 72 116 126 70 201 3 69 114 211 202 200 171 22 247 42 139 20 218 148 132 70 83 29 75 67 199 88 178 113 124 155 78 2 214 67 89 33 160 246 69 118 159 167 196 204 5 216 237 212 34 247 38 191 55 222 92 149 78 120 211 61 226 177 140 103 39 27 50 54 25 245 241 42 25 249 212 30 21 50 195 254 239 123 186 28 106 182 171 167 192 1 17 220 181 229 65 29 220 177 26 77 33 164 194 57 137 215 150 165 167 78 230 11 102 93 232 177 22 129 68 168 138 74 145 20 77 174 138 188 171 26 218 7 158 76 201 117 72 120 74 35 197 59 52 83 151 20 214 177 144 51 27 46 106 37 249 185 59 56 54 139 16 15 160 136 14 100 37 112 182 53 170 198 119 128 240 69 4 156 161 78 116 240 96 207 121 157 134 99 209 36 25 135 186 1 158 194 175 111 209 32 77 147 190 200 175 225 235 38 195 3 187 88 205 61 89 151 134 217 206 30 162 24 166 113 128 103 66 253 15 50 58 228 210 5 98 8 218 152 80 35 79 62 58 224 7 17 102 207 3 183 140 217 65 56 168 165 22 133 16 133 157 107 128 244 12 ^'}}, + {OUT=>'DFA19180359D5A7A38E842F172359CAF4208FC05'}], + ['193', {IN=> {f=> '517 1 218 150 217 59 81 203 140 217 148 45 193 82 116 122 93 236 7 11 127 242 235 123 155 246 125 238 148 134 126 72 27 247 67 27 50 162 22 247 127 153 45 133 213 121 151 159 105 209 231 36 166 217 177 140 188 53 50 222 148 242 67 87 145 157 250 181 227 177 51 224 63 108 97 174 194 24 162 250 152 132 182 80 33 189 84 60 83 118 37 216 235 94 60 251 154 47 48 110 120 238 208 229 121 43 218 90 91 64 110 12 40 193 111 211 117 64 170 107 35 164 76 54 141 101 4 183 53 79 60 143 213 32 187 169 194 84 31 245 123 66 25 135 39 23 160 78 29 102 95 62 166 20 46 135 128 244 150 246 154 76 143 105 91 172 51 27 158 103 37 108 37 79 199 84 228 119 128 95 91 4 15 17 69 2 11 187 80 230 94 89 89 149 244 239 210 144 18 42 48 139 215 233 179 163 252 67 255 181 167 82 56 253 98 8 42 137 103 205 144 47 137 43 110 149 76 203 200 86 143 16 127 182 140 128 184 55 251 183 142 43 50 54 81 232 9 212 119 236 36 106 122 182 169 223 179 26 185 57 166 80 141 130 99 178 24 44 191 167 219 92 6 187 140 99 89 60 54 249 42 19 44 220 5 214 63 197 30 164 105 180 136 41 195 26 77 116 151 219 231 204 202 1 9 15 214 231 7 40 222 237 206 57 255 13 131 72 224 152 72 87 85 62 255 241 36 77 27 187 229 32 79 228 179 223 90 62 195 115 41 106 93 87 174 26 245 152 161 20 75 4 123 184 84 120 178 113 234 181 78 118 66 85 230 34 251 94 178 53 139 186 138 184 223 61 193 200 175 107 6 38 81 114 207 227 206 146 219 3 73 197 198 200 115 238 11 98 116 240 152 221 146 70 201 88 58 139 126 12 189 252 96 93 176 138 16 156 51 135 99 118 155 49 220 233 119 68 96 64 81 143 45 222 177 111 62 58 79 31 17 218 61 253 69 170 47 197 169 105 120 41 46 224 92 234 92 145 128 155 186 256 243 208 200 26 48 21 156 248 40 104 178 221 175 196 196 28 249 239 150 49 23 71 114 39 191 196 88 87 234 121 240 123 95 151 130 10 214 34 102 35 193 171 49 112 35 104 207 59 170 136 130 159 16 19 241 125 213 ^'}}, + {OUT=>'7B0FA84EBBCFF7D7F4500F73D79660C4A3431B67'}], + ['194', {IN=> {f=> '529 1 15 127 93 2 121 8 104 114 126 176 223 1 183 225 196 90 230 3 119 93 201 117 39 125 97 91 147 41 19 216 80 35 75 110 58 193 198 26 98 8 185 161 103 95 257 71 21 71 199 24 183 144 149 74 52 228 88 255 96 114 66 172 215 61 166 190 167 128 209 36 13 152 186 256 94 199 202 136 128 10 40 21 131 203 32 162 161 184 142 14 210 55 141 37 129 186 78 141 215 82 170 198 107 145 244 65 195 173 192 103 35 214 63 81 54 164 215 1 123 182 227 111 213 227 90 170 219 150 153 184 82 230 202 115 124 2 100 4 96 174 109 141 155 78 201 219 90 149 215 142 213 167 47 162 20 133 118 155 159 248 235 9 183 246 239 59 170 20 154 161 163 99 6 11 38 106 8 206 204 111 35 15 67 89 253 181 250 69 85 164 194 256 154 242 210 115 145 45 108 203 113 209 138 103 176 45 48 160 105 10 121 68 108 122 66 193 258 69 106 207 202 196 171 18 239 38 127 12 214 144 128 70 83 29 71 67 191 84 166 109 120 151 70 2 202 55 81 33 160 246 61 106 147 159 188 192 1 204 229 204 30 247 38 187 55 222 84 145 66 112 211 53 226 173 132 99 27 15 46 46 25 241 233 34 17 241 212 30 9 42 195 254 239 119 174 28 94 178 159 167 188 252 5 212 169 221 65 17 220 169 22 69 25 160 186 57 137 207 142 153 163 78 222 3 98 89 232 177 22 129 68 168 126 74 133 16 65 174 130 184 163 18 218 254 158 72 197 109 60 108 62 23 185 59 52 71 139 20 214 165 132 39 23 46 106 29 249 173 51 52 50 135 12 15 148 136 10 100 25 100 182 49 158 190 107 124 240 57 255 156 157 74 112 232 96 195 113 149 134 95 197 28 13 131 182 248 154 182 167 107 205 28 73 135 190 188 171 217 235 30 187 254 179 76 205 49 77 143 130 205 206 26 158 12 154 101 120 91 66 253 3 38 46 224 198 5 94 206 144 68 27 75 50 54 224 258 9 102 199 3 179 136 209 57 56 160 165 14 129 8 125 157 95 116 240 36 212 148 217 57 77 203 134 213 146 43 193 80 116 122 87 236 7 9 123 242 231 119 153 244 125 238 142 132 120 70 23 245 63 21 50 156 16 243 127 153 45 129 207 121 149 155 99 205 227 30 166 211 57 ^'}}, + {OUT=>'9E886081C9ACAAD0F97B10810D1DE6FCDCE6B5F4'}], + ['195', {IN=> {f=> '548 0 134 188 53 47 219 148 236 58 84 142 148 247 172 224 174 45 221 63 99 97 171 194 15 156 250 149 132 179 71 30 183 78 54 77 118 37 207 232 94 60 248 151 47 42 110 117 235 205 223 112 43 212 81 82 61 101 12 34 190 102 208 117 58 167 104 29 164 76 45 138 101 1 180 50 70 51 143 210 32 181 163 191 81 31 245 123 63 16 135 30 17 154 75 26 93 92 62 163 14 43 129 119 244 144 240 148 70 134 105 91 166 42 27 155 94 28 102 31 79 199 84 225 110 128 89 85 255 9 17 60 259 5 187 74 224 91 83 80 146 238 233 207 138 18 39 39 133 209 230 179 154 252 64 255 175 158 82 50 247 89 2 33 128 100 199 135 41 131 34 107 140 67 200 197 86 140 16 124 176 137 122 178 52 245 174 139 37 41 48 72 226 6 206 119 233 30 100 116 173 160 214 173 26 176 54 160 80 135 124 93 175 24 44 191 164 210 83 257 184 140 99 86 57 54 243 42 16 41 214 256 205 57 188 21 161 99 180 133 32 192 17 71 113 145 219 231 198 199 1 3 12 211 228 4 31 213 237 203 48 249 4 125 72 215 152 66 87 76 56 252 241 33 77 24 178 229 23 76 222 176 220 84 59 186 106 38 103 93 81 165 23 242 146 155 11 66 4 114 175 75 120 169 113 228 181 69 115 60 82 227 25 251 85 172 47 136 186 138 184 223 61 184 191 175 107 6 29 81 114 207 221 197 137 216 254 73 194 192 194 109 232 11 98 107 234 143 221 146 61 195 88 55 139 120 3 189 249 87 87 170 132 13 147 51 132 96 109 149 49 217 233 113 62 257 90 64 78 137 39 216 171 111 53 58 73 28 8 215 58 250 66 170 38 197 169 102 114 41 37 218 86 234 92 145 125 155 177 250 243 208 200 20 48 21 150 245 40 101 178 218 169 196 190 19 246 236 141 46 23 65 108 36 188 187 85 78 231 115 237 120 86 151 130 4 208 34 96 26 187 168 40 112 32 98 201 50 164 127 121 159 7 19 235 122 1 14 126 91 118 5 104 112 126 174 222 259 182 225 193 90 230 2 116 90 198 116 39 122 95 90 147 40 18 216 77 35 75 109 55 190 196 24 95 7 185 159 101 95 256 71 19 69 198 22 180 144 146 72 49 228 87 253 94 111 64 172 213 60 165 189 166 125 206 36 11 149 183 255 92 196 201 133 126 8 38 20 131 213 ^'}}, + {OUT=>'A4D46E4BA0AE4B012F75B1B50D0534D578AE9CB6'}], + ['196', {IN=> {f=> '547 0 29 162 161 178 142 14 207 49 141 31 120 183 72 135 212 73 161 198 101 136 238 59 189 173 192 94 29 205 60 78 48 158 206 254 114 176 227 102 213 224 87 164 213 150 147 175 76 227 196 112 124 255 97 1 93 171 109 132 146 75 201 210 84 149 215 139 210 158 38 153 14 133 109 152 156 248 232 9 183 240 236 50 167 17 148 158 163 93 3 8 32 103 8 200 204 108 32 9 58 89 247 175 244 66 85 155 191 256 154 239 210 115 139 42 108 200 110 209 132 103 176 39 42 151 99 10 115 65 102 119 63 187 258 69 100 204 202 193 171 15 233 35 118 6 211 141 125 70 83 29 68 67 185 81 157 106 117 148 64 2 193 46 75 33 160 246 55 97 138 153 182 183 260 195 223 198 27 247 38 184 55 222 78 142 57 106 211 47 226 170 126 96 18 6 43 40 25 238 227 28 11 235 212 30 36 195 254 239 116 165 28 85 175 150 167 185 249 258 206 160 215 65 8 220 163 19 63 19 157 180 57 137 201 136 144 160 78 216 259 95 86 232 177 22 129 68 168 117 74 124 13 56 174 124 181 157 12 218 248 158 69 194 103 51 99 53 14 176 59 52 62 130 20 214 156 123 30 20 46 106 23 249 164 45 49 47 132 9 15 139 136 7 100 16 91 182 46 149 184 98 121 240 48 252 156 154 71 109 226 96 186 107 143 134 92 188 22 4 128 179 242 151 173 161 104 202 25 70 126 190 179 168 211 235 24 181 251 173 67 205 40 68 137 127 196 206 23 155 3 145 92 114 82 66 253 256 29 37 221 189 5 91 256 197 138 59 21 72 41 51 224 255 3 102 193 3 176 133 203 51 56 154 165 8 126 2 119 157 86 107 237 33 203 145 217 54 71 203 125 207 143 40 193 77 116 122 78 236 7 6 117 242 225 113 150 241 125 238 133 129 111 67 17 242 57 12 50 147 7 237 127 153 45 123 198 121 146 149 90 199 221 21 166 202 162 130 188 53 45 217 148 232 52 82 140 142 245 166 222 172 41 219 63 93 97 169 194 9 152 250 147 132 177 65 28 179 74 50 73 118 37 201 230 94 60 246 149 47 38 110 115 233 203 219 106 43 208 75 76 59 95 12 30 188 96 206 117 54 165 102 25 164 76 39 136 101 261 178 48 64 45 143 208 32 177 159 189 79 31 245 123 61 10 135 24 13 150 73 24 87 90 62 161 10 41 125 209 ^'}}, + {OUT=>'6342B199EE64C7B2C9CBCD4F2DCB65ACEF51516F'}], + ['197', {IN=> {f=> '542 1 244 136 232 140 62 122 105 91 158 30 27 151 82 16 94 23 79 199 84 221 98 128 81 77 247 1 17 48 259 261 187 66 216 87 75 68 142 230 225 203 130 18 35 27 125 201 226 179 142 252 60 255 167 146 82 42 239 77 258 21 116 96 191 123 33 123 22 103 128 55 196 193 86 136 16 120 168 133 114 170 48 237 162 135 29 29 40 60 218 2 198 119 229 22 92 108 161 148 202 165 26 164 50 152 80 127 116 85 171 24 44 191 160 198 71 249 180 140 99 82 53 54 235 42 12 37 206 248 193 49 176 9 157 91 180 129 20 188 5 63 109 137 219 231 190 195 1 259 8 207 224 19 201 237 199 36 241 256 117 72 203 152 58 87 64 48 248 241 29 77 20 166 229 11 72 214 172 216 76 55 174 94 34 99 93 73 153 19 238 138 147 263 54 4 102 163 63 120 157 113 220 181 57 111 52 78 223 13 251 73 164 39 132 186 138 184 223 61 172 179 175 107 6 17 81 114 207 213 185 125 212 246 73 190 184 186 101 224 11 98 95 226 131 221 146 49 187 88 51 139 112 255 189 245 75 79 162 124 9 135 51 128 92 97 141 49 213 233 105 54 257 82 64 74 129 31 208 163 111 41 58 65 24 260 211 54 246 62 170 26 197 169 98 106 41 25 210 78 234 92 145 121 155 165 242 243 208 200 12 48 21 142 241 40 97 178 214 161 196 182 7 242 232 129 42 23 57 100 32 184 175 81 66 227 107 233 116 74 151 130 260 200 34 88 14 179 164 28 112 28 90 193 38 156 115 109 159 259 19 227 118 253 10 122 83 256 106 257 104 104 126 166 218 255 178 225 181 90 230 262 104 78 186 112 39 110 87 86 147 36 14 216 65 35 75 105 43 178 188 16 83 3 185 151 93 95 252 71 11 61 194 14 168 144 134 64 37 228 83 245 86 99 56 172 205 56 161 185 162 113 194 36 3 137 171 251 84 184 197 121 118 30 16 131 188 27 162 161 174 142 14 205 45 141 27 114 181 68 131 210 67 155 198 97 130 234 55 185 173 192 88 25 199 58 76 44 154 200 250 108 172 227 96 213 222 85 160 209 150 143 169 72 225 192 110 124 251 95 263 91 169 109 126 140 73 201 204 80 149 215 137 208 152 32 147 10 133 103 150 154 248 230 9 183 236 234 44 165 15 144 156 163 89 1 6 28 101 8 196 204 106 164 ^'}}, + {OUT=>'AABFD63688EB678357869130083E1B52F6EA861D'}], + ['198', {IN=> {f=> '567 0 1 46 89 239 167 236 62 85 143 187 256 154 235 210 115 131 38 108 196 106 209 124 103 176 31 34 139 91 10 107 61 94 115 59 179 258 69 92 200 202 189 171 11 225 31 106 264 207 137 121 70 83 29 64 67 177 77 145 102 113 144 56 2 181 34 67 33 160 246 47 85 126 145 174 171 260 183 215 190 23 247 38 180 55 222 70 138 45 98 211 39 226 166 118 92 6 260 39 32 25 234 219 20 3 227 212 30 254 28 195 254 239 112 153 28 73 171 138 167 181 245 250 198 148 207 65 262 220 155 15 55 11 153 172 57 137 193 128 132 156 78 208 255 91 82 232 177 22 129 68 168 105 74 112 9 44 174 116 177 149 4 218 240 158 65 190 95 39 87 41 2 164 59 52 50 118 20 214 144 111 18 16 46 106 15 249 152 37 45 43 128 5 15 127 136 3 100 4 79 182 42 137 176 86 117 240 36 248 156 150 67 105 218 96 174 99 135 134 88 176 14 258 124 175 234 147 161 153 100 198 21 66 114 190 167 164 203 235 16 173 247 165 55 205 28 56 129 123 184 206 19 151 257 133 80 106 70 66 253 248 17 25 217 177 5 87 252 185 130 47 13 68 29 47 224 251 261 102 185 3 172 129 195 43 56 146 165 122 260 111 157 74 95 233 29 191 141 217 50 63 203 113 199 139 36 193 73 116 122 66 236 7 2 109 242 217 105 146 237 125 238 121 125 99 63 9 238 49 50 135 261 229 127 153 45 115 186 121 142 141 78 191 213 9 166 190 150 122 188 53 41 213 148 224 40 78 136 130 241 154 218 168 33 215 63 81 97 165 194 263 144 250 143 132 173 53 24 171 66 42 65 118 37 189 226 94 60 242 145 47 30 110 111 229 199 211 94 43 200 63 64 55 83 12 22 184 84 202 117 46 161 98 17 164 76 27 132 101 261 174 44 52 33 143 204 32 169 151 185 75 31 245 123 57 264 135 12 5 142 69 20 75 86 62 157 2 37 117 101 244 132 228 136 58 116 105 91 154 24 27 149 76 10 90 19 79 199 84 219 92 128 77 73 243 263 17 42 259 259 187 62 212 85 71 62 140 226 221 201 126 18 33 21 121 197 224 179 136 252 58 255 163 140 82 38 235 71 256 15 110 94 187 117 29 119 16 101 122 49 194 191 86 134 16 118 164 131 110 166 46 233 156 133 25 23 36 54 214 194 119 227 18 88 104 155 142 196 161 26 158 48 148 80 123 112 81 169 24 44 191 158 192 65 245 178 140 223 ^'}}, + {OUT=>'F732B7372DAF44801F81EFFE3108726239837936'}], + ['199', {IN=> {f=> '551 1 78 49 54 227 42 8 33 198 240 181 41 164 265 153 83 180 125 8 184 261 55 105 129 219 231 182 191 1 255 4 203 220 264 7 189 237 195 24 233 248 109 72 191 152 50 87 52 40 244 241 25 77 16 154 229 267 68 206 168 212 68 51 162 82 30 95 93 65 141 15 234 130 139 255 42 4 90 151 51 120 145 113 212 181 45 107 44 74 219 1 251 61 156 31 128 186 138 184 223 61 160 167 175 107 6 5 81 114 207 205 173 113 208 238 73 186 176 178 93 216 11 98 83 218 119 221 146 37 179 88 47 139 104 247 189 241 63 71 154 116 5 123 51 124 88 85 133 49 209 233 97 46 257 74 64 70 121 23 200 155 111 29 58 57 20 252 207 50 242 58 170 14 197 169 94 98 41 13 202 70 234 92 145 117 155 153 234 243 208 200 4 48 21 134 237 40 93 178 210 153 196 174 263 238 228 117 38 23 49 92 28 180 163 77 54 223 99 229 112 62 151 130 256 192 34 80 2 171 160 16 112 24 82 185 26 148 103 97 159 251 19 219 114 245 6 118 75 252 94 249 104 96 126 158 214 251 174 225 169 90 230 262 92 66 174 108 39 98 79 82 147 32 10 216 53 35 75 101 31 166 180 8 71 267 185 143 85 95 248 71 3 53 190 6 156 144 122 56 25 228 79 237 78 87 48 172 197 52 157 181 158 101 182 36 263 125 159 247 76 172 193 109 110 260 22 12 131 176 23 162 161 166 142 14 201 37 141 19 102 177 60 123 206 55 143 198 89 118 226 47 177 173 192 76 17 187 54 72 36 146 188 242 96 164 227 84 213 218 81 152 201 150 135 157 64 221 184 106 124 243 91 263 87 165 109 114 128 69 201 192 72 149 215 133 204 140 20 135 2 133 91 146 150 248 226 9 183 228 230 32 161 11 136 152 163 81 265 2 20 97 8 188 204 102 26 265 40 89 235 163 232 60 85 137 185 256 154 233 210 115 127 36 108 194 104 209 120 103 176 27 30 133 87 10 103 59 90 113 57 175 258 69 88 198 202 187 171 9 221 29 100 262 205 135 119 70 83 29 62 67 173 75 139 100 111 142 52 2 175 28 63 33 160 246 43 79 120 141 170 165 260 177 211 186 21 247 38 178 55 222 66 136 39 94 211 35 226 164 114 90 256 37 28 25 232 215 16 267 223 212 30 250 24 195 254 239 110 147 28 67 169 132 167 179 243 246 194 142 203 65 263 ^'}}, + {OUT=>'5E9347FE4574CDCB80281ED092191199BADD7B42'}], + ['200', {IN=> {f=> '578 0 220 147 11 47 3 149 164 57 137 185 120 120 152 78 200 251 87 78 232 177 22 129 68 168 93 74 100 5 32 174 108 173 141 266 218 232 158 61 186 87 27 75 29 260 152 59 52 38 106 20 214 132 99 6 12 46 106 7 249 140 29 41 39 124 1 15 115 136 269 100 262 67 182 38 125 168 74 113 240 24 244 156 146 63 101 210 96 162 91 127 134 84 164 6 250 120 171 226 143 149 145 96 194 17 62 102 190 155 160 195 235 8 165 243 157 43 205 16 44 121 119 172 206 15 147 249 121 68 98 58 66 253 240 5 13 213 165 5 83 248 173 122 35 5 64 17 43 224 247 257 102 177 3 168 125 187 35 56 138 165 262 118 256 103 157 62 83 229 25 179 137 217 46 55 203 101 191 135 32 193 69 116 122 54 236 7 268 101 242 209 97 142 233 125 238 109 121 87 59 1 234 41 258 50 123 253 221 127 153 45 107 174 121 138 133 66 183 205 267 166 178 138 114 188 53 37 209 148 216 28 74 132 118 237 142 214 164 25 211 63 69 97 161 194 255 136 250 139 132 169 41 20 163 58 34 57 118 37 177 222 94 60 238 141 47 22 110 107 225 195 203 82 43 192 51 52 51 71 12 14 180 72 198 117 38 157 94 9 164 76 15 128 101 261 170 40 40 21 143 200 32 161 143 181 71 31 245 123 53 256 135 267 134 65 16 63 82 62 153 264 33 109 89 244 124 220 128 50 104 105 91 146 12 27 145 64 268 82 11 79 199 84 215 80 128 69 65 235 259 17 30 259 255 187 54 204 81 63 50 136 218 213 197 118 18 29 9 113 189 220 179 124 252 54 255 155 128 82 30 227 59 252 3 98 90 179 105 21 111 4 97 110 37 190 187 86 130 16 114 156 127 102 158 42 225 144 129 17 11 28 42 206 266 186 119 223 10 80 96 143 130 184 153 26 146 44 140 80 115 104 73 165 24 44 191 154 180 53 237 174 140 99 76 47 54 223 42 6 31 194 236 175 37 158 261 151 79 180 123 2 182 257 51 103 125 219 231 178 189 1 253 2 201 218 264 1 183 237 193 18 229 244 105 72 185 152 46 87 46 36 242 241 23 77 14 148 229 263 66 202 166 210 64 49 156 76 28 93 93 61 135 13 232 126 135 251 36 4 84 145 45 120 139 113 208 181 39 105 40 72 217 265 251 55 152 27 126 186 138 184 223 61 154 161 175 107 6 269 81 114 207 201 167 107 206 234 73 184 172 174 89 212 11 98 77 214 113 221 146 31 175 88 45 139 100 243 189 213 ^'}}, + {OUT=>'D5776B7DFFF75C1358ABDBBB3F27A20BB6CA7C55'}], + ['201', {IN=> {f=> '578 1 51 63 146 108 1 111 51 120 84 73 125 49 205 233 89 38 257 66 64 66 113 15 192 147 111 17 58 49 16 244 203 46 238 54 170 2 197 169 90 90 41 1 194 62 234 92 145 113 155 141 226 243 208 200 268 48 21 126 233 40 89 178 206 145 196 166 255 234 224 105 34 23 41 84 24 176 151 73 42 219 91 225 108 50 151 130 252 184 34 72 262 163 156 4 112 20 74 177 14 140 91 85 159 243 19 211 110 237 2 114 67 248 82 241 104 88 126 150 210 247 170 225 157 90 230 262 80 54 162 104 39 86 71 78 147 28 6 216 41 35 75 97 19 154 172 59 267 185 135 77 95 244 71 267 45 186 270 144 144 110 48 13 228 75 229 70 75 40 172 189 48 153 177 154 89 170 36 259 113 147 243 68 160 189 97 102 256 14 8 131 164 19 162 161 158 142 14 197 29 141 11 90 173 52 115 202 43 131 198 81 106 218 39 169 173 192 64 9 175 50 68 28 138 176 234 84 156 227 72 213 214 77 144 193 150 127 145 56 217 176 102 124 235 87 263 83 161 109 102 116 65 201 180 64 149 215 129 200 128 8 123 266 133 79 142 146 248 222 9 183 220 226 20 157 7 128 148 163 73 265 270 12 93 8 180 204 98 22 261 28 89 227 155 224 56 85 125 181 256 154 229 210 115 119 32 108 190 100 209 112 103 176 19 22 121 79 10 95 55 82 109 53 167 258 69 80 194 202 183 171 5 213 25 88 258 201 131 115 70 83 29 58 67 165 71 127 96 107 138 44 2 163 16 55 33 160 246 35 67 108 133 162 153 260 165 203 178 17 247 38 174 55 222 58 132 27 86 211 27 226 160 106 86 260 248 33 20 25 228 207 8 263 215 212 30 242 16 195 254 239 106 135 28 55 165 120 167 175 239 238 186 130 195 65 250 220 143 9 43 271 147 160 57 137 181 116 114 150 78 196 249 85 76 232 177 22 129 68 168 87 74 94 3 26 174 104 171 137 264 218 228 158 59 184 83 21 69 23 256 146 59 52 32 100 20 214 126 93 10 46 106 3 249 134 25 39 37 122 271 15 109 136 269 100 258 61 182 36 119 164 68 111 240 18 242 156 144 61 99 206 96 156 87 123 134 82 158 2 246 118 169 222 141 143 141 94 192 15 60 96 190 149 158 191 235 4 161 241 153 37 205 10 38 117 117 166 206 13 145 245 115 62 94 52 66 253 236 271 7 211 159 5 81 246 167 118 29 1 62 11 41 224 245 255 102 173 3 166 123 183 31 56 134 165 260 116 254 81 ^'}}, + {OUT=>'022B7ADA472FB7A9DA9219621C9C5F563D3792F6'}], + ['202', {IN=> {f=> '583 1 157 50 71 225 21 167 133 217 42 47 203 89 183 131 28 193 65 116 122 42 236 7 268 93 242 201 89 138 229 125 238 97 117 75 55 267 230 33 250 50 111 245 213 127 153 45 99 162 121 134 125 54 175 197 259 166 166 126 106 188 53 33 205 148 208 16 70 128 106 233 130 210 160 17 207 63 57 97 157 194 247 128 250 135 132 165 29 16 155 50 26 49 118 37 165 218 94 60 234 137 47 14 110 103 221 191 195 70 43 184 39 40 47 59 12 6 176 60 194 117 30 153 90 1 164 76 3 124 101 261 166 36 28 9 143 196 32 153 135 177 67 31 245 123 49 248 135 262 263 126 61 12 51 78 62 149 260 29 101 77 244 116 212 120 42 92 105 91 138 27 141 52 260 74 3 79 199 84 211 68 128 61 57 227 255 17 18 259 251 187 46 196 77 55 38 132 210 205 193 110 18 25 271 105 181 216 179 112 252 50 255 147 116 82 22 219 47 248 265 86 86 171 93 13 103 266 93 98 25 186 183 86 126 16 110 148 123 94 150 38 217 132 125 9 273 20 30 198 266 178 119 219 2 72 88 131 118 172 145 26 134 40 132 80 107 96 65 161 24 44 191 150 168 41 229 170 140 99 72 43 54 215 42 2 27 186 228 163 29 146 253 147 71 180 119 264 178 249 43 99 117 219 231 170 185 1 249 272 197 214 264 263 171 237 189 6 221 236 97 72 173 152 38 87 34 28 238 241 19 77 10 136 229 255 62 194 162 206 56 45 144 64 24 89 93 53 123 9 228 118 127 243 24 4 72 133 33 120 127 113 200 181 27 101 32 68 213 257 251 43 144 19 122 186 138 184 223 61 142 149 175 107 6 261 81 114 207 193 155 95 202 226 73 180 164 166 81 204 11 98 65 206 101 221 146 19 167 88 41 139 92 235 189 235 45 59 142 104 273 105 51 118 82 67 121 49 203 233 85 34 257 62 64 64 109 11 188 143 111 11 58 45 14 240 201 44 236 52 170 270 197 169 88 86 41 269 190 58 234 92 145 111 155 135 222 243 208 200 266 48 21 122 231 40 87 178 204 141 196 162 251 232 222 99 32 23 37 80 22 174 145 71 36 217 87 223 106 44 151 130 250 180 34 68 258 159 154 272 112 18 70 173 8 136 85 79 159 239 19 207 108 233 112 63 246 76 237 104 84 126 146 208 245 168 225 151 90 230 262 74 48 156 102 39 80 67 76 147 26 4 216 35 35 75 95 13 148 168 270 53 267 185 131 73 95 242 71 265 41 184 268 138 144 104 44 7 228 73 225 66 69 36 272 ^'}}, + {OUT=>'7F1DE4ECA20362DA624653D225A5B3F7964A9FF2'}], + ['203', {IN=> {f=> '588 0 181 44 149 173 150 77 158 36 255 101 135 239 60 148 185 85 94 252 6 4 131 152 15 162 161 150 142 14 193 21 141 3 78 169 44 107 198 31 119 198 73 94 210 31 161 173 192 52 1 163 46 64 20 130 164 226 72 148 227 60 213 210 73 136 185 150 119 133 48 213 168 98 124 227 83 263 79 157 109 90 104 61 201 168 56 149 215 125 196 116 272 111 262 133 67 138 142 248 218 9 183 212 222 8 153 3 120 144 163 65 265 270 4 89 8 172 204 94 18 257 16 89 219 147 216 52 85 113 177 256 154 225 210 115 111 28 108 186 96 209 104 103 176 11 14 109 71 10 87 51 74 105 49 159 258 69 72 190 202 179 171 1 205 21 76 254 197 127 111 70 83 29 54 67 157 67 115 92 103 134 36 2 151 4 47 33 160 246 27 55 96 125 154 141 260 153 195 170 13 247 38 170 55 222 50 128 15 78 211 19 226 156 98 82 252 240 29 12 25 224 199 259 207 212 30 234 8 195 254 239 102 123 28 43 161 108 167 171 235 230 178 118 187 65 242 220 135 5 35 267 143 152 57 137 173 108 102 146 78 188 245 81 72 232 177 22 129 68 168 75 74 82 275 14 174 96 167 129 260 218 220 158 55 180 75 9 57 11 248 134 59 52 20 88 20 214 114 81 264 6 46 106 271 249 122 17 35 33 118 271 15 97 136 269 100 250 49 182 32 107 156 56 107 240 6 238 156 140 57 95 198 96 144 79 115 134 78 146 270 238 114 165 214 137 131 133 90 188 11 56 84 190 137 154 183 235 272 153 237 145 25 205 274 26 109 113 154 206 9 141 237 103 50 86 40 66 253 228 263 271 207 147 5 77 242 155 110 17 269 58 275 37 224 241 251 102 165 3 162 119 175 23 56 126 165 256 112 250 91 157 44 65 223 19 161 131 217 40 43 203 83 179 129 26 193 63 116 122 36 236 7 268 89 242 197 85 136 227 125 238 91 115 69 53 265 228 29 246 50 105 241 209 127 153 45 95 156 121 132 121 48 171 193 255 166 160 120 102 188 53 31 203 148 204 10 68 126 100 231 124 208 158 13 205 63 51 97 155 194 243 124 250 133 132 163 23 14 151 46 22 45 118 37 159 216 94 60 232 135 47 10 110 101 219 189 191 64 43 180 33 34 45 53 12 2 174 54 192 117 26 151 88 273 164 76 273 122 101 261 164 34 22 3 143 194 32 149 131 175 65 31 245 123 47 244 135 258 261 122 59 10 45 76 62 147 258 27 97 71 244 112 208 116 38 86 105 91 134 270 27 139 46 256 70 275 79 199 160 ^'}}, + {OUT=>'CA0F2B1BFB4469C11ED006A994734F0F2F5EFD17'}], + ['204', {IN=> {f=> '594 0 207 56 128 53 49 219 251 17 6 259 247 187 38 188 73 47 26 128 202 197 189 102 18 21 263 97 173 212 179 100 252 46 255 139 104 82 14 211 35 244 257 74 82 163 81 5 95 258 89 86 13 182 179 86 122 16 106 140 119 86 142 34 209 120 121 1 265 12 18 190 266 170 119 215 272 64 80 119 106 160 137 26 122 36 124 80 99 88 57 157 24 44 191 146 156 29 221 166 140 99 68 39 54 207 42 276 23 178 220 151 21 134 245 143 63 180 115 256 174 241 35 95 109 219 231 162 181 1 245 272 193 210 264 255 159 237 185 272 213 228 89 72 161 152 30 87 22 20 234 241 15 77 6 124 229 247 58 186 158 202 48 41 132 52 20 85 93 45 111 5 224 110 119 235 12 4 60 121 21 120 115 113 192 181 15 97 24 64 209 249 251 31 136 11 118 186 138 184 223 61 130 137 175 107 6 253 81 114 207 185 143 83 198 218 73 176 156 158 73 196 11 98 53 198 89 221 146 7 159 88 37 139 84 227 189 231 33 51 134 96 273 93 51 114 78 55 113 49 199 233 77 26 257 54 64 60 101 3 180 135 111 277 58 37 10 232 197 40 232 48 170 262 197 169 84 78 41 261 182 50 234 92 145 107 155 123 214 243 208 200 262 48 21 114 227 40 83 178 200 133 196 154 243 228 218 87 28 23 29 72 18 170 133 67 24 213 79 219 102 32 151 130 246 172 34 60 250 151 150 264 112 14 62 165 274 128 73 67 159 231 19 199 104 225 274 108 55 242 64 229 104 76 126 138 204 241 164 225 139 90 230 262 62 36 144 98 39 68 59 72 147 22 216 23 35 75 91 1 136 160 266 41 267 185 123 65 95 238 71 261 33 180 264 126 144 92 36 273 228 69 217 58 57 28 172 177 42 147 171 148 71 152 36 253 95 129 237 56 142 183 79 90 250 2 2 131 146 13 162 161 146 142 14 191 17 141 277 72 167 40 103 196 25 113 198 69 88 206 27 157 173 192 46 275 157 44 62 16 126 158 222 66 144 227 54 213 208 71 132 181 150 115 127 44 211 164 96 124 223 81 263 77 155 109 84 98 59 201 162 52 149 215 123 194 110 268 105 260 133 61 136 140 248 216 9 183 208 220 2 151 1 116 142 163 61 265 270 87 8 168 204 92 16 255 10 89 215 143 212 50 85 107 175 256 154 223 210 115 107 26 108 184 94 209 100 103 176 7 10 103 67 10 83 49 70 103 47 155 258 69 68 188 202 177 171 277 201 19 70 252 195 125 109 70 83 29 52 67 153 65 109 90 101 132 32 2 145 276 43 33 160 246 23 259 ^'}}, + {OUT=>'833D63F5C2EA0CD43EC15F2B9DD97FF12B030479'}], + ['205', {IN=> {f=> '600 1 87 119 148 132 260 144 189 164 10 247 38 167 55 222 44 125 6 72 211 13 226 153 92 79 246 234 26 6 25 221 193 273 256 201 212 30 228 2 195 254 239 99 114 28 34 158 99 167 168 232 224 172 109 181 65 236 220 129 2 29 264 140 146 57 137 167 102 93 143 78 182 242 78 69 232 177 22 129 68 168 66 74 73 275 5 174 90 164 123 257 218 214 158 52 177 69 48 2 242 125 59 52 11 79 20 214 105 72 258 3 46 106 268 249 113 11 32 30 115 271 15 88 136 269 100 244 40 182 29 98 150 47 104 240 276 235 156 137 54 92 192 96 135 73 109 134 75 137 267 232 111 162 208 134 122 127 87 185 8 53 75 190 128 151 177 235 269 147 234 139 16 205 268 17 103 110 145 206 6 138 231 94 41 80 31 66 253 222 257 265 204 138 5 74 239 146 104 8 266 55 269 34 224 238 248 102 159 3 159 116 169 17 56 120 165 253 109 247 85 157 35 56 220 16 152 128 217 37 37 203 74 173 126 23 193 60 116 122 27 236 7 268 83 242 191 79 133 224 125 238 82 112 60 50 262 225 23 240 50 96 235 203 127 153 45 89 147 121 129 115 39 165 187 249 166 151 111 96 188 53 28 200 148 198 1 65 123 91 228 115 205 155 7 202 63 42 97 152 194 237 118 250 130 132 160 14 11 145 40 16 39 118 37 150 213 94 60 229 132 47 4 110 98 216 186 185 55 43 174 24 25 42 44 12 275 171 45 189 117 20 148 85 270 164 76 267 119 101 261 161 31 13 273 143 191 32 143 125 172 62 31 245 123 44 238 135 252 258 116 56 7 36 73 62 144 255 24 91 62 244 106 202 110 32 77 105 91 128 264 27 136 37 250 64 272 79 199 84 206 53 128 51 47 217 250 17 3 259 246 187 36 186 72 45 23 127 200 195 188 100 18 20 261 95 171 211 179 97 252 45 255 137 101 82 12 209 32 243 255 71 81 161 78 3 93 256 88 83 10 181 178 86 121 16 105 138 118 84 140 33 207 117 120 278 263 10 15 188 266 168 119 214 271 62 78 116 103 157 135 26 119 35 122 80 97 86 55 156 24 44 191 145 153 26 219 165 140 99 67 38 54 205 42 276 22 176 218 148 19 131 243 142 61 180 114 254 173 239 33 94 107 219 231 160 180 1 244 272 192 209 264 253 156 237 184 270 211 226 87 72 158 152 28 87 19 18 233 241 14 77 5 121 229 245 57 184 157 201 46 40 129 49 19 84 93 43 108 4 223 108 117 233 9 4 57 118 18 120 112 113 190 181 12 96 22 63 208 247 251 28 134 9 117 186 138 184 223 61 127 216 ^'}}, + {OUT=>'14FD356190416C00592B86FF7CA50B622F85593A'}], + ['206', {IN=> {f=> '590 1 175 107 6 247 81 114 207 179 134 74 195 212 73 173 150 152 67 190 11 98 44 192 80 221 146 279 153 88 34 139 78 221 189 228 24 45 128 90 273 84 51 111 75 46 107 49 196 233 71 20 257 48 64 57 95 278 174 129 111 271 58 31 7 226 194 37 229 45 170 256 197 169 81 72 41 255 176 44 234 92 145 104 155 114 208 243 208 200 259 48 21 108 224 40 80 178 197 127 196 148 237 225 215 78 25 23 23 66 15 167 124 64 15 210 73 216 99 23 151 130 243 166 34 54 244 145 147 258 112 11 56 159 268 122 64 58 159 225 19 193 101 219 274 105 49 239 55 223 104 70 126 132 201 238 161 225 130 90 230 262 53 27 135 95 39 59 53 69 147 19 278 216 14 35 75 88 273 127 154 263 32 267 185 117 59 95 235 71 258 27 177 261 117 144 83 30 267 228 66 211 52 48 22 172 171 39 144 168 145 62 143 36 250 86 120 234 50 133 180 70 84 247 277 280 131 137 10 162 161 140 142 14 188 11 141 274 63 164 34 97 193 16 104 198 63 79 200 21 151 173 192 37 272 148 41 59 10 120 149 216 57 138 227 45 213 205 68 126 175 150 109 118 38 208 158 93 124 217 78 263 74 152 109 75 89 56 201 153 46 149 215 120 191 101 262 96 257 133 52 133 137 248 213 9 183 202 217 274 148 279 110 139 163 55 265 270 275 84 8 162 204 89 13 252 1 89 209 137 206 47 85 98 172 256 154 220 210 115 101 23 108 181 91 209 94 103 176 1 4 94 61 10 77 46 64 100 44 149 258 69 62 185 202 174 171 277 195 16 61 249 192 122 106 70 83 29 49 67 147 62 100 87 98 129 26 2 136 270 37 33 160 246 17 40 81 115 144 126 260 138 185 160 8 247 38 165 55 222 40 123 68 211 9 226 151 88 77 242 230 24 2 25 219 189 271 254 197 212 30 224 279 195 254 239 97 108 28 28 156 93 167 166 230 220 168 103 177 65 232 220 125 25 262 138 142 57 137 163 98 87 141 78 178 240 76 67 232 177 22 129 68 168 60 74 67 275 280 174 86 162 119 255 218 210 158 50 175 65 275 42 277 238 119 59 52 5 73 20 214 99 66 254 1 46 106 266 249 107 7 30 28 113 271 15 82 136 269 100 240 34 182 27 92 146 41 102 240 272 233 156 135 52 90 188 96 129 69 105 134 73 131 265 228 109 160 204 132 116 123 85 183 6 51 69 190 122 149 173 235 267 143 232 135 10 205 264 11 99 108 139 206 4 136 227 88 35 76 25 66 253 218 253 261 202 132 5 72 237 140 203 ^'}}, + {OUT=>'4AB6B57EDDEF1CE935622F935C1619AE7C1667D6'}], + ['207', {IN=> {f=> '620 0 279 262 51 261 30 224 234 244 102 151 3 155 112 161 9 56 112 165 249 105 243 77 157 23 44 216 12 140 124 217 33 29 203 62 165 122 19 193 56 116 122 15 236 7 268 75 242 183 71 129 220 125 238 70 108 48 46 258 221 15 232 50 84 227 195 127 153 45 81 135 121 125 107 27 157 179 241 166 139 99 88 188 53 24 196 148 190 272 61 119 79 224 103 201 151 282 198 63 30 97 148 194 229 110 250 126 132 156 2 7 137 32 8 31 118 37 138 209 94 60 225 128 47 279 110 94 212 182 177 43 43 166 12 13 38 32 12 271 167 33 185 117 12 144 81 266 164 76 259 115 101 261 157 27 1 265 143 187 32 135 117 168 58 31 245 123 40 230 135 244 254 108 52 3 24 69 62 140 251 20 83 50 244 98 194 102 24 65 105 91 120 256 27 132 25 242 56 268 79 199 84 202 41 128 43 39 209 246 17 274 259 242 187 28 178 68 37 11 123 192 187 184 92 18 16 253 87 163 207 179 85 252 41 255 129 89 82 4 201 20 239 247 59 77 153 66 278 85 248 84 71 281 177 174 86 117 16 101 130 114 76 132 29 199 105 116 274 255 2 3 180 266 160 119 210 267 54 70 104 91 145 127 26 107 31 114 80 89 78 47 152 24 44 191 141 141 14 211 161 140 99 63 34 54 197 42 276 18 168 210 136 11 119 235 138 53 180 110 246 169 231 25 90 99 219 231 152 176 1 240 272 188 205 264 245 144 237 180 262 203 218 79 72 146 152 20 87 7 10 229 241 10 77 1 109 229 237 53 176 153 197 38 36 117 37 15 80 93 35 96 219 100 109 225 280 4 45 106 6 120 100 113 182 181 92 14 59 204 239 251 16 126 1 113 186 138 184 223 61 115 122 175 107 6 243 81 114 207 175 128 68 193 208 73 171 146 148 63 186 11 98 38 188 74 221 146 275 149 88 32 139 74 217 189 226 18 41 124 86 273 78 51 109 73 40 103 49 194 233 67 16 257 44 64 55 91 276 170 125 111 267 58 27 5 222 192 35 227 43 170 252 197 169 79 68 41 251 172 40 234 92 145 102 155 108 204 243 208 200 257 48 21 104 222 40 78 178 195 123 196 144 233 223 213 72 23 23 19 62 13 165 118 62 9 208 69 214 97 17 151 130 241 162 34 50 240 141 145 254 112 9 52 155 264 118 58 52 159 221 19 189 99 215 274 103 45 237 49 219 104 66 126 128 199 236 159 225 124 90 230 262 47 21 129 93 39 53 49 67 147 17 278 216 8 35 75 86 269 121 150 261 26 267 185 113 55 95 233 71 256 23 175 259 111 144 77 26 263 228 64 207 48 42 18 172 167 37 142 166 143 56 137 36 248 80 114 232 46 127 257 ^'}}, + {OUT=>'B456A6A968ACD66CAA974F96A9A916E700AA3C5D'}], + ['208', {IN=> {f=> '605 1 58 76 243 273 280 131 125 6 162 161 132 142 14 184 3 141 270 51 160 26 89 189 4 92 198 55 67 192 13 143 173 192 25 268 136 37 55 2 112 137 208 45 130 227 33 213 201 64 118 167 150 101 106 30 204 150 89 124 209 74 263 70 148 109 63 77 52 201 141 38 149 215 116 187 89 254 84 253 133 40 129 133 248 209 9 183 194 213 266 144 279 102 135 163 47 265 270 271 80 8 154 204 85 9 248 274 89 201 129 198 43 85 86 168 256 154 216 210 115 93 19 108 177 87 209 86 103 176 278 281 82 53 10 69 42 56 96 40 141 258 69 54 181 202 170 171 277 187 12 49 245 188 118 102 70 83 29 45 67 139 58 88 83 94 125 18 2 124 262 29 33 160 246 9 28 69 107 136 114 260 126 177 152 4 247 38 161 55 222 32 119 273 60 211 1 226 147 80 73 234 222 20 279 25 215 181 267 250 189 212 30 216 275 195 254 239 93 96 28 16 152 81 167 162 226 212 160 91 169 65 224 220 117 281 17 258 134 134 57 137 155 90 75 137 78 170 236 72 63 232 177 22 129 68 168 48 74 55 275 272 174 78 158 111 251 218 202 158 46 171 57 267 30 269 230 107 59 52 278 61 20 214 87 54 246 282 46 106 262 249 95 284 26 24 109 271 15 70 136 269 100 232 22 182 23 80 138 29 98 240 264 229 156 131 48 86 180 96 117 61 97 134 69 119 261 220 105 156 196 128 104 115 81 179 2 47 57 190 110 145 165 235 263 135 228 127 283 205 256 284 91 104 127 206 132 219 76 23 68 13 66 253 210 245 253 198 120 5 68 233 128 92 275 260 49 257 28 224 232 242 102 147 3 153 110 157 5 56 108 165 247 103 241 73 157 17 38 214 10 134 122 217 31 25 203 56 161 120 17 193 54 116 122 9 236 7 268 71 242 179 67 127 218 125 238 64 106 42 44 256 219 11 228 50 78 223 191 127 153 45 77 129 121 123 103 21 153 175 237 166 133 93 84 188 53 22 194 148 186 268 59 117 73 222 97 199 149 280 196 63 24 97 146 194 225 106 250 124 132 154 281 5 133 28 4 27 118 37 132 207 94 60 223 126 47 277 110 92 210 180 173 37 43 162 6 7 36 26 12 269 165 27 183 117 8 142 79 264 164 76 255 113 101 261 155 25 280 261 143 185 32 131 113 166 56 31 245 123 38 226 135 240 252 104 50 1 18 67 62 138 249 18 79 44 244 94 190 98 20 59 105 91 116 252 27 130 19 238 52 266 79 199 84 200 35 128 39 35 205 244 17 270 259 240 187 24 174 66 33 5 121 188 183 182 88 18 14 249 83 159 205 179 79 252 186 ^'}}, + {OUT=>'FD1C257FE046B2A27E2F0CD55ED2DECA845F01D7'}], + ['209', {IN=> {f=> '615 0 255 121 77 82 283 193 8 235 239 47 73 145 54 274 77 240 80 59 273 173 170 86 113 16 97 122 110 68 124 25 191 93 112 270 247 281 278 172 266 152 119 206 263 46 62 92 79 133 119 26 95 27 106 80 81 70 39 148 24 44 191 137 129 2 203 157 140 99 59 30 54 189 42 276 14 160 202 124 3 107 227 134 45 180 106 238 165 223 17 86 91 219 231 144 172 1 236 272 184 201 264 237 132 237 176 254 195 210 71 72 134 152 12 87 282 2 225 241 6 77 284 97 229 229 49 168 149 193 30 32 105 25 11 76 93 27 84 283 215 92 101 217 272 4 33 94 281 120 88 113 174 181 275 88 6 55 200 231 251 4 118 280 109 186 138 184 223 61 103 110 175 107 6 235 81 114 207 167 116 56 189 200 73 167 138 140 55 178 11 98 26 180 62 221 146 267 141 88 28 139 66 209 189 222 6 33 116 78 273 66 51 105 69 28 95 49 190 233 59 8 257 36 64 51 83 272 162 117 111 259 58 19 1 214 188 31 223 39 170 244 197 169 75 60 41 243 164 32 234 92 145 98 155 96 196 243 208 200 253 48 21 96 218 40 74 178 191 115 196 136 225 219 209 60 19 23 11 54 9 161 106 58 284 204 61 210 93 5 151 130 237 154 34 42 232 133 141 246 112 5 44 147 256 110 46 40 159 213 19 181 95 207 274 99 37 233 37 211 104 58 126 120 195 232 155 225 112 90 230 262 35 9 117 89 39 41 41 63 147 13 278 216 283 35 75 82 261 109 142 257 14 267 185 105 47 95 229 71 252 15 171 255 99 144 65 18 255 228 60 199 40 30 10 172 159 33 138 162 139 44 125 36 244 68 102 228 38 115 174 52 72 241 271 280 131 119 4 162 161 128 142 14 182 286 141 268 45 158 22 85 187 285 86 198 51 61 188 9 139 173 192 19 266 130 35 53 285 108 131 204 39 126 227 27 213 199 62 114 163 150 97 100 26 202 146 87 124 205 72 263 68 146 109 57 71 50 201 135 34 149 215 114 185 83 250 78 251 133 34 127 131 248 207 9 183 190 211 262 142 279 98 133 163 43 265 270 269 78 8 150 204 83 7 246 270 89 197 125 194 41 85 80 166 256 154 214 210 115 89 17 108 175 85 209 82 103 176 276 279 76 49 10 65 40 52 94 38 137 258 69 50 179 202 168 171 277 183 10 43 243 186 116 100 70 83 29 43 67 135 56 82 81 92 123 14 2 118 258 25 33 160 246 5 22 63 103 132 108 260 120 173 148 2 247 38 159 55 222 28 117 269 56 211 284 226 145 76 71 230 218 18 277 25 213 177 265 248 185 212 30 212 273 195 254 239 91 90 28 10 150 75 167 160 224 175 ^'}}, + {OUT=>'66E0D01780F1063E2929EAAD74826BC64060E38C'}], + ['210', {IN=> {f=> '613 0 152 79 161 65 216 220 109 281 9 254 130 126 57 137 147 82 63 133 78 162 232 68 59 232 177 22 129 68 168 36 74 43 275 264 174 70 154 103 247 218 194 158 42 167 49 259 18 261 222 95 59 52 270 49 20 214 75 42 238 282 46 106 258 249 83 280 22 20 105 271 15 58 136 269 100 224 10 182 19 68 130 17 94 240 256 225 156 127 44 82 172 96 105 53 89 134 65 107 257 212 101 152 188 124 92 107 77 175 287 43 45 190 98 141 157 235 259 127 224 119 275 205 248 276 83 100 115 206 285 128 211 64 11 60 1 66 253 202 237 245 194 108 5 64 229 116 84 267 256 45 249 24 224 228 238 102 139 3 149 106 149 286 56 100 165 243 99 237 65 157 5 26 210 6 122 118 217 27 17 203 44 153 116 13 193 50 116 122 286 236 7 268 63 242 171 59 123 214 125 238 52 102 30 40 252 215 3 220 50 66 215 183 127 153 45 69 117 121 119 95 9 145 167 229 166 121 81 76 188 53 18 190 148 178 260 55 113 61 218 85 195 145 276 192 63 12 97 142 194 217 98 250 120 132 150 273 1 125 20 285 19 118 37 120 203 94 60 219 122 47 273 110 88 206 176 165 25 43 154 283 284 32 14 12 265 161 15 179 117 138 75 260 164 76 247 109 101 261 151 21 272 253 143 181 32 123 105 162 52 31 245 123 34 218 135 232 248 96 46 286 6 63 62 134 245 14 71 32 244 86 182 90 12 47 105 91 108 244 27 126 7 230 44 262 79 199 84 196 23 128 31 27 197 240 17 262 259 236 187 16 166 62 25 282 117 180 175 178 80 18 10 241 75 151 201 179 67 252 35 255 117 71 82 281 189 2 233 235 41 71 141 48 272 73 236 78 53 269 171 168 86 111 16 95 118 108 64 120 23 187 87 110 268 243 279 274 168 266 148 119 204 261 42 58 86 73 127 115 26 89 25 102 80 77 66 35 146 24 44 191 135 123 285 199 155 140 99 57 28 54 185 42 276 12 156 198 118 288 101 223 132 41 180 104 234 163 219 13 84 87 219 231 140 170 1 234 272 182 199 264 233 126 237 174 250 191 206 67 72 128 152 8 87 278 287 223 241 4 77 284 91 229 225 47 164 147 191 26 30 99 19 9 74 93 23 78 283 213 88 97 213 268 4 27 88 277 120 82 113 170 181 271 86 2 53 198 227 251 287 114 278 107 186 138 184 223 61 97 104 175 107 6 231 81 114 207 163 110 50 187 196 73 165 134 136 51 174 11 98 20 176 56 221 146 263 137 88 26 139 62 205 189 220 29 112 74 273 60 51 103 67 22 91 49 188 233 55 4 257 32 64 49 79 270 158 113 111 255 58 15 288 210 213 ^'}}, + {OUT=>'A8478DF406F179FD4EF97F4574D7F99EA1CE9EB8'}], + ['211', {IN=> {f=> '624 1 28 220 36 170 238 197 169 72 54 41 237 158 26 234 92 145 95 155 87 190 243 208 200 250 48 21 90 215 40 71 178 188 109 196 130 219 216 206 51 16 23 5 48 6 158 97 55 278 201 55 207 90 286 151 130 234 148 34 36 226 127 138 240 112 2 38 141 250 104 37 31 159 207 19 175 92 201 274 96 31 230 28 205 104 52 126 114 192 229 152 225 103 90 230 262 26 108 86 39 32 35 60 147 10 278 216 277 35 75 79 255 100 136 254 5 267 185 99 41 95 226 71 249 9 168 252 90 144 56 12 249 228 57 193 34 21 4 172 153 30 135 159 136 35 116 36 241 59 93 225 32 106 171 43 66 238 268 280 131 110 1 162 161 122 142 14 179 283 141 265 36 155 16 79 184 279 77 198 45 52 182 3 133 173 192 10 263 121 32 50 282 102 122 198 30 120 227 18 213 196 59 108 157 150 91 91 20 199 140 84 124 199 69 263 65 143 109 48 62 47 201 126 28 149 215 111 182 74 244 69 248 133 25 124 128 248 204 9 183 184 208 256 139 279 92 130 163 37 265 270 266 75 8 144 204 80 4 243 264 89 191 119 188 38 85 71 163 256 154 211 210 115 83 14 108 172 82 209 76 103 176 273 276 67 43 10 59 37 46 91 35 131 258 69 44 176 202 165 171 277 177 7 34 240 183 113 97 70 83 29 40 67 129 53 73 78 89 120 8 2 109 252 19 33 160 246 289 13 54 97 126 99 260 111 167 142 289 247 38 156 55 222 22 114 263 50 211 281 226 142 70 68 224 212 15 274 25 210 171 262 245 179 212 30 206 270 195 254 239 88 81 28 1 147 66 167 157 221 202 150 76 159 65 214 220 107 281 7 253 129 124 57 137 145 80 60 132 78 160 231 67 58 232 177 22 129 68 168 33 74 40 275 262 174 68 153 101 246 218 192 158 41 166 47 257 15 259 220 92 59 52 268 46 20 214 72 39 236 282 46 106 257 249 80 279 21 19 104 271 15 55 136 269 100 222 7 182 18 65 128 14 93 240 254 224 156 126 43 81 170 96 102 51 87 134 64 104 256 210 100 151 186 123 89 105 76 174 287 42 42 190 95 140 155 235 258 125 223 117 273 205 246 274 81 99 112 206 285 127 209 61 8 58 288 66 253 200 235 243 193 105 5 63 228 113 82 265 255 44 247 23 224 227 237 102 137 3 148 105 147 285 56 98 165 242 98 236 63 157 2 23 209 5 119 117 217 26 15 203 41 151 115 12 193 49 116 122 284 236 7 268 61 242 169 57 122 213 125 238 49 101 27 39 251 214 1 218 50 63 213 181 127 153 45 67 114 121 118 93 6 143 165 227 166 118 78 74 188 53 17 189 148 176 258 54 112 58 217 82 194 144 275 191 141 ^'}}, + {OUT=>'248E58CF09A372114FC2F93B09C5FC14F3D0059E'}], + ['212', {IN=> {f=> '628 1 3 97 139 194 211 92 250 117 132 147 267 290 119 14 282 13 118 37 111 200 94 60 216 119 47 270 110 85 203 173 159 16 43 148 277 278 29 5 12 262 158 6 176 117 286 135 72 257 164 76 241 106 101 261 148 18 266 247 143 178 32 117 99 159 49 31 245 123 31 212 135 226 245 90 43 286 289 60 62 131 242 11 65 23 244 80 176 84 6 38 105 91 102 238 27 123 290 224 38 259 79 199 84 193 14 128 25 21 191 237 17 256 259 233 187 10 160 59 19 276 114 174 169 175 74 18 7 235 69 145 198 179 58 252 32 255 111 62 82 278 183 285 230 229 32 68 135 39 269 67 230 75 44 263 168 165 86 108 16 92 112 105 58 114 20 181 78 107 265 237 276 268 162 266 142 119 201 258 36 52 77 64 118 109 26 80 22 96 80 71 60 29 143 24 44 191 132 114 279 193 152 140 99 54 25 54 179 42 276 9 150 192 109 285 92 217 129 35 180 101 228 160 213 7 81 81 219 231 134 167 1 231 272 179 196 264 227 117 237 171 244 185 200 61 72 119 152 2 87 272 284 220 241 1 77 284 82 229 219 44 158 144 188 20 27 90 10 6 71 93 17 69 283 210 82 91 207 262 4 18 79 271 120 73 113 164 181 265 83 288 50 195 221 251 281 108 275 104 186 138 184 223 61 88 95 175 107 6 225 81 114 207 157 101 41 184 190 73 162 128 130 45 168 11 98 11 170 47 221 146 257 131 88 23 139 56 199 189 217 283 23 106 68 273 51 51 100 64 13 85 49 185 233 49 290 257 26 64 46 73 267 152 107 111 249 58 9 288 204 183 26 218 34 170 234 197 169 70 50 41 233 154 22 234 92 145 93 155 81 186 243 208 200 248 48 21 86 213 40 69 178 186 105 196 126 215 214 204 45 14 23 1 44 4 156 91 53 274 199 51 205 88 282 151 130 232 144 34 32 222 123 136 236 112 34 137 246 100 31 25 159 203 19 171 90 197 274 94 27 228 22 201 104 48 126 110 190 227 150 225 97 90 230 262 20 286 102 84 39 26 31 58 147 8 278 216 273 35 75 77 251 94 132 252 291 267 185 95 37 95 224 71 247 5 166 250 84 144 50 8 245 228 55 189 30 15 172 149 28 133 157 134 29 110 36 239 53 87 223 28 100 169 37 62 236 266 280 131 104 291 162 161 118 142 14 177 281 141 263 30 153 12 75 182 275 71 198 41 46 178 291 129 173 192 4 261 115 30 48 280 98 116 194 24 116 227 12 213 194 57 104 153 150 87 85 16 197 136 82 124 195 67 263 63 141 109 42 56 45 201 120 24 149 215 109 180 68 240 63 246 133 19 122 126 248 202 9 183 180 206 252 137 279 88 128 163 33 265 270 264 73 8 140 204 78 2 241 76 ^'}}, + {OUT=>'F15767DE91796A6816977EFA4FCED4B7FD9B8A57'}], + ['213', {IN=> {f=> '622 0 89 183 111 180 34 85 59 159 256 154 207 210 115 75 10 108 168 78 209 68 103 176 269 272 55 35 10 51 33 38 87 31 123 258 69 36 172 202 161 171 277 169 3 22 236 179 109 93 70 83 29 36 67 121 49 61 74 85 116 2 97 244 11 33 160 246 285 1 42 89 118 87 260 99 159 134 289 247 38 152 55 222 14 110 255 42 211 277 226 138 62 64 216 204 11 270 25 206 163 258 241 171 212 30 198 266 195 254 239 84 69 28 283 143 54 167 153 217 194 142 64 151 65 206 220 99 281 293 249 125 116 57 137 137 72 48 128 78 152 227 63 54 232 177 22 129 68 168 21 74 28 275 254 174 60 149 93 242 218 184 158 37 162 39 249 3 251 212 80 59 52 260 34 20 214 60 27 228 282 46 106 253 249 68 275 17 15 100 271 15 43 136 269 100 214 289 182 14 53 120 2 89 240 246 220 156 122 39 77 162 96 90 43 79 134 60 92 252 202 96 147 178 119 77 97 72 170 287 38 30 190 83 136 147 235 254 117 219 109 265 205 238 266 73 95 100 206 285 123 201 49 290 50 280 66 253 192 227 235 189 93 5 59 224 101 74 257 251 40 239 19 224 223 233 102 129 3 144 101 139 281 56 90 165 238 94 232 55 157 284 11 205 1 107 113 217 22 7 203 29 143 111 8 193 45 116 122 276 236 7 268 53 242 161 49 118 209 125 238 37 97 15 35 247 210 287 210 50 51 205 173 127 153 45 59 102 121 114 85 288 135 157 219 166 106 66 66 188 53 13 185 148 168 250 50 108 46 213 70 190 140 271 187 63 291 97 137 194 207 88 250 115 132 145 263 290 115 10 280 9 118 37 105 198 94 60 214 117 47 268 110 83 201 171 155 10 43 144 273 274 27 293 12 260 156 174 117 284 133 70 255 164 76 237 104 101 261 146 16 262 243 143 176 32 113 95 157 47 31 245 123 29 208 135 222 243 86 41 286 285 58 62 129 240 9 61 17 244 76 172 80 2 32 105 91 98 234 27 121 286 220 34 257 79 199 84 191 8 128 21 17 187 235 17 252 259 231 187 6 156 57 15 272 112 170 165 173 70 18 5 231 65 141 196 179 52 252 30 255 107 56 82 276 179 281 228 225 26 66 131 33 267 63 226 73 38 259 166 163 86 106 16 90 108 103 54 110 18 177 72 105 263 233 274 264 158 266 138 119 199 256 32 48 71 58 112 105 26 74 20 92 80 67 56 25 141 24 44 191 130 108 275 189 150 140 99 52 23 54 175 42 276 7 146 188 103 283 86 213 127 31 180 99 224 158 209 3 79 77 219 231 130 165 1 229 272 177 194 264 223 111 237 169 240 181 196 57 72 113 152 292 87 268 282 218 241 293 77 284 76 229 80 ^'}}, + {OUT=>'36A6BC5E680E15675D9696338C88B36248BBBAF4'}], + ['214', {IN=> {f=> '635 1 40 150 140 184 12 23 78 294 2 67 93 9 57 283 206 74 83 199 254 4 6 67 263 120 61 113 156 181 257 79 284 46 191 213 251 273 100 271 100 186 138 184 223 61 76 83 175 107 6 217 81 114 207 149 89 29 180 182 73 158 120 122 37 160 11 98 295 162 35 221 146 249 123 88 19 139 48 191 189 213 275 15 98 60 273 39 51 96 60 1 77 49 181 233 41 286 257 18 64 42 65 263 144 99 111 241 58 1 288 196 179 22 214 30 170 226 197 169 66 42 41 225 146 14 234 92 145 89 155 69 178 243 208 200 244 48 21 78 209 40 65 178 182 97 196 118 207 210 200 33 10 23 289 36 152 79 49 266 195 43 201 84 274 151 130 228 136 34 24 214 115 132 228 112 292 26 129 238 92 19 13 159 195 19 163 86 189 274 90 19 224 10 193 104 40 126 102 186 223 146 225 85 90 230 262 8 278 90 80 39 14 23 54 147 4 278 216 265 35 75 73 243 82 124 248 283 267 185 87 29 95 220 71 243 293 162 246 72 144 38 237 228 51 181 22 3 288 172 141 24 129 153 130 17 98 36 235 41 75 219 20 88 165 25 54 232 262 280 131 92 291 162 161 110 142 14 173 277 141 259 18 149 4 67 178 267 59 198 33 34 170 287 121 173 192 288 257 103 26 44 276 90 104 186 12 108 227 213 190 53 96 145 150 79 73 8 193 128 78 124 187 63 263 59 137 109 30 44 41 201 108 16 149 215 105 176 56 232 51 242 133 7 118 122 248 198 9 183 172 202 244 133 279 80 124 163 25 265 270 260 69 8 132 204 74 294 237 252 89 179 107 176 32 85 53 157 256 154 205 210 115 71 8 108 166 76 209 64 103 176 267 270 49 31 10 47 31 34 85 29 119 258 69 32 170 202 159 171 277 165 1 16 234 177 107 91 70 83 29 34 67 117 47 55 72 83 114 292 2 91 240 7 33 160 246 283 291 36 85 114 81 260 93 155 130 289 247 38 150 55 222 10 108 251 38 211 275 226 136 58 62 212 200 9 268 25 204 159 256 239 167 212 30 194 264 195 254 239 82 63 28 279 141 48 167 151 215 190 138 58 147 65 202 220 95 281 291 247 123 112 57 137 133 68 42 126 78 148 225 61 52 232 177 22 129 68 168 15 74 22 275 250 174 56 147 89 240 218 180 158 35 160 35 245 293 247 208 74 59 52 256 28 20 214 54 21 224 282 46 106 251 249 62 273 15 13 98 271 15 37 136 269 100 210 285 182 12 47 116 292 87 240 242 218 156 120 37 75 158 96 84 39 75 134 58 86 250 198 94 145 174 117 71 93 70 168 287 36 24 190 77 134 143 235 252 113 217 105 261 205 234 262 69 93 94 206 285 121 197 43 286 46 276 66 253 188 223 231 187 87 5 57 222 95 285 ^'}}, + {OUT=>'4DEA6251B2A6DF017A8093AB066EE3863A4EC369'}], + ['215', {IN=> {f=> '636 0 251 248 37 233 16 224 220 230 102 123 3 141 98 133 278 56 84 165 235 91 229 49 157 278 2 202 295 98 110 217 19 1 203 20 137 108 5 193 42 116 122 270 236 7 268 47 242 155 43 115 206 125 238 28 94 6 32 244 207 284 204 50 42 199 167 127 153 45 53 93 121 111 79 282 129 151 213 166 97 57 60 188 53 10 182 148 162 244 47 105 37 210 61 187 137 268 184 63 285 97 134 194 201 82 250 112 132 142 257 290 109 4 277 3 118 37 96 195 94 60 211 114 47 265 110 80 198 168 149 1 43 138 267 268 24 287 12 257 153 288 171 117 281 130 67 252 164 76 231 101 101 261 143 13 256 237 143 173 32 107 89 154 44 31 245 123 26 202 135 216 240 80 38 286 279 55 62 126 237 6 55 8 244 70 166 74 293 23 105 91 92 228 27 118 280 214 28 254 79 199 84 188 296 128 15 11 181 232 17 246 259 228 187 150 54 9 266 109 164 159 170 64 18 2 225 59 135 193 179 43 252 27 255 101 47 82 273 173 275 225 219 17 63 125 24 264 57 220 70 29 253 163 160 86 103 16 87 102 100 48 104 15 171 63 102 260 227 271 258 152 266 132 119 196 253 26 42 62 49 103 99 26 65 17 86 80 61 50 19 138 24 44 191 127 99 269 183 147 140 99 49 20 54 169 42 276 4 140 182 94 280 77 207 124 25 180 96 218 155 203 294 76 71 219 231 124 162 1 226 272 174 191 264 217 102 237 166 234 175 190 51 72 104 152 289 87 262 279 215 241 293 77 284 67 229 209 39 148 139 183 10 22 75 292 1 66 93 7 54 283 205 72 81 197 252 4 3 64 261 120 58 113 154 181 255 78 283 45 190 211 251 271 98 270 99 186 138 184 223 61 73 80 175 107 6 215 81 114 207 147 86 26 179 180 73 157 118 120 35 158 11 98 293 160 32 221 146 247 121 88 18 139 46 189 189 212 273 13 96 58 273 36 51 95 59 295 75 49 180 233 39 285 257 16 64 41 63 262 142 97 111 239 58 296 288 194 178 21 213 29 170 224 197 169 65 40 41 223 144 12 234 92 145 88 155 66 176 243 208 200 243 48 21 76 208 40 64 178 181 95 196 116 205 209 199 30 9 23 288 34 296 151 76 48 264 194 41 200 83 272 151 130 227 134 34 22 212 113 131 226 112 292 24 127 236 90 16 10 159 193 19 161 85 187 274 89 17 223 7 191 104 38 126 100 185 222 145 225 82 90 230 262 5 276 87 79 39 11 21 53 147 3 278 216 263 35 75 72 241 79 122 247 281 267 185 85 27 95 219 71 242 292 161 245 69 144 35 295 235 228 50 179 20 287 172 139 23 128 152 129 14 95 36 234 38 72 218 18 85 164 22 52 231 261 280 131 89 291 162 161 108 142 14 172 276 91 ^'}}, + {OUT=>'D30E70E357D57E3D82CA554B8A3D58DFF528FA94'}], + ['216', {IN=> {f=> '635 1 256 9 146 297 61 175 261 50 198 27 25 164 284 115 173 192 282 254 94 23 41 273 84 95 180 3 102 227 290 213 187 50 90 139 150 73 64 2 190 122 75 124 181 60 263 56 134 109 21 35 38 201 99 10 149 215 102 173 47 226 42 239 133 297 115 119 248 195 9 183 166 199 238 130 279 74 121 163 19 265 270 257 66 8 126 204 71 294 234 246 89 173 101 170 29 85 44 154 256 154 202 210 115 65 5 108 163 73 209 58 103 176 264 267 40 25 10 41 28 28 82 26 113 258 69 26 167 202 156 171 277 159 297 7 231 174 104 88 70 83 29 31 67 111 44 46 69 80 111 289 2 82 234 1 33 160 246 280 285 27 79 108 72 260 84 149 124 289 247 38 147 55 222 4 105 245 32 211 272 226 133 52 59 206 194 6 265 25 201 153 253 236 161 212 30 188 261 195 254 239 79 54 28 273 138 39 167 148 212 184 132 49 141 65 196 220 89 281 288 244 120 106 57 137 127 62 33 123 78 142 222 58 49 232 177 22 129 68 168 6 74 13 275 244 174 50 144 83 237 218 174 158 32 157 29 239 287 241 202 65 59 52 250 19 20 214 45 12 218 282 46 106 248 249 53 270 12 10 95 271 15 28 136 269 100 204 279 182 9 38 110 286 84 240 236 215 156 117 34 72 152 96 75 33 69 134 55 77 247 192 91 142 168 114 62 87 67 165 287 33 15 190 68 131 137 235 249 107 214 99 255 205 228 256 63 90 85 206 285 118 191 34 280 40 270 66 253 182 217 225 184 78 5 54 219 86 64 247 246 35 229 14 224 218 228 102 119 3 139 96 129 276 56 80 165 233 89 227 45 157 274 295 200 295 92 108 217 17 296 203 14 133 106 3 193 40 116 122 266 236 7 268 43 242 151 39 113 204 125 238 22 92 30 242 205 282 200 50 36 195 163 127 153 45 49 87 121 109 75 278 125 147 209 166 91 51 56 188 53 8 180 148 158 240 45 103 31 208 55 185 135 266 182 63 281 97 132 194 197 78 250 110 132 140 253 290 105 275 298 118 37 90 193 94 60 209 112 47 263 110 78 196 166 145 294 43 134 263 264 22 283 12 255 151 284 169 117 279 128 65 250 164 76 227 99 101 261 141 11 252 233 143 171 32 103 85 152 42 31 245 123 24 198 135 212 238 76 36 286 275 53 62 124 235 4 51 2 244 66 162 70 291 17 105 91 88 224 27 116 276 210 24 252 79 199 84 186 292 128 11 7 177 230 17 242 259 226 187 295 146 52 5 262 107 160 155 168 60 18 221 55 131 191 179 37 252 25 255 97 41 82 271 169 271 223 215 11 61 121 18 262 53 216 68 23 249 161 158 86 101 16 85 98 98 44 100 13 167 57 100 258 223 269 254 148 266 128 119 194 251 22 38 56 43 275 ^'}}, + {OUT=>'70CA84D827F7FD61446233F88CF2F990B0F3E2AA'}], + ['217', {IN=> {f=> '642 0 91 26 53 13 78 80 53 42 11 134 24 44 191 123 87 261 175 143 140 99 45 16 54 161 42 276 132 174 82 276 65 199 120 17 180 92 210 151 195 290 72 63 219 231 116 158 1 222 272 170 187 264 209 90 237 162 226 167 182 43 72 92 152 285 87 254 275 211 241 293 77 284 55 229 201 35 140 135 179 2 18 63 284 298 62 93 300 42 283 201 64 73 189 244 4 292 52 253 120 46 113 146 181 247 74 279 41 186 203 251 263 90 266 95 186 138 184 223 61 61 68 175 107 6 207 81 114 207 139 74 14 175 172 73 153 110 112 27 150 11 98 285 152 20 221 146 239 113 88 14 139 38 181 189 208 265 5 88 50 273 24 51 91 55 287 67 49 176 233 31 281 257 8 64 37 55 258 134 89 111 231 58 292 288 186 174 17 209 25 170 216 197 169 61 32 41 215 136 4 234 92 145 84 155 54 168 243 208 200 239 48 21 68 204 40 60 178 177 87 196 108 197 205 195 18 5 23 284 26 296 147 64 44 256 190 33 196 79 264 151 130 223 126 34 14 204 105 127 218 112 292 16 119 228 82 4 299 159 185 19 153 81 179 274 85 9 219 296 183 104 30 126 92 181 218 141 225 70 90 230 262 294 268 75 75 39 300 13 49 147 300 278 216 255 35 75 68 233 67 114 243 273 267 185 77 19 95 215 71 238 288 157 241 57 144 23 291 227 228 46 171 12 289 283 172 131 19 124 148 125 2 83 36 230 26 60 214 10 73 160 10 44 227 257 280 131 77 291 162 161 100 142 14 168 272 141 254 3 144 295 57 173 257 44 198 23 19 160 282 111 173 192 278 252 88 21 39 271 80 89 176 298 98 227 286 213 185 48 86 135 150 69 58 299 188 118 73 124 177 58 263 54 132 109 15 29 36 201 93 6 149 215 100 171 41 222 36 237 133 293 113 117 248 193 9 183 162 197 234 128 279 70 119 163 15 265 270 255 64 8 122 204 69 294 232 242 89 169 97 166 27 85 38 152 256 154 200 210 115 61 3 108 161 71 209 54 103 176 262 265 34 21 10 37 26 24 80 24 109 258 69 22 165 202 154 171 277 155 297 1 229 172 102 86 70 83 29 29 67 107 42 40 67 78 109 287 2 76 230 298 33 160 246 278 281 21 75 104 66 260 78 145 120 289 247 38 145 55 222 103 241 28 211 270 226 131 48 57 202 190 4 263 25 199 149 251 234 157 212 30 184 259 195 254 239 77 48 28 269 136 33 167 146 210 180 128 43 137 65 192 220 85 281 286 242 118 102 57 137 123 58 27 121 78 138 220 56 47 232 177 22 129 68 168 74 7 275 240 174 46 142 79 235 218 170 158 30 155 25 235 283 237 198 59 59 52 246 13 20 214 39 6 214 282 46 106 246 249 47 268 10 8 93 271 15 22 136 269 100 200 275 42 ^'}}, + {OUT=>'8D500C9CFDE0288530A2106B70BED39326C52C3C'}], + ['218', {IN=> {f=> '644 0 6 29 104 280 81 240 230 212 156 114 31 69 146 96 66 27 63 134 52 68 244 186 88 139 162 111 53 81 64 162 287 30 6 190 59 128 131 235 246 101 211 93 249 205 222 250 57 87 76 206 285 115 185 25 274 34 264 66 253 176 211 219 181 69 5 51 216 77 58 241 243 32 223 11 224 215 225 102 113 3 136 93 123 273 56 74 165 230 86 224 39 157 268 289 197 295 83 105 217 14 293 203 5 127 103 193 37 116 122 260 236 7 268 37 242 145 33 110 201 125 238 13 89 293 27 239 202 279 194 50 27 189 157 127 153 45 43 78 121 106 69 272 119 141 203 166 82 42 50 188 53 5 177 148 152 234 42 100 22 205 46 182 132 263 179 63 275 97 129 194 191 72 250 107 132 137 247 290 99 296 272 295 118 37 81 190 94 60 206 109 47 260 110 75 193 163 139 288 43 128 257 258 19 277 12 252 148 278 166 117 276 125 62 247 164 76 221 96 101 261 138 8 246 227 143 168 32 97 79 149 39 31 245 123 21 192 135 206 235 70 33 286 269 50 62 121 232 1 45 295 244 60 156 64 288 8 105 91 82 218 27 113 270 204 18 249 79 199 84 183 286 128 5 1 171 227 17 236 259 223 187 292 140 49 301 256 104 154 149 165 54 18 299 215 49 125 188 179 28 252 22 255 91 32 82 268 163 265 220 209 2 58 115 9 259 47 210 65 14 243 158 155 86 98 16 82 92 95 38 94 10 161 48 97 255 217 266 248 142 266 122 119 191 248 16 32 47 34 88 89 26 50 12 76 80 51 40 9 133 24 44 191 122 84 259 173 142 140 99 44 15 54 159 42 276 301 130 172 79 275 62 197 119 15 180 91 208 150 193 289 71 61 219 231 114 157 1 221 272 169 186 264 207 87 237 161 224 165 180 41 72 89 152 284 87 252 274 210 241 293 77 284 52 229 199 34 138 134 178 17 60 282 298 61 93 299 39 283 200 62 71 187 242 4 290 49 251 120 43 113 144 181 245 73 278 40 185 201 251 261 88 265 94 186 138 184 223 61 58 65 175 107 6 205 81 114 207 137 71 11 174 170 73 152 108 110 25 148 11 98 283 150 17 221 146 237 111 88 13 139 36 179 189 207 263 3 86 48 273 21 51 90 54 285 65 49 175 233 29 280 257 6 64 36 53 257 132 87 111 229 58 291 288 184 173 16 208 24 170 214 197 169 60 30 41 213 134 2 234 92 145 83 155 51 166 243 208 200 238 48 21 66 203 40 59 178 176 85 196 106 195 204 194 15 4 23 283 24 296 146 61 43 254 189 31 195 78 262 151 130 222 124 34 12 202 103 126 216 112 292 14 117 226 80 1 297 159 183 19 151 80 177 274 84 7 218 294 181 104 28 126 90 180 217 140 225 67 90 230 262 292 266 72 74 39 298 11 48 147 300 278 216 253 265 ^'}}, + {OUT=>'F3D4D139EDFC24596377BC97A96FB7621F27FFC7'}], + ['219', {IN=> {f=> '638 1 75 65 227 58 108 240 267 267 185 71 13 95 212 71 235 285 154 238 48 144 14 288 221 228 43 165 6 283 280 172 125 16 121 145 122 297 74 36 227 17 51 211 4 64 157 1 38 224 254 280 131 68 291 162 161 94 142 14 165 269 141 251 298 141 292 51 170 251 35 198 17 10 154 279 105 173 192 272 249 79 18 36 268 74 80 170 292 92 227 280 213 182 45 80 129 150 63 49 296 185 112 70 124 171 55 263 51 129 109 6 20 33 201 84 149 215 97 168 32 216 27 234 133 287 110 114 248 190 9 183 156 194 228 125 279 64 116 163 9 265 270 252 61 8 116 204 66 294 229 236 89 163 91 160 24 85 29 149 256 154 197 210 115 55 108 158 68 209 48 103 176 259 262 25 15 10 31 23 18 77 21 103 258 69 16 162 202 151 171 277 149 297 296 226 169 99 83 70 83 29 26 67 101 39 31 64 75 106 284 2 67 224 295 33 160 246 275 275 12 69 98 57 260 69 139 114 289 247 38 142 55 222 298 100 235 22 211 267 226 128 42 54 196 184 1 260 25 196 143 248 231 151 212 30 178 256 195 254 239 74 39 28 263 133 24 167 143 207 174 122 34 131 65 186 220 79 281 283 239 115 96 57 137 117 52 18 118 78 132 217 53 44 232 177 22 129 68 168 295 74 302 275 234 174 40 139 73 232 218 164 158 27 152 19 229 277 231 192 50 59 52 240 4 20 214 30 301 208 282 46 106 243 249 38 265 7 5 90 271 15 13 136 269 100 194 269 182 4 23 100 276 79 240 226 210 156 112 29 67 142 96 60 23 59 134 50 62 242 182 86 137 158 109 47 77 62 160 287 28 190 53 126 127 235 244 97 209 89 245 205 218 246 53 85 70 206 285 113 181 19 270 30 260 66 253 172 207 215 179 63 5 49 214 71 54 237 241 30 219 9 224 213 223 102 109 3 134 91 119 271 56 70 165 228 84 222 35 157 264 285 195 295 77 103 217 12 291 203 303 123 101 302 193 35 116 122 256 236 7 268 33 242 141 29 108 199 125 238 7 87 289 25 237 200 277 190 50 21 185 153 127 153 45 39 72 121 104 65 268 115 137 199 166 76 36 46 188 53 3 175 148 148 230 40 98 16 203 40 180 130 261 177 63 271 97 127 194 187 68 250 105 132 135 243 290 95 294 270 293 118 37 75 188 94 60 204 107 47 258 110 73 191 161 135 284 43 124 253 254 17 273 12 250 146 274 164 117 274 123 60 245 164 76 217 94 101 261 136 6 242 223 143 166 32 93 75 147 37 31 245 123 19 188 135 202 233 66 31 286 265 48 62 119 230 303 41 291 244 56 152 60 286 2 105 91 78 214 27 111 266 200 14 247 79 199 84 181 282 128 1 301 167 225 17 232 259 221 187 290 136 47 299 252 102 150 145 163 157 ^'}}, + {OUT=>'5509BAFFAC6D507860CEFC5AB5832CB63CD4B687'}], + ['220', {IN=> {f=> '653 0 18 299 207 41 117 184 179 16 252 18 255 83 20 82 264 155 257 216 201 296 54 107 303 255 39 202 61 2 235 154 151 86 94 16 78 84 91 30 86 6 153 36 93 251 209 262 240 134 266 114 119 187 244 8 24 35 22 76 81 26 38 8 68 80 43 32 1 129 24 44 191 118 72 251 165 138 140 99 40 11 54 151 42 276 301 122 164 67 271 50 189 115 7 180 87 200 146 185 285 67 53 219 231 106 153 1 217 272 165 182 264 199 75 237 157 216 157 172 33 72 77 152 280 87 244 270 206 241 293 77 284 40 229 191 30 130 130 174 298 13 48 274 298 57 93 295 27 283 196 54 63 179 234 4 282 37 243 120 31 113 136 181 237 69 274 36 181 193 251 253 80 261 90 186 138 184 223 61 46 53 175 107 6 197 81 114 207 129 59 305 170 162 73 148 100 102 17 140 11 98 275 142 5 221 146 229 103 88 9 139 28 171 189 203 255 301 78 40 273 9 51 86 50 277 57 49 171 233 21 276 257 304 64 32 45 253 124 79 111 221 58 287 288 176 169 12 204 20 170 206 197 169 56 22 41 205 126 300 234 92 145 79 155 39 158 243 208 200 234 48 21 58 199 40 55 178 172 77 196 98 187 200 190 3 23 279 16 296 142 49 39 246 185 23 191 74 254 151 130 218 116 34 4 194 95 122 208 112 292 6 109 218 72 295 289 159 175 19 143 76 169 274 80 305 214 286 173 104 20 126 82 176 213 136 225 55 90 230 262 284 258 60 70 39 290 3 44 147 300 278 216 245 35 75 63 223 52 104 238 263 267 185 67 9 95 210 71 233 283 152 236 42 144 8 286 217 228 41 161 2 279 278 172 121 14 119 143 120 293 68 36 225 11 45 209 58 155 301 34 222 252 280 131 62 291 162 161 90 142 14 163 267 141 249 294 139 290 47 168 247 29 198 13 4 150 277 101 173 192 268 247 73 16 34 266 70 74 166 288 88 227 276 213 180 43 76 125 150 59 43 294 183 108 68 124 167 53 263 49 127 109 14 31 201 78 302 149 215 95 166 26 212 21 232 133 283 108 112 248 188 9 183 152 192 224 123 279 60 114 163 5 265 270 250 59 8 112 204 64 294 227 232 89 159 87 156 22 85 23 147 256 154 195 210 115 51 304 108 156 66 209 44 103 176 257 260 19 11 10 27 21 14 75 19 99 258 69 12 160 202 149 171 277 145 297 292 224 167 97 81 70 83 29 24 67 97 37 25 62 73 104 282 2 61 220 293 33 160 246 273 271 6 65 94 51 260 63 135 110 289 247 38 140 55 222 296 98 231 18 211 265 226 126 38 52 192 180 305 258 25 194 139 246 229 147 212 30 174 254 195 254 239 72 33 28 259 131 18 167 141 205 170 118 28 127 65 182 220 75 281 281 237 113 92 57 137 113 48 12 116 78 128 215 51 42 232 177 22 129 68 168 291 161 ^'}}, + {OUT=>'0C0AEA0C2FD7A620C77866B1A177481E26B4F592'}], + ['221', {IN=> {f=> '653 0 296 275 228 174 34 136 67 229 218 158 158 24 149 13 223 271 225 186 41 59 52 234 302 20 214 21 295 202 282 46 106 240 249 29 262 4 2 87 271 15 4 136 269 100 188 263 182 1 14 94 270 76 240 220 207 156 109 26 64 136 96 51 17 53 134 47 53 239 176 83 134 152 106 38 71 59 157 287 25 298 190 44 123 121 235 241 91 206 83 239 205 212 240 47 82 61 206 285 110 175 10 264 24 254 66 253 166 201 209 176 54 5 46 211 62 48 231 238 27 213 6 224 210 220 102 103 3 131 88 113 268 56 64 165 225 81 219 29 157 258 279 192 295 68 100 217 9 288 203 297 117 98 302 193 32 116 122 250 236 7 268 27 242 135 23 105 196 125 238 305 84 283 22 234 197 274 184 50 12 179 147 127 153 45 33 63 121 101 59 262 109 131 193 166 67 27 40 188 53 172 148 142 224 37 95 7 200 31 177 127 258 174 63 265 97 124 194 181 62 250 102 132 132 237 290 89 291 267 290 118 37 66 185 94 60 201 104 47 255 110 70 188 158 129 278 43 118 247 248 14 267 12 247 143 268 161 117 271 120 57 242 164 76 211 91 101 261 133 3 236 217 143 163 32 87 69 144 34 31 245 123 16 182 135 196 230 60 28 286 259 45 62 116 227 303 35 285 244 50 146 54 283 300 105 91 72 208 27 108 260 194 8 244 79 199 84 178 276 128 302 298 161 222 17 226 259 218 187 287 130 44 296 246 99 144 139 160 44 18 299 205 39 115 183 179 13 252 17 255 81 17 82 263 153 255 215 199 294 53 105 301 254 37 200 60 306 233 153 150 86 93 16 77 82 90 28 84 5 151 33 92 250 207 261 238 132 266 112 119 186 243 6 22 32 19 73 79 26 35 7 66 80 41 30 306 128 24 44 191 117 69 249 163 137 140 99 39 10 54 149 42 276 301 120 162 64 270 47 187 114 5 180 86 198 145 183 284 66 51 219 231 104 152 1 216 272 164 181 264 197 72 237 156 214 155 170 31 72 74 152 279 87 242 269 205 241 293 77 284 37 229 189 29 128 129 173 297 12 45 272 298 56 93 294 24 283 195 52 61 177 232 4 280 34 241 120 28 113 134 181 235 68 273 35 180 191 251 251 78 260 89 186 138 184 223 61 43 50 175 107 6 195 81 114 207 127 56 303 169 160 73 147 98 100 15 138 11 98 273 140 2 221 146 227 101 88 8 139 26 169 189 202 253 300 76 38 273 6 51 85 49 275 55 49 170 233 19 275 257 303 64 31 43 252 122 77 111 219 58 286 288 174 168 11 203 19 170 204 197 169 55 20 41 203 124 299 234 92 145 78 155 36 156 243 208 200 233 48 21 56 198 40 54 178 171 75 196 96 185 199 189 306 23 278 14 296 141 46 38 244 184 21 190 73 252 151 130 217 114 34 2 192 93 121 206 112 292 4 107 216 70 293 112 ^'}}, + {OUT=>'149176007FEE58A591E3F00F8DB658B605F8390C'}], + ['222', {IN=> {f=> '646 1 159 169 19 137 73 163 274 77 302 211 280 167 104 14 126 76 173 210 133 225 46 90 230 262 278 252 51 67 39 284 306 41 147 300 278 216 239 35 75 60 217 43 98 235 257 267 185 61 3 95 207 71 230 280 149 233 33 144 308 283 211 228 38 155 305 273 275 172 115 11 116 140 117 287 59 36 222 2 36 206 303 49 152 295 28 219 249 280 131 53 291 162 161 84 142 14 160 264 141 246 288 136 287 41 165 241 20 198 7 304 144 274 95 173 192 262 244 64 13 31 263 64 65 160 282 82 227 270 213 177 40 70 119 150 53 34 291 180 102 65 124 161 50 263 46 124 109 300 5 28 201 69 299 149 215 92 163 17 206 12 229 133 277 105 109 248 185 9 183 146 189 218 120 279 54 111 163 308 265 270 247 56 8 106 204 61 294 224 226 89 153 81 150 19 85 14 144 256 154 192 210 115 45 304 108 153 63 209 38 103 176 254 257 10 5 10 21 18 8 72 16 93 258 69 6 157 202 146 171 277 139 297 286 221 164 94 78 70 83 29 21 67 91 34 16 59 70 101 279 2 52 214 290 33 160 246 270 265 306 59 88 42 260 54 129 104 289 247 38 137 55 222 293 95 225 12 211 262 226 123 32 49 186 174 305 255 25 191 133 243 226 141 212 30 168 251 195 254 239 69 24 28 253 128 9 167 138 202 164 112 19 121 65 176 220 69 281 278 234 110 86 57 137 107 42 3 113 78 122 212 48 39 232 177 22 129 68 168 285 74 292 275 224 174 30 134 63 227 218 154 158 22 147 9 219 267 221 182 35 59 52 230 298 20 214 15 291 198 282 46 106 238 249 23 260 2 85 271 15 307 136 269 100 184 259 182 308 8 90 266 74 240 216 205 156 107 24 62 132 96 45 13 49 134 45 47 237 172 81 132 148 104 32 67 57 155 287 23 294 190 38 121 117 235 239 87 204 79 235 205 208 236 43 80 55 206 285 108 171 4 260 20 250 66 253 162 197 205 174 48 5 44 209 56 44 227 236 25 209 4 224 208 218 102 99 3 129 86 109 266 56 60 165 223 79 217 25 157 254 275 190 295 62 98 217 7 286 203 293 113 96 302 193 30 116 122 246 236 7 268 23 242 131 19 103 194 125 238 301 82 279 20 232 195 272 180 50 6 175 143 127 153 45 29 57 121 99 55 258 105 127 189 166 61 21 36 188 53 307 170 148 138 220 35 93 1 198 25 175 125 256 172 63 261 97 122 194 177 58 250 100 132 130 233 290 85 289 265 288 118 37 60 183 94 60 199 102 47 253 110 68 186 156 125 274 43 114 243 244 12 263 12 245 141 264 159 117 269 118 55 240 164 76 207 89 101 261 131 1 232 213 143 161 32 83 65 142 32 31 245 123 14 178 135 192 228 56 26 286 255 43 62 114 225 303 31 281 244 46 142 50 281 296 105 91 238 ^'}}, + {OUT=>'17C0D7B0256159F3626786FFDB20237AE154FA84'}], + ['223', {IN=> {f=> '647 0 200 27 104 252 186 240 79 199 84 174 268 128 298 294 153 218 17 218 259 214 187 283 122 40 292 238 95 136 131 156 36 18 299 197 31 107 179 179 1 252 13 255 73 5 82 259 145 247 211 191 286 49 97 293 250 29 192 56 298 225 149 146 86 89 16 73 74 86 20 76 1 143 21 88 246 199 257 230 124 266 104 119 182 239 309 14 20 7 61 71 26 23 3 58 80 33 22 302 124 24 44 191 113 57 241 155 133 140 99 35 6 54 141 42 276 301 112 154 52 266 35 179 110 308 180 82 190 141 175 280 62 43 219 231 96 148 1 212 272 160 177 264 189 60 237 152 206 147 162 23 72 62 152 275 87 234 265 201 241 293 77 284 25 229 181 25 120 125 169 293 8 33 264 298 52 93 290 12 283 191 44 53 169 224 4 272 22 233 120 16 113 126 181 227 64 269 31 176 183 251 243 70 256 85 186 138 184 223 61 31 38 175 107 6 187 81 114 207 119 44 295 165 152 73 143 90 92 7 130 11 98 265 132 301 221 146 219 93 88 4 139 18 161 189 198 245 296 68 30 273 305 51 81 45 267 47 49 166 233 11 271 257 299 64 27 35 248 114 69 111 211 58 282 288 166 164 7 199 15 170 196 197 169 51 12 41 195 116 295 234 92 145 74 155 24 148 243 208 200 229 48 21 48 194 40 50 178 167 67 196 88 177 195 185 299 306 23 274 6 296 137 34 34 236 180 13 186 69 244 151 130 213 106 34 305 184 85 117 198 112 292 307 99 208 62 285 279 159 165 19 133 71 159 274 75 300 209 276 163 104 10 126 72 171 208 131 225 40 90 230 262 274 248 45 65 39 280 304 39 147 300 278 216 235 35 75 58 213 37 94 233 253 267 185 57 310 95 205 71 228 278 147 231 27 144 304 281 207 228 36 151 303 269 273 172 111 9 114 138 115 283 53 36 220 307 30 204 301 43 150 291 24 217 247 280 131 47 291 162 161 80 142 14 158 262 141 244 284 134 285 37 163 237 14 198 3 300 140 272 91 173 192 258 242 58 11 29 261 60 59 156 278 78 227 266 213 175 38 66 115 150 49 28 289 178 98 63 124 157 48 263 44 122 109 296 310 26 201 63 297 149 215 90 161 11 202 6 227 133 273 103 107 248 183 9 183 142 187 214 118 279 50 109 163 306 265 270 245 54 8 102 204 59 294 222 222 89 149 77 146 17 85 8 142 256 154 190 210 115 41 304 108 151 61 209 34 103 176 252 255 4 1 10 17 16 4 70 14 89 258 69 2 155 202 144 171 277 135 297 282 219 162 92 76 70 83 29 19 67 87 32 10 57 68 99 277 2 46 210 288 33 160 246 268 261 302 55 84 36 260 48 125 100 289 247 38 135 55 222 291 93 221 8 211 260 226 121 28 47 182 170 305 253 25 189 129 241 224 137 212 30 164 249 195 254 239 86 ^'}}, + {OUT=>'741A58618ABEB1D983D67AFDCBC49AA397A3B8E0'}], + ['224', {IN=> {f=> '665 0 15 28 247 125 167 135 199 158 106 10 115 65 170 220 63 281 275 231 107 80 57 137 101 36 306 110 78 116 209 45 36 232 177 22 129 68 168 279 74 286 275 218 174 24 131 57 224 218 148 158 19 144 3 213 261 215 176 26 59 52 224 292 20 214 6 285 192 282 46 106 235 249 14 257 311 309 82 271 15 301 136 269 100 178 253 182 308 311 84 260 71 240 210 202 156 104 21 59 126 96 36 7 43 134 42 38 234 166 78 129 142 101 23 61 54 152 287 20 288 190 29 118 111 235 236 81 201 73 229 205 202 230 37 77 46 206 285 105 165 307 254 14 244 66 253 156 191 199 171 39 5 41 206 47 38 221 233 22 203 1 224 205 215 102 93 3 126 83 103 263 56 54 165 220 76 214 19 157 248 269 187 295 53 95 217 4 283 203 287 107 93 302 193 27 116 122 240 236 7 268 17 242 125 13 100 191 125 238 295 79 273 17 229 192 269 174 50 309 169 137 127 153 45 23 48 121 96 49 252 99 121 183 166 52 12 30 188 53 307 167 148 132 214 32 90 304 195 16 172 122 253 169 63 255 97 119 194 171 52 250 97 132 127 227 290 79 286 262 285 118 37 51 180 94 60 196 99 47 250 110 65 183 153 119 268 43 108 237 238 9 257 12 242 138 258 156 117 266 115 52 237 164 76 201 86 101 261 128 310 226 207 143 158 32 77 59 139 29 31 245 123 11 172 135 186 225 50 23 286 249 40 62 111 222 303 25 275 244 40 136 44 278 290 105 91 62 198 27 103 250 184 310 239 79 199 84 173 266 128 297 293 151 217 17 216 259 213 187 282 120 39 291 236 94 134 129 155 34 18 299 195 29 105 178 179 310 252 12 255 71 2 82 258 143 245 210 189 284 48 95 291 249 27 190 55 296 223 148 145 86 88 16 72 72 85 18 74 141 18 87 245 197 256 228 122 266 102 119 181 238 308 12 17 4 58 69 26 20 2 56 80 31 20 301 123 24 44 191 112 54 239 153 132 140 99 34 5 54 139 42 276 301 110 152 49 265 32 177 109 307 180 81 188 140 173 279 61 41 219 231 94 147 1 211 272 159 176 264 187 57 237 151 204 145 160 21 72 59 152 274 87 232 264 200 241 293 77 284 22 229 179 24 118 124 168 292 7 30 262 298 51 93 289 9 283 190 42 51 167 222 4 270 19 231 120 13 113 124 181 225 63 268 30 175 181 251 241 68 255 84 186 138 184 223 61 28 35 175 107 6 185 81 114 207 117 41 293 164 150 73 142 88 90 5 128 11 98 263 130 299 221 146 217 91 88 3 139 16 159 189 197 243 295 66 28 273 303 51 80 44 265 45 49 165 233 9 270 257 298 64 26 33 247 112 67 111 209 58 281 288 164 163 6 198 14 170 194 197 169 50 10 41 193 114 294 234 92 145 73 155 21 146 243 208 200 228 48 21 46 193 40 49 178 166 65 196 86 175 194 184 297 306 23 273 206 ^'}}, + {OUT=>'B738D6B3409EB9ED2F1719B84D13F7C36169CDEC'}], + ['225', {IN=> {f=> '641 0 296 134 25 31 230 177 7 183 66 238 151 130 210 100 34 302 178 79 114 192 112 292 304 93 202 56 279 273 159 159 19 127 68 153 274 72 297 206 270 157 104 4 126 66 168 205 128 225 31 90 230 262 268 242 36 62 39 274 301 36 147 300 278 216 229 35 75 55 207 28 88 230 247 267 185 51 307 95 202 71 225 275 144 228 18 144 298 278 201 228 33 145 300 263 270 172 105 6 111 135 112 277 44 36 217 301 21 201 298 34 147 285 18 214 244 280 131 38 291 162 161 74 142 14 155 259 141 241 278 131 282 31 160 231 5 198 311 294 134 269 85 173 192 252 239 49 8 26 258 54 50 150 272 72 227 260 213 172 35 60 109 150 43 19 286 175 92 60 124 151 45 263 41 119 109 290 304 23 201 54 294 149 215 87 158 2 196 311 224 133 267 100 104 248 180 9 183 136 184 208 115 279 44 106 163 303 265 270 242 51 8 96 204 56 294 219 216 89 143 71 140 14 85 313 139 256 154 187 210 115 35 304 108 148 58 209 28 103 176 249 252 309 309 10 11 13 312 67 11 83 258 69 310 152 202 141 171 277 129 297 276 216 159 89 73 70 83 29 16 67 81 29 1 54 65 96 274 2 37 204 285 33 160 246 265 255 296 49 78 27 260 39 119 94 289 247 38 132 55 222 288 90 215 2 211 257 226 118 22 44 176 164 305 250 25 186 123 238 221 131 212 30 158 246 195 254 239 64 9 28 243 123 308 167 133 197 154 102 4 111 65 166 220 59 281 273 229 105 76 57 137 97 32 302 108 78 112 207 43 34 232 177 22 129 68 168 275 74 282 275 214 174 20 129 53 222 218 144 158 17 142 313 209 257 211 172 20 59 52 220 288 20 214 281 188 282 46 106 233 249 8 255 311 309 80 271 15 297 136 269 100 174 249 182 308 307 80 256 69 240 206 200 156 102 19 57 122 96 30 3 39 134 40 32 232 162 76 127 138 99 17 57 52 150 287 18 284 190 23 116 107 235 234 77 199 69 225 205 198 226 33 75 40 206 285 103 161 303 250 10 240 66 253 152 187 195 169 33 5 39 204 41 34 217 231 20 199 313 224 203 213 102 89 3 124 81 99 261 56 50 165 218 74 212 15 157 244 265 185 295 47 93 217 2 281 203 283 103 91 302 193 25 116 122 236 236 7 268 13 242 121 9 98 189 125 238 291 77 269 15 227 190 267 170 50 305 165 133 127 153 45 19 42 121 94 45 248 95 117 179 166 46 6 26 188 53 307 165 148 128 210 30 88 300 193 10 170 120 251 167 63 251 97 117 194 167 48 250 95 132 125 223 290 75 284 260 283 118 37 45 178 94 60 194 97 47 248 110 63 181 151 115 264 43 104 233 234 7 253 12 240 136 254 154 117 264 113 50 235 164 76 197 84 101 261 126 310 222 203 143 276 ^'}}, + {OUT=>'3D33DE31F64055D3B128AC9A6AA3F92DFD4F5330'}], + ['226', {IN=> {f=> '656 0 32 69 51 135 25 31 245 123 7 164 135 178 221 42 19 286 241 36 62 107 218 303 17 267 244 32 128 36 274 282 105 91 54 190 27 99 242 176 306 235 79 199 84 169 258 128 293 289 143 213 17 208 259 209 187 278 112 35 287 228 90 126 121 151 26 18 299 187 21 97 174 179 302 252 8 255 63 306 82 254 135 237 206 181 276 44 87 283 245 19 182 51 288 215 144 141 86 84 16 68 64 81 10 66 312 133 6 83 241 189 252 220 114 266 94 119 177 234 304 4 5 308 46 61 26 8 314 48 80 23 12 297 119 24 44 191 108 42 231 145 128 140 99 30 1 54 131 42 276 301 102 144 37 261 20 169 105 303 180 77 180 136 165 275 57 33 219 231 86 143 1 207 272 155 172 264 179 45 237 147 196 137 152 13 72 47 152 270 87 224 260 196 241 293 77 284 10 229 171 20 110 120 164 288 3 18 254 298 47 93 285 313 283 186 34 43 159 214 4 262 7 223 120 1 113 116 181 217 59 264 26 171 173 251 233 60 251 80 186 138 184 223 61 16 23 175 107 6 177 81 114 207 109 29 285 160 142 73 138 80 82 313 120 11 98 255 122 291 221 146 209 83 88 315 139 8 151 189 193 235 291 58 20 273 295 51 76 40 257 37 49 161 233 1 266 257 294 64 22 25 243 104 59 111 201 58 277 288 156 159 2 194 10 170 186 197 169 46 2 41 185 106 290 234 92 145 69 155 9 138 243 208 200 224 48 21 38 189 40 45 178 162 57 196 78 167 190 180 289 306 23 269 312 296 132 19 29 226 175 3 181 64 234 151 130 208 96 34 300 174 75 112 188 112 292 302 89 198 52 275 269 159 155 19 123 66 149 274 70 295 204 266 153 104 126 62 166 203 126 225 25 90 230 262 264 238 30 60 39 270 299 34 147 300 278 216 225 35 75 53 203 22 84 228 243 267 185 47 305 95 200 71 223 273 142 226 12 144 294 276 197 228 31 141 298 259 268 172 101 4 109 133 110 273 38 36 215 297 15 199 296 28 145 281 14 212 242 280 131 32 291 162 161 70 142 14 153 257 141 239 274 129 280 27 158 227 315 198 309 290 130 267 81 173 192 248 237 43 6 24 256 50 44 146 268 68 227 256 213 170 33 56 105 150 39 13 284 173 88 58 124 147 43 263 39 117 109 286 300 21 201 48 292 149 215 85 156 312 192 307 222 133 263 98 102 248 178 9 183 132 182 204 113 279 40 104 163 301 265 270 240 49 8 92 204 54 294 217 212 89 139 67 136 12 85 309 137 256 154 185 210 115 31 304 108 146 56 209 24 103 176 247 250 305 307 10 7 11 310 65 9 79 258 69 308 150 202 139 171 277 125 297 272 214 157 87 71 70 83 29 14 67 77 27 311 52 63 94 272 2 31 200 283 33 160 246 263 251 292 45 74 21 260 33 115 90 289 247 38 130 55 222 286 88 211 227 ^'}}, + {OUT=>'B6925F4DF94949B8844C867428BA3DEDF4CF2B51'}], + ['227', {IN=> {f=> '668 0 211 254 226 115 16 41 170 158 305 247 25 183 117 235 218 125 212 30 152 243 195 254 239 61 28 237 120 302 167 130 194 148 96 312 105 65 160 220 53 281 270 226 102 70 57 137 91 26 296 105 78 106 204 40 31 232 177 22 129 68 168 269 74 276 275 208 174 14 126 47 219 218 138 158 14 139 310 203 251 205 166 11 59 52 214 282 20 214 308 275 182 282 46 106 230 249 316 252 311 309 77 271 15 291 136 269 100 168 243 182 308 301 74 250 66 240 200 197 156 99 16 54 116 96 21 314 33 134 37 23 229 156 73 124 132 96 8 51 49 147 287 15 278 190 14 113 101 235 231 71 196 63 219 205 192 220 27 72 31 206 285 100 155 297 244 4 234 66 253 146 181 189 166 24 5 36 201 32 28 211 228 17 193 313 224 200 210 102 83 3 121 78 93 258 56 44 165 215 71 209 9 157 238 259 182 295 38 90 217 316 278 203 277 97 88 302 193 22 116 122 230 236 7 268 7 242 115 3 95 186 125 238 285 74 263 12 224 187 264 164 50 299 159 127 127 153 45 13 33 121 91 39 242 89 111 173 166 37 314 20 188 53 307 162 148 122 204 27 85 294 190 1 167 117 248 164 63 245 97 114 194 161 42 250 92 132 122 217 290 69 281 257 280 118 37 36 175 94 60 191 94 47 245 110 60 178 148 109 258 43 98 227 228 4 247 12 237 133 248 151 117 261 110 47 232 164 76 191 81 101 261 123 310 216 197 143 153 32 67 49 134 24 31 245 123 6 162 135 176 220 40 18 286 239 35 62 106 217 303 15 265 244 30 126 34 273 280 105 91 52 188 27 98 240 174 305 234 79 199 84 168 256 128 292 288 141 212 17 206 259 208 187 277 110 34 286 226 89 124 119 150 24 18 299 185 19 95 173 179 300 252 7 255 61 304 82 253 133 235 205 179 274 43 85 281 244 17 180 50 286 213 143 140 86 83 16 67 62 80 8 64 312 131 3 82 240 187 251 218 112 266 92 119 176 233 303 2 2 306 43 59 26 5 314 46 80 21 10 296 118 24 44 191 107 39 229 143 127 140 99 29 54 129 42 276 301 100 142 34 260 17 167 104 302 180 76 178 135 163 274 56 31 219 231 84 142 1 206 272 154 171 264 177 42 237 146 194 135 150 11 72 44 152 269 87 222 259 195 241 293 77 284 7 229 169 19 108 119 163 287 2 15 252 298 46 93 284 311 283 185 32 41 157 212 4 260 4 221 120 315 113 114 181 215 58 263 25 170 171 251 231 58 250 79 186 138 184 223 61 13 20 175 107 6 175 81 114 207 107 26 283 159 140 73 137 78 80 312 118 11 98 253 120 289 221 146 207 81 88 315 139 6 149 189 192 233 290 56 18 273 293 51 75 39 255 35 49 160 233 316 265 257 293 64 21 23 242 102 57 111 199 58 276 288 154 158 1 193 9 170 184 197 169 45 41 183 104 289 234 92 145 68 155 6 136 243 208 203 ^'}}, + {OUT=>'CF5E7256292ABEC431D8E8B9CBEAF22AF072377E'}], + ['228', {IN=> {f=> '656 0 221 48 21 32 186 40 42 178 159 51 196 72 161 187 177 283 306 23 266 309 296 129 10 26 220 172 316 178 61 228 151 130 205 90 34 297 168 69 109 182 112 292 299 83 192 46 269 263 159 149 19 117 63 143 274 67 292 201 260 147 104 313 126 56 163 200 123 225 16 90 230 262 258 232 21 57 39 264 296 31 147 300 278 216 219 35 75 50 197 13 78 225 237 267 185 41 302 95 197 71 220 270 139 223 3 144 288 273 191 228 28 135 295 253 265 172 95 1 106 130 107 267 29 36 212 291 6 196 293 19 142 275 8 209 239 280 131 23 291 162 161 64 142 14 150 254 141 236 268 126 277 21 155 221 309 198 306 284 124 264 75 173 192 242 234 34 3 21 253 44 35 140 262 62 227 250 213 167 30 50 99 150 33 4 281 170 82 55 124 141 40 263 36 114 109 280 294 18 201 39 289 149 215 82 153 306 186 301 219 133 257 95 99 248 175 9 183 126 179 198 110 279 34 101 163 298 265 270 237 46 8 86 204 51 294 214 206 89 133 61 130 9 85 303 134 256 154 182 210 115 25 304 108 143 53 209 18 103 176 244 247 299 304 10 1 8 307 62 6 73 258 69 305 147 202 136 171 277 119 297 266 211 154 84 68 70 83 29 11 67 71 24 305 49 60 91 269 2 22 194 280 33 160 246 260 245 286 39 68 12 260 24 109 84 289 247 38 127 55 222 283 85 205 311 211 252 226 113 12 39 166 154 305 245 25 181 113 233 216 121 212 30 148 241 195 254 239 59 313 28 233 118 298 167 128 192 144 92 308 101 65 156 220 49 281 268 224 100 66 57 137 87 22 292 103 78 102 202 38 29 232 177 22 129 68 168 265 74 272 275 204 174 10 124 43 217 218 134 158 12 137 308 199 247 201 162 5 59 52 210 278 20 214 304 271 178 282 46 106 228 249 312 250 311 309 75 271 15 287 136 269 100 164 239 182 308 297 70 246 64 240 196 195 156 97 14 52 112 96 15 312 29 134 35 17 227 152 71 122 128 94 2 47 47 145 287 13 274 190 8 111 97 235 229 67 194 59 215 205 188 216 23 70 25 206 285 98 151 293 240 230 66 253 142 177 185 164 18 5 34 199 26 24 207 226 15 189 313 224 198 208 102 79 3 119 76 89 256 56 40 165 213 69 207 5 157 234 255 180 295 32 88 217 316 276 203 273 93 86 302 193 20 116 122 226 236 7 268 3 242 111 318 93 184 125 238 281 72 259 10 222 185 262 160 50 295 155 123 127 153 45 9 27 121 89 35 238 85 107 169 166 31 310 16 188 53 307 160 148 118 200 25 83 290 188 314 165 115 246 162 63 241 97 112 194 157 38 250 90 132 120 213 290 65 279 255 278 118 37 30 173 94 60 189 92 47 243 110 58 176 146 105 254 43 94 223 224 2 243 12 235 131 244 149 117 259 108 45 230 164 76 187 79 101 261 109 ^'}}, + {OUT=>'975DCE94902923977F129C0E4ACF40AD28DDB9AA'}], + ['229', {IN=> {f=> '656 0 310 208 189 143 149 32 59 41 130 20 31 245 123 2 154 135 168 216 32 14 286 231 31 62 102 213 303 7 257 244 22 118 26 269 272 105 91 44 180 27 94 232 166 301 230 79 199 84 164 248 128 288 284 133 208 17 198 259 204 187 273 102 30 282 218 85 116 111 146 16 18 299 177 11 87 169 179 292 252 3 255 53 296 82 249 125 227 201 171 266 39 77 273 240 9 172 46 278 205 139 136 86 79 16 63 54 76 56 312 123 312 78 236 179 247 210 104 266 84 119 172 229 299 315 311 298 31 51 26 314 314 38 80 13 2 292 114 24 44 191 103 27 221 135 123 140 99 25 317 54 121 42 276 301 92 134 22 256 5 159 100 298 180 72 170 131 155 270 52 23 219 231 76 138 1 202 272 150 167 264 169 30 237 142 186 127 142 3 72 32 152 265 87 214 255 191 241 293 77 284 316 229 161 15 100 115 159 283 319 3 244 298 42 93 280 303 283 181 24 33 149 204 4 252 313 213 120 307 113 106 181 207 54 259 21 166 163 251 223 50 246 75 186 138 184 223 61 1 8 175 107 6 167 81 114 207 99 14 275 155 132 73 133 70 72 308 110 11 98 245 112 281 221 146 199 73 88 315 139 319 141 189 188 225 286 48 10 273 285 51 71 35 247 27 49 156 233 312 261 257 289 64 17 15 238 94 49 111 191 58 272 288 146 154 318 189 5 170 176 197 169 41 313 41 175 96 285 234 92 145 64 155 315 128 243 208 200 219 48 21 28 184 40 40 178 157 47 196 68 157 185 175 279 306 23 264 307 296 127 4 24 216 170 314 176 59 224 151 130 203 86 34 295 164 65 107 178 112 292 297 79 188 42 265 259 159 145 19 113 61 139 274 65 290 199 256 143 104 311 126 52 161 198 121 225 10 90 230 262 254 228 15 55 39 260 294 29 147 300 278 216 215 35 75 48 193 7 74 223 233 267 185 37 300 95 195 71 218 268 137 221 318 144 284 271 187 228 26 131 293 249 263 172 91 320 104 128 105 263 23 36 210 287 194 291 13 140 271 4 207 237 280 131 17 291 162 161 60 142 14 148 252 141 234 264 124 275 17 153 217 305 198 304 280 120 262 71 173 192 238 232 28 1 19 251 40 29 136 258 58 227 246 213 165 28 46 95 150 29 319 279 168 78 53 124 137 38 263 34 112 109 276 290 16 201 33 287 149 215 80 151 302 182 297 217 133 253 93 97 248 173 9 183 122 177 194 108 279 30 99 163 296 265 270 235 44 8 82 204 49 294 212 202 89 129 57 126 7 85 299 132 256 154 180 210 115 21 304 108 141 51 209 14 103 176 242 245 295 302 10 318 6 305 60 4 69 258 69 303 145 202 134 171 277 115 297 262 209 152 82 66 70 83 29 9 67 67 22 301 47 58 89 267 2 16 190 278 33 160 246 258 241 282 35 64 6 260 18 105 80 289 247 38 125 55 292 ^'}}, + {OUT=>'333B0259B18CE64D6B52CF563DD3041E5F63A516'}], + ); + +sub binary_expand ($$) +{ + my ($test_name, $line) = @_; + my ($n, $b, $rest) = split ' ', $line, 3; + defined $n && defined $b or die "$test_name: too few args\n"; + my @a = split ' ', $rest, $n + 1; + my $caret = pop @a; + $caret eq '^' or die "test $test_name: @a missing '^'\n"; + $b eq '1' || $b eq '0' or die "test $test_name: bad 'b'=$b\n"; + my $n_bad = @a; + @a == $n or + die "test $test_name: wrong number of args (expected $n, found $n_bad)\n"; + my $bit_string = ''; + foreach my $a (@a) + { + $bit_string .= $b x $a; + $b = 1 - $b; + } + my $t = pack ("B*", $bit_string); + # print "$bit_string\n $t\n"; + return $t; +} + +my $t; +foreach $t (@Tests) + { + # Expand each input. + my $in = $t->[1]->{IN}; + $in->{f} = binary_expand $t->[0], $in->{f}; + + # Convert each expected output string to lower case, and append " f\n". + my $h = $t->[2]; + $h->{OUT} = lc $h->{OUT} . " f\n"; + + # Insert the '--text' argument for each test. + splice @$t, 1, 0, '--text'; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'sha1sum'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sha1sum.pl b/tests/misc/sha1sum.pl new file mode 100755 index 000000000..2b08c7fc0 --- /dev/null +++ b/tests/misc/sha1sum.pl @@ -0,0 +1,90 @@ +#!/usr/bin/perl +# Test "sha1sum". + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'sha1sum'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $sha_degenerate = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; + +my @Tests = + ( + ['s1', {IN=> {f=> ''}}, + {OUT=>"$sha_degenerate f\n"}], + ['s2', {IN=> {f=> 'a'}}, + {OUT=>"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 f\n"}], + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"a9993e364706816aba3e25717850c26c9cd0d89d f\n"}], + ['s4', + {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, + {OUT=>"84983e441c3bd26ebaae4aa1f95129e5e54670f1 f\n"}], + ['s5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, + {OUT=>"32d10c7b8cf96570ca04ce37f2a19d84240d3a89 f\n"}], + ['s6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, + {OUT=>"761c457bf73b14d27e9e9265c46f4b4dda11f940 f\n"}], + ['s7', {IN=> {f=> '1234567890' x 8}}, + {OUT=>"50abf5706a150990a08b2c5ea40fa0e585554732 f\n"}], + ['million-a', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"34aa973cd4c4daa4f61eeb2bdbad27316534016f f\n"}], + ['bs-sha', {IN=> {".\\foo"=> ''}}, + {OUT=>"\\$sha_degenerate .\\\\foo\n"}], + # The sha1sum and md5sum drivers share a lot of code. + # Ensure that sha1sum does *not* share the part that makes + # md5sum accept BSD format. + ['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}}, + {AUX=> {f=> ''}}, + {ERR=>"sha1sum: f.md5: no properly formatted " + . "SHA1 checksum lines found\n"}, + {EXIT=> 1}], + ['check-bsd2', '--check', + {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, + {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], + ['check-bsd3', '--check', '--status', + {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}}, + {AUX=> {f=> 'bar'}}, {EXIT=> 1}], + ['check-openssl', '--check', + {IN=> {'f.md5' => "MD5(f)= $sha_degenerate\n"}}, + {AUX=> {f=> ''}}, + {ERR=>"sha1sum: f.md5: no properly formatted " + . "SHA1 checksum lines found\n"}, + {EXIT=> 1}], + ['check-openssl2', '--check', + {IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}}, + {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}], + ['check-openssl3', '--check', '--status', + {IN=> {'f.sha1' => "SHA1(f)= $sha_degenerate\n"}}, + {AUX=> {f=> 'bar'}}, {EXIT=> 1}], + ['bsd-segv', '--check', {IN=> {'z' => "SHA1 ("}}, {EXIT=> 1}, + {ERR=> "$prog: z: no properly formatted SHA1 checksum lines found\n"}], + ); + +# Insert the '--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sha224sum b/tests/misc/sha224sum deleted file mode 100755 index 1da67381f..000000000 --- a/tests/misc/sha224sum +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/perl -# Test "sha224sum". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 f\n"}], - ['s4', - {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, - {OUT=>"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525 f\n"}], - ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67 f\n"}], - ); - -# Insert the '--text' argument for each test. -my $t; -foreach $t (@Tests) - { - splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'sha224sum'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sha224sum.pl b/tests/misc/sha224sum.pl new file mode 100755 index 000000000..1da67381f --- /dev/null +++ b/tests/misc/sha224sum.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl +# Test "sha224sum". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 f\n"}], + ['s4', + {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, + {OUT=>"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67 f\n"}], + ); + +# Insert the '--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'sha224sum'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sha256sum b/tests/misc/sha256sum deleted file mode 100755 index fa408a635..000000000 --- a/tests/misc/sha256sum +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/perl -# Test "sha256sum". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $sha_degenerate = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; - -my @Tests = - ( - ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], - ['s2', {IN=> {f=> 'a'}}, - {OUT=>"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb f\n"}], - ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad f\n"}], - ['s4', - {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, - {OUT=>"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 f\n"}], - ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 f\n"}], - ); - -# Insert the '--text' argument for each test. -my $t; -foreach $t (@Tests) - { - splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'sha256sum'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sha256sum.pl b/tests/misc/sha256sum.pl new file mode 100755 index 000000000..fa408a635 --- /dev/null +++ b/tests/misc/sha256sum.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# Test "sha256sum". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $sha_degenerate = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; + +my @Tests = + ( + ['s1', {IN=> {f=> ''}}, + {OUT=>"$sha_degenerate f\n"}], + ['s2', {IN=> {f=> 'a'}}, + {OUT=>"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb f\n"}], + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad f\n"}], + ['s4', + {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}}, + {OUT=>"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 f\n"}], + ); + +# Insert the '--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'sha256sum'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sha384sum b/tests/misc/sha384sum deleted file mode 100755 index 921268b7b..000000000 --- a/tests/misc/sha384sum +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/perl -# Test "sha384sum". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $sha_degenerate = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"; - -my @Tests = - ( - ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], - ['s2', {IN=> {f=> 'a'}}, - {OUT=>"54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31 f\n"}], - ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 f\n"}], - ['s4', - {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, - {OUT=>"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039 f\n"}], - ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985 f\n"}], - ); - -# Insert the '--text' argument for each test. -my $t; -foreach $t (@Tests) - { - splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'sha384sum'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sha384sum.pl b/tests/misc/sha384sum.pl new file mode 100755 index 000000000..921268b7b --- /dev/null +++ b/tests/misc/sha384sum.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# Test "sha384sum". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $sha_degenerate = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"; + +my @Tests = + ( + ['s1', {IN=> {f=> ''}}, + {OUT=>"$sha_degenerate f\n"}], + ['s2', {IN=> {f=> 'a'}}, + {OUT=>"54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31 f\n"}], + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 f\n"}], + ['s4', + {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, + {OUT=>"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985 f\n"}], + ); + +# Insert the '--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'sha384sum'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sha512sum b/tests/misc/sha512sum deleted file mode 100755 index 7fdb396af..000000000 --- a/tests/misc/sha512sum +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/perl -# Test "sha512sum". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $sha_degenerate = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"; - -my @Tests = - ( - ['s1', {IN=> {f=> ''}}, - {OUT=>"$sha_degenerate f\n"}], - ['s2', {IN=> {f=> 'a'}}, - {OUT=>"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75 f\n"}], - ['s3', {IN=> {f=> 'abc'}}, - {OUT=>"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f f\n"}], - ['s4', - {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, - {OUT=>"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909 f\n"}], - ['s8', {IN=> {f=> 'a' x 1000000}}, - {OUT=>"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b f\n"}], - ); - -# Insert the '--text' argument for each test. -my $t; -foreach $t (@Tests) - { - splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; - } - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'sha512sum'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sha512sum.pl b/tests/misc/sha512sum.pl new file mode 100755 index 000000000..7fdb396af --- /dev/null +++ b/tests/misc/sha512sum.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# Test "sha512sum". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $sha_degenerate = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"; + +my @Tests = + ( + ['s1', {IN=> {f=> ''}}, + {OUT=>"$sha_degenerate f\n"}], + ['s2', {IN=> {f=> 'a'}}, + {OUT=>"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75 f\n"}], + ['s3', {IN=> {f=> 'abc'}}, + {OUT=>"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f f\n"}], + ['s4', + {IN=> {f=> 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'}}, + {OUT=>"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909 f\n"}], + ['s8', {IN=> {f=> 'a' x 1000000}}, + {OUT=>"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b f\n"}], + ); + +# Insert the '--text' argument for each test. +my $t; +foreach $t (@Tests) + { + splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/; + } + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'sha512sum'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/shred-exact b/tests/misc/shred-exact deleted file mode 100755 index 22d14c30d..000000000 --- a/tests/misc/shred-exact +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# make sure that neither --exact nor --zero gobbles a command line argument - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ shred - - -for opt in --exact --zero; do - echo a > a || fail=1 - echo bb > b || fail=1 - echo ccc > c || fail=1 - - shred --remove $opt a b || fail=1 - test -f a && fail=1 - test -f b && fail=1 - - shred --remove $opt c || fail=1 - test -f c && fail=1 -done - -Exit $fail diff --git a/tests/misc/shred-exact.sh b/tests/misc/shred-exact.sh new file mode 100755 index 000000000..22d14c30d --- /dev/null +++ b/tests/misc/shred-exact.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# make sure that neither --exact nor --zero gobbles a command line argument + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ shred + + +for opt in --exact --zero; do + echo a > a || fail=1 + echo bb > b || fail=1 + echo ccc > c || fail=1 + + shred --remove $opt a b || fail=1 + test -f a && fail=1 + test -f b && fail=1 + + shred --remove $opt c || fail=1 + test -f c && fail=1 +done + +Exit $fail diff --git a/tests/misc/shred-passes b/tests/misc/shred-passes deleted file mode 100755 index 4ff80d749..000000000 --- a/tests/misc/shred-passes +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Verify the operations done by shred - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ shred - - -# shred a single letter, zero length file which should result in -# 3 random passes and a single rename. -touch f || framework_failure_ -echo "\ -shred: f: pass 1/3 (random)... -shred: f: pass 2/3 (random)... -shred: f: pass 3/3 (random)... -shred: f: removing -shred: f: renamed to 0 -shred: f: removed" > exp || framework_failure_ - - -shred -v -u f 2>out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/shred-passes.sh b/tests/misc/shred-passes.sh new file mode 100755 index 000000000..4ff80d749 --- /dev/null +++ b/tests/misc/shred-passes.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Verify the operations done by shred + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ shred + + +# shred a single letter, zero length file which should result in +# 3 random passes and a single rename. +touch f || framework_failure_ +echo "\ +shred: f: pass 1/3 (random)... +shred: f: pass 2/3 (random)... +shred: f: pass 3/3 (random)... +shred: f: removing +shred: f: renamed to 0 +shred: f: removed" > exp || framework_failure_ + + +shred -v -u f 2>out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/shred-remove b/tests/misc/shred-remove deleted file mode 100755 index c060a21cb..000000000 --- a/tests/misc/shred-remove +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Exercise a bug that was fixed in shred-4.0l - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ shred -skip_if_root_ - -# The length of the basename is what matters. -# In this case, shred would try to rename the file 256^10 times -# before terminating. -file=0123456789 -touch $file || framework_failure_ -chmod u-w $file || framework_failure_ - - -# This would take so long that it appears to infloop -# when using version from fileutils-4.0k. -# When the command completes, expect it to fail. -shred -u $file > /dev/null 2>&1 && fail=1 || : - -Exit $fail diff --git a/tests/misc/shred-remove.sh b/tests/misc/shred-remove.sh new file mode 100755 index 000000000..c060a21cb --- /dev/null +++ b/tests/misc/shred-remove.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Exercise a bug that was fixed in shred-4.0l + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ shred +skip_if_root_ + +# The length of the basename is what matters. +# In this case, shred would try to rename the file 256^10 times +# before terminating. +file=0123456789 +touch $file || framework_failure_ +chmod u-w $file || framework_failure_ + + +# This would take so long that it appears to infloop +# when using version from fileutils-4.0k. +# When the command completes, expect it to fail. +shred -u $file > /dev/null 2>&1 && fail=1 || : + +Exit $fail diff --git a/tests/misc/shuf b/tests/misc/shuf deleted file mode 100755 index 243c0498d..000000000 --- a/tests/misc/shuf +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Ensure that shuf randomizes its input. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ shuf -getlimits_ - -seq 100 > in || framework_failure_ - -shuf in >out || fail=1 - -# Fail if the input is the same as the output. -# This is a probabilistic test :-) -# However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) -compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } - -# Fail if the sorted output is not the same as the input. -sort -n out > out1 -compare in out1 || { fail=1; echo "not a permutation" 1>&2; } - -# Exercise shuf's -i option. -shuf -i 1-100 > out || fail=1 -compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } -sort -n out > out1 -compare in out1 || { fail=1; echo "not a permutation" 1>&2; } - -# Exercise shuf's -e option. -t=$(shuf -e a b c d e | sort | fmt) -test "$t" = 'a b c d e' || { fail=1; echo "not a permutation" 1>&2; } - -# Before coreutils-6.3, this would infloop. -# "seq 1860" produces 8193 (8K + 1) bytes of output. -seq 1860 | shuf > /dev/null || fail=1 - -# coreutils-6.12 and earlier would output a newline terminator, not \0. -shuf --zero-terminated -i 1-1 > out || fail=1 -printf '1\0' > exp || framework_failure_ -cmp out exp || { fail=1; echo "missing NUL terminator?" 1>&2; } - -# Ensure shuf -n operates efficiently for small n. Before coreutils-8.13 -# this would try to allocate $SIZE_MAX * sizeof(size_t) -timeout 10 shuf -i1-$SIZE_MAX -n2 >/dev/null || - { fail=1; echo "couldn't get a small subset" >&2; } - -Exit $fail diff --git a/tests/misc/shuf.sh b/tests/misc/shuf.sh new file mode 100755 index 000000000..243c0498d --- /dev/null +++ b/tests/misc/shuf.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# Ensure that shuf randomizes its input. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ shuf +getlimits_ + +seq 100 > in || framework_failure_ + +shuf in >out || fail=1 + +# Fail if the input is the same as the output. +# This is a probabilistic test :-) +# However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) +compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } + +# Fail if the sorted output is not the same as the input. +sort -n out > out1 +compare in out1 || { fail=1; echo "not a permutation" 1>&2; } + +# Exercise shuf's -i option. +shuf -i 1-100 > out || fail=1 +compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } +sort -n out > out1 +compare in out1 || { fail=1; echo "not a permutation" 1>&2; } + +# Exercise shuf's -e option. +t=$(shuf -e a b c d e | sort | fmt) +test "$t" = 'a b c d e' || { fail=1; echo "not a permutation" 1>&2; } + +# Before coreutils-6.3, this would infloop. +# "seq 1860" produces 8193 (8K + 1) bytes of output. +seq 1860 | shuf > /dev/null || fail=1 + +# coreutils-6.12 and earlier would output a newline terminator, not \0. +shuf --zero-terminated -i 1-1 > out || fail=1 +printf '1\0' > exp || framework_failure_ +cmp out exp || { fail=1; echo "missing NUL terminator?" 1>&2; } + +# Ensure shuf -n operates efficiently for small n. Before coreutils-8.13 +# this would try to allocate $SIZE_MAX * sizeof(size_t) +timeout 10 shuf -i1-$SIZE_MAX -n2 >/dev/null || + { fail=1; echo "couldn't get a small subset" >&2; } + +Exit $fail diff --git a/tests/misc/sort b/tests/misc/sort deleted file mode 100755 index 10d1e5fbd..000000000 --- a/tests/misc/sort +++ /dev/null @@ -1,432 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $limits = getlimits (); - -my $prog = 'sort'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $mb_locale = $ENV{LOCALE_FR_UTF8}; -! defined $mb_locale || $mb_locale eq 'none' - and $mb_locale = 'C'; - -# Since each test is run with a file name and with redirected stdin, -# the name in the diagnostic is either the file name or "-". -# Normalize each diagnostic to use '-'. -my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'}; - -my $no_file = "$prog: cannot read: no-file: No such file or directory\n"; - -my @Tests = -( -["n1", '-n', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}], -["n2", '-n', {IN=>".02\n.01\n"}, {OUT=>".01\n.02\n"}], -["n3", '-n', {IN=>".02\n.00\n"}, {OUT=>".00\n.02\n"}], -["n4", '-n', {IN=>".02\n.000\n"}, {OUT=>".000\n.02\n"}], -["n5", '-n', {IN=>".021\n.029\n"}, {OUT=>".021\n.029\n"}], - -["n6", '-n', {IN=>".02\n.0*\n"}, {OUT=>".0*\n.02\n"}], -["n7", '-n', {IN=>".02\n.*\n"}, {OUT=>".*\n.02\n"}], -["n8a", '-s -n -k1,1', {IN=>".0a\n.0b\n"}, {OUT=>".0a\n.0b\n"}], -["n8b", '-s -n -k1,1', {IN=>".0b\n.0a\n"}, {OUT=>".0b\n.0a\n"}], -["n9a", '-s -n -k1,1', {IN=>".000a\n.000b\n"}, {OUT=>".000a\n.000b\n"}], -["n9b", '-s -n -k1,1', {IN=>".000b\n.000a\n"}, {OUT=>".000b\n.000a\n"}], -["n10a", '-s -n -k1,1', {IN=>".00a\n.000b\n"}, {OUT=>".00a\n.000b\n"}], -["n10b", '-s -n -k1,1', {IN=>".00b\n.000a\n"}, {OUT=>".00b\n.000a\n"}], -["n11a", '-s -n -k1,1', {IN=>".01a\n.010\n"}, {OUT=>".01a\n.010\n"}], -["n11b", '-s -n -k1,1', {IN=>".010\n.01a\n"}, {OUT=>".010\n.01a\n"}], - -# human readable suffixes -["h1", '-h', - {IN=>"1Y\n1Z\n1E\n1P\n1T\n1G\n1M\n1K\n02\n1\nY\n-1k\n-1M\n-1G\n-1T\n" - . "-1P\n-1E\n-1Z\n-1Y\n"}, - {OUT=>"-1Y\n-1Z\n-1E\n-1P\n-1T\n-1G\n-1M\n-1k\nY\n1\n02\n1K\n1M\n1G\n1T\n" - . "1P\n1E\n1Z\n1Y\n"}], -["h2", '-h', {IN=>"1M\n-2G\n-3K"}, {OUT=>"-2G\n-3K\n1M\n"}], -# check that it works with powers of 1024 -["h3", '-k 2,2h -k 1,1', {IN=>"a 1G\nb 1023M\n"}, {OUT=>"b 1023M\na 1G\n"}], -# decimal at end => allowed -["h4", '-h', {IN=>"1.E\n2.M\n"}, {OUT=>"2.M\n1.E\n"}], -# double decimal => ignore suffix -["h5", '-h', {IN=>"1..2E\n2..2M\n"}, {OUT=>"1..2E\n2..2M\n"}], -# "M" sorts before "G" regardless of the positive number attached. -["h6", '-h', {IN=>"1GiB\n1030MiB\n"}, {OUT=>"1030MiB\n1GiB\n"}], -# check option incompatibility -["h7", '-hn', {IN=>""}, {OUT=>""}, {EXIT=>2}, - {ERR=>"$prog: options '-hn' are incompatible\n"}], -# check key processing -["h8", '-n -k2,2h', {IN=>"1 1E\n2 2M\n"}, {OUT=>"2 2M\n1 1E\n"}], -# SI and IEC prefixes on separate keys allowed -["h9", '-h -k1,1 -k2,2', {IN=>"1M 1Mi\n1M 1Mi\n"}, {OUT=>"1M 1Mi\n1M 1Mi\n"}], -# This invalid SI and IEC prefix mixture is not significant so not noticed -["h10", '-h -k1,1 -k2,2', {IN=>"1M 2M\n2M 1Mi\n"}, {OUT=>"1M 2M\n2M 1Mi\n"}], - -["01a", '', {IN=>"A\nB\nC\n"}, {OUT=>"A\nB\nC\n"}], -# -["02a", '-c', {IN=>"A\nB\nC\n"}, {OUT=>''}], -["02b", '-c', {IN=>"A\nC\nB\n"}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: -:3: disorder: B\n"}, $normalize_filename], -["02c", '-c -k1,1', {IN=>"a\na b\n"}, {OUT=>''}], -["02d", '-C', {IN=>"A\nB\nC\n"}, {OUT=>''}], -["02e", '-C', {IN=>"A\nC\nB\n"}, {OUT=>''}, {EXIT=>1}], -# This should fail because there are duplicate keys -["02m", '-cu', {IN=>"A\nA\n"}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: -:2: disorder: A\n"}, $normalize_filename], -["02n", '-cu', {IN=>"A\nB\n"}, {OUT=>''}], -["02o", '-cu', {IN=>"A\nB\nB\n"}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: -:3: disorder: B\n"}, $normalize_filename], -["02p", '-cu', {IN=>"B\nA\nB\n"}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: -:2: disorder: A\n"}, $normalize_filename], -["02q", '-c -k 1,1fR', {IN=>"ABC\nABc\nAbC\nAbc\naBC\naBc\nabC\nabc\n"}], -["02r", '-c -k 1,1fV', {IN=>"ABC\nABc\nAbC\nAbc\naBC\naBc\nabC\nabc\n"}], -["02s", '-c -k 1,1dfR', - {IN=>".ABC\n.ABc.\nA.bC\nA.bc.\naB.C\naB.c.\nabC.\nabc..\n"}], -# -["03a", '-k1', {IN=>"B\nA\n"}, {OUT=>"A\nB\n"}], -["03b", '-k1,1', {IN=>"B\nA\n"}, {OUT=>"A\nB\n"}], -["03c", '-k1 -k2', {IN=>"A b\nA a\n"}, {OUT=>"A a\nA b\n"}], -# Fail with a diagnostic when -k specifies field == 0. -["03d", '-k0', {EXIT=>2}, - {ERR=>"$prog: -: invalid field specification '0'\n"}, - $normalize_filename], -# Fail with a diagnostic when -k specifies character == 0. -["03e", '-k1.0', {EXIT=>2}, - {ERR=>"$prog: character offset is zero: invalid field specification '1.0'\n"}], -["03f", '-k1.1,-k0', {EXIT=>2}, - {ERR=>"$prog: invalid number after ',': invalid count at start of '-k0'\n"}], -# This is ok. -["03g", '-k1.1,1.0', {IN=>''}], -# This is equivalent to 3f. -["03h", '-k1.1,1', {IN=>''}], -# This too, is equivalent to 3f. -["03i", '-k1,1', {IN=>''}], -# -["04a", '-nc', {IN=>"2\n11\n"}], -["04b", '-n', {IN=>"11\n2\n"}, {OUT=>"2\n11\n"}], -["04c", '-k1n', {IN=>"11\n2\n"}, {OUT=>"2\n11\n"}], -["04d", '-k1', {IN=>"11\n2\n"}, {OUT=>"11\n2\n"}], -["04e", '-k2', {IN=>"ignored B\nz-ig A\n"}, {OUT=>"z-ig A\nignored B\n"}], -# -["05a", '-k1,2', {IN=>"A B\nA A\n"}, {OUT=>"A A\nA B\n"}], -["05b", '-k1,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -["05c", '-k1 -k2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -["05d", '-k2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -["05e", '-k2,2', {IN=>"A B Z\nA A A\n"}, {OUT=>"A A A\nA B Z\n"}], -["05f", '-k2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -# -["06a", '-k 1,2', {IN=>"A B\nA A\n"}, {OUT=>"A A\nA B\n"}], -["06b", '-k 1,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -["06c", '-k 1 -k 2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -["06d", '-k 2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -["06e", '-k 2,2', {IN=>"A B Z\nA A A\n"}, {OUT=>"A A A\nA B Z\n"}], -["06f", '-k 2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], -# -["07a", '-k 2,3', {IN=>"9 a b\n7 a a\n"}, {OUT=>"7 a a\n9 a b\n"}], -["07b", '-k 2,3', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}], -["07c", '-k 2,3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}], -["07d", '+1 -3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}], -# ensure a character position of 0 includes whole field -["07e", '-k 2,3.0', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}], -# ensure fields with end position before start are ignored -["07f", '-n -k1.3,1.1', {IN=>"a 2\nb 1\n"}, {OUT=>"a 2\nb 1\n"}], -["07g", '-n -k2.2,1.2', {IN=>"aa 2\nbb 1\n"}, {OUT=>"aa 2\nbb 1\n"}], -["07h", '-k1.3nb,1.3', {IN=>" a 2\n b 1\n"}, {OUT=>" a 2\n b 1\n"}], -# ensure obsolescent key limits are handled correctly -["07i", '-s +0 -1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}], -["07j", '-s +0 -1.0', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}], -["07k", '-s +0 -1.1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}], -["07l", '-s +0 -1.2', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}], -["07m", '-s +0 -1.1b', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}], -# -# report an error for '.' without following char spec -["08a", '-k 2.,3', {EXIT=>2}, - {ERR=>"$prog: invalid number after '.': invalid count at start of ',3'\n"}], -# report an error for ',' without following POS2 -["08b", '-k 2,', {EXIT=>2}, - {ERR=>"$prog: invalid number after ',': invalid count at start of ''\n"}], -# -# Test new -g option. -["09a", '-g', {IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}], -# Make sure -n works how we expect. -["09b", '-n', {IN=>"1e2\n2e1\n"}, {OUT=>"1e2\n2e1\n"}], -["09c", '-n', {IN=>"2e1\n1e2\n"}, {OUT=>"1e2\n2e1\n"}], -["09d", '-k2g', {IN=>"a 1e2\nb 2e1\n"}, {OUT=>"b 2e1\na 1e2\n"}], -# -# Bug reported by Roger Peel -["10a", '-t : -k 2.2,2.2', {IN=>":ba\n:ab\n"}, {OUT=>":ba\n:ab\n"}], -# Equivalent to above, but using obsolescent '+pos -pos' option syntax. -["10b", '-t : +1.1 -1.2', {IN=>":ba\n:ab\n"}, {OUT=>":ba\n:ab\n"}], -# -# The same as the preceding two, but with input lines reversed. -["10c", '-t : -k 2.2,2.2', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}], -# Equivalent to above, but using obsolescent '+pos -pos' option syntax. -["10d", '-t : +1.1 -1.2', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}], -# Try without -t... -# But note that we have to count the delimiting space at the beginning -# of each field that has it. -["10a0", '-k 2.3,2.3', {IN=>"z ba\nz ab\n"}, {OUT=>"z ba\nz ab\n"}], -["10a1", '-k 1.2,1.2', {IN=>"ba\nab\n"}, {OUT=>"ba\nab\n"}], -["10a2", '-b -k 2.2,2.2', {IN=>"z ba\nz ab\n"}, {OUT=>"z ba\nz ab\n"}], -# -# An even simpler example demonstrating the bug. -["10e", '-k 1.2,1.2', {IN=>"ab\nba\n"}, {OUT=>"ba\nab\n"}], -# -# The way sort works on these inputs (10f and 10g) seems wrong to me. -# See http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=3c467c0d223 -# POSIX doesn't seem to say one way or the other, but that's the way all -# other sort implementations work. -["10f", '-t : -k 1.3,1.3', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}], -["10g", '-k 1.4,1.4', {IN=>"a ab\nb ba\n"}, {OUT=>"b ba\na ab\n"}], -# -# Exercise bug re using -b to skip trailing blanks. -["11a", '-t: -k1,1b -k2,2', {IN=>"a\t:a\na :b\n"}, {OUT=>"a\t:a\na :b\n"}], -["11b", '-t: -k1,1b -k2,2', {IN=>"a :b\na\t:a\n"}, {OUT=>"a\t:a\na :b\n"}], -["11c", '-t: -k2,2b -k3,3', {IN=>"z:a\t:a\na :b\n"}, {OUT=>"z:a\t:a\na :b\n"}], -# Before 1.22m, the first key comparison reported equality. -# With 1.22m, they compare different: "a" sorts before "a\n", -# and the second key spec isn't even used. -["11d", '-t: -k2,2b -k3,3', {IN=>"z:a :b\na\t:a\n"}, {OUT=>"a\t:a\nz:a :b\n"}], -# -# Exercise bug re comparing '-' and integers. -["12a", '-n -t: +1', {IN=>"a:1\nb:-\n"}, {OUT=>"b:-\na:1\n"}], -["12b", '-n -t: +1', {IN=>"b:-\na:1\n"}, {OUT=>"b:-\na:1\n"}], -# Try some other (e.g. 'X') invalid character. -["12c", '-n -t: +1', {IN=>"a:1\nb:X\n"}, {OUT=>"b:X\na:1\n"}], -["12d", '-n -t: +1', {IN=>"b:X\na:1\n"}, {OUT=>"b:X\na:1\n"}], -# From Karl Heuer -["13a", '+0.1n', {IN=>"axx\nb-1\n"}, {OUT=>"b-1\naxx\n"}], -["13b", '+0.1n', {IN=>"b-1\naxx\n"}, {OUT=>"b-1\naxx\n"}], -# -# From Carl Johnson -["14a", '-d -u', {IN=>"mal\nmal-\nmala\n"}, {OUT=>"mal\nmala\n"}], -# Be sure to fix the (translate && ignore) case in keycompare. -["14b", '-f -d -u', {IN=>"mal\nmal-\nmala\n"}, {OUT=>"mal\nmala\n"}], -# -# Experiment with -i. -["15a", '-i -u', {IN=>"a\na\1\n"}, {OUT=>"a\n"}], -["15b", '-i -u', {IN=>"a\n\1a\n"}, {OUT=>"a\n"}], -["15c", '-i -u', {IN=>"a\1\na\n"}, {OUT=>"a\1\n"}], -["15d", '-i -u', {IN=>"\1a\na\n"}, {OUT=>"\1a\n"}], -["15e", '-i -u', {IN=>"a\n\1\1\1\1\1a\1\1\1\1\n"}, {OUT=>"a\n"}], - -# This would fail (printing only the 7) for 8.6..8.18. -# Use --parallel=1 for reproducibility, and a small buffer size -# to let us trigger the problem with a smaller input. -["unique-1", '--p=1 -S32b -u', {IN=>"7\n"x11 . "1\n"}, {OUT=>"1\n7\n"}], -# Demonstrate that 8.19's key-spec-adjusting code is required. -# These are more finicky in that they are arch-dependent. -["unique-key-i686", '-u -k2,2 --p=1 -S32b', - {IN=>"a 7\n"x10 . "b 1\n"}, {OUT=>"b 1\na 7\n"}], -["unique-key-x86_64", '-u -k2,2 --p=1 -S32b', - {IN=>"a 7\n"x11 . "b 1\n"}, {OUT=>"b 1\na 7\n"}], -# Before 8.19, this would trigger a free-memory read. -["unique-free-mem-read", '-u --p=1 -S32b', - {IN=>"a\n"."b"x900 ."\n"}, - {OUT=>"a\n"."b"x900 ."\n"}], - -# From Erick Branderhorst -- fixed around 1.19e -["16a", '-f', - {IN=>"éminence\nüberhaupt\n's-Gravenhage\naëroclub\nAag\naagtappels\n"}, - {OUT=>"'s-Gravenhage\nAag\naagtappels\naëroclub\néminence\nüberhaupt\n"}], - -# This provokes a one-byte memory overrun of a malloc'd block for versions -# of sort from textutils-1.19p and before. -["17", '-c', {IN=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"}], - -# POSIX says -n no longer implies -b, so here we're comparing ' 9' and '10'. -["18a", '-k1.1,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}], - -# Just like above, because the global '-b' has no effect on the -# key specifier when a key-specific option ('n' in this case) is used. -["18b", '-b -k1.1,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}], - -# Here we're comparing ' 90' and '10', because the 'b' on the key-end specifier -# makes sort ignore leading blanks when determining that key's *end*. -["18c", '-k1.1,1.2nb', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}], - -# Here we're comparing '9' and '10', because the 'b' on the key-start specifier -# makes sort ignore leading blanks when determining that key's *start*. -["18d", '-k1.1b,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}], - -# This compares '90' and '10', as it ignores leading blanks for both -# key start and key end. -["18e", '-nb -k1.1,1.2', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}], - -# When ignoring leading blanks for end position, ensure blanks from -# next field are not included in the sort. I.E. order should not change here. -["18f", '-k1,1b', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}], - -# When ignoring leading blanks for start position, ensure blanks from -# next field are not included in the sort. I.E. order should not change here. -# This was noticed as an issue on fedora 8 (only in multibyte locales). -["18g", '-k1b,1', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}, - {ENV => "LC_ALL=$mb_locale"}], - -# This looks odd, but works properly -- 2nd keyspec is never -# used because all lines are different. -["19a", '+0 +1nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 1\nb 2\nb 3\n"}], - -# The test *intended* by the author of the above, but using the -# more-intuitive POSIX-style -k options. -["19b", '-k1,1 -k2nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 3\nb 2\nb 1\n"}], - -# This test failed when sort-1.22 was compiled on a Next x86 system -# without optimization. Without optimization gcc uses the buggy version -# of memcmp in the Next C library. With optimization, gcc uses its -# (working) builtin version. Test case form William Lewis. -["20a", '', - {IN=>"_________U__free\n_________U__malloc\n_________U__abort\n" - . "_________U__memcpy\n_________U__memset\n" - . "_________U_dyld_stub_binding_helper\n_________U__malloc\n" - . "_________U___iob\n_________U__abort\n_________U__fprintf\n"}, - {OUT=>"_________U___iob\n_________U__abort\n_________U__abort\n" - . "_________U__fprintf\n_________U__free\n_________U__malloc\n" - . "_________U__malloc\n_________U__memcpy\n_________U__memset\n" - . "_________U_dyld_stub_binding_helper\n"}], - -# Demonstrate that folding changes the ordering of e.g. A, a, and _ -# because while they normally (in the C locale) collate like A, _, a, -# when using -f, 'a' is compared as if it were 'A'. -["21a", '', {IN=>"A\na\n_\n"}, {OUT=>"A\n_\na\n"}], -["21b", '-f', {IN=>"A\na\n_\n"}, {OUT=>"A\na\n_\n"}], -["21c", '-f', {IN=>"a\nA\n_\n"}, {OUT=>"A\na\n_\n"}], -["21d", '-f', {IN=>"_\na\nA\n"}, {OUT=>"A\na\n_\n"}], -["21e", '-f', {IN=>"a\n_\nA\n"}, {OUT=>"A\na\n_\n"}], -["21f", '-fs', {IN=>"A\na\n_\n"}, {OUT=>"A\na\n_\n"}], -["21g", '-fu', {IN=>"a\n_\n"}, {OUT=>"a\n_\n"}], - -# This test failed until 1.22f. From Zvi Har'El. -["22a", '-k 2,2fd -k 1,1r', {IN=>"3 b\n4 B\n"}, {OUT=>"4 B\n3 b\n"}], -["22b", '-k 2,2d -k 1,1r', {IN=>"3 b\n4 b\n"}, {OUT=>"4 b\n3 b\n"}], - -["no-file1", 'no-file', {EXIT=>2}, {ERR=>$no_file}], -# This test failed until 1.22f. Sort didn't give an error. -# From Will Edgington. -["o-no-file1", qw(-o no-file no-file), {EXIT=>2}, {ERR=>$no_file}], - -["create-empty", qw(-o no/such/file /dev/null), {EXIT=>2}, - {ERR=>"$prog: open failed: no/such/file: No such file or directory\n"}], - -# From Paul Eggert. This was fixed in textutils-1.22k. -["neg-nls", '-n', {IN=>"-1\n-9\n"}, {OUT=>"-9\n-1\n"}], - -# From Paul Eggert. This was fixed in textutils-1.22m. -# The bug was visible only when using the internationalized sorting code -# (i.e., not when configured with --disable-nls). -["nul-nls", '', {IN=>"\0b\n\0a\n"}, {OUT=>"\0a\n\0b\n"}], - -# Paul Eggert wrote: -# A previous version of POSIX incorrectly required that the newline -# at the end of the input line contributed to the sort, which would -# mean that an empty line should sort after a line starting with a tab -# (because \t precedes \n in the ASCII collating sequence). -# GNU 'sort' was altered to do this, but was changed back once it -# was discovered to be a POSIX bug (and the POSIX bug was fixed). -# Check that 'sort' conforms to the fixed POSIX, not to the buggy one. -["use-nl", '', {IN=>"\n\t\n"}, {OUT=>"\n\t\n"}], - -# Specifying two -o options should evoke a failure -["o2", qw(-o x -o y), {EXIT=>2}, - {ERR=>"foo\n"}, {ERR_SUBST => 's/^$prog: .*/foo/'}], - -# Specifying incompatible options should evoke a failure. -["incompat1", '-in', {EXIT=>2}, - {ERR=>"$prog: options '-in' are incompatible\n"}], -["incompat2", '-nR', {EXIT=>2}, - {ERR=>"$prog: options '-nR' are incompatible\n"}], -["incompat3", '-dfgiMnR', {EXIT=>2}, - {ERR=>"$prog: options '-dfgMnR' are incompatible\n"}], -["incompat4", qw(-c -o /dev/null), {EXIT=>2}, - {ERR=>"$prog: options '-co' are incompatible\n"}], -["incompat5", qw(-C -o /dev/null), {EXIT=>2}, - {ERR=>"$prog: options '-Co' are incompatible\n"}], -["incompat6", '-cC', {EXIT=>2}, - {ERR=>"$prog: options '-cC' are incompatible\n"}], -["incompat7", qw(--sort=random -n), {EXIT=>2}, - {ERR=>"$prog: options '-nR' are incompatible\n"}], - -# -t '\0' is accepted, as of coreutils-5.0.91 -['nul-tab', "-k2,2 -t '\\0'", - {IN=>"a\0z\01\nb\0y\02\n"}, {OUT=>"b\0y\02\na\0z\01\n"}], - -# fields > SIZE_MAX are silently interpreted as SIZE_MAX -["bigfield1", "-k $limits->{UINTMAX_OFLOW}", - {IN=>"2\n1\n"}, {OUT=>"1\n2\n"}], -["bigfield2", "-k $limits->{SIZE_OFLOW}", - {IN=>"2\n1\n"}, {OUT=>"1\n2\n"}], - -# Using an old-style key-specifying option like +1 with an invalid -# ordering-option character would cause sort to try to free an invalid -# (non-malloc'd) pointer. This bug affects coreutils-6.5 through 6.9. -['obs-inval', '+1x', {EXIT=>2}, - {ERR=>"foo\n"}, {ERR_SUBST => 's/^$prog: .*/foo/'}], - -# Exercise the code that enlarges the line buffer. See the thread here: -# http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11006 -['realloc-buf', '-S1', {IN=>'a'x4000 ."\n"}, {OUT=>'a'x4000 ."\n"}], -['realloc-buf-2', '-S1', {IN=>'a'x5 ."\n"}, {OUT=>'a'x5 ."\n"}], - -["sort-numeric", '--sort=numeric', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}], -["sort-gennum", '--sort=general-numeric', - {IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}], - -# -m with output file also used as an input file -# In coreutils-7.2, this caused a segfault. -# This test looks a little strange. Here's why: -# since we're using "-o f", standard output will be empty, hence OUT=>'' -# We still want to ensure that the output file, "f" has expected contents, -# hence the added CMP=> directive. -["output-is-input", '-m -o f', {IN=> {f=> "a\n"}}, {OUT=>''}, - {CMP=> ["a\n", {'f'=> undef}]} ], -["output-is-input-2", '-m -o f', {OUT=>''}, - {IN=> {f=> "a\n"}}, {IN=> {g=> "b\n"}}, {IN=> {h=> "c\n"}}, - {CMP=> ["a\nb\nc\n", {'f'=> undef}]} ], -["output-is-input-3", '-m -o f', {OUT=>''}, - {IN=> {g=> "a\n"}}, {IN=> {h=> "b\n"}}, {IN=> {f=> "c\n"}}, - {CMP=> ["a\nb\nc\n", {'f'=> undef}]} ], -); - -# Add _POSIX2_VERSION=199209 to the environment of each test -# that uses an old-style option like +1. -foreach my $t (@Tests) - { - foreach my $e (@$t) - { - !ref $e && $e =~ /\+\d/ - and push (@$t, {ENV=>'_POSIX2_VERSION=199209'}), last; - } - } - -@Tests = triple_test \@Tests; - -# Remember that triple_test creates from each test with exactly one "IN" -# file two more tests (.p and .r suffix on name) corresponding to reading -# input from a file and from a pipe. The pipe-reading test would fail -# due to a race condition about 1 in 20 times. -# Remove the IN_PIPE version of the "output-is-input" test above. -# The others aren't susceptible because they have three inputs each. -@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sort-NaN-infloop b/tests/misc/sort-NaN-infloop deleted file mode 100755 index e64d38599..000000000 --- a/tests/misc/sort-NaN-infloop +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# exercise the NaN-infloop bug in coreutils-8.13 - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -echo nan > F || fail=1 -printf 'nan\nnan\n' > exp || fail=1 -timeout 10 sort -g -m F F > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/sort-NaN-infloop.sh b/tests/misc/sort-NaN-infloop.sh new file mode 100755 index 000000000..e64d38599 --- /dev/null +++ b/tests/misc/sort-NaN-infloop.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# exercise the NaN-infloop bug in coreutils-8.13 + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +echo nan > F || fail=1 +printf 'nan\nnan\n' > exp || fail=1 +timeout 10 sort -g -m F F > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/sort-benchmark-random b/tests/misc/sort-benchmark-random deleted file mode 100755 index 9eb9a63f9..000000000 --- a/tests/misc/sort-benchmark-random +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# Benchmark sort on randomly generated data. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Written by Glen Lenker. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -very_expensive_ - -perl -e ' -my $num_lines = 500000; -my $length = 100; - -for (my $i=0; $i < $num_lines; $i++) -{ - for (my $j=0; $j < $length; $j++) - { - printf "%c", 32 + rand(94); - } - print "\n"; -}' > in || framework_failure_ - -# We need to generate a lot of data for sort to show a noticeable -# improvement in performance. Sorting it in PERL may take awhile. - -perl -e ' -open (FILE, "; -print sort(@list); -close (FILE); -' > exp || framework_failure_ - -time sort in > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/sort-benchmark-random.sh b/tests/misc/sort-benchmark-random.sh new file mode 100755 index 000000000..9eb9a63f9 --- /dev/null +++ b/tests/misc/sort-benchmark-random.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Benchmark sort on randomly generated data. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Written by Glen Lenker. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +very_expensive_ + +perl -e ' +my $num_lines = 500000; +my $length = 100; + +for (my $i=0; $i < $num_lines; $i++) +{ + for (my $j=0; $j < $length; $j++) + { + printf "%c", 32 + rand(94); + } + print "\n"; +}' > in || framework_failure_ + +# We need to generate a lot of data for sort to show a noticeable +# improvement in performance. Sorting it in PERL may take awhile. + +perl -e ' +open (FILE, "; +print sort(@list); +close (FILE); +' > exp || framework_failure_ + +time sort in > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/sort-compress b/tests/misc/sort-compress deleted file mode 100755 index 00dcf06ac..000000000 --- a/tests/misc/sort-compress +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# Test use of compression by sort - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -seq -w 2000 > exp || framework_failure_ -tac exp > in || framework_failure_ - -# This should force the use of temp files -sort -S 1k in > out || fail=1 -compare exp out || fail=1 - -# Create our own gzip program that will be used as the default -cat <<\EOF > gzip || fail=1 -#!/bin/sh -tr 41 14 -touch ok -EOF - -chmod +x gzip - -# Ensure 'sort' is immune to parent's SIGCHLD handler -# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. -( - # ash doesn't support "trap '' CHLD"; it knows only signal numbers. - sig=$("$abs_top_builddir/src/kill" -l CHLD 2>/dev/null) && trap '' $sig - - # This should force the use of child processes for "compression" - PATH=.:$PATH exec sort -S 1k --compress-program=gzip in > /dev/null -) || fail=1 - -# This will find our new gzip in PATH -PATH=.:$PATH sort -S 1k --compress-program=gzip in > out || fail=1 -compare exp out || fail=1 -test -f ok || fail=1 -rm -f ok - -# This is to make sure it works with no compression. -PATH=.:$PATH sort -S 1k in > out || fail=1 -compare exp out || fail=1 -test -f ok && fail=1 - -# This is to make sure we can use something other than gzip -mv gzip dzip || fail=1 -sort --compress-program=./dzip -S 1k in > out || fail=1 -compare exp out || fail=1 -test -f ok || fail=1 -rm -f ok - -# Make sure it can find other programs in PATH correctly -PATH=.:$PATH sort --compress-program=dzip -S 1k in > out || fail=1 -compare exp out || fail=1 -test -f ok || fail=1 -rm -f dzip ok - -Exit $fail diff --git a/tests/misc/sort-compress-hang b/tests/misc/sort-compress-hang deleted file mode 100755 index e1b8ff0f5..000000000 --- a/tests/misc/sort-compress-hang +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# Test for sort --compress hang - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort -very_expensive_ - -cat <<\EOF >compress || framework_failure_ -#!/bin/sh -tr 41 14 || exit -touch ok -EOF - -chmod +x compress - -seq -w 200000 > exp || fail=1 -tac exp > in || fail=1 - -# When the bug occurs, 'sort' hangs forever. When it doesn't occur, -# 'sort' could be running slowly on an overburdened machine. -# On a circa-2010 Linux server using NFS, a successful test completes -# in about 170 seconds, so specify 1700 seconds as a safety margin. -timeout 1700 sort --compress-program=./compress -S 1k in > out || fail=1 - -compare exp out || fail=1 -test -f ok || fail=1 -rm -f compress ok - -# If $TMPDIR is relative, give subprocesses time to react when 'sort' exits. -# Otherwise, under NFS, when 'sort' unlinks the temp files and they -# are renamed to .nfsXXXX instead of being removed, the parent cleanup -# of this directory will fail because the files are still open. -case $TMPDIR in -/*) ;; -*) sleep 1;; -esac - -Exit $fail diff --git a/tests/misc/sort-compress-hang.sh b/tests/misc/sort-compress-hang.sh new file mode 100755 index 000000000..e1b8ff0f5 --- /dev/null +++ b/tests/misc/sort-compress-hang.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Test for sort --compress hang + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort +very_expensive_ + +cat <<\EOF >compress || framework_failure_ +#!/bin/sh +tr 41 14 || exit +touch ok +EOF + +chmod +x compress + +seq -w 200000 > exp || fail=1 +tac exp > in || fail=1 + +# When the bug occurs, 'sort' hangs forever. When it doesn't occur, +# 'sort' could be running slowly on an overburdened machine. +# On a circa-2010 Linux server using NFS, a successful test completes +# in about 170 seconds, so specify 1700 seconds as a safety margin. +timeout 1700 sort --compress-program=./compress -S 1k in > out || fail=1 + +compare exp out || fail=1 +test -f ok || fail=1 +rm -f compress ok + +# If $TMPDIR is relative, give subprocesses time to react when 'sort' exits. +# Otherwise, under NFS, when 'sort' unlinks the temp files and they +# are renamed to .nfsXXXX instead of being removed, the parent cleanup +# of this directory will fail because the files are still open. +case $TMPDIR in +/*) ;; +*) sleep 1;; +esac + +Exit $fail diff --git a/tests/misc/sort-compress-proc b/tests/misc/sort-compress-proc deleted file mode 100755 index 7ee0fd1f5..000000000 --- a/tests/misc/sort-compress-proc +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -# Test use of compression subprocesses by sort - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort -expensive_ - -seq -w 2000 > exp || fail=1 -tac exp > in || fail=1 -insize=$(stat -c %s - compress || framework_failure_ -#!/bin/sh -eval "$PRE_COMPRESS" -tr 41 14 || exit -eval "$POST_COMPRESS" -EOF - -chmod +x compress - -# "Impatient exit" tests -# -# In these test cases, the biggest compressor (or decompressor) exits -# with nonzero status, after sleeping a bit. Until coreutils 8.7 -# 'sort' impatiently exited without waiting for its decompression -# subprocesses in these cases. Check compression too, while we're here. -# -for compress_arg in '' '-d' -do - POST_COMPRESS=' - test "X$1" != "X'$compress_arg'" || { - test "X$1" = "X" && exec <&1 - size=$(stat -c %s -) - exec >/dev/null 2>&1 <&1 || exit - expr $size "<" '"$insize"' / 2 || { sleep 1; exit 1; } - } - ' sort --compress-program=./compress -S 1k --batch-size=2 in > out && fail=1 -done - -# "Pre-exec child" test -# -# Ignore a random child process created before 'sort' was exec'ed. -# This bug was also present in coreutils 8.7. -# -( (sleep 1; exec false) & - PRE_COMPRESS='test -f ok || sleep 2' - POST_COMPRESS='touch ok' - exec sort --compress-program=./compress -S 1k in >out -) || fail=1 -compare exp out || fail=1 -test -f ok || fail=1 -rm -f ok - -rm -f compress - -# If $TMPDIR is relative, give subprocesses time to react when 'sort' exits. -# Otherwise, under NFS, when 'sort' unlinks the temp files and they -# are renamed to .nfsXXXX instead of being removed, the parent cleanup -# of this directory will fail because the files are still open. -case $TMPDIR in -/*) ;; -*) sleep 1;; -esac - -Exit $fail diff --git a/tests/misc/sort-compress-proc.sh b/tests/misc/sort-compress-proc.sh new file mode 100755 index 000000000..7ee0fd1f5 --- /dev/null +++ b/tests/misc/sort-compress-proc.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# Test use of compression subprocesses by sort + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort +expensive_ + +seq -w 2000 > exp || fail=1 +tac exp > in || fail=1 +insize=$(stat -c %s - compress || framework_failure_ +#!/bin/sh +eval "$PRE_COMPRESS" +tr 41 14 || exit +eval "$POST_COMPRESS" +EOF + +chmod +x compress + +# "Impatient exit" tests +# +# In these test cases, the biggest compressor (or decompressor) exits +# with nonzero status, after sleeping a bit. Until coreutils 8.7 +# 'sort' impatiently exited without waiting for its decompression +# subprocesses in these cases. Check compression too, while we're here. +# +for compress_arg in '' '-d' +do + POST_COMPRESS=' + test "X$1" != "X'$compress_arg'" || { + test "X$1" = "X" && exec <&1 + size=$(stat -c %s -) + exec >/dev/null 2>&1 <&1 || exit + expr $size "<" '"$insize"' / 2 || { sleep 1; exit 1; } + } + ' sort --compress-program=./compress -S 1k --batch-size=2 in > out && fail=1 +done + +# "Pre-exec child" test +# +# Ignore a random child process created before 'sort' was exec'ed. +# This bug was also present in coreutils 8.7. +# +( (sleep 1; exec false) & + PRE_COMPRESS='test -f ok || sleep 2' + POST_COMPRESS='touch ok' + exec sort --compress-program=./compress -S 1k in >out +) || fail=1 +compare exp out || fail=1 +test -f ok || fail=1 +rm -f ok + +rm -f compress + +# If $TMPDIR is relative, give subprocesses time to react when 'sort' exits. +# Otherwise, under NFS, when 'sort' unlinks the temp files and they +# are renamed to .nfsXXXX instead of being removed, the parent cleanup +# of this directory will fail because the files are still open. +case $TMPDIR in +/*) ;; +*) sleep 1;; +esac + +Exit $fail diff --git a/tests/misc/sort-compress.sh b/tests/misc/sort-compress.sh new file mode 100755 index 000000000..00dcf06ac --- /dev/null +++ b/tests/misc/sort-compress.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Test use of compression by sort + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +seq -w 2000 > exp || framework_failure_ +tac exp > in || framework_failure_ + +# This should force the use of temp files +sort -S 1k in > out || fail=1 +compare exp out || fail=1 + +# Create our own gzip program that will be used as the default +cat <<\EOF > gzip || fail=1 +#!/bin/sh +tr 41 14 +touch ok +EOF + +chmod +x gzip + +# Ensure 'sort' is immune to parent's SIGCHLD handler +# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. +( + # ash doesn't support "trap '' CHLD"; it knows only signal numbers. + sig=$("$abs_top_builddir/src/kill" -l CHLD 2>/dev/null) && trap '' $sig + + # This should force the use of child processes for "compression" + PATH=.:$PATH exec sort -S 1k --compress-program=gzip in > /dev/null +) || fail=1 + +# This will find our new gzip in PATH +PATH=.:$PATH sort -S 1k --compress-program=gzip in > out || fail=1 +compare exp out || fail=1 +test -f ok || fail=1 +rm -f ok + +# This is to make sure it works with no compression. +PATH=.:$PATH sort -S 1k in > out || fail=1 +compare exp out || fail=1 +test -f ok && fail=1 + +# This is to make sure we can use something other than gzip +mv gzip dzip || fail=1 +sort --compress-program=./dzip -S 1k in > out || fail=1 +compare exp out || fail=1 +test -f ok || fail=1 +rm -f ok + +# Make sure it can find other programs in PATH correctly +PATH=.:$PATH sort --compress-program=dzip -S 1k in > out || fail=1 +compare exp out || fail=1 +test -f ok || fail=1 +rm -f dzip ok + +Exit $fail diff --git a/tests/misc/sort-continue b/tests/misc/sort-continue deleted file mode 100755 index 1491dbf65..000000000 --- a/tests/misc/sort-continue +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# Tests for file descriptor exhaustion. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -# Skip the test when running under valgrind. -( ulimit -n 6; sort 3<&- 4<&- 5<&- < /dev/null ) \ - || skip_ 'fd-limited sort failed; are you running under valgrind?' - -for i in $(seq 31); do - echo $i | tee -a in > __test.$i || framework_failure_ -done - -# glob before ulimit to avoid issues on bash 3.2 on OS X 10.6.8 at least -test_files=$(echo __test.*) - -( - ulimit -n 6 - sort -n -m $test_files 3<&- 4<&- 5<&- < /dev/null > out -) && -compare in out || - { fail=1; echo 'file descriptor exhaustion not handled' 1>&2; } - -echo 32 | tee -a in > in1 -( - ulimit -n 6 - sort -n -m $test_files - 3<&- 4<&- 5<&- < in1 > out -) && -compare in out || { fail=1; echo 'stdin not handled properly' 1>&2; } - -Exit $fail diff --git a/tests/misc/sort-continue.sh b/tests/misc/sort-continue.sh new file mode 100755 index 000000000..1491dbf65 --- /dev/null +++ b/tests/misc/sort-continue.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Tests for file descriptor exhaustion. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +# Skip the test when running under valgrind. +( ulimit -n 6; sort 3<&- 4<&- 5<&- < /dev/null ) \ + || skip_ 'fd-limited sort failed; are you running under valgrind?' + +for i in $(seq 31); do + echo $i | tee -a in > __test.$i || framework_failure_ +done + +# glob before ulimit to avoid issues on bash 3.2 on OS X 10.6.8 at least +test_files=$(echo __test.*) + +( + ulimit -n 6 + sort -n -m $test_files 3<&- 4<&- 5<&- < /dev/null > out +) && +compare in out || + { fail=1; echo 'file descriptor exhaustion not handled' 1>&2; } + +echo 32 | tee -a in > in1 +( + ulimit -n 6 + sort -n -m $test_files - 3<&- 4<&- 5<&- < in1 > out +) && +compare in out || { fail=1; echo 'stdin not handled properly' 1>&2; } + +Exit $fail diff --git a/tests/misc/sort-debug-keys b/tests/misc/sort-debug-keys deleted file mode 100755 index a284e84c3..000000000 --- a/tests/misc/sort-debug-keys +++ /dev/null @@ -1,330 +0,0 @@ -#!/bin/sh -# Test annotation of sort keys - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -number() { cat -n | sed 's/^ *//'; } - -cat <<\EOF > exp -1 - ^ no match for key - -^ no match for key -44 - ^ no match for key -33 - ^ no match for key -2 - ^ no match for key -1 - ^ no match for key - -^ no match for key -44 - ^ no match for key -33 - ^ no match for key -2 - ^ no match for key - -^ no match for key -1 -_ -2 -_ -33 -__ -44 -__ -2> - ^ no match for key -3>1 - _ -1>2 - _ -1 - ^ no match for key - -^ no match for key -44 - ^ no match for key -33 - ^ no match for key -2 - ^ no match for key -1 - ^ no match for key - -^ no match for key -44 - ^ no match for key -33 - ^ no match for key -2 - ^ no match for key - -^ no match for key -1 -_ -2 -_ -33 -__ -44 -__ -2> - ^ no match for key -3>1 - _ -1>2 - _ -1 - ^ no match for key - -^ no match for key -44 - ^ no match for key -33 - ^ no match for key -2 - ^ no match for key -1 - ^ no match for key - -^ no match for key -44 - ^ no match for key -33 - ^ no match for key -2 - ^ no match for key - -^ no match for key -1 -_ -2 -_ -33 -__ -44 -__ -2> - ^ no match for key -3>1 - _ -1>2 - _ - -^ no match for key -JAN -___ -FEB -___ -FEB - ^ no match for key - -^ no match for key -JAN - ^ no match for key -JAZZ -^ no match for key - -^ no match for key -JAN -___ -FEB -___ -2>JAZZ - ^ no match for key -3> - ^ no match for key -4>JAN - ___ -1>FEB - ___ - -^ no match for key -JANZ -___ -JAN -___ -FEB -___ -3> - ^ no match for key -2>JANZ - ___ -4>JAN - ___ -1>FEB - ___ - 1.2ignore - ___ - 1.1e4ignore - _____ ->>a -___ ->b -__ -a - ^ no match for key - -^ no match for key -a -_ -b -_ --3 -__ --2 -__ --0 -__ ---Mi-1 -^ no match for key --0 -__ -1 -_ - 1 - _ -__ -1 -_ -_ - 1 - _ -1 -_ - 1 -__ -1 -_ -2,5 -_ -2.4 -___ -2.,,3 -__ -2.4 -___ -2,,3 -_ -2.4 -___ -1a -_ -2b -_ ->a - _ -A>chr10 - ^ no match for key -B>chr1 - ^ no match for key -EOF - -( -for type in n h g; do - printf '1\n\n44\n33\n2\n' | sort -s -k2$type --debug - printf '1\n\n44\n33\n2\n' | sort -s -k1.3$type --debug - printf '1\n\n44\n33\n2\n' | sort -s -k1$type --debug - printf '2\n\n1\n' | number | sort -s -k2g --debug -done - -printf 'FEB\n\nJAN\n' | sort -s -k1M --debug -printf 'FEB\n\nJAN\n' | sort -s -k2,2M --debug -printf 'FEB\nJAZZ\n\nJAN\n' | sort -s -k1M --debug -printf 'FEB\nJAZZ\n\nJAN\n' | number | sort -s -k2,2M --debug -printf 'FEB\nJANZ\n\nJAN\n' | sort -s -k1M --debug -printf 'FEB\nJANZ\n\nJAN\n' | number | sort -s -k2,2M --debug - -printf ' 1.2ignore\n 1.1e4ignore\n' | sort -s -g --debug - -printf '\tb\n\t\ta\n' | sort -s -d --debug # ignore = 1 - -printf 'a\n\n' | sort -s -k2,2 --debug #lena = 0 - -printf 'b\na\n' | sort -s -k1 --debug #otherwise key compare - -printf -- '-0\n1\n-2\n--Mi-1\n-3\n-0\n' | sort -s --debug -k1,1h - -printf ' 1\n1\n' | sort -b --debug -printf ' 1\n1\n' | sort -sb --debug -printf ' 1\n1\n' | sort --debug - -# strnumcmp is a bit weird, so we don't match exactly -printf '2,5\n2.4\n' | sort -s -k1n --debug -printf '2.,,3\n2.4\n' | sort -s -k1n --debug -printf '2,,3\n2.4\n' | sort -s -k1n --debug - -# -z means we convert \0 to \n -env printf '1a\x002b\x00' | sort -s -n -z --debug - -# Check that \0 and \t intermix. -printf '\0\ta\n' | sort -s -k2b,2 --debug | tr -d '\0' - -# Check that key end before key start is not underlined -printf 'A\tchr10\nB\tchr1\n' | sort -s -k2.4b,2.3n --debug -) > out - -compare exp out || fail=1 - -cat <<\EOF > exp - 1²---++3 1,234 Mi - _ - _________ -________________________ - 1²---++3 1,234 Mi - _____ - ________ -_______________________ -+1234 1234Gi 1,234M -^ no match for key -_____ -^ no match for key - ____ - ____ - _____ - _____ - _____ - ______ -___________________ -EOF - -unset LC_ALL -f=$LOCALE_FR_UTF8 - -: ${LOCALE_FR_UTF8=none} -if test "$LOCALE_FR_UTF8" != "none"; then - ( - echo ' 1²---++3 1,234 Mi' | - LC_ALL=C sort --debug -k2g -k1b,1 - echo ' 1²---++3 1,234 Mi' | - LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \ - sort --debug -k2g -k1b,1 - echo '+1234 1234Gi 1,234M' | - LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \ - sort --debug -k1,1n -k1,1g \ - -k1,1h -k2,2n -k2,2g -k2,2h -k3,3n -k3,3g -k3,3h - ) > out - compare exp out || fail=1 -fi - -Exit $fail diff --git a/tests/misc/sort-debug-keys.sh b/tests/misc/sort-debug-keys.sh new file mode 100755 index 000000000..a284e84c3 --- /dev/null +++ b/tests/misc/sort-debug-keys.sh @@ -0,0 +1,330 @@ +#!/bin/sh +# Test annotation of sort keys + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +number() { cat -n | sed 's/^ *//'; } + +cat <<\EOF > exp +1 + ^ no match for key + +^ no match for key +44 + ^ no match for key +33 + ^ no match for key +2 + ^ no match for key +1 + ^ no match for key + +^ no match for key +44 + ^ no match for key +33 + ^ no match for key +2 + ^ no match for key + +^ no match for key +1 +_ +2 +_ +33 +__ +44 +__ +2> + ^ no match for key +3>1 + _ +1>2 + _ +1 + ^ no match for key + +^ no match for key +44 + ^ no match for key +33 + ^ no match for key +2 + ^ no match for key +1 + ^ no match for key + +^ no match for key +44 + ^ no match for key +33 + ^ no match for key +2 + ^ no match for key + +^ no match for key +1 +_ +2 +_ +33 +__ +44 +__ +2> + ^ no match for key +3>1 + _ +1>2 + _ +1 + ^ no match for key + +^ no match for key +44 + ^ no match for key +33 + ^ no match for key +2 + ^ no match for key +1 + ^ no match for key + +^ no match for key +44 + ^ no match for key +33 + ^ no match for key +2 + ^ no match for key + +^ no match for key +1 +_ +2 +_ +33 +__ +44 +__ +2> + ^ no match for key +3>1 + _ +1>2 + _ + +^ no match for key +JAN +___ +FEB +___ +FEB + ^ no match for key + +^ no match for key +JAN + ^ no match for key +JAZZ +^ no match for key + +^ no match for key +JAN +___ +FEB +___ +2>JAZZ + ^ no match for key +3> + ^ no match for key +4>JAN + ___ +1>FEB + ___ + +^ no match for key +JANZ +___ +JAN +___ +FEB +___ +3> + ^ no match for key +2>JANZ + ___ +4>JAN + ___ +1>FEB + ___ + 1.2ignore + ___ + 1.1e4ignore + _____ +>>a +___ +>b +__ +a + ^ no match for key + +^ no match for key +a +_ +b +_ +-3 +__ +-2 +__ +-0 +__ +--Mi-1 +^ no match for key +-0 +__ +1 +_ + 1 + _ +__ +1 +_ +_ + 1 + _ +1 +_ + 1 +__ +1 +_ +2,5 +_ +2.4 +___ +2.,,3 +__ +2.4 +___ +2,,3 +_ +2.4 +___ +1a +_ +2b +_ +>a + _ +A>chr10 + ^ no match for key +B>chr1 + ^ no match for key +EOF + +( +for type in n h g; do + printf '1\n\n44\n33\n2\n' | sort -s -k2$type --debug + printf '1\n\n44\n33\n2\n' | sort -s -k1.3$type --debug + printf '1\n\n44\n33\n2\n' | sort -s -k1$type --debug + printf '2\n\n1\n' | number | sort -s -k2g --debug +done + +printf 'FEB\n\nJAN\n' | sort -s -k1M --debug +printf 'FEB\n\nJAN\n' | sort -s -k2,2M --debug +printf 'FEB\nJAZZ\n\nJAN\n' | sort -s -k1M --debug +printf 'FEB\nJAZZ\n\nJAN\n' | number | sort -s -k2,2M --debug +printf 'FEB\nJANZ\n\nJAN\n' | sort -s -k1M --debug +printf 'FEB\nJANZ\n\nJAN\n' | number | sort -s -k2,2M --debug + +printf ' 1.2ignore\n 1.1e4ignore\n' | sort -s -g --debug + +printf '\tb\n\t\ta\n' | sort -s -d --debug # ignore = 1 + +printf 'a\n\n' | sort -s -k2,2 --debug #lena = 0 + +printf 'b\na\n' | sort -s -k1 --debug #otherwise key compare + +printf -- '-0\n1\n-2\n--Mi-1\n-3\n-0\n' | sort -s --debug -k1,1h + +printf ' 1\n1\n' | sort -b --debug +printf ' 1\n1\n' | sort -sb --debug +printf ' 1\n1\n' | sort --debug + +# strnumcmp is a bit weird, so we don't match exactly +printf '2,5\n2.4\n' | sort -s -k1n --debug +printf '2.,,3\n2.4\n' | sort -s -k1n --debug +printf '2,,3\n2.4\n' | sort -s -k1n --debug + +# -z means we convert \0 to \n +env printf '1a\x002b\x00' | sort -s -n -z --debug + +# Check that \0 and \t intermix. +printf '\0\ta\n' | sort -s -k2b,2 --debug | tr -d '\0' + +# Check that key end before key start is not underlined +printf 'A\tchr10\nB\tchr1\n' | sort -s -k2.4b,2.3n --debug +) > out + +compare exp out || fail=1 + +cat <<\EOF > exp + 1²---++3 1,234 Mi + _ + _________ +________________________ + 1²---++3 1,234 Mi + _____ + ________ +_______________________ ++1234 1234Gi 1,234M +^ no match for key +_____ +^ no match for key + ____ + ____ + _____ + _____ + _____ + ______ +___________________ +EOF + +unset LC_ALL +f=$LOCALE_FR_UTF8 + +: ${LOCALE_FR_UTF8=none} +if test "$LOCALE_FR_UTF8" != "none"; then + ( + echo ' 1²---++3 1,234 Mi' | + LC_ALL=C sort --debug -k2g -k1b,1 + echo ' 1²---++3 1,234 Mi' | + LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \ + sort --debug -k2g -k1b,1 + echo '+1234 1234Gi 1,234M' | + LC_COLLATE=$f LC_CTYPE=$f LC_NUMERIC=$f LC_MESSAGES=C \ + sort --debug -k1,1n -k1,1g \ + -k1,1h -k2,2n -k2,2g -k2,2h -k3,3n -k3,3g -k3,3h + ) > out + compare exp out || fail=1 +fi + +Exit $fail diff --git a/tests/misc/sort-debug-warn b/tests/misc/sort-debug-warn deleted file mode 100755 index 504a2d2bc..000000000 --- a/tests/misc/sort-debug-warn +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -# Test warnings for sort options - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -cat <<\EOF > exp -sort: using simple byte comparison -sort: key 1 has zero width and will be ignored -sort: using simple byte comparison -sort: key 1 has zero width and will be ignored -sort: using simple byte comparison -sort: key 1 is numeric and spans multiple fields -sort: using simple byte comparison -sort: options '-bghMRrV' are ignored -sort: using simple byte comparison -sort: options '-bghMRV' are ignored -sort: option '-r' only applies to last-resort comparison -sort: using simple byte comparison -sort: option '-r' only applies to last-resort comparison -sort: using simple byte comparison -sort: options '-bg' are ignored -sort: using simple byte comparison -sort: using simple byte comparison -sort: option '-b' is ignored -sort: using simple byte comparison -sort: using simple byte comparison -sort: using simple byte comparison -sort: leading blanks are significant in key 1; consider also specifying 'b' -sort: using simple byte comparison -sort: leading blanks are significant in key 1; consider also specifying 'b' -sort: option '-d' is ignored -sort: using simple byte comparison -sort: leading blanks are significant in key 1; consider also specifying 'b' -sort: option '-i' is ignored -sort: using simple byte comparison -sort: using simple byte comparison -sort: using simple byte comparison -EOF - -sort -s -k2,1 --debug /dev/null 2>>out -sort -s -k2,1n --debug /dev/null 2>>out -sort -s -k1,2n --debug /dev/null 2>>out -sort -s -rRVMhgb -k1,1n --debug /dev/null 2>>out -sort -rRVMhgb -k1,1n --debug /dev/null 2>>out -sort -r -k1,1n --debug /dev/null 2>>out -sort -gbr -k1,1n -k1,1r --debug /dev/null 2>>out -sort -b -k1b,1bn --debug /dev/null 2>>out # no warning -sort -b -k1,1bn --debug /dev/null 2>>out -sort -b -k1,1bn -k2b,2 --debug /dev/null 2>>out # no warning -sort -r -k1,1r --debug /dev/null 2>>out # no warning for redundant options -sort -i -k1,1i --debug /dev/null 2>>out # no warning -sort -d -k1,1b --debug /dev/null 2>>out -sort -i -k1,1d --debug /dev/null 2>>out -sort -r --debug /dev/null 2>>out #no warning -sort -rM --debug /dev/null 2>>out #no warning -sort -rM -k1,1 --debug /dev/null 2>>out #no warning - -compare exp out || fail=1 - -cat <<\EOF > exp -sort: using simple byte comparison -sort: key 1 is numeric and spans multiple fields -sort: obsolescent key '+2 -1' used; consider '-k 3,1' instead -sort: key 2 has zero width and will be ignored -sort: leading blanks are significant in key 2; consider also specifying 'b' -sort: option '-b' is ignored -sort: option '-r' only applies to last-resort comparison -EOF - -sort --debug -rb -k2n +2.2 -1b /dev/null 2>out - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/sort-debug-warn.sh b/tests/misc/sort-debug-warn.sh new file mode 100755 index 000000000..504a2d2bc --- /dev/null +++ b/tests/misc/sort-debug-warn.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# Test warnings for sort options + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +cat <<\EOF > exp +sort: using simple byte comparison +sort: key 1 has zero width and will be ignored +sort: using simple byte comparison +sort: key 1 has zero width and will be ignored +sort: using simple byte comparison +sort: key 1 is numeric and spans multiple fields +sort: using simple byte comparison +sort: options '-bghMRrV' are ignored +sort: using simple byte comparison +sort: options '-bghMRV' are ignored +sort: option '-r' only applies to last-resort comparison +sort: using simple byte comparison +sort: option '-r' only applies to last-resort comparison +sort: using simple byte comparison +sort: options '-bg' are ignored +sort: using simple byte comparison +sort: using simple byte comparison +sort: option '-b' is ignored +sort: using simple byte comparison +sort: using simple byte comparison +sort: using simple byte comparison +sort: leading blanks are significant in key 1; consider also specifying 'b' +sort: using simple byte comparison +sort: leading blanks are significant in key 1; consider also specifying 'b' +sort: option '-d' is ignored +sort: using simple byte comparison +sort: leading blanks are significant in key 1; consider also specifying 'b' +sort: option '-i' is ignored +sort: using simple byte comparison +sort: using simple byte comparison +sort: using simple byte comparison +EOF + +sort -s -k2,1 --debug /dev/null 2>>out +sort -s -k2,1n --debug /dev/null 2>>out +sort -s -k1,2n --debug /dev/null 2>>out +sort -s -rRVMhgb -k1,1n --debug /dev/null 2>>out +sort -rRVMhgb -k1,1n --debug /dev/null 2>>out +sort -r -k1,1n --debug /dev/null 2>>out +sort -gbr -k1,1n -k1,1r --debug /dev/null 2>>out +sort -b -k1b,1bn --debug /dev/null 2>>out # no warning +sort -b -k1,1bn --debug /dev/null 2>>out +sort -b -k1,1bn -k2b,2 --debug /dev/null 2>>out # no warning +sort -r -k1,1r --debug /dev/null 2>>out # no warning for redundant options +sort -i -k1,1i --debug /dev/null 2>>out # no warning +sort -d -k1,1b --debug /dev/null 2>>out +sort -i -k1,1d --debug /dev/null 2>>out +sort -r --debug /dev/null 2>>out #no warning +sort -rM --debug /dev/null 2>>out #no warning +sort -rM -k1,1 --debug /dev/null 2>>out #no warning + +compare exp out || fail=1 + +cat <<\EOF > exp +sort: using simple byte comparison +sort: key 1 is numeric and spans multiple fields +sort: obsolescent key '+2 -1' used; consider '-k 3,1' instead +sort: key 2 has zero width and will be ignored +sort: leading blanks are significant in key 2; consider also specifying 'b' +sort: option '-b' is ignored +sort: option '-r' only applies to last-resort comparison +EOF + +sort --debug -rb -k2n +2.2 -1b /dev/null 2>out + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/sort-discrim b/tests/misc/sort-discrim deleted file mode 100755 index fced20495..000000000 --- a/tests/misc/sort-discrim +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -# Test discriminator-based sorting. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -# Set limit variables. -getlimits_ - -# These tests are designed for a 'sort' implementation that uses a -# discriminator, i.e., a brief summary of a key that may have lost info, -# but whose ordering is consistent with that of the original key. -# The tests are useful even if 'sort' does not use this representation. - -# Test lexicographic sorting. - -# A long-enough string so that it overruns a small discriminator buffer size. -long_prefix='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' -seq -f "$long_prefix%5.0f" 10000 > exp || fail=1 -sort -R exp | LC_ALL=C sort > out || fail=1 -compare exp out || fail=1 - - -# Test numeric sorting. - -# These tests are designed for an internal representation that ordinarily -# looks at the number plus two decimal digits, but if -h is -# used it looks at one decimal place plus a 4-bit SI prefix value. -# In both cases, there's an extra factor of 2 for the sign. -# Note INTMAX_MAX is used below as that's that largest number -# expr can handle on all systems (without GMP). -max_int100=$(expr $INTMAX_MAX / 100) && -max_frac100=$(printf '%.2d' $(expr $INTMAX_MAX % 100)) && -max_int160=$(expr $INTMAX_MAX / 160) && -max_frac160=$(expr $INTMAX_MAX / 16 % 10) && -{ printf -- "\ - -$UINTMAX_OFLOW - -$UINTMAX_MAX - -${max_int100}0.1 - -${max_int100}0 - -${max_int100}0.0 - -${max_int160}0.1 - -${max_int160}0 - -${max_int160}0.0 - -$max_int100.${max_frac100}1 - -$max_int100.$max_frac100 - -$max_int160.${max_frac160}1 - -$max_int160.$max_frac160 -" && - seq -- -10 .001 10 && - printf "\ - $max_int160 - $max_int160.$max_frac160 - $max_int160.${max_frac160}1 - $max_int100 - $max_int100.$max_frac100 - $max_int100.${max_frac100}1 - ${max_int160}0 - ${max_int160}0.0 - ${max_int160}0.1 - ${max_int100}0 - ${max_int100}0.0 - ${max_int100}0.1 - $UINTMAX_MAX - $UINTMAX_OFLOW -" -} > exp || fail=1 - -for opts in -n -h; do - sort -R exp | LC_ALL=C sort $opts > out || fail=1 - compare exp out || fail=1 -done - -Exit $fail diff --git a/tests/misc/sort-discrim.sh b/tests/misc/sort-discrim.sh new file mode 100755 index 000000000..fced20495 --- /dev/null +++ b/tests/misc/sort-discrim.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# Test discriminator-based sorting. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +# Set limit variables. +getlimits_ + +# These tests are designed for a 'sort' implementation that uses a +# discriminator, i.e., a brief summary of a key that may have lost info, +# but whose ordering is consistent with that of the original key. +# The tests are useful even if 'sort' does not use this representation. + +# Test lexicographic sorting. + +# A long-enough string so that it overruns a small discriminator buffer size. +long_prefix='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +seq -f "$long_prefix%5.0f" 10000 > exp || fail=1 +sort -R exp | LC_ALL=C sort > out || fail=1 +compare exp out || fail=1 + + +# Test numeric sorting. + +# These tests are designed for an internal representation that ordinarily +# looks at the number plus two decimal digits, but if -h is +# used it looks at one decimal place plus a 4-bit SI prefix value. +# In both cases, there's an extra factor of 2 for the sign. +# Note INTMAX_MAX is used below as that's that largest number +# expr can handle on all systems (without GMP). +max_int100=$(expr $INTMAX_MAX / 100) && +max_frac100=$(printf '%.2d' $(expr $INTMAX_MAX % 100)) && +max_int160=$(expr $INTMAX_MAX / 160) && +max_frac160=$(expr $INTMAX_MAX / 16 % 10) && +{ printf -- "\ + -$UINTMAX_OFLOW + -$UINTMAX_MAX + -${max_int100}0.1 + -${max_int100}0 + -${max_int100}0.0 + -${max_int160}0.1 + -${max_int160}0 + -${max_int160}0.0 + -$max_int100.${max_frac100}1 + -$max_int100.$max_frac100 + -$max_int160.${max_frac160}1 + -$max_int160.$max_frac160 +" && + seq -- -10 .001 10 && + printf "\ + $max_int160 + $max_int160.$max_frac160 + $max_int160.${max_frac160}1 + $max_int100 + $max_int100.$max_frac100 + $max_int100.${max_frac100}1 + ${max_int160}0 + ${max_int160}0.0 + ${max_int160}0.1 + ${max_int100}0 + ${max_int100}0.0 + ${max_int100}0.1 + $UINTMAX_MAX + $UINTMAX_OFLOW +" +} > exp || fail=1 + +for opts in -n -h; do + sort -R exp | LC_ALL=C sort $opts > out || fail=1 + compare exp out || fail=1 +done + +Exit $fail diff --git a/tests/misc/sort-exit-early b/tests/misc/sort-exit-early deleted file mode 100755 index 5ad6d41aa..000000000 --- a/tests/misc/sort-exit-early +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Test 'sort' exits early on inaccessible inputs or output - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort -skip_if_root_ - -# Check output is writable before starting to sort -touch input -chmod a-w input -timeout 10 sort -o input && fail=1 -test $? = 124 && fail=1 - -# Check all inputs are readable before starting to sort -# Also ensure the output isn't created in this case -touch output -chmod a-r output -timeout 10 sort -o typo - output && fail=1 -test $? = 124 && fail=1 -test -e typo && fail=1 - -Exit $fail diff --git a/tests/misc/sort-exit-early.sh b/tests/misc/sort-exit-early.sh new file mode 100755 index 000000000..5ad6d41aa --- /dev/null +++ b/tests/misc/sort-exit-early.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Test 'sort' exits early on inaccessible inputs or output + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort +skip_if_root_ + +# Check output is writable before starting to sort +touch input +chmod a-w input +timeout 10 sort -o input && fail=1 +test $? = 124 && fail=1 + +# Check all inputs are readable before starting to sort +# Also ensure the output isn't created in this case +touch output +chmod a-r output +timeout 10 sort -o typo - output && fail=1 +test $? = 124 && fail=1 +test -e typo && fail=1 + +Exit $fail diff --git a/tests/misc/sort-files0-from b/tests/misc/sort-files0-from deleted file mode 100755 index 6aa10acc1..000000000 --- a/tests/misc/sort-files0-from +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/perl -# Exercise sort's --files0-from option. -# FIXME: keep this file in sync with tests/du/files0-from. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -my $prog = 'sort'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - # invalid extra command line argument - ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>2}, - {ERR => "$prog: extra operand 'no-such'\n" - . "file operands cannot be combined with --files0-from\n" - . "Try '$prog --help' for more information.\n"} - ], - - # missing input file - ['missing', '--files0-from=missing', {EXIT=>2}, - {ERR => "$prog: cannot open 'missing' for reading: " - . "No such file or directory\n"}], - - # input file name of '-' - ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>2}, - {ERR => "$prog: when reading file names from stdin, no file name of" - . " '-' allowed\n"}], - - # empty input, regular file - ['empty', '--files0-from=@AUX@', {AUX=>''}, {EXIT=>2}, - {ERR_SUBST => 's/no input from.+$//'}, {ERR => "$prog: \n"}], - - # empty input, from non-regular file - ['empty-nonreg', '--files0-from=/dev/null', {EXIT=>2}, - {ERR => "$prog: no input from '/dev/null'\n"}], - - # one NUL - ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>2}, - {ERR => "$prog: -:1: invalid zero-length file name\n"}], - - # two NULs - # Note that the behavior here differs from 'wc' in that the - # first zero-length file name is treated as fatal, so there - # is only one line of diagnostic output. - ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>2}, - {ERR => "$prog: -:1: invalid zero-length file name\n"}], - - # one file name, no NUL - ['1', '--files0-from=-', '<', - {IN=>{f=>"g"}}, {AUX=>{g=>'a'}}, {OUT=>"a\n"} ], - - # one file name, with NUL - ['1a', '--files0-from=-', '<', - {IN=>{f=>"g\0"}}, {AUX=>{g=>'a'}}, {OUT=>"a\n"} ], - - # two file names, no final NUL - ['2', '--files0-from=-', '<', - {IN=>{f=>"g\0g"}}, {AUX=>{g=>'a'}}, {OUT=>"a\na\n"} ], - - # two file names, with final NUL - ['2a', '--files0-from=-', '<', - {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>'a'}}, {OUT=>"a\na\n"} ], - - # Ensure that $prog does nothing when there is a zero-length filename. - # Note that the behavior here differs from 'wc' in that the - # first zero-length file name is treated as fatal, so there - # should be no output on STDOUT. - ['zero-len', '--files0-from=-', '<', - {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, - {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>2} ], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sort-files0-from.pl b/tests/misc/sort-files0-from.pl new file mode 100755 index 000000000..6aa10acc1 --- /dev/null +++ b/tests/misc/sort-files0-from.pl @@ -0,0 +1,96 @@ +#!/usr/bin/perl +# Exercise sort's --files0-from option. +# FIXME: keep this file in sync with tests/du/files0-from. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +my $prog = 'sort'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + # invalid extra command line argument + ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>2}, + {ERR => "$prog: extra operand 'no-such'\n" + . "file operands cannot be combined with --files0-from\n" + . "Try '$prog --help' for more information.\n"} + ], + + # missing input file + ['missing', '--files0-from=missing', {EXIT=>2}, + {ERR => "$prog: cannot open 'missing' for reading: " + . "No such file or directory\n"}], + + # input file name of '-' + ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>2}, + {ERR => "$prog: when reading file names from stdin, no file name of" + . " '-' allowed\n"}], + + # empty input, regular file + ['empty', '--files0-from=@AUX@', {AUX=>''}, {EXIT=>2}, + {ERR_SUBST => 's/no input from.+$//'}, {ERR => "$prog: \n"}], + + # empty input, from non-regular file + ['empty-nonreg', '--files0-from=/dev/null', {EXIT=>2}, + {ERR => "$prog: no input from '/dev/null'\n"}], + + # one NUL + ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>2}, + {ERR => "$prog: -:1: invalid zero-length file name\n"}], + + # two NULs + # Note that the behavior here differs from 'wc' in that the + # first zero-length file name is treated as fatal, so there + # is only one line of diagnostic output. + ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>2}, + {ERR => "$prog: -:1: invalid zero-length file name\n"}], + + # one file name, no NUL + ['1', '--files0-from=-', '<', + {IN=>{f=>"g"}}, {AUX=>{g=>'a'}}, {OUT=>"a\n"} ], + + # one file name, with NUL + ['1a', '--files0-from=-', '<', + {IN=>{f=>"g\0"}}, {AUX=>{g=>'a'}}, {OUT=>"a\n"} ], + + # two file names, no final NUL + ['2', '--files0-from=-', '<', + {IN=>{f=>"g\0g"}}, {AUX=>{g=>'a'}}, {OUT=>"a\na\n"} ], + + # two file names, with final NUL + ['2a', '--files0-from=-', '<', + {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>'a'}}, {OUT=>"a\na\n"} ], + + # Ensure that $prog does nothing when there is a zero-length filename. + # Note that the behavior here differs from 'wc' in that the + # first zero-length file name is treated as fatal, so there + # should be no output on STDOUT. + ['zero-len', '--files0-from=-', '<', + {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, + {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>2} ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sort-float b/tests/misc/sort-float deleted file mode 100755 index b585b9bf1..000000000 --- a/tests/misc/sort-float +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# Ensure sort -g sorts floating point limits correctly - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -# Return 0 if LDBL_MIN is smaller than DBL_MIN, else 1. -# Dissect numbers like these, comparing first exponent, then -# whole part of mantissa, then fraction, until finding enough -# of a difference to determine the relative order of the numbers. -# These are "reversed": -# $ ./getlimits |grep DBL_MIN -# DBL_MIN=2.225074e-308 -# LDBL_MIN=2.004168e-292 -# -# These are in the expected order: -# $ ./getlimits|grep DBL_MIN -# DBL_MIN=2.225074e-308 -# LDBL_MIN=3.362103e-4932 - -dbl_minima_order() -{ - LC_ALL=C getlimits_ - set -- $(echo $LDBL_MIN | tr .e- ' ') - local ldbl_whole=$1 ldbl_frac=$2 ldbl_exp=$3 - - set -- $(echo $DBL_MIN |tr .e- ' ') - local dbl_whole=$1 dbl_frac=$2 dbl_exp=$3 - - test "$dbl_exp" -lt "$ldbl_exp" && return 0 - test "$ldbl_exp" -lt "$dbl_exp" && return 1 - test "$ldbl_whole" -lt "$dbl_whole" && return 0 - test "$dbl_whole" -lt "$ldbl_whole" && return 1 - test "$ldbl_frac" -le "$dbl_frac" && return 0 - return 1 -} - -# On some systems, DBL_MIN < LDBL_MIN. Detect that. -dbl_minima_order; reversed=$? - -for LOC in C $LOCALE_FR; do - - LC_ALL=$LOC getlimits_ - - # See if sort should be using long doubles - grep '^#define HAVE_C99_STRTOLD 1' $CONFIG_HEADER > /dev/null || - { LDBL_MAX="$DBL_MAX"; LDBL_MIN="$DBL_MIN"; } - - # If DBL_MIN happens to be smaller than LDBL_MIN, swap them, - # so that out expected output is sorted. - if test $reversed = 1; then - t=$LDBL_MIN - LDBL_MIN=$DBL_MIN - DBL_MIN=$t - fi - - printf -- "\ --$LDBL_MAX --$DBL_MAX --$FLT_MAX --$FLT_MIN --$DBL_MIN --$LDBL_MIN -0 -$LDBL_MIN -$DBL_MIN -$FLT_MIN -$FLT_MAX -$DBL_MAX -$LDBL_MAX -" | - grep '^[0-9.,e+-]*$' > exp # restrict to numeric just in case - - tac exp | LC_ALL=$LOC sort -sg > out || fail=1 - - compare exp out || fail=1 -done - -Exit $fail diff --git a/tests/misc/sort-float.sh b/tests/misc/sort-float.sh new file mode 100755 index 000000000..b585b9bf1 --- /dev/null +++ b/tests/misc/sort-float.sh @@ -0,0 +1,94 @@ +#!/bin/sh +# Ensure sort -g sorts floating point limits correctly + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +# Return 0 if LDBL_MIN is smaller than DBL_MIN, else 1. +# Dissect numbers like these, comparing first exponent, then +# whole part of mantissa, then fraction, until finding enough +# of a difference to determine the relative order of the numbers. +# These are "reversed": +# $ ./getlimits |grep DBL_MIN +# DBL_MIN=2.225074e-308 +# LDBL_MIN=2.004168e-292 +# +# These are in the expected order: +# $ ./getlimits|grep DBL_MIN +# DBL_MIN=2.225074e-308 +# LDBL_MIN=3.362103e-4932 + +dbl_minima_order() +{ + LC_ALL=C getlimits_ + set -- $(echo $LDBL_MIN | tr .e- ' ') + local ldbl_whole=$1 ldbl_frac=$2 ldbl_exp=$3 + + set -- $(echo $DBL_MIN |tr .e- ' ') + local dbl_whole=$1 dbl_frac=$2 dbl_exp=$3 + + test "$dbl_exp" -lt "$ldbl_exp" && return 0 + test "$ldbl_exp" -lt "$dbl_exp" && return 1 + test "$ldbl_whole" -lt "$dbl_whole" && return 0 + test "$dbl_whole" -lt "$ldbl_whole" && return 1 + test "$ldbl_frac" -le "$dbl_frac" && return 0 + return 1 +} + +# On some systems, DBL_MIN < LDBL_MIN. Detect that. +dbl_minima_order; reversed=$? + +for LOC in C $LOCALE_FR; do + + LC_ALL=$LOC getlimits_ + + # See if sort should be using long doubles + grep '^#define HAVE_C99_STRTOLD 1' $CONFIG_HEADER > /dev/null || + { LDBL_MAX="$DBL_MAX"; LDBL_MIN="$DBL_MIN"; } + + # If DBL_MIN happens to be smaller than LDBL_MIN, swap them, + # so that out expected output is sorted. + if test $reversed = 1; then + t=$LDBL_MIN + LDBL_MIN=$DBL_MIN + DBL_MIN=$t + fi + + printf -- "\ +-$LDBL_MAX +-$DBL_MAX +-$FLT_MAX +-$FLT_MIN +-$DBL_MIN +-$LDBL_MIN +0 +$LDBL_MIN +$DBL_MIN +$FLT_MIN +$FLT_MAX +$DBL_MAX +$LDBL_MAX +" | + grep '^[0-9.,e+-]*$' > exp # restrict to numeric just in case + + tac exp | LC_ALL=$LOC sort -sg > out || fail=1 + + compare exp out || fail=1 +done + +Exit $fail diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge deleted file mode 100755 index 7a56dc125..000000000 --- a/tests/misc/sort-merge +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/perl -# Test "sort -m". - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $limits = getlimits (); - -(my $program_name = $0) =~ s|.*/||; -my $prog = 'sort'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# three empty files and one that says 'foo' -my @inputs = (+(map{{IN=> {"empty$_"=> ''}}}1..3), {IN=> {foo=> "foo\n"}}); - -my $big_input = "aaa\n" x 1024; - -# don't need to check for existence, since we're running in a temp dir -my $badtmp = 'does/not/exist'; - -my $bigint = $limits->{UINTMAX_OFLOW}; - -my @Tests = - ( - ['m1', '-m', @inputs, {OUT=>"foo\n"}], - - # check validation of --batch-size option - ['nmerge-0', "-m --batch-size=0", @inputs, - {ERR=>"$prog: invalid --batch-size argument '0'\n". - "$prog: minimum --batch-size argument is '2'\n"}, {EXIT=>2}], - - ['nmerge-1', "-m --batch-size=1", @inputs, - {ERR=>"$prog: invalid --batch-size argument '1'\n". - "$prog: minimum --batch-size argument is '2'\n"}, {EXIT=>2}], - - ['nmerge-neg', "-m --batch-size=-1", @inputs, - {ERR=>"$prog: invalid --batch-size argument '-1'\n"}, {EXIT=>2}], - - ['nmerge-nan', "-m --batch-size=a", @inputs, - {ERR=>"$prog: invalid --batch-size argument 'a'\n"}, {EXIT=>2}], - - ['nmerge-big', "-m --batch-size=$bigint", @inputs, - {ERR_SUBST=>'s/(current rlimit is) \d+/$1/'}, - {ERR=>"$prog: --batch-size argument '$bigint' too large\n". - "$prog: maximum --batch-size argument with current rlimit is\n"}, - {EXIT=>2}], - - # This should work since nmerge >= the number of input files - ['nmerge-yes', "-m --batch-size=4 -T$badtmp", @inputs, {OUT=>"foo\n"}], - - # this should fail since nmerge < # of input files, so - # temp files are needed - ['nmerge-no', "-m --batch-size=2 -T$badtmp", @inputs, - {ERR_SUBST=>"s|': .*|':|"}, - {ERR=>"$prog: cannot create temporary file in '$badtmp':\n"}, - {EXIT=>2}], - - # This used to fail because setting batch-size without also setting - # buffer size would cause the buffer size to be set to the minimum. - ['batch-size', "--batch-size=16 -T$badtmp", {IN=> {big=> $big_input}}, - {OUT=>$big_input}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sort-merge-fdlimit b/tests/misc/sort-merge-fdlimit deleted file mode 100755 index 7ce109c1a..000000000 --- a/tests/misc/sort-merge-fdlimit +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# Test whether sort avoids opening more file descriptors than it is -# allowed when merging files. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort -require_ulimit_ - -mkdir in err || framework_failure_ - - -for i in $(seq 17); do - echo $i >in/$i -done -seq 17 >some-data - -# When these tests are run inside the automated testing framework, they -# have one less available file descriptor than when run outside the -# automated testing framework. If a test with a batch size of b fails -# inside the ATF, then the same test with batch size b+1 may pass outside -# the ATF but fail inside it. - -# The default batch size (nmerge) is 16. -(ulimit -n 19 \ - && sort -m --batch-size=16 in/* 2>err/merge-default-err \ - || ! grep "open failed" err/merge-default-err) || fail=1 - -# If sort opens a file to sort by random hashes of keys, -# it needs to consider this file against its limit on open file -# descriptors. Test once with the default random source -# and once with an explicit source. -for randsource in '' --random-source=some-data; do - (ulimit -n 20 \ - && sort -mR $randsource --batch-size=16 in/* 2>err/merge-random-err \ - || ! grep "open failed" err/merge-random-err) || fail=1 -done - -# 'sort -m' should work in a limited file descriptor -# environment when the output is repeatedly one of its inputs. -# In coreutils 8.7 and earlier, 'sort' would dump core on this test. -# -# This test uses 'exec' to redirect file descriptors rather than -# ordinary redirection on the 'sort' command. This is intended to -# work around bugs in OpenBSD /bin/sh, and some other sh variants, -# that squirrel away file descriptors before closing them; see -# . -# This test finds the bug only with shells that do not close FDs on -# exec, and will miss the bug (if present) on other shells, but it's -# not easy to fix this without running afoul of the OpenBSD-like sh bugs. -(seq 6 && echo 6) >exp || fail=1 -echo 6 >out || fail=1 -(exec 3<&- 4<&- 5<&- 6. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort +require_ulimit_ + +mkdir in err || framework_failure_ + + +for i in $(seq 17); do + echo $i >in/$i +done +seq 17 >some-data + +# When these tests are run inside the automated testing framework, they +# have one less available file descriptor than when run outside the +# automated testing framework. If a test with a batch size of b fails +# inside the ATF, then the same test with batch size b+1 may pass outside +# the ATF but fail inside it. + +# The default batch size (nmerge) is 16. +(ulimit -n 19 \ + && sort -m --batch-size=16 in/* 2>err/merge-default-err \ + || ! grep "open failed" err/merge-default-err) || fail=1 + +# If sort opens a file to sort by random hashes of keys, +# it needs to consider this file against its limit on open file +# descriptors. Test once with the default random source +# and once with an explicit source. +for randsource in '' --random-source=some-data; do + (ulimit -n 20 \ + && sort -mR $randsource --batch-size=16 in/* 2>err/merge-random-err \ + || ! grep "open failed" err/merge-random-err) || fail=1 +done + +# 'sort -m' should work in a limited file descriptor +# environment when the output is repeatedly one of its inputs. +# In coreutils 8.7 and earlier, 'sort' would dump core on this test. +# +# This test uses 'exec' to redirect file descriptors rather than +# ordinary redirection on the 'sort' command. This is intended to +# work around bugs in OpenBSD /bin/sh, and some other sh variants, +# that squirrel away file descriptors before closing them; see +# . +# This test finds the bug only with shells that do not close FDs on +# exec, and will miss the bug (if present) on other shells, but it's +# not easy to fix this without running afoul of the OpenBSD-like sh bugs. +(seq 6 && echo 6) >exp || fail=1 +echo 6 >out || fail=1 +(exec 3<&- 4<&- 5<&- 6. + +use strict; + +my $limits = getlimits (); + +(my $program_name = $0) =~ s|.*/||; +my $prog = 'sort'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# three empty files and one that says 'foo' +my @inputs = (+(map{{IN=> {"empty$_"=> ''}}}1..3), {IN=> {foo=> "foo\n"}}); + +my $big_input = "aaa\n" x 1024; + +# don't need to check for existence, since we're running in a temp dir +my $badtmp = 'does/not/exist'; + +my $bigint = $limits->{UINTMAX_OFLOW}; + +my @Tests = + ( + ['m1', '-m', @inputs, {OUT=>"foo\n"}], + + # check validation of --batch-size option + ['nmerge-0', "-m --batch-size=0", @inputs, + {ERR=>"$prog: invalid --batch-size argument '0'\n". + "$prog: minimum --batch-size argument is '2'\n"}, {EXIT=>2}], + + ['nmerge-1', "-m --batch-size=1", @inputs, + {ERR=>"$prog: invalid --batch-size argument '1'\n". + "$prog: minimum --batch-size argument is '2'\n"}, {EXIT=>2}], + + ['nmerge-neg', "-m --batch-size=-1", @inputs, + {ERR=>"$prog: invalid --batch-size argument '-1'\n"}, {EXIT=>2}], + + ['nmerge-nan', "-m --batch-size=a", @inputs, + {ERR=>"$prog: invalid --batch-size argument 'a'\n"}, {EXIT=>2}], + + ['nmerge-big', "-m --batch-size=$bigint", @inputs, + {ERR_SUBST=>'s/(current rlimit is) \d+/$1/'}, + {ERR=>"$prog: --batch-size argument '$bigint' too large\n". + "$prog: maximum --batch-size argument with current rlimit is\n"}, + {EXIT=>2}], + + # This should work since nmerge >= the number of input files + ['nmerge-yes', "-m --batch-size=4 -T$badtmp", @inputs, {OUT=>"foo\n"}], + + # this should fail since nmerge < # of input files, so + # temp files are needed + ['nmerge-no', "-m --batch-size=2 -T$badtmp", @inputs, + {ERR_SUBST=>"s|': .*|':|"}, + {ERR=>"$prog: cannot create temporary file in '$badtmp':\n"}, + {EXIT=>2}], + + # This used to fail because setting batch-size without also setting + # buffer size would cause the buffer size to be set to the minimum. + ['batch-size', "--batch-size=16 -T$badtmp", {IN=> {big=> $big_input}}, + {OUT=>$big_input}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/sort-month b/tests/misc/sort-month deleted file mode 100755 index fa1e69574..000000000 --- a/tests/misc/sort-month +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Test sorting of abbreviated months from the locale - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -locale --version >/dev/null 2>&1 || - skip_ 'The locale utility is not present' - -# C will be used if the locale is not present -for LOC in "$LOCALE_FR" "$LOCALE_FR_UTF8" "ja_JP.utf8"; do - mon="$(LC_ALL=$LOC locale abmon 2>/dev/null);" - smon=$(LC_ALL=$LOC locale abmon 2>/dev/null | - tr ';' '\n' | shuf | nl | LC_ALL=$LOC sort -k2,2M | - cut -f2 | tr '\n' ';') - test "$mon" = "$smon" || { fail=1; break; } -done - -Exit $fail diff --git a/tests/misc/sort-month.sh b/tests/misc/sort-month.sh new file mode 100755 index 000000000..fa1e69574 --- /dev/null +++ b/tests/misc/sort-month.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Test sorting of abbreviated months from the locale + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +locale --version >/dev/null 2>&1 || + skip_ 'The locale utility is not present' + +# C will be used if the locale is not present +for LOC in "$LOCALE_FR" "$LOCALE_FR_UTF8" "ja_JP.utf8"; do + mon="$(LC_ALL=$LOC locale abmon 2>/dev/null);" + smon=$(LC_ALL=$LOC locale abmon 2>/dev/null | + tr ';' '\n' | shuf | nl | LC_ALL=$LOC sort -k2,2M | + cut -f2 | tr '\n' ';') + test "$mon" = "$smon" || { fail=1; break; } +done + +Exit $fail diff --git a/tests/misc/sort-rand b/tests/misc/sort-rand deleted file mode 100755 index 1782a9acc..000000000 --- a/tests/misc/sort-rand +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Ensure that sort --sort-random doesn't sort. - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -seq 100 > in || framework_failure_ - - -sort --random-sort in > out || fail=1 - -# Fail if the input is the same as the output. -# This is a probabilistic test :-) -# However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) -compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } - -# Fail if the sorted output is not the same as the input. -sort -n out > out1 -compare in out1 || { fail=1; echo "not a permutation" 1>&2; } - -# If locale is available then use it to find a random non-C locale. -if (locale --version) > /dev/null 2>&1; then - locale=$(locale -a | sort --random-sort | $AWK '/^.._/{print;exit}') - LC_ALL=$locale sort --random-sort in > out1 || fail=1 - LC_ALL=$locale sort --random-sort in > out2 || fail=1 - - # Fail if the output "randomly" is the same twice in a row. - compare out1 out2 > /dev/null && - { fail=1; echo "not random with LC_ALL=$locale" 1>&2; } - - # Fail if the sorted output is not the same as the input. - sort -n out > out1 - compare in out1 || - { fail=1; echo "not a permutation with LC_ALL=$locale" 1>&2; } -fi - -Exit $fail diff --git a/tests/misc/sort-rand.sh b/tests/misc/sort-rand.sh new file mode 100755 index 000000000..1782a9acc --- /dev/null +++ b/tests/misc/sort-rand.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Ensure that sort --sort-random doesn't sort. + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +seq 100 > in || framework_failure_ + + +sort --random-sort in > out || fail=1 + +# Fail if the input is the same as the output. +# This is a probabilistic test :-) +# However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) +compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } + +# Fail if the sorted output is not the same as the input. +sort -n out > out1 +compare in out1 || { fail=1; echo "not a permutation" 1>&2; } + +# If locale is available then use it to find a random non-C locale. +if (locale --version) > /dev/null 2>&1; then + locale=$(locale -a | sort --random-sort | $AWK '/^.._/{print;exit}') + LC_ALL=$locale sort --random-sort in > out1 || fail=1 + LC_ALL=$locale sort --random-sort in > out2 || fail=1 + + # Fail if the output "randomly" is the same twice in a row. + compare out1 out2 > /dev/null && + { fail=1; echo "not random with LC_ALL=$locale" 1>&2; } + + # Fail if the sorted output is not the same as the input. + sort -n out > out1 + compare in out1 || + { fail=1; echo "not a permutation with LC_ALL=$locale" 1>&2; } +fi + +Exit $fail diff --git a/tests/misc/sort-spinlock-abuse b/tests/misc/sort-spinlock-abuse deleted file mode 100755 index 628326fd7..000000000 --- a/tests/misc/sort-spinlock-abuse +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# trigger a bug that would make parallel sort use 100% of one or more -# CPU while blocked on output. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -# This isn't terribly expensive, but it must not be run under heavy load. -# Since the "very expensive" tests are already run only with -j1, adding -# this test to the list ensures it still gets _some_ (albeit minimal) -# coverage while not causing false-positive failures in day to day runs. -very_expensive_ - -grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null || - skip_ 'requires pthreads' - -seq 100000 > in || framework_failure_ -mkfifo_or_skip_ fifo - -# Arrange for sort to require 8.0+ seconds of wall-clock time, -# while actually using far less than 1 second of CPU time. -(for i in $(seq 80); do read line; echo $i; sleep .1; done - cat > /dev/null) < fifo & - -# However, under heavy load, it can easily take more than -# one second of CPU time, so set a permissive limit: -ulimit -t 7 -sort --parallel=2 in > fifo || fail=1 - -Exit $fail diff --git a/tests/misc/sort-spinlock-abuse.sh b/tests/misc/sort-spinlock-abuse.sh new file mode 100755 index 000000000..628326fd7 --- /dev/null +++ b/tests/misc/sort-spinlock-abuse.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# trigger a bug that would make parallel sort use 100% of one or more +# CPU while blocked on output. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +# This isn't terribly expensive, but it must not be run under heavy load. +# Since the "very expensive" tests are already run only with -j1, adding +# this test to the list ensures it still gets _some_ (albeit minimal) +# coverage while not causing false-positive failures in day to day runs. +very_expensive_ + +grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null || + skip_ 'requires pthreads' + +seq 100000 > in || framework_failure_ +mkfifo_or_skip_ fifo + +# Arrange for sort to require 8.0+ seconds of wall-clock time, +# while actually using far less than 1 second of CPU time. +(for i in $(seq 80); do read line; echo $i; sleep .1; done + cat > /dev/null) < fifo & + +# However, under heavy load, it can easily take more than +# one second of CPU time, so set a permissive limit: +ulimit -t 7 +sort --parallel=2 in > fifo || fail=1 + +Exit $fail diff --git a/tests/misc/sort-stale-thread-mem b/tests/misc/sort-stale-thread-mem deleted file mode 100755 index 05cc9ba1c..000000000 --- a/tests/misc/sort-stale-thread-mem +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Trigger a bug that would cause 'sort' to reference stale thread stack memory. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# written by Jim Meyering and Paul Eggert - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -very_expensive_ -require_valgrind_ - -grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null || - skip_ 'requires pthreads' - -# gensort output seems to trigger the failure more often, -# so prefer gensort if it is available. -(gensort -a 10000 in) 2>/dev/null || - seq -f %-98f 10000 | shuf > in || - framework_failure_ - -# On Fedora-17-beta (valgrind-3.7.0-2.fc17.x86_64), this evokes two -# "Conditional jump or move depends on uninitialised value(s)" errors, -# each originating from _dl_start. -valgrind --quiet --error-exitcode=3 sort --version > /dev/null || - framework_failure_ 'valgrind fails for trivial sort invocation' - -# With the bug, 'sort' would fail under valgrind about half the time, -# on some circa-2010 multicore Linux platforms. Run the test 100 times -# so that the probability of missing the bug should be about 1 in -# 2**100 on these hosts. -for i in $(seq 100); do - valgrind --quiet --error-exitcode=3 \ - sort -S 100K --parallel=2 in > /dev/null || - { fail=$?; echo iteration $i failed; Exit $fail; } -done - -Exit $fail diff --git a/tests/misc/sort-stale-thread-mem.sh b/tests/misc/sort-stale-thread-mem.sh new file mode 100755 index 000000000..05cc9ba1c --- /dev/null +++ b/tests/misc/sort-stale-thread-mem.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Trigger a bug that would cause 'sort' to reference stale thread stack memory. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# written by Jim Meyering and Paul Eggert + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +very_expensive_ +require_valgrind_ + +grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null || + skip_ 'requires pthreads' + +# gensort output seems to trigger the failure more often, +# so prefer gensort if it is available. +(gensort -a 10000 in) 2>/dev/null || + seq -f %-98f 10000 | shuf > in || + framework_failure_ + +# On Fedora-17-beta (valgrind-3.7.0-2.fc17.x86_64), this evokes two +# "Conditional jump or move depends on uninitialised value(s)" errors, +# each originating from _dl_start. +valgrind --quiet --error-exitcode=3 sort --version > /dev/null || + framework_failure_ 'valgrind fails for trivial sort invocation' + +# With the bug, 'sort' would fail under valgrind about half the time, +# on some circa-2010 multicore Linux platforms. Run the test 100 times +# so that the probability of missing the bug should be about 1 in +# 2**100 on these hosts. +for i in $(seq 100); do + valgrind --quiet --error-exitcode=3 \ + sort -S 100K --parallel=2 in > /dev/null || + { fail=$?; echo iteration $i failed; Exit $fail; } +done + +Exit $fail diff --git a/tests/misc/sort-u-FMR b/tests/misc/sort-u-FMR deleted file mode 100755 index 303b4291c..000000000 --- a/tests/misc/sort-u-FMR +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Before 8.19, this would trigger a free-memory read. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort -require_valgrind_ - -{ echo 0; printf '%0900d\n' 1; } > in || framework_failure_ - -valgrind --error-exitcode=1 sort --p=1 -S32b -u in > out || fail=1 - -compare in out || fail=1 - -Exit $fail diff --git a/tests/misc/sort-u-FMR.sh b/tests/misc/sort-u-FMR.sh new file mode 100755 index 000000000..303b4291c --- /dev/null +++ b/tests/misc/sort-u-FMR.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Before 8.19, this would trigger a free-memory read. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort +require_valgrind_ + +{ echo 0; printf '%0900d\n' 1; } > in || framework_failure_ + +valgrind --error-exitcode=1 sort --p=1 -S32b -u in > out || fail=1 + +compare in out || fail=1 + +Exit $fail diff --git a/tests/misc/sort-unique b/tests/misc/sort-unique deleted file mode 100755 index 275cbeb02..000000000 --- a/tests/misc/sort-unique +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# Test 'sort -u'. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -cat > in <<\EOF -1 -2 -1 -3 -EOF - -cat > exp <<\EOF -1 -2 -3 -EOF - -for LOC in C "$LOCALE_FR" "$LOCALE_FR_UTF8"; do - test -z "$LOC" && continue - - LC_ALL=$LOC sort -u in > out || { fail=1; break; } - compare exp out || { fail=1; break; } -done - -Exit $fail diff --git a/tests/misc/sort-unique-segv b/tests/misc/sort-unique-segv deleted file mode 100755 index b853cfe43..000000000 --- a/tests/misc/sort-unique-segv +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# parallel sort with --unique (-u) would segfault - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null || - skip_ 'requires pthreads' - -cat <<\EOF > in || framework_failure_ - - - - - - - -z -zzzzzz -zzzzzzz -zzzzzzz -zzzzzzz -zzzzzzzzz -zzzzzzzzzzz -zzzzzzzzzzzz -EOF - -sort --parallel=1 -u in > exp || fail=1 - -sort --parallel=2 -u -S 10b < in > out || fail=1 -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/sort-unique-segv.sh b/tests/misc/sort-unique-segv.sh new file mode 100755 index 000000000..b853cfe43 --- /dev/null +++ b/tests/misc/sort-unique-segv.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# parallel sort with --unique (-u) would segfault + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null || + skip_ 'requires pthreads' + +cat <<\EOF > in || framework_failure_ + + + + + + + +z +zzzzzz +zzzzzzz +zzzzzzz +zzzzzzz +zzzzzzzzz +zzzzzzzzzzz +zzzzzzzzzzzz +EOF + +sort --parallel=1 -u in > exp || fail=1 + +sort --parallel=2 -u -S 10b < in > out || fail=1 +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/sort-unique.sh b/tests/misc/sort-unique.sh new file mode 100755 index 000000000..275cbeb02 --- /dev/null +++ b/tests/misc/sort-unique.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Test 'sort -u'. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +cat > in <<\EOF +1 +2 +1 +3 +EOF + +cat > exp <<\EOF +1 +2 +3 +EOF + +for LOC in C "$LOCALE_FR" "$LOCALE_FR_UTF8"; do + test -z "$LOC" && continue + + LC_ALL=$LOC sort -u in > out || { fail=1; break; } + compare exp out || { fail=1; break; } +done + +Exit $fail diff --git a/tests/misc/sort-version b/tests/misc/sort-version deleted file mode 100755 index cb9acab71..000000000 --- a/tests/misc/sort-version +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh -# exercise sort's --sort=version option - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sort - -cat > in << _EOF_ -gcc-c++-10.fc9.tar.gz -gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 -glibc-2-0.1.beta1.fc10.rpm -glibc-common-5-0.2.beta2.fc9.ebuild -glibc-common-5-0.2b.deb -glibc-common-11b.ebuild -glibc-common-11-0.6rc2.ebuild -libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz -libstdc++-4a.fc8.tar.gz -libstdc++-4.10.4.20040204svn.rpm -libstdc++-devel-3.fc8.ebuild -libstdc++-devel-3a.fc9.tar.gz -libstdc++-devel-8.fc8.deb -libstdc++-devel-8.6.2-0.4b.fc8 -nss_ldap-1-0.2b.fc9.tar.bz2 -nss_ldap-1-0.6rc2.fc8.tar.gz -nss_ldap-1.0-0.1a.tar.gz -nss_ldap-10beta1.fc8.tar.gz -nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild -string start 5.0.0 end of str -string start 5.1.0 end of str -string start 5.10.0 end of str -string start 5.2.0 end of str -string start 5.20.0 end of str -string start 5.3.0 end of str -string start 5.30.0 end of str -string start 5.4.0 end of str -string start 5.40.0 end of str -string start 5.5.0 end of str -string start 5.50.0 end of str -string start 5.6.0 end of str -string start 5.60.0 end of str -string start 5.7.0 end of str -string start 5.70.0 end of str -string start 5.8.0 end of str -string start 5.80.0 end of str -string start 5.9.0 end of str -string start 5.90.0 end of str -_EOF_ - -cat > exp << _EOF_ -gcc-c++-10.fc9.tar.gz -gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 -glibc-2-0.1.beta1.fc10.rpm -glibc-common-5-0.2.beta2.fc9.ebuild -glibc-common-5-0.2b.deb -glibc-common-11b.ebuild -glibc-common-11-0.6rc2.ebuild -libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz -libstdc++-4a.fc8.tar.gz -libstdc++-4.10.4.20040204svn.rpm -libstdc++-devel-3.fc8.ebuild -libstdc++-devel-3a.fc9.tar.gz -libstdc++-devel-8.fc8.deb -libstdc++-devel-8.6.2-0.4b.fc8 -nss_ldap-1-0.2b.fc9.tar.bz2 -nss_ldap-1-0.6rc2.fc8.tar.gz -nss_ldap-1.0-0.1a.tar.gz -nss_ldap-10beta1.fc8.tar.gz -nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild -string start 5.0.0 end of str -string start 5.1.0 end of str -string start 5.2.0 end of str -string start 5.3.0 end of str -string start 5.4.0 end of str -string start 5.5.0 end of str -string start 5.6.0 end of str -string start 5.7.0 end of str -string start 5.8.0 end of str -string start 5.9.0 end of str -string start 5.10.0 end of str -string start 5.20.0 end of str -string start 5.30.0 end of str -string start 5.40.0 end of str -string start 5.50.0 end of str -string start 5.60.0 end of str -string start 5.70.0 end of str -string start 5.80.0 end of str -string start 5.90.0 end of str -_EOF_ - -sort --sort=version -o out in || fail=1 -compare exp out || fail=1 -Exit $fail diff --git a/tests/misc/sort-version.sh b/tests/misc/sort-version.sh new file mode 100755 index 000000000..cb9acab71 --- /dev/null +++ b/tests/misc/sort-version.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# exercise sort's --sort=version option + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sort + +cat > in << _EOF_ +gcc-c++-10.fc9.tar.gz +gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 +glibc-2-0.1.beta1.fc10.rpm +glibc-common-5-0.2.beta2.fc9.ebuild +glibc-common-5-0.2b.deb +glibc-common-11b.ebuild +glibc-common-11-0.6rc2.ebuild +libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz +libstdc++-4a.fc8.tar.gz +libstdc++-4.10.4.20040204svn.rpm +libstdc++-devel-3.fc8.ebuild +libstdc++-devel-3a.fc9.tar.gz +libstdc++-devel-8.fc8.deb +libstdc++-devel-8.6.2-0.4b.fc8 +nss_ldap-1-0.2b.fc9.tar.bz2 +nss_ldap-1-0.6rc2.fc8.tar.gz +nss_ldap-1.0-0.1a.tar.gz +nss_ldap-10beta1.fc8.tar.gz +nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild +string start 5.0.0 end of str +string start 5.1.0 end of str +string start 5.10.0 end of str +string start 5.2.0 end of str +string start 5.20.0 end of str +string start 5.3.0 end of str +string start 5.30.0 end of str +string start 5.4.0 end of str +string start 5.40.0 end of str +string start 5.5.0 end of str +string start 5.50.0 end of str +string start 5.6.0 end of str +string start 5.60.0 end of str +string start 5.7.0 end of str +string start 5.70.0 end of str +string start 5.8.0 end of str +string start 5.80.0 end of str +string start 5.9.0 end of str +string start 5.90.0 end of str +_EOF_ + +cat > exp << _EOF_ +gcc-c++-10.fc9.tar.gz +gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2 +glibc-2-0.1.beta1.fc10.rpm +glibc-common-5-0.2.beta2.fc9.ebuild +glibc-common-5-0.2b.deb +glibc-common-11b.ebuild +glibc-common-11-0.6rc2.ebuild +libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz +libstdc++-4a.fc8.tar.gz +libstdc++-4.10.4.20040204svn.rpm +libstdc++-devel-3.fc8.ebuild +libstdc++-devel-3a.fc9.tar.gz +libstdc++-devel-8.fc8.deb +libstdc++-devel-8.6.2-0.4b.fc8 +nss_ldap-1-0.2b.fc9.tar.bz2 +nss_ldap-1-0.6rc2.fc8.tar.gz +nss_ldap-1.0-0.1a.tar.gz +nss_ldap-10beta1.fc8.tar.gz +nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild +string start 5.0.0 end of str +string start 5.1.0 end of str +string start 5.2.0 end of str +string start 5.3.0 end of str +string start 5.4.0 end of str +string start 5.5.0 end of str +string start 5.6.0 end of str +string start 5.7.0 end of str +string start 5.8.0 end of str +string start 5.9.0 end of str +string start 5.10.0 end of str +string start 5.20.0 end of str +string start 5.30.0 end of str +string start 5.40.0 end of str +string start 5.50.0 end of str +string start 5.60.0 end of str +string start 5.70.0 end of str +string start 5.80.0 end of str +string start 5.90.0 end of str +_EOF_ + +sort --sort=version -o out in || fail=1 +compare exp out || fail=1 +Exit $fail diff --git a/tests/misc/sort.pl b/tests/misc/sort.pl new file mode 100755 index 000000000..10d1e5fbd --- /dev/null +++ b/tests/misc/sort.pl @@ -0,0 +1,432 @@ +#!/usr/bin/perl + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $limits = getlimits (); + +my $prog = 'sort'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $mb_locale = $ENV{LOCALE_FR_UTF8}; +! defined $mb_locale || $mb_locale eq 'none' + and $mb_locale = 'C'; + +# Since each test is run with a file name and with redirected stdin, +# the name in the diagnostic is either the file name or "-". +# Normalize each diagnostic to use '-'. +my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'}; + +my $no_file = "$prog: cannot read: no-file: No such file or directory\n"; + +my @Tests = +( +["n1", '-n', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}], +["n2", '-n', {IN=>".02\n.01\n"}, {OUT=>".01\n.02\n"}], +["n3", '-n', {IN=>".02\n.00\n"}, {OUT=>".00\n.02\n"}], +["n4", '-n', {IN=>".02\n.000\n"}, {OUT=>".000\n.02\n"}], +["n5", '-n', {IN=>".021\n.029\n"}, {OUT=>".021\n.029\n"}], + +["n6", '-n', {IN=>".02\n.0*\n"}, {OUT=>".0*\n.02\n"}], +["n7", '-n', {IN=>".02\n.*\n"}, {OUT=>".*\n.02\n"}], +["n8a", '-s -n -k1,1', {IN=>".0a\n.0b\n"}, {OUT=>".0a\n.0b\n"}], +["n8b", '-s -n -k1,1', {IN=>".0b\n.0a\n"}, {OUT=>".0b\n.0a\n"}], +["n9a", '-s -n -k1,1', {IN=>".000a\n.000b\n"}, {OUT=>".000a\n.000b\n"}], +["n9b", '-s -n -k1,1', {IN=>".000b\n.000a\n"}, {OUT=>".000b\n.000a\n"}], +["n10a", '-s -n -k1,1', {IN=>".00a\n.000b\n"}, {OUT=>".00a\n.000b\n"}], +["n10b", '-s -n -k1,1', {IN=>".00b\n.000a\n"}, {OUT=>".00b\n.000a\n"}], +["n11a", '-s -n -k1,1', {IN=>".01a\n.010\n"}, {OUT=>".01a\n.010\n"}], +["n11b", '-s -n -k1,1', {IN=>".010\n.01a\n"}, {OUT=>".010\n.01a\n"}], + +# human readable suffixes +["h1", '-h', + {IN=>"1Y\n1Z\n1E\n1P\n1T\n1G\n1M\n1K\n02\n1\nY\n-1k\n-1M\n-1G\n-1T\n" + . "-1P\n-1E\n-1Z\n-1Y\n"}, + {OUT=>"-1Y\n-1Z\n-1E\n-1P\n-1T\n-1G\n-1M\n-1k\nY\n1\n02\n1K\n1M\n1G\n1T\n" + . "1P\n1E\n1Z\n1Y\n"}], +["h2", '-h', {IN=>"1M\n-2G\n-3K"}, {OUT=>"-2G\n-3K\n1M\n"}], +# check that it works with powers of 1024 +["h3", '-k 2,2h -k 1,1', {IN=>"a 1G\nb 1023M\n"}, {OUT=>"b 1023M\na 1G\n"}], +# decimal at end => allowed +["h4", '-h', {IN=>"1.E\n2.M\n"}, {OUT=>"2.M\n1.E\n"}], +# double decimal => ignore suffix +["h5", '-h', {IN=>"1..2E\n2..2M\n"}, {OUT=>"1..2E\n2..2M\n"}], +# "M" sorts before "G" regardless of the positive number attached. +["h6", '-h', {IN=>"1GiB\n1030MiB\n"}, {OUT=>"1030MiB\n1GiB\n"}], +# check option incompatibility +["h7", '-hn', {IN=>""}, {OUT=>""}, {EXIT=>2}, + {ERR=>"$prog: options '-hn' are incompatible\n"}], +# check key processing +["h8", '-n -k2,2h', {IN=>"1 1E\n2 2M\n"}, {OUT=>"2 2M\n1 1E\n"}], +# SI and IEC prefixes on separate keys allowed +["h9", '-h -k1,1 -k2,2', {IN=>"1M 1Mi\n1M 1Mi\n"}, {OUT=>"1M 1Mi\n1M 1Mi\n"}], +# This invalid SI and IEC prefix mixture is not significant so not noticed +["h10", '-h -k1,1 -k2,2', {IN=>"1M 2M\n2M 1Mi\n"}, {OUT=>"1M 2M\n2M 1Mi\n"}], + +["01a", '', {IN=>"A\nB\nC\n"}, {OUT=>"A\nB\nC\n"}], +# +["02a", '-c', {IN=>"A\nB\nC\n"}, {OUT=>''}], +["02b", '-c', {IN=>"A\nC\nB\n"}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: -:3: disorder: B\n"}, $normalize_filename], +["02c", '-c -k1,1', {IN=>"a\na b\n"}, {OUT=>''}], +["02d", '-C', {IN=>"A\nB\nC\n"}, {OUT=>''}], +["02e", '-C', {IN=>"A\nC\nB\n"}, {OUT=>''}, {EXIT=>1}], +# This should fail because there are duplicate keys +["02m", '-cu', {IN=>"A\nA\n"}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: -:2: disorder: A\n"}, $normalize_filename], +["02n", '-cu', {IN=>"A\nB\n"}, {OUT=>''}], +["02o", '-cu', {IN=>"A\nB\nB\n"}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: -:3: disorder: B\n"}, $normalize_filename], +["02p", '-cu', {IN=>"B\nA\nB\n"}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: -:2: disorder: A\n"}, $normalize_filename], +["02q", '-c -k 1,1fR', {IN=>"ABC\nABc\nAbC\nAbc\naBC\naBc\nabC\nabc\n"}], +["02r", '-c -k 1,1fV', {IN=>"ABC\nABc\nAbC\nAbc\naBC\naBc\nabC\nabc\n"}], +["02s", '-c -k 1,1dfR', + {IN=>".ABC\n.ABc.\nA.bC\nA.bc.\naB.C\naB.c.\nabC.\nabc..\n"}], +# +["03a", '-k1', {IN=>"B\nA\n"}, {OUT=>"A\nB\n"}], +["03b", '-k1,1', {IN=>"B\nA\n"}, {OUT=>"A\nB\n"}], +["03c", '-k1 -k2', {IN=>"A b\nA a\n"}, {OUT=>"A a\nA b\n"}], +# Fail with a diagnostic when -k specifies field == 0. +["03d", '-k0', {EXIT=>2}, + {ERR=>"$prog: -: invalid field specification '0'\n"}, + $normalize_filename], +# Fail with a diagnostic when -k specifies character == 0. +["03e", '-k1.0', {EXIT=>2}, + {ERR=>"$prog: character offset is zero: invalid field specification '1.0'\n"}], +["03f", '-k1.1,-k0', {EXIT=>2}, + {ERR=>"$prog: invalid number after ',': invalid count at start of '-k0'\n"}], +# This is ok. +["03g", '-k1.1,1.0', {IN=>''}], +# This is equivalent to 3f. +["03h", '-k1.1,1', {IN=>''}], +# This too, is equivalent to 3f. +["03i", '-k1,1', {IN=>''}], +# +["04a", '-nc', {IN=>"2\n11\n"}], +["04b", '-n', {IN=>"11\n2\n"}, {OUT=>"2\n11\n"}], +["04c", '-k1n', {IN=>"11\n2\n"}, {OUT=>"2\n11\n"}], +["04d", '-k1', {IN=>"11\n2\n"}, {OUT=>"11\n2\n"}], +["04e", '-k2', {IN=>"ignored B\nz-ig A\n"}, {OUT=>"z-ig A\nignored B\n"}], +# +["05a", '-k1,2', {IN=>"A B\nA A\n"}, {OUT=>"A A\nA B\n"}], +["05b", '-k1,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +["05c", '-k1 -k2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +["05d", '-k2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +["05e", '-k2,2', {IN=>"A B Z\nA A A\n"}, {OUT=>"A A A\nA B Z\n"}], +["05f", '-k2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +# +["06a", '-k 1,2', {IN=>"A B\nA A\n"}, {OUT=>"A A\nA B\n"}], +["06b", '-k 1,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +["06c", '-k 1 -k 2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +["06d", '-k 2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +["06e", '-k 2,2', {IN=>"A B Z\nA A A\n"}, {OUT=>"A A A\nA B Z\n"}], +["06f", '-k 2,2', {IN=>"A B A\nA A Z\n"}, {OUT=>"A A Z\nA B A\n"}], +# +["07a", '-k 2,3', {IN=>"9 a b\n7 a a\n"}, {OUT=>"7 a a\n9 a b\n"}], +["07b", '-k 2,3', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}], +["07c", '-k 2,3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}], +["07d", '+1 -3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}], +# ensure a character position of 0 includes whole field +["07e", '-k 2,3.0', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}], +# ensure fields with end position before start are ignored +["07f", '-n -k1.3,1.1', {IN=>"a 2\nb 1\n"}, {OUT=>"a 2\nb 1\n"}], +["07g", '-n -k2.2,1.2', {IN=>"aa 2\nbb 1\n"}, {OUT=>"aa 2\nbb 1\n"}], +["07h", '-k1.3nb,1.3', {IN=>" a 2\n b 1\n"}, {OUT=>" a 2\n b 1\n"}], +# ensure obsolescent key limits are handled correctly +["07i", '-s +0 -1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}], +["07j", '-s +0 -1.0', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}], +["07k", '-s +0 -1.1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}], +["07l", '-s +0 -1.2', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}], +["07m", '-s +0 -1.1b', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}], +# +# report an error for '.' without following char spec +["08a", '-k 2.,3', {EXIT=>2}, + {ERR=>"$prog: invalid number after '.': invalid count at start of ',3'\n"}], +# report an error for ',' without following POS2 +["08b", '-k 2,', {EXIT=>2}, + {ERR=>"$prog: invalid number after ',': invalid count at start of ''\n"}], +# +# Test new -g option. +["09a", '-g', {IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}], +# Make sure -n works how we expect. +["09b", '-n', {IN=>"1e2\n2e1\n"}, {OUT=>"1e2\n2e1\n"}], +["09c", '-n', {IN=>"2e1\n1e2\n"}, {OUT=>"1e2\n2e1\n"}], +["09d", '-k2g', {IN=>"a 1e2\nb 2e1\n"}, {OUT=>"b 2e1\na 1e2\n"}], +# +# Bug reported by Roger Peel +["10a", '-t : -k 2.2,2.2', {IN=>":ba\n:ab\n"}, {OUT=>":ba\n:ab\n"}], +# Equivalent to above, but using obsolescent '+pos -pos' option syntax. +["10b", '-t : +1.1 -1.2', {IN=>":ba\n:ab\n"}, {OUT=>":ba\n:ab\n"}], +# +# The same as the preceding two, but with input lines reversed. +["10c", '-t : -k 2.2,2.2', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}], +# Equivalent to above, but using obsolescent '+pos -pos' option syntax. +["10d", '-t : +1.1 -1.2', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}], +# Try without -t... +# But note that we have to count the delimiting space at the beginning +# of each field that has it. +["10a0", '-k 2.3,2.3', {IN=>"z ba\nz ab\n"}, {OUT=>"z ba\nz ab\n"}], +["10a1", '-k 1.2,1.2', {IN=>"ba\nab\n"}, {OUT=>"ba\nab\n"}], +["10a2", '-b -k 2.2,2.2', {IN=>"z ba\nz ab\n"}, {OUT=>"z ba\nz ab\n"}], +# +# An even simpler example demonstrating the bug. +["10e", '-k 1.2,1.2', {IN=>"ab\nba\n"}, {OUT=>"ba\nab\n"}], +# +# The way sort works on these inputs (10f and 10g) seems wrong to me. +# See http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=3c467c0d223 +# POSIX doesn't seem to say one way or the other, but that's the way all +# other sort implementations work. +["10f", '-t : -k 1.3,1.3', {IN=>":ab\n:ba\n"}, {OUT=>":ba\n:ab\n"}], +["10g", '-k 1.4,1.4', {IN=>"a ab\nb ba\n"}, {OUT=>"b ba\na ab\n"}], +# +# Exercise bug re using -b to skip trailing blanks. +["11a", '-t: -k1,1b -k2,2', {IN=>"a\t:a\na :b\n"}, {OUT=>"a\t:a\na :b\n"}], +["11b", '-t: -k1,1b -k2,2', {IN=>"a :b\na\t:a\n"}, {OUT=>"a\t:a\na :b\n"}], +["11c", '-t: -k2,2b -k3,3', {IN=>"z:a\t:a\na :b\n"}, {OUT=>"z:a\t:a\na :b\n"}], +# Before 1.22m, the first key comparison reported equality. +# With 1.22m, they compare different: "a" sorts before "a\n", +# and the second key spec isn't even used. +["11d", '-t: -k2,2b -k3,3', {IN=>"z:a :b\na\t:a\n"}, {OUT=>"a\t:a\nz:a :b\n"}], +# +# Exercise bug re comparing '-' and integers. +["12a", '-n -t: +1', {IN=>"a:1\nb:-\n"}, {OUT=>"b:-\na:1\n"}], +["12b", '-n -t: +1', {IN=>"b:-\na:1\n"}, {OUT=>"b:-\na:1\n"}], +# Try some other (e.g. 'X') invalid character. +["12c", '-n -t: +1', {IN=>"a:1\nb:X\n"}, {OUT=>"b:X\na:1\n"}], +["12d", '-n -t: +1', {IN=>"b:X\na:1\n"}, {OUT=>"b:X\na:1\n"}], +# From Karl Heuer +["13a", '+0.1n', {IN=>"axx\nb-1\n"}, {OUT=>"b-1\naxx\n"}], +["13b", '+0.1n', {IN=>"b-1\naxx\n"}, {OUT=>"b-1\naxx\n"}], +# +# From Carl Johnson +["14a", '-d -u', {IN=>"mal\nmal-\nmala\n"}, {OUT=>"mal\nmala\n"}], +# Be sure to fix the (translate && ignore) case in keycompare. +["14b", '-f -d -u', {IN=>"mal\nmal-\nmala\n"}, {OUT=>"mal\nmala\n"}], +# +# Experiment with -i. +["15a", '-i -u', {IN=>"a\na\1\n"}, {OUT=>"a\n"}], +["15b", '-i -u', {IN=>"a\n\1a\n"}, {OUT=>"a\n"}], +["15c", '-i -u', {IN=>"a\1\na\n"}, {OUT=>"a\1\n"}], +["15d", '-i -u', {IN=>"\1a\na\n"}, {OUT=>"\1a\n"}], +["15e", '-i -u', {IN=>"a\n\1\1\1\1\1a\1\1\1\1\n"}, {OUT=>"a\n"}], + +# This would fail (printing only the 7) for 8.6..8.18. +# Use --parallel=1 for reproducibility, and a small buffer size +# to let us trigger the problem with a smaller input. +["unique-1", '--p=1 -S32b -u', {IN=>"7\n"x11 . "1\n"}, {OUT=>"1\n7\n"}], +# Demonstrate that 8.19's key-spec-adjusting code is required. +# These are more finicky in that they are arch-dependent. +["unique-key-i686", '-u -k2,2 --p=1 -S32b', + {IN=>"a 7\n"x10 . "b 1\n"}, {OUT=>"b 1\na 7\n"}], +["unique-key-x86_64", '-u -k2,2 --p=1 -S32b', + {IN=>"a 7\n"x11 . "b 1\n"}, {OUT=>"b 1\na 7\n"}], +# Before 8.19, this would trigger a free-memory read. +["unique-free-mem-read", '-u --p=1 -S32b', + {IN=>"a\n"."b"x900 ."\n"}, + {OUT=>"a\n"."b"x900 ."\n"}], + +# From Erick Branderhorst -- fixed around 1.19e +["16a", '-f', + {IN=>"éminence\nüberhaupt\n's-Gravenhage\naëroclub\nAag\naagtappels\n"}, + {OUT=>"'s-Gravenhage\nAag\naagtappels\naëroclub\néminence\nüberhaupt\n"}], + +# This provokes a one-byte memory overrun of a malloc'd block for versions +# of sort from textutils-1.19p and before. +["17", '-c', {IN=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"}], + +# POSIX says -n no longer implies -b, so here we're comparing ' 9' and '10'. +["18a", '-k1.1,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}], + +# Just like above, because the global '-b' has no effect on the +# key specifier when a key-specific option ('n' in this case) is used. +["18b", '-b -k1.1,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}], + +# Here we're comparing ' 90' and '10', because the 'b' on the key-end specifier +# makes sort ignore leading blanks when determining that key's *end*. +["18c", '-k1.1,1.2nb', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}], + +# Here we're comparing '9' and '10', because the 'b' on the key-start specifier +# makes sort ignore leading blanks when determining that key's *start*. +["18d", '-k1.1b,1.2n', {IN=>" 901\n100\n"}, {OUT=>" 901\n100\n"}], + +# This compares '90' and '10', as it ignores leading blanks for both +# key start and key end. +["18e", '-nb -k1.1,1.2', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}], + +# When ignoring leading blanks for end position, ensure blanks from +# next field are not included in the sort. I.E. order should not change here. +["18f", '-k1,1b', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}], + +# When ignoring leading blanks for start position, ensure blanks from +# next field are not included in the sort. I.E. order should not change here. +# This was noticed as an issue on fedora 8 (only in multibyte locales). +["18g", '-k1b,1', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}, + {ENV => "LC_ALL=$mb_locale"}], + +# This looks odd, but works properly -- 2nd keyspec is never +# used because all lines are different. +["19a", '+0 +1nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 1\nb 2\nb 3\n"}], + +# The test *intended* by the author of the above, but using the +# more-intuitive POSIX-style -k options. +["19b", '-k1,1 -k2nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 3\nb 2\nb 1\n"}], + +# This test failed when sort-1.22 was compiled on a Next x86 system +# without optimization. Without optimization gcc uses the buggy version +# of memcmp in the Next C library. With optimization, gcc uses its +# (working) builtin version. Test case form William Lewis. +["20a", '', + {IN=>"_________U__free\n_________U__malloc\n_________U__abort\n" + . "_________U__memcpy\n_________U__memset\n" + . "_________U_dyld_stub_binding_helper\n_________U__malloc\n" + . "_________U___iob\n_________U__abort\n_________U__fprintf\n"}, + {OUT=>"_________U___iob\n_________U__abort\n_________U__abort\n" + . "_________U__fprintf\n_________U__free\n_________U__malloc\n" + . "_________U__malloc\n_________U__memcpy\n_________U__memset\n" + . "_________U_dyld_stub_binding_helper\n"}], + +# Demonstrate that folding changes the ordering of e.g. A, a, and _ +# because while they normally (in the C locale) collate like A, _, a, +# when using -f, 'a' is compared as if it were 'A'. +["21a", '', {IN=>"A\na\n_\n"}, {OUT=>"A\n_\na\n"}], +["21b", '-f', {IN=>"A\na\n_\n"}, {OUT=>"A\na\n_\n"}], +["21c", '-f', {IN=>"a\nA\n_\n"}, {OUT=>"A\na\n_\n"}], +["21d", '-f', {IN=>"_\na\nA\n"}, {OUT=>"A\na\n_\n"}], +["21e", '-f', {IN=>"a\n_\nA\n"}, {OUT=>"A\na\n_\n"}], +["21f", '-fs', {IN=>"A\na\n_\n"}, {OUT=>"A\na\n_\n"}], +["21g", '-fu', {IN=>"a\n_\n"}, {OUT=>"a\n_\n"}], + +# This test failed until 1.22f. From Zvi Har'El. +["22a", '-k 2,2fd -k 1,1r', {IN=>"3 b\n4 B\n"}, {OUT=>"4 B\n3 b\n"}], +["22b", '-k 2,2d -k 1,1r', {IN=>"3 b\n4 b\n"}, {OUT=>"4 b\n3 b\n"}], + +["no-file1", 'no-file', {EXIT=>2}, {ERR=>$no_file}], +# This test failed until 1.22f. Sort didn't give an error. +# From Will Edgington. +["o-no-file1", qw(-o no-file no-file), {EXIT=>2}, {ERR=>$no_file}], + +["create-empty", qw(-o no/such/file /dev/null), {EXIT=>2}, + {ERR=>"$prog: open failed: no/such/file: No such file or directory\n"}], + +# From Paul Eggert. This was fixed in textutils-1.22k. +["neg-nls", '-n', {IN=>"-1\n-9\n"}, {OUT=>"-9\n-1\n"}], + +# From Paul Eggert. This was fixed in textutils-1.22m. +# The bug was visible only when using the internationalized sorting code +# (i.e., not when configured with --disable-nls). +["nul-nls", '', {IN=>"\0b\n\0a\n"}, {OUT=>"\0a\n\0b\n"}], + +# Paul Eggert wrote: +# A previous version of POSIX incorrectly required that the newline +# at the end of the input line contributed to the sort, which would +# mean that an empty line should sort after a line starting with a tab +# (because \t precedes \n in the ASCII collating sequence). +# GNU 'sort' was altered to do this, but was changed back once it +# was discovered to be a POSIX bug (and the POSIX bug was fixed). +# Check that 'sort' conforms to the fixed POSIX, not to the buggy one. +["use-nl", '', {IN=>"\n\t\n"}, {OUT=>"\n\t\n"}], + +# Specifying two -o options should evoke a failure +["o2", qw(-o x -o y), {EXIT=>2}, + {ERR=>"foo\n"}, {ERR_SUBST => 's/^$prog: .*/foo/'}], + +# Specifying incompatible options should evoke a failure. +["incompat1", '-in', {EXIT=>2}, + {ERR=>"$prog: options '-in' are incompatible\n"}], +["incompat2", '-nR', {EXIT=>2}, + {ERR=>"$prog: options '-nR' are incompatible\n"}], +["incompat3", '-dfgiMnR', {EXIT=>2}, + {ERR=>"$prog: options '-dfgMnR' are incompatible\n"}], +["incompat4", qw(-c -o /dev/null), {EXIT=>2}, + {ERR=>"$prog: options '-co' are incompatible\n"}], +["incompat5", qw(-C -o /dev/null), {EXIT=>2}, + {ERR=>"$prog: options '-Co' are incompatible\n"}], +["incompat6", '-cC', {EXIT=>2}, + {ERR=>"$prog: options '-cC' are incompatible\n"}], +["incompat7", qw(--sort=random -n), {EXIT=>2}, + {ERR=>"$prog: options '-nR' are incompatible\n"}], + +# -t '\0' is accepted, as of coreutils-5.0.91 +['nul-tab', "-k2,2 -t '\\0'", + {IN=>"a\0z\01\nb\0y\02\n"}, {OUT=>"b\0y\02\na\0z\01\n"}], + +# fields > SIZE_MAX are silently interpreted as SIZE_MAX +["bigfield1", "-k $limits->{UINTMAX_OFLOW}", + {IN=>"2\n1\n"}, {OUT=>"1\n2\n"}], +["bigfield2", "-k $limits->{SIZE_OFLOW}", + {IN=>"2\n1\n"}, {OUT=>"1\n2\n"}], + +# Using an old-style key-specifying option like +1 with an invalid +# ordering-option character would cause sort to try to free an invalid +# (non-malloc'd) pointer. This bug affects coreutils-6.5 through 6.9. +['obs-inval', '+1x', {EXIT=>2}, + {ERR=>"foo\n"}, {ERR_SUBST => 's/^$prog: .*/foo/'}], + +# Exercise the code that enlarges the line buffer. See the thread here: +# http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11006 +['realloc-buf', '-S1', {IN=>'a'x4000 ."\n"}, {OUT=>'a'x4000 ."\n"}], +['realloc-buf-2', '-S1', {IN=>'a'x5 ."\n"}, {OUT=>'a'x5 ."\n"}], + +["sort-numeric", '--sort=numeric', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}], +["sort-gennum", '--sort=general-numeric', + {IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}], + +# -m with output file also used as an input file +# In coreutils-7.2, this caused a segfault. +# This test looks a little strange. Here's why: +# since we're using "-o f", standard output will be empty, hence OUT=>'' +# We still want to ensure that the output file, "f" has expected contents, +# hence the added CMP=> directive. +["output-is-input", '-m -o f', {IN=> {f=> "a\n"}}, {OUT=>''}, + {CMP=> ["a\n", {'f'=> undef}]} ], +["output-is-input-2", '-m -o f', {OUT=>''}, + {IN=> {f=> "a\n"}}, {IN=> {g=> "b\n"}}, {IN=> {h=> "c\n"}}, + {CMP=> ["a\nb\nc\n", {'f'=> undef}]} ], +["output-is-input-3", '-m -o f', {OUT=>''}, + {IN=> {g=> "a\n"}}, {IN=> {h=> "b\n"}}, {IN=> {f=> "c\n"}}, + {CMP=> ["a\nb\nc\n", {'f'=> undef}]} ], +); + +# Add _POSIX2_VERSION=199209 to the environment of each test +# that uses an old-style option like +1. +foreach my $t (@Tests) + { + foreach my $e (@$t) + { + !ref $e && $e =~ /\+\d/ + and push (@$t, {ENV=>'_POSIX2_VERSION=199209'}), last; + } + } + +@Tests = triple_test \@Tests; + +# Remember that triple_test creates from each test with exactly one "IN" +# file two more tests (.p and .r suffix on name) corresponding to reading +# input from a file and from a pipe. The pipe-reading test would fail +# due to a race condition about 1 in 20 times. +# Remove the IN_PIPE version of the "output-is-input" test above. +# The others aren't susceptible because they have three inputs each. +@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/stat-birthtime b/tests/misc/stat-birthtime deleted file mode 100755 index dd68e675e..000000000 --- a/tests/misc/stat-birthtime +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# ensure that stat attempts birthtime access - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stat - -# Whether birthtime is supported or not, it better not change even when -# [acm]time are modified. :) -touch a || fail=1 -btime=$(stat --format %W a) || fail=1 -atime=$(stat --format %X a) || fail=1 -mtime=$(stat --format %Y a) || fail=1 -ctime=$(stat --format %Z a) || fail=1 - -# Wait up to 2.17s for timestamps to change. -# ---------------------------------------- -# iterations file system resolution e.g. -# ---------------------------------------- -# 1 nano or micro second ext4 -# 4 1 second ext3 -# 5 2 second FAT -# ---------------------------------------- -check_timestamps_updated() -{ - local delay="$1" - sleep $delay - touch a || fail=1 - - test "x$btime" = x$(stat --format %W a) && - test "x$atime" != x$(stat --format %X a) && - test "x$mtime" != x$(stat --format %Y a) && - test "x$ctime" != x$(stat --format %Z a) -} -retry_delay_ check_timestamps_updated .07 5 || fail=1 - -Exit $fail diff --git a/tests/misc/stat-birthtime.sh b/tests/misc/stat-birthtime.sh new file mode 100755 index 000000000..dd68e675e --- /dev/null +++ b/tests/misc/stat-birthtime.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# ensure that stat attempts birthtime access + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stat + +# Whether birthtime is supported or not, it better not change even when +# [acm]time are modified. :) +touch a || fail=1 +btime=$(stat --format %W a) || fail=1 +atime=$(stat --format %X a) || fail=1 +mtime=$(stat --format %Y a) || fail=1 +ctime=$(stat --format %Z a) || fail=1 + +# Wait up to 2.17s for timestamps to change. +# ---------------------------------------- +# iterations file system resolution e.g. +# ---------------------------------------- +# 1 nano or micro second ext4 +# 4 1 second ext3 +# 5 2 second FAT +# ---------------------------------------- +check_timestamps_updated() +{ + local delay="$1" + sleep $delay + touch a || fail=1 + + test "x$btime" = x$(stat --format %W a) && + test "x$atime" != x$(stat --format %X a) && + test "x$mtime" != x$(stat --format %Y a) && + test "x$ctime" != x$(stat --format %Z a) +} +retry_delay_ check_timestamps_updated .07 5 || fail=1 + +Exit $fail diff --git a/tests/misc/stat-fmt b/tests/misc/stat-fmt deleted file mode 100755 index 8952a7abb..000000000 --- a/tests/misc/stat-fmt +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# ensure that stat properly handles a format string ending with % - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stat - - - -for i in $(seq 50); do - fmt=$(printf "%${i}s" %) - out=$(stat --form="$fmt" .) - test "$out" = "$fmt" || fail=1 -done - -Exit $fail diff --git a/tests/misc/stat-fmt.sh b/tests/misc/stat-fmt.sh new file mode 100755 index 000000000..8952a7abb --- /dev/null +++ b/tests/misc/stat-fmt.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# ensure that stat properly handles a format string ending with % + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stat + + + +for i in $(seq 50); do + fmt=$(printf "%${i}s" %) + out=$(stat --form="$fmt" .) + test "$out" = "$fmt" || fail=1 +done + +Exit $fail diff --git a/tests/misc/stat-hyphen b/tests/misc/stat-hyphen deleted file mode 100755 index a6b524362..000000000 --- a/tests/misc/stat-hyphen +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# demonstrate that stat - works and stat -f - does not. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stat - -printf -- '-\n' > exp || framework_failure_ -touch f || framework_failure_ - -stat --format=%n - < f > out || fail=1 -stat -f - < f && fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/stat-hyphen.sh b/tests/misc/stat-hyphen.sh new file mode 100755 index 000000000..a6b524362 --- /dev/null +++ b/tests/misc/stat-hyphen.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# demonstrate that stat - works and stat -f - does not. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stat + +printf -- '-\n' > exp || framework_failure_ +touch f || framework_failure_ + +stat --format=%n - < f > out || fail=1 +stat -f - < f && fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/stat-mount b/tests/misc/stat-mount deleted file mode 100755 index c93d8dcb5..000000000 --- a/tests/misc/stat-mount +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Test stat -c%m - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stat - -df_mnt=$(df -P . | sed -n '2s/.* \([^ ]*$\)/\1/p') -stat_mnt=$(stat -c%m .) || fail=1 -test "$stat_mnt" || fail=1 - -Exit $fail diff --git a/tests/misc/stat-mount.sh b/tests/misc/stat-mount.sh new file mode 100755 index 000000000..c93d8dcb5 --- /dev/null +++ b/tests/misc/stat-mount.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Test stat -c%m + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stat + +df_mnt=$(df -P . | sed -n '2s/.* \([^ ]*$\)/\1/p') +stat_mnt=$(stat -c%m .) || fail=1 +test "$stat_mnt" || fail=1 + +Exit $fail diff --git a/tests/misc/stat-nanoseconds b/tests/misc/stat-nanoseconds deleted file mode 100755 index 1afb610f9..000000000 --- a/tests/misc/stat-nanoseconds +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# Exercise format strings involving %:X, %:Y, etc. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -print_ver_ stat -. "${srcdir=.}/init.sh"; path_prepend_ ../src - -# Set this to avoid problems with weird time zones. -TZ=UTC0 -export TZ - -# Use a time stamp near the Epoch to avoid trouble with leap seconds. -touch -d '1970-01-01 18:43:33.023456789' k || framework_failure_ - -ls --full-time | grep 18:43:33.023456789 \ - || skip_ this file system does not support sub-second time stamps - -test "$(stat -c %X k)" = 67413 || fail=1 -test "$(stat -c %.X k)" = 67413.023456789 || fail=1 -test "$(stat -c %.1X k)" = 67413.0 || fail=1 -test "$(stat -c %.3X k)" = 67413.023 || fail=1 -test "$(stat -c %.6X k)" = 67413.023456 || fail=1 -test "$(stat -c %.9X k)" = 67413.023456789 || fail=1 -test "$(stat -c %13.6X k)" = ' 67413.023456' || fail=1 -test "$(stat -c %013.6X k)" = 067413.023456 || fail=1 -test "$(stat -c %-13.6X k)" = '67413.023456 ' || fail=1 -test "$(stat -c %18.10X k)" = ' 67413.0234567890' || fail=1 -test "$(stat -c %I18.10X k)" = ' 67413.0234567890' || fail=1 -test "$(stat -c %018.10X k)" = 0067413.0234567890 || fail=1 -test "$(stat -c %-18.10X k)" = '67413.0234567890 ' || fail=1 - -Exit $fail diff --git a/tests/misc/stat-nanoseconds.sh b/tests/misc/stat-nanoseconds.sh new file mode 100755 index 000000000..1afb610f9 --- /dev/null +++ b/tests/misc/stat-nanoseconds.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Exercise format strings involving %:X, %:Y, etc. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +print_ver_ stat +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +# Set this to avoid problems with weird time zones. +TZ=UTC0 +export TZ + +# Use a time stamp near the Epoch to avoid trouble with leap seconds. +touch -d '1970-01-01 18:43:33.023456789' k || framework_failure_ + +ls --full-time | grep 18:43:33.023456789 \ + || skip_ this file system does not support sub-second time stamps + +test "$(stat -c %X k)" = 67413 || fail=1 +test "$(stat -c %.X k)" = 67413.023456789 || fail=1 +test "$(stat -c %.1X k)" = 67413.0 || fail=1 +test "$(stat -c %.3X k)" = 67413.023 || fail=1 +test "$(stat -c %.6X k)" = 67413.023456 || fail=1 +test "$(stat -c %.9X k)" = 67413.023456789 || fail=1 +test "$(stat -c %13.6X k)" = ' 67413.023456' || fail=1 +test "$(stat -c %013.6X k)" = 067413.023456 || fail=1 +test "$(stat -c %-13.6X k)" = '67413.023456 ' || fail=1 +test "$(stat -c %18.10X k)" = ' 67413.0234567890' || fail=1 +test "$(stat -c %I18.10X k)" = ' 67413.0234567890' || fail=1 +test "$(stat -c %018.10X k)" = 0067413.0234567890 || fail=1 +test "$(stat -c %-18.10X k)" = '67413.0234567890 ' || fail=1 + +Exit $fail diff --git a/tests/misc/stat-printf b/tests/misc/stat-printf deleted file mode 100755 index 929b255e5..000000000 --- a/tests/misc/stat-printf +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/perl -# Test "stat --printf". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $ME = $0) =~ s|.*/||; -my $prog = 'stat'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - # test-name, [option, option, ...] {OUT=>"expected-output"} - # - ['nl', q!--printf='\n' .!, {OUT=>"\n"}], - ['no-nl', "--printf=%n .", {OUT=>"."}], - ['pct-and-esc', q!--printf='\0%n\0' .!, {OUT=>"\0.\0"}], - ['backslash', q!--printf='\\\\' .!, {OUT=>"\\"}], - ['nul', q!--printf='\0' .!, {OUT=>"\0"}], - # Don't bother testing \v, since Perl doesn't handle it. - ['bel-etc', q!--printf='\a\b\f\n\r\t' .!, {OUT=>"\a\b\f\n\r\t"}], - ['octal-1', q!--printf='\012\377' .!, {OUT=>"\012\377"}], - ['octal-2', q!--printf='.\012a\377b' .!, {OUT=>".\012a\377b"}], - ['hex-1', q!--printf='\x34\xf' .!, {OUT=>"\x34\xf"}], - ['hex-2', q!--printf='.\x18p\xfq' .!, {OUT=>".\x18p\x0fq"}], - ['hex-3', q!--printf='\x' .!, {OUT=>'x'}, - {ERR=>"$prog: warning: unrecognized escape '\\x'\n"}], - - # With --format, there *is* a trailing newline. - ['f-nl', "--format=%n .", {OUT=>".\n"}], - ['f-nl2', "--format=%n . .", {OUT=>".\n.\n"}], - - ['end-pct', "--printf=% .", {OUT=>"%"}], - ['pct-pct', "--printf=%% .", {OUT=>"%"}], - ['end-bs', "--printf='\\' .", {OUT=>'\\'}, - {ERR=>"$prog: warning: backslash at end of format\n"}], - - ['err-1', "--printf=%9% .", {EXIT => 1}, - {ERR=>"$prog: %9%: invalid directive\n"}], - ['err-2', "--printf=%9 .", {EXIT => 1}, - {ERR=>"$prog: %9: invalid directive\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/stat-printf.pl b/tests/misc/stat-printf.pl new file mode 100755 index 000000000..929b255e5 --- /dev/null +++ b/tests/misc/stat-printf.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# Test "stat --printf". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $ME = $0) =~ s|.*/||; +my $prog = 'stat'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + # test-name, [option, option, ...] {OUT=>"expected-output"} + # + ['nl', q!--printf='\n' .!, {OUT=>"\n"}], + ['no-nl', "--printf=%n .", {OUT=>"."}], + ['pct-and-esc', q!--printf='\0%n\0' .!, {OUT=>"\0.\0"}], + ['backslash', q!--printf='\\\\' .!, {OUT=>"\\"}], + ['nul', q!--printf='\0' .!, {OUT=>"\0"}], + # Don't bother testing \v, since Perl doesn't handle it. + ['bel-etc', q!--printf='\a\b\f\n\r\t' .!, {OUT=>"\a\b\f\n\r\t"}], + ['octal-1', q!--printf='\012\377' .!, {OUT=>"\012\377"}], + ['octal-2', q!--printf='.\012a\377b' .!, {OUT=>".\012a\377b"}], + ['hex-1', q!--printf='\x34\xf' .!, {OUT=>"\x34\xf"}], + ['hex-2', q!--printf='.\x18p\xfq' .!, {OUT=>".\x18p\x0fq"}], + ['hex-3', q!--printf='\x' .!, {OUT=>'x'}, + {ERR=>"$prog: warning: unrecognized escape '\\x'\n"}], + + # With --format, there *is* a trailing newline. + ['f-nl', "--format=%n .", {OUT=>".\n"}], + ['f-nl2', "--format=%n . .", {OUT=>".\n.\n"}], + + ['end-pct', "--printf=% .", {OUT=>"%"}], + ['pct-pct', "--printf=%% .", {OUT=>"%"}], + ['end-bs', "--printf='\\' .", {OUT=>'\\'}, + {ERR=>"$prog: warning: backslash at end of format\n"}], + + ['err-1', "--printf=%9% .", {EXIT => 1}, + {ERR=>"$prog: %9%: invalid directive\n"}], + ['err-2', "--printf=%9 .", {EXIT => 1}, + {ERR=>"$prog: %9: invalid directive\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/stat-slash b/tests/misc/stat-slash deleted file mode 100755 index ff122eb0f..000000000 --- a/tests/misc/stat-slash +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# demonstrate that stat handles trailing slashes correctly - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stat - -touch file || framework_failure_ -mkdir dir || framework_failure_ -ln -s file link1 || framework_failure_ -ln -s dir link2 || framework_failure_ - -cat < exp || framework_failure_ -link1 -symbolic link -directory -directory -EOF - -# This failed on Solaris 9 for coreutils 8.0. -stat --format=%n link1 > out || fail=1 -stat --format=%n link1/ >> out && fail=1 - -stat --format=%F link2 >> out || fail=1 -stat -L --format=%F link2 >> out || fail=1 -stat --format=%F link2/ >> out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/stat-slash.sh b/tests/misc/stat-slash.sh new file mode 100755 index 000000000..ff122eb0f --- /dev/null +++ b/tests/misc/stat-slash.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# demonstrate that stat handles trailing slashes correctly + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stat + +touch file || framework_failure_ +mkdir dir || framework_failure_ +ln -s file link1 || framework_failure_ +ln -s dir link2 || framework_failure_ + +cat < exp || framework_failure_ +link1 +symbolic link +directory +directory +EOF + +# This failed on Solaris 9 for coreutils 8.0. +stat --format=%n link1 > out || fail=1 +stat --format=%n link1/ >> out && fail=1 + +stat --format=%F link2 >> out || fail=1 +stat -L --format=%F link2 >> out || fail=1 +stat --format=%F link2/ >> out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/stdbuf b/tests/misc/stdbuf deleted file mode 100755 index 3164df1b0..000000000 --- a/tests/misc/stdbuf +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/sh -# Exercise stdbuf functionality - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stdbuf - -getlimits_ -require_built_ stdbuf - -# stdbuf fails when the absolute top build dir name contains e.g., -# space, TAB, NL -lf=' -' -case $abs_top_builddir in - *[\\\"\#\$\&\'\`$lf\ \ ]*) - skip_ "unsafe absolute build directory name: $abs_top_builddir";; -esac - -# Use a fifo rather than a pipe in the tests below -# so that the producer (uniq) will wait until the -# consumer (dd) opens the fifo therefore increasing -# the chance that dd will read the data from each -# write separately. -mkfifo_or_skip_ fifo - - -# Verify input parameter checking -stdbuf -o1 true || fail=1 # verify size syntax -stdbuf -oK true || fail=1 # verify size syntax -stdbuf -o0 true || fail=1 # verify unbuffered syntax -stdbuf -oL true || fail=1 # verify line buffered syntax -stdbuf -ol true # Capital 'L' required -test $? = 125 || fail=1 # Internal error is a particular status -stdbuf -o$SIZE_OFLOW true # size too large -test $? = 125 || fail=1 -stdbuf -iL true # line buffering stdin disallowed -test $? = 125 || fail=1 -stdbuf -i0 -o0 -e0 true || fail=1 #check all files -stdbuf -o1 . # invalid command -test $? = 126 || fail=1 -stdbuf -o1 no_such # no such command -test $? = 127 || fail=1 - -# Ensure line buffering stdout takes effect -stdbuf_linebuffer() -{ - local delay="$1" - - printf '1\n' > exp - dd count=1 if=fifo > out 2> err & - (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -oL uniq > fifo - wait # for dd to complete - compare exp out -} - -retry_delay_ stdbuf_linebuffer .1 6 || fail=1 - -stdbuf_unbuffer() -{ - local delay="$1" - - # Ensure un buffering stdout takes effect - printf '1\n' > exp - dd count=1 if=fifo > out 2> err & - (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o0 uniq > fifo - wait # for dd to complete - compare exp out -} - -retry_delay_ stdbuf_unbuffer .1 6 || fail=1 - -# Ensure un buffering stdin takes effect -# The following works for me, but is racy. I.E. we're depending -# on dd to run and close the fifo before the second write by uniq. -# If we add a sleep, then we're just testing -oL - # printf '3\n' > exp - # dd count=1 if=fifo > /dev/null 2> err & - # printf '1\n\2\n3\n' | (stdbuf -i0 -oL uniq > fifo; cat) > out - # wait # for dd to complete - # compare exp out || fail=1 -# One could remove the need for dd (used to close the fifo to get uniq to quit -# early), if head -n1 read stdin char by char. Note uniq | head -c2 doesn't -# suffice due to the buffering implicit in the pipe. sed currently does read -# stdin char by char, so we can test with 'sed 1q'. However I'm wary about -# adding this dependency on a program outside of coreutils. - # printf '2\n' > exp - # printf '1\n2\n' | (stdbuf -i0 sed 1q >/dev/null; cat) > out - # compare exp out || fail=1 - -# Ensure block buffering stdout takes effect -# We don't currently test block buffering failures as -# this doesn't work on GLIBC-2.7 or GLIBC-2.9 at least. - # stdbuf_blockbuffer() - # { - # local delay="$1" - # - # printf '1\n2\n' > exp - # dd count=1 if=fifo > out 2> err & - # (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o4 uniq > fifo - # wait # for dd to complete - # compare exp out - # } - # - # retry_delay_ stdbuf_blockbuffer .1 6 || fail=1 - -Exit $fail diff --git a/tests/misc/stdbuf.sh b/tests/misc/stdbuf.sh new file mode 100755 index 000000000..3164df1b0 --- /dev/null +++ b/tests/misc/stdbuf.sh @@ -0,0 +1,121 @@ +#!/bin/sh +# Exercise stdbuf functionality + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stdbuf + +getlimits_ +require_built_ stdbuf + +# stdbuf fails when the absolute top build dir name contains e.g., +# space, TAB, NL +lf=' +' +case $abs_top_builddir in + *[\\\"\#\$\&\'\`$lf\ \ ]*) + skip_ "unsafe absolute build directory name: $abs_top_builddir";; +esac + +# Use a fifo rather than a pipe in the tests below +# so that the producer (uniq) will wait until the +# consumer (dd) opens the fifo therefore increasing +# the chance that dd will read the data from each +# write separately. +mkfifo_or_skip_ fifo + + +# Verify input parameter checking +stdbuf -o1 true || fail=1 # verify size syntax +stdbuf -oK true || fail=1 # verify size syntax +stdbuf -o0 true || fail=1 # verify unbuffered syntax +stdbuf -oL true || fail=1 # verify line buffered syntax +stdbuf -ol true # Capital 'L' required +test $? = 125 || fail=1 # Internal error is a particular status +stdbuf -o$SIZE_OFLOW true # size too large +test $? = 125 || fail=1 +stdbuf -iL true # line buffering stdin disallowed +test $? = 125 || fail=1 +stdbuf -i0 -o0 -e0 true || fail=1 #check all files +stdbuf -o1 . # invalid command +test $? = 126 || fail=1 +stdbuf -o1 no_such # no such command +test $? = 127 || fail=1 + +# Ensure line buffering stdout takes effect +stdbuf_linebuffer() +{ + local delay="$1" + + printf '1\n' > exp + dd count=1 if=fifo > out 2> err & + (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -oL uniq > fifo + wait # for dd to complete + compare exp out +} + +retry_delay_ stdbuf_linebuffer .1 6 || fail=1 + +stdbuf_unbuffer() +{ + local delay="$1" + + # Ensure un buffering stdout takes effect + printf '1\n' > exp + dd count=1 if=fifo > out 2> err & + (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o0 uniq > fifo + wait # for dd to complete + compare exp out +} + +retry_delay_ stdbuf_unbuffer .1 6 || fail=1 + +# Ensure un buffering stdin takes effect +# The following works for me, but is racy. I.E. we're depending +# on dd to run and close the fifo before the second write by uniq. +# If we add a sleep, then we're just testing -oL + # printf '3\n' > exp + # dd count=1 if=fifo > /dev/null 2> err & + # printf '1\n\2\n3\n' | (stdbuf -i0 -oL uniq > fifo; cat) > out + # wait # for dd to complete + # compare exp out || fail=1 +# One could remove the need for dd (used to close the fifo to get uniq to quit +# early), if head -n1 read stdin char by char. Note uniq | head -c2 doesn't +# suffice due to the buffering implicit in the pipe. sed currently does read +# stdin char by char, so we can test with 'sed 1q'. However I'm wary about +# adding this dependency on a program outside of coreutils. + # printf '2\n' > exp + # printf '1\n2\n' | (stdbuf -i0 sed 1q >/dev/null; cat) > out + # compare exp out || fail=1 + +# Ensure block buffering stdout takes effect +# We don't currently test block buffering failures as +# this doesn't work on GLIBC-2.7 or GLIBC-2.9 at least. + # stdbuf_blockbuffer() + # { + # local delay="$1" + # + # printf '1\n2\n' > exp + # dd count=1 if=fifo > out 2> err & + # (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o4 uniq > fifo + # wait # for dd to complete + # compare exp out + # } + # + # retry_delay_ stdbuf_blockbuffer .1 6 || fail=1 + +Exit $fail diff --git a/tests/misc/stty b/tests/misc/stty deleted file mode 100755 index ae6565649..000000000 --- a/tests/misc/stty +++ /dev/null @@ -1,68 +0,0 @@ -#! /bin/sh -# Make sure stty can parse most of its options. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Make sure there's a tty on stdin. -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stty - -require_controlling_input_terminal_ -trap '' TTOU # Ignore SIGTTOU - -# Get the reversible settings from stty.c. -stty_reversible_init_ - -saved_state=.saved-state -stty --save > $saved_state || fail=1 -stty $(cat $saved_state) || fail=1 - -# This would segfault prior to sh-utils-2.0j. -stty erase - || fail=1 - -# These would improperly ignore invalid options through coreutils 5.2.1. -stty -F 2>/dev/null && fail=1 -stty -raw -F no/such/file 2>/dev/null && fail=1 -stty -raw -a 2>/dev/null && fail=1 - -# Build a list of all boolean options stty accepts on this system. -# Don't depend on terminal width. Put each option on its own line, -# remove all non-boolean ones, then remove any leading hyphens. -sed_del='/^speed/d;/^rows/d;/^columns/d;/ = /d' -options=$(stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g") - -# Take them one at a time, with and without the leading '-'. -for opt in $options; do - # 'stty parenb' and 'stty -parenb' fail with this message - # stty: standard input: unable to perform all requested operations - # on Linux 2.2.0-pre4 kernels. Also since around Linux 2.6.30 - # other serial control settings give the same error. So skip them. - # Also on ppc*|sparc* glibc platforms 'icanon' gives the same error. - # See: http://debbugs.gnu.org/7228#14 - case $opt in parenb|parodd|cstopb|crtscts|icanon) continue;; esac - - stty $opt || fail=1 - - # Likewise, 'stty -cread' would fail, so skip that, too. - test $opt = cread && continue - if stty_reversible_query_ "$opt" ; then - stty -$opt || { fail=1; echo -$opt; } - fi -done - -stty $(cat $saved_state) - -Exit $fail diff --git a/tests/misc/stty-invalid b/tests/misc/stty-invalid deleted file mode 100755 index 3b035ecef..000000000 --- a/tests/misc/stty-invalid +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# Ensure that stty diagnoses invalid inputs, rather than silently misbehaving. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stty -require_controlling_input_terminal_ -trap '' TTOU # Ignore SIGTTOU - - -saved_state=$(stty -g) || fail=1 -stty $saved_state || fail=1 - -# Before coreutils-6.9.90, if stty were given an argument with 35 colons -# separating 36 hexadecimal strings, stty would fail to diagnose as invalid -# any number that was out of range as long as sscanf happened to -# overflow/wrap it back into the range of the corresponding type (either -# tcflag_t or cc_t). - -# For each of the following, with coreutils-6.9 and earlier, -# stty would fail to diagnose the error on at least Solaris 10. -hex_2_64=10000000000000000 -stty $(echo $saved_state |sed 's/^[^:]*:/'$hex_2_64:/) 2>/dev/null && fail=1 -stty $(echo $saved_state |sed 's/:[0-9a-f]*$/:'$hex_2_64/) 2>/dev/null && fail=1 - -# Just in case either of the above mistakenly succeeds (and changes -# the state of our tty), try to restore the initial state. -stty $saved_state || fail=1 - -Exit $fail diff --git a/tests/misc/stty-invalid.sh b/tests/misc/stty-invalid.sh new file mode 100755 index 000000000..3b035ecef --- /dev/null +++ b/tests/misc/stty-invalid.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Ensure that stty diagnoses invalid inputs, rather than silently misbehaving. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stty +require_controlling_input_terminal_ +trap '' TTOU # Ignore SIGTTOU + + +saved_state=$(stty -g) || fail=1 +stty $saved_state || fail=1 + +# Before coreutils-6.9.90, if stty were given an argument with 35 colons +# separating 36 hexadecimal strings, stty would fail to diagnose as invalid +# any number that was out of range as long as sscanf happened to +# overflow/wrap it back into the range of the corresponding type (either +# tcflag_t or cc_t). + +# For each of the following, with coreutils-6.9 and earlier, +# stty would fail to diagnose the error on at least Solaris 10. +hex_2_64=10000000000000000 +stty $(echo $saved_state |sed 's/^[^:]*:/'$hex_2_64:/) 2>/dev/null && fail=1 +stty $(echo $saved_state |sed 's/:[0-9a-f]*$/:'$hex_2_64/) 2>/dev/null && fail=1 + +# Just in case either of the above mistakenly succeeds (and changes +# the state of our tty), try to restore the initial state. +stty $saved_state || fail=1 + +Exit $fail diff --git a/tests/misc/stty-pairs b/tests/misc/stty-pairs deleted file mode 100755 index e59da0435..000000000 --- a/tests/misc/stty-pairs +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Make sure stty can parse most of its options - in pairs [expensive]. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stty - -expensive_ - -# Make sure there's a tty on stdin. -require_controlling_input_terminal_ -trap '' TTOU # Ignore SIGTTOU - -# Get the reversible settings from stty.c. -stty_reversible_init_ - -saved_state=.saved-state -stty --save > $saved_state || fail=1 -stty $(cat $saved_state) || fail=1 - -# Build a list of all boolean options stty accepts on this system. -# Don't depend on terminal width. Put each option on its own line, -# remove all non-boolean ones, remove 'parenb' and 'cread' explicitly, -# then remove any leading hyphens. -sed_del='/^speed/d;/^rows/d;/^columns/d;/ = /d;s/parenb//;s/cread//' -options=$(stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g") - -# Take them in pairs, with and without the leading '-'. -for opt1 in $options; do - for opt2 in $options; do - - stty $opt1 $opt2 || fail=1 - - if stty_reversible_query_ "$opt1" ; then - stty -$opt1 $opt2 || fail=1 - fi - if stty_reversible_query_ "$opt2" ; then - stty $opt1 -$opt2 || fail=1 - fi - if stty_reversible_query_ "$opt1" \ - && stty_reversible_query_ "$opt2" ; then - stty -$opt1 -$opt2 || fail=1 - fi - done -done - -stty $(cat $saved_state) - -Exit $fail diff --git a/tests/misc/stty-pairs.sh b/tests/misc/stty-pairs.sh new file mode 100755 index 000000000..e59da0435 --- /dev/null +++ b/tests/misc/stty-pairs.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Make sure stty can parse most of its options - in pairs [expensive]. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stty + +expensive_ + +# Make sure there's a tty on stdin. +require_controlling_input_terminal_ +trap '' TTOU # Ignore SIGTTOU + +# Get the reversible settings from stty.c. +stty_reversible_init_ + +saved_state=.saved-state +stty --save > $saved_state || fail=1 +stty $(cat $saved_state) || fail=1 + +# Build a list of all boolean options stty accepts on this system. +# Don't depend on terminal width. Put each option on its own line, +# remove all non-boolean ones, remove 'parenb' and 'cread' explicitly, +# then remove any leading hyphens. +sed_del='/^speed/d;/^rows/d;/^columns/d;/ = /d;s/parenb//;s/cread//' +options=$(stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g") + +# Take them in pairs, with and without the leading '-'. +for opt1 in $options; do + for opt2 in $options; do + + stty $opt1 $opt2 || fail=1 + + if stty_reversible_query_ "$opt1" ; then + stty -$opt1 $opt2 || fail=1 + fi + if stty_reversible_query_ "$opt2" ; then + stty $opt1 -$opt2 || fail=1 + fi + if stty_reversible_query_ "$opt1" \ + && stty_reversible_query_ "$opt2" ; then + stty -$opt1 -$opt2 || fail=1 + fi + done +done + +stty $(cat $saved_state) + +Exit $fail diff --git a/tests/misc/stty-row-col b/tests/misc/stty-row-col deleted file mode 100755 index d7151d5b7..000000000 --- a/tests/misc/stty-row-col +++ /dev/null @@ -1,87 +0,0 @@ -#! /bin/sh -# Test "stty" with rows and columns. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Setting this envvar to a very small value used to cause e.g., 'stty size' -# to generate slightly different output on certain systems. -COLUMNS=80 -export COLUMNS - -# Make sure we get English-language behavior. -# See the report about a possibly-related Solaris problem by Alexandre Peshansky -# . -# Currently stty isn't localized, but it might be in the future. -LC_ALL=C -export LC_ALL - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ stty - -require_controlling_input_terminal_ -trap '' TTOU # Ignore SIGTTOU - -# Versions of GNU stty from shellutils-1.9.2c and earlier failed -# tests #2 and #4 when run on SunOS 4.1.3. - -tests=' -1 rows_40_columns_80 40_80 -2 rows_1_columns_1 1_1 -3 rows_40_columns_80 40_80 -4 rows_1 1_80 -5 columns_1 1_1 -6 rows_40 40_1 -7 rows_1 1_1 -8 columns_80 1_80 -9 rows_30 30_80 -NA LAST NA -' -set $tests - -saved_size=$(stty size) && test -n "$saved_size" \ - || skip_ "can't get window size" - -# Linux virtual consoles issue an error if you -# try to increase their size. So skip in that case. -if test "x$saved_size" != "x0 0"; then - srow=$(echo $saved_size | cut -d ' ' -f1) - scol=$(echo $saved_size | cut -d ' ' -f2) - stty rows $(expr $srow + 1) cols $(expr $scol + 1) || - skip_ "can't increase window size" -fi - -while :; do - test_name=$1 - args=$2 - expected_result="$(echo $3|tr _ ' ')" - test "$args" = empty && args='' - test "x$args" = xLAST && break - args=$(echo x$args|tr _ ' '|sed 's/^x//') - if test "$VERBOSE" = yes; then - # echo "testing \$(stty $args; stty size\) = $expected_result ..." - echo "test $test_name... " | tr -d '\n' - fi - stty $args || exit 1 - test x"$(stty size 2> /dev/null)" = "x$expected_result" \ - && ok=ok || ok=FAIL fail=1 - test "$VERBOSE" = yes && echo $ok - shift; shift; shift -done - -set x $saved_size -stty rows $2 columns $3 || exit 1 - -Exit $fail diff --git a/tests/misc/stty-row-col.sh b/tests/misc/stty-row-col.sh new file mode 100755 index 000000000..d7151d5b7 --- /dev/null +++ b/tests/misc/stty-row-col.sh @@ -0,0 +1,87 @@ +#! /bin/sh +# Test "stty" with rows and columns. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Setting this envvar to a very small value used to cause e.g., 'stty size' +# to generate slightly different output on certain systems. +COLUMNS=80 +export COLUMNS + +# Make sure we get English-language behavior. +# See the report about a possibly-related Solaris problem by Alexandre Peshansky +# . +# Currently stty isn't localized, but it might be in the future. +LC_ALL=C +export LC_ALL + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stty + +require_controlling_input_terminal_ +trap '' TTOU # Ignore SIGTTOU + +# Versions of GNU stty from shellutils-1.9.2c and earlier failed +# tests #2 and #4 when run on SunOS 4.1.3. + +tests=' +1 rows_40_columns_80 40_80 +2 rows_1_columns_1 1_1 +3 rows_40_columns_80 40_80 +4 rows_1 1_80 +5 columns_1 1_1 +6 rows_40 40_1 +7 rows_1 1_1 +8 columns_80 1_80 +9 rows_30 30_80 +NA LAST NA +' +set $tests + +saved_size=$(stty size) && test -n "$saved_size" \ + || skip_ "can't get window size" + +# Linux virtual consoles issue an error if you +# try to increase their size. So skip in that case. +if test "x$saved_size" != "x0 0"; then + srow=$(echo $saved_size | cut -d ' ' -f1) + scol=$(echo $saved_size | cut -d ' ' -f2) + stty rows $(expr $srow + 1) cols $(expr $scol + 1) || + skip_ "can't increase window size" +fi + +while :; do + test_name=$1 + args=$2 + expected_result="$(echo $3|tr _ ' ')" + test "$args" = empty && args='' + test "x$args" = xLAST && break + args=$(echo x$args|tr _ ' '|sed 's/^x//') + if test "$VERBOSE" = yes; then + # echo "testing \$(stty $args; stty size\) = $expected_result ..." + echo "test $test_name... " | tr -d '\n' + fi + stty $args || exit 1 + test x"$(stty size 2> /dev/null)" = "x$expected_result" \ + && ok=ok || ok=FAIL fail=1 + test "$VERBOSE" = yes && echo $ok + shift; shift; shift +done + +set x $saved_size +stty rows $2 columns $3 || exit 1 + +Exit $fail diff --git a/tests/misc/stty.sh b/tests/misc/stty.sh new file mode 100755 index 000000000..ae6565649 --- /dev/null +++ b/tests/misc/stty.sh @@ -0,0 +1,68 @@ +#! /bin/sh +# Make sure stty can parse most of its options. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Make sure there's a tty on stdin. +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ stty + +require_controlling_input_terminal_ +trap '' TTOU # Ignore SIGTTOU + +# Get the reversible settings from stty.c. +stty_reversible_init_ + +saved_state=.saved-state +stty --save > $saved_state || fail=1 +stty $(cat $saved_state) || fail=1 + +# This would segfault prior to sh-utils-2.0j. +stty erase - || fail=1 + +# These would improperly ignore invalid options through coreutils 5.2.1. +stty -F 2>/dev/null && fail=1 +stty -raw -F no/such/file 2>/dev/null && fail=1 +stty -raw -a 2>/dev/null && fail=1 + +# Build a list of all boolean options stty accepts on this system. +# Don't depend on terminal width. Put each option on its own line, +# remove all non-boolean ones, then remove any leading hyphens. +sed_del='/^speed/d;/^rows/d;/^columns/d;/ = /d' +options=$(stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g") + +# Take them one at a time, with and without the leading '-'. +for opt in $options; do + # 'stty parenb' and 'stty -parenb' fail with this message + # stty: standard input: unable to perform all requested operations + # on Linux 2.2.0-pre4 kernels. Also since around Linux 2.6.30 + # other serial control settings give the same error. So skip them. + # Also on ppc*|sparc* glibc platforms 'icanon' gives the same error. + # See: http://debbugs.gnu.org/7228#14 + case $opt in parenb|parodd|cstopb|crtscts|icanon) continue;; esac + + stty $opt || fail=1 + + # Likewise, 'stty -cread' would fail, so skip that, too. + test $opt = cread && continue + if stty_reversible_query_ "$opt" ; then + stty -$opt || { fail=1; echo -$opt; } + fi +done + +stty $(cat $saved_state) + +Exit $fail diff --git a/tests/misc/sum b/tests/misc/sum deleted file mode 100755 index 8aaa6350e..000000000 --- a/tests/misc/sum +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl -# Test "sum". - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $in_1k = 'a' x 1024; -my $in_2k = 'b' x 2048; - -my @Tests = - ( - ['1', {IN=> {f=> ''}}, {OUT=>"00000 0\n"}], - ['2', {IN=> {f=> 'a'}}, {OUT=>"00097 1\n"}], - ['3', {IN=> {f=> 'abc'}}, {OUT=>"16556 1\n"}], - ['4', {IN=> {f=> 'message digest'}}, {OUT=>"26423 1\n"}], - ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"53553 1\n"}], - ['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"25587 1\n"}], - ['7', {IN=> {f=> '1234567890' x 8}}, {OUT=>"21845 1\n"}], - - ['a-r-1k', '-r', {IN=> {f=> $in_1k}}, {OUT=>"65409 1\n"}], - ['a-s-1k', '-s', {IN=> {f=> $in_1k}}, {OUT=>"33793 2 f\n"}], - ['b-r-2k', '-r', {IN=> {f=> $in_2k}}, {OUT=>"65223 2\n"}], - ['b-s-2k', '-s', {IN=> {f=> $in_2k}}, {OUT=>"4099 4 f\n"}], - - ['1s', '-s', {IN=> {f=> ''}}, {OUT=>"0 0 f\n"}], - ['2s', '-s', {IN=> {f=> 'a'}}, {OUT=>"97 1 f\n"}], - ['3s', '-s', {IN=> {f=> 'abc'}}, {OUT=>"294 1 f\n"}], - ['4s', '-s', {IN=> {f=> 'message digest'}}, {OUT=>"1413 1 f\n"}], - ['5s', '-s', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, - {OUT=>"2847 1 f\n"}], - ['6s', '-s', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, - {OUT=>"5387 1 f\n"}], - ['7s', '-s', {IN=> {f=> '1234567890' x 8}}, {OUT=>"4200 1 f\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'sum'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/sum-sysv b/tests/misc/sum-sysv deleted file mode 100755 index 9cdf07fc6..000000000 --- a/tests/misc/sum-sysv +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# make sure 'sum -s' works for input whose sum of bytes is larger than 2^32 - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Avoid a problem when run in a UTF-8 locale. -# Otherwise, Perl would try to (and fail to) interpret -# each string below as a sequence of multi-byte characters. -LC_ALL=C -export LC_ALL - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ sum - -require_perl_ - -# FYI, 16843009 is floor (2^32 / 255). - -# aka: perl -e 'print chr(255) x 16843009' -$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}' \ - | sum -s > out || fail=1 -cat > exp <<\EOF -65535 32897 -EOF -compare exp out || fail=1 - -rm -f out exp - -# aka: perl -e 'print chr(255) x 16843010' -$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}; print chr(255)' \ - | sum -s > out || fail=1 -cat > exp <<\EOF -254 32897 -EOF -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/sum-sysv.sh b/tests/misc/sum-sysv.sh new file mode 100755 index 000000000..9cdf07fc6 --- /dev/null +++ b/tests/misc/sum-sysv.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# make sure 'sum -s' works for input whose sum of bytes is larger than 2^32 + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Avoid a problem when run in a UTF-8 locale. +# Otherwise, Perl would try to (and fail to) interpret +# each string below as a sequence of multi-byte characters. +LC_ALL=C +export LC_ALL + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ sum + +require_perl_ + +# FYI, 16843009 is floor (2^32 / 255). + +# aka: perl -e 'print chr(255) x 16843009' +$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}' \ + | sum -s > out || fail=1 +cat > exp <<\EOF +65535 32897 +EOF +compare exp out || fail=1 + +rm -f out exp + +# aka: perl -e 'print chr(255) x 16843010' +$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}; print chr(255)' \ + | sum -s > out || fail=1 +cat > exp <<\EOF +254 32897 +EOF +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/sum.pl b/tests/misc/sum.pl new file mode 100755 index 000000000..8aaa6350e --- /dev/null +++ b/tests/misc/sum.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl +# Test "sum". + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $in_1k = 'a' x 1024; +my $in_2k = 'b' x 2048; + +my @Tests = + ( + ['1', {IN=> {f=> ''}}, {OUT=>"00000 0\n"}], + ['2', {IN=> {f=> 'a'}}, {OUT=>"00097 1\n"}], + ['3', {IN=> {f=> 'abc'}}, {OUT=>"16556 1\n"}], + ['4', {IN=> {f=> 'message digest'}}, {OUT=>"26423 1\n"}], + ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"53553 1\n"}], + ['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, + {OUT=>"25587 1\n"}], + ['7', {IN=> {f=> '1234567890' x 8}}, {OUT=>"21845 1\n"}], + + ['a-r-1k', '-r', {IN=> {f=> $in_1k}}, {OUT=>"65409 1\n"}], + ['a-s-1k', '-s', {IN=> {f=> $in_1k}}, {OUT=>"33793 2 f\n"}], + ['b-r-2k', '-r', {IN=> {f=> $in_2k}}, {OUT=>"65223 2\n"}], + ['b-s-2k', '-s', {IN=> {f=> $in_2k}}, {OUT=>"4099 4 f\n"}], + + ['1s', '-s', {IN=> {f=> ''}}, {OUT=>"0 0 f\n"}], + ['2s', '-s', {IN=> {f=> 'a'}}, {OUT=>"97 1 f\n"}], + ['3s', '-s', {IN=> {f=> 'abc'}}, {OUT=>"294 1 f\n"}], + ['4s', '-s', {IN=> {f=> 'message digest'}}, {OUT=>"1413 1 f\n"}], + ['5s', '-s', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, + {OUT=>"2847 1 f\n"}], + ['6s', '-s', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}}, + {OUT=>"5387 1 f\n"}], + ['7s', '-s', {IN=> {f=> '1234567890' x 8}}, {OUT=>"4200 1 f\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'sum'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/tac b/tests/misc/tac deleted file mode 100755 index 077cc0c9d..000000000 --- a/tests/misc/tac +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'tac'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $bad_dir = 'no/such/dir'; - -# This must be longer than 16KiB to trigger the double free in coreutils-8.5. -my $long_line = 'o' x (16 * 1024 + 1); - -my @Tests = -( - ['segfault', '-r', {IN=>"a\n"}, {IN=>"b\n"}, {OUT=>"a\nb\n"}], - ['segfault2','-r', {IN=>"a\nb\n"}, {IN=>"1\n2\n"}, {OUT=>"b\na\n2\n1\n"}], - - ['basic-0', '', {IN=>""}, {OUT=>""}], - ['basic-a', '', {IN=>"a"}, {OUT=>"a"}], - ['basic-b', '', {IN=>"\n"}, {OUT=>"\n"}], - ['basic-c', '', {IN=>"a\n"}, {OUT=>"a\n"}], - ['basic-d', '', {IN=>"a\nb"}, {OUT=>"ba\n"}], - ['basic-e', '', {IN=>"a\nb\n"}, {OUT=>"b\na\n"}], - ['basic-f', '', {IN=>"1234567\n8\n"}, {OUT=>"8\n1234567\n"}], - ['basic-g', '', {IN=>"12345678\n9\n"}, {OUT=>"9\n12345678\n"}], - ['basic-h', '', {IN=>"123456\n8\n"}, {OUT=>"8\n123456\n"}], - ['basic-i', '', {IN=>"12345\n8\n"}, {OUT=>"8\n12345\n"}], - ['basic-j', '', {IN=>"1234\n8\n"}, {OUT=>"8\n1234\n"}], - ['basic-k', '', {IN=>"123\n8\n"}, {OUT=>"8\n123\n"}], - - ['opt-b', '-b', {IN=>"\na\nb\nc"}, {OUT=>"\nc\nb\na"}], - ['opt-s', '-s:', {IN=>"a:b:c:"}, {OUT=>"c:b:a:"}], - ['opt-sb', qw(-s : -b), {IN=>":a:b:c"}, {OUT=>":c:b:a"}], - ['opt-r', qw(-r -s '\._+'), - {IN=>"1._2.__3.___4._"}, - {OUT=>"4._3.___2.__1._"}], - - ['opt-r2', qw(-r -s '\._+'), - {IN=>"a.___b.__1._2.__3.___4._"}, - {OUT=>"4._3.___2.__1._b.__a.___"}], - - # This gave incorrect output (.___4._2.__3._1) with tac-1.22. - ['opt-br', qw(-b -r -s '\._+'), - {IN=>"._1._2.__3.___4"}, {OUT=>".___4.__3._2._1"}], - - ['opt-br2', qw(-b -r -s '\._+'), - {IN=>".__x.___y.____z._1._2.__3.___4"}, - {OUT=>".___4.__3._2._1.____z.___y.__x"}], - - ['pipe-bad-tmpdir', - {ENV => "TMPDIR=$bad_dir"}, - {IN_PIPE => "a\n"}, - {ERR_SUBST => "s,'$bad_dir': .*,...,"}, - {ERR => "$prog: failed to create temporary file in ...\n"}, - {EXIT => 1}], - - # coreutils-8.5's tac would double-free its primary buffer. - ['double-free', {IN=>$long_line}, {OUT=>$long_line}], -); - -@Tests = triple_test \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/tac-2-nonseekable b/tests/misc/tac-2-nonseekable deleted file mode 100755 index f980f3b8c..000000000 --- a/tests/misc/tac-2-nonseekable +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# ensure that tac works with two or more non-seekable inputs - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tac - -echo x | tac - - > out 2> err || fail=1 -echo x > exp || fail=1 -compare exp out || fail=1 -compare /dev/null err || fail=1 - -Exit $fail diff --git a/tests/misc/tac-2-nonseekable.sh b/tests/misc/tac-2-nonseekable.sh new file mode 100755 index 000000000..f980f3b8c --- /dev/null +++ b/tests/misc/tac-2-nonseekable.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# ensure that tac works with two or more non-seekable inputs + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tac + +echo x | tac - - > out 2> err || fail=1 +echo x > exp || fail=1 +compare exp out || fail=1 +compare /dev/null err || fail=1 + +Exit $fail diff --git a/tests/misc/tac-continue b/tests/misc/tac-continue deleted file mode 100755 index d9cc550ac..000000000 --- a/tests/misc/tac-continue +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# Ensure that tac processes all command line arguments, even -# when it encounters an error with say the first one. -# With coreutils-5.2.1 and earlier, this test would fail. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tac - -# See if the envvar is defined. -if test x = "x$FULL_PARTITION_TMPDIR"; then - skip_ "FULL_PARTITION_TMPDIR not defined" -fi - -if ! test -d "$FULL_PARTITION_TMPDIR"; then - echo "$0: $FULL_PARTITION_TMPDIR:" \ - "\$FULL_PARTITION_TMPDIR does not specify a directory" 1>&2 - Exit 1 -fi - -fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$" -cleanup_() { rm -f "$fp_tmp"; } - -# Make sure we can create an empty file there (i.e. no shortage of inodes). -if ! touch $fp_tmp; then - echo "$0: $fp_tmp: cannot create empty file" 1>&2 - Exit 1 -fi - -# Make sure that we fail when trying to create a file large enough -# to consume a non-inode block. -if seq 1000 > $fp_tmp 2>/dev/null; then - echo "$0: $FULL_PARTITION_TMPDIR: not a full partition" 1>&2 - Exit 1 -fi - -seq 5 > in - - -# Give tac a fifo command line argument. -# This makes it try to create a temporary file in $TMPDIR. -mkfifo_or_skip_ fifo -seq 1000 > fifo & -TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1 - -cat <<\EOF > exp || fail=1 -5 -4 -3 -2 -1 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/misc/tac-continue.sh b/tests/misc/tac-continue.sh new file mode 100755 index 000000000..d9cc550ac --- /dev/null +++ b/tests/misc/tac-continue.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Ensure that tac processes all command line arguments, even +# when it encounters an error with say the first one. +# With coreutils-5.2.1 and earlier, this test would fail. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tac + +# See if the envvar is defined. +if test x = "x$FULL_PARTITION_TMPDIR"; then + skip_ "FULL_PARTITION_TMPDIR not defined" +fi + +if ! test -d "$FULL_PARTITION_TMPDIR"; then + echo "$0: $FULL_PARTITION_TMPDIR:" \ + "\$FULL_PARTITION_TMPDIR does not specify a directory" 1>&2 + Exit 1 +fi + +fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$" +cleanup_() { rm -f "$fp_tmp"; } + +# Make sure we can create an empty file there (i.e. no shortage of inodes). +if ! touch $fp_tmp; then + echo "$0: $fp_tmp: cannot create empty file" 1>&2 + Exit 1 +fi + +# Make sure that we fail when trying to create a file large enough +# to consume a non-inode block. +if seq 1000 > $fp_tmp 2>/dev/null; then + echo "$0: $FULL_PARTITION_TMPDIR: not a full partition" 1>&2 + Exit 1 +fi + +seq 5 > in + + +# Give tac a fifo command line argument. +# This makes it try to create a temporary file in $TMPDIR. +mkfifo_or_skip_ fifo +seq 1000 > fifo & +TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1 + +cat <<\EOF > exp || fail=1 +5 +4 +3 +2 +1 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/misc/tac.pl b/tests/misc/tac.pl new file mode 100755 index 000000000..077cc0c9d --- /dev/null +++ b/tests/misc/tac.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'tac'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $bad_dir = 'no/such/dir'; + +# This must be longer than 16KiB to trigger the double free in coreutils-8.5. +my $long_line = 'o' x (16 * 1024 + 1); + +my @Tests = +( + ['segfault', '-r', {IN=>"a\n"}, {IN=>"b\n"}, {OUT=>"a\nb\n"}], + ['segfault2','-r', {IN=>"a\nb\n"}, {IN=>"1\n2\n"}, {OUT=>"b\na\n2\n1\n"}], + + ['basic-0', '', {IN=>""}, {OUT=>""}], + ['basic-a', '', {IN=>"a"}, {OUT=>"a"}], + ['basic-b', '', {IN=>"\n"}, {OUT=>"\n"}], + ['basic-c', '', {IN=>"a\n"}, {OUT=>"a\n"}], + ['basic-d', '', {IN=>"a\nb"}, {OUT=>"ba\n"}], + ['basic-e', '', {IN=>"a\nb\n"}, {OUT=>"b\na\n"}], + ['basic-f', '', {IN=>"1234567\n8\n"}, {OUT=>"8\n1234567\n"}], + ['basic-g', '', {IN=>"12345678\n9\n"}, {OUT=>"9\n12345678\n"}], + ['basic-h', '', {IN=>"123456\n8\n"}, {OUT=>"8\n123456\n"}], + ['basic-i', '', {IN=>"12345\n8\n"}, {OUT=>"8\n12345\n"}], + ['basic-j', '', {IN=>"1234\n8\n"}, {OUT=>"8\n1234\n"}], + ['basic-k', '', {IN=>"123\n8\n"}, {OUT=>"8\n123\n"}], + + ['opt-b', '-b', {IN=>"\na\nb\nc"}, {OUT=>"\nc\nb\na"}], + ['opt-s', '-s:', {IN=>"a:b:c:"}, {OUT=>"c:b:a:"}], + ['opt-sb', qw(-s : -b), {IN=>":a:b:c"}, {OUT=>":c:b:a"}], + ['opt-r', qw(-r -s '\._+'), + {IN=>"1._2.__3.___4._"}, + {OUT=>"4._3.___2.__1._"}], + + ['opt-r2', qw(-r -s '\._+'), + {IN=>"a.___b.__1._2.__3.___4._"}, + {OUT=>"4._3.___2.__1._b.__a.___"}], + + # This gave incorrect output (.___4._2.__3._1) with tac-1.22. + ['opt-br', qw(-b -r -s '\._+'), + {IN=>"._1._2.__3.___4"}, {OUT=>".___4.__3._2._1"}], + + ['opt-br2', qw(-b -r -s '\._+'), + {IN=>".__x.___y.____z._1._2.__3.___4"}, + {OUT=>".___4.__3._2._1.____z.___y.__x"}], + + ['pipe-bad-tmpdir', + {ENV => "TMPDIR=$bad_dir"}, + {IN_PIPE => "a\n"}, + {ERR_SUBST => "s,'$bad_dir': .*,...,"}, + {ERR => "$prog: failed to create temporary file in ...\n"}, + {EXIT => 1}], + + # coreutils-8.5's tac would double-free its primary buffer. + ['double-free', {IN=>$long_line}, {OUT=>$long_line}], +); + +@Tests = triple_test \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/tail b/tests/misc/tail deleted file mode 100755 index 41c2f9a99..000000000 --- a/tests/misc/tail +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/perl -# Test tail. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'tail'; -my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'}; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @tv = ( -# test name, options, input, expected output, expected return code -# -['obs-plus-c1', '+2c', 'abcd', 'bcd', 0], -['obs-plus-c2', '+8c', 'abcd', '', 0], -['obs-c3', '-1c', 'abcd', 'd', 0], -['obs-c4', '-9c', 'abcd', 'abcd', 0], -['obs-c5', '-12c', 'x' . ('y' x 12) . 'z', ('y' x 11) . 'z', 0], - -['obs-l1', '-1l', 'x', 'x', 0], -['obs-l2', '-1l', "x\ny\n", "y\n", 0], -['obs-l3', '-1l', "x\ny", "y", 0], -['obs-plus-l4', '+1l', "x\ny\n", "x\ny\n", 0], -['obs-plus-l5', '+2l', "x\ny\n", "y\n", 0], - -# Same as -l tests, but without the 'l'. -['obs-1', '-1', 'x', 'x', 0], -['obs-2', '-1', "x\ny\n", "y\n", 0], -['obs-3', '-1', "x\ny", "y", 0], -['obs-plus-4', '+1', "x\ny\n", "x\ny\n", 0], -['obs-plus-5', '+2', "x\ny\n", "y\n", 0], - -# This is equivalent to +10c -['obs-plus-x1', '+c', 'x' . ('y' x 10) . 'z', 'yyz', 0], -# This is equivalent to +10l -['obs-plus-x2', '+l', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0], -# With no number, this is like -10l -['obs-l', '-l', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], - -['obs-b', '-b', "x\n" x (512 * 10 / 2 + 1), "x\n" x (512 * 10 / 2), 0], - -['err-1', '+cl', '', '', 1, - "$prog: cannot open '+cl' for reading: No such file or directory\n"], - -['err-2', '-cl', '', '', 1, - "$prog: l: invalid number of bytes\n"], - -['err-3', '+2cz', '', '', 1, - "$prog: cannot open '+2cz' for reading: No such file or directory\n"], - -# This should get 'tail: invalid option -- 2' -['err-4', '-2cX', '', '', 1, - "$prog: option used in invalid context -- 2\n"], - -# Since the number is larger than 2^64, this should provoke -# the diagnostic: 'tail: 99999999999999999999: invalid number of bytes' -# on all systems... probably, for now, maybe. -['err-5', '-c99999999999999999999', '', '', 1, - "$prog: 99999999999999999999: invalid number of bytes\n"], -['err-6', '-c --', '', '', 1, - "$prog: -: invalid number of bytes\n", $normalize_filename], - -# Same as -n 10 -['minus-1', '-', '', '', 0], -['minus-2', '-', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], - -['c-2', '-c 2', "abcd\n", "d\n", 0], -['c-2-minus', '-c 2 --', "abcd\n", "d\n", 0], -['c2', '-c2', "abcd\n", "d\n", 0], -['c2-minus', '-c2 --', "abcd\n", "d\n", 0], - -['n-1', '-n 10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], -['n-2', '-n -10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], -['n-3', '-n +10', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0], - -# Accept +0 as synonym for +1. -['n-4', '-n +0', "y\n" x 5, "y\n" x 5, 0], -['n-4a', '-n +1', "y\n" x 5, "y\n" x 5, 0], - -# Note that -0 is *not* a synonym for -1. -['n-5', '-n -0', "y\n" x 5, '', 0], -['n-5a', '-n -1', "y\n" x 5, "y\n", 0], -['n-5b', '-n 0', "y\n" x 5, '', 0], - -# With textutils-1.22, this failed. -['f-pipe-1', '-f -n 1', "a\nb\n", "b\n", 0], -); - -my @Tests; - -foreach my $t (@tv) - { - my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t; - my $e = [$test_name, $flags, {IN=>$in}, {OUT=>$exp}]; - $ret - and push @$e, {EXIT=>$ret}, {ERR=>$err_msg}; - - $test_name =~ /^(obs-plus-|minus-)/ - and push @$e, {ENV=>'_POSIX2_VERSION=199209'}; - - $test_name =~ /^(err-6|c-2)$/ - and push @$e, {ENV=>'_POSIX2_VERSION=200112'}; - - $test_name =~ /^f-pipe-/ - and push @$e, {ENV=>'POSIXLY_CORRECT=1'}; - - push @Tests, $e; - } - -@Tests = triple_test \@Tests; - -# If you run the minus* tests with a FILE arg they'd hang. -# If you run the err-1 or err-3 tests with a FILE, they'd misinterpret -# the arg unless we are using the obsolete form. -@Tests = grep { $_->[0] !~ /^(minus|err-[13])/ || $_->[0] =~ /\.[rp]$/ } @Tests; - -# Using redirection or a file would make this hang. -@Tests = grep { $_->[0] !~ /^f-/ || $_->[0] =~ /\.p$/ } @Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/tail.pl b/tests/misc/tail.pl new file mode 100755 index 000000000..41c2f9a99 --- /dev/null +++ b/tests/misc/tail.pl @@ -0,0 +1,140 @@ +#!/usr/bin/perl +# Test tail. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'tail'; +my $normalize_filename = {ERR_SUBST => 's/^$prog: .*?:/$prog: -:/'}; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @tv = ( +# test name, options, input, expected output, expected return code +# +['obs-plus-c1', '+2c', 'abcd', 'bcd', 0], +['obs-plus-c2', '+8c', 'abcd', '', 0], +['obs-c3', '-1c', 'abcd', 'd', 0], +['obs-c4', '-9c', 'abcd', 'abcd', 0], +['obs-c5', '-12c', 'x' . ('y' x 12) . 'z', ('y' x 11) . 'z', 0], + +['obs-l1', '-1l', 'x', 'x', 0], +['obs-l2', '-1l', "x\ny\n", "y\n", 0], +['obs-l3', '-1l', "x\ny", "y", 0], +['obs-plus-l4', '+1l', "x\ny\n", "x\ny\n", 0], +['obs-plus-l5', '+2l', "x\ny\n", "y\n", 0], + +# Same as -l tests, but without the 'l'. +['obs-1', '-1', 'x', 'x', 0], +['obs-2', '-1', "x\ny\n", "y\n", 0], +['obs-3', '-1', "x\ny", "y", 0], +['obs-plus-4', '+1', "x\ny\n", "x\ny\n", 0], +['obs-plus-5', '+2', "x\ny\n", "y\n", 0], + +# This is equivalent to +10c +['obs-plus-x1', '+c', 'x' . ('y' x 10) . 'z', 'yyz', 0], +# This is equivalent to +10l +['obs-plus-x2', '+l', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0], +# With no number, this is like -10l +['obs-l', '-l', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], + +['obs-b', '-b', "x\n" x (512 * 10 / 2 + 1), "x\n" x (512 * 10 / 2), 0], + +['err-1', '+cl', '', '', 1, + "$prog: cannot open '+cl' for reading: No such file or directory\n"], + +['err-2', '-cl', '', '', 1, + "$prog: l: invalid number of bytes\n"], + +['err-3', '+2cz', '', '', 1, + "$prog: cannot open '+2cz' for reading: No such file or directory\n"], + +# This should get 'tail: invalid option -- 2' +['err-4', '-2cX', '', '', 1, + "$prog: option used in invalid context -- 2\n"], + +# Since the number is larger than 2^64, this should provoke +# the diagnostic: 'tail: 99999999999999999999: invalid number of bytes' +# on all systems... probably, for now, maybe. +['err-5', '-c99999999999999999999', '', '', 1, + "$prog: 99999999999999999999: invalid number of bytes\n"], +['err-6', '-c --', '', '', 1, + "$prog: -: invalid number of bytes\n", $normalize_filename], + +# Same as -n 10 +['minus-1', '-', '', '', 0], +['minus-2', '-', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], + +['c-2', '-c 2', "abcd\n", "d\n", 0], +['c-2-minus', '-c 2 --', "abcd\n", "d\n", 0], +['c2', '-c2', "abcd\n", "d\n", 0], +['c2-minus', '-c2 --', "abcd\n", "d\n", 0], + +['n-1', '-n 10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], +['n-2', '-n -10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0], +['n-3', '-n +10', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0], + +# Accept +0 as synonym for +1. +['n-4', '-n +0', "y\n" x 5, "y\n" x 5, 0], +['n-4a', '-n +1', "y\n" x 5, "y\n" x 5, 0], + +# Note that -0 is *not* a synonym for -1. +['n-5', '-n -0', "y\n" x 5, '', 0], +['n-5a', '-n -1', "y\n" x 5, "y\n", 0], +['n-5b', '-n 0', "y\n" x 5, '', 0], + +# With textutils-1.22, this failed. +['f-pipe-1', '-f -n 1', "a\nb\n", "b\n", 0], +); + +my @Tests; + +foreach my $t (@tv) + { + my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t; + my $e = [$test_name, $flags, {IN=>$in}, {OUT=>$exp}]; + $ret + and push @$e, {EXIT=>$ret}, {ERR=>$err_msg}; + + $test_name =~ /^(obs-plus-|minus-)/ + and push @$e, {ENV=>'_POSIX2_VERSION=199209'}; + + $test_name =~ /^(err-6|c-2)$/ + and push @$e, {ENV=>'_POSIX2_VERSION=200112'}; + + $test_name =~ /^f-pipe-/ + and push @$e, {ENV=>'POSIXLY_CORRECT=1'}; + + push @Tests, $e; + } + +@Tests = triple_test \@Tests; + +# If you run the minus* tests with a FILE arg they'd hang. +# If you run the err-1 or err-3 tests with a FILE, they'd misinterpret +# the arg unless we are using the obsolete form. +@Tests = grep { $_->[0] !~ /^(minus|err-[13])/ || $_->[0] =~ /\.[rp]$/ } @Tests; + +# Using redirection or a file would make this hang. +@Tests = grep { $_->[0] !~ /^f-/ || $_->[0] =~ /\.p$/ } @Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/tee b/tests/misc/tee deleted file mode 100755 index 4c17316d3..000000000 --- a/tests/misc/tee +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# test for basic tee functionality. - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tee - -echo line >sample || framework_failure_ -nums=$(seq 9) || framework_failure_ - -for n in 0 $nums; do - files=$(seq $n) - rm -f $files - tee $files out || fail=1 - for f in out $files; do - compare sample $f || fail=1 - done -done - -Exit $fail diff --git a/tests/misc/tee-dash b/tests/misc/tee-dash deleted file mode 100755 index 8ee0820bd..000000000 --- a/tests/misc/tee-dash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# test for "tee -". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tee - -tee - . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tee + +tee - . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tee + +echo line >sample || framework_failure_ +nums=$(seq 9) || framework_failure_ + +for n in 0 $nums; do + files=$(seq $n) + rm -f $files + tee $files out || fail=1 + for f in out $files; do + compare sample $f || fail=1 + done +done + +Exit $fail diff --git a/tests/misc/test b/tests/misc/test deleted file mode 100755 index ac30c3790..000000000 --- a/tests/misc/test +++ /dev/null @@ -1,197 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $limits = getlimits (); - -my $prog = 'test'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -sub digest_test ($) -{ - my ($t) = @_; - my @args; - my $ret = 0; - my @list_of_hashref; - foreach my $e (@$t) - { - !ref $e - and push (@args, $e), next; - ref $e eq 'HASH' - or (warn "$0: $t->[0]: unexpected entry type\n"), next; - - exists $e->{EXIT} - and $ret = $e->{EXIT}, next; - - push @list_of_hashref, $e; - } - shift @args; # discard test name - my $flags = join ' ', @args; - - return ($flags, $ret, \@list_of_hashref); -} - -sub add_inverse_op_tests($) -{ - my ($tests) = @_; - my @new; - - my %inverse_op = - ( - eq => 'ne', - lt => 'ge', - gt => 'le', - ); - - foreach my $t (@$tests) - { - push @new, $t; - - my $test_name = $t->[0]; - my ($flags, $ret, $LoH) = digest_test $t; - - # Generate corresponding tests of inverse ops. - # E.g. generate tests of '-ge' from those of '-lt'. - foreach my $op (qw(gt lt eq)) - { - if ($test_name =~ /$op-/ && $flags =~ / -$op /) - { - my $inv = $inverse_op{$op}; - $test_name =~ s/$op/$inv/; - $flags =~ s/-$op/-$inv/; - $ret = 1 - $ret; - push (@new, [$test_name, $flags, {EXIT=>$ret}, @$LoH]); - } - } - } - return @new; -} - -sub add_pn_tests($) -{ - my ($tests) = @_; - my @new; - - # Generate parenthesized and negated versions of each test. - # There are a few exceptions. - my %not_N = map {$_ => 1} qw (1a); - my %not_P = map {$_ => 1} qw (1a - streq-6 strne-6 - paren-1 paren-2 paren-3 paren-4 paren-5); - foreach my $t (@$tests) - { - push @new, $t; - - my $test_name = $t->[0]; - my ($flags, $ret, $LoH) = digest_test $t; - next if $ret == 2; - - push (@new, ["N-$test_name", "! $flags", {EXIT=>1-$ret}, @$LoH]) - unless $not_N{$test_name}; - push (@new, ["P-$test_name", "'(' $flags ')'", {EXIT=>$ret}, @$LoH]) - unless $not_P{$test_name}; - push (@new, ["NP-$test_name", "! '(' $flags ')'", {EXIT=>1-$ret}, @$LoH]) - unless $not_P{$test_name}; - push (@new, ["NNP-$test_name", "! ! '(' $flags ')'", {EXIT=>$ret, @$LoH}]) - unless $not_P{$test_name}; - } - - return @new; -} - -my @Tests = -( - ['1a', {EXIT=>1}], - ['1b', qw(-z '')], - ['1c', 'any-string'], - ['1d', qw(-n any-string)], - ['1e', "''", {EXIT=>1}], - ['1f', '-'], - ['1g', '--'], - ['1h', '-0'], - ['1i', '-f'], - ['1j', '--help'], - ['1k', '--version'], - - ['streq-1', qw(t = t)], - ['streq-2', qw(t = f), {EXIT=>1}], - ['streqeq-1', qw(t == t)], - ['streqeq-2', qw(t == f), {EXIT=>1}], - ['streq-3', qw(! = !)], - ['streq-4', qw(= = =)], - ['streq-5', "'(' = '('"], - ['streq-6', "'(' = ')'", {EXIT=>1}], - ['strne-1', qw(t != t), {EXIT=>1}], - ['strne-2', qw(t != f)], - ['strne-3', qw(! != !), {EXIT=>1}], - ['strne-4', qw(= != =), {EXIT=>1}], - ['strne-5', "'(' != '('", {EXIT=>1}], - ['strne-6', "'(' != ')'"], - - ['and-1', qw(t -a t)], - ['and-2', qw('' -a t), {EXIT=>1}], - ['and-3', qw(t -a ''), {EXIT=>1}], - ['and-4', qw('' -a ''), {EXIT=>1}], - - ['or-1', qw(t -o t)], - ['or-2', qw('' -o t)], - ['or-3', qw(t -o '')], - ['or-4', qw('' -o ''), {EXIT=>1}], - - ['eq-1', qw(9 -eq 9)], - ['eq-2', qw(0 -eq 0)], - ['eq-3', qw(0 -eq 00)], - ['eq-4', qw(8 -eq 9), {EXIT=>1}], - ['eq-5', qw(1 -eq 0), {EXIT=>1}], - ['eq-6', "$limits->{UINTMAX_OFLOW} -eq 0", {EXIT=>1}], - - ['gt-1', qw(5 -gt 5), {EXIT=>1}], - ['gt-2', qw(5 -gt 4)], - ['gt-3', qw(4 -gt 5), {EXIT=>1}], - ['gt-4', qw(-1 -gt -2)], - ['gt-5', "$limits->{UINTMAX_OFLOW} -gt $limits->{INTMAX_UFLOW}"], - - ['lt-1', qw(5 -lt 5), {EXIT=>1}], - ['lt-2', qw(5 -lt 4), {EXIT=>1}], - ['lt-3', qw(4 -lt 5)], - ['lt-4', qw(-1 -lt -2), {EXIT=>1}], - ['lt-5', "$limits->{INTMAX_UFLOW} -lt $limits->{UINTMAX_OFLOW}"], - - ['inv-1', qw(0x0 -eq 00), {EXIT=>2}, - {ERR=>"$prog: invalid integer '0x0'\n"}], - - ['t1', "-t"], - ['t2', qw(-t 1), {EXIT=>1}], - - ['paren-1', "'(' '' ')'", {EXIT=>1}], - ['paren-2', "'(' '(' ')'"], - ['paren-3', "'(' ')' ')'"], - ['paren-4', "'(' ! ')'"], - ['paren-5', "'(' -a ')'"], -); - -@Tests = add_inverse_op_tests \@Tests; -@Tests = add_pn_tests \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/test-diag b/tests/misc/test-diag deleted file mode 100755 index 9c0ce227f..000000000 --- a/tests/misc/test-diag +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -# Test the diagnostics of "test". - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = "$ENV{abs_top_builddir}/src/test"; -my @Tests = - ( - # In coreutils-5.93, this diagnostic lacked the newline. - ['o', '-o arg', {ERR => "test: extra argument '-o'\n"}, - {ERR_SUBST => 's!^.*:!test:!'}, - {EXIT => 2}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/test-diag.pl b/tests/misc/test-diag.pl new file mode 100755 index 000000000..9c0ce227f --- /dev/null +++ b/tests/misc/test-diag.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +# Test the diagnostics of "test". + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = "$ENV{abs_top_builddir}/src/test"; +my @Tests = + ( + # In coreutils-5.93, this diagnostic lacked the newline. + ['o', '-o arg', {ERR => "test: extra argument '-o'\n"}, + {ERR_SUBST => 's!^.*:!test:!'}, + {EXIT => 2}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/test.pl b/tests/misc/test.pl new file mode 100755 index 000000000..ac30c3790 --- /dev/null +++ b/tests/misc/test.pl @@ -0,0 +1,197 @@ +#!/usr/bin/perl + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $limits = getlimits (); + +my $prog = 'test'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +sub digest_test ($) +{ + my ($t) = @_; + my @args; + my $ret = 0; + my @list_of_hashref; + foreach my $e (@$t) + { + !ref $e + and push (@args, $e), next; + ref $e eq 'HASH' + or (warn "$0: $t->[0]: unexpected entry type\n"), next; + + exists $e->{EXIT} + and $ret = $e->{EXIT}, next; + + push @list_of_hashref, $e; + } + shift @args; # discard test name + my $flags = join ' ', @args; + + return ($flags, $ret, \@list_of_hashref); +} + +sub add_inverse_op_tests($) +{ + my ($tests) = @_; + my @new; + + my %inverse_op = + ( + eq => 'ne', + lt => 'ge', + gt => 'le', + ); + + foreach my $t (@$tests) + { + push @new, $t; + + my $test_name = $t->[0]; + my ($flags, $ret, $LoH) = digest_test $t; + + # Generate corresponding tests of inverse ops. + # E.g. generate tests of '-ge' from those of '-lt'. + foreach my $op (qw(gt lt eq)) + { + if ($test_name =~ /$op-/ && $flags =~ / -$op /) + { + my $inv = $inverse_op{$op}; + $test_name =~ s/$op/$inv/; + $flags =~ s/-$op/-$inv/; + $ret = 1 - $ret; + push (@new, [$test_name, $flags, {EXIT=>$ret}, @$LoH]); + } + } + } + return @new; +} + +sub add_pn_tests($) +{ + my ($tests) = @_; + my @new; + + # Generate parenthesized and negated versions of each test. + # There are a few exceptions. + my %not_N = map {$_ => 1} qw (1a); + my %not_P = map {$_ => 1} qw (1a + streq-6 strne-6 + paren-1 paren-2 paren-3 paren-4 paren-5); + foreach my $t (@$tests) + { + push @new, $t; + + my $test_name = $t->[0]; + my ($flags, $ret, $LoH) = digest_test $t; + next if $ret == 2; + + push (@new, ["N-$test_name", "! $flags", {EXIT=>1-$ret}, @$LoH]) + unless $not_N{$test_name}; + push (@new, ["P-$test_name", "'(' $flags ')'", {EXIT=>$ret}, @$LoH]) + unless $not_P{$test_name}; + push (@new, ["NP-$test_name", "! '(' $flags ')'", {EXIT=>1-$ret}, @$LoH]) + unless $not_P{$test_name}; + push (@new, ["NNP-$test_name", "! ! '(' $flags ')'", {EXIT=>$ret, @$LoH}]) + unless $not_P{$test_name}; + } + + return @new; +} + +my @Tests = +( + ['1a', {EXIT=>1}], + ['1b', qw(-z '')], + ['1c', 'any-string'], + ['1d', qw(-n any-string)], + ['1e', "''", {EXIT=>1}], + ['1f', '-'], + ['1g', '--'], + ['1h', '-0'], + ['1i', '-f'], + ['1j', '--help'], + ['1k', '--version'], + + ['streq-1', qw(t = t)], + ['streq-2', qw(t = f), {EXIT=>1}], + ['streqeq-1', qw(t == t)], + ['streqeq-2', qw(t == f), {EXIT=>1}], + ['streq-3', qw(! = !)], + ['streq-4', qw(= = =)], + ['streq-5', "'(' = '('"], + ['streq-6', "'(' = ')'", {EXIT=>1}], + ['strne-1', qw(t != t), {EXIT=>1}], + ['strne-2', qw(t != f)], + ['strne-3', qw(! != !), {EXIT=>1}], + ['strne-4', qw(= != =), {EXIT=>1}], + ['strne-5', "'(' != '('", {EXIT=>1}], + ['strne-6', "'(' != ')'"], + + ['and-1', qw(t -a t)], + ['and-2', qw('' -a t), {EXIT=>1}], + ['and-3', qw(t -a ''), {EXIT=>1}], + ['and-4', qw('' -a ''), {EXIT=>1}], + + ['or-1', qw(t -o t)], + ['or-2', qw('' -o t)], + ['or-3', qw(t -o '')], + ['or-4', qw('' -o ''), {EXIT=>1}], + + ['eq-1', qw(9 -eq 9)], + ['eq-2', qw(0 -eq 0)], + ['eq-3', qw(0 -eq 00)], + ['eq-4', qw(8 -eq 9), {EXIT=>1}], + ['eq-5', qw(1 -eq 0), {EXIT=>1}], + ['eq-6', "$limits->{UINTMAX_OFLOW} -eq 0", {EXIT=>1}], + + ['gt-1', qw(5 -gt 5), {EXIT=>1}], + ['gt-2', qw(5 -gt 4)], + ['gt-3', qw(4 -gt 5), {EXIT=>1}], + ['gt-4', qw(-1 -gt -2)], + ['gt-5', "$limits->{UINTMAX_OFLOW} -gt $limits->{INTMAX_UFLOW}"], + + ['lt-1', qw(5 -lt 5), {EXIT=>1}], + ['lt-2', qw(5 -lt 4), {EXIT=>1}], + ['lt-3', qw(4 -lt 5)], + ['lt-4', qw(-1 -lt -2), {EXIT=>1}], + ['lt-5', "$limits->{INTMAX_UFLOW} -lt $limits->{UINTMAX_OFLOW}"], + + ['inv-1', qw(0x0 -eq 00), {EXIT=>2}, + {ERR=>"$prog: invalid integer '0x0'\n"}], + + ['t1', "-t"], + ['t2', qw(-t 1), {EXIT=>1}], + + ['paren-1', "'(' '' ')'", {EXIT=>1}], + ['paren-2', "'(' '(' ')'"], + ['paren-3', "'(' ')' ')'"], + ['paren-4', "'(' ! ')'"], + ['paren-5', "'(' -a ')'"], +); + +@Tests = add_inverse_op_tests \@Tests; +@Tests = add_pn_tests \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, \$prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/timeout b/tests/misc/timeout deleted file mode 100755 index 5f4e9ec2a..000000000 --- a/tests/misc/timeout +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# Validate timeout basic operation - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ timeout - -# no timeout -timeout 10 true || fail=1 - -# no timeout (suffix check) -timeout 1d true || fail=1 - -# disabled timeout -timeout 0 true || fail=1 - -# exit status propagation -timeout 10 sh -c 'exit 2' -test $? = 2 || fail=1 - -# timeout -timeout 1 sleep 10 -test $? = 124 || fail=1 - -# kill delay. Note once the initial timeout triggers, -# the exit status will be 124 even if the command -# exits on its own accord. -timeout -s0 -k1 1 sleep 10 -test $? = 124 && fail=1 - -# Ensure 'timeout' is immune to parent's SIGCHLD handler -# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. -( - # ash doesn't support "trap '' CHLD"; it knows only signal numbers. - sig=$("$abs_top_builddir/src/kill" -l CHLD 2>/dev/null) && trap '' $sig - - exec timeout 10 true -) || fail=1 - -# Don't be confused when starting off with a child (Bug#9098). -out=$(sleep 1 & exec timeout 2 sh -c 'sleep 3; echo foo') -status=$? -test "$out" = "" && test $status = 124 || fail=1 - -Exit $fail diff --git a/tests/misc/timeout-group b/tests/misc/timeout-group deleted file mode 100755 index 7a08bb3a5..000000000 --- a/tests/misc/timeout-group +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -# test program group handling - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ timeout - -# construct a program group hierarchy as follows: -# timeout-group - foreground group -# group.sh - separate group -# timeout.cmd - same group as group.sh -# -# We then send a SIGINT to the "separate group" -# to simulate what happens when a Ctrl-C -# is sent to the foreground group. - -setsid true || skip_ "setsid required to control groups" - -cat > timeout.cmd <<\EOF -#!/bin/sh -trap 'touch int.received; exit' INT -touch timeout.running -sleep $1 -EOF -chmod a+x timeout.cmd - -cat > group.sh <<\EOF -#!/bin/sh -trap '' INT -timeout --foreground 25 ./timeout.cmd 20& -wait -EOF -chmod a+x group.sh - -check_timeout_cmd_running() -{ - local delay="$1" - test -e timeout.running || - { sleep $delay; return 1; } -} - - -# Start above script in its own group. -# We could use timeout for this, but that assumes an implementation. -setsid ./group.sh & -# Wait 6.3s for timeout.cmd to start -retry_delay_ check_timeout_cmd_running .1 6 || fail=1 -# Simulate a Ctrl-C to the group to test timely exit -# Note dash doesn't support signalling groups (a leading -) -env kill -INT -- -$! -wait -test -e int.received || fail=1 - -rm -f int.received timeout.running - - -# Ensure cascaded timeouts work -# or more generally, ensure we timeout -# commands that create their own group -# This didn't work before 8.13. - -start=$(date +%s) - -# Note the first timeout must send a signal that -# the second is handling for it to be propagated to the command. -# SIGINT, SIGTERM, SIGALRM etc. are implicit. -timeout -sALRM 30 timeout -sINT 25 ./timeout.cmd 20& -pid=$! -# Wait 6.3s for timeout.cmd to start -retry_delay_ check_timeout_cmd_running .1 6 || fail=1 -kill -ALRM $pid # trigger the alarm of the first timeout command -wait $pid -ret=$? -test $ret -eq 124 || - skip_ "timeout returned $ret. SIGALRM not handled?" -test -e int.received || fail=1 - -end=$(date +%s) - -test $(expr $end - $start) -lt 20 || - skip_ "timeout.cmd didn't receive a signal until after sleep?" - -Exit $fail diff --git a/tests/misc/timeout-group.sh b/tests/misc/timeout-group.sh new file mode 100755 index 000000000..7a08bb3a5 --- /dev/null +++ b/tests/misc/timeout-group.sh @@ -0,0 +1,97 @@ +#!/bin/sh +# test program group handling + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ timeout + +# construct a program group hierarchy as follows: +# timeout-group - foreground group +# group.sh - separate group +# timeout.cmd - same group as group.sh +# +# We then send a SIGINT to the "separate group" +# to simulate what happens when a Ctrl-C +# is sent to the foreground group. + +setsid true || skip_ "setsid required to control groups" + +cat > timeout.cmd <<\EOF +#!/bin/sh +trap 'touch int.received; exit' INT +touch timeout.running +sleep $1 +EOF +chmod a+x timeout.cmd + +cat > group.sh <<\EOF +#!/bin/sh +trap '' INT +timeout --foreground 25 ./timeout.cmd 20& +wait +EOF +chmod a+x group.sh + +check_timeout_cmd_running() +{ + local delay="$1" + test -e timeout.running || + { sleep $delay; return 1; } +} + + +# Start above script in its own group. +# We could use timeout for this, but that assumes an implementation. +setsid ./group.sh & +# Wait 6.3s for timeout.cmd to start +retry_delay_ check_timeout_cmd_running .1 6 || fail=1 +# Simulate a Ctrl-C to the group to test timely exit +# Note dash doesn't support signalling groups (a leading -) +env kill -INT -- -$! +wait +test -e int.received || fail=1 + +rm -f int.received timeout.running + + +# Ensure cascaded timeouts work +# or more generally, ensure we timeout +# commands that create their own group +# This didn't work before 8.13. + +start=$(date +%s) + +# Note the first timeout must send a signal that +# the second is handling for it to be propagated to the command. +# SIGINT, SIGTERM, SIGALRM etc. are implicit. +timeout -sALRM 30 timeout -sINT 25 ./timeout.cmd 20& +pid=$! +# Wait 6.3s for timeout.cmd to start +retry_delay_ check_timeout_cmd_running .1 6 || fail=1 +kill -ALRM $pid # trigger the alarm of the first timeout command +wait $pid +ret=$? +test $ret -eq 124 || + skip_ "timeout returned $ret. SIGALRM not handled?" +test -e int.received || fail=1 + +end=$(date +%s) + +test $(expr $end - $start) -lt 20 || + skip_ "timeout.cmd didn't receive a signal until after sleep?" + +Exit $fail diff --git a/tests/misc/timeout-parameters b/tests/misc/timeout-parameters deleted file mode 100755 index c7d663092..000000000 --- a/tests/misc/timeout-parameters +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# Validate timeout parameter combinations - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ timeout -getlimits_ - - -# internal errors are 125, distinct from execution failure - -# invalid timeout -timeout invalid sleep 0 -test $? = 125 || fail=1 - -# invalid kill delay -timeout --kill-after=invalid 1 sleep 0 -test $? = 125 || fail=1 - -# invalid timeout suffix -timeout 42D sleep 0 -test $? = 125 || fail=1 - -# It was seen on 32 bit Linux/HPPA that a kernel time_t overflowed, -# thus causing the timer to fire immediately. -# So verify that doesn't happen before checking large timeouts -KERNEL_OVERFLOW_LIMIT=$(expr $TIME_T_MAX - $(date +%s) + 100) -timeout $KERNEL_OVERFLOW_LIMIT sleep 0 -if test $? != 124; then - # timeout overflow - timeout $UINT_OFLOW sleep 0 - test $? = 0 || fail=1 - - # timeout overflow - timeout $(expr $UINT_MAX / 86400 + 1)d sleep 0 - test $? = 0 || fail=1 - - # timeout overflow - timeout 999999999999999999999999999999999999999999999999999999999999d sleep 0 - test $? = 0 || fail=1 - - # floating point notation - timeout 2.34e+5d sleep 0 - test $? = 0 || fail=1 -fi - -# floating point notation -timeout 2.34 sleep 0 -test $? = 0 || fail=1 - -# nanoseconds potentially supported -timeout .999999999 sleep 0 || fail=1 - -# invalid signal spec -timeout --signal=invalid 1 sleep 0 -test $? = 125 || fail=1 - -# invalid command -timeout 10 . -test $? = 126 || fail=1 - -# no such command -timeout 10 no_such -test $? = 127 || fail=1 - -Exit $fail diff --git a/tests/misc/timeout-parameters.sh b/tests/misc/timeout-parameters.sh new file mode 100755 index 000000000..c7d663092 --- /dev/null +++ b/tests/misc/timeout-parameters.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Validate timeout parameter combinations + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ timeout +getlimits_ + + +# internal errors are 125, distinct from execution failure + +# invalid timeout +timeout invalid sleep 0 +test $? = 125 || fail=1 + +# invalid kill delay +timeout --kill-after=invalid 1 sleep 0 +test $? = 125 || fail=1 + +# invalid timeout suffix +timeout 42D sleep 0 +test $? = 125 || fail=1 + +# It was seen on 32 bit Linux/HPPA that a kernel time_t overflowed, +# thus causing the timer to fire immediately. +# So verify that doesn't happen before checking large timeouts +KERNEL_OVERFLOW_LIMIT=$(expr $TIME_T_MAX - $(date +%s) + 100) +timeout $KERNEL_OVERFLOW_LIMIT sleep 0 +if test $? != 124; then + # timeout overflow + timeout $UINT_OFLOW sleep 0 + test $? = 0 || fail=1 + + # timeout overflow + timeout $(expr $UINT_MAX / 86400 + 1)d sleep 0 + test $? = 0 || fail=1 + + # timeout overflow + timeout 999999999999999999999999999999999999999999999999999999999999d sleep 0 + test $? = 0 || fail=1 + + # floating point notation + timeout 2.34e+5d sleep 0 + test $? = 0 || fail=1 +fi + +# floating point notation +timeout 2.34 sleep 0 +test $? = 0 || fail=1 + +# nanoseconds potentially supported +timeout .999999999 sleep 0 || fail=1 + +# invalid signal spec +timeout --signal=invalid 1 sleep 0 +test $? = 125 || fail=1 + +# invalid command +timeout 10 . +test $? = 126 || fail=1 + +# no such command +timeout 10 no_such +test $? = 127 || fail=1 + +Exit $fail diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh new file mode 100755 index 000000000..5f4e9ec2a --- /dev/null +++ b/tests/misc/timeout.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# Validate timeout basic operation + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ timeout + +# no timeout +timeout 10 true || fail=1 + +# no timeout (suffix check) +timeout 1d true || fail=1 + +# disabled timeout +timeout 0 true || fail=1 + +# exit status propagation +timeout 10 sh -c 'exit 2' +test $? = 2 || fail=1 + +# timeout +timeout 1 sleep 10 +test $? = 124 || fail=1 + +# kill delay. Note once the initial timeout triggers, +# the exit status will be 124 even if the command +# exits on its own accord. +timeout -s0 -k1 1 sleep 10 +test $? = 124 && fail=1 + +# Ensure 'timeout' is immune to parent's SIGCHLD handler +# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. +( + # ash doesn't support "trap '' CHLD"; it knows only signal numbers. + sig=$("$abs_top_builddir/src/kill" -l CHLD 2>/dev/null) && trap '' $sig + + exec timeout 10 true +) || fail=1 + +# Don't be confused when starting off with a child (Bug#9098). +out=$(sleep 1 & exec timeout 2 sh -c 'sleep 3; echo foo') +status=$? +test "$out" = "" && test $status = 124 || fail=1 + +Exit $fail diff --git a/tests/misc/tr b/tests/misc/tr deleted file mode 100755 index 89f777757..000000000 --- a/tests/misc/tr +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'tr'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $map_all_to_1 = - "$prog: when translating with complemented character classes,\n" - . "string2 must map all characters in the domain to one\n"; - -my @Tests = -( - ['1', qw(abcd '[]*]'), {IN=>'abcd'}, {OUT=>']]]]'}], - ['2', qw(abc '[%*]xyz'), {IN=>'abc'}, {OUT=>'xyz'}], - ['3', qw('' '[.*]'), {IN=>'abc'}, {OUT=>'abc'}], - - # Test --truncate-set1 behavior when string1 is longer than string2 - ['4', qw(-t abcd xy), {IN=>'abcde'}, {OUT=>'xycde'}], - # Test bsd behavior (the default) when string1 is longer than string2 - ['5', qw(abcd xy), {IN=>'abcde'}, {OUT=>'xyyye'}], - # Do it the posix way - ['6', qw(abcd 'x[y*]'), {IN=>'abcde'}, {OUT=>'xyyye'}], - ['7', qw(-s a-p '%[.*]$'), {IN=>'abcdefghijklmnop'}, {OUT=>'%.$'}], - ['8', qw(-s a-p '[.*]$'), {IN=>'abcdefghijklmnop'}, {OUT=>'.$'}], - ['9', qw(-s a-p '%[.*]'), {IN=>'abcdefghijklmnop'}, {OUT=>'%.'}], - ['a', qw(-s '[a-z]'), {IN=>'aabbcc'}, {OUT=>'abc'}], - ['b', qw(-s '[a-c]'), {IN=>'aabbcc'}, {OUT=>'abc'}], - ['c', qw(-s '[a-b]'), {IN=>'aabbcc'}, {OUT=>'abcc'}], - ['d', qw(-s '[b-c]'), {IN=>'aabbcc'}, {OUT=>'aabc'}], - ['e', qw(-s '[\0-\5]'), - {IN=>"\0\0a\1\1b\2\2\2c\3\3\3d\4\4\4\4e\5\5"}, {OUT=>"\0a\1b\2c\3d\4e\5"}], - # tests of delete - ['f', qw(-d '[=[=]'), {IN=>'[[[[[[[]]]]]]]]'}, {OUT=>']]]]]]]]'}], - ['g', qw(-d '[=]=]'), {IN=>'[[[[[[[]]]]]]]]'}, {OUT=>'[[[[[[['}], - ['h', qw(-d '[:xdigit:]'), {IN=>'0123456789acbdefABCDEF'}, {OUT=>''}], - ['i', qw(-d '[:xdigit:]'), {IN=>'w0x1y2z3456789acbdefABCDEFz'}, - {OUT=>'wxyzz'}], - ['j', qw(-d '[:digit:]'), {IN=>'0123456789'}, {OUT=>''}], - ['k', qw(-d '[:digit:]'), - {IN=>'a0b1c2d3e4f5g6h7i8j9k'}, {OUT=>'abcdefghijk'}], - ['l', qw(-d '[:lower:]'), {IN=>'abcdefghijklmnopqrstuvwxyz'}, {OUT=>''}], - ['m', qw(-d '[:upper:]'), {IN=>'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}, {OUT=>''}], - ['n', qw(-d '[:lower:][:upper:]'), - {IN=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'}, {OUT=>''}], - ['o', qw(-d '[:alpha:]'), - {IN=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'}, {OUT=>''}], - ['p', qw(-d '[:alnum:]'), - {IN=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'}, - {OUT=>''}], - ['q', qw(-d '[:alnum:]'), - {IN=>'.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'}, - {OUT=>'..'}], - ['r', qw(-ds '[:alnum:]' .), - {IN=>'.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'}, - {OUT=>'.'}], - - # The classic example, with string2 BSD-style - ['s', qw(-cs '[:alnum:]' '\n'), - {IN=>'The big black fox jumped over the fence.'}, - {OUT=>"The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n"}], - - # The classic example, POSIX-style - ['t', qw(-cs '[:alnum:]' '[\n*]'), - {IN=>'The big black fox jumped over the fence.'}, - {OUT=>"The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n"}], - ['u', qw(-ds b a), {IN=>'aabbaa'}, {OUT=>'a'}], - ['v', qw(-ds '[:xdigit:]' Z), {IN=>'ZZ0123456789acbdefABCDEFZZ'}, {OUT=>'Z'}], - - # Try some data with 8th bit set in case something is mistakenly - # sign-extended. - ['w', qw(-ds '\350' '\345'), - {IN=>"\300\301\377\345\345\350\345"}, - {OUT=>"\300\301\377\345"}], - ['x', qw(-s abcdefghijklmn '[:*016]'), - {IN=>'abcdefghijklmnop'}, {OUT=>':op'}], - ['y', qw(-d a-z), {IN=>'abc $code'}, {OUT=>' $'}], - ['z', qw(-ds a-z '$.'), {IN=>'a.b.c $$$$code\\'}, {OUT=>'. $\\'}], - - # Make sure that a-a is accepted. - ['range-a-a', qw(a-a z), {IN=>'abc'}, {OUT=>'zbc'}], - # - ['null', qw(a ''), {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: when not truncating set1, string2 must be non-empty\n"}], - ['upcase', qw('[:lower:]' '[:upper:]'), - {IN=>'abcxyzABCXYZ'}, - {OUT=>'ABCXYZABCXYZ'}], - ['dncase', qw('[:upper:]' '[:lower:]'), - {IN=>'abcxyzABCXYZ'}, - {OUT=>'abcxyzabcxyz'}], - # - ['rep-cclass', qw('a[=*2][=c=]' xyyz), {IN=>'a=c'}, {OUT=>'xyz'}], - ['rep-1', qw('[:*3][:digit:]' a-m), {IN=>':1239'}, {OUT=>'cefgm'}], - ['rep-2', qw('a[b*512]c' '1[x*]2'), {IN=>'abc'}, {OUT=>'1x2'}], - ['rep-3', qw('a[b*513]c' '1[x*]2'), {IN=>'abc'}, {OUT=>'1x2'}], - # Another couple octal repeat count tests. - ['o-rep-1', qw('[b*08]' '[x*]'), {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: invalid repeat count '08' in [c*n] construct\n"}], - ['o-rep-2', qw('[b*010]cd' '[a*7]BC[x*]'), {IN=>'bcd'}, {OUT=>'BCx'}], - - ['esc', qw('a\-z' A-Z), {IN=>'abc-z'}, {OUT=>'AbcBC'}], - ['bs-055', qw('a\055b' def), {IN=>"a\055b"}, {OUT=>'def'}], - ['bs-at-end', qw('\\' x), {IN=>"\\"}, {OUT=>'x'}, - {ERR=>"$prog: warning: an unescaped backslash at end of " - . "string is not portable\n"}], - - # - # From Ross - ['ross-0a', qw(-cs '[:upper:]' 'X[Y*]'), {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>$map_all_to_1}], - ['ross-0b', qw(-cs '[:cntrl:]' 'X[Y*]'), {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>$map_all_to_1}], - ['ross-1a', qw(-cs '[:upper:]' '[X*]'), - {IN=>'AMZamz123.-+AMZ'}, {OUT=>'AMZXAMZ'}], - ['ross-1b', qw(-cs '[:upper:][:digit:]' '[Z*]'), {IN=>''}, {OUT=>''}], - ['ross-2', qw(-dcs '[:lower:]' n-rs-z), - {IN=>'amzAMZ123.-+amz'}, {OUT=>'amzamz'}], - ['ross-3', qw(-ds '[:xdigit:]' '[:alnum:]'), - {IN=>'.ZABCDEFGzabcdefg.0123456788899.GG'}, {OUT=>'.ZGzg..G'}], - ['ross-4', qw(-dcs '[:alnum:]' '[:digit:]'), {IN=>''}, {OUT=>''}], - ['ross-5', qw(-dc '[:lower:]'), {IN=>''}, {OUT=>''}], - ['ross-6', qw(-dc '[:upper:]'), {IN=>''}, {OUT=>''}], - - # Ensure that these fail. - # Prior to 2.0.20, each would evoke a failed assertion. - ['empty-eq', qw('[==]' x), {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: missing equivalence class character '[==]'\n"}], - ['empty-cc', qw('[::]' x), {IN=>''}, {OUT=>''}, {EXIT=>1}, - {ERR=>"$prog: missing character class name '[::]'\n"}], - - # Weird repeat counts. - ['repeat-bs-9', qw(abc '[b*\9]'), {IN=>'abcd'}, {OUT=>'[b*d'}], - ['repeat-0', qw(abc '[b*0]'), {IN=>'abcd'}, {OUT=>'bbbd'}], - ['repeat-zeros', qw(abc '[b*00000000000000000000]'), - {IN=>'abcd'}, {OUT=>'bbbd'}], - ['repeat-compl', qw(-c '[a*65536]\n' '[b*]'), {IN=>'abcd'}, {OUT=>'abbb'}], - ['repeat-xC', qw(-C '[a*65536]\n' '[b*]'), {IN=>'abcd'}, {OUT=>'abbb'}], - - # From Glenn Fowler. - ['fowler-1', qw(ah -H), {IN=>'aha'}, {OUT=>'-H-'}], - - # Up to coreutils-6.9, this would provoke a failed assertion. - ['no-abort-1', qw(-c a '[b*256]'), {IN=>'abc'}, {OUT=>'abb'}], -); - -@Tests = triple_test \@Tests; - -# tr takes its input only from stdin, not from a file argument, so -# remove the tests that provide file arguments and keep only the ones -# generated by triple_test (identifiable by their .r and .p suffixes). -@Tests = grep {$_->[0] =~ /\.[pr]$/} @Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/tr-case-class b/tests/misc/tr-case-class deleted file mode 100755 index 2f70f4eb1..000000000 --- a/tests/misc/tr-case-class +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh -# Test case conversion classes - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tr - -# Ensure we support translation of case classes with extension -echo '01234567899999999999999999' > exp -echo 'abcdefghijklmnopqrstuvwxyz' | -tr '[:lower:]' '0-9' > out || fail=1 -compare exp out || fail=1 -echo 'abcdefghijklmnopqrstuvwxyz' | -tr '[:lower:][:lower:]' '[:upper:]0-9' > out || fail=1 -compare exp out || fail=1 - -# Validate the alignment of case classes -tr 'A-Z[:lower:]' 'a-y[:upper:]' < /dev/null && fail=1 -tr '[:upper:][:lower:]' 'a-y[:upper:]' < /dev/null && fail=1 -tr 'A-Y[:lower:]' 'a-z[:upper:]' < /dev/null && fail=1 -tr 'A-Z[:lower:]' '[:lower:][:upper:]' < /dev/null && fail=1 -tr 'A-Z[:lower:]' '[:lower:]A-Z' < /dev/null && fail=1 -tr '[:upper:][:lower:]' 'a-z[:upper:]' < /dev/null || fail=1 -tr '[:upper:][:lower:]' '[:upper:]a-z' < /dev/null || fail=1 - -# Before coreutils 8.6 the trailing space in string1 -# caused the case class in string2 to be extended. -# However that was not portable, dependent on locale -# and in contravention of POSIX. -tr '[:upper:] ' '[:lower:]' < /dev/null 2>out && fail=1 -echo 'tr: when translating with string1 longer than string2, -the latter string must not end with a character class' > exp -compare exp out || fail=1 - -# Up to coreutils-6.9, tr rejected an unmatched [:lower:] or [:upper:] in SET1. -echo '#$%123abcABC' | tr '[:lower:]' '[.*]' > out || fail=1 -echo '#$%123...ABC' > exp -compare exp out || fail=1 -echo '#$%123abcABC' | tr '[:upper:]' '[.*]' > out || fail=1 -echo '#$%123abc...' > exp -compare exp out || fail=1 - -# When doing a case-converting translation with something after the -# [:upper:] and [:lower:] elements, ensure that tr honors the following byte. -echo 'abc.' | tr '[:lower:].' '[:upper:]x' > out || fail=1 -echo 'ABCx' > exp -compare exp out || fail=1 - -# Before coreutils 8.6 the disparate number of upper and lower -# characters in some locales, triggered abort()s and invalid behavior -export LC_ALL=en_US.ISO-8859-1 - -if test "$(locale charmap 2>/dev/null)" = ISO-8859-1; then - # Up to coreutils-6.9.91, this would fail with the diagnostic: - # tr: misaligned [:upper:] and/or [:lower:] construct - # with LC_CTYPE=en_US.ISO-8859-1. - tr '[:upper:]' '[:lower:]' < /dev/null || fail=1 - - tr '[:upper:] ' '[:lower:]' < /dev/null 2>out && fail=1 - echo 'tr: when translating with string1 longer than string2, -the latter string must not end with a character class' > exp - compare exp out || fail=1 - - # Ensure when there are a different number of elements - # in each string, we validate the case mapping correctly - echo 'abc.xyz' | - tr 'ab[:lower:]' '0-1[:upper:]' > out || fail=1 - echo 'ABC.XYZ' > exp - compare exp out || fail=1 - - # Ensure we extend string2 appropriately - echo 'ABC- XYZ' | - tr '[:upper:]- ' '[:lower:]_' > out || fail=1 - echo 'abc__xyz' > exp - compare exp out || fail=1 - - # Ensure the size of the case classes are accounted - # for as a unit. - echo 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | - tr '[:upper:]A-B' '[:lower:]0' >out || fail=1 - echo '00cdefghijklmnopqrstuvwxyz' > exp - compare exp out || fail=1 - - # Ensure the size of the case classes are accounted - # for as a unit. - echo 'a' | - tr -t '[:lower:]a' '[:upper:]0' >out || fail=1 - echo '0' > exp - compare exp out || fail=1 - - # Ensure the size of the case classes are accounted - # for as a unit. - echo 'a' | - tr -t '[:lower:][:lower:]a' '[:lower:][:upper:]0' >out || fail=1 - echo '0' > exp - compare exp out || fail=1 -fi - -Exit $fail diff --git a/tests/misc/tr-case-class.sh b/tests/misc/tr-case-class.sh new file mode 100755 index 000000000..2f70f4eb1 --- /dev/null +++ b/tests/misc/tr-case-class.sh @@ -0,0 +1,113 @@ +#!/bin/sh +# Test case conversion classes + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tr + +# Ensure we support translation of case classes with extension +echo '01234567899999999999999999' > exp +echo 'abcdefghijklmnopqrstuvwxyz' | +tr '[:lower:]' '0-9' > out || fail=1 +compare exp out || fail=1 +echo 'abcdefghijklmnopqrstuvwxyz' | +tr '[:lower:][:lower:]' '[:upper:]0-9' > out || fail=1 +compare exp out || fail=1 + +# Validate the alignment of case classes +tr 'A-Z[:lower:]' 'a-y[:upper:]' < /dev/null && fail=1 +tr '[:upper:][:lower:]' 'a-y[:upper:]' < /dev/null && fail=1 +tr 'A-Y[:lower:]' 'a-z[:upper:]' < /dev/null && fail=1 +tr 'A-Z[:lower:]' '[:lower:][:upper:]' < /dev/null && fail=1 +tr 'A-Z[:lower:]' '[:lower:]A-Z' < /dev/null && fail=1 +tr '[:upper:][:lower:]' 'a-z[:upper:]' < /dev/null || fail=1 +tr '[:upper:][:lower:]' '[:upper:]a-z' < /dev/null || fail=1 + +# Before coreutils 8.6 the trailing space in string1 +# caused the case class in string2 to be extended. +# However that was not portable, dependent on locale +# and in contravention of POSIX. +tr '[:upper:] ' '[:lower:]' < /dev/null 2>out && fail=1 +echo 'tr: when translating with string1 longer than string2, +the latter string must not end with a character class' > exp +compare exp out || fail=1 + +# Up to coreutils-6.9, tr rejected an unmatched [:lower:] or [:upper:] in SET1. +echo '#$%123abcABC' | tr '[:lower:]' '[.*]' > out || fail=1 +echo '#$%123...ABC' > exp +compare exp out || fail=1 +echo '#$%123abcABC' | tr '[:upper:]' '[.*]' > out || fail=1 +echo '#$%123abc...' > exp +compare exp out || fail=1 + +# When doing a case-converting translation with something after the +# [:upper:] and [:lower:] elements, ensure that tr honors the following byte. +echo 'abc.' | tr '[:lower:].' '[:upper:]x' > out || fail=1 +echo 'ABCx' > exp +compare exp out || fail=1 + +# Before coreutils 8.6 the disparate number of upper and lower +# characters in some locales, triggered abort()s and invalid behavior +export LC_ALL=en_US.ISO-8859-1 + +if test "$(locale charmap 2>/dev/null)" = ISO-8859-1; then + # Up to coreutils-6.9.91, this would fail with the diagnostic: + # tr: misaligned [:upper:] and/or [:lower:] construct + # with LC_CTYPE=en_US.ISO-8859-1. + tr '[:upper:]' '[:lower:]' < /dev/null || fail=1 + + tr '[:upper:] ' '[:lower:]' < /dev/null 2>out && fail=1 + echo 'tr: when translating with string1 longer than string2, +the latter string must not end with a character class' > exp + compare exp out || fail=1 + + # Ensure when there are a different number of elements + # in each string, we validate the case mapping correctly + echo 'abc.xyz' | + tr 'ab[:lower:]' '0-1[:upper:]' > out || fail=1 + echo 'ABC.XYZ' > exp + compare exp out || fail=1 + + # Ensure we extend string2 appropriately + echo 'ABC- XYZ' | + tr '[:upper:]- ' '[:lower:]_' > out || fail=1 + echo 'abc__xyz' > exp + compare exp out || fail=1 + + # Ensure the size of the case classes are accounted + # for as a unit. + echo 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | + tr '[:upper:]A-B' '[:lower:]0' >out || fail=1 + echo '00cdefghijklmnopqrstuvwxyz' > exp + compare exp out || fail=1 + + # Ensure the size of the case classes are accounted + # for as a unit. + echo 'a' | + tr -t '[:lower:]a' '[:upper:]0' >out || fail=1 + echo '0' > exp + compare exp out || fail=1 + + # Ensure the size of the case classes are accounted + # for as a unit. + echo 'a' | + tr -t '[:lower:][:lower:]a' '[:lower:][:upper:]0' >out || fail=1 + echo '0' > exp + compare exp out || fail=1 +fi + +Exit $fail diff --git a/tests/misc/tr.pl b/tests/misc/tr.pl new file mode 100755 index 000000000..89f777757 --- /dev/null +++ b/tests/misc/tr.pl @@ -0,0 +1,174 @@ +#!/usr/bin/perl + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'tr'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $map_all_to_1 = + "$prog: when translating with complemented character classes,\n" + . "string2 must map all characters in the domain to one\n"; + +my @Tests = +( + ['1', qw(abcd '[]*]'), {IN=>'abcd'}, {OUT=>']]]]'}], + ['2', qw(abc '[%*]xyz'), {IN=>'abc'}, {OUT=>'xyz'}], + ['3', qw('' '[.*]'), {IN=>'abc'}, {OUT=>'abc'}], + + # Test --truncate-set1 behavior when string1 is longer than string2 + ['4', qw(-t abcd xy), {IN=>'abcde'}, {OUT=>'xycde'}], + # Test bsd behavior (the default) when string1 is longer than string2 + ['5', qw(abcd xy), {IN=>'abcde'}, {OUT=>'xyyye'}], + # Do it the posix way + ['6', qw(abcd 'x[y*]'), {IN=>'abcde'}, {OUT=>'xyyye'}], + ['7', qw(-s a-p '%[.*]$'), {IN=>'abcdefghijklmnop'}, {OUT=>'%.$'}], + ['8', qw(-s a-p '[.*]$'), {IN=>'abcdefghijklmnop'}, {OUT=>'.$'}], + ['9', qw(-s a-p '%[.*]'), {IN=>'abcdefghijklmnop'}, {OUT=>'%.'}], + ['a', qw(-s '[a-z]'), {IN=>'aabbcc'}, {OUT=>'abc'}], + ['b', qw(-s '[a-c]'), {IN=>'aabbcc'}, {OUT=>'abc'}], + ['c', qw(-s '[a-b]'), {IN=>'aabbcc'}, {OUT=>'abcc'}], + ['d', qw(-s '[b-c]'), {IN=>'aabbcc'}, {OUT=>'aabc'}], + ['e', qw(-s '[\0-\5]'), + {IN=>"\0\0a\1\1b\2\2\2c\3\3\3d\4\4\4\4e\5\5"}, {OUT=>"\0a\1b\2c\3d\4e\5"}], + # tests of delete + ['f', qw(-d '[=[=]'), {IN=>'[[[[[[[]]]]]]]]'}, {OUT=>']]]]]]]]'}], + ['g', qw(-d '[=]=]'), {IN=>'[[[[[[[]]]]]]]]'}, {OUT=>'[[[[[[['}], + ['h', qw(-d '[:xdigit:]'), {IN=>'0123456789acbdefABCDEF'}, {OUT=>''}], + ['i', qw(-d '[:xdigit:]'), {IN=>'w0x1y2z3456789acbdefABCDEFz'}, + {OUT=>'wxyzz'}], + ['j', qw(-d '[:digit:]'), {IN=>'0123456789'}, {OUT=>''}], + ['k', qw(-d '[:digit:]'), + {IN=>'a0b1c2d3e4f5g6h7i8j9k'}, {OUT=>'abcdefghijk'}], + ['l', qw(-d '[:lower:]'), {IN=>'abcdefghijklmnopqrstuvwxyz'}, {OUT=>''}], + ['m', qw(-d '[:upper:]'), {IN=>'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}, {OUT=>''}], + ['n', qw(-d '[:lower:][:upper:]'), + {IN=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'}, {OUT=>''}], + ['o', qw(-d '[:alpha:]'), + {IN=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'}, {OUT=>''}], + ['p', qw(-d '[:alnum:]'), + {IN=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'}, + {OUT=>''}], + ['q', qw(-d '[:alnum:]'), + {IN=>'.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'}, + {OUT=>'..'}], + ['r', qw(-ds '[:alnum:]' .), + {IN=>'.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'}, + {OUT=>'.'}], + + # The classic example, with string2 BSD-style + ['s', qw(-cs '[:alnum:]' '\n'), + {IN=>'The big black fox jumped over the fence.'}, + {OUT=>"The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n"}], + + # The classic example, POSIX-style + ['t', qw(-cs '[:alnum:]' '[\n*]'), + {IN=>'The big black fox jumped over the fence.'}, + {OUT=>"The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n"}], + ['u', qw(-ds b a), {IN=>'aabbaa'}, {OUT=>'a'}], + ['v', qw(-ds '[:xdigit:]' Z), {IN=>'ZZ0123456789acbdefABCDEFZZ'}, {OUT=>'Z'}], + + # Try some data with 8th bit set in case something is mistakenly + # sign-extended. + ['w', qw(-ds '\350' '\345'), + {IN=>"\300\301\377\345\345\350\345"}, + {OUT=>"\300\301\377\345"}], + ['x', qw(-s abcdefghijklmn '[:*016]'), + {IN=>'abcdefghijklmnop'}, {OUT=>':op'}], + ['y', qw(-d a-z), {IN=>'abc $code'}, {OUT=>' $'}], + ['z', qw(-ds a-z '$.'), {IN=>'a.b.c $$$$code\\'}, {OUT=>'. $\\'}], + + # Make sure that a-a is accepted. + ['range-a-a', qw(a-a z), {IN=>'abc'}, {OUT=>'zbc'}], + # + ['null', qw(a ''), {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: when not truncating set1, string2 must be non-empty\n"}], + ['upcase', qw('[:lower:]' '[:upper:]'), + {IN=>'abcxyzABCXYZ'}, + {OUT=>'ABCXYZABCXYZ'}], + ['dncase', qw('[:upper:]' '[:lower:]'), + {IN=>'abcxyzABCXYZ'}, + {OUT=>'abcxyzabcxyz'}], + # + ['rep-cclass', qw('a[=*2][=c=]' xyyz), {IN=>'a=c'}, {OUT=>'xyz'}], + ['rep-1', qw('[:*3][:digit:]' a-m), {IN=>':1239'}, {OUT=>'cefgm'}], + ['rep-2', qw('a[b*512]c' '1[x*]2'), {IN=>'abc'}, {OUT=>'1x2'}], + ['rep-3', qw('a[b*513]c' '1[x*]2'), {IN=>'abc'}, {OUT=>'1x2'}], + # Another couple octal repeat count tests. + ['o-rep-1', qw('[b*08]' '[x*]'), {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: invalid repeat count '08' in [c*n] construct\n"}], + ['o-rep-2', qw('[b*010]cd' '[a*7]BC[x*]'), {IN=>'bcd'}, {OUT=>'BCx'}], + + ['esc', qw('a\-z' A-Z), {IN=>'abc-z'}, {OUT=>'AbcBC'}], + ['bs-055', qw('a\055b' def), {IN=>"a\055b"}, {OUT=>'def'}], + ['bs-at-end', qw('\\' x), {IN=>"\\"}, {OUT=>'x'}, + {ERR=>"$prog: warning: an unescaped backslash at end of " + . "string is not portable\n"}], + + # + # From Ross + ['ross-0a', qw(-cs '[:upper:]' 'X[Y*]'), {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>$map_all_to_1}], + ['ross-0b', qw(-cs '[:cntrl:]' 'X[Y*]'), {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>$map_all_to_1}], + ['ross-1a', qw(-cs '[:upper:]' '[X*]'), + {IN=>'AMZamz123.-+AMZ'}, {OUT=>'AMZXAMZ'}], + ['ross-1b', qw(-cs '[:upper:][:digit:]' '[Z*]'), {IN=>''}, {OUT=>''}], + ['ross-2', qw(-dcs '[:lower:]' n-rs-z), + {IN=>'amzAMZ123.-+amz'}, {OUT=>'amzamz'}], + ['ross-3', qw(-ds '[:xdigit:]' '[:alnum:]'), + {IN=>'.ZABCDEFGzabcdefg.0123456788899.GG'}, {OUT=>'.ZGzg..G'}], + ['ross-4', qw(-dcs '[:alnum:]' '[:digit:]'), {IN=>''}, {OUT=>''}], + ['ross-5', qw(-dc '[:lower:]'), {IN=>''}, {OUT=>''}], + ['ross-6', qw(-dc '[:upper:]'), {IN=>''}, {OUT=>''}], + + # Ensure that these fail. + # Prior to 2.0.20, each would evoke a failed assertion. + ['empty-eq', qw('[==]' x), {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: missing equivalence class character '[==]'\n"}], + ['empty-cc', qw('[::]' x), {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR=>"$prog: missing character class name '[::]'\n"}], + + # Weird repeat counts. + ['repeat-bs-9', qw(abc '[b*\9]'), {IN=>'abcd'}, {OUT=>'[b*d'}], + ['repeat-0', qw(abc '[b*0]'), {IN=>'abcd'}, {OUT=>'bbbd'}], + ['repeat-zeros', qw(abc '[b*00000000000000000000]'), + {IN=>'abcd'}, {OUT=>'bbbd'}], + ['repeat-compl', qw(-c '[a*65536]\n' '[b*]'), {IN=>'abcd'}, {OUT=>'abbb'}], + ['repeat-xC', qw(-C '[a*65536]\n' '[b*]'), {IN=>'abcd'}, {OUT=>'abbb'}], + + # From Glenn Fowler. + ['fowler-1', qw(ah -H), {IN=>'aha'}, {OUT=>'-H-'}], + + # Up to coreutils-6.9, this would provoke a failed assertion. + ['no-abort-1', qw(-c a '[b*256]'), {IN=>'abc'}, {OUT=>'abb'}], +); + +@Tests = triple_test \@Tests; + +# tr takes its input only from stdin, not from a file argument, so +# remove the tests that provide file arguments and keep only the ones +# generated by triple_test (identifiable by their .r and .p suffixes). +@Tests = grep {$_->[0] =~ /\.[pr]$/} @Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/truncate-dangling-symlink b/tests/misc/truncate-dangling-symlink deleted file mode 100755 index d9175d4eb..000000000 --- a/tests/misc/truncate-dangling-symlink +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Make sure truncate can create a file through a dangling symlink. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate - -ln -s truncate-target t-symlink - -truncate -s0 t-symlink || fail=1 - -test -f truncate-target || fail=1 - -Exit $fail diff --git a/tests/misc/truncate-dangling-symlink.sh b/tests/misc/truncate-dangling-symlink.sh new file mode 100755 index 000000000..d9175d4eb --- /dev/null +++ b/tests/misc/truncate-dangling-symlink.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Make sure truncate can create a file through a dangling symlink. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate + +ln -s truncate-target t-symlink + +truncate -s0 t-symlink || fail=1 + +test -f truncate-target || fail=1 + +Exit $fail diff --git a/tests/misc/truncate-dir-fail b/tests/misc/truncate-dir-fail deleted file mode 100755 index 54a31479f..000000000 --- a/tests/misc/truncate-dir-fail +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Make sure truncate fails for a directory. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate - -# truncate on dir not allowed -truncate -s+0 . && fail=1 - -Exit $fail diff --git a/tests/misc/truncate-dir-fail.sh b/tests/misc/truncate-dir-fail.sh new file mode 100755 index 000000000..54a31479f --- /dev/null +++ b/tests/misc/truncate-dir-fail.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Make sure truncate fails for a directory. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate + +# truncate on dir not allowed +truncate -s+0 . && fail=1 + +Exit $fail diff --git a/tests/misc/truncate-fail-diag b/tests/misc/truncate-fail-diag deleted file mode 100755 index 994ee0b8b..000000000 --- a/tests/misc/truncate-fail-diag +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# make sure truncate gives reasonable diagnostics -# Note open() checks for trailing '/' before checking for existence -# open (".", O_CREAT & (O_WRONLY | O_RDWR), ...) -> EISDIR -# open ("missing/", O_CREAT & (O_WRONLY | O_RDWR), ...) -> EISDIR -# open ("missing/file", O_CREAT & (O_WRONLY | O_RDWR), ...) -> ENOENT - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate -skip_if_root_ - - -d1=no - -dir=$d1/such-dir -truncate -s0 $dir > out 2>&1 && fail=1 -cat < exp -truncate: cannot open '$dir' for writing: No such file or directory -EOF -compare exp out || fail=1 - -dir=$d1/ -truncate -s0 $dir > out 2>&1 && fail=1 -#The following can be returned at least -#truncate: cannot open '$dir' for writing: Not a directory -#truncate: cannot open '$dir' for writing: Is a directory - -Exit $fail diff --git a/tests/misc/truncate-fail-diag.sh b/tests/misc/truncate-fail-diag.sh new file mode 100755 index 000000000..994ee0b8b --- /dev/null +++ b/tests/misc/truncate-fail-diag.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# make sure truncate gives reasonable diagnostics +# Note open() checks for trailing '/' before checking for existence +# open (".", O_CREAT & (O_WRONLY | O_RDWR), ...) -> EISDIR +# open ("missing/", O_CREAT & (O_WRONLY | O_RDWR), ...) -> EISDIR +# open ("missing/file", O_CREAT & (O_WRONLY | O_RDWR), ...) -> ENOENT + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate +skip_if_root_ + + +d1=no + +dir=$d1/such-dir +truncate -s0 $dir > out 2>&1 && fail=1 +cat < exp +truncate: cannot open '$dir' for writing: No such file or directory +EOF +compare exp out || fail=1 + +dir=$d1/ +truncate -s0 $dir > out 2>&1 && fail=1 +#The following can be returned at least +#truncate: cannot open '$dir' for writing: Not a directory +#truncate: cannot open '$dir' for writing: Is a directory + +Exit $fail diff --git a/tests/misc/truncate-fifo b/tests/misc/truncate-fifo deleted file mode 100755 index 6588f0a27..000000000 --- a/tests/misc/truncate-fifo +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Make sure truncate works on fifos without hanging - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate - -mkfifo_or_skip_ fifo - -timeout 10 truncate -s0 fifo -test "$?" = 124 && fail=1 - -Exit $fail diff --git a/tests/misc/truncate-fifo.sh b/tests/misc/truncate-fifo.sh new file mode 100755 index 000000000..6588f0a27 --- /dev/null +++ b/tests/misc/truncate-fifo.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Make sure truncate works on fifos without hanging + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate + +mkfifo_or_skip_ fifo + +timeout 10 truncate -s0 fifo +test "$?" = 124 && fail=1 + +Exit $fail diff --git a/tests/misc/truncate-no-create-missing b/tests/misc/truncate-no-create-missing deleted file mode 100755 index 56b2ac187..000000000 --- a/tests/misc/truncate-no-create-missing +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Ensure that truncate -c no-such-file doesn't fail. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate - - -# truncate -c no-such-file should not fail. -truncate -s0 -c no-such-file || fail=1 - -Exit $fail diff --git a/tests/misc/truncate-no-create-missing.sh b/tests/misc/truncate-no-create-missing.sh new file mode 100755 index 000000000..56b2ac187 --- /dev/null +++ b/tests/misc/truncate-no-create-missing.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Ensure that truncate -c no-such-file doesn't fail. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate + + +# truncate -c no-such-file should not fail. +truncate -s0 -c no-such-file || fail=1 + +Exit $fail diff --git a/tests/misc/truncate-overflow b/tests/misc/truncate-overflow deleted file mode 100755 index 9ec353fa8..000000000 --- a/tests/misc/truncate-overflow +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Validate truncate integer overflow - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate -getlimits_ - - -# -= overflow -truncate -s-1 create-zero-len-file || fail=1 - -echo > non-empty-file - -# signed overflow -truncate -s$OFF_T_OFLOW file && fail=1 - -# += signed overflow -truncate -s+$OFF_T_MAX non-empty-file && fail=1 - -# *= signed overflow -IO_BLOCK_OFLOW=$(expr $OFF_T_MAX / $(stat -f -c%s .) + 1) -truncate --io-blocks --size=$IO_BLOCK_OFLOW file && fail=1 - -Exit $fail diff --git a/tests/misc/truncate-overflow.sh b/tests/misc/truncate-overflow.sh new file mode 100755 index 000000000..9ec353fa8 --- /dev/null +++ b/tests/misc/truncate-overflow.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Validate truncate integer overflow + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate +getlimits_ + + +# -= overflow +truncate -s-1 create-zero-len-file || fail=1 + +echo > non-empty-file + +# signed overflow +truncate -s$OFF_T_OFLOW file && fail=1 + +# += signed overflow +truncate -s+$OFF_T_MAX non-empty-file && fail=1 + +# *= signed overflow +IO_BLOCK_OFLOW=$(expr $OFF_T_MAX / $(stat -f -c%s .) + 1) +truncate --io-blocks --size=$IO_BLOCK_OFLOW file && fail=1 + +Exit $fail diff --git a/tests/misc/truncate-owned-by-other b/tests/misc/truncate-owned-by-other deleted file mode 100755 index 931608698..000000000 --- a/tests/misc/truncate-owned-by-other +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Demonstrate that "truncate -s0 writable-but-owned-by-other" works. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate - -require_root_ - -group_num=$(id -g $NON_ROOT_USERNAME) - -# Create a file owned by root, and writable by $NON_ROOT_USERNAME. -echo > root-owned || framework_failure_ -chgrp +$group_num . root-owned || framework_failure_ -chmod g+w root-owned - -# Ensure that the current directory is searchable by $NON_ROOT_USERNAME. -chmod g+x . - -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" truncate -s0 root-owned || fail=1 - -Exit $fail diff --git a/tests/misc/truncate-owned-by-other.sh b/tests/misc/truncate-owned-by-other.sh new file mode 100755 index 000000000..931608698 --- /dev/null +++ b/tests/misc/truncate-owned-by-other.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Demonstrate that "truncate -s0 writable-but-owned-by-other" works. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate + +require_root_ + +group_num=$(id -g $NON_ROOT_USERNAME) + +# Create a file owned by root, and writable by $NON_ROOT_USERNAME. +echo > root-owned || framework_failure_ +chgrp +$group_num . root-owned || framework_failure_ +chmod g+w root-owned + +# Ensure that the current directory is searchable by $NON_ROOT_USERNAME. +chmod g+x . + +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" truncate -s0 root-owned || fail=1 + +Exit $fail diff --git a/tests/misc/truncate-parameters b/tests/misc/truncate-parameters deleted file mode 100755 index 13a8475e6..000000000 --- a/tests/misc/truncate-parameters +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Validate truncate parameter combinations - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate - - -# must specify at least 1 file -truncate --size=0 && fail=1 - -# must specify size. don't default to 0 -truncate file && fail=1 - -# mixture of absolute size & reference not allowed -truncate --size=0 --reference=file file && fail=1 - -# blocks without size is not valid -truncate --io-blocks --reference=file file && fail=1 - -# must specify valid numbers -truncate --size="invalid" file && fail=1 - -# spaces not significant around size -truncate --size="> -1" file && fail=1 -truncate --size=" >1" file || fail=1 #file now 1 -truncate --size=" +1" file || fail=1 #file now 2 -test $(stat --format %s file) = 2 || fail=1 - -# reference allowed with relative size -truncate --size=" +1" -r file file || fail=1 #file now 3 -test $(stat --format %s file) = 3 || fail=1 - -# reference allowed alone also -truncate -r file file || fail=1 #file still 3 -test $(stat --format %s file) = 3 || fail=1 -truncate -r file file2 || fail=1 #file2 now 3 -test $(stat --format %s file2) = 3 || fail=1 - -Exit $fail diff --git a/tests/misc/truncate-parameters.sh b/tests/misc/truncate-parameters.sh new file mode 100755 index 000000000..13a8475e6 --- /dev/null +++ b/tests/misc/truncate-parameters.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Validate truncate parameter combinations + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate + + +# must specify at least 1 file +truncate --size=0 && fail=1 + +# must specify size. don't default to 0 +truncate file && fail=1 + +# mixture of absolute size & reference not allowed +truncate --size=0 --reference=file file && fail=1 + +# blocks without size is not valid +truncate --io-blocks --reference=file file && fail=1 + +# must specify valid numbers +truncate --size="invalid" file && fail=1 + +# spaces not significant around size +truncate --size="> -1" file && fail=1 +truncate --size=" >1" file || fail=1 #file now 1 +truncate --size=" +1" file || fail=1 #file now 2 +test $(stat --format %s file) = 2 || fail=1 + +# reference allowed with relative size +truncate --size=" +1" -r file file || fail=1 #file now 3 +test $(stat --format %s file) = 3 || fail=1 + +# reference allowed alone also +truncate -r file file || fail=1 #file still 3 +test $(stat --format %s file) = 3 || fail=1 +truncate -r file file2 || fail=1 #file2 now 3 +test $(stat --format %s file2) = 3 || fail=1 + +Exit $fail diff --git a/tests/misc/truncate-relative b/tests/misc/truncate-relative deleted file mode 100755 index 19543db6b..000000000 --- a/tests/misc/truncate-relative +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Validate truncate relative sizes - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ truncate - - -# mixture of relative modifiers not allowed -truncate --size="+>0" file && fail=1 - -# mixture of relative modifiers not allowed -truncate --size=">+0" file && fail=1 - -# division by zero -truncate --size="/0" file && fail=1 - -# division by zero -truncate --size="%0" file && fail=1 - -Exit $fail diff --git a/tests/misc/truncate-relative.sh b/tests/misc/truncate-relative.sh new file mode 100755 index 000000000..19543db6b --- /dev/null +++ b/tests/misc/truncate-relative.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Validate truncate relative sizes + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ truncate + + +# mixture of relative modifiers not allowed +truncate --size="+>0" file && fail=1 + +# mixture of relative modifiers not allowed +truncate --size=">+0" file && fail=1 + +# division by zero +truncate --size="/0" file && fail=1 + +# division by zero +truncate --size="%0" file && fail=1 + +Exit $fail diff --git a/tests/misc/tsort b/tests/misc/tsort deleted file mode 100755 index cc8ac957f..000000000 --- a/tests/misc/tsort +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/perl -# Test "tsort". - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['cycle-1', {IN => {f => "t b\nt s\ns t\n"}}, {OUT => "s\nt\nb\n"}, - {EXIT => 1}, - {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ], - ['cycle-2', {IN => {f => "t x\nt s\ns t\n"}}, {OUT => "s\nt\nx\n"}, - {EXIT => 1}, - {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ], - - ['posix-1', {IN => "a b c c d e\ng g\nf g e f\nh h\n"}, - {OUT => "a\nc\nd\nh\nb\ne\nf\ng\n"}], - ['posix-2', {IN => "b a\nd c\nz h x h r h\n"}, - {OUT => "b\nd\nr\nx\nz\na\nc\nh\n"}], - - ['linear-1', {IN => "a b b c c d d e e f f g\n"}, - {OUT => "a\nb\nc\nd\ne\nf\ng\n"}], - - ['tree-1', {IN => "a b b c c d d e e f f g\nc x x y y z\n"}, - {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\ng\n"}], - ['tree-2', {IN => "a b b c c d d e e f f g\nc x x y y z\nf r r s s t\n"}, - {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\nr\ng\ns\nt\n"}], - - # Before coreutils-5.0.1, given an odd number of input tokens, - # tsort would accept that and treat the input as if an additional - # copy of the final token were appended. - ['odd', {IN => "a\n"}, - {EXIT => 1}, - {ERR => "tsort: odd.1: input contains an odd number of tokens\n"}], - - ['only-one', {IN => {f => ""}}, {IN => {g => ""}}, - {EXIT => 1}, - {ERR => "tsort: extra operand 'g'\n" - . "Try 'tsort --help' for more information.\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'tsort'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/tsort.pl b/tests/misc/tsort.pl new file mode 100755 index 000000000..cc8ac957f --- /dev/null +++ b/tests/misc/tsort.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl +# Test "tsort". + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['cycle-1', {IN => {f => "t b\nt s\ns t\n"}}, {OUT => "s\nt\nb\n"}, + {EXIT => 1}, + {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ], + ['cycle-2', {IN => {f => "t x\nt s\ns t\n"}}, {OUT => "s\nt\nx\n"}, + {EXIT => 1}, + {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ], + + ['posix-1', {IN => "a b c c d e\ng g\nf g e f\nh h\n"}, + {OUT => "a\nc\nd\nh\nb\ne\nf\ng\n"}], + ['posix-2', {IN => "b a\nd c\nz h x h r h\n"}, + {OUT => "b\nd\nr\nx\nz\na\nc\nh\n"}], + + ['linear-1', {IN => "a b b c c d d e e f f g\n"}, + {OUT => "a\nb\nc\nd\ne\nf\ng\n"}], + + ['tree-1', {IN => "a b b c c d d e e f f g\nc x x y y z\n"}, + {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\ng\n"}], + ['tree-2', {IN => "a b b c c d d e e f f g\nc x x y y z\nf r r s s t\n"}, + {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\nr\ng\ns\nt\n"}], + + # Before coreutils-5.0.1, given an odd number of input tokens, + # tsort would accept that and treat the input as if an additional + # copy of the final token were appended. + ['odd', {IN => "a\n"}, + {EXIT => 1}, + {ERR => "tsort: odd.1: input contains an odd number of tokens\n"}], + + ['only-one', {IN => {f => ""}}, {IN => {g => ""}}, + {EXIT => 1}, + {ERR => "tsort: extra operand 'g'\n" + . "Try 'tsort --help' for more information.\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'tsort'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof deleted file mode 100755 index e9eed2eac..000000000 --- a/tests/misc/tty-eof +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/perl -# Test whether programs exit upon a single EOF from a tty. -# Ensure that e.g., cat exits upon a single EOF (^D) from a tty. -# Do the same for all programs that can read stdin, -# require no arguments and that write to standard output. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; -(my $ME = $0) =~ s|.*/||; - -# Some older versions of Expect.pm (e.g. 1.07) lack the log_user method, -# so check for that, too. -eval { require Expect; Expect->require_version('1.11') }; -$@ - and CuSkip::skip "$ME: this script requires Perl's Expect package >=1.11\n"; - -{ - my $fail = 0; - my @stdin_reading_commands = qw( - base64 - cat - cksum - dd - expand - fmt - fold - head - md5sum - nl - od - paste - pr - ptx - sha1sum - sha224sum - sha256sum - sha384sum - sha512sum - shuf - sort - sum - tac - tail - tee - tsort - unexpand - uniq - wc - ); - my $stderr = 'tty-eof.err'; - foreach my $cmd ((@stdin_reading_commands), 'cut -f2') - { - my $exp = new Expect; - $exp->log_user(0); - $exp->spawn("$cmd 2> $stderr") - or (warn "$ME: cannot run '$cmd': $!\n"), $fail=1, next; - # No input for cut -f2. - $cmd =~ /^cut/ - or $exp->send("a b\n"); - $exp->send("\cD"); # This is Control-D. FIXME: what if that's not EOF? - $exp->expect (0, '-re', "^a b\\r?\$"); - my $found = $exp->expect (1, '-re', "^.+\$"); - $found and warn "F: $found: " . $exp->exp_match () . "\n"; - $exp->expect(10, 'eof'); - # Expect no output from cut, since we gave it no input. - defined $found || $cmd =~ /^cut/ - or (warn "$ME: $cmd didn't produce expected output\n"), - $fail=1, next; - defined $exp->exitstatus - or (warn "$ME: $cmd didn't exit after ^D from standard input\n"), - $fail=1, next; - my $s = $exp->exitstatus; - $s == 0 - or (warn "$ME: $cmd exited with status $s (expected 0)\n"), - $fail=1; - $exp->hard_close(); - - # dd normally writes to stderr. If it exits successfully, we're done. - $cmd eq 'dd' && $s == 0 - and next; - - if (-s $stderr) - { - warn "$ME: $cmd wrote to stderr:\n"; - system "cat $stderr"; - $fail = 1; - } - } - continue - { - unlink $stderr - or warn "$ME: failed to remove stderr file from $cmd, $stderr: $!\n"; - } - - exit $fail -} diff --git a/tests/misc/tty-eof.pl b/tests/misc/tty-eof.pl new file mode 100755 index 000000000..e9eed2eac --- /dev/null +++ b/tests/misc/tty-eof.pl @@ -0,0 +1,110 @@ +#!/usr/bin/perl +# Test whether programs exit upon a single EOF from a tty. +# Ensure that e.g., cat exits upon a single EOF (^D) from a tty. +# Do the same for all programs that can read stdin, +# require no arguments and that write to standard output. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +(my $ME = $0) =~ s|.*/||; + +# Some older versions of Expect.pm (e.g. 1.07) lack the log_user method, +# so check for that, too. +eval { require Expect; Expect->require_version('1.11') }; +$@ + and CuSkip::skip "$ME: this script requires Perl's Expect package >=1.11\n"; + +{ + my $fail = 0; + my @stdin_reading_commands = qw( + base64 + cat + cksum + dd + expand + fmt + fold + head + md5sum + nl + od + paste + pr + ptx + sha1sum + sha224sum + sha256sum + sha384sum + sha512sum + shuf + sort + sum + tac + tail + tee + tsort + unexpand + uniq + wc + ); + my $stderr = 'tty-eof.err'; + foreach my $cmd ((@stdin_reading_commands), 'cut -f2') + { + my $exp = new Expect; + $exp->log_user(0); + $exp->spawn("$cmd 2> $stderr") + or (warn "$ME: cannot run '$cmd': $!\n"), $fail=1, next; + # No input for cut -f2. + $cmd =~ /^cut/ + or $exp->send("a b\n"); + $exp->send("\cD"); # This is Control-D. FIXME: what if that's not EOF? + $exp->expect (0, '-re', "^a b\\r?\$"); + my $found = $exp->expect (1, '-re', "^.+\$"); + $found and warn "F: $found: " . $exp->exp_match () . "\n"; + $exp->expect(10, 'eof'); + # Expect no output from cut, since we gave it no input. + defined $found || $cmd =~ /^cut/ + or (warn "$ME: $cmd didn't produce expected output\n"), + $fail=1, next; + defined $exp->exitstatus + or (warn "$ME: $cmd didn't exit after ^D from standard input\n"), + $fail=1, next; + my $s = $exp->exitstatus; + $s == 0 + or (warn "$ME: $cmd exited with status $s (expected 0)\n"), + $fail=1; + $exp->hard_close(); + + # dd normally writes to stderr. If it exits successfully, we're done. + $cmd eq 'dd' && $s == 0 + and next; + + if (-s $stderr) + { + warn "$ME: $cmd wrote to stderr:\n"; + system "cat $stderr"; + $fail = 1; + } + } + continue + { + unlink $stderr + or warn "$ME: failed to remove stderr file from $cmd, $stderr: $!\n"; + } + + exit $fail +} diff --git a/tests/misc/unexpand b/tests/misc/unexpand deleted file mode 100755 index 633a1603f..000000000 --- a/tests/misc/unexpand +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/perl -# Test "unexpand". - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $limits = getlimits (); - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = 'unexpand'; - -my @Tests = - ( - ['a1', {IN=> ' 'x 1 ."y\n"}, {OUT=> ' 'x 1 ."y\n"}], - ['a2', {IN=> ' 'x 2 ."y\n"}, {OUT=> ' 'x 2 ."y\n"}], - ['a3', {IN=> ' 'x 3 ."y\n"}, {OUT=> ' 'x 3 ."y\n"}], - ['a4', {IN=> ' 'x 4 ."y\n"}, {OUT=> ' 'x 4 ."y\n"}], - ['a5', {IN=> ' 'x 5 ."y\n"}, {OUT=> ' 'x 5 ."y\n"}], - ['a6', {IN=> ' 'x 6 ."y\n"}, {OUT=> ' 'x 6 ."y\n"}], - ['a7', {IN=> ' 'x 7 ."y\n"}, {OUT=> ' 'x 7 ."y\n"}], - ['a8', {IN=> ' 'x 8 ."y\n"}, {OUT=> "\ty\n"}], - - ['aa-1', '-a', {IN=> 'w'.' 'x 1 ."y\n"}, {OUT=> 'w'.' 'x 1 ."y\n"}], - ['aa-2', '-a', {IN=> 'w'.' 'x 2 ."y\n"}, {OUT=> 'w'.' 'x 2 ."y\n"}], - ['aa-3', '-a', {IN=> 'w'.' 'x 3 ."y\n"}, {OUT=> 'w'.' 'x 3 ."y\n"}], - ['aa-4', '-a', {IN=> 'w'.' 'x 4 ."y\n"}, {OUT=> 'w'.' 'x 4 ."y\n"}], - ['aa-5', '-a', {IN=> 'w'.' 'x 5 ."y\n"}, {OUT=> 'w'.' 'x 5 ."y\n"}], - ['aa-6', '-a', {IN=> 'w'.' 'x 6 ."y\n"}, {OUT=> 'w'.' 'x 6 ."y\n"}], - ['aa-7', '-a', {IN=> 'w'.' 'x 7 ."y\n"}, {OUT=> "w\ty\n"}], - ['aa-8', '-a', {IN=> 'w'.' 'x 8 ."y\n"}, {OUT=> "w\t y\n"}], - - ['b-1', '-t', '2,4', {IN=> " ."}, {OUT=>"\t\t ."}], - # These would infloop prior to textutils-2.0d. - - ['infloop-1', '-t', '1,2', {IN=> " \t\t .\n"}, {OUT=>"\t\t\t .\n"}], - ['infloop-2', '-t', '4,5', {IN=> ' 'x4 . "\t\t \n"}, {OUT=>"\t\t\t \n"}], - ['infloop-3', '-t', '2,3', {IN=> "x \t\t \n"}, {OUT=>"x\t\t\t \n"}], - ['infloop-4', '-t', '1,2', {IN=> " \t\t \n"}, {OUT=>"\t\t\t \n"}], - ['c-1', '-t', '1,2', {IN=> "x\t\t .\n"}, {OUT=>"x\t\t .\n"}], - - # -t implies -a - # Feature addition (--first-only) prompted by a report from Jie Xu. - ['tabs-1', qw(-t 3), {IN=> " a b\n"}, {OUT=>"\ta\tb\n"}], - ['tabs-2', qw(-t 3 --first-only), {IN=> " a b\n"}, {OUT=>"\ta b\n"}], - - # blanks - ['blanks-1', qw(-t 1), {IN=> " b c d\n"}, {OUT=> "\tb\t\tc\t\t\td\n"}], - ['blanks-2', qw(-t 1), {IN=> "a \n"}, {OUT=> "a \n"}], - ['blanks-3', qw(-t 1), {IN=> "a \n"}, {OUT=> "a\t\t\n"}], - ['blanks-4', qw(-t 1), {IN=> "a \n"}, {OUT=> "a\t\t\t\n"}], - ['blanks-5', qw(-t 1), {IN=> "a "}, {OUT=> "a "}], - ['blanks-6', qw(-t 1), {IN=> "a "}, {OUT=> "a\t\t"}], - ['blanks-7', qw(-t 1), {IN=> "a "}, {OUT=> "a\t\t\t"}], - ['blanks-8', qw(-t 1), {IN=> " a a a\n"}, {OUT=> "\ta a\t\ta\n"}], - ['blanks-9', qw(-t 2), {IN=> " a a a\n"}, {OUT=> "\t a\ta\t a\n"}], - ['blanks-10', '-t', '3,4', {IN=> "0 2 4 6\t8\n"}, {OUT=> "0 2 4 6\t8\n"}], - ['blanks-11', '-t', '3,4', {IN=> " 4\n"}, {OUT=> "\t\t4\n"}], - ['blanks-12', '-t', '3,4', {IN=> "01 4\n"}, {OUT=> "01\t\t4\n"}], - ['blanks-13', '-t', '3,4', {IN=> "0 4\n"}, {OUT=> "0\t\t4\n"}], - - # POSIX says spaces should only follow tabs. Also a single - # trailing space is not converted to a tab, when before - # a field starting with non blanks - ['posix-1', '-a', {IN=> "1234567 \t1\n"}, {OUT=>"1234567\t\t1\n"}], - ['posix-2', '-a', {IN=> "1234567 \t1\n"}, {OUT=>"1234567\t\t1\n"}], - ['posix-3', '-a', {IN=> "1234567 \t1\n"}, {OUT=>"1234567\t\t1\n"}], - ['posix-4', '-a', {IN=> "1234567\t1\n"}, {OUT=>"1234567\t1\n"}], - ['posix-5', '-a', {IN=> "1234567 1\n"}, {OUT=>"1234567\t 1\n"}], - ['posix-6', '-a', {IN=> "1234567 1\n"}, {OUT=>"1234567 1\n"}], - - # It is debatable whether this test should require an environment - # setting of e.g., _POSIX2_VERSION=1. - ['obs-ovflo', "-$limits->{UINTMAX_OFLOW}", {IN=>''}, {OUT=>''}, - {EXIT => 1}, {ERR => "$prog: tab stop value is too large\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/unexpand.pl b/tests/misc/unexpand.pl new file mode 100755 index 000000000..633a1603f --- /dev/null +++ b/tests/misc/unexpand.pl @@ -0,0 +1,99 @@ +#!/usr/bin/perl +# Test "unexpand". + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $limits = getlimits (); + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = 'unexpand'; + +my @Tests = + ( + ['a1', {IN=> ' 'x 1 ."y\n"}, {OUT=> ' 'x 1 ."y\n"}], + ['a2', {IN=> ' 'x 2 ."y\n"}, {OUT=> ' 'x 2 ."y\n"}], + ['a3', {IN=> ' 'x 3 ."y\n"}, {OUT=> ' 'x 3 ."y\n"}], + ['a4', {IN=> ' 'x 4 ."y\n"}, {OUT=> ' 'x 4 ."y\n"}], + ['a5', {IN=> ' 'x 5 ."y\n"}, {OUT=> ' 'x 5 ."y\n"}], + ['a6', {IN=> ' 'x 6 ."y\n"}, {OUT=> ' 'x 6 ."y\n"}], + ['a7', {IN=> ' 'x 7 ."y\n"}, {OUT=> ' 'x 7 ."y\n"}], + ['a8', {IN=> ' 'x 8 ."y\n"}, {OUT=> "\ty\n"}], + + ['aa-1', '-a', {IN=> 'w'.' 'x 1 ."y\n"}, {OUT=> 'w'.' 'x 1 ."y\n"}], + ['aa-2', '-a', {IN=> 'w'.' 'x 2 ."y\n"}, {OUT=> 'w'.' 'x 2 ."y\n"}], + ['aa-3', '-a', {IN=> 'w'.' 'x 3 ."y\n"}, {OUT=> 'w'.' 'x 3 ."y\n"}], + ['aa-4', '-a', {IN=> 'w'.' 'x 4 ."y\n"}, {OUT=> 'w'.' 'x 4 ."y\n"}], + ['aa-5', '-a', {IN=> 'w'.' 'x 5 ."y\n"}, {OUT=> 'w'.' 'x 5 ."y\n"}], + ['aa-6', '-a', {IN=> 'w'.' 'x 6 ."y\n"}, {OUT=> 'w'.' 'x 6 ."y\n"}], + ['aa-7', '-a', {IN=> 'w'.' 'x 7 ."y\n"}, {OUT=> "w\ty\n"}], + ['aa-8', '-a', {IN=> 'w'.' 'x 8 ."y\n"}, {OUT=> "w\t y\n"}], + + ['b-1', '-t', '2,4', {IN=> " ."}, {OUT=>"\t\t ."}], + # These would infloop prior to textutils-2.0d. + + ['infloop-1', '-t', '1,2', {IN=> " \t\t .\n"}, {OUT=>"\t\t\t .\n"}], + ['infloop-2', '-t', '4,5', {IN=> ' 'x4 . "\t\t \n"}, {OUT=>"\t\t\t \n"}], + ['infloop-3', '-t', '2,3', {IN=> "x \t\t \n"}, {OUT=>"x\t\t\t \n"}], + ['infloop-4', '-t', '1,2', {IN=> " \t\t \n"}, {OUT=>"\t\t\t \n"}], + ['c-1', '-t', '1,2', {IN=> "x\t\t .\n"}, {OUT=>"x\t\t .\n"}], + + # -t implies -a + # Feature addition (--first-only) prompted by a report from Jie Xu. + ['tabs-1', qw(-t 3), {IN=> " a b\n"}, {OUT=>"\ta\tb\n"}], + ['tabs-2', qw(-t 3 --first-only), {IN=> " a b\n"}, {OUT=>"\ta b\n"}], + + # blanks + ['blanks-1', qw(-t 1), {IN=> " b c d\n"}, {OUT=> "\tb\t\tc\t\t\td\n"}], + ['blanks-2', qw(-t 1), {IN=> "a \n"}, {OUT=> "a \n"}], + ['blanks-3', qw(-t 1), {IN=> "a \n"}, {OUT=> "a\t\t\n"}], + ['blanks-4', qw(-t 1), {IN=> "a \n"}, {OUT=> "a\t\t\t\n"}], + ['blanks-5', qw(-t 1), {IN=> "a "}, {OUT=> "a "}], + ['blanks-6', qw(-t 1), {IN=> "a "}, {OUT=> "a\t\t"}], + ['blanks-7', qw(-t 1), {IN=> "a "}, {OUT=> "a\t\t\t"}], + ['blanks-8', qw(-t 1), {IN=> " a a a\n"}, {OUT=> "\ta a\t\ta\n"}], + ['blanks-9', qw(-t 2), {IN=> " a a a\n"}, {OUT=> "\t a\ta\t a\n"}], + ['blanks-10', '-t', '3,4', {IN=> "0 2 4 6\t8\n"}, {OUT=> "0 2 4 6\t8\n"}], + ['blanks-11', '-t', '3,4', {IN=> " 4\n"}, {OUT=> "\t\t4\n"}], + ['blanks-12', '-t', '3,4', {IN=> "01 4\n"}, {OUT=> "01\t\t4\n"}], + ['blanks-13', '-t', '3,4', {IN=> "0 4\n"}, {OUT=> "0\t\t4\n"}], + + # POSIX says spaces should only follow tabs. Also a single + # trailing space is not converted to a tab, when before + # a field starting with non blanks + ['posix-1', '-a', {IN=> "1234567 \t1\n"}, {OUT=>"1234567\t\t1\n"}], + ['posix-2', '-a', {IN=> "1234567 \t1\n"}, {OUT=>"1234567\t\t1\n"}], + ['posix-3', '-a', {IN=> "1234567 \t1\n"}, {OUT=>"1234567\t\t1\n"}], + ['posix-4', '-a', {IN=> "1234567\t1\n"}, {OUT=>"1234567\t1\n"}], + ['posix-5', '-a', {IN=> "1234567 1\n"}, {OUT=>"1234567\t 1\n"}], + ['posix-6', '-a', {IN=> "1234567 1\n"}, {OUT=>"1234567 1\n"}], + + # It is debatable whether this test should require an environment + # setting of e.g., _POSIX2_VERSION=1. + ['obs-ovflo', "-$limits->{UINTMAX_OFLOW}", {IN=>''}, {OUT=>''}, + {EXIT => 1}, {ERR => "$prog: tab stop value is too large\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/uniq b/tests/misc/uniq deleted file mode 100755 index d0e6d151a..000000000 --- a/tests/misc/uniq +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/perl -# Test uniq. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $limits = getlimits (); - -my $prog = 'uniq'; -my $try = "Try '$prog --help' for more information.\n"; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -# When possible, create a "-z"-testing variant of each test. -sub add_z_variants($) -{ - my ($tests) = @_; - my @new; - TEST: - foreach my $t (@$tests) - { - push @new, $t; - - # skip the obsolete-syntax tests - $t->[0] =~ /^obs-plus/ - and next; - - my @args; - my @list_of_hash; - - foreach my $e (@$t) - { - !ref $e - and push (@args, $e), next; - - ref $e && ref $e eq 'HASH' - or (warn "$0: $t->[0]: unexpected entry type\n"), next; - my $tmp = $e; - foreach my $k (qw(IN OUT)) - { - my $val = $e->{$k}; - # skip any test whose input or output already contains a NUL byte - if (defined $val) - { - $val =~ /\0/ - and next TEST; - - # Convert each NL in input or output to \0. - $val =~ s/\n/\0/g; - $tmp = {$k => $val}; - last; - } - } - push @list_of_hash, $tmp; - } - - shift @args; # discard test name - - # skip any test that uses the -z option - grep /z/, @args - and next; - - push @new, ["$t->[0]-z", '-z', @args, @list_of_hash]; - } - return @new; -} - -# I've only ever triggered the problem in a non-C locale. -my $locale = $ENV{LOCALE_FR}; -! defined $locale || $locale eq 'none' - and CuSkip::skip "$prog: skipping this test -- no appropriate locale\n"; - -# See if isblank returns true for nbsp. -my $x = qx!env printf '\xa0'| LC_ALL=$locale tr '[:blank:]' x!; -# If so, expect just one line of output in the schar test. -# Otherwise, expect two. -my $in = " y z\n\xa0 y z\n"; -my $schar_exp = $x eq 'x' ? " y z\n" : $in; - -my @Tests = -( - # Test for a subtle, system-and-locale-dependent bug in uniq. - ['schar', '-f1', {IN => $in}, {OUT => $schar_exp}, - {ENV => "LC_ALL=$locale"}], - ['1', '', {IN=>''}, {OUT=>''}], - ['2', '', {IN=>"a\na\n"}, {OUT=>"a\n"}], - ['3', '', {IN=>"a\na"}, {OUT=>"a\n"}], - ['4', '', {IN=>"a\nb"}, {OUT=>"a\nb\n"}], - ['5', '', {IN=>"a\na\nb"}, {OUT=>"a\nb\n"}], - ['6', '', {IN=>"b\na\na\n"}, {OUT=>"b\na\n"}], - ['7', '', {IN=>"a\nb\nc\n"}, {OUT=>"a\nb\nc\n"}], - - # Ensure that newlines are not interpreted with -z. - ['2z', '-z', {IN=>"a\na\n"}, {OUT=>"a\na\n\0"}], - ['3z', '-z', {IN=>"a\na"}, {OUT=>"a\na\0"}], - ['4z', '-z', {IN=>"a\nb"}, {OUT=>"a\nb\0"}], - ['5z', '-z', {IN=>"a\na\nb"}, {OUT=>"a\na\nb\0"}], - ['20z', '-dz', {IN=>"a\na\n"}, {OUT=>""}], - - # Make sure that eight bit characters work - ['8', '', {IN=>"ö\nv\n"}, {OUT=>"ö\nv\n"}], - # Test output of -u option; only unique lines - ['9', '-u', {IN=>"a\na\n"}, {OUT=>""}], - ['10', '-u', {IN=>"a\nb\n"}, {OUT=>"a\nb\n"}], - ['11', '-u', {IN=>"a\nb\na\n"}, {OUT=>"a\nb\na\n"}], - ['12', '-u', {IN=>"a\na\n"}, {OUT=>""}], - ['13', '-u', {IN=>"a\na\n"}, {OUT=>""}], - #['5', '-u', "a\na\n", "", 0], - # Test output of -d option; only repeated lines - ['20', '-d', {IN=>"a\na\n"}, {OUT=>"a\n"}], - ['21', '-d', {IN=>"a\nb\n"}, {OUT=>""}], - ['22', '-d', {IN=>"a\nb\na\n"}, {OUT=>""}], - ['23', '-d', {IN=>"a\na\nb\n"}, {OUT=>"a\n"}], - # Check the key options - # If we skip over fields or characters, is the output deterministic? - ['obs30', '-1', {IN=>"a a\nb a\n"}, {OUT=>"a a\n"}], - ['31', qw(-f 1), {IN=>"a a\nb a\n"}, {OUT=>"a a\n"}], - ['32', qw(-f 1), {IN=>"a a\nb b\n"}, {OUT=>"a a\nb b\n"}], - ['33', qw(-f 1), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\nb a c\n"}], - ['34', qw(-f 1), {IN=>"b a\na a\n"}, {OUT=>"b a\n"}], - ['35', qw(-f 2), {IN=>"a a c\nb a c\n"}, {OUT=>"a a c\n"}], - # Skip over characters. - ['obs-plus40', '+1', {IN=>"aaa\naaa\n"}, {OUT=>"aaa\n"}], - ['obs-plus41', '+1', {IN=>"baa\naaa\n"}, {OUT=>"baa\n"}], - ['42', qw(-s 1), {IN=>"aaa\naaa\n"}, {OUT=>"aaa\n"}], - ['43', qw(-s 2), {IN=>"baa\naaa\n"}, {OUT=>"baa\n"}], - ['obs-plus44', qw(+1 --), {IN=>"aaa\naaa\n"}, {OUT=>"aaa\n"}], - ['obs-plus45', qw(+1 --), {IN=>"baa\naaa\n"}, {OUT=>"baa\n"}], - # Skip over fields and characters - ['50', qw(-f 1 -s 1), {IN=>"a aaa\nb ab\n"}, {OUT=>"a aaa\nb ab\n"}], - ['51', qw(-f 1 -s 1), {IN=>"a aaa\nb aaa\n"}, {OUT=>"a aaa\n"}], - ['52', qw(-s 1 -f 1), {IN=>"a aaa\nb ab\n"}, {OUT=>"a aaa\nb ab\n"}], - ['53', qw(-s 1 -f 1), {IN=>"a aaa\nb aaa\n"}, {OUT=>"a aaa\n"}], - # Fixed in 2.0.15 - ['54', qw(-s 4), {IN=>"abc\nabcd\n"}, {OUT=>"abc\n"}], - # Supported in 2.0.15 - ['55', qw(-s 0), {IN=>"abc\nabcd\n"}, {OUT=>"abc\nabcd\n"}], - ['56', qw(-s 0), {IN=>"abc\n"}, {OUT=>"abc\n"}], - ['57', qw(-w 0), {IN=>"abc\nabcd\n"}, {OUT=>"abc\n"}], - # Only account for a number of characters - ['60', qw(-w 1), {IN=>"a a\nb a\n"}, {OUT=>"a a\nb a\n"}], - ['61', qw(-w 3), {IN=>"a a\nb a\n"}, {OUT=>"a a\nb a\n"}], - ['62', qw(-w 1 -f 1), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\n"}], - ['63', qw(-f 1 -w 1), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\n"}], - # The blank after field one is checked too - ['64', qw(-f 1 -w 4), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\nb a c\n"}], - ['65', qw(-f 1 -w 3), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\n"}], - # Make sure we don't break if the file contains \0 - ['90', '', {IN=>"a\0a\na\n"}, {OUT=>"a\0a\na\n"}], - # Check fields separated by tabs and by spaces - ['91', '', {IN=>"a\ta\na a\n"}, {OUT=>"a\ta\na a\n"}], - ['92', qw(-f 1), {IN=>"a\ta\na a\n"}, {OUT=>"a\ta\na a\n"}], - ['93', qw(-f 2), {IN=>"a\ta a\na a a\n"}, {OUT=>"a\ta a\n"}], - ['94', qw(-f 1), {IN=>"a\ta\na\ta\n"}, {OUT=>"a\ta\n"}], - # Check the count option; add tests for other options too - ['101', '-c', {IN=>"a\nb\n"}, {OUT=>" 1 a\n 1 b\n"}], - ['102', '-c', {IN=>"a\na\n"}, {OUT=>" 2 a\n"}], - # Check the local -D (--all-repeated) option - ['110', '-D', {IN=>"a\na\n"}, {OUT=>"a\na\n"}], - ['111', qw(-D -w1), {IN=>"a a\na b\n"}, {OUT=>"a a\na b\n"}], - ['112', qw(-D -c), {IN=>"a a\na b\n"}, {OUT=>""}, {EXIT=>1}, {ERR=> - "$prog: printing all duplicated lines and repeat counts is meaningless\n$try"} - ], - ['113', '--all-repeated=separate', {IN=>"a\na\n"}, {OUT=>"a\na\n"}], - ['114', '--all-repeated=separate', - {IN=>"a\na\nb\nc\nc\n"}, {OUT=>"a\na\n\nc\nc\n"}], - ['115', '--all-repeated=separate', - {IN=>"a\na\nb\nb\nc\n"}, {OUT=>"a\na\n\nb\nb\n"}], - ['116', '--all-repeated=prepend', {IN=>"a\na\n"}, {OUT=>"\na\na\n"}], - ['117', '--all-repeated=prepend', - {IN=>"a\na\nb\nc\nc\n"}, {OUT=>"\na\na\n\nc\nc\n"}], - ['118', '--all-repeated=prepend', {IN=>"a\nb\n"}, {OUT=>""}], - ['119', '--all-repeated=badoption', {IN=>"a\n"}, {OUT=>""}, {EXIT=>1}, - {ERR=>"$prog: invalid argument 'badoption' for '--all-repeated'\n" - . "Valid arguments are:\n" - . " - 'none'\n" - . " - 'prepend'\n" - . " - 'separate'\n" - . $try}], - # Check that -d and -u suppress all output, as POSIX requires. - ['120', qw(-d -u), {IN=>"a\na\n\b"}, {OUT=>""}], - ['121', "-d -u -w$limits->{UINTMAX_OFLOW}", {IN=>"a\na\n\b"}, {OUT=>""}], - ['122', "-d -u -w$limits->{SIZE_OFLOW}", {IN=>"a\na\n\b"}, {OUT=>""}], - # Check that --zero-terminated is synonymous with -z. - ['123', '--zero-terminated', {IN=>"a\na\nb"}, {OUT=>"a\na\nb\0"}], - ['124', '--zero-terminated', {IN=>"a\0a\0b"}, {OUT=>"a\0b\0"}], -); - -# Set _POSIX2_VERSION=199209 in the environment of each obs-plus* test. -foreach my $t (@Tests) - { - $t->[0] =~ /^obs-plus/ - and push @$t, {ENV=>'_POSIX2_VERSION=199209'}; - } - -@Tests = add_z_variants \@Tests; -@Tests = triple_test \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/uniq-perf b/tests/misc/uniq-perf deleted file mode 100755 index 57794c3b0..000000000 --- a/tests/misc/uniq-perf +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# before coreutils-8.10, seq 100000|uniq -f 10000000000 would run for days - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ uniq - -seq 100 > in || fail=1 -timeout 1 uniq -f 10000000000 in || fail=1 - -Exit $fail diff --git a/tests/misc/uniq-perf.sh b/tests/misc/uniq-perf.sh new file mode 100755 index 000000000..57794c3b0 --- /dev/null +++ b/tests/misc/uniq-perf.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# before coreutils-8.10, seq 100000|uniq -f 10000000000 would run for days + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ uniq + +seq 100 > in || fail=1 +timeout 1 uniq -f 10000000000 in || fail=1 + +Exit $fail diff --git a/tests/misc/uniq.pl b/tests/misc/uniq.pl new file mode 100755 index 000000000..d0e6d151a --- /dev/null +++ b/tests/misc/uniq.pl @@ -0,0 +1,218 @@ +#!/usr/bin/perl +# Test uniq. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $limits = getlimits (); + +my $prog = 'uniq'; +my $try = "Try '$prog --help' for more information.\n"; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +# When possible, create a "-z"-testing variant of each test. +sub add_z_variants($) +{ + my ($tests) = @_; + my @new; + TEST: + foreach my $t (@$tests) + { + push @new, $t; + + # skip the obsolete-syntax tests + $t->[0] =~ /^obs-plus/ + and next; + + my @args; + my @list_of_hash; + + foreach my $e (@$t) + { + !ref $e + and push (@args, $e), next; + + ref $e && ref $e eq 'HASH' + or (warn "$0: $t->[0]: unexpected entry type\n"), next; + my $tmp = $e; + foreach my $k (qw(IN OUT)) + { + my $val = $e->{$k}; + # skip any test whose input or output already contains a NUL byte + if (defined $val) + { + $val =~ /\0/ + and next TEST; + + # Convert each NL in input or output to \0. + $val =~ s/\n/\0/g; + $tmp = {$k => $val}; + last; + } + } + push @list_of_hash, $tmp; + } + + shift @args; # discard test name + + # skip any test that uses the -z option + grep /z/, @args + and next; + + push @new, ["$t->[0]-z", '-z', @args, @list_of_hash]; + } + return @new; +} + +# I've only ever triggered the problem in a non-C locale. +my $locale = $ENV{LOCALE_FR}; +! defined $locale || $locale eq 'none' + and CuSkip::skip "$prog: skipping this test -- no appropriate locale\n"; + +# See if isblank returns true for nbsp. +my $x = qx!env printf '\xa0'| LC_ALL=$locale tr '[:blank:]' x!; +# If so, expect just one line of output in the schar test. +# Otherwise, expect two. +my $in = " y z\n\xa0 y z\n"; +my $schar_exp = $x eq 'x' ? " y z\n" : $in; + +my @Tests = +( + # Test for a subtle, system-and-locale-dependent bug in uniq. + ['schar', '-f1', {IN => $in}, {OUT => $schar_exp}, + {ENV => "LC_ALL=$locale"}], + ['1', '', {IN=>''}, {OUT=>''}], + ['2', '', {IN=>"a\na\n"}, {OUT=>"a\n"}], + ['3', '', {IN=>"a\na"}, {OUT=>"a\n"}], + ['4', '', {IN=>"a\nb"}, {OUT=>"a\nb\n"}], + ['5', '', {IN=>"a\na\nb"}, {OUT=>"a\nb\n"}], + ['6', '', {IN=>"b\na\na\n"}, {OUT=>"b\na\n"}], + ['7', '', {IN=>"a\nb\nc\n"}, {OUT=>"a\nb\nc\n"}], + + # Ensure that newlines are not interpreted with -z. + ['2z', '-z', {IN=>"a\na\n"}, {OUT=>"a\na\n\0"}], + ['3z', '-z', {IN=>"a\na"}, {OUT=>"a\na\0"}], + ['4z', '-z', {IN=>"a\nb"}, {OUT=>"a\nb\0"}], + ['5z', '-z', {IN=>"a\na\nb"}, {OUT=>"a\na\nb\0"}], + ['20z', '-dz', {IN=>"a\na\n"}, {OUT=>""}], + + # Make sure that eight bit characters work + ['8', '', {IN=>"ö\nv\n"}, {OUT=>"ö\nv\n"}], + # Test output of -u option; only unique lines + ['9', '-u', {IN=>"a\na\n"}, {OUT=>""}], + ['10', '-u', {IN=>"a\nb\n"}, {OUT=>"a\nb\n"}], + ['11', '-u', {IN=>"a\nb\na\n"}, {OUT=>"a\nb\na\n"}], + ['12', '-u', {IN=>"a\na\n"}, {OUT=>""}], + ['13', '-u', {IN=>"a\na\n"}, {OUT=>""}], + #['5', '-u', "a\na\n", "", 0], + # Test output of -d option; only repeated lines + ['20', '-d', {IN=>"a\na\n"}, {OUT=>"a\n"}], + ['21', '-d', {IN=>"a\nb\n"}, {OUT=>""}], + ['22', '-d', {IN=>"a\nb\na\n"}, {OUT=>""}], + ['23', '-d', {IN=>"a\na\nb\n"}, {OUT=>"a\n"}], + # Check the key options + # If we skip over fields or characters, is the output deterministic? + ['obs30', '-1', {IN=>"a a\nb a\n"}, {OUT=>"a a\n"}], + ['31', qw(-f 1), {IN=>"a a\nb a\n"}, {OUT=>"a a\n"}], + ['32', qw(-f 1), {IN=>"a a\nb b\n"}, {OUT=>"a a\nb b\n"}], + ['33', qw(-f 1), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\nb a c\n"}], + ['34', qw(-f 1), {IN=>"b a\na a\n"}, {OUT=>"b a\n"}], + ['35', qw(-f 2), {IN=>"a a c\nb a c\n"}, {OUT=>"a a c\n"}], + # Skip over characters. + ['obs-plus40', '+1', {IN=>"aaa\naaa\n"}, {OUT=>"aaa\n"}], + ['obs-plus41', '+1', {IN=>"baa\naaa\n"}, {OUT=>"baa\n"}], + ['42', qw(-s 1), {IN=>"aaa\naaa\n"}, {OUT=>"aaa\n"}], + ['43', qw(-s 2), {IN=>"baa\naaa\n"}, {OUT=>"baa\n"}], + ['obs-plus44', qw(+1 --), {IN=>"aaa\naaa\n"}, {OUT=>"aaa\n"}], + ['obs-plus45', qw(+1 --), {IN=>"baa\naaa\n"}, {OUT=>"baa\n"}], + # Skip over fields and characters + ['50', qw(-f 1 -s 1), {IN=>"a aaa\nb ab\n"}, {OUT=>"a aaa\nb ab\n"}], + ['51', qw(-f 1 -s 1), {IN=>"a aaa\nb aaa\n"}, {OUT=>"a aaa\n"}], + ['52', qw(-s 1 -f 1), {IN=>"a aaa\nb ab\n"}, {OUT=>"a aaa\nb ab\n"}], + ['53', qw(-s 1 -f 1), {IN=>"a aaa\nb aaa\n"}, {OUT=>"a aaa\n"}], + # Fixed in 2.0.15 + ['54', qw(-s 4), {IN=>"abc\nabcd\n"}, {OUT=>"abc\n"}], + # Supported in 2.0.15 + ['55', qw(-s 0), {IN=>"abc\nabcd\n"}, {OUT=>"abc\nabcd\n"}], + ['56', qw(-s 0), {IN=>"abc\n"}, {OUT=>"abc\n"}], + ['57', qw(-w 0), {IN=>"abc\nabcd\n"}, {OUT=>"abc\n"}], + # Only account for a number of characters + ['60', qw(-w 1), {IN=>"a a\nb a\n"}, {OUT=>"a a\nb a\n"}], + ['61', qw(-w 3), {IN=>"a a\nb a\n"}, {OUT=>"a a\nb a\n"}], + ['62', qw(-w 1 -f 1), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\n"}], + ['63', qw(-f 1 -w 1), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\n"}], + # The blank after field one is checked too + ['64', qw(-f 1 -w 4), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\nb a c\n"}], + ['65', qw(-f 1 -w 3), {IN=>"a a a\nb a c\n"}, {OUT=>"a a a\n"}], + # Make sure we don't break if the file contains \0 + ['90', '', {IN=>"a\0a\na\n"}, {OUT=>"a\0a\na\n"}], + # Check fields separated by tabs and by spaces + ['91', '', {IN=>"a\ta\na a\n"}, {OUT=>"a\ta\na a\n"}], + ['92', qw(-f 1), {IN=>"a\ta\na a\n"}, {OUT=>"a\ta\na a\n"}], + ['93', qw(-f 2), {IN=>"a\ta a\na a a\n"}, {OUT=>"a\ta a\n"}], + ['94', qw(-f 1), {IN=>"a\ta\na\ta\n"}, {OUT=>"a\ta\n"}], + # Check the count option; add tests for other options too + ['101', '-c', {IN=>"a\nb\n"}, {OUT=>" 1 a\n 1 b\n"}], + ['102', '-c', {IN=>"a\na\n"}, {OUT=>" 2 a\n"}], + # Check the local -D (--all-repeated) option + ['110', '-D', {IN=>"a\na\n"}, {OUT=>"a\na\n"}], + ['111', qw(-D -w1), {IN=>"a a\na b\n"}, {OUT=>"a a\na b\n"}], + ['112', qw(-D -c), {IN=>"a a\na b\n"}, {OUT=>""}, {EXIT=>1}, {ERR=> + "$prog: printing all duplicated lines and repeat counts is meaningless\n$try"} + ], + ['113', '--all-repeated=separate', {IN=>"a\na\n"}, {OUT=>"a\na\n"}], + ['114', '--all-repeated=separate', + {IN=>"a\na\nb\nc\nc\n"}, {OUT=>"a\na\n\nc\nc\n"}], + ['115', '--all-repeated=separate', + {IN=>"a\na\nb\nb\nc\n"}, {OUT=>"a\na\n\nb\nb\n"}], + ['116', '--all-repeated=prepend', {IN=>"a\na\n"}, {OUT=>"\na\na\n"}], + ['117', '--all-repeated=prepend', + {IN=>"a\na\nb\nc\nc\n"}, {OUT=>"\na\na\n\nc\nc\n"}], + ['118', '--all-repeated=prepend', {IN=>"a\nb\n"}, {OUT=>""}], + ['119', '--all-repeated=badoption', {IN=>"a\n"}, {OUT=>""}, {EXIT=>1}, + {ERR=>"$prog: invalid argument 'badoption' for '--all-repeated'\n" + . "Valid arguments are:\n" + . " - 'none'\n" + . " - 'prepend'\n" + . " - 'separate'\n" + . $try}], + # Check that -d and -u suppress all output, as POSIX requires. + ['120', qw(-d -u), {IN=>"a\na\n\b"}, {OUT=>""}], + ['121', "-d -u -w$limits->{UINTMAX_OFLOW}", {IN=>"a\na\n\b"}, {OUT=>""}], + ['122', "-d -u -w$limits->{SIZE_OFLOW}", {IN=>"a\na\n\b"}, {OUT=>""}], + # Check that --zero-terminated is synonymous with -z. + ['123', '--zero-terminated', {IN=>"a\na\nb"}, {OUT=>"a\na\nb\0"}], + ['124', '--zero-terminated', {IN=>"a\0a\0b"}, {OUT=>"a\0b\0"}], +); + +# Set _POSIX2_VERSION=199209 in the environment of each obs-plus* test. +foreach my $t (@Tests) + { + $t->[0] =~ /^obs-plus/ + and push @$t, {ENV=>'_POSIX2_VERSION=199209'}; + } + +@Tests = add_z_variants \@Tests; +@Tests = triple_test \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/wc b/tests/misc/wc deleted file mode 100755 index 713663f7b..000000000 --- a/tests/misc/wc +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl -# Basic tests for "wc". - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -my $prog = 'wc'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - ['a0', '-c', {IN_PIPE=>''}, {OUT=>"0\n"}], - ['a1', '-l', {IN_PIPE=>''}, {OUT=>"0\n"}], - ['a2', '-w', {IN_PIPE=>''}, {OUT=>"0\n"}], - ['a3', '-c', {IN_PIPE=>'x'}, {OUT=>"1\n"}], - ['a4', '-w', {IN_PIPE=>'x'}, {OUT=>"1\n"}], - ['a5', '-w', {IN_PIPE=>"x y\n"}, {OUT=>"2\n"}], - ['a6', '-w', {IN_PIPE=>"x y\nz"}, {OUT=>"3\n"}], - # Remember, -l counts *newline* bytes, not logical lines. - ['a7', '-l', {IN_PIPE=>"x y"}, {OUT=>"0\n"}], - ['a8', '-l', {IN_PIPE=>"x y\n"}, {OUT=>"1\n"}], - ['a9', '-l', {IN_PIPE=>"x\ny\n"}, {OUT=>"2\n"}], - ['b0', '', {IN_PIPE=>""}, {OUT=>" 0 0 0\n"}], - ['b1', '', {IN_PIPE=>"a b\nc\n"}, {OUT=>" 2 3 6\n"}], - ['c0', '-L', {IN_PIPE=>"1\n12\n"}, {OUT=>"2\n"}], - ['c1', '-L', {IN_PIPE=>"1\n123\n1\n"}, {OUT=>"3\n"}], - ['c2', '-L', {IN_PIPE=>"\n123456"}, {OUT=>"6\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/wc-files0 b/tests/misc/wc-files0 deleted file mode 100755 index 9a0d0501d..000000000 --- a/tests/misc/wc-files0 +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Show that wc's new --files0-from option works. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ wc - -echo 2 > 2b || framework_failure_ -echo 2 words > 2w || framework_failure_ -printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure_ - - -wc --files0-from=names > out || fail=1 -cat <<\EOF > exp || fail=1 - 1 1 2 2b - 1 2 8 2w - 2 3 10 total -EOF - -compare exp out || fail=1 - -if test "$fail" = ''; then - # Repeat the above test, but read the file name list from stdin. - rm -f out - wc --files0-from=- < names > out || fail=1 - compare exp out || fail=1 -fi - -Exit $fail diff --git a/tests/misc/wc-files0-from b/tests/misc/wc-files0-from deleted file mode 100755 index 0f99aeeb6..000000000 --- a/tests/misc/wc-files0-from +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/perl -# Exercise wc's --files0-from option. -# FIXME: keep this file in sync with tests/du/files0-from. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -my $prog = 'wc'; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my @Tests = - ( - # invalid extra command line argument - ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1}, - {ERR => "$prog: extra operand 'no-such'\n" - . "file operands cannot be combined with --files0-from\n" - . "Try '$prog --help' for more information.\n"} - ], - - # missing input file - ['missing', '--files0-from=missing', {EXIT=>1}, - {ERR => "$prog: cannot open 'missing' for reading: " - . "No such file or directory\n"}], - - # input file name of '-' - ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1}, - {ERR => "$prog: when reading file names from stdin, no file name of" - . " '-' allowed\n"}], - - # empty input, regular file - ['empty', '--files0-from=@AUX@', {AUX=>''}], - - # empty input, from non-regular file - ['empty-nonreg', '--files0-from=/dev/null'], - - # one NUL - ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, - {ERR => "$prog: -:1: invalid zero-length file name\n"}], - - # two NULs - ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, - {OUT=>"0 0 0 total\n"}, - {ERR => "$prog: -:1: invalid zero-length file name\n" - . "$prog: -:2: invalid zero-length file name\n"}], - - # one file name, no NUL - ['1', '--files0-from=-', '<', - {IN=>{f=>"g"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ], - - # one file name, with NUL - ['1a', '--files0-from=-', '<', - {IN=>{f=>"g\0"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ], - - # two file names, no final NUL - ['2', '--files0-from=-', '<', - {IN=>{f=>"g\0g"}}, {AUX=>{g=>''}}, - {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ], - - # two file names, with final NUL - ['2a', '--files0-from=-', '<', - {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>''}}, - {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ], - - # Ensure that $prog processes FILEs following a zero-length name. - ['zero-len', '--files0-from=-', '<', - {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, - {OUT=>"0 0 0 g\n0 0 0 total\n"}, - {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/wc-files0-from.pl b/tests/misc/wc-files0-from.pl new file mode 100755 index 000000000..0f99aeeb6 --- /dev/null +++ b/tests/misc/wc-files0-from.pl @@ -0,0 +1,93 @@ +#!/usr/bin/perl +# Exercise wc's --files0-from option. +# FIXME: keep this file in sync with tests/du/files0-from. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +my $prog = 'wc'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + # invalid extra command line argument + ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1}, + {ERR => "$prog: extra operand 'no-such'\n" + . "file operands cannot be combined with --files0-from\n" + . "Try '$prog --help' for more information.\n"} + ], + + # missing input file + ['missing', '--files0-from=missing', {EXIT=>1}, + {ERR => "$prog: cannot open 'missing' for reading: " + . "No such file or directory\n"}], + + # input file name of '-' + ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1}, + {ERR => "$prog: when reading file names from stdin, no file name of" + . " '-' allowed\n"}], + + # empty input, regular file + ['empty', '--files0-from=@AUX@', {AUX=>''}], + + # empty input, from non-regular file + ['empty-nonreg', '--files0-from=/dev/null'], + + # one NUL + ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1}, + {ERR => "$prog: -:1: invalid zero-length file name\n"}], + + # two NULs + ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1}, + {OUT=>"0 0 0 total\n"}, + {ERR => "$prog: -:1: invalid zero-length file name\n" + . "$prog: -:2: invalid zero-length file name\n"}], + + # one file name, no NUL + ['1', '--files0-from=-', '<', + {IN=>{f=>"g"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ], + + # one file name, with NUL + ['1a', '--files0-from=-', '<', + {IN=>{f=>"g\0"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ], + + # two file names, no final NUL + ['2', '--files0-from=-', '<', + {IN=>{f=>"g\0g"}}, {AUX=>{g=>''}}, + {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ], + + # two file names, with final NUL + ['2a', '--files0-from=-', '<', + {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>''}}, + {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ], + + # Ensure that $prog processes FILEs following a zero-length name. + ['zero-len', '--files0-from=-', '<', + {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}}, + {OUT=>"0 0 0 g\n0 0 0 total\n"}, + {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/wc-files0.sh b/tests/misc/wc-files0.sh new file mode 100755 index 000000000..9a0d0501d --- /dev/null +++ b/tests/misc/wc-files0.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Show that wc's new --files0-from option works. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ wc + +echo 2 > 2b || framework_failure_ +echo 2 words > 2w || framework_failure_ +printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure_ + + +wc --files0-from=names > out || fail=1 +cat <<\EOF > exp || fail=1 + 1 1 2 2b + 1 2 8 2w + 2 3 10 total +EOF + +compare exp out || fail=1 + +if test "$fail" = ''; then + # Repeat the above test, but read the file name list from stdin. + rm -f out + wc --files0-from=- < names > out || fail=1 + compare exp out || fail=1 +fi + +Exit $fail diff --git a/tests/misc/wc-parallel b/tests/misc/wc-parallel deleted file mode 100755 index 6611b47c2..000000000 --- a/tests/misc/wc-parallel +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Ensure that wc prints counts atomically -# so that concurrent processes don't intersperse their output - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ wc - -(mkdir tmp && cd tmp && seq 2000 | xargs touch) - -# This will output at least 16KiB per process -# and start 3 processes, with 2 running concurrently, -# which triggers often on Fedora 11 at least. -(find tmp tmp tmp -type f | xargs -n2000 -P2 wc) | -sed -n '/0 0 0 /!p' | -grep . > /dev/null && fail=1 - -Exit $fail diff --git a/tests/misc/wc-parallel.sh b/tests/misc/wc-parallel.sh new file mode 100755 index 000000000..6611b47c2 --- /dev/null +++ b/tests/misc/wc-parallel.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Ensure that wc prints counts atomically +# so that concurrent processes don't intersperse their output + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ wc + +(mkdir tmp && cd tmp && seq 2000 | xargs touch) + +# This will output at least 16KiB per process +# and start 3 processes, with 2 running concurrently, +# which triggers often on Fedora 11 at least. +(find tmp tmp tmp -type f | xargs -n2000 -P2 wc) | +sed -n '/0 0 0 /!p' | +grep . > /dev/null && fail=1 + +Exit $fail diff --git a/tests/misc/wc.pl b/tests/misc/wc.pl new file mode 100755 index 000000000..713663f7b --- /dev/null +++ b/tests/misc/wc.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +# Basic tests for "wc". + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +my $prog = 'wc'; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my @Tests = + ( + ['a0', '-c', {IN_PIPE=>''}, {OUT=>"0\n"}], + ['a1', '-l', {IN_PIPE=>''}, {OUT=>"0\n"}], + ['a2', '-w', {IN_PIPE=>''}, {OUT=>"0\n"}], + ['a3', '-c', {IN_PIPE=>'x'}, {OUT=>"1\n"}], + ['a4', '-w', {IN_PIPE=>'x'}, {OUT=>"1\n"}], + ['a5', '-w', {IN_PIPE=>"x y\n"}, {OUT=>"2\n"}], + ['a6', '-w', {IN_PIPE=>"x y\nz"}, {OUT=>"3\n"}], + # Remember, -l counts *newline* bytes, not logical lines. + ['a7', '-l', {IN_PIPE=>"x y"}, {OUT=>"0\n"}], + ['a8', '-l', {IN_PIPE=>"x y\n"}, {OUT=>"1\n"}], + ['a9', '-l', {IN_PIPE=>"x\ny\n"}, {OUT=>"2\n"}], + ['b0', '', {IN_PIPE=>""}, {OUT=>" 0 0 0\n"}], + ['b1', '', {IN_PIPE=>"a b\nc\n"}, {OUT=>" 2 3 6\n"}], + ['c0', '-L', {IN_PIPE=>"1\n12\n"}, {OUT=>"2\n"}], + ['c1', '-L', {IN_PIPE=>"1\n123\n1\n"}, {OUT=>"3\n"}], + ['c2', '-L', {IN_PIPE=>"\n123456"}, {OUT=>"6\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/misc/xattr b/tests/misc/xattr deleted file mode 100755 index ff50e6c9c..000000000 --- a/tests/misc/xattr +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh -# Ensure that cp --preserve=xattr, cp --preserve=all and mv preserve extended -# attributes and install does not preserve extended attributes. -# cp -a should preserve xattr, error diagnostics should not be displayed - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv ginstall - -# Skip this test if cp was built without xattr support: -touch src dest || framework_failure_ -cp --preserve=xattr -n src dest \ - || skip_ "coreutils built without xattr support" - -# this code was taken from test mv/backup-is-src -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" -b_other="$other_partition_tmpdir/b" -rm -f "$b_other" || framework_failure_ - -# testing xattr name-value pair -xattr_name="user.foo" -xattr_value="bar" -xattr_pair="$xattr_name=\"$xattr_value\"" - -# create new file and check its xattrs -touch a || framework_failure_ -getfattr -d a >out_a || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_a && framework_failure_ - -# try to set user xattr on file -setfattr -n "$xattr_name" -v "$xattr_value" a >out_a \ - || skip_ "failed to set xattr of file" -getfattr -d a >out_a || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_a \ - || skip_ "failed to set xattr of file" - - -# cp should not preserve xattr by default -cp a b || fail=1 -getfattr -d b >out_b || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_b && fail=1 - -# test if --preserve=xattr option works -cp --preserve=xattr a b || fail=1 -getfattr -d b >out_b || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_b || fail=1 - -# test if --preserve=all option works -cp --preserve=all a c || fail=1 -getfattr -d c >out_c || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_c || fail=1 - -# cp's -a option must produce no diagnostics. -cp -a a d 2>err && test -s err && fail=1 -getfattr -d d >out_d || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_d || fail=1 - -# test if --preserve=xattr works even for files without write access -chmod a-w a || framework_failure_ -rm -f e -cp --preserve=xattr a e || fail=1 -getfattr -d e >out_e || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_e || fail=1 - -# Ensure that permission bits are preserved, too. -src_perm=$(stat --format=%a a) -dst_perm=$(stat --format=%a e) -test "$dst_perm" = "$src_perm" || fail=1 - -chmod u+w a || framework_failure_ - -rm b || framework_failure_ - -# install should never preserve xattr -ginstall a b || fail=1 -getfattr -d b >out_b || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_b && fail=1 - -# mv should preserve xattr when renaming within a file system. -# This is implicitly done by rename () and doesn't need explicit -# xattr support in mv. -mv a b || fail=1 -getfattr -d b >out_b || skip_ "failed to get xattr of file" -grep -F "$xattr_pair" out_b || cat >&2 <out_a \ - || test_mv=0 -getfattr -d "$b_other" >out_b || test_mv=0 -grep -F "$xattr_pair" out_b || test_mv=0 -rm -f "$b_other" || framework_failure_ - -if test $test_mv -eq 1; then - # mv should preserve xattr when copying content from one partition to another - mv b "$b_other" || fail=1 - getfattr -d "$b_other" >out_b || - skip_ "failed to get xattr of file" - grep -F "$xattr_pair" out_b || fail=1 -else - cat >&2 <. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv ginstall + +# Skip this test if cp was built without xattr support: +touch src dest || framework_failure_ +cp --preserve=xattr -n src dest \ + || skip_ "coreutils built without xattr support" + +# this code was taken from test mv/backup-is-src +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" +b_other="$other_partition_tmpdir/b" +rm -f "$b_other" || framework_failure_ + +# testing xattr name-value pair +xattr_name="user.foo" +xattr_value="bar" +xattr_pair="$xattr_name=\"$xattr_value\"" + +# create new file and check its xattrs +touch a || framework_failure_ +getfattr -d a >out_a || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_a && framework_failure_ + +# try to set user xattr on file +setfattr -n "$xattr_name" -v "$xattr_value" a >out_a \ + || skip_ "failed to set xattr of file" +getfattr -d a >out_a || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_a \ + || skip_ "failed to set xattr of file" + + +# cp should not preserve xattr by default +cp a b || fail=1 +getfattr -d b >out_b || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_b && fail=1 + +# test if --preserve=xattr option works +cp --preserve=xattr a b || fail=1 +getfattr -d b >out_b || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_b || fail=1 + +# test if --preserve=all option works +cp --preserve=all a c || fail=1 +getfattr -d c >out_c || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_c || fail=1 + +# cp's -a option must produce no diagnostics. +cp -a a d 2>err && test -s err && fail=1 +getfattr -d d >out_d || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_d || fail=1 + +# test if --preserve=xattr works even for files without write access +chmod a-w a || framework_failure_ +rm -f e +cp --preserve=xattr a e || fail=1 +getfattr -d e >out_e || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_e || fail=1 + +# Ensure that permission bits are preserved, too. +src_perm=$(stat --format=%a a) +dst_perm=$(stat --format=%a e) +test "$dst_perm" = "$src_perm" || fail=1 + +chmod u+w a || framework_failure_ + +rm b || framework_failure_ + +# install should never preserve xattr +ginstall a b || fail=1 +getfattr -d b >out_b || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_b && fail=1 + +# mv should preserve xattr when renaming within a file system. +# This is implicitly done by rename () and doesn't need explicit +# xattr support in mv. +mv a b || fail=1 +getfattr -d b >out_b || skip_ "failed to get xattr of file" +grep -F "$xattr_pair" out_b || cat >&2 <out_a \ + || test_mv=0 +getfattr -d "$b_other" >out_b || test_mv=0 +grep -F "$xattr_pair" out_b || test_mv=0 +rm -f "$b_other" || framework_failure_ + +if test $test_mv -eq 1; then + # mv should preserve xattr when copying content from one partition to another + mv b "$b_other" || fail=1 + getfattr -d "$b_other" >out_b || + skip_ "failed to get xattr of file" + grep -F "$xattr_pair" out_b || fail=1 +else + cat >&2 <. - -use strict; - -(my $ME = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = 'pr'; -my $too_big = '9' x 81; # Big enough to overflow a 256-bit integer. -my @Tests = - ( - # test-name, [option, option, ...] {OUT=>"expected-output"} - - ['inval-suffix', "--pages=${too_big}h", {EXIT => 1}, - {ERR=>"$prog: invalid suffix in --pages argument '${too_big}h'\n"}], - - ['too-big', "--pages=$too_big", {EXIT => 1}, - {ERR=>"$prog: --pages argument '$too_big' too large\n"}], - - ['simply-inval', "--pages=x", {EXIT => 1}, - {ERR=>"$prog: invalid --pages argument 'x'\n"}], - - ['inv-pg-range', "--pages=9x", {EXIT => 1}, - {ERR=>"$prog: invalid page range '9x'\n"}], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/misc/xstrtol.pl b/tests/misc/xstrtol.pl new file mode 100755 index 000000000..fa0056fcd --- /dev/null +++ b/tests/misc/xstrtol.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl +# exercise xstrtol's diagnostics via pr + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $ME = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = 'pr'; +my $too_big = '9' x 81; # Big enough to overflow a 256-bit integer. +my @Tests = + ( + # test-name, [option, option, ...] {OUT=>"expected-output"} + + ['inval-suffix', "--pages=${too_big}h", {EXIT => 1}, + {ERR=>"$prog: invalid suffix in --pages argument '${too_big}h'\n"}], + + ['too-big', "--pages=$too_big", {EXIT => 1}, + {ERR=>"$prog: --pages argument '$too_big' too large\n"}], + + ['simply-inval', "--pages=x", {EXIT => 1}, + {ERR=>"$prog: invalid --pages argument 'x'\n"}], + + ['inv-pg-range', "--pages=9x", {EXIT => 1}, + {ERR=>"$prog: invalid page range '9x'\n"}], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/mkdir/p-1 b/tests/mkdir/p-1 deleted file mode 100755 index cd8e67606..000000000 --- a/tests/mkdir/p-1 +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Test "mkdir -p". - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir - -mkdir --parents "$(pwd)/t" || fail=1 -test -d t || fail=1 - -Exit $fail diff --git a/tests/mkdir/p-1.sh b/tests/mkdir/p-1.sh new file mode 100755 index 000000000..cd8e67606 --- /dev/null +++ b/tests/mkdir/p-1.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Test "mkdir -p". + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir + +mkdir --parents "$(pwd)/t" || fail=1 +test -d t || fail=1 + +Exit $fail diff --git a/tests/mkdir/p-2 b/tests/mkdir/p-2 deleted file mode 100755 index d0c487ec9..000000000 --- a/tests/mkdir/p-2 +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Just like p-1, but with an absolute path. - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir - -mkdir --parents "$(pwd)/t/u" || fail=1 -test -d t/u || fail=1 - -Exit $fail diff --git a/tests/mkdir/p-2.sh b/tests/mkdir/p-2.sh new file mode 100755 index 000000000..d0c487ec9 --- /dev/null +++ b/tests/mkdir/p-2.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Just like p-1, but with an absolute path. + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir + +mkdir --parents "$(pwd)/t/u" || fail=1 +test -d t/u || fail=1 + +Exit $fail diff --git a/tests/mkdir/p-3 b/tests/mkdir/p-3 deleted file mode 100755 index 7031b2ede..000000000 --- a/tests/mkdir/p-3 +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Ensure that mkdir-p.c's fail-to-return-to-initial-working-directory -# causes immediate failure. Also, ensure that we don't create -# subsequent, relative command-line arguments in the wrong place. - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir -skip_if_root_ - -mkdir no-access || framework_failure_ -mkdir no-acce2s || framework_failure_ -mkdir -p no-acce3s/d || framework_failure_ - -p=$(pwd) -(cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1 -test -d "$p/a/b" || fail=1 - -# Same as above, but with a following *absolute* name, it should succeed -(cd no-acce2s && chmod 0 . && mkdir -p "$p/b/b" "$p/z") || fail=1 -test -d "$p/b/b" && test -d "$p/z" || fail=1 - -# Same as above, but a trailing relative name in an unreadable directory -# whose parent is inaccessible. coreutils 5.97 fails this test. -# Perform this test only if "." is on a local file system. -# Otherwise, it would fail e.g., on an NFS-mounted file system. -if is_local_dir_ .; then - (cd no-acce3s/d && chmod a-r . && chmod a-rx .. && - mkdir -p a/b "$p/b/c" d/e && test -d a/b && test -d d/e) || fail=1 - test -d "$p/b/c" || fail=1 -fi - -b=$(ls "$p/a" | tr -d '\n') -# With coreutils-5.3.0, this would fail with $b=bu. -test "x$b" = xb || fail=1 - -Exit $fail diff --git a/tests/mkdir/p-3.sh b/tests/mkdir/p-3.sh new file mode 100755 index 000000000..7031b2ede --- /dev/null +++ b/tests/mkdir/p-3.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Ensure that mkdir-p.c's fail-to-return-to-initial-working-directory +# causes immediate failure. Also, ensure that we don't create +# subsequent, relative command-line arguments in the wrong place. + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir +skip_if_root_ + +mkdir no-access || framework_failure_ +mkdir no-acce2s || framework_failure_ +mkdir -p no-acce3s/d || framework_failure_ + +p=$(pwd) +(cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1 +test -d "$p/a/b" || fail=1 + +# Same as above, but with a following *absolute* name, it should succeed +(cd no-acce2s && chmod 0 . && mkdir -p "$p/b/b" "$p/z") || fail=1 +test -d "$p/b/b" && test -d "$p/z" || fail=1 + +# Same as above, but a trailing relative name in an unreadable directory +# whose parent is inaccessible. coreutils 5.97 fails this test. +# Perform this test only if "." is on a local file system. +# Otherwise, it would fail e.g., on an NFS-mounted file system. +if is_local_dir_ .; then + (cd no-acce3s/d && chmod a-r . && chmod a-rx .. && + mkdir -p a/b "$p/b/c" d/e && test -d a/b && test -d d/e) || fail=1 + test -d "$p/b/c" || fail=1 +fi + +b=$(ls "$p/a" | tr -d '\n') +# With coreutils-5.3.0, this would fail with $b=bu. +test "x$b" = xb || fail=1 + +Exit $fail diff --git a/tests/mkdir/p-slashdot b/tests/mkdir/p-slashdot deleted file mode 100755 index 76d21d055..000000000 --- a/tests/mkdir/p-slashdot +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Ensure that mkdir -p works with arguments specified with a trailing "/.". - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir - - -mkdir -p d1/. || fail=1 -test -d d1 || fail=1 - -mkdir -p d2/.. || fail=1 -test -d d2 || fail=1 - -Exit $fail diff --git a/tests/mkdir/p-slashdot.sh b/tests/mkdir/p-slashdot.sh new file mode 100755 index 000000000..76d21d055 --- /dev/null +++ b/tests/mkdir/p-slashdot.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Ensure that mkdir -p works with arguments specified with a trailing "/.". + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir + + +mkdir -p d1/. || fail=1 +test -d d1 || fail=1 + +mkdir -p d2/.. || fail=1 +test -d d2 || fail=1 + +Exit $fail diff --git a/tests/mkdir/p-thru-slink b/tests/mkdir/p-thru-slink deleted file mode 100755 index 3f5993248..000000000 --- a/tests/mkdir/p-thru-slink +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Ensure that mkdir -p foo/bar works when foo is a symbolic link to a directory - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir - -ln -s . slink || framework_failure_ - -mkdir -p slink/x || fail=1 -test -d x || fail=1 - -Exit $fail diff --git a/tests/mkdir/p-thru-slink.sh b/tests/mkdir/p-thru-slink.sh new file mode 100755 index 000000000..3f5993248 --- /dev/null +++ b/tests/mkdir/p-thru-slink.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Ensure that mkdir -p foo/bar works when foo is a symbolic link to a directory + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir + +ln -s . slink || framework_failure_ + +mkdir -p slink/x || fail=1 +test -d x || fail=1 + +Exit $fail diff --git a/tests/mkdir/p-v b/tests/mkdir/p-v deleted file mode 100755 index d6dcfdd87..000000000 --- a/tests/mkdir/p-v +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Test mkdir -pv. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir - -mkdir -pv foo/a/b/c/d >out || fail=1 - -compare - out <<\EOF -mkdir: created directory 'foo' -mkdir: created directory 'foo/a' -mkdir: created directory 'foo/a/b' -mkdir: created directory 'foo/a/b/c' -mkdir: created directory 'foo/a/b/c/d' -EOF - -Exit $fail diff --git a/tests/mkdir/p-v.sh b/tests/mkdir/p-v.sh new file mode 100755 index 000000000..d6dcfdd87 --- /dev/null +++ b/tests/mkdir/p-v.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Test mkdir -pv. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir + +mkdir -pv foo/a/b/c/d >out || fail=1 + +compare - out <<\EOF +mkdir: created directory 'foo' +mkdir: created directory 'foo/a' +mkdir: created directory 'foo/a/b' +mkdir: created directory 'foo/a/b/c' +mkdir: created directory 'foo/a/b/c/d' +EOF + +Exit $fail diff --git a/tests/mkdir/parents b/tests/mkdir/parents deleted file mode 100755 index 0543e675e..000000000 --- a/tests/mkdir/parents +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# make sure mkdir's -p options works properly - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir -skip_if_setgid_ - -mkdir -m 700 e-dir || framework_failure_ - - -# Make sure 'mkdir -p existing-dir' succeeds -# and that 'mkdir existing-dir' fails. -mkdir -p e-dir || fail=1 -mkdir e-dir > /dev/null 2>&1 && fail=1 - -# Create an existing directory. -umask 077 -mode_str=drwxr-x-wx -mode_arg=$(rwx_to_mode_ $mode_str) -mkdir -m $mode_arg a || fail=1 - -# this 'mkdir -p ...' shouldn't change perms of existing dir 'a'. -d_mode_str=drwx-w--wx -d_mode_arg=$(rwx_to_mode_ $d_mode_str) -mkdir -p -m $d_mode_arg a/b/c/d - -# Make sure the permissions of 'a' haven't been changed. -p=$(ls -ld a|cut -b-10); case $p in $mode_str);; *) fail=1;; esac -# 'b's and 'c's should reflect the umask -p=$(ls -ld a/b|cut -b-10); case $p in drwx------);; *) fail=1;; esac -p=$(ls -ld a/b/c|cut -b-10); case $p in drwx------);; *) fail=1;; esac - -# 'd's perms are determined by the -m argument. -p=$(ls -ld a/b/c/d|cut -b-10); case $p in $d_mode_str);; *) fail=1;; esac - -Exit $fail diff --git a/tests/mkdir/parents.sh b/tests/mkdir/parents.sh new file mode 100755 index 000000000..0543e675e --- /dev/null +++ b/tests/mkdir/parents.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# make sure mkdir's -p options works properly + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir +skip_if_setgid_ + +mkdir -m 700 e-dir || framework_failure_ + + +# Make sure 'mkdir -p existing-dir' succeeds +# and that 'mkdir existing-dir' fails. +mkdir -p e-dir || fail=1 +mkdir e-dir > /dev/null 2>&1 && fail=1 + +# Create an existing directory. +umask 077 +mode_str=drwxr-x-wx +mode_arg=$(rwx_to_mode_ $mode_str) +mkdir -m $mode_arg a || fail=1 + +# this 'mkdir -p ...' shouldn't change perms of existing dir 'a'. +d_mode_str=drwx-w--wx +d_mode_arg=$(rwx_to_mode_ $d_mode_str) +mkdir -p -m $d_mode_arg a/b/c/d + +# Make sure the permissions of 'a' haven't been changed. +p=$(ls -ld a|cut -b-10); case $p in $mode_str);; *) fail=1;; esac +# 'b's and 'c's should reflect the umask +p=$(ls -ld a/b|cut -b-10); case $p in drwx------);; *) fail=1;; esac +p=$(ls -ld a/b/c|cut -b-10); case $p in drwx------);; *) fail=1;; esac + +# 'd's perms are determined by the -m argument. +p=$(ls -ld a/b/c/d|cut -b-10); case $p in $d_mode_str);; *) fail=1;; esac + +Exit $fail diff --git a/tests/mkdir/perm b/tests/mkdir/perm deleted file mode 100755 index f9b207f81..000000000 --- a/tests/mkdir/perm +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -# Verify that mkdir's '-m MODE' option works properly -# with various umask settings. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir -skip_if_setgid_ - -working_umask_or_skip_ - - -# parent parent/dir -# umask -m option resulting perm resulting perm -tests=' - 000 : empty : drwxrwxrwx : drwxrwxrwx : - 000 : -m 016 : drwxrwxrwx : d-----xrw- : - 077 : empty : drwx------ : drwx------ : - 050 : empty : drwx-w-rwx : drwx-w-rwx : - 050 : -m 312 : drwx-w-rwx : d-wx--x-w- : - 160 : empty : drwx--xrwx : drw---xrwx : - 160 : -m 743 : drwx--xrwx : drwxr---wx : - 027 : -m =+x : drwxr-x--- : d--x--x--- : - 027 : -m =+X : drwxr-x--- : d--x--x--- : - - : - : last : last : - ' -colon_tests=$(echo $tests | sed 's/^ *//; s/ *: */:/g') - -for p in empty -p; do - test _$p = _empty && p= - - old_IFS=$IFS - IFS=':' - set $colon_tests - IFS=$old_IFS - - while :; do - test "$VERBOSE" = yes && set -x - umask=$1 mode=$2 parent_perms=$3 sub_perms=$4 - test "_$mode" = _empty && mode= - test $sub_perms = last && break - # echo p=$p umask=$1 mode=$2 parent_perms=$3 sub_perms=$4 - shift; shift; shift; shift - umask $umask - - # If we're not using -p, then create the parent manually, - # and adjust expectations accordingly. - test x$p = x && \ - { - mkdir -m =,u=rwx parent || fail=1 - parent_perms=drwx------ - } - - mkdir $p $mode parent/sub || fail=1 - - perms=$(stat --printf %A parent) - test "$parent_perms" = "$perms" \ - || { fail=1; echo parent: expected $parent_perms, got $perms; } - - perms=$(stat --printf %A parent/sub) - test "$sub_perms" = "$perms" \ - || { fail=1; echo parent/sub: expected $sub_perms, got $perms; } - - chmod -R u+rwx parent - rm -rf parent || fail=1 - done -done - -Exit $fail diff --git a/tests/mkdir/perm.sh b/tests/mkdir/perm.sh new file mode 100755 index 000000000..f9b207f81 --- /dev/null +++ b/tests/mkdir/perm.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# Verify that mkdir's '-m MODE' option works properly +# with various umask settings. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir +skip_if_setgid_ + +working_umask_or_skip_ + + +# parent parent/dir +# umask -m option resulting perm resulting perm +tests=' + 000 : empty : drwxrwxrwx : drwxrwxrwx : + 000 : -m 016 : drwxrwxrwx : d-----xrw- : + 077 : empty : drwx------ : drwx------ : + 050 : empty : drwx-w-rwx : drwx-w-rwx : + 050 : -m 312 : drwx-w-rwx : d-wx--x-w- : + 160 : empty : drwx--xrwx : drw---xrwx : + 160 : -m 743 : drwx--xrwx : drwxr---wx : + 027 : -m =+x : drwxr-x--- : d--x--x--- : + 027 : -m =+X : drwxr-x--- : d--x--x--- : + - : - : last : last : + ' +colon_tests=$(echo $tests | sed 's/^ *//; s/ *: */:/g') + +for p in empty -p; do + test _$p = _empty && p= + + old_IFS=$IFS + IFS=':' + set $colon_tests + IFS=$old_IFS + + while :; do + test "$VERBOSE" = yes && set -x + umask=$1 mode=$2 parent_perms=$3 sub_perms=$4 + test "_$mode" = _empty && mode= + test $sub_perms = last && break + # echo p=$p umask=$1 mode=$2 parent_perms=$3 sub_perms=$4 + shift; shift; shift; shift + umask $umask + + # If we're not using -p, then create the parent manually, + # and adjust expectations accordingly. + test x$p = x && \ + { + mkdir -m =,u=rwx parent || fail=1 + parent_perms=drwx------ + } + + mkdir $p $mode parent/sub || fail=1 + + perms=$(stat --printf %A parent) + test "$parent_perms" = "$perms" \ + || { fail=1; echo parent: expected $parent_perms, got $perms; } + + perms=$(stat --printf %A parent/sub) + test "$sub_perms" = "$perms" \ + || { fail=1; echo parent/sub: expected $sub_perms, got $perms; } + + chmod -R u+rwx parent + rm -rf parent || fail=1 + done +done + +Exit $fail diff --git a/tests/mkdir/selinux b/tests/mkdir/selinux deleted file mode 100755 index 763236259..000000000 --- a/tests/mkdir/selinux +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# ensure that an invalid context doesn't cause a segfault - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir mkfifo mknod - -# Note: on an SELinux/enforcing system running mcstransd older than -# mcstrans-0.2.8-1.fc9, the following commands may mistakenly exit -# successfully, in spite of the invalid context string. -require_selinux_enforcing_ - -c=invalid-selinux-context -msg="failed to set default file creation context to '$c':" - -# Test each of mkdir, mknod, mkfifo with "-Z invalid-context". - -for cmd_w_arg in 'mkdir dir' 'mknod b p' 'mkfifo f'; do - # In OpenBSD's /bin/sh, mknod is a shell built-in. - # Running via "env" ensures we run our program and not the built-in. - env -- $cmd_w_arg -Z $c 2> out && fail=1 - set $cmd_w_arg; cmd=$1 - echo "$cmd: $msg" > exp || fail=1 - - # Some systems fail with ENOTSUP, EINVAL, ENOENT, or even - # "Unknown system error", or "Function not implemented". - # For AIX 5.3: "Unsupported attribute value" - # For HP-UX 11.23: Unknown error (252) - sed \ - -e 's/ Not supported$//' \ - -e 's/ Invalid argument$//' \ - -e 's/ Unknown system error$//' \ - -e 's/ Operation not supported$//' \ - -e 's/ Function not implemented$//' \ - -e 's/ Unsupported attribute value$//' \ - -e 's/ Unknown error .*$//' \ - -e 's/ No such file or directory$//' out > k || fail=1 - mv k out || fail=1 - compare exp out || fail=1 -done - -Exit $fail diff --git a/tests/mkdir/selinux.sh b/tests/mkdir/selinux.sh new file mode 100755 index 000000000..763236259 --- /dev/null +++ b/tests/mkdir/selinux.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# ensure that an invalid context doesn't cause a segfault + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir mkfifo mknod + +# Note: on an SELinux/enforcing system running mcstransd older than +# mcstrans-0.2.8-1.fc9, the following commands may mistakenly exit +# successfully, in spite of the invalid context string. +require_selinux_enforcing_ + +c=invalid-selinux-context +msg="failed to set default file creation context to '$c':" + +# Test each of mkdir, mknod, mkfifo with "-Z invalid-context". + +for cmd_w_arg in 'mkdir dir' 'mknod b p' 'mkfifo f'; do + # In OpenBSD's /bin/sh, mknod is a shell built-in. + # Running via "env" ensures we run our program and not the built-in. + env -- $cmd_w_arg -Z $c 2> out && fail=1 + set $cmd_w_arg; cmd=$1 + echo "$cmd: $msg" > exp || fail=1 + + # Some systems fail with ENOTSUP, EINVAL, ENOENT, or even + # "Unknown system error", or "Function not implemented". + # For AIX 5.3: "Unsupported attribute value" + # For HP-UX 11.23: Unknown error (252) + sed \ + -e 's/ Not supported$//' \ + -e 's/ Invalid argument$//' \ + -e 's/ Unknown system error$//' \ + -e 's/ Operation not supported$//' \ + -e 's/ Function not implemented$//' \ + -e 's/ Unsupported attribute value$//' \ + -e 's/ Unknown error .*$//' \ + -e 's/ No such file or directory$//' out > k || fail=1 + mv k out || fail=1 + compare exp out || fail=1 +done + +Exit $fail diff --git a/tests/mkdir/special-1 b/tests/mkdir/special-1 deleted file mode 100755 index d478930eb..000000000 --- a/tests/mkdir/special-1 +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# verify that mkdir honors special bits in MODE - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir - -set_mode_string=u=rwx,g=rx,o=w,-s,+t -output_mode_string=drwxr-x-wT - -tmp=t -mkdir -m$set_mode_string $tmp || fail=1 - -test -d $tmp || fail=1 -mode=$(ls -ld $tmp|cut -b-10) -case "$mode" in - $output_mode_string) ;; - *) fail=1 ;; -esac - -rmdir $tmp || fail=1 -tmp2=$tmp/sub - -# This should fail. -mkdir -m$set_mode_string $tmp2 2> /dev/null && fail=1 - -# Now test the --parents option. -mkdir --parents -m$set_mode_string $tmp2 || fail=1 - -test -d $tmp2 || fail=1 -mode=$(ls -ld $tmp2|cut -b-10) -case "$mode" in - $output_mode_string) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/mkdir/special-1.sh b/tests/mkdir/special-1.sh new file mode 100755 index 000000000..d478930eb --- /dev/null +++ b/tests/mkdir/special-1.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# verify that mkdir honors special bits in MODE + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir + +set_mode_string=u=rwx,g=rx,o=w,-s,+t +output_mode_string=drwxr-x-wT + +tmp=t +mkdir -m$set_mode_string $tmp || fail=1 + +test -d $tmp || fail=1 +mode=$(ls -ld $tmp|cut -b-10) +case "$mode" in + $output_mode_string) ;; + *) fail=1 ;; +esac + +rmdir $tmp || fail=1 +tmp2=$tmp/sub + +# This should fail. +mkdir -m$set_mode_string $tmp2 2> /dev/null && fail=1 + +# Now test the --parents option. +mkdir --parents -m$set_mode_string $tmp2 || fail=1 + +test -d $tmp2 || fail=1 +mode=$(ls -ld $tmp2|cut -b-10) +case "$mode" in + $output_mode_string) ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/mkdir/t-slash b/tests/mkdir/t-slash deleted file mode 100755 index 7b3c1ba30..000000000 --- a/tests/mkdir/t-slash +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Ensure that mkdir works with arguments specified with and without -# a trailing slash. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir - - -mkdir -p dir/ || fail=1 -test -d dir || fail=1 - -# This failed on NetBSD for fileutils-4.0.33. -mkdir d2/ || fail=1 -test -d d2 || fail=1 - -Exit $fail diff --git a/tests/mkdir/t-slash.sh b/tests/mkdir/t-slash.sh new file mode 100755 index 000000000..7b3c1ba30 --- /dev/null +++ b/tests/mkdir/t-slash.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Ensure that mkdir works with arguments specified with and without +# a trailing slash. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir + + +mkdir -p dir/ || fail=1 +test -d dir || fail=1 + +# This failed on NetBSD for fileutils-4.0.33. +mkdir d2/ || fail=1 +test -d d2 || fail=1 + +Exit $fail diff --git a/tests/mkdir/writable-under-readonly b/tests/mkdir/writable-under-readonly deleted file mode 100755 index 93e46d5b2..000000000 --- a/tests/mkdir/writable-under-readonly +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# FIXME: convert this to a root-only test. - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Test for the 2005-10-13 patch to lib/mkdir-p.c that fixed this sort -# of bug in mkdir: -# -# "mkdir -p /a/b/c" no longer fails merely because a leading prefix -# directory (e.g., /a or /a/b) exists on a read-only file system. -# -# Demonstrate the problem, as root: - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mkdir -require_root_ - -# FIXME: for now, skip it unconditionally -skip_ temporarily disabled - -# FIXME: define cleanup_ to do the umount - -# FIXME: use mktemp -cd /tmp \ - && dd if=/dev/zero of=1 bs=8192 count=50 \ - && dd if=/dev/zero of=2 bs=8192 count=50 \ - && mkdir -p mnt-ro && mkfs -t ext2 1 && mkfs -t ext2 2 \ - && mount -o loop=/dev/loop3 1 mnt-ro \ - && mkdir -p mnt-ro/rw \ - && mount -o remount,ro mnt-ro \ - && mount -o loop=/dev/loop4 2 mnt-ro/rw - -mkdir -p mnt-ro/rw/sub || fail=1 - -# To clean up -umount /tmp/2 -umount /tmp/1 - -Exit $fail diff --git a/tests/mkdir/writable-under-readonly.sh b/tests/mkdir/writable-under-readonly.sh new file mode 100755 index 000000000..93e46d5b2 --- /dev/null +++ b/tests/mkdir/writable-under-readonly.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# FIXME: convert this to a root-only test. + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test for the 2005-10-13 patch to lib/mkdir-p.c that fixed this sort +# of bug in mkdir: +# +# "mkdir -p /a/b/c" no longer fails merely because a leading prefix +# directory (e.g., /a or /a/b) exists on a read-only file system. +# +# Demonstrate the problem, as root: + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mkdir +require_root_ + +# FIXME: for now, skip it unconditionally +skip_ temporarily disabled + +# FIXME: define cleanup_ to do the umount + +# FIXME: use mktemp +cd /tmp \ + && dd if=/dev/zero of=1 bs=8192 count=50 \ + && dd if=/dev/zero of=2 bs=8192 count=50 \ + && mkdir -p mnt-ro && mkfs -t ext2 1 && mkfs -t ext2 2 \ + && mount -o loop=/dev/loop3 1 mnt-ro \ + && mkdir -p mnt-ro/rw \ + && mount -o remount,ro mnt-ro \ + && mount -o loop=/dev/loop4 2 mnt-ro/rw + +mkdir -p mnt-ro/rw/sub || fail=1 + +# To clean up +umount /tmp/2 +umount /tmp/1 + +Exit $fail diff --git a/tests/mv/acl b/tests/mv/acl deleted file mode 100755 index 2354ed967..000000000 --- a/tests/mv/acl +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# move files/directories across file system boundaries -# and make sure acls are preserved - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv getfacl setfacl - -require_acl_ - -# Skip this test if cp was built without ACL support: -grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null || - skip_ "insufficient ACL support" - -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -touch file || framework_failure_ -t1=$other_partition_tmpdir/t1 -touch $t1 || framework_failure_ - -skip_partition=none -# Ensure that setfacl and getfacl work on this file system. -setfacl -m user:bin:rw- file 2> /dev/null || skip_partition=. -# And on the destination file system. -setfacl -m user:bin:rw- $t1 || skip_partition=$other_partition_tmpdir -acl1=$(getfacl file) || skip_partition=. - -test $skip_partition != none && - skip_ "'$skip_partition' is not on a suitable file system for this test" - -# move the access acl of a file -mv file "$other_partition_tmpdir" || fail=1 -acl2=$(cd "$other_partition_tmpdir" && getfacl file) || framework_failure_ -test "$acl1" = "$acl2" || fail=1 - -# move the access acl of a directory -mkdir dir || framework_failure_ -setfacl -m user:bin:rw- dir || framework_failure_ -acl1=$(getfacl dir) || framework_failure_ -mv dir "$other_partition_tmpdir" || fail=1 -acl2=$(cd "$other_partition_tmpdir" && getfacl dir) || framework_failure_ -test "$acl1" = "$acl2" || fail=1 - -# move the default acl of a directory -mkdir dir2 || framework_failure_ -setfacl -d -m user:bin:rw- dir2 || framework_failure_ -acl1=$(getfacl dir2) || framework_failure_ -mv dir2 "$other_partition_tmpdir" || fail=1 -acl2=$(cd "$other_partition_tmpdir" && getfacl dir2) || framework_failure_ -test "$acl1" = "$acl2" || fail=1 - -Exit $fail diff --git a/tests/mv/acl.sh b/tests/mv/acl.sh new file mode 100755 index 000000000..2354ed967 --- /dev/null +++ b/tests/mv/acl.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# move files/directories across file system boundaries +# and make sure acls are preserved + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv getfacl setfacl + +require_acl_ + +# Skip this test if cp was built without ACL support: +grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null || + skip_ "insufficient ACL support" + +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +touch file || framework_failure_ +t1=$other_partition_tmpdir/t1 +touch $t1 || framework_failure_ + +skip_partition=none +# Ensure that setfacl and getfacl work on this file system. +setfacl -m user:bin:rw- file 2> /dev/null || skip_partition=. +# And on the destination file system. +setfacl -m user:bin:rw- $t1 || skip_partition=$other_partition_tmpdir +acl1=$(getfacl file) || skip_partition=. + +test $skip_partition != none && + skip_ "'$skip_partition' is not on a suitable file system for this test" + +# move the access acl of a file +mv file "$other_partition_tmpdir" || fail=1 +acl2=$(cd "$other_partition_tmpdir" && getfacl file) || framework_failure_ +test "$acl1" = "$acl2" || fail=1 + +# move the access acl of a directory +mkdir dir || framework_failure_ +setfacl -m user:bin:rw- dir || framework_failure_ +acl1=$(getfacl dir) || framework_failure_ +mv dir "$other_partition_tmpdir" || fail=1 +acl2=$(cd "$other_partition_tmpdir" && getfacl dir) || framework_failure_ +test "$acl1" = "$acl2" || fail=1 + +# move the default acl of a directory +mkdir dir2 || framework_failure_ +setfacl -d -m user:bin:rw- dir2 || framework_failure_ +acl1=$(getfacl dir2) || framework_failure_ +mv dir2 "$other_partition_tmpdir" || fail=1 +acl2=$(cd "$other_partition_tmpdir" && getfacl dir2) || framework_failure_ +test "$acl1" = "$acl2" || fail=1 + +Exit $fail diff --git a/tests/mv/atomic b/tests/mv/atomic deleted file mode 100755 index e5391c337..000000000 --- a/tests/mv/atomic +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# ensure that mv doesn't first unlink its destination in one particular case - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -require_strace_ unlink - -# Before the fix, mv would unnecessarily unlink the destination symlink: -# $ rm -rf s[12]; ln -s / s1; ln -s /tmp s2 -# $ strace -qe unlink /bin/mv -T s1 s2 -# unlink("s2") = 0 -# -# With the fix, it doesn't call unlink: -# $ rm -rf s[12]; ln -s / s1; ln -s /tmp s2 -# $ strace -qe unlink ./mv -T s1 s2 -# $ - -ln -s t1 s1 || framework_failure_ -ln -s t2 s2 || framework_failure_ - - -strace -qe unlink mv -T s1 s2 > out 2>&1 || fail=1 -$EGREP 'unlink.*"s1"' out && fail=1 - -# Ensure that the source, s1, is gone. -ls -dl s1 > /dev/null 2>&1 && fail=1 - -# Ensure that the destination, s2, contains the link from s1. -test "$(readlink s2)" = t1 || fail=1 - -Exit $fail diff --git a/tests/mv/atomic.sh b/tests/mv/atomic.sh new file mode 100755 index 000000000..e5391c337 --- /dev/null +++ b/tests/mv/atomic.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# ensure that mv doesn't first unlink its destination in one particular case + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +require_strace_ unlink + +# Before the fix, mv would unnecessarily unlink the destination symlink: +# $ rm -rf s[12]; ln -s / s1; ln -s /tmp s2 +# $ strace -qe unlink /bin/mv -T s1 s2 +# unlink("s2") = 0 +# +# With the fix, it doesn't call unlink: +# $ rm -rf s[12]; ln -s / s1; ln -s /tmp s2 +# $ strace -qe unlink ./mv -T s1 s2 +# $ + +ln -s t1 s1 || framework_failure_ +ln -s t2 s2 || framework_failure_ + + +strace -qe unlink mv -T s1 s2 > out 2>&1 || fail=1 +$EGREP 'unlink.*"s1"' out && fail=1 + +# Ensure that the source, s1, is gone. +ls -dl s1 > /dev/null 2>&1 && fail=1 + +# Ensure that the destination, s2, contains the link from s1. +test "$(readlink s2)" = t1 || fail=1 + +Exit $fail diff --git a/tests/mv/atomic2 b/tests/mv/atomic2 deleted file mode 100755 index d9c55e2c9..000000000 --- a/tests/mv/atomic2 +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# ensure that mv doesn't first unlink a multi-hard-linked destination - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -require_strace_ unlink - -# Before the fix, mv would unnecessarily unlink the destination symlink: -# $ rm -f a b b2; touch a b; ln b b2; strace -e unlink /p/bin/mv a b -# unlink("b") = 0 -# -# With the fix, it doesn't call unlink: -# $ rm -f a b b2; touch a b; ln b b2; strace -e unlink ./mv a b -# $ - -touch a b || framework_failure_ -ln b b2 || framework_failure_ - - -strace -qe unlink mv a b > out 2>&1 || fail=1 -$EGREP 'unlink.*"b"' out && fail=1 - -# Ensure that the source, "a", is gone. -ls -dl a > /dev/null 2>&1 && fail=1 - -# Ensure that the destination, "b", has link count 1. -n_links=$(stat --printf=%h b) || fail=1 -test "$n_links" = 1 || fail=1 - -Exit $fail diff --git a/tests/mv/atomic2.sh b/tests/mv/atomic2.sh new file mode 100755 index 000000000..d9c55e2c9 --- /dev/null +++ b/tests/mv/atomic2.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# ensure that mv doesn't first unlink a multi-hard-linked destination + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +require_strace_ unlink + +# Before the fix, mv would unnecessarily unlink the destination symlink: +# $ rm -f a b b2; touch a b; ln b b2; strace -e unlink /p/bin/mv a b +# unlink("b") = 0 +# +# With the fix, it doesn't call unlink: +# $ rm -f a b b2; touch a b; ln b b2; strace -e unlink ./mv a b +# $ + +touch a b || framework_failure_ +ln b b2 || framework_failure_ + + +strace -qe unlink mv a b > out 2>&1 || fail=1 +$EGREP 'unlink.*"b"' out && fail=1 + +# Ensure that the source, "a", is gone. +ls -dl a > /dev/null 2>&1 && fail=1 + +# Ensure that the destination, "b", has link count 1. +n_links=$(stat --printf=%h b) || fail=1 +test "$n_links" = 1 || fail=1 + +Exit $fail diff --git a/tests/mv/backup-dir b/tests/mv/backup-dir deleted file mode 100755 index 40f2c756a..000000000 --- a/tests/mv/backup-dir +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Ensure "mv --verbose --backup" works the same for dirs and non-dirs. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -mkdir A B || framework_failure_ -touch X Y || framework_failure_ - - -# Before coreutils-6.2, the " (backup: 'B.~1~')" suffix was not printed. -mv --verbose --backup=numbered -T A B > out || fail=1 -cat <<\EOF > exp || fail=1 -'A' -> 'B' (backup: 'B.~1~') -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/mv/backup-dir.sh b/tests/mv/backup-dir.sh new file mode 100755 index 000000000..40f2c756a --- /dev/null +++ b/tests/mv/backup-dir.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Ensure "mv --verbose --backup" works the same for dirs and non-dirs. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +mkdir A B || framework_failure_ +touch X Y || framework_failure_ + + +# Before coreutils-6.2, the " (backup: 'B.~1~')" suffix was not printed. +mv --verbose --backup=numbered -T A B > out || fail=1 +cat <<\EOF > exp || fail=1 +'A' -> 'B' (backup: 'B.~1~') +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/mv/backup-is-src b/tests/mv/backup-is-src deleted file mode 100755 index e1383a14d..000000000 --- a/tests/mv/backup-is-src +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# Force mv to use the copying code. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -a="$other_partition_tmpdir/a" -a2="$other_partition_tmpdir/a~" - -rm -f "$a" "$a2" || framework_failure_ -echo a > "$a" || framework_failure_ -echo a2 > "$a2" || framework_failure_ - -# This mv command should exit nonzero. -mv --b=simple "$a2" "$a" > out 2>&1 && fail=1 - -sed \ - -e "s,mv:,XXX:," \ - -e "s,$a,YYY," \ - -e "s,$a2,ZZZ," \ - out > out2 - -cat > exp <<\EOF -XXX: backing up 'YYY' would destroy source; 'ZZZ' not moved -EOF - -compare exp out2 || fail=1 - -Exit $fail diff --git a/tests/mv/backup-is-src.sh b/tests/mv/backup-is-src.sh new file mode 100755 index 000000000..e1383a14d --- /dev/null +++ b/tests/mv/backup-is-src.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Force mv to use the copying code. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +a="$other_partition_tmpdir/a" +a2="$other_partition_tmpdir/a~" + +rm -f "$a" "$a2" || framework_failure_ +echo a > "$a" || framework_failure_ +echo a2 > "$a2" || framework_failure_ + +# This mv command should exit nonzero. +mv --b=simple "$a2" "$a" > out 2>&1 && fail=1 + +sed \ + -e "s,mv:,XXX:," \ + -e "s,$a,YYY," \ + -e "s,$a2,ZZZ," \ + out > out2 + +cat > exp <<\EOF +XXX: backing up 'YYY' would destroy source; 'ZZZ' not moved +EOF + +compare exp out2 || fail=1 + +Exit $fail diff --git a/tests/mv/childproof b/tests/mv/childproof deleted file mode 100755 index efe7225d6..000000000 --- a/tests/mv/childproof +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -# Ensure that cp/mv/ln don't clobber a just-copied/moved/linked file. -# With fileutils-4.1 and earlier, this test would fail for cp and mv. -# With coreutils-6.9 and earlier, this test would fail for ln. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv ln - -skip_if_root_ - -mkdir a b c || framework_failure_ -echo a > a/f || framework_failure_ -echo b > b/f || framework_failure_ - - -cp a/f b/f c 2> /dev/null && fail=1 -test -f a/f || fail=1 -test -f b/f || fail=1 -test -f c/f || fail=1 -test "$(cat c/f)" = a || fail=1 -rm -f c/f - -# With --backup=numbered, it should succeed -cp --backup=numbered a/f b/f c || fail=1 -test -f a/f || fail=1 -test -f b/f || fail=1 -test -f c/f || fail=1 -test -f c/f.~1~ || fail=1 -rm -f c/f* - -mv a/f b/f c 2> /dev/null && fail=1 -test -f a/f && fail=1 -test -f b/f || fail=1 -test -f c/f || fail=1 -test "$(cat c/f)" = a || fail=1 - -# Make sure mv still works when moving hard links. -# This is where the same_file test is necessary, and why -# we save file names in addition to dev/ino. -rm -f c/f* b/f -touch a/f -ln a/f b/g -mv a/f b/g c || fail=1 -test -f a/f && fail=1 -test -f b/g && fail=1 -test -f c/f || fail=1 -test -f c/g || fail=1 - -touch a/f b/f b/g -mv a/f b/f b/g c 2> /dev/null && fail=1 -test -f a/f && fail=1 # a/f should have been moved -test -f b/f || fail=1 # b/f should remain -test -f b/g && fail=1 # b/g should have been moved -test -f c/f || fail=1 -test -f c/g || fail=1 - -# Test ln -f. - -rm -f a/f b/f c/f -echo a > a/f || fail=1 -echo b > b/f || fail=1 -ln -f a/f b/f c 2> /dev/null && fail=1 -# a/f and c/f must be linked -test $(stat --format %i a/f) = $(stat --format %i c/f) || fail=1 -# b/f and c/f must not be linked -test $(stat --format %i b/f) = $(stat --format %i c/f) && fail=1 - -Exit $fail diff --git a/tests/mv/childproof.sh b/tests/mv/childproof.sh new file mode 100755 index 000000000..efe7225d6 --- /dev/null +++ b/tests/mv/childproof.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# Ensure that cp/mv/ln don't clobber a just-copied/moved/linked file. +# With fileutils-4.1 and earlier, this test would fail for cp and mv. +# With coreutils-6.9 and earlier, this test would fail for ln. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv ln + +skip_if_root_ + +mkdir a b c || framework_failure_ +echo a > a/f || framework_failure_ +echo b > b/f || framework_failure_ + + +cp a/f b/f c 2> /dev/null && fail=1 +test -f a/f || fail=1 +test -f b/f || fail=1 +test -f c/f || fail=1 +test "$(cat c/f)" = a || fail=1 +rm -f c/f + +# With --backup=numbered, it should succeed +cp --backup=numbered a/f b/f c || fail=1 +test -f a/f || fail=1 +test -f b/f || fail=1 +test -f c/f || fail=1 +test -f c/f.~1~ || fail=1 +rm -f c/f* + +mv a/f b/f c 2> /dev/null && fail=1 +test -f a/f && fail=1 +test -f b/f || fail=1 +test -f c/f || fail=1 +test "$(cat c/f)" = a || fail=1 + +# Make sure mv still works when moving hard links. +# This is where the same_file test is necessary, and why +# we save file names in addition to dev/ino. +rm -f c/f* b/f +touch a/f +ln a/f b/g +mv a/f b/g c || fail=1 +test -f a/f && fail=1 +test -f b/g && fail=1 +test -f c/f || fail=1 +test -f c/g || fail=1 + +touch a/f b/f b/g +mv a/f b/f b/g c 2> /dev/null && fail=1 +test -f a/f && fail=1 # a/f should have been moved +test -f b/f || fail=1 # b/f should remain +test -f b/g && fail=1 # b/g should have been moved +test -f c/f || fail=1 +test -f c/g || fail=1 + +# Test ln -f. + +rm -f a/f b/f c/f +echo a > a/f || fail=1 +echo b > b/f || fail=1 +ln -f a/f b/f c 2> /dev/null && fail=1 +# a/f and c/f must be linked +test $(stat --format %i a/f) = $(stat --format %i c/f) || fail=1 +# b/f and c/f must not be linked +test $(stat --format %i b/f) = $(stat --format %i c/f) && fail=1 + +Exit $fail diff --git a/tests/mv/diag b/tests/mv/diag deleted file mode 100755 index d7c287030..000000000 --- a/tests/mv/diag +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# make sure we get proper diagnostics: e.g., with --target-dir=d but no args - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -touch f1 || framework_failure_ -touch f2 || framework_failure_ -touch d || framework_failure_ - -# These mv commands should all exit nonzero. - -# Too few args. This first one did fail, but with an incorrect diagnostic -# until fileutils-4.0u. -mv --target=. >> out 2>&1 && fail=1 -mv no-file >> out 2>&1 && fail=1 - -# Target is not a directory. -mv f1 f2 f1 >> out 2>&1 && fail=1 -mv --target=f2 f1 >> out 2>&1 && fail=1 - -cat > exp <<\EOF -mv: missing file operand -Try 'mv --help' for more information. -mv: missing destination file operand after 'no-file' -Try 'mv --help' for more information. -mv: target 'f1' is not a directory -mv: target 'f2' is not a directory -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/mv/diag.sh b/tests/mv/diag.sh new file mode 100755 index 000000000..d7c287030 --- /dev/null +++ b/tests/mv/diag.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# make sure we get proper diagnostics: e.g., with --target-dir=d but no args + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +touch f1 || framework_failure_ +touch f2 || framework_failure_ +touch d || framework_failure_ + +# These mv commands should all exit nonzero. + +# Too few args. This first one did fail, but with an incorrect diagnostic +# until fileutils-4.0u. +mv --target=. >> out 2>&1 && fail=1 +mv no-file >> out 2>&1 && fail=1 + +# Target is not a directory. +mv f1 f2 f1 >> out 2>&1 && fail=1 +mv --target=f2 f1 >> out 2>&1 && fail=1 + +cat > exp <<\EOF +mv: missing file operand +Try 'mv --help' for more information. +mv: missing destination file operand after 'no-file' +Try 'mv --help' for more information. +mv: target 'f1' is not a directory +mv: target 'f2' is not a directory +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/mv/dir-file b/tests/mv/dir-file deleted file mode 100755 index fb1a59424..000000000 --- a/tests/mv/dir-file +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# mv must fail when src and dest are mismatched directory/non-directory. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -mkdir -p dir/file || framework_failure_ -> file || framework_failure_ - - -# These should both fail, but until fileutils-4.0q only the second one did. -mv dir file > /dev/null 2>&1 && fail=1 -mv file dir > /dev/null 2>&1 && fail=1 - -Exit $fail diff --git a/tests/mv/dir-file.sh b/tests/mv/dir-file.sh new file mode 100755 index 000000000..fb1a59424 --- /dev/null +++ b/tests/mv/dir-file.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# mv must fail when src and dest are mismatched directory/non-directory. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +mkdir -p dir/file || framework_failure_ +> file || framework_failure_ + + +# These should both fail, but until fileutils-4.0q only the second one did. +mv dir file > /dev/null 2>&1 && fail=1 +mv file dir > /dev/null 2>&1 && fail=1 + +Exit $fail diff --git a/tests/mv/dir2dir b/tests/mv/dir2dir deleted file mode 100755 index 4322fd23d..000000000 --- a/tests/mv/dir2dir +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# Ensure that mv prints the right diagnostic for a dir->dir move -# where the destination directory is not empty. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -mkdir -p a/t b/t || framework_failure_ -touch a/t/f || framework_failure_ - - -# Expect this to fail with the expected diagnostic. -# For an interim (pre-6.0) release, it would give an erroneous -# diagnostic about moving one directory to a subdirectory of itself. -mv b/t a 2> out && fail=1 - -# Accept any of these: EEXIST, ENOTEMPTY, EBUSY. -sed 's/: File exists/: Directory not empty/'o1;mv o1 out -sed 's/: Device or resource busy/: Directory not empty/'o1;mv o1 out - -cat <<\EOF > exp || fail=1 -mv: cannot move 'b/t' to 'a/t': Directory not empty -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/mv/dir2dir.sh b/tests/mv/dir2dir.sh new file mode 100755 index 000000000..4322fd23d --- /dev/null +++ b/tests/mv/dir2dir.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Ensure that mv prints the right diagnostic for a dir->dir move +# where the destination directory is not empty. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +mkdir -p a/t b/t || framework_failure_ +touch a/t/f || framework_failure_ + + +# Expect this to fail with the expected diagnostic. +# For an interim (pre-6.0) release, it would give an erroneous +# diagnostic about moving one directory to a subdirectory of itself. +mv b/t a 2> out && fail=1 + +# Accept any of these: EEXIST, ENOTEMPTY, EBUSY. +sed 's/: File exists/: Directory not empty/'o1;mv o1 out +sed 's/: Device or resource busy/: Directory not empty/'o1;mv o1 out + +cat <<\EOF > exp || fail=1 +mv: cannot move 'b/t' to 'a/t': Directory not empty +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/mv/dup-source b/tests/mv/dup-source deleted file mode 100755 index ea88a046e..000000000 --- a/tests/mv/dup-source +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Ensure that cp merely warns when a non-directory source file is -# listed on the command line more than once. fileutils-4.1.1 -# made this fail: cp a a d/ -# Ensure that mv fails with a similar command. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv - -skip_if_root_ - -for i in cp; do - - # cp may not fail in this case. - - rm -fr a d; touch a; mkdir d - $i a a d/ 2> out || fail=1 - rm -fr a d; touch a; mkdir d - $i ./a a d/ 2>> out || fail=1 - - # cp succeeds with --backup=numbered. - rm -fr a d; touch a; mkdir d - $i --backup=numbered a a d/ 2>> out || fail=1 - - # But not with plain '--backup' - rm -fr a d; touch a; mkdir d - $i --backup a a d/ 2>> out && fail=1 - cat < exp -$i: warning: source file 'a' specified more than once -$i: warning: source file 'a' specified more than once -$i: will not overwrite just-created 'd/a' with 'a' -EOF - compare exp out || fail=1 -done - -for i in mv; do - # But mv *does* fail in this case (it has to). - - rm -fr a d; touch a; mkdir d - $i a a d/ 2> out && fail=1 - rm -fr a d; touch a; mkdir d - $i ./a a d/ 2>> out && fail=1 - cat < exp -$i: cannot stat 'a': No such file or directory -$i: cannot stat 'a': No such file or directory -EOF - compare exp out || fail=1 -done - -Exit $fail diff --git a/tests/mv/dup-source.sh b/tests/mv/dup-source.sh new file mode 100755 index 000000000..ea88a046e --- /dev/null +++ b/tests/mv/dup-source.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Ensure that cp merely warns when a non-directory source file is +# listed on the command line more than once. fileutils-4.1.1 +# made this fail: cp a a d/ +# Ensure that mv fails with a similar command. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv + +skip_if_root_ + +for i in cp; do + + # cp may not fail in this case. + + rm -fr a d; touch a; mkdir d + $i a a d/ 2> out || fail=1 + rm -fr a d; touch a; mkdir d + $i ./a a d/ 2>> out || fail=1 + + # cp succeeds with --backup=numbered. + rm -fr a d; touch a; mkdir d + $i --backup=numbered a a d/ 2>> out || fail=1 + + # But not with plain '--backup' + rm -fr a d; touch a; mkdir d + $i --backup a a d/ 2>> out && fail=1 + cat < exp +$i: warning: source file 'a' specified more than once +$i: warning: source file 'a' specified more than once +$i: will not overwrite just-created 'd/a' with 'a' +EOF + compare exp out || fail=1 +done + +for i in mv; do + # But mv *does* fail in this case (it has to). + + rm -fr a d; touch a; mkdir d + $i a a d/ 2> out && fail=1 + rm -fr a d; touch a; mkdir d + $i ./a a d/ 2>> out && fail=1 + cat < exp +$i: cannot stat 'a': No such file or directory +$i: cannot stat 'a': No such file or directory +EOF + compare exp out || fail=1 +done + +Exit $fail diff --git a/tests/mv/force b/tests/mv/force deleted file mode 100755 index 6bed83bf9..000000000 --- a/tests/mv/force +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# move a file onto itself - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -ff=mvforce -ff2=mvforce2 - -echo force-contents > $ff || framework_failure_ -ln $ff $ff2 || framework_failure_ - -# This mv command should exit nonzero. -mv $ff $ff > out 2>&1 && fail=1 - -cat > exp <. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +ff=mvforce +ff2=mvforce2 + +echo force-contents > $ff || framework_failure_ +ln $ff $ff2 || framework_failure_ + +# This mv command should exit nonzero. +mv $ff $ff > out 2>&1 && fail=1 + +cat > exp <. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv - -skip_if_root_ - -mkdir dst || framework_failure_ -(cd dst && touch a b c) || framework_failure_ -touch a || framework_failure_ -ln a b || framework_failure_ -ln a c || framework_failure_ - - -# ====================================== -cp --preserve=link a b c dst || fail=1 -# The source files must remain. -test -f a || fail=1 -test -f b || fail=1 -test -f c || fail=1 -cd dst - -# Three destination files must exist. -test -f a || fail=1 -test -f b || fail=1 -test -f c || fail=1 - -# The three i-node numbers must be the same. -ia=$(ls -i a|sed 's/ a//') -ib=$(ls -i b|sed 's/ b//') -ic=$(ls -i c|sed 's/ c//') -test $ia = $ib || fail=1 -test $ia = $ic || fail=1 - -cd .. -rm -f dst/[abc] -(cd dst && touch a b c) - -# ====================================== -mv a b c dst || fail=1 - -# The source files must be gone. -test -f a && fail=1 -test -f b && fail=1 -test -f c && fail=1 -cd dst - -# Three destination files must exist. -test -f a || fail=1 -test -f b || fail=1 -test -f c || fail=1 - -# The three i-node numbers must be the same. -ia=$(ls -i a|sed 's/ a//') -ib=$(ls -i b|sed 's/ b//') -ic=$(ls -i c|sed 's/ c//') -test $ia = $ib || fail=1 -test $ia = $ic || fail=1 - -Exit $fail diff --git a/tests/mv/hard-2.sh b/tests/mv/hard-2.sh new file mode 100755 index 000000000..e0fc174f0 --- /dev/null +++ b/tests/mv/hard-2.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# Ensure that moving hard-linked arguments onto existing destinations works. +# Likewise when using cp --preserve=link. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv + +skip_if_root_ + +mkdir dst || framework_failure_ +(cd dst && touch a b c) || framework_failure_ +touch a || framework_failure_ +ln a b || framework_failure_ +ln a c || framework_failure_ + + +# ====================================== +cp --preserve=link a b c dst || fail=1 +# The source files must remain. +test -f a || fail=1 +test -f b || fail=1 +test -f c || fail=1 +cd dst + +# Three destination files must exist. +test -f a || fail=1 +test -f b || fail=1 +test -f c || fail=1 + +# The three i-node numbers must be the same. +ia=$(ls -i a|sed 's/ a//') +ib=$(ls -i b|sed 's/ b//') +ic=$(ls -i c|sed 's/ c//') +test $ia = $ib || fail=1 +test $ia = $ic || fail=1 + +cd .. +rm -f dst/[abc] +(cd dst && touch a b c) + +# ====================================== +mv a b c dst || fail=1 + +# The source files must be gone. +test -f a && fail=1 +test -f b && fail=1 +test -f c && fail=1 +cd dst + +# Three destination files must exist. +test -f a || fail=1 +test -f b || fail=1 +test -f c || fail=1 + +# The three i-node numbers must be the same. +ia=$(ls -i a|sed 's/ a//') +ib=$(ls -i b|sed 's/ b//') +ic=$(ls -i c|sed 's/ c//') +test $ia = $ib || fail=1 +test $ia = $ic || fail=1 + +Exit $fail diff --git a/tests/mv/hard-3 b/tests/mv/hard-3 deleted file mode 100755 index a62167a07..000000000 --- a/tests/mv/hard-3 +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -# Ensure that using 'cp --preserve=link' to copy hard-linked arguments -# onto existing destinations works, even when one of the link operations fails. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -# This bug was fixed in coreutils-4.5.9. -# To exercise this bug is non-trivial: -# Set-up requires at least three hard-linked files. In copying them, -# while preserving links, the initial copy must succeed, the attempt -# to create the second file via 'link' must fail, and the final 'link' -# (to create the third) must succeed. Before the corresponding fix, -# the first and third destination files would not be linked. -# -# Note that this is nominally a test of 'cp', yet it is in the tests/mv -# directory, because it requires use of the --preserve=link option that -# mv enables by default. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp -skip_if_root_ - -mkdir -p x dst/x || framework_failure_ -touch dst/x/b || framework_failure_ -chmod a-w dst/x -touch a || framework_failure_ -ln a x/b || framework_failure_ -ln a c || framework_failure_ - - -# ====================================== -# This must fail -- because x/b cannot be unlinked. -cp --preserve=link --parents a x/b c dst 2> /dev/null && fail=1 - -# Source files must remain. -test -f a || fail=1 -test -f x/b || fail=1 -test -f c || fail=1 -cd dst - -# Three destination files must exist. -test -f a || fail=1 -test -f x/b || fail=1 -test -f c || fail=1 - -# The i-node numbers of a and c must be the same. -ia=$(ls -i a) || fail=1; set x $ia; ia=$2 -ic=$(ls -i c) || fail=1; set x $ic; ic=$2 -test "$ia" = "$ic" || fail=1 - -# The i-node number of x/b must be different. -ib=$(ls -i x/b) || fail=1; set x $ib; ib=$2 -test "$ia" = "$ib" && fail=1 - -Exit $fail diff --git a/tests/mv/hard-3.sh b/tests/mv/hard-3.sh new file mode 100755 index 000000000..a62167a07 --- /dev/null +++ b/tests/mv/hard-3.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# Ensure that using 'cp --preserve=link' to copy hard-linked arguments +# onto existing destinations works, even when one of the link operations fails. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# This bug was fixed in coreutils-4.5.9. +# To exercise this bug is non-trivial: +# Set-up requires at least three hard-linked files. In copying them, +# while preserving links, the initial copy must succeed, the attempt +# to create the second file via 'link' must fail, and the final 'link' +# (to create the third) must succeed. Before the corresponding fix, +# the first and third destination files would not be linked. +# +# Note that this is nominally a test of 'cp', yet it is in the tests/mv +# directory, because it requires use of the --preserve=link option that +# mv enables by default. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp +skip_if_root_ + +mkdir -p x dst/x || framework_failure_ +touch dst/x/b || framework_failure_ +chmod a-w dst/x +touch a || framework_failure_ +ln a x/b || framework_failure_ +ln a c || framework_failure_ + + +# ====================================== +# This must fail -- because x/b cannot be unlinked. +cp --preserve=link --parents a x/b c dst 2> /dev/null && fail=1 + +# Source files must remain. +test -f a || fail=1 +test -f x/b || fail=1 +test -f c || fail=1 +cd dst + +# Three destination files must exist. +test -f a || fail=1 +test -f x/b || fail=1 +test -f c || fail=1 + +# The i-node numbers of a and c must be the same. +ia=$(ls -i a) || fail=1; set x $ia; ia=$2 +ic=$(ls -i c) || fail=1; set x $ic; ic=$2 +test "$ia" = "$ic" || fail=1 + +# The i-node number of x/b must be different. +ib=$(ls -i x/b) || fail=1; set x $ib; ib=$2 +test "$ia" = "$ib" && fail=1 + +Exit $fail diff --git a/tests/mv/hard-4 b/tests/mv/hard-4 deleted file mode 100755 index 645ead3c5..000000000 --- a/tests/mv/hard-4 +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# ensure that mv removes a in this case: touch a; ln a b; mv a b - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -touch a || framework_failure_ -ln a b || framework_failure_ - - -mv a b || fail=1 - -# In coreutils-5.0 and earlier, a would not be removed. -test -r a && fail=1 -test -r b || fail=1 - -# Make sure it works also with --backup. -ln b a -mv --backup=simple a b || fail=1 -test -r a && fail=1 -test -r b || fail=1 -test -r b~ || fail=1 - -Exit $fail diff --git a/tests/mv/hard-4.sh b/tests/mv/hard-4.sh new file mode 100755 index 000000000..645ead3c5 --- /dev/null +++ b/tests/mv/hard-4.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# ensure that mv removes a in this case: touch a; ln a b; mv a b + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +touch a || framework_failure_ +ln a b || framework_failure_ + + +mv a b || fail=1 + +# In coreutils-5.0 and earlier, a would not be removed. +test -r a && fail=1 +test -r b || fail=1 + +# Make sure it works also with --backup. +ln b a +mv --backup=simple a b || fail=1 +test -r a && fail=1 +test -r b || fail=1 +test -r b~ || fail=1 + +Exit $fail diff --git a/tests/mv/hard-link-1 b/tests/mv/hard-link-1 deleted file mode 100755 index 78a555ac9..000000000 --- a/tests/mv/hard-link-1 +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# move a directory containing hard-linked files and -# make sure the links are preserved - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -dir=hlink - -mkdir $dir || framework_failure_ -> $dir/a || framework_failure_ -ln $dir/a $dir/b || framework_failure_ - -mv $dir "$other_partition_tmpdir" || fail=1 - -# Display inode numbers, one per line. -ls -1i "$other_partition_tmpdir/$dir" > out || fail=1 - -# Make sure the inode numbers are the same. -a=$(sed -n 's/ a$//p' out) -b=$(sed -n 's/ b$//p' out) -test "$a" = "$b" || fail=1 - -Exit $fail diff --git a/tests/mv/hard-link-1.sh b/tests/mv/hard-link-1.sh new file mode 100755 index 000000000..78a555ac9 --- /dev/null +++ b/tests/mv/hard-link-1.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# move a directory containing hard-linked files and +# make sure the links are preserved + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +dir=hlink + +mkdir $dir || framework_failure_ +> $dir/a || framework_failure_ +ln $dir/a $dir/b || framework_failure_ + +mv $dir "$other_partition_tmpdir" || fail=1 + +# Display inode numbers, one per line. +ls -1i "$other_partition_tmpdir/$dir" > out || fail=1 + +# Make sure the inode numbers are the same. +a=$(sed -n 's/ a$//p' out) +b=$(sed -n 's/ b$//p' out) +test "$a" = "$b" || fail=1 + +Exit $fail diff --git a/tests/mv/hard-verbose b/tests/mv/hard-verbose deleted file mode 100755 index 41c4187ea..000000000 --- a/tests/mv/hard-verbose +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# ensure that mv's --verbose options works even in this unusual case - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -touch x || framework_failure_ -ln x y || framework_failure_ - - -mv --verbose x y > out || fail=1 -cat <<\EOF > exp || fail=1 -removed 'x' -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/mv/hard-verbose.sh b/tests/mv/hard-verbose.sh new file mode 100755 index 000000000..41c4187ea --- /dev/null +++ b/tests/mv/hard-verbose.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# ensure that mv's --verbose options works even in this unusual case + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +touch x || framework_failure_ +ln x y || framework_failure_ + + +mv --verbose x y > out || fail=1 +cat <<\EOF > exp || fail=1 +removed 'x' +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/mv/i-1 b/tests/mv/i-1 deleted file mode 100755 index 5fa054ab3..000000000 --- a/tests/mv/i-1 +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/perl -# Make sure a 'n' reply to 'mv -i...' aborts the move operation. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $test_a = 'a'; - -my @Tests = - ( - # Make sure a 'n' reply to 'mv -i...' aborts the move operation. - [$test_a, '-i', - {IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"}, - {ERR => "mv: overwrite 'dst'? "}, - {POST => sub { -r 'src' or die "test $test_a failed\n"}}, - {EXIT => 0}, - ], - ); - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $prog = 'mv'; -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/mv/i-1.pl b/tests/mv/i-1.pl new file mode 100755 index 000000000..5fa054ab3 --- /dev/null +++ b/tests/mv/i-1.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +# Make sure a 'n' reply to 'mv -i...' aborts the move operation. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $test_a = 'a'; + +my @Tests = + ( + # Make sure a 'n' reply to 'mv -i...' aborts the move operation. + [$test_a, '-i', + {IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"}, + {ERR => "mv: overwrite 'dst'? "}, + {POST => sub { -r 'src' or die "test $test_a failed\n"}}, + {EXIT => 0}, + ], + ); + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $prog = 'mv'; +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/mv/i-2 b/tests/mv/i-2 deleted file mode 100755 index f24801958..000000000 --- a/tests/mv/i-2 +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Test both cp and mv for their behavior with -if and -fi -# The standards (POSIX and SuS) dictate annoyingly inconsistent behavior. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv - -skip_if_root_ - -for i in a b c d e f g h; do - echo $i > $i || framework_failure_ -done -chmod 0 b d f h || framework_failure_ -echo y > y || framework_failure_ - -mv -if a b || fail=1 -mv -fi c d < y >/dev/null 2>&1 || fail=1 - -# Before 4.0s, this would not prompt. -cp -if e f < y > out 2>&1 || fail=1 - -# Make sure out contains the prompt. -case "$(cat out)" in - "cp: try to overwrite 'f', overriding mode 0000 (---------)?"*) ;; - *) fail=1 ;; -esac - -test -f e || fail=1 -test -f f || fail=1 -compare e f || fail=1 - -cp -fi g h < y > out 2>&1 || fail=1 -test -f g || fail=1 -test -f h || fail=1 -compare g h || fail=1 - -Exit $fail diff --git a/tests/mv/i-2.sh b/tests/mv/i-2.sh new file mode 100755 index 000000000..f24801958 --- /dev/null +++ b/tests/mv/i-2.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Test both cp and mv for their behavior with -if and -fi +# The standards (POSIX and SuS) dictate annoyingly inconsistent behavior. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv + +skip_if_root_ + +for i in a b c d e f g h; do + echo $i > $i || framework_failure_ +done +chmod 0 b d f h || framework_failure_ +echo y > y || framework_failure_ + +mv -if a b || fail=1 +mv -fi c d < y >/dev/null 2>&1 || fail=1 + +# Before 4.0s, this would not prompt. +cp -if e f < y > out 2>&1 || fail=1 + +# Make sure out contains the prompt. +case "$(cat out)" in + "cp: try to overwrite 'f', overriding mode 0000 (---------)?"*) ;; + *) fail=1 ;; +esac + +test -f e || fail=1 +test -f f || fail=1 +compare e f || fail=1 + +cp -fi g h < y > out 2>&1 || fail=1 +test -f g || fail=1 +test -f h || fail=1 +compare g h || fail=1 + +Exit $fail diff --git a/tests/mv/i-3 b/tests/mv/i-3 deleted file mode 100755 index 3912842a2..000000000 --- a/tests/mv/i-3 +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -# Make sure that 'mv file unwritable-file' prompts the user -# and that 'mv -f file unwritable-file' doesn't. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -require_controlling_input_terminal_ -skip_if_root_ -trap '' TTIN # Ignore SIGTTIN - -test "$(uname -s)" = FreeBSD && skip_ "known spurious failure on FreeBSD" - -touch f g h i || framework_failure_ -chmod 0 g i || framework_failure_ - - -ls /dev/stdin >/dev/null 2>&1 \ - || skip_ 'there is no /dev/stdin file' - -# work around a dash bug when redirecting -# from symlinked ttys in the background -tty=$(readlink -f /dev/stdin) - -test -r "$tty" 2>&1 \ - || skip_ '/dev/stdin is not readable' - -mv f g < $tty > out 2>&1 & pid=$! - -# Test for the expected prompt; sleep upon non-match. -check_overwrite_prompt() -{ - local delay="$1" - case "$(cat out)" in - "mv: try to overwrite 'g', overriding mode 0000"*) ;; - *) sleep $delay; return 1;; - esac -} - -# Wait for up to 12.7 seconds for the expected prompt. -retry_delay_ check_overwrite_prompt .1 7 || fail=1 - -kill $pid - -mv -f h i > out 2>&1 || fail=1 -test -f i || fail=1 -test -f h && fail=1 - -# Make sure there was no prompt. -case "$(cat out)" in - '') ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/mv/i-3.sh b/tests/mv/i-3.sh new file mode 100755 index 000000000..3912842a2 --- /dev/null +++ b/tests/mv/i-3.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# Make sure that 'mv file unwritable-file' prompts the user +# and that 'mv -f file unwritable-file' doesn't. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +require_controlling_input_terminal_ +skip_if_root_ +trap '' TTIN # Ignore SIGTTIN + +test "$(uname -s)" = FreeBSD && skip_ "known spurious failure on FreeBSD" + +touch f g h i || framework_failure_ +chmod 0 g i || framework_failure_ + + +ls /dev/stdin >/dev/null 2>&1 \ + || skip_ 'there is no /dev/stdin file' + +# work around a dash bug when redirecting +# from symlinked ttys in the background +tty=$(readlink -f /dev/stdin) + +test -r "$tty" 2>&1 \ + || skip_ '/dev/stdin is not readable' + +mv f g < $tty > out 2>&1 & pid=$! + +# Test for the expected prompt; sleep upon non-match. +check_overwrite_prompt() +{ + local delay="$1" + case "$(cat out)" in + "mv: try to overwrite 'g', overriding mode 0000"*) ;; + *) sleep $delay; return 1;; + esac +} + +# Wait for up to 12.7 seconds for the expected prompt. +retry_delay_ check_overwrite_prompt .1 7 || fail=1 + +kill $pid + +mv -f h i > out 2>&1 || fail=1 +test -f i || fail=1 +test -f h && fail=1 + +# Make sure there was no prompt. +case "$(cat out)" in + '') ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/mv/i-4 b/tests/mv/i-4 deleted file mode 100755 index 8ef6ca77b..000000000 --- a/tests/mv/i-4 +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# make sure 'mv -i a b' does its job with a positive response - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -for i in a b; do - echo $i > $i || framework_failure_ -done -echo y > y || framework_failure_ - -mv -i a b < y >/dev/null 2>&1 || fail=1 - -# Make sure out contains the prompt. -case "$(cat b)" in - a) ;; - *) fail=1 ;; -esac - -# Ensure that mv -i a b works properly with 'n' and 'y' -# responses, even when a and b are hard links to the same file. -# This 'n' test would fail (no prompt) for coreutils-5.0.1 through 5.3.0. -echo n > n -rm -f a b -echo a > a -ln a b -mv -i a b < n >/dev/null 2>&1 || fail=1 -test -r a || fail=1 -test -r b || fail=1 -mv -i a b < y >/dev/null 2>&1 || fail=1 -test -r a && fail=1 -test -r b || fail=1 - -Exit $fail diff --git a/tests/mv/i-4.sh b/tests/mv/i-4.sh new file mode 100755 index 000000000..8ef6ca77b --- /dev/null +++ b/tests/mv/i-4.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# make sure 'mv -i a b' does its job with a positive response + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +for i in a b; do + echo $i > $i || framework_failure_ +done +echo y > y || framework_failure_ + +mv -i a b < y >/dev/null 2>&1 || fail=1 + +# Make sure out contains the prompt. +case "$(cat b)" in + a) ;; + *) fail=1 ;; +esac + +# Ensure that mv -i a b works properly with 'n' and 'y' +# responses, even when a and b are hard links to the same file. +# This 'n' test would fail (no prompt) for coreutils-5.0.1 through 5.3.0. +echo n > n +rm -f a b +echo a > a +ln a b +mv -i a b < n >/dev/null 2>&1 || fail=1 +test -r a || fail=1 +test -r b || fail=1 +mv -i a b < y >/dev/null 2>&1 || fail=1 +test -r a && fail=1 +test -r b || fail=1 + +Exit $fail diff --git a/tests/mv/i-5 b/tests/mv/i-5 deleted file mode 100755 index 76cacabe3..000000000 --- a/tests/mv/i-5 +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Make sure 'mv -i dir file' prompts before failing. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -mkdir a || framework_failure_ -touch b || framework_failure_ - - -# coreutils 6.2 mv would neglect to prompt in this case. -echo n | mv -i a b 2>/dev/null || fail=1 - -Exit $fail diff --git a/tests/mv/i-5.sh b/tests/mv/i-5.sh new file mode 100755 index 000000000..76cacabe3 --- /dev/null +++ b/tests/mv/i-5.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Make sure 'mv -i dir file' prompts before failing. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +mkdir a || framework_failure_ +touch b || framework_failure_ + + +# coreutils 6.2 mv would neglect to prompt in this case. +echo n | mv -i a b 2>/dev/null || fail=1 + +Exit $fail diff --git a/tests/mv/i-link-no b/tests/mv/i-link-no deleted file mode 100755 index 4615eaabb..000000000 --- a/tests/mv/i-link-no +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Show that mv doesn't preserve links to files the user has declined to move. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -mkdir a b || framework_failure_ -echo foo > a/foo || framework_failure_ -ln a/foo a/bar || framework_failure_ -echo FUBAR > b/FUBAR || framework_failure_ -ln b/FUBAR b/bar || framework_failure_ -chmod a-w b/bar || framework_failure_ -echo n > no || framework_failure_ - - -mv a/bar a/foo b < no > out 2> err || fail=1 -touch exp -touch exp_err - -compare exp out || fail=1 -compare exp_err err || fail=1 - -case "$(cat b/foo)" in - foo) ;; - *) fail=1;; -esac - -Exit $fail diff --git a/tests/mv/i-link-no.sh b/tests/mv/i-link-no.sh new file mode 100755 index 000000000..4615eaabb --- /dev/null +++ b/tests/mv/i-link-no.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Show that mv doesn't preserve links to files the user has declined to move. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +mkdir a b || framework_failure_ +echo foo > a/foo || framework_failure_ +ln a/foo a/bar || framework_failure_ +echo FUBAR > b/FUBAR || framework_failure_ +ln b/FUBAR b/bar || framework_failure_ +chmod a-w b/bar || framework_failure_ +echo n > no || framework_failure_ + + +mv a/bar a/foo b < no > out 2> err || fail=1 +touch exp +touch exp_err + +compare exp out || fail=1 +compare exp_err err || fail=1 + +case "$(cat b/foo)" in + foo) ;; + *) fail=1;; +esac + +Exit $fail diff --git a/tests/mv/into-self b/tests/mv/into-self deleted file mode 100755 index 231d69c2c..000000000 --- a/tests/mv/into-self +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/sh -# Demonstrate how mv fails when it tries to move a directory into itself. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -dir=toself-dir -file=toself-file - -rm -rf $dir $file || framework_failure_ -mkdir -p $dir/a/b || framework_failure_ -touch $file || framework_failure_ - - -# This mv command should fail. -mv $dir $file $dir > out 2>&1 && fail=1 - -sed \ - -e "s,mv:,XXX:," \ - -e "s,$dir,SRC," \ - -e "s,$dir/$dir,DEST," \ - out > out2 - -cat > exp <<\EOF -XXX: cannot move 'SRC' to a subdirectory of itself, 'DEST' -EOF - -compare exp out2 || fail=1 - -# Make sure the file is gone. -test -f $file && fail=1 -# Make sure the directory is *not* moved. -test -d $dir || fail=1 -test -d $dir/$dir && fail=1 -# Make sure the file has been moved to the right place. -test -f $dir/$file || fail=1 - -Exit $fail diff --git a/tests/mv/into-self-2 b/tests/mv/into-self-2 deleted file mode 100755 index 3e6ace718..000000000 --- a/tests/mv/into-self-2 +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Force mv to use the copying code. -# Consider the case where SRC and DEST are on different -# partitions and DEST is a symlink to SRC. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -file="$other_partition_tmpdir/file" -symlink=symlink - - -echo whatever > $file || framework_failure_ -ln -s $file $symlink || framework_failure_ - -# This mv command should exit nonzero. -mv $symlink $file > out 2>&1 && fail=1 - -# This should succeed. -mv $file $symlink || fail=1 - -sed \ - -e "s,mv:,XXX:," \ - -e "s,$file,YYY," \ - -e "s,$symlink,ZZZ," \ - out > out2 - -cat > exp <<\EOF -XXX: 'ZZZ' and 'YYY' are the same file -EOF -#' - -compare exp out2 || fail=1 - -Exit $fail diff --git a/tests/mv/into-self-2.sh b/tests/mv/into-self-2.sh new file mode 100755 index 000000000..3e6ace718 --- /dev/null +++ b/tests/mv/into-self-2.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Force mv to use the copying code. +# Consider the case where SRC and DEST are on different +# partitions and DEST is a symlink to SRC. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +file="$other_partition_tmpdir/file" +symlink=symlink + + +echo whatever > $file || framework_failure_ +ln -s $file $symlink || framework_failure_ + +# This mv command should exit nonzero. +mv $symlink $file > out 2>&1 && fail=1 + +# This should succeed. +mv $file $symlink || fail=1 + +sed \ + -e "s,mv:,XXX:," \ + -e "s,$file,YYY," \ + -e "s,$symlink,ZZZ," \ + out > out2 + +cat > exp <<\EOF +XXX: 'ZZZ' and 'YYY' are the same file +EOF +#' + +compare exp out2 || fail=1 + +Exit $fail diff --git a/tests/mv/into-self-3 b/tests/mv/into-self-3 deleted file mode 100755 index b2b8f8351..000000000 --- a/tests/mv/into-self-3 +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# move a directory into itself, with a twist - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -dir1=is3-dir1 -dir2=is3-dir2 - -mkdir $dir1 $dir2 || framework_failure_ - -# This mv command should exit nonzero. -mv $dir1 $dir2 $dir2 > out 2>&1 && fail=1 - -sed \ - -e "s,mv:,XXX:,g" \ - -e "s,$dir2,ZZZ,g" \ - out > out2 - -cat > exp <<\EOF -XXX: cannot move 'ZZZ' to a subdirectory of itself, 'ZZZ/ZZZ' -EOF - -compare exp out2 || fail=1 - -Exit $fail diff --git a/tests/mv/into-self-3.sh b/tests/mv/into-self-3.sh new file mode 100755 index 000000000..b2b8f8351 --- /dev/null +++ b/tests/mv/into-self-3.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# move a directory into itself, with a twist + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +dir1=is3-dir1 +dir2=is3-dir2 + +mkdir $dir1 $dir2 || framework_failure_ + +# This mv command should exit nonzero. +mv $dir1 $dir2 $dir2 > out 2>&1 && fail=1 + +sed \ + -e "s,mv:,XXX:,g" \ + -e "s,$dir2,ZZZ,g" \ + out > out2 + +cat > exp <<\EOF +XXX: cannot move 'ZZZ' to a subdirectory of itself, 'ZZZ/ZZZ' +EOF + +compare exp out2 || fail=1 + +Exit $fail diff --git a/tests/mv/into-self-4 b/tests/mv/into-self-4 deleted file mode 100755 index 5119e8fa3..000000000 --- a/tests/mv/into-self-4 +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# confirm that 'mv symlink symlink' doesn't remove symlink -# Based on an example from David Luyer. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -touch file || framework_failure_ -ln -s file s || framework_failure_ - - -# This must fail. -mv s s 2> /dev/null && fail=1 - -# But the symlink, s, must not be removed. -# Before 4.0.36, 's' would have been removed. -test -f s || fail=1 - -Exit $fail diff --git a/tests/mv/into-self-4.sh b/tests/mv/into-self-4.sh new file mode 100755 index 000000000..5119e8fa3 --- /dev/null +++ b/tests/mv/into-self-4.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# confirm that 'mv symlink symlink' doesn't remove symlink +# Based on an example from David Luyer. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +touch file || framework_failure_ +ln -s file s || framework_failure_ + + +# This must fail. +mv s s 2> /dev/null && fail=1 + +# But the symlink, s, must not be removed. +# Before 4.0.36, 's' would have been removed. +test -f s || fail=1 + +Exit $fail diff --git a/tests/mv/into-self.sh b/tests/mv/into-self.sh new file mode 100755 index 000000000..231d69c2c --- /dev/null +++ b/tests/mv/into-self.sh @@ -0,0 +1,53 @@ +#! /bin/sh +# Demonstrate how mv fails when it tries to move a directory into itself. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +dir=toself-dir +file=toself-file + +rm -rf $dir $file || framework_failure_ +mkdir -p $dir/a/b || framework_failure_ +touch $file || framework_failure_ + + +# This mv command should fail. +mv $dir $file $dir > out 2>&1 && fail=1 + +sed \ + -e "s,mv:,XXX:," \ + -e "s,$dir,SRC," \ + -e "s,$dir/$dir,DEST," \ + out > out2 + +cat > exp <<\EOF +XXX: cannot move 'SRC' to a subdirectory of itself, 'DEST' +EOF + +compare exp out2 || fail=1 + +# Make sure the file is gone. +test -f $file && fail=1 +# Make sure the directory is *not* moved. +test -d $dir || fail=1 +test -d $dir/$dir && fail=1 +# Make sure the file has been moved to the right place. +test -f $dir/$file || fail=1 + +Exit $fail diff --git a/tests/mv/leak-fd b/tests/mv/leak-fd deleted file mode 100755 index d349a3f11..000000000 --- a/tests/mv/leak-fd +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Exercise mv's file-descriptor-leak bug, reported against coreutils-5.2.1 -# and fixed (properly) on 2004-10-21. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# limit so don't run it by default. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -skip_if_root_ -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -# This test is relatively expensive, and might well evoke a -# framework-failure on systems with a smaller command-line length -expensive_ - -b="0 1 2 3 4 5 6 7 8 9 -a b c d e f g h i j k l m n o p q r s t u v w x y z -_A _B _C _D _E _F _G _H _I _J _K _L _M _N _O _P _Q _R _S _T _U _V _W _X _Y _Z" - -for i in $(echo $b); do - echo $i - for j in $b; do - echo $i$j - done -done > .dirs -mkdir $(cat .dirs) || framework_failure_ -sed 's,$,/f,' .dirs | xargs touch - -last_file=$(tail -n1 .dirs)/f -test -f $last_file || framework_failure_ - - -mv * "$other_partition_tmpdir" || fail=1 -test -f $last_file/f && fail=1 -rm .dirs - -out=$(ls -A) || fail=1 -test -z "$out" || fail=1 - -Exit $fail diff --git a/tests/mv/leak-fd.sh b/tests/mv/leak-fd.sh new file mode 100755 index 000000000..d349a3f11 --- /dev/null +++ b/tests/mv/leak-fd.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Exercise mv's file-descriptor-leak bug, reported against coreutils-5.2.1 +# and fixed (properly) on 2004-10-21. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# limit so don't run it by default. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +skip_if_root_ +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +# This test is relatively expensive, and might well evoke a +# framework-failure on systems with a smaller command-line length +expensive_ + +b="0 1 2 3 4 5 6 7 8 9 +a b c d e f g h i j k l m n o p q r s t u v w x y z +_A _B _C _D _E _F _G _H _I _J _K _L _M _N _O _P _Q _R _S _T _U _V _W _X _Y _Z" + +for i in $(echo $b); do + echo $i + for j in $b; do + echo $i$j + done +done > .dirs +mkdir $(cat .dirs) || framework_failure_ +sed 's,$,/f,' .dirs | xargs touch + +last_file=$(tail -n1 .dirs)/f +test -f $last_file || framework_failure_ + + +mv * "$other_partition_tmpdir" || fail=1 +test -f $last_file/f && fail=1 +rm .dirs + +out=$(ls -A) || fail=1 +test -z "$out" || fail=1 + +Exit $fail diff --git a/tests/mv/mv-n b/tests/mv/mv-n deleted file mode 100755 index 9a9b1156a..000000000 --- a/tests/mv/mv-n +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# Test whether mv -n works as documented (not overwrite target). - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - - -# test miscellaneous combinations of -f -i -n parameters -touch a b || framework_failure_ -echo "'a' -> 'b'" > out_move -> out_empty - -# ask for overwrite, answer no -touch a b || framework_failure_ -echo n | mv -vi a b 2>/dev/null > out1 || fail=1 -compare out1 out_empty || fail=1 - -# ask for overwrite, answer yes -touch a b || framework_failure_ -echo y | mv -vi a b 2>/dev/null > out2 || fail=1 -compare out2 out_move || fail=1 - -# -n wins (as the last option) -touch a b || framework_failure_ -echo y | mv -vin a b 2>/dev/null > out3 || fail=1 -compare out3 out_empty || fail=1 - -# -n wins (as the last option) -touch a b || framework_failure_ -echo y | mv -vfn a b 2>/dev/null > out4 || fail=1 -compare out4 out_empty || fail=1 - -# -n wins (as the last option) -touch a b || framework_failure_ -echo y | mv -vifn a b 2>/dev/null > out5 || fail=1 -compare out5 out_empty || fail=1 - -# options --backup and --no-clobber are mutually exclusive -touch a || framework_failure_ -mv -bn a b 2>/dev/null && fail=1 - -Exit $fail diff --git a/tests/mv/mv-n.sh b/tests/mv/mv-n.sh new file mode 100755 index 000000000..9a9b1156a --- /dev/null +++ b/tests/mv/mv-n.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Test whether mv -n works as documented (not overwrite target). + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + + +# test miscellaneous combinations of -f -i -n parameters +touch a b || framework_failure_ +echo "'a' -> 'b'" > out_move +> out_empty + +# ask for overwrite, answer no +touch a b || framework_failure_ +echo n | mv -vi a b 2>/dev/null > out1 || fail=1 +compare out1 out_empty || fail=1 + +# ask for overwrite, answer yes +touch a b || framework_failure_ +echo y | mv -vi a b 2>/dev/null > out2 || fail=1 +compare out2 out_move || fail=1 + +# -n wins (as the last option) +touch a b || framework_failure_ +echo y | mv -vin a b 2>/dev/null > out3 || fail=1 +compare out3 out_empty || fail=1 + +# -n wins (as the last option) +touch a b || framework_failure_ +echo y | mv -vfn a b 2>/dev/null > out4 || fail=1 +compare out4 out_empty || fail=1 + +# -n wins (as the last option) +touch a b || framework_failure_ +echo y | mv -vifn a b 2>/dev/null > out5 || fail=1 +compare out5 out_empty || fail=1 + +# options --backup and --no-clobber are mutually exclusive +touch a || framework_failure_ +mv -bn a b 2>/dev/null && fail=1 + +Exit $fail diff --git a/tests/mv/mv-special-1 b/tests/mv/mv-special-1 deleted file mode 100755 index dac55d0c2..000000000 --- a/tests/mv/mv-special-1 +++ /dev/null @@ -1,72 +0,0 @@ -#! /bin/sh -# Test "mv" with special files. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -null=mv-null -dir=mv-dir - -rm -f $null || framework_failure_ -mknod $null p || framework_failure_ -test -p $null || framework_failure_ -mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure_ -touch $dir/a/b/c/file1 $dir/d/e/f/file2 || framework_failure_ - -# We used to... -# exit 77 here to indicate that we couldn't run the test. -# At least running on SunOS 4.1.4, using a directory NFS mounted -# from an OpenBSD system, the above mknod fails. -# It's not worth making an exception any more. - -mv --verbose $null $dir "$other_partition_tmpdir" > out || fail=1 -# Make sure the files are gone. -test -p $null && fail=1 -test -d $dir && fail=1 -# Make sure they were moved. -test -p "$other_partition_tmpdir/$null" || fail=1 -test -d "$other_partition_tmpdir/$dir/a/b/c" || fail=1 - -# POSIX says rename (A, B) can succeed if A and B are on different file systems, -# so ignore chatter about when files are removed and copied rather than renamed. -sed " - /^removed /d - s,$other_partition_tmpdir,XXX, -" out | sort > out2 - -cat < exp -'$null' -> 'XXX/$null' -'$dir' -> 'XXX/$dir' -'$dir/a' -> 'XXX/$dir/a' -'$dir/a/b' -> 'XXX/$dir/a/b' -'$dir/a/b/c' -> 'XXX/$dir/a/b/c' -'$dir/a/b/c/file1' -> 'XXX/$dir/a/b/c/file1' -'$dir/d' -> 'XXX/$dir/d' -'$dir/d/e' -> 'XXX/$dir/d/e' -'$dir/d/e/f' -> 'XXX/$dir/d/e/f' -'$dir/d/e/f/file2' -> 'XXX/$dir/d/e/f/file2' -EOF - -compare exp out2 || fail=1 - -# cd "$other_partition_tmpdir" -# ls -l -A -R "$other_partition_tmpdir" - -Exit $fail diff --git a/tests/mv/mv-special-1.sh b/tests/mv/mv-special-1.sh new file mode 100755 index 000000000..dac55d0c2 --- /dev/null +++ b/tests/mv/mv-special-1.sh @@ -0,0 +1,72 @@ +#! /bin/sh +# Test "mv" with special files. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +null=mv-null +dir=mv-dir + +rm -f $null || framework_failure_ +mknod $null p || framework_failure_ +test -p $null || framework_failure_ +mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure_ +touch $dir/a/b/c/file1 $dir/d/e/f/file2 || framework_failure_ + +# We used to... +# exit 77 here to indicate that we couldn't run the test. +# At least running on SunOS 4.1.4, using a directory NFS mounted +# from an OpenBSD system, the above mknod fails. +# It's not worth making an exception any more. + +mv --verbose $null $dir "$other_partition_tmpdir" > out || fail=1 +# Make sure the files are gone. +test -p $null && fail=1 +test -d $dir && fail=1 +# Make sure they were moved. +test -p "$other_partition_tmpdir/$null" || fail=1 +test -d "$other_partition_tmpdir/$dir/a/b/c" || fail=1 + +# POSIX says rename (A, B) can succeed if A and B are on different file systems, +# so ignore chatter about when files are removed and copied rather than renamed. +sed " + /^removed /d + s,$other_partition_tmpdir,XXX, +" out | sort > out2 + +cat < exp +'$null' -> 'XXX/$null' +'$dir' -> 'XXX/$dir' +'$dir/a' -> 'XXX/$dir/a' +'$dir/a/b' -> 'XXX/$dir/a/b' +'$dir/a/b/c' -> 'XXX/$dir/a/b/c' +'$dir/a/b/c/file1' -> 'XXX/$dir/a/b/c/file1' +'$dir/d' -> 'XXX/$dir/d' +'$dir/d/e' -> 'XXX/$dir/d/e' +'$dir/d/e/f' -> 'XXX/$dir/d/e/f' +'$dir/d/e/f/file2' -> 'XXX/$dir/d/e/f/file2' +EOF + +compare exp out2 || fail=1 + +# cd "$other_partition_tmpdir" +# ls -l -A -R "$other_partition_tmpdir" + +Exit $fail diff --git a/tests/mv/no-target-dir b/tests/mv/no-target-dir deleted file mode 100755 index c1443cd3e..000000000 --- a/tests/mv/no-target-dir +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# ensure that --no-target-directory (-T) works when the destination is -# an empty directory. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -mkdir -p d/sub empty src d2/sub e2 || framework_failure_ -touch f || framework_failure_ - -# Skip this test if there's an underlying kernel bug. -mkdir a b b/a || framework_failure_ - -mv a b || - skip_ "your kernel's rename syscall is buggy" - - -# This should succeed, since both src and dest are directories, -# and the dest dir is empty. -mv -fT d empty || fail=1 - -# Ensure that the source, d, is gone. -ls -d d > /dev/null 2>&1 && fail=1 - -# Ensure that the dest dir now has a subdirectory. -test -d empty/sub || fail=1 - -# rename must fail, since the dest is non-empty. -mv -fT src d2 2> /dev/null && fail=1 - -# rename must fail, since the src is not a directory. -mv -fT f e2 2> /dev/null && fail=1 - -Exit $fail diff --git a/tests/mv/no-target-dir.sh b/tests/mv/no-target-dir.sh new file mode 100755 index 000000000..c1443cd3e --- /dev/null +++ b/tests/mv/no-target-dir.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ensure that --no-target-directory (-T) works when the destination is +# an empty directory. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +mkdir -p d/sub empty src d2/sub e2 || framework_failure_ +touch f || framework_failure_ + +# Skip this test if there's an underlying kernel bug. +mkdir a b b/a || framework_failure_ + +mv a b || + skip_ "your kernel's rename syscall is buggy" + + +# This should succeed, since both src and dest are directories, +# and the dest dir is empty. +mv -fT d empty || fail=1 + +# Ensure that the source, d, is gone. +ls -d d > /dev/null 2>&1 && fail=1 + +# Ensure that the dest dir now has a subdirectory. +test -d empty/sub || fail=1 + +# rename must fail, since the dest is non-empty. +mv -fT src d2 2> /dev/null && fail=1 + +# rename must fail, since the src is not a directory. +mv -fT f e2 2> /dev/null && fail=1 + +Exit $fail diff --git a/tests/mv/part-fail b/tests/mv/part-fail deleted file mode 100755 index 499a6b66f..000000000 --- a/tests/mv/part-fail +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Make sure we give a sensible diagnostic when a cross-device 'mv' -# fails, e.g., because the destination cannot be unlinked. -# This is a bit fragile since it relies on the string used -# for EPERM: 'permission denied'. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -skip_if_root_ -cleanup_() { t=$other_partition_tmpdir; chmod -R 700 "$t"; rm -rf "$t"; } -. "$abs_srcdir/other-fs-tmpdir" - -touch k "$other_partition_tmpdir/k" || framework_failure_ -chmod u-w "$other_partition_tmpdir" || framework_failure_ - - -mv -f k "$other_partition_tmpdir" 2> out && fail=1 -printf \ -"mv: inter-device move failed: '%s' to '%s';"\ -' unable to remove target: Permission denied\n' \ - k "$other_partition_tmpdir/k" >exp - -# On some (less-compliant) systems, we get EPERM in this case. -# Accept either diagnostic. -cat < exp2 -mv: cannot move 'k' to '$other_partition_tmpdir/k': Permission denied -EOF - -if cmp out exp >/dev/null 2>&1; then - : -else - if cmp out exp2; then - : - else - fail=1 - fi -fi -test $fail = 1 && compare exp out - -Exit $fail diff --git a/tests/mv/part-fail.sh b/tests/mv/part-fail.sh new file mode 100755 index 000000000..499a6b66f --- /dev/null +++ b/tests/mv/part-fail.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Make sure we give a sensible diagnostic when a cross-device 'mv' +# fails, e.g., because the destination cannot be unlinked. +# This is a bit fragile since it relies on the string used +# for EPERM: 'permission denied'. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +skip_if_root_ +cleanup_() { t=$other_partition_tmpdir; chmod -R 700 "$t"; rm -rf "$t"; } +. "$abs_srcdir/other-fs-tmpdir" + +touch k "$other_partition_tmpdir/k" || framework_failure_ +chmod u-w "$other_partition_tmpdir" || framework_failure_ + + +mv -f k "$other_partition_tmpdir" 2> out && fail=1 +printf \ +"mv: inter-device move failed: '%s' to '%s';"\ +' unable to remove target: Permission denied\n' \ + k "$other_partition_tmpdir/k" >exp + +# On some (less-compliant) systems, we get EPERM in this case. +# Accept either diagnostic. +cat < exp2 +mv: cannot move 'k' to '$other_partition_tmpdir/k': Permission denied +EOF + +if cmp out exp >/dev/null 2>&1; then + : +else + if cmp out exp2; then + : + else + fail=1 + fi +fi +test $fail = 1 && compare exp out + +Exit $fail diff --git a/tests/mv/part-hardlink b/tests/mv/part-hardlink deleted file mode 100755 index af773a23b..000000000 --- a/tests/mv/part-hardlink +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Ensure that hard links are preserved when moving between partitions -# and when the links are in separate command line arguments. -# For additional constraints, see the comment in copy.c. -# Before coreutils-5.2.1, this test would fail. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -touch f || framework_failure_ -ln f g || framework_failure_ -mkdir a b || framework_failure_ -touch a/1 || framework_failure_ -ln a/1 b/1 || framework_failure_ - - -mv f g "$other_partition_tmpdir" || fail=1 -mv a b "$other_partition_tmpdir" || fail=1 - -cd "$other_partition_tmpdir" -set $(ls -Ci f g) -test $1 = $3 || fail=1 -set $(ls -Ci a/1 b/1) -test $1 = $3 || fail=1 - -Exit $fail diff --git a/tests/mv/part-hardlink.sh b/tests/mv/part-hardlink.sh new file mode 100755 index 000000000..af773a23b --- /dev/null +++ b/tests/mv/part-hardlink.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Ensure that hard links are preserved when moving between partitions +# and when the links are in separate command line arguments. +# For additional constraints, see the comment in copy.c. +# Before coreutils-5.2.1, this test would fail. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +touch f || framework_failure_ +ln f g || framework_failure_ +mkdir a b || framework_failure_ +touch a/1 || framework_failure_ +ln a/1 b/1 || framework_failure_ + + +mv f g "$other_partition_tmpdir" || fail=1 +mv a b "$other_partition_tmpdir" || fail=1 + +cd "$other_partition_tmpdir" +set $(ls -Ci f g) +test $1 = $3 || fail=1 +set $(ls -Ci a/1 b/1) +test $1 = $3 || fail=1 + +Exit $fail diff --git a/tests/mv/part-rename b/tests/mv/part-rename deleted file mode 100755 index 19d9ecb75..000000000 --- a/tests/mv/part-rename +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Moving a directory specified with a trailing slash from one partition to -# another, and giving it a different name at the destination would cause mv -# to get a failed assertion. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -mkdir foo || framework_failure_ - - -mv foo/ "$other_partition_tmpdir/bar" || fail=1 - -Exit $fail diff --git a/tests/mv/part-rename.sh b/tests/mv/part-rename.sh new file mode 100755 index 000000000..19d9ecb75 --- /dev/null +++ b/tests/mv/part-rename.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Moving a directory specified with a trailing slash from one partition to +# another, and giving it a different name at the destination would cause mv +# to get a failed assertion. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +mkdir foo || framework_failure_ + + +mv foo/ "$other_partition_tmpdir/bar" || fail=1 + +Exit $fail diff --git a/tests/mv/part-symlink b/tests/mv/part-symlink deleted file mode 100755 index e57de3c96..000000000 --- a/tests/mv/part-symlink +++ /dev/null @@ -1,261 +0,0 @@ -#!/bin/sh -# make sure cp and mv can handle many combinations of local and -# other-partition regular/symlink'd files. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv - -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -# On NFS on Linux 2.6.9 at least we get: -# mv: preserving permissions for 'rem_sl': Operation not supported -require_local_dir_ - -pwd_tmp=$(pwd) - -# Unset CDPATH. Otherwise, output from the 'cd dir' command -# can make this test fail. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# Four cases: -# local regular file w/symlink on another partition -# (loc_reg, rem_sl) -# (rem_sl, loc_reg) -# local symlink to regular file on another partition -# (loc_sl, rem_reg) -# (rem_reg, loc_sl) - -# Exercise those four cases for each of -# cp and mv, with lots of combinations of options. - -exec 1> actual - -# FIXME: This should be bigger: like more than 8k -contents=XYZ - -loc_reg=loc_reg -loc_sl=loc_sl -rem_reg=$other_partition_tmpdir/rem_reg -rem_sl=$other_partition_tmpdir/rem_sl - -for copy in cp mv; do - for args in \ - 'loc_reg rem_sl' \ - 'rem_sl loc_reg' \ - 'loc_sl rem_reg' \ - 'rem_reg loc_sl' \ - ; do - for options in '' --rem '--rem -d' '--rem -b' -b -bd -d; do - case "$options" in *d*|*--rem*) test $copy = mv && continue;; esac - rm -rf dir || fail=1 - rm -f "$other_partition_tmpdir"/* || fail=1 - mkdir dir || fail=1 - cd dir || fail=1 - case "$args" in *loc_reg*) reg_abs="$(pwd)/$loc_reg" ;; esac - case "$args" in *rem_reg*) reg_abs=$rem_reg ;; esac - case "$args" in *loc_sl*) slink=$loc_sl ;; esac - case "$args" in *rem_sl*) slink=$rem_sl ;; esac - - echo $contents > "$reg_abs" || fail=1 - ln -nsf "$reg_abs" $slink || fail=1 - actual_args=$(echo $args|sed 's,^,$,;s/ / $/') - actual_args=$(eval echo $actual_args) - - ( - ( - # echo 1>&2 cp $options $args - $copy $options $actual_args 2>.err - copy_status=$? - echo $copy_status $copy $options $args - - # Normalize the program name in the error output, - # remove any site-dependent part of other-partition file name, - # and put brackets around the output. - test -s .err && { - echo ' [' | tr -d '\n' - sed 's/^[^:][^:]*\(..\):/\1:/;s,'"$other_partition_tmpdir/,," .err | - tr -d '\n' - echo ']' - } - # Strip off all but the file names. - # Remove any site-dependent part of each file name. - ls=$(ls -gG --ignore=.err . \ - | sed \ - -e '/^total /d' \ - -e "s,$other_partition_tmpdir/,," \ - -e "s,$pwd_tmp/,," \ - -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//') - ls2=$(cd "$other_partition_tmpdir" && ls -gG --ignore=.err . \ - | sed \ - -e '/^total /d' \ - -e "s,$other_partition_tmpdir/,," \ - -e "s,$pwd_tmp/,," \ - -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//') - echo " ("$ls") ("$ls2")" - - # If the command failed, then it must not have changed the files. - if test $copy_status != 0; then - for f in $actual_args; do - test -f $f || - { echo " $copy FAILED but removed $f"; continue; } - case "$(cat $f)" in - "$contents") ;; - *) echo " $copy FAILED but modified $f";; - esac - done - fi - - if test $copy = cp; then - # Make sure the original is unchanged and that - # the destination is a copy. - for f in $actual_args; do - if test -f $f; then - if test $copy_status != 0; then - test - fi - case "$(cat $f)" in - "$contents") ;; - *) echo " $copy FAILED";; - esac - else - echo " symlink-loop" - fi - done - fi - ) - ) | sed 's/ *$//' - cd .. - done - echo - done -done - -test $fail = 1 && - { (exit 1); exit; } - -cat <<\EOF > expected -1 cp loc_reg rem_sl - [cp: 'loc_reg' and 'rem_sl' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) -0 cp --rem loc_reg rem_sl - (loc_reg) (rem_sl) -0 cp --rem -d loc_reg rem_sl - (loc_reg) (rem_sl) -0 cp --rem -b loc_reg rem_sl - (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg) -0 cp -b loc_reg rem_sl - (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg) -0 cp -bd loc_reg rem_sl - (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg) -1 cp -d loc_reg rem_sl - [cp: 'loc_reg' and 'rem_sl' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) - -1 cp rem_sl loc_reg - [cp: 'rem_sl' and 'loc_reg' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) -1 cp --rem rem_sl loc_reg - [cp: 'rem_sl' and 'loc_reg' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) -1 cp --rem -d rem_sl loc_reg - [cp: 'rem_sl' and 'loc_reg' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) -1 cp --rem -b rem_sl loc_reg - [cp: 'rem_sl' and 'loc_reg' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) -1 cp -b rem_sl loc_reg - [cp: 'rem_sl' and 'loc_reg' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) -0 cp -bd rem_sl loc_reg - (loc_reg -> dir/loc_reg loc_reg~) (rem_sl -> dir/loc_reg) - symlink-loop - symlink-loop -1 cp -d rem_sl loc_reg - [cp: 'rem_sl' and 'loc_reg' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) - -1 cp loc_sl rem_reg - [cp: 'loc_sl' and 'rem_reg' are the same file] - (loc_sl -> rem_reg) (rem_reg) -1 cp --rem loc_sl rem_reg - [cp: 'loc_sl' and 'rem_reg' are the same file] - (loc_sl -> rem_reg) (rem_reg) -1 cp --rem -d loc_sl rem_reg - [cp: 'loc_sl' and 'rem_reg' are the same file] - (loc_sl -> rem_reg) (rem_reg) -1 cp --rem -b loc_sl rem_reg - [cp: 'loc_sl' and 'rem_reg' are the same file] - (loc_sl -> rem_reg) (rem_reg) -1 cp -b loc_sl rem_reg - [cp: 'loc_sl' and 'rem_reg' are the same file] - (loc_sl -> rem_reg) (rem_reg) -0 cp -bd loc_sl rem_reg - (loc_sl -> rem_reg) (rem_reg -> rem_reg rem_reg~) - symlink-loop - symlink-loop -1 cp -d loc_sl rem_reg - [cp: 'loc_sl' and 'rem_reg' are the same file] - (loc_sl -> rem_reg) (rem_reg) - -1 cp rem_reg loc_sl - [cp: 'rem_reg' and 'loc_sl' are the same file] - (loc_sl -> rem_reg) (rem_reg) -0 cp --rem rem_reg loc_sl - (loc_sl) (rem_reg) -0 cp --rem -d rem_reg loc_sl - (loc_sl) (rem_reg) -0 cp --rem -b rem_reg loc_sl - (loc_sl loc_sl~ -> rem_reg) (rem_reg) -0 cp -b rem_reg loc_sl - (loc_sl loc_sl~ -> rem_reg) (rem_reg) -0 cp -bd rem_reg loc_sl - (loc_sl loc_sl~ -> rem_reg) (rem_reg) -1 cp -d rem_reg loc_sl - [cp: 'rem_reg' and 'loc_sl' are the same file] - (loc_sl -> rem_reg) (rem_reg) - -0 mv loc_reg rem_sl - () (rem_sl) -0 mv -b loc_reg rem_sl - () (rem_sl rem_sl~ -> dir/loc_reg) - -1 mv rem_sl loc_reg - [mv: 'rem_sl' and 'loc_reg' are the same file] - (loc_reg) (rem_sl -> dir/loc_reg) -0 mv -b rem_sl loc_reg - (loc_reg -> dir/loc_reg loc_reg~) () - -1 mv loc_sl rem_reg - [mv: 'loc_sl' and 'rem_reg' are the same file] - (loc_sl -> rem_reg) (rem_reg) -0 mv -b loc_sl rem_reg - () (rem_reg -> rem_reg rem_reg~) - -0 mv rem_reg loc_sl - (loc_sl) () -0 mv -b rem_reg loc_sl - (loc_sl loc_sl~ -> rem_reg) () - -EOF - -# Redirect to stderr, since stdout is already taken. -compare expected actual 1>&2 || fail=1 - -Exit $fail diff --git a/tests/mv/part-symlink.sh b/tests/mv/part-symlink.sh new file mode 100755 index 000000000..e57de3c96 --- /dev/null +++ b/tests/mv/part-symlink.sh @@ -0,0 +1,261 @@ +#!/bin/sh +# make sure cp and mv can handle many combinations of local and +# other-partition regular/symlink'd files. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv + +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +# On NFS on Linux 2.6.9 at least we get: +# mv: preserving permissions for 'rem_sl': Operation not supported +require_local_dir_ + +pwd_tmp=$(pwd) + +# Unset CDPATH. Otherwise, output from the 'cd dir' command +# can make this test fail. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# Four cases: +# local regular file w/symlink on another partition +# (loc_reg, rem_sl) +# (rem_sl, loc_reg) +# local symlink to regular file on another partition +# (loc_sl, rem_reg) +# (rem_reg, loc_sl) + +# Exercise those four cases for each of +# cp and mv, with lots of combinations of options. + +exec 1> actual + +# FIXME: This should be bigger: like more than 8k +contents=XYZ + +loc_reg=loc_reg +loc_sl=loc_sl +rem_reg=$other_partition_tmpdir/rem_reg +rem_sl=$other_partition_tmpdir/rem_sl + +for copy in cp mv; do + for args in \ + 'loc_reg rem_sl' \ + 'rem_sl loc_reg' \ + 'loc_sl rem_reg' \ + 'rem_reg loc_sl' \ + ; do + for options in '' --rem '--rem -d' '--rem -b' -b -bd -d; do + case "$options" in *d*|*--rem*) test $copy = mv && continue;; esac + rm -rf dir || fail=1 + rm -f "$other_partition_tmpdir"/* || fail=1 + mkdir dir || fail=1 + cd dir || fail=1 + case "$args" in *loc_reg*) reg_abs="$(pwd)/$loc_reg" ;; esac + case "$args" in *rem_reg*) reg_abs=$rem_reg ;; esac + case "$args" in *loc_sl*) slink=$loc_sl ;; esac + case "$args" in *rem_sl*) slink=$rem_sl ;; esac + + echo $contents > "$reg_abs" || fail=1 + ln -nsf "$reg_abs" $slink || fail=1 + actual_args=$(echo $args|sed 's,^,$,;s/ / $/') + actual_args=$(eval echo $actual_args) + + ( + ( + # echo 1>&2 cp $options $args + $copy $options $actual_args 2>.err + copy_status=$? + echo $copy_status $copy $options $args + + # Normalize the program name in the error output, + # remove any site-dependent part of other-partition file name, + # and put brackets around the output. + test -s .err && { + echo ' [' | tr -d '\n' + sed 's/^[^:][^:]*\(..\):/\1:/;s,'"$other_partition_tmpdir/,," .err | + tr -d '\n' + echo ']' + } + # Strip off all but the file names. + # Remove any site-dependent part of each file name. + ls=$(ls -gG --ignore=.err . \ + | sed \ + -e '/^total /d' \ + -e "s,$other_partition_tmpdir/,," \ + -e "s,$pwd_tmp/,," \ + -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//') + ls2=$(cd "$other_partition_tmpdir" && ls -gG --ignore=.err . \ + | sed \ + -e '/^total /d' \ + -e "s,$other_partition_tmpdir/,," \ + -e "s,$pwd_tmp/,," \ + -e 's/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* *//') + echo " ("$ls") ("$ls2")" + + # If the command failed, then it must not have changed the files. + if test $copy_status != 0; then + for f in $actual_args; do + test -f $f || + { echo " $copy FAILED but removed $f"; continue; } + case "$(cat $f)" in + "$contents") ;; + *) echo " $copy FAILED but modified $f";; + esac + done + fi + + if test $copy = cp; then + # Make sure the original is unchanged and that + # the destination is a copy. + for f in $actual_args; do + if test -f $f; then + if test $copy_status != 0; then + test + fi + case "$(cat $f)" in + "$contents") ;; + *) echo " $copy FAILED";; + esac + else + echo " symlink-loop" + fi + done + fi + ) + ) | sed 's/ *$//' + cd .. + done + echo + done +done + +test $fail = 1 && + { (exit 1); exit; } + +cat <<\EOF > expected +1 cp loc_reg rem_sl + [cp: 'loc_reg' and 'rem_sl' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) +0 cp --rem loc_reg rem_sl + (loc_reg) (rem_sl) +0 cp --rem -d loc_reg rem_sl + (loc_reg) (rem_sl) +0 cp --rem -b loc_reg rem_sl + (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg) +0 cp -b loc_reg rem_sl + (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg) +0 cp -bd loc_reg rem_sl + (loc_reg) (rem_sl rem_sl~ -> dir/loc_reg) +1 cp -d loc_reg rem_sl + [cp: 'loc_reg' and 'rem_sl' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) + +1 cp rem_sl loc_reg + [cp: 'rem_sl' and 'loc_reg' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) +1 cp --rem rem_sl loc_reg + [cp: 'rem_sl' and 'loc_reg' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) +1 cp --rem -d rem_sl loc_reg + [cp: 'rem_sl' and 'loc_reg' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) +1 cp --rem -b rem_sl loc_reg + [cp: 'rem_sl' and 'loc_reg' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) +1 cp -b rem_sl loc_reg + [cp: 'rem_sl' and 'loc_reg' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) +0 cp -bd rem_sl loc_reg + (loc_reg -> dir/loc_reg loc_reg~) (rem_sl -> dir/loc_reg) + symlink-loop + symlink-loop +1 cp -d rem_sl loc_reg + [cp: 'rem_sl' and 'loc_reg' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) + +1 cp loc_sl rem_reg + [cp: 'loc_sl' and 'rem_reg' are the same file] + (loc_sl -> rem_reg) (rem_reg) +1 cp --rem loc_sl rem_reg + [cp: 'loc_sl' and 'rem_reg' are the same file] + (loc_sl -> rem_reg) (rem_reg) +1 cp --rem -d loc_sl rem_reg + [cp: 'loc_sl' and 'rem_reg' are the same file] + (loc_sl -> rem_reg) (rem_reg) +1 cp --rem -b loc_sl rem_reg + [cp: 'loc_sl' and 'rem_reg' are the same file] + (loc_sl -> rem_reg) (rem_reg) +1 cp -b loc_sl rem_reg + [cp: 'loc_sl' and 'rem_reg' are the same file] + (loc_sl -> rem_reg) (rem_reg) +0 cp -bd loc_sl rem_reg + (loc_sl -> rem_reg) (rem_reg -> rem_reg rem_reg~) + symlink-loop + symlink-loop +1 cp -d loc_sl rem_reg + [cp: 'loc_sl' and 'rem_reg' are the same file] + (loc_sl -> rem_reg) (rem_reg) + +1 cp rem_reg loc_sl + [cp: 'rem_reg' and 'loc_sl' are the same file] + (loc_sl -> rem_reg) (rem_reg) +0 cp --rem rem_reg loc_sl + (loc_sl) (rem_reg) +0 cp --rem -d rem_reg loc_sl + (loc_sl) (rem_reg) +0 cp --rem -b rem_reg loc_sl + (loc_sl loc_sl~ -> rem_reg) (rem_reg) +0 cp -b rem_reg loc_sl + (loc_sl loc_sl~ -> rem_reg) (rem_reg) +0 cp -bd rem_reg loc_sl + (loc_sl loc_sl~ -> rem_reg) (rem_reg) +1 cp -d rem_reg loc_sl + [cp: 'rem_reg' and 'loc_sl' are the same file] + (loc_sl -> rem_reg) (rem_reg) + +0 mv loc_reg rem_sl + () (rem_sl) +0 mv -b loc_reg rem_sl + () (rem_sl rem_sl~ -> dir/loc_reg) + +1 mv rem_sl loc_reg + [mv: 'rem_sl' and 'loc_reg' are the same file] + (loc_reg) (rem_sl -> dir/loc_reg) +0 mv -b rem_sl loc_reg + (loc_reg -> dir/loc_reg loc_reg~) () + +1 mv loc_sl rem_reg + [mv: 'loc_sl' and 'rem_reg' are the same file] + (loc_sl -> rem_reg) (rem_reg) +0 mv -b loc_sl rem_reg + () (rem_reg -> rem_reg rem_reg~) + +0 mv rem_reg loc_sl + (loc_sl) () +0 mv -b rem_reg loc_sl + (loc_sl loc_sl~ -> rem_reg) () + +EOF + +# Redirect to stderr, since stdout is already taken. +compare expected actual 1>&2 || fail=1 + +Exit $fail diff --git a/tests/mv/partition-perm b/tests/mv/partition-perm deleted file mode 100755 index bbda9da7a..000000000 --- a/tests/mv/partition-perm +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Make sure permissions are preserved when moving from one partition to another. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -: > file -chmod a=rwx file - -umask 077 -mv file "$other_partition_tmpdir" - -test -f file && fail=1 -test -f "$other_partition_tmpdir/file" || fail=1 - -# This would have failed with the mv from fileutils-4.0i. -mode=$(ls -l "$other_partition_tmpdir/file" | cut -b-10) -test "$mode" = "-rwxrwxrwx" || fail=1 - -Exit $fail diff --git a/tests/mv/partition-perm.sh b/tests/mv/partition-perm.sh new file mode 100755 index 000000000..bbda9da7a --- /dev/null +++ b/tests/mv/partition-perm.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Make sure permissions are preserved when moving from one partition to another. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +: > file +chmod a=rwx file + +umask 077 +mv file "$other_partition_tmpdir" + +test -f file && fail=1 +test -f "$other_partition_tmpdir/file" || fail=1 + +# This would have failed with the mv from fileutils-4.0i. +mode=$(ls -l "$other_partition_tmpdir/file" | cut -b-10) +test "$mode" = "-rwxrwxrwx" || fail=1 + +Exit $fail diff --git a/tests/mv/perm-1 b/tests/mv/perm-1 deleted file mode 100755 index 3a7944a66..000000000 --- a/tests/mv/perm-1 +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# ensure that mv gives one diagnostic, not two, when failing -# due to lack of permissions - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -skip_if_root_ - -mkdir -p no-write/dir || framework_failure_ -chmod u-w no-write || framework_failure_ - - -mv no-write/dir . > out 2>&1 && fail=1 -cat <<\EOF > exp -mv: cannot move 'no-write/dir' to './dir': Permission denied -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/mv/perm-1.sh b/tests/mv/perm-1.sh new file mode 100755 index 000000000..3a7944a66 --- /dev/null +++ b/tests/mv/perm-1.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# ensure that mv gives one diagnostic, not two, when failing +# due to lack of permissions + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +skip_if_root_ + +mkdir -p no-write/dir || framework_failure_ +chmod u-w no-write || framework_failure_ + + +mv no-write/dir . > out 2>&1 && fail=1 +cat <<\EOF > exp +mv: cannot move 'no-write/dir' to './dir': Permission denied +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/mv/sticky-to-xpart b/tests/mv/sticky-to-xpart deleted file mode 100755 index 6df65024e..000000000 --- a/tests/mv/sticky-to-xpart +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# A cross-partition move of a file in a sticky tmpdir and owned by -# someone else would evoke an invalid diagnostic: -# mv: cannot remove 'x': Operation not permitted -# Affects coreutils-6.0-6.9. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -require_root_ - -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -# Set up to run a test where non-root user tries to move a root-owned -# file from a sticky tmpdir to a directory owned by that user on -# a different partition. - -mkdir t || framework_failure_ -chmod a=rwx,o+t t || framework_failure_ -echo > t/root-owned || framework_failure_ -chmod a+r t/root-owned || framework_failure_ -chown "$NON_ROOT_USERNAME" "$other_partition_tmpdir" || framework_failure_ - -# We have to allow $NON_ROOT_USERNAME access to ".". -chmod go+x . || framework_failure_ - - -# Ensure that $NON_ROOT_USERNAME can access the required version of mv. -version=$( - setuidgid $NON_ROOT_USERNAME env PATH="$PATH" mv --version | - sed -n '1s/.* //p' -) -case $version in - $PACKAGE_VERSION) ;; - *) skip_ "cannot access just-built mv as user $NON_ROOT_USERNAME";; -esac - -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" \ - mv t/root-owned "$other_partition_tmpdir" 2> out-t && fail=1 - -# On some systems, we get 'Not owner'. Convert it. -# On other systems (HPUX), we get 'Permission denied'. Convert it, too. -onp='Operation not permitted' -sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t > out - -cat <<\EOF > exp -mv: cannot remove 't/root-owned': Operation not permitted -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/mv/sticky-to-xpart.sh b/tests/mv/sticky-to-xpart.sh new file mode 100755 index 000000000..6df65024e --- /dev/null +++ b/tests/mv/sticky-to-xpart.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# A cross-partition move of a file in a sticky tmpdir and owned by +# someone else would evoke an invalid diagnostic: +# mv: cannot remove 'x': Operation not permitted +# Affects coreutils-6.0-6.9. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +require_root_ + +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +# Set up to run a test where non-root user tries to move a root-owned +# file from a sticky tmpdir to a directory owned by that user on +# a different partition. + +mkdir t || framework_failure_ +chmod a=rwx,o+t t || framework_failure_ +echo > t/root-owned || framework_failure_ +chmod a+r t/root-owned || framework_failure_ +chown "$NON_ROOT_USERNAME" "$other_partition_tmpdir" || framework_failure_ + +# We have to allow $NON_ROOT_USERNAME access to ".". +chmod go+x . || framework_failure_ + + +# Ensure that $NON_ROOT_USERNAME can access the required version of mv. +version=$( + setuidgid $NON_ROOT_USERNAME env PATH="$PATH" mv --version | + sed -n '1s/.* //p' +) +case $version in + $PACKAGE_VERSION) ;; + *) skip_ "cannot access just-built mv as user $NON_ROOT_USERNAME";; +esac + +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" \ + mv t/root-owned "$other_partition_tmpdir" 2> out-t && fail=1 + +# On some systems, we get 'Not owner'. Convert it. +# On other systems (HPUX), we get 'Permission denied'. Convert it, too. +onp='Operation not permitted' +sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t > out + +cat <<\EOF > exp +mv: cannot remove 't/root-owned': Operation not permitted +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/mv/symlink-onto-hardlink b/tests/mv/symlink-onto-hardlink deleted file mode 100755 index 2dac48401..000000000 --- a/tests/mv/symlink-onto-hardlink +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Ensure that mv works with a few symlink-onto-hard-link cases. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -touch f || framework_failure_ -ln f h || framework_failure_ -ln -s f s || framework_failure_ - -# Given two links f and h to some important content, and a symlink s to f, -# "mv s f" must fail because it might then be hard to find the link, h. -# "mv s l" may succeed because then, s (now "l") still points to f. -# Of course, if the symlink were being moved into a different destination -# directory, things would be very different, and, I suspect, implausible. - -echo "mv: 's' and 'f' are the same file" > exp || framework_failure_ -mv s f > out 2> err && fail=1 -compare /dev/null out || fail=1 -compare exp err || fail=1 - -mv s l > out 2> err || fail=1 -compare /dev/null out || fail=1 -compare /dev/null err || fail=1 - -Exit $fail diff --git a/tests/mv/symlink-onto-hardlink-to-self b/tests/mv/symlink-onto-hardlink-to-self deleted file mode 100755 index f53f6ef44..000000000 --- a/tests/mv/symlink-onto-hardlink-to-self +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# Demonstrate that when moving a symlink onto a hardlink-to-that-symlink, the -# source symlink is removed. Depending on your kernel (e.g., Linux, Solaris, -# but not NetBSD), prior to coreutils-8.16, the mv would successfully perform -# a no-op. I.e., surprisingly, mv s1 s2 would succeed, yet fail to remove s1. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -# Create a file f, and a symlink s1 to that file. -touch f || framework_failure_ -ln -s f s2 || framework_failure_ - -for opt in '' --backup; do - - # Attempt to create a hard link to that symlink. - # On some systems, it's not possible: they create a hard link to the referent. - ln s2 s1 || framework_failure_ - - # If s1 is not a symlink, skip this test. - test -h s1 \ - || skip_ your kernel or file system cannot create a hard link to a symlink - - mv $opt s1 s2 > out 2>&1 || fail=1 - compare /dev/null out || fail=1 - - # Ensure that s1 is gone. - test -e s1 && fail=1 - - if test "$opt" = --backup; then - # With --backup, ensure that the backup file was created. - ref=$(readlink s2~) || fail=1 - test "$ref" = f || fail=1 - else - # Without --backup, ensure there is no backup file. - test -e s2~ && fail=1 - fi - -done - -Exit $fail diff --git a/tests/mv/symlink-onto-hardlink-to-self.sh b/tests/mv/symlink-onto-hardlink-to-self.sh new file mode 100755 index 000000000..f53f6ef44 --- /dev/null +++ b/tests/mv/symlink-onto-hardlink-to-self.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Demonstrate that when moving a symlink onto a hardlink-to-that-symlink, the +# source symlink is removed. Depending on your kernel (e.g., Linux, Solaris, +# but not NetBSD), prior to coreutils-8.16, the mv would successfully perform +# a no-op. I.e., surprisingly, mv s1 s2 would succeed, yet fail to remove s1. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +# Create a file f, and a symlink s1 to that file. +touch f || framework_failure_ +ln -s f s2 || framework_failure_ + +for opt in '' --backup; do + + # Attempt to create a hard link to that symlink. + # On some systems, it's not possible: they create a hard link to the referent. + ln s2 s1 || framework_failure_ + + # If s1 is not a symlink, skip this test. + test -h s1 \ + || skip_ your kernel or file system cannot create a hard link to a symlink + + mv $opt s1 s2 > out 2>&1 || fail=1 + compare /dev/null out || fail=1 + + # Ensure that s1 is gone. + test -e s1 && fail=1 + + if test "$opt" = --backup; then + # With --backup, ensure that the backup file was created. + ref=$(readlink s2~) || fail=1 + test "$ref" = f || fail=1 + else + # Without --backup, ensure there is no backup file. + test -e s2~ && fail=1 + fi + +done + +Exit $fail diff --git a/tests/mv/symlink-onto-hardlink.sh b/tests/mv/symlink-onto-hardlink.sh new file mode 100755 index 000000000..2dac48401 --- /dev/null +++ b/tests/mv/symlink-onto-hardlink.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Ensure that mv works with a few symlink-onto-hard-link cases. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +touch f || framework_failure_ +ln f h || framework_failure_ +ln -s f s || framework_failure_ + +# Given two links f and h to some important content, and a symlink s to f, +# "mv s f" must fail because it might then be hard to find the link, h. +# "mv s l" may succeed because then, s (now "l") still points to f. +# Of course, if the symlink were being moved into a different destination +# directory, things would be very different, and, I suspect, implausible. + +echo "mv: 's' and 'f' are the same file" > exp || framework_failure_ +mv s f > out 2> err && fail=1 +compare /dev/null out || fail=1 +compare exp err || fail=1 + +mv s l > out 2> err || fail=1 +compare /dev/null out || fail=1 +compare /dev/null err || fail=1 + +Exit $fail diff --git a/tests/mv/to-symlink b/tests/mv/to-symlink deleted file mode 100755 index c203d7a4b..000000000 --- a/tests/mv/to-symlink +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Make sure that the copying code used in an inter-partition -# move unlinks a destination symlink before opening it. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv -cleanup_() { rm -rf "$other_partition_tmpdir"; } -. "$abs_srcdir/other-fs-tmpdir" - -rem_file="$other_partition_tmpdir/file" -rem_symlink="$other_partition_tmpdir/symlink" -file=to-sym - -echo local > $file || framework_failure_ -echo remote > $rem_file || framework_failure_ -ln -s $rem_file $rem_symlink || framework_failure_ - -# This mv command should succeed, unlinking the symlink -# before copying. -mv $file $rem_symlink || fail=1 - -# Make sure $file is gone. -test -f $file && fail=1 - -# Make sure $rem_file is unmodified. -test $(cat $rem_file) = remote || fail=1 - -Exit $fail diff --git a/tests/mv/to-symlink.sh b/tests/mv/to-symlink.sh new file mode 100755 index 000000000..c203d7a4b --- /dev/null +++ b/tests/mv/to-symlink.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Make sure that the copying code used in an inter-partition +# move unlinks a destination symlink before opening it. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" + +rem_file="$other_partition_tmpdir/file" +rem_symlink="$other_partition_tmpdir/symlink" +file=to-sym + +echo local > $file || framework_failure_ +echo remote > $rem_file || framework_failure_ +ln -s $rem_file $rem_symlink || framework_failure_ + +# This mv command should succeed, unlinking the symlink +# before copying. +mv $file $rem_symlink || fail=1 + +# Make sure $file is gone. +test -f $file && fail=1 + +# Make sure $rem_file is unmodified. +test $(cat $rem_file) = remote || fail=1 + +Exit $fail diff --git a/tests/mv/trailing-slash b/tests/mv/trailing-slash deleted file mode 100755 index 26f880250..000000000 --- a/tests/mv/trailing-slash +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# On some operating systems, e.g. SunOS-4.1.1_U1 on sun3x, -# rename() doesn't accept trailing slashes. -# Also, ensure that "mv dir non-exist-dir/" works. -# Also, ensure that "cp dir non-exist-dir/" works. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ mv - -mkdir foo || framework_failure_ - - -mv foo/ bar || fail=1 - -# mv and cp would misbehave for coreutils versions [5.3.0..5.97], 6.0 and 6.1 -for cmd in mv 'cp -r'; do - for opt in '' -T -u; do - rm -rf d e || framework_failure_ - mkdir d || framework_failure_ - - $cmd $opt d e/ || fail=1 - if test "$cmd" = mv; then - test -d d && fail=1 - else - test -d d || fail=1 - fi - test -d e || fail=1 - done -done - -# We would like the erroneous-looking "mv any non-dir/" to fail, -# but with the current implementation, it depends on how the -# underlying rename syscall handles the trailing slash. -# It does fail, as desired, on recent Linux and Solaris systems. -#touch a a2 -#mv a a2/ && fail=1 - -# Test for a cp-specific diagnostic introduced after coreutils-8.7: -printf '%s\n' \ - "cp: cannot create regular file 'no-such/': Not a directory" \ -> expected-err -touch b -cp b no-such/ 2> err && fail=1 - -# Map "No such file..." diagnostic to the expected "Not a directory" -sed 's/No such file or directory/Not a directory/' err > k && mv k err - -compare expected-err err || fail=1 - -Exit $fail diff --git a/tests/mv/trailing-slash.sh b/tests/mv/trailing-slash.sh new file mode 100755 index 000000000..26f880250 --- /dev/null +++ b/tests/mv/trailing-slash.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# On some operating systems, e.g. SunOS-4.1.1_U1 on sun3x, +# rename() doesn't accept trailing slashes. +# Also, ensure that "mv dir non-exist-dir/" works. +# Also, ensure that "cp dir non-exist-dir/" works. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ mv + +mkdir foo || framework_failure_ + + +mv foo/ bar || fail=1 + +# mv and cp would misbehave for coreutils versions [5.3.0..5.97], 6.0 and 6.1 +for cmd in mv 'cp -r'; do + for opt in '' -T -u; do + rm -rf d e || framework_failure_ + mkdir d || framework_failure_ + + $cmd $opt d e/ || fail=1 + if test "$cmd" = mv; then + test -d d && fail=1 + else + test -d d || fail=1 + fi + test -d e || fail=1 + done +done + +# We would like the erroneous-looking "mv any non-dir/" to fail, +# but with the current implementation, it depends on how the +# underlying rename syscall handles the trailing slash. +# It does fail, as desired, on recent Linux and Solaris systems. +#touch a a2 +#mv a a2/ && fail=1 + +# Test for a cp-specific diagnostic introduced after coreutils-8.7: +printf '%s\n' \ + "cp: cannot create regular file 'no-such/': Not a directory" \ +> expected-err +touch b +cp b no-such/ 2> err && fail=1 + +# Map "No such file..." diagnostic to the expected "Not a directory" +sed 's/No such file or directory/Not a directory/' err > k && mv k err + +compare expected-err err || fail=1 + +Exit $fail diff --git a/tests/mv/update b/tests/mv/update deleted file mode 100755 index f0beb4076..000000000 --- a/tests/mv/update +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# make sure --update works as advertised - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ cp mv - -echo old > old || framework_failure_ -touch -d yesterday old || framework_failure_ -echo new > new || framework_failure_ - - -for interactive in '' -i; do - for cp_or_mv in cp mv; do - # This is a no-op, with no prompt. - # With coreutils-6.9 and earlier, using --update with -i would - # mistakenly elicit a prompt. - $cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1 - test -s out && fail=1 - case "$(cat new)" in new) ;; *) fail=1 ;; esac - case "$(cat old)" in old) ;; *) fail=1 ;; esac - done -done - -# This will actually perform the rename. -mv --update new old || fail=1 -test -f new && fail=1 -case "$(cat old)" in new) ;; *) fail=1 ;; esac - -# Restore initial conditions. -echo old > old || fail=1 -touch -d yesterday old || fail=1 -echo new > new || fail=1 - -# This will actually perform the copy. -cp --update new old || fail=1 -case "$(cat old)" in new) ;; *) fail=1 ;; esac -case "$(cat new)" in new) ;; *) fail=1 ;; esac - -Exit $fail diff --git a/tests/mv/update.sh b/tests/mv/update.sh new file mode 100755 index 000000000..f0beb4076 --- /dev/null +++ b/tests/mv/update.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# make sure --update works as advertised + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ cp mv + +echo old > old || framework_failure_ +touch -d yesterday old || framework_failure_ +echo new > new || framework_failure_ + + +for interactive in '' -i; do + for cp_or_mv in cp mv; do + # This is a no-op, with no prompt. + # With coreutils-6.9 and earlier, using --update with -i would + # mistakenly elicit a prompt. + $cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1 + test -s out && fail=1 + case "$(cat new)" in new) ;; *) fail=1 ;; esac + case "$(cat old)" in old) ;; *) fail=1 ;; esac + done +done + +# This will actually perform the rename. +mv --update new old || fail=1 +test -f new && fail=1 +case "$(cat old)" in new) ;; *) fail=1 ;; esac + +# Restore initial conditions. +echo old > old || fail=1 +touch -d yesterday old || fail=1 +echo new > new || fail=1 + +# This will actually perform the copy. +cp --update new old || fail=1 +case "$(cat old)" in new) ;; *) fail=1 ;; esac +case "$(cat new)" in new) ;; *) fail=1 ;; esac + +Exit $fail diff --git a/tests/pr/pr-tests b/tests/pr/pr-tests deleted file mode 100755 index 259c9d6c2..000000000 --- a/tests/pr/pr-tests +++ /dev/null @@ -1,460 +0,0 @@ -#!/usr/bin/perl -# Test pr. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = 'pr'; - -my @tv = ( - -# -b option is no longer an official option. But it's still working to -# get a downward compatibility. Now (version 1.19m or newer) -COLUMN -# only is equivalent to -b -COLUMN. -# -# test_name options input-file-name(s) expected-output-group-file-name -# expected-return-code -# ------------------------------------------------------------------------- -# Following tests with "FF set" don't contain a complete set of all -# combinations of options and FF-arrangements -# -# One FF at start of file (one empty page) -# ['1a', '', [\'0Ft'], [\'0F'], 0], -['1b', '', [\'0Fnt'], [\'0F'], 0], -['1c', '+3', [\'0Ft'], [\'3-0F'], 0], -['1d', '+3 -f', [\'0Ft'], [\'3f-0F'], 0], -['1e', '-a -3', [\'0Ft'], [\'a3-0F'], 0], -['1f', '-a -3 -f', [\'0Ft'], [\'a3f-0F'], 0], -['1g', '-a -3 -f', [\'0Fnt'], [\'a3f-0F'], 0], -['1h', '+3 -a -3 -f', [\'0Ft'], [\'3a3f-0F'], 0], -['1i', '-b -3', [\'0Ft'], [\'b3-0F'], 0], -['1j', '-b -3 -f', [\'0Ft'], [\'b3f-0F'], 0], -['1k', '-b -3 -f', [\'0Fnt'], [\'b3f-0F'], 0], -['1l', '+3 -b -3 -f', [\'0Ft'], [\'3b3f-0F'], 0], -# Two FF at start of file (two empty page) -['2a', '', [\'0FFt'], [\'0FF'], 0], -['2b', '', [\'0FnFnt'], [\'0FF'], 0], -['2c', '-a -3 -f', [\'0FFt'], [\'a3f-0FF'], 0], -['2d', '-a -3 -f', [\'0FFnt'], [\'a3f-0FF'], 0], -['2e', '-b -3 -f', [\'0FFt'], [\'b3f-0FF'], 0], -['2f', '-b -3 -f', [\'0FFnt'], [\'b3f-0FF'], 0], -['2g', '-b -3 -f', [\'0FnFt'], [\'b3f-0FF'], 0], -['2h', '-b -3 -f', [\'0FnFnt'], [\'b3f-0FF'], 0], -['2i', '+3 -b -3 -f', [\'0FFt'], [\'3b3f-0FF'], 0], -['2j', '+3 -b -3 -f', [\'0FFnt'], [\'3b3f-0FF'], 0], -# -# FFs in text (none / one / two empty page(s)) -['3a', '', [\'FFn'], [\'FF'], 0], -['3b', '', [\'FnFn'], [\'FF'], 0], -['3c', '+3', [\'FFn'], [\'3-FF'], 0], -['3d', '+3 -f', [\'FFn'], [\'3f-FF'], 0], -['3e', '-a -3 -f', [\'FFn'], [\'a3f-FF'], 0], -['3f', '-a -3 -f', [\'FFtn'], [\'a3f-FF'], 0], -['3g', '-b -3 -f', [\'FFn'], [\'b3f-FF'], 0], -['3h', '-b -3 -f', [\'FFtn'], [\'b3f-FF'], 0], -['3i', '-b -3 -f', [\'FnFn'], [\'b3f-FF'], 0], -['3j', '-b -3 -f', [\'tFFn'], [\'b3f-FF'], 0], -['3k', '-b -3 -f', [\'tFnFt'], [\'b3f-FF'], 0], -['3l', '+3 -b -3 -f', [\'FFn'], [\'3b3f-FF'], 0], -['3m', '+3 -b -3 -f', [\'FFtn'], [\'3b3f-FF'], 0], -# A full page printed (lines_left_on_page = 0) without a FF found. -# Avoid an extra empty page if a FF follows in the next input line. -['3la', '-l 24', [\'FFn'], [\'l24-FF'], 0], -['3lb', '-l 24', [\'FFtn'], [\'l24-FF'], 0], -['3lc', '-l 24', [\'FnFn'], [\'l24-FF'], 0], -['3ld', '-l 24', [\'tFFn'], [\'l24-FF'], 0], -['3le', '-l 24', [\'tFnFt'], [\'l24-FF'], 0], -['3lf', '-l 24', [\'tFFt'], [\'l24-FF'], 0], -['3aa', '-a -2 -l 17', [\'FFn'], [\'a2l17-FF'], 0], -['3ab', '-a -2 -l 17', [\'FFtn'], [\'a2l17-FF'], 0], -['3ac', '-a -2 -l 17', [\'FnFn'], [\'a2l17-FF'], 0], -['3ad', '-a -2 -l 17', [\'tFFn'], [\'a2l17-FF'], 0], -['3ae', '-a -2 -l 17', [\'tFnFt'], [\'a2l17-FF'], 0], -['3af', '-a -2 -l 17', [\'tFFt'], [\'a2l17-FF'], 0], -['3ag', '-a -2 -l 15', [\'FFn'], [\'a2l15-FF'], 0], -['3ah', '-a -2 -l 15', [\'FFtn'], [\'a2l15-FF'], 0], -['3ai', '-a -2 -l 15', [\'FnFn'], [\'a2l15-FF'], 0], -['3aj', '-a -2 -l 15', [\'tFFn'], [\'a2l15-FF'], 0], -['3ak', '-a -2 -l 15', [\'tFnFt'], [\'a2l15-FF'], 0], -['3ba', '-b -2 -l 17', [\'FFn'], [\'b2l17-FF'], 0], -['3bb', '-b -2 -l 17', [\'FFtn'], [\'b2l17-FF'], 0], -['3bc', '-b -2 -l 17', [\'FnFn'], [\'b2l17-FF'], 0], -['3bd', '-b -2 -l 17', [\'tFFn'], [\'b2l17-FF'], 0], -['3be', '-b -2 -l 17', [\'tFnFt'], [\'b2l17-FF'], 0], -['3bf', '-b -2 -l 17', [\'tFFt'], [\'b2l17-FF'], 0], -['3bg', '-b -2 -l 15', [\'FFn'], [\'b2l15-FF'], 0], -['3bh', '-b -2 -l 15', [\'FFtn'], [\'b2l15-FF'], 0], -['3bi', '-b -2 -l 15', [\'FnFn'], [\'b2l15-FF'], 0], -['3bj', '-b -2 -l 15', [\'tFFn'], [\'b2l15-FF'], 0], -['3bk', '-b -2 -l 15', [\'tFnFt'], [\'b2l15-FF'], 0], -['3Pa', '+4 -l 24', [\'FFn'], [\'4l24-FF'], 0], -['3Pb', '+4 -l 24', [\'FFtn'], [\'4l24-FF'], 0], -['3Pc', '+4 -l 24', [\'FnFn'], [\'4l24-FF'], 0], -['3Pd', '+4 -l 24', [\'tFFn'], [\'4l24-FF'], 0], -['3Pe', '+4 -l 24', [\'tFnFt'], [\'4l24-FF'], 0], -['3Pf', '+4 -l 24', [\'tFFt'], [\'4l24-FF'], 0], -['3Pg', '+4:7 -l 24', [\'tFFt'], [\'4-7l24-FF'], 0], -['3Paa', '+3 -a -2 -l 17', [\'FFn'], [\'3a2l17-FF'], 0], -['3Pab', '+3 -a -2 -l 17', [\'FFtn'], [\'3a2l17-FF'], 0], -['3Pac', '+3 -a -2 -l 17', [\'FnFn'], [\'3a2l17-FF'], 0], -['3Pad', '+3 -a -2 -l 17', [\'tFFn'], [\'3a2l17-FF'], 0], -['3Pae', '+3 -a -2 -l 17', [\'tFnFt'], [\'3a2l17-FF'], 0], -['3Paf', '+3 -a -2 -l 17', [\'tFFt'], [\'3a2l17-FF'], 0], -['3Pba', '+3 -b -2 -l 17', [\'FFn'], [\'3b2l17-FF'], 0], -['3Pbb', '+3 -b -2 -l 17', [\'FFtn'], [\'3b2l17-FF'], 0], -['3Pbc', '+3 -b -2 -l 17', [\'FnFn'], [\'3b2l17-FF'], 0], -['3Pbd', '+3 -b -2 -l 17', [\'tFFn'], [\'3b2l17-FF'], 0], -['3Pbe', '+3 -b -2 -l 17', [\'tFnFt'], [\'3b2l17-FF'], 0], -['3Pbf', '+3 -b -2 -l 17', [\'tFFt'], [\'3b2l17-FF'], 0], -# -# Without "FF set by hand" -['4a', '-l 24', [\'tn'], [\'l24-t'], 0], -['4b', '-l 24 -f', [\'tn'], [\'l24f-t'], 0], -['4c', '+3 -l 24', [\'tn'], [\'3l24-t'], 0], -['4d', '+3 -l 24 -f', [\'tn'], [\'3l24f-t'], 0], -['4e', '+3:5 -l 24 -f', [\'tn'], [\'3-5l24f-t'], 0], -['4f', '-a -3 -l 15', [\'tn'], [\'a3l15-t'], 0], -['4g', '-a -3 -l 15 -f', [\'tn'], [\'a3l15f-t'], 0], -['4h', '+3 -a -3 -l 15', [\'tn'], [\'3a3l15-t'], 0], -['4i', '+3 -a -3 -l 15 -f', [\'tn'], [\'3a3l15f-t'], 0], -['4j', '-b -3 -l 15', [\'tn'], [\'b3l15-t'], 0], -['4k', '-b -3 -l 15 -f', [\'tn'], [\'b3l15f-t'], 0], -['4l', '+3 -b -3 -l 15', [\'tn'], [\'3b3l15-t'], 0], -['4m', '+3 -b -3 -l 15 -f', [\'tn'], [\'3b3l15f-t'], 0], -# -# Merge input files (-m option) -['5a', '-m -l 24', [\'tn', \'tn'], [\'ml24-t'], 0], -['5b', '-m -l 24 -f', [\'tn', \'tn'], [\'ml24f-t'], 0], -['5c', '+3 -m -l 24', [\'tn', \'tn'], [\'3ml24-t'], 0], -['5d', '+3 -m -l 24 -f', [\'tn', \'tn'], [\'3ml24f-t'], 0], -['5e', '-m -l 24 -f', [\'0Ft', \'0Ft'], [\'ml24f-0F'], 0], -['5f', '-m -l 24 -f', [\'0Ft', \'0Fnt'], [\'ml24f-0F'], 0], -['5g', '-m -l 24 -f', [\'tn', \'0Ft'], [\'ml24f-t-0F'], 0], -# A full page printed (lines_left_on_page = 0) without a FF found. -# Avoid an extra empty page if a FF follows in the next input line. -['5ma', '-m -l 24', [\'tFFn', \'tFnFt'], [\'ml24-FF'], 0], -['5mb', '-m -l 24', [\'tFFn', \'FFn'], [\'ml24-FF'], 0], -['5mc', '-m -l 24', [\'tn', \'FFn'], [\'ml24-t-FF'], 0], -['5md', '-m -l 20', [\'FFn', \'tn'], [\'ml20-FF-t'], 0], -['5Pma', '+3 -m -l 24', [\'FFn', \'FnFn'], [\'3ml24-FF'], 0], -['5Pmb', '+3 -m -l 24', [\'tFFn', \'FFn'], [\'3ml24-FF'], 0], -['5Pmc', '+3 -m -l 24', [\'tn', \'FFn'], [\'3ml24-t-FF'], 0], -# -# Do not print header and footer but retain "FF set by Hand" -# (-t option) -['6a', '-t -l 24', [\'tn'], [\'t-t'], 0], -['6b', '-t -l 24 -f', [\'tn'], [\'t-t'], 0], -['6c', '-t -l 24 -f', [\'tFFt-bl'], [\'t-bl'], 0], -['6d', '-t -l 24', [\'0FnFnt'], [\'t-0FF'], 0], -['6e', '-t -l 24', [\'FFn'], [\'t-FF'], 0], -['6f', '-t -l 24', [\'FnFn'], [\'t-FF'], 0], -['6g', '-t -l 24 -f', [\'FFn'], [\'t-FF'], 0], -['6aa', '-t -a -3', [\'0FnFnt'], [\'ta3-0FF'], 0], -['6ab', '-t -a -3', [\'FFn'], [\'ta3-FF'], 0], -['6ac', '-t -a -3 -l 24', [\'FnFn'], [\'ta3-FF'], 0], -['6ba', '-t -b -3', [\'0FnFnt'], [\'tb3-0FF'], 0], -['6bb', '-t -b -3', [\'FFn'], [\'tb3-FF'], 0], -['6bc', '-t -b -3 -l 24', [\'FnFn'], [\'tb3-FF'], 0], -# -# Do not print header and footer nor "FF set by Hand" (-T option) -['7a', '-T -l 24', [\'tn'], [\'tt-t'], 0], -['7b', '-T -l 24 -f', [\'tn'], [\'tt-t'], 0], -['7c', '-T -l 24 -f', [\'tFFt-bl'], [\'tt-bl'], 0], -['7d', '-T -l 24', [\'0FnFnt'], [\'tt-0FF'], 0], -['7e', '-T -l 24', [\'FFn'], [\'tt-FF'], 0], -['7f', '-T -l 24', [\'FnFn'], [\'tt-FF'], 0], -['7g', '-T -l 24 -f', [\'FFn'], [\'tt-FF'], 0], -['7aa', '-T -a -3', [\'0FnFnt'], [\'tta3-0FF'], 0], -['7ab', '-T -a -3', [\'FFn'], [\'tta3-FF'], 0], -['7ac', '-T -a -3 -l 24', [\'FnFn'], [\'tta3-FF'], 0], -['7ba', '-T -b -3', [\'0FnFnt'], [\'ttb3-0FF'], 0], -['7bb', '-T -b -3', [\'FFn'], [\'ttb3-FF'], 0], -['7bc', '-T -b -3 -l 24', [\'FnFn'], [\'ttb3-FF'], 0], -# -# lhs-truncation of header -# pr-1.19m: Text line truncation only with column output -# -# numbering lines (-n -N option) -# skip pages (+FIRST_PAGE[:LAST_PAGE] option) -['9a', '-n.3 -l 24 -f', [\'tFFt-bl'], [\'nl24f-bl'], 0], -['9b', '-n.3 -N 15 -l 24 -f', [\'tFFt-bl'], [\'nN15l24f-bl'], 0], -['9Pa', '-n.3 +2 -l 24 -f', [\'tFFt-bl'], [\'n+2l24f-bl'], 0], -['9Pb', '-n.3 +3 -l 24 -f', [\'tFFt-bl'], [\'n+3l24f-bl'], 0], -['9Pc', '-n.3 -N 1 +3 -l 24 -f', [\'tFFt-bl'], [\'nN1+3l24f-bl'], 0], -['9Pe', '-n.3 +2 -l 24 -f', [\'0FFt'], [\'n+2l24f-0FF'], 0], -['9Pf', '-n.3 +2 -l 24 -f', [\'0FFnt'], [\'n+2l24f-0FF'], 0], -['9Pg', '-n.3 +2 -l 24 -f', [\'0FnFt'], [\'n+2l24f-0FF'], 0], -['9Ph', '-n.3 +2 -l 24 -f', [\'0FnFnt'], [\'n+2l24f-0FF'], 0], -['9Pi', '-n.3 +2:5 -l 24 -f', [\'0FFt'], [\'n+2-5l24f-0FF'], 0], -['9Pj', '-n.3 +3 -l 24 -f', [\'0FFt'], [\'n+3l24f-0FF'], 0], -['9Pk', '-n.3 +3 -l 24 -f', [\'0FFnt'], [\'n+3l24f-0FF'], 0], -['9Pl', '-n.3 +3 -l 24 -f', [\'0FnFt'], [\'n+3l24f-0FF'], 0], -['9Pm', '-n.3 +3 -l 24 -f', [\'0FnFnt'], [\'n+3l24f-0FF'], 0], -['9Pn', '-n.3 +7 -l 24', [\'FFn'], [\'n+7l24-FF'], 0], -['9Po', '-n.3 +7 -l 24', [\'FFtn'], [\'n+7l24-FF'], 0], -['9Pp', '-n.3 +7 -l 24', [\'FnFn'], [\'n+7l24-FF'], 0], -['9Pq', '-n.3 +3:7 -l 24', [\'FnFn'], [\'n+3-7l24-FF'], 0], -['9Pr', '-n.3 +8 -l 20', [\'tFFn'], [\'n+8l20-FF'], 0], -['9Ps', '-n.3 +8 -l 20', [\'tFnFt'], [\'n+8l20-FF'], 0], -['9Pt', '-n.3 +8 -l 20', [\'tFFt'], [\'n+8l20-FF'], 0], -['9Paa', '-n.3 +5 -a -3 -l 13 -f', [\'0FFt'], [\'n+5a3l13f-0FF'], 0], -['9Pab', '-n.3 +5 -a -3 -l 13 -f', [\'0FFnt'], [\'n+5a3l13f-0FF'], 0], -['9Pac', '-n.3 +5 -a -3 -l 13 -f', [\'0FnFt'], [\'n+5a3l13f-0FF'], 0], -['9Pad', '-n.3 +5 -a -3 -l 13 -f', [\'0FnFnt'], [\'n+5a3l13f-0FF'], 0], -['9Pae', '-n.3 +6 -a -2 -l 17', [\'FFn'], [\'n+6a2l17-FF'], 0], -['9Paf', '-n.3 +6 -a -2 -l 17', [\'FFtn'], [\'n+6a2l17-FF'], 0], -['9Pag', '-n.3 +6 -a -2 -l 17', [\'FnFn'], [\'n+6a2l17-FF'], 0], -['9Pah', '-n.3 +6 -a -2 -l 17', [\'tFFn'], [\'n+6a2l17-FF'], 0], -['9Pai', '-n.3 +6 -a -2 -l 17', [\'tFnFt'], [\'n+6a2l17-FF'], 0], -['9Paj', '-n.3 +6 -a -2 -l 17', [\'tFFt'], [\'n+6a2l17-FF'], 0], -['9Pak', '-n.3 +4:8 -a -2 -l 17', [\'tFFt'], [\'n+4-8a2l17-FF'], 0], -['9Pba', '-n.3 +4 -b -2 -l 17 -f', [\'0FFt'], [\'n+4b2l17f-0FF'], 0], -['9Pbb', '-n.3 +4 -b -2 -l 17 -f', [\'0FFnt'], [\'n+4b2l17f-0FF'], 0], -['9Pbc', '-n.3 +4 -b -2 -l 17 -f', [\'0FnFt'], [\'n+4b2l17f-0FF'], 0], -['9Pbd', '-n.3 +4 -b -2 -l 17 -f', [\'0FnFnt'], [\'n+4b2l17f-0FF'], 0], -['9Pbe', '-n.3 +6 -b -3 -l 13 -f', [\'FFn'], [\'n+6b3l13f-FF'], 0], -['9Pbf', '-n.3 +6 -b -3 -l 13 -f', [\'FFtn'], [\'n+6b3l13f-FF'], 0], -['9Pbg', '-n.3 +6 -b -3 -l 13 -f', [\'FnFn'], [\'n+6b3l13f-FF'], 0], -['9Pbh', '-n.3 +6 -b -3 -l 13 -f', [\'tFFn'], [\'n+6b3l13f-FF'], 0], -['9Pbi', '-n.3 +6 -b -3 -l 13 -f', [\'tFnFt'], [\'n+6b3l13f-FF'], 0], -['9Pbj', '-n.3 +6 -b -3 -l 13 -f', [\'tFFt'], [\'n+6b3l13f-FF'], 0], -['9Pbk', '-n.3 +5:8 -b -3 -l 17 -f', [\'FnFn'], [\'n+5-8b3l17f-FF'], 0], -['9Pma', '-n.3 +3 -m -l 20 -f', [\'tFFt-bl', \'FnFn'], [\'n+3ml20f-bl-FF'], 0], -['9Pmb', '-n.3 +3 -m -l 24 -f', [\'tFFt-bl', \'tn'], [\'n+3ml24f-bl-tn'], 0], -['9Pmc', '-n.3 +3 -m -l 24 -f', [\'tn', \'tFFt-bl'], [\'n+3ml24f-tn-bl'], 0], -# -# line truncation column alignment; header line truncation -# -w/W PAGE_WIDTH [-J] options -['10wa', '-W 72 -J -l24 -f', [\'tFFt-ll'], [\'W72Jl24f-ll'], 0], -['10wb', '-w 72 -J -l24 -f', [\'tFFt-ll'], [\'W72Jl24f-ll'], 0], -['10wc', '-W 72 -l24 -f', [\'tFFt-ll'], [\'W-72l24f-ll'], 0], -['10wd', '-w 72 -l24 -f', [\'tFFt-ll'], [\'w72l24f-ll'], 0], -['10we', '-W 28 -l24 -f', [\'tFFt-ll'], [\'W28l24f-ll'], 0], -['10wf', '-W 27 -l24 -f', [\'tFFt-ll'], [\'W27l24f-ll'], 0], -['10wg', '-W 26 -l24 -f', [\'tFFt-ll'], [\'W26l24f-ll'], 0], -['10wh', '-W 20 -l24 -f', [\'tFFt-ll'], [\'W20l24f-ll'], 0], -['10ma', '-m -l 24 -f', [\'tFFt-lm', \'loli'], [\'ml24f-lm-lo'], 0], -['10mb', '-W 35 -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35ml24f-lm-lo'], 0], -['10mc', '-w 35 -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35ml24f-lm-lo'], 0], -['10md', '-J -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'Jml24f-lm-lo'], 0], -['10me', '-W 35 -J -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35Jml24f-lmlo'], 0], -['10mf', '-w 35 -J -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35Jml24f-lmlo'], 0], -['10mg', '-n.3 -J -m -l 24 -f', [\'tFFt-lm', \'tFFt-lm', \'loli'], - [\'nJml24f-lmlmlo'], 0], -['10mh', '-n.3 -J -m -l 24 -f', [\'tFFt-lm', \'loli', \'tFFt-lm'], - [\'nJml24f-lmlolm'], 0], -['10aa', '-a -3 -l 24 -f', [\'tFFt-lm'], [\'a3l24f-lm'], 0], -['10ab', '-W 35 -a -3 -l 24 -f', [\'tFFt-lm'], [\'W35a3l24f-lm'], 0], -['10ac', '-J -a -3 -l 24 -f', [\'tFFt-lm'], [\'Ja3l24f-lm'], 0], -['10ad', '-W 35 -J -a -3 -l 24 -f', [\'tFFt-lm'], [\'W35Ja3l24f-lm'], 0], -['10ba', '-b -3 -l 24 -f', [\'tFFt-lm'], [\'b3l24f-lm'], 0], -['10bb', '-W 35 -b -3 -l 24 -f', [\'tFFt-lm'], [\'W35b3l24f-lm'], 0], -['10bc', '-J -b -3 -l 24 -f', [\'tFFt-lm'], [\'Jb3l24f-lm'], 0], -['10bd', '-W 35 -J -b -3 -l 24 -f', [\'tFFt-lm'], [\'W35Jb3l24f-lm'], 0], -# -# merge files (-m option) use separator string (-S option) -['11sa', '-n.3 -S:--: -m -l 20 -f', [\'tFFt-bl', \'FnFn'], - [\'nSml20-bl-FF'], 0], -['11sb', '-n.3 -S:--: -m -l 24 -f', [\'tFFt-bl', \'FnFn'], - [\'nSml24-bl-FF'], 0], -['11se', '-n.3 -S:--: -m -l 20 -f', [\'tn', \'tn', \'FnFn'], - [\'nSml20-t-t-FF'], 0], -['11sf', '-n.3 -S:--: -m -l 24 -f', [\'tn', \'tn', \'FnFn'], - [\'nSml24-t-t-FF'], 0], -['11sg', '-n.3 -S:--: -m -l 20 -f', [\'tn', \'tn', \'FnFn', \'FnFn'], - [\'nSml20-t-tFFFF'], 0], -['11sh', '-n.3 -S:--: -m -l 24 -f', [\'tn', \'tn', \'FnFn', \'FnFn'], - [\'nSml24-t-tFFFF'], 0], -# -# left margin (-o option) and separator string (-S option) -['12aa', '-o3 -a -3 -l24 -f', [\'tn'], [\'o3a3l24f-tn'], 0], -['12ab', '-o3 -a -3 -S:--: -l24 -f', [\'tn'], [\'o3a3Sl24f-tn'], 0], -['12ac', '-o3 -a -3 -S:--: -n. -l24 -f', [\'tn'], [\'o3a3Snl24f-tn'], 0], -['12ba', '-o3 -b -3 -l24 -f', [\'tn'], [\'o3b3l24f-tn'], 0], -['12bb', '-o3 -b -3 -S:--: -l24 -f', [\'tn'], [\'o3b3Sl24f-tn'], 0], -['12bc', '-o3 -b -3 -S:--: -n. -l24 -f', [\'tn'], [\'o3b3Snl24f-tn'], 0], -['12ma', '-o3 -m -l24 -f', [\'tFFt-bl', \'tn'], [\'o3ml24f-bl-tn'], 0], -['12mb', '-o3 -m -S:--: -l24 -f', [\'tFFt-bl', \'tn'], [\'o3mSl24f-bl-tn'], 0], -['12mc', '-o3 -m -S:--: -n. -l24 -f', [\'tFFt-bl', \'tn'], - [\'o3mSnl24fbltn'], 0], -['12md', '-o3 -J -m -l24 -f', [\'tFFt-lm', \'loli'], [\'o3Jml24f-lm-lo'], 0], -# -# -# Single column output: POSIX compliant, adapt other UNIXes (SunOS.5.5.1 e.g.) -# number-separator TAB always an output TAB --> varying number/text-spacing -['13a', '-t -n -e8', [\'t_tab'], [\'tne8-t_tab'], 0], -['13b', '-t -n -e8 -o3', [\'t_tab'], [\'tne8o3-t_tab'], 0], -# -# POSIX compliant: multi-columns of equal width (unlike SunOS.5.5.1 e.g.) -# text-tab handling -['13ba', '-t -n -2 -e8', [\'t_tab'], [\'tn2e8-t_tab'], 0], -['13bb', '-t -n: -2 -e8', [\'t_tab'], [\'tn_2e8-t_tab'], 0], -['13bc', '-t -n: -2 -e8 -S----', [\'t_tab'], [\'tn_2e8S-t_tab'], 0], -['13bd', '-t -n -2 -e8 -o3', [\'t_tab'], [\'tn2e8o3-t_tab'], 0], -# number-separator TAB not treated as input text-tab, no '-e' expansion -['13be', '-t -n -2 -e5 -o3', [\'t_tab'], [\'tn2e5o3-t_tab'], 0], -# input-tab-char ':' not equal default (text) TABs -['13bf', '-t -n -2 -e:8', [\'t_tab_'], [\'tn2e8-t_tab'], 0], -# -# options -w/-s: POSIX-compliant, means adapting the interference of -w/-s -# with multi-column output from other UNIXes (SunOS e.g.); -# columns, truncated = 72 / separator = space : -['14a', '-2 -f', [\'t_notab'], [\'2f-t_notab'], 0], -# full lines, no truncation / separator = TAB : -['14b', '-2 -s -f', [\'t_notab'], [\'2sf-t_notab'], 0], -# full lines, no truncation / separator = ':' : -['14c', '-2 -s: -f', [\'t_notab'], [\'2s_f-t_notab'], 0], -# columns, truncated = 60 / separator = space : -['14d', '-2 -w60 -f', [\'t_notab'], [\'2w60f-t_notab'], 0], -# columns, truncated = 60 / no separator (SunOS-BUG: line width to small): -['14e', '-2 -s -w60 -f', [\'t_notab'], [\'2sw60f-t_notab'], 0], -# columns, truncated = 60 / separator = ':' (HP-UX.10.20-2-BUG: -# ':' missing with -m option): -['14f', '-2 -s: -w60 -f', [\'t_notab'], [\'2s_w60f-t_nota'], 0], -# -# new long-options -W/-S/-J disentangle those options (see also No.'10*') -# columns, truncated = 72 / no separator : -['14g', '-2 -S -f', [\'t_notab'], [\'2-Sf-t_notab'], 0], -# full lines, no truncation / separator = TAB : (Input: -S"") -['14h', '-2 -S" " -J -f', [\'t_notab'], [\'2sf-t_notab'], 0], -# columns, truncated = 72 / separator ':' : -['14i', '-2 -S: -f', [\'t_notab'], [\'2-S_f-t_notab'], 0], -# full lines, no truncation / separator = ':' : -['14j', '-2 -S: -J -f', [\'t_notab'], [\'2s_f-t_notab'], 0], -# columns, truncated = 60 / separator = space: -['14k', '-2 -W60 -f', [\'t_notab'], [\'2w60f-t_notab'], 0], -# columns, truncated = 60 / no separator : -['14l', '-2 -S -W60 -f', [\'t_notab'], [\'2sw60f-t_notab'], 0], -# columns, truncated = 60 / separator = ':' : -['14m', '-2 -S: -W60 -f', [\'t_notab'], [\'2s_w60f-t_nota'], 0], -# -# Tabify multiple spaces, -i option -# number of input spaces between a and b must not change; be careful -# comparing with other UNIXes (some other SunOS examples are OK !?) -# SunOS.5.5.1-BUG: 8 input spaces --> 11 output spaces between a and b; -['i-opt-a', '-tn -i5 -h ""', "a b\n", " 1 a b\n", 0], -# SunOS.5.5.1-BUG: 8 input spaces --> 9 output spaces between a and b; -['i-opt-b', '-tn -i5 -o9 -h ""', "a b\n", - " 1 a b\n", 0], -# -# line number overflow not allowed: cut off leading digits; -# don't adapt other UNIXes, no real standard to follow, a consequent -# programming of column handling may change the GNU pr concept. -['ncut-a', '-tn2 -N98', "y\ny\ny\ny\ny\n", - "98 y\n99 y\n00 y\n01 y\n02 y\n", 0], -['ncut-b', '-tn:2 -N98', "y\ny\ny\ny\ny\n", - "98:y\n99:y\n00:y\n01:y\n02:y\n", 0], - -['margin-0', '-o 0', '', '', 0], - -# BUG fixed: that leading space on 3rd line of output should not be there -['dbl-sp-a', '-d -l 14 -h ""', "1\n2\n", - "\n\n-- Date/Time -- " - . "Page 1\n\n\n1\n\n2\n\n\n\n\n\n\n", 0], -# This test failed with 1.22e and earlier. -['dbl-sp-b', '-d -t', "1\n2\n", "1\n\n2\n\n", 0], - -# This test would segfault with 2.0f and earlier. -['narrow-1', '-W1 -t', "12345\n", "1\n", 0], - -# This test would fail with textutils-2.1 and earlier. -['col-last', '-W3 -t2', "a\nb\nc\n", "a c\nb\n", 0], - -# Make sure that -02 is treated just like -2. -['col-02', '-W3 -t -02', "a\nb\nc\n", "a c\nb\n", 0], -# The -2 must override preceding column-count-specifying options. -['col-2', '-W3 -t -4 --columns=1 -2', "a\nb\nc\n", "a c\nb\n", 0], -# The --columns=2 must override preceding column-count-specifying options. -['col-long', '-W3 -t -1 --columns=2', "a\nb\nc\n", "a c\nb\n", 0], -# Make sure these fail. -['col-0', '-0', '', '', 1, - "$prog: invalid number of columns: '0'\n"], -['col-inval', '-'.'9'x100, '', '', 1, - "$prog: invalid number of columns: '". ('9'x100) ."'\n"], - -# Before coreutils-5.3.1, --pages=1:-1 would be treated like -# --pages=1:18446744073709551615. -['neg-page', '--pages=1:-1', '', '', 1, - "$prog: invalid --pages argument '1:-1'\n"], - -# Up to coreutils-6.10, this would cause pr to decrement its -# internal "input_position" below zero and sometimes segfault. -['neg-inp-pos1', '-t -e', "\b\b\b\b\b\b\tx\n", " x\n", 0], -# NB: while there are 4 backspaces in the input, there are only 3 in the output -['neg-inp-pos2', '-t -e', "abc\b\b\b\b\tx", "abc\b\b\b x\n", 0], - -# This would clobber so much of the heap, it'd segfault or abort every time. -['smash-heap', '-t -e300', "a".("\b"x50)."\t", "a\b".(" "x300)."\n", 0], -['smash-heap8', '-t -e', "a".("\b"x50)."\t", "a\b".(" "x 8)."\n", 0], - -# Before coreutils-8.13 page numbers were not handled correctly when -# headers were not printed (when -l <= 10 or -t or -T specified) -['page-range', '+1:1 -2 -l1 -s" "', "a\nb\nc\n", "a b\n", 0], -); - -# Convert the above old-style test vectors to the newer -# format used by Coreutils.pm. - -my $pfx = "$ENV{abs_srcdir}/pr"; - -# Normalize otherwise-variable output page headers. -my $common_option_prefix = '--date-format="-- Date/Time --" -h x'; - -my @Tests; -foreach my $t (@tv) - { - my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t; - my $new_ent = [$test_name, $common_option_prefix, $flags]; - if (!ref $in) - { - push @$new_ent, {IN=>$in}; - } - else - { - foreach my $e (@$in) - { - my $file_name = $$e; - push @$new_ent, {IN=>{"$pfx/$file_name"=>undef}}; - } - } - if (!ref $exp) - { - push @$new_ent, {OUT=>$exp}; - } - else - { - foreach my $e (@$exp) - { - my $file_name = $$e; - push @$new_ent, {OUT=>{"$pfx/$file_name"=>undef}}; - } - } - $ret - and push @$new_ent, {EXIT=>$ret}, {ERR=>$err_msg}; - push @Tests, $new_ent; - } - -@Tests = triple_test \@Tests; - -my $save_temps = $ENV{DEBUG}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/pr/pr-tests.pl b/tests/pr/pr-tests.pl new file mode 100755 index 000000000..259c9d6c2 --- /dev/null +++ b/tests/pr/pr-tests.pl @@ -0,0 +1,460 @@ +#!/usr/bin/perl +# Test pr. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = 'pr'; + +my @tv = ( + +# -b option is no longer an official option. But it's still working to +# get a downward compatibility. Now (version 1.19m or newer) -COLUMN +# only is equivalent to -b -COLUMN. +# +# test_name options input-file-name(s) expected-output-group-file-name +# expected-return-code +# ------------------------------------------------------------------------- +# Following tests with "FF set" don't contain a complete set of all +# combinations of options and FF-arrangements +# +# One FF at start of file (one empty page) +# ['1a', '', [\'0Ft'], [\'0F'], 0], +['1b', '', [\'0Fnt'], [\'0F'], 0], +['1c', '+3', [\'0Ft'], [\'3-0F'], 0], +['1d', '+3 -f', [\'0Ft'], [\'3f-0F'], 0], +['1e', '-a -3', [\'0Ft'], [\'a3-0F'], 0], +['1f', '-a -3 -f', [\'0Ft'], [\'a3f-0F'], 0], +['1g', '-a -3 -f', [\'0Fnt'], [\'a3f-0F'], 0], +['1h', '+3 -a -3 -f', [\'0Ft'], [\'3a3f-0F'], 0], +['1i', '-b -3', [\'0Ft'], [\'b3-0F'], 0], +['1j', '-b -3 -f', [\'0Ft'], [\'b3f-0F'], 0], +['1k', '-b -3 -f', [\'0Fnt'], [\'b3f-0F'], 0], +['1l', '+3 -b -3 -f', [\'0Ft'], [\'3b3f-0F'], 0], +# Two FF at start of file (two empty page) +['2a', '', [\'0FFt'], [\'0FF'], 0], +['2b', '', [\'0FnFnt'], [\'0FF'], 0], +['2c', '-a -3 -f', [\'0FFt'], [\'a3f-0FF'], 0], +['2d', '-a -3 -f', [\'0FFnt'], [\'a3f-0FF'], 0], +['2e', '-b -3 -f', [\'0FFt'], [\'b3f-0FF'], 0], +['2f', '-b -3 -f', [\'0FFnt'], [\'b3f-0FF'], 0], +['2g', '-b -3 -f', [\'0FnFt'], [\'b3f-0FF'], 0], +['2h', '-b -3 -f', [\'0FnFnt'], [\'b3f-0FF'], 0], +['2i', '+3 -b -3 -f', [\'0FFt'], [\'3b3f-0FF'], 0], +['2j', '+3 -b -3 -f', [\'0FFnt'], [\'3b3f-0FF'], 0], +# +# FFs in text (none / one / two empty page(s)) +['3a', '', [\'FFn'], [\'FF'], 0], +['3b', '', [\'FnFn'], [\'FF'], 0], +['3c', '+3', [\'FFn'], [\'3-FF'], 0], +['3d', '+3 -f', [\'FFn'], [\'3f-FF'], 0], +['3e', '-a -3 -f', [\'FFn'], [\'a3f-FF'], 0], +['3f', '-a -3 -f', [\'FFtn'], [\'a3f-FF'], 0], +['3g', '-b -3 -f', [\'FFn'], [\'b3f-FF'], 0], +['3h', '-b -3 -f', [\'FFtn'], [\'b3f-FF'], 0], +['3i', '-b -3 -f', [\'FnFn'], [\'b3f-FF'], 0], +['3j', '-b -3 -f', [\'tFFn'], [\'b3f-FF'], 0], +['3k', '-b -3 -f', [\'tFnFt'], [\'b3f-FF'], 0], +['3l', '+3 -b -3 -f', [\'FFn'], [\'3b3f-FF'], 0], +['3m', '+3 -b -3 -f', [\'FFtn'], [\'3b3f-FF'], 0], +# A full page printed (lines_left_on_page = 0) without a FF found. +# Avoid an extra empty page if a FF follows in the next input line. +['3la', '-l 24', [\'FFn'], [\'l24-FF'], 0], +['3lb', '-l 24', [\'FFtn'], [\'l24-FF'], 0], +['3lc', '-l 24', [\'FnFn'], [\'l24-FF'], 0], +['3ld', '-l 24', [\'tFFn'], [\'l24-FF'], 0], +['3le', '-l 24', [\'tFnFt'], [\'l24-FF'], 0], +['3lf', '-l 24', [\'tFFt'], [\'l24-FF'], 0], +['3aa', '-a -2 -l 17', [\'FFn'], [\'a2l17-FF'], 0], +['3ab', '-a -2 -l 17', [\'FFtn'], [\'a2l17-FF'], 0], +['3ac', '-a -2 -l 17', [\'FnFn'], [\'a2l17-FF'], 0], +['3ad', '-a -2 -l 17', [\'tFFn'], [\'a2l17-FF'], 0], +['3ae', '-a -2 -l 17', [\'tFnFt'], [\'a2l17-FF'], 0], +['3af', '-a -2 -l 17', [\'tFFt'], [\'a2l17-FF'], 0], +['3ag', '-a -2 -l 15', [\'FFn'], [\'a2l15-FF'], 0], +['3ah', '-a -2 -l 15', [\'FFtn'], [\'a2l15-FF'], 0], +['3ai', '-a -2 -l 15', [\'FnFn'], [\'a2l15-FF'], 0], +['3aj', '-a -2 -l 15', [\'tFFn'], [\'a2l15-FF'], 0], +['3ak', '-a -2 -l 15', [\'tFnFt'], [\'a2l15-FF'], 0], +['3ba', '-b -2 -l 17', [\'FFn'], [\'b2l17-FF'], 0], +['3bb', '-b -2 -l 17', [\'FFtn'], [\'b2l17-FF'], 0], +['3bc', '-b -2 -l 17', [\'FnFn'], [\'b2l17-FF'], 0], +['3bd', '-b -2 -l 17', [\'tFFn'], [\'b2l17-FF'], 0], +['3be', '-b -2 -l 17', [\'tFnFt'], [\'b2l17-FF'], 0], +['3bf', '-b -2 -l 17', [\'tFFt'], [\'b2l17-FF'], 0], +['3bg', '-b -2 -l 15', [\'FFn'], [\'b2l15-FF'], 0], +['3bh', '-b -2 -l 15', [\'FFtn'], [\'b2l15-FF'], 0], +['3bi', '-b -2 -l 15', [\'FnFn'], [\'b2l15-FF'], 0], +['3bj', '-b -2 -l 15', [\'tFFn'], [\'b2l15-FF'], 0], +['3bk', '-b -2 -l 15', [\'tFnFt'], [\'b2l15-FF'], 0], +['3Pa', '+4 -l 24', [\'FFn'], [\'4l24-FF'], 0], +['3Pb', '+4 -l 24', [\'FFtn'], [\'4l24-FF'], 0], +['3Pc', '+4 -l 24', [\'FnFn'], [\'4l24-FF'], 0], +['3Pd', '+4 -l 24', [\'tFFn'], [\'4l24-FF'], 0], +['3Pe', '+4 -l 24', [\'tFnFt'], [\'4l24-FF'], 0], +['3Pf', '+4 -l 24', [\'tFFt'], [\'4l24-FF'], 0], +['3Pg', '+4:7 -l 24', [\'tFFt'], [\'4-7l24-FF'], 0], +['3Paa', '+3 -a -2 -l 17', [\'FFn'], [\'3a2l17-FF'], 0], +['3Pab', '+3 -a -2 -l 17', [\'FFtn'], [\'3a2l17-FF'], 0], +['3Pac', '+3 -a -2 -l 17', [\'FnFn'], [\'3a2l17-FF'], 0], +['3Pad', '+3 -a -2 -l 17', [\'tFFn'], [\'3a2l17-FF'], 0], +['3Pae', '+3 -a -2 -l 17', [\'tFnFt'], [\'3a2l17-FF'], 0], +['3Paf', '+3 -a -2 -l 17', [\'tFFt'], [\'3a2l17-FF'], 0], +['3Pba', '+3 -b -2 -l 17', [\'FFn'], [\'3b2l17-FF'], 0], +['3Pbb', '+3 -b -2 -l 17', [\'FFtn'], [\'3b2l17-FF'], 0], +['3Pbc', '+3 -b -2 -l 17', [\'FnFn'], [\'3b2l17-FF'], 0], +['3Pbd', '+3 -b -2 -l 17', [\'tFFn'], [\'3b2l17-FF'], 0], +['3Pbe', '+3 -b -2 -l 17', [\'tFnFt'], [\'3b2l17-FF'], 0], +['3Pbf', '+3 -b -2 -l 17', [\'tFFt'], [\'3b2l17-FF'], 0], +# +# Without "FF set by hand" +['4a', '-l 24', [\'tn'], [\'l24-t'], 0], +['4b', '-l 24 -f', [\'tn'], [\'l24f-t'], 0], +['4c', '+3 -l 24', [\'tn'], [\'3l24-t'], 0], +['4d', '+3 -l 24 -f', [\'tn'], [\'3l24f-t'], 0], +['4e', '+3:5 -l 24 -f', [\'tn'], [\'3-5l24f-t'], 0], +['4f', '-a -3 -l 15', [\'tn'], [\'a3l15-t'], 0], +['4g', '-a -3 -l 15 -f', [\'tn'], [\'a3l15f-t'], 0], +['4h', '+3 -a -3 -l 15', [\'tn'], [\'3a3l15-t'], 0], +['4i', '+3 -a -3 -l 15 -f', [\'tn'], [\'3a3l15f-t'], 0], +['4j', '-b -3 -l 15', [\'tn'], [\'b3l15-t'], 0], +['4k', '-b -3 -l 15 -f', [\'tn'], [\'b3l15f-t'], 0], +['4l', '+3 -b -3 -l 15', [\'tn'], [\'3b3l15-t'], 0], +['4m', '+3 -b -3 -l 15 -f', [\'tn'], [\'3b3l15f-t'], 0], +# +# Merge input files (-m option) +['5a', '-m -l 24', [\'tn', \'tn'], [\'ml24-t'], 0], +['5b', '-m -l 24 -f', [\'tn', \'tn'], [\'ml24f-t'], 0], +['5c', '+3 -m -l 24', [\'tn', \'tn'], [\'3ml24-t'], 0], +['5d', '+3 -m -l 24 -f', [\'tn', \'tn'], [\'3ml24f-t'], 0], +['5e', '-m -l 24 -f', [\'0Ft', \'0Ft'], [\'ml24f-0F'], 0], +['5f', '-m -l 24 -f', [\'0Ft', \'0Fnt'], [\'ml24f-0F'], 0], +['5g', '-m -l 24 -f', [\'tn', \'0Ft'], [\'ml24f-t-0F'], 0], +# A full page printed (lines_left_on_page = 0) without a FF found. +# Avoid an extra empty page if a FF follows in the next input line. +['5ma', '-m -l 24', [\'tFFn', \'tFnFt'], [\'ml24-FF'], 0], +['5mb', '-m -l 24', [\'tFFn', \'FFn'], [\'ml24-FF'], 0], +['5mc', '-m -l 24', [\'tn', \'FFn'], [\'ml24-t-FF'], 0], +['5md', '-m -l 20', [\'FFn', \'tn'], [\'ml20-FF-t'], 0], +['5Pma', '+3 -m -l 24', [\'FFn', \'FnFn'], [\'3ml24-FF'], 0], +['5Pmb', '+3 -m -l 24', [\'tFFn', \'FFn'], [\'3ml24-FF'], 0], +['5Pmc', '+3 -m -l 24', [\'tn', \'FFn'], [\'3ml24-t-FF'], 0], +# +# Do not print header and footer but retain "FF set by Hand" +# (-t option) +['6a', '-t -l 24', [\'tn'], [\'t-t'], 0], +['6b', '-t -l 24 -f', [\'tn'], [\'t-t'], 0], +['6c', '-t -l 24 -f', [\'tFFt-bl'], [\'t-bl'], 0], +['6d', '-t -l 24', [\'0FnFnt'], [\'t-0FF'], 0], +['6e', '-t -l 24', [\'FFn'], [\'t-FF'], 0], +['6f', '-t -l 24', [\'FnFn'], [\'t-FF'], 0], +['6g', '-t -l 24 -f', [\'FFn'], [\'t-FF'], 0], +['6aa', '-t -a -3', [\'0FnFnt'], [\'ta3-0FF'], 0], +['6ab', '-t -a -3', [\'FFn'], [\'ta3-FF'], 0], +['6ac', '-t -a -3 -l 24', [\'FnFn'], [\'ta3-FF'], 0], +['6ba', '-t -b -3', [\'0FnFnt'], [\'tb3-0FF'], 0], +['6bb', '-t -b -3', [\'FFn'], [\'tb3-FF'], 0], +['6bc', '-t -b -3 -l 24', [\'FnFn'], [\'tb3-FF'], 0], +# +# Do not print header and footer nor "FF set by Hand" (-T option) +['7a', '-T -l 24', [\'tn'], [\'tt-t'], 0], +['7b', '-T -l 24 -f', [\'tn'], [\'tt-t'], 0], +['7c', '-T -l 24 -f', [\'tFFt-bl'], [\'tt-bl'], 0], +['7d', '-T -l 24', [\'0FnFnt'], [\'tt-0FF'], 0], +['7e', '-T -l 24', [\'FFn'], [\'tt-FF'], 0], +['7f', '-T -l 24', [\'FnFn'], [\'tt-FF'], 0], +['7g', '-T -l 24 -f', [\'FFn'], [\'tt-FF'], 0], +['7aa', '-T -a -3', [\'0FnFnt'], [\'tta3-0FF'], 0], +['7ab', '-T -a -3', [\'FFn'], [\'tta3-FF'], 0], +['7ac', '-T -a -3 -l 24', [\'FnFn'], [\'tta3-FF'], 0], +['7ba', '-T -b -3', [\'0FnFnt'], [\'ttb3-0FF'], 0], +['7bb', '-T -b -3', [\'FFn'], [\'ttb3-FF'], 0], +['7bc', '-T -b -3 -l 24', [\'FnFn'], [\'ttb3-FF'], 0], +# +# lhs-truncation of header +# pr-1.19m: Text line truncation only with column output +# +# numbering lines (-n -N option) +# skip pages (+FIRST_PAGE[:LAST_PAGE] option) +['9a', '-n.3 -l 24 -f', [\'tFFt-bl'], [\'nl24f-bl'], 0], +['9b', '-n.3 -N 15 -l 24 -f', [\'tFFt-bl'], [\'nN15l24f-bl'], 0], +['9Pa', '-n.3 +2 -l 24 -f', [\'tFFt-bl'], [\'n+2l24f-bl'], 0], +['9Pb', '-n.3 +3 -l 24 -f', [\'tFFt-bl'], [\'n+3l24f-bl'], 0], +['9Pc', '-n.3 -N 1 +3 -l 24 -f', [\'tFFt-bl'], [\'nN1+3l24f-bl'], 0], +['9Pe', '-n.3 +2 -l 24 -f', [\'0FFt'], [\'n+2l24f-0FF'], 0], +['9Pf', '-n.3 +2 -l 24 -f', [\'0FFnt'], [\'n+2l24f-0FF'], 0], +['9Pg', '-n.3 +2 -l 24 -f', [\'0FnFt'], [\'n+2l24f-0FF'], 0], +['9Ph', '-n.3 +2 -l 24 -f', [\'0FnFnt'], [\'n+2l24f-0FF'], 0], +['9Pi', '-n.3 +2:5 -l 24 -f', [\'0FFt'], [\'n+2-5l24f-0FF'], 0], +['9Pj', '-n.3 +3 -l 24 -f', [\'0FFt'], [\'n+3l24f-0FF'], 0], +['9Pk', '-n.3 +3 -l 24 -f', [\'0FFnt'], [\'n+3l24f-0FF'], 0], +['9Pl', '-n.3 +3 -l 24 -f', [\'0FnFt'], [\'n+3l24f-0FF'], 0], +['9Pm', '-n.3 +3 -l 24 -f', [\'0FnFnt'], [\'n+3l24f-0FF'], 0], +['9Pn', '-n.3 +7 -l 24', [\'FFn'], [\'n+7l24-FF'], 0], +['9Po', '-n.3 +7 -l 24', [\'FFtn'], [\'n+7l24-FF'], 0], +['9Pp', '-n.3 +7 -l 24', [\'FnFn'], [\'n+7l24-FF'], 0], +['9Pq', '-n.3 +3:7 -l 24', [\'FnFn'], [\'n+3-7l24-FF'], 0], +['9Pr', '-n.3 +8 -l 20', [\'tFFn'], [\'n+8l20-FF'], 0], +['9Ps', '-n.3 +8 -l 20', [\'tFnFt'], [\'n+8l20-FF'], 0], +['9Pt', '-n.3 +8 -l 20', [\'tFFt'], [\'n+8l20-FF'], 0], +['9Paa', '-n.3 +5 -a -3 -l 13 -f', [\'0FFt'], [\'n+5a3l13f-0FF'], 0], +['9Pab', '-n.3 +5 -a -3 -l 13 -f', [\'0FFnt'], [\'n+5a3l13f-0FF'], 0], +['9Pac', '-n.3 +5 -a -3 -l 13 -f', [\'0FnFt'], [\'n+5a3l13f-0FF'], 0], +['9Pad', '-n.3 +5 -a -3 -l 13 -f', [\'0FnFnt'], [\'n+5a3l13f-0FF'], 0], +['9Pae', '-n.3 +6 -a -2 -l 17', [\'FFn'], [\'n+6a2l17-FF'], 0], +['9Paf', '-n.3 +6 -a -2 -l 17', [\'FFtn'], [\'n+6a2l17-FF'], 0], +['9Pag', '-n.3 +6 -a -2 -l 17', [\'FnFn'], [\'n+6a2l17-FF'], 0], +['9Pah', '-n.3 +6 -a -2 -l 17', [\'tFFn'], [\'n+6a2l17-FF'], 0], +['9Pai', '-n.3 +6 -a -2 -l 17', [\'tFnFt'], [\'n+6a2l17-FF'], 0], +['9Paj', '-n.3 +6 -a -2 -l 17', [\'tFFt'], [\'n+6a2l17-FF'], 0], +['9Pak', '-n.3 +4:8 -a -2 -l 17', [\'tFFt'], [\'n+4-8a2l17-FF'], 0], +['9Pba', '-n.3 +4 -b -2 -l 17 -f', [\'0FFt'], [\'n+4b2l17f-0FF'], 0], +['9Pbb', '-n.3 +4 -b -2 -l 17 -f', [\'0FFnt'], [\'n+4b2l17f-0FF'], 0], +['9Pbc', '-n.3 +4 -b -2 -l 17 -f', [\'0FnFt'], [\'n+4b2l17f-0FF'], 0], +['9Pbd', '-n.3 +4 -b -2 -l 17 -f', [\'0FnFnt'], [\'n+4b2l17f-0FF'], 0], +['9Pbe', '-n.3 +6 -b -3 -l 13 -f', [\'FFn'], [\'n+6b3l13f-FF'], 0], +['9Pbf', '-n.3 +6 -b -3 -l 13 -f', [\'FFtn'], [\'n+6b3l13f-FF'], 0], +['9Pbg', '-n.3 +6 -b -3 -l 13 -f', [\'FnFn'], [\'n+6b3l13f-FF'], 0], +['9Pbh', '-n.3 +6 -b -3 -l 13 -f', [\'tFFn'], [\'n+6b3l13f-FF'], 0], +['9Pbi', '-n.3 +6 -b -3 -l 13 -f', [\'tFnFt'], [\'n+6b3l13f-FF'], 0], +['9Pbj', '-n.3 +6 -b -3 -l 13 -f', [\'tFFt'], [\'n+6b3l13f-FF'], 0], +['9Pbk', '-n.3 +5:8 -b -3 -l 17 -f', [\'FnFn'], [\'n+5-8b3l17f-FF'], 0], +['9Pma', '-n.3 +3 -m -l 20 -f', [\'tFFt-bl', \'FnFn'], [\'n+3ml20f-bl-FF'], 0], +['9Pmb', '-n.3 +3 -m -l 24 -f', [\'tFFt-bl', \'tn'], [\'n+3ml24f-bl-tn'], 0], +['9Pmc', '-n.3 +3 -m -l 24 -f', [\'tn', \'tFFt-bl'], [\'n+3ml24f-tn-bl'], 0], +# +# line truncation column alignment; header line truncation +# -w/W PAGE_WIDTH [-J] options +['10wa', '-W 72 -J -l24 -f', [\'tFFt-ll'], [\'W72Jl24f-ll'], 0], +['10wb', '-w 72 -J -l24 -f', [\'tFFt-ll'], [\'W72Jl24f-ll'], 0], +['10wc', '-W 72 -l24 -f', [\'tFFt-ll'], [\'W-72l24f-ll'], 0], +['10wd', '-w 72 -l24 -f', [\'tFFt-ll'], [\'w72l24f-ll'], 0], +['10we', '-W 28 -l24 -f', [\'tFFt-ll'], [\'W28l24f-ll'], 0], +['10wf', '-W 27 -l24 -f', [\'tFFt-ll'], [\'W27l24f-ll'], 0], +['10wg', '-W 26 -l24 -f', [\'tFFt-ll'], [\'W26l24f-ll'], 0], +['10wh', '-W 20 -l24 -f', [\'tFFt-ll'], [\'W20l24f-ll'], 0], +['10ma', '-m -l 24 -f', [\'tFFt-lm', \'loli'], [\'ml24f-lm-lo'], 0], +['10mb', '-W 35 -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35ml24f-lm-lo'], 0], +['10mc', '-w 35 -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35ml24f-lm-lo'], 0], +['10md', '-J -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'Jml24f-lm-lo'], 0], +['10me', '-W 35 -J -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35Jml24f-lmlo'], 0], +['10mf', '-w 35 -J -m -l 24 -f', [\'tFFt-lm', \'loli'], [\'W35Jml24f-lmlo'], 0], +['10mg', '-n.3 -J -m -l 24 -f', [\'tFFt-lm', \'tFFt-lm', \'loli'], + [\'nJml24f-lmlmlo'], 0], +['10mh', '-n.3 -J -m -l 24 -f', [\'tFFt-lm', \'loli', \'tFFt-lm'], + [\'nJml24f-lmlolm'], 0], +['10aa', '-a -3 -l 24 -f', [\'tFFt-lm'], [\'a3l24f-lm'], 0], +['10ab', '-W 35 -a -3 -l 24 -f', [\'tFFt-lm'], [\'W35a3l24f-lm'], 0], +['10ac', '-J -a -3 -l 24 -f', [\'tFFt-lm'], [\'Ja3l24f-lm'], 0], +['10ad', '-W 35 -J -a -3 -l 24 -f', [\'tFFt-lm'], [\'W35Ja3l24f-lm'], 0], +['10ba', '-b -3 -l 24 -f', [\'tFFt-lm'], [\'b3l24f-lm'], 0], +['10bb', '-W 35 -b -3 -l 24 -f', [\'tFFt-lm'], [\'W35b3l24f-lm'], 0], +['10bc', '-J -b -3 -l 24 -f', [\'tFFt-lm'], [\'Jb3l24f-lm'], 0], +['10bd', '-W 35 -J -b -3 -l 24 -f', [\'tFFt-lm'], [\'W35Jb3l24f-lm'], 0], +# +# merge files (-m option) use separator string (-S option) +['11sa', '-n.3 -S:--: -m -l 20 -f', [\'tFFt-bl', \'FnFn'], + [\'nSml20-bl-FF'], 0], +['11sb', '-n.3 -S:--: -m -l 24 -f', [\'tFFt-bl', \'FnFn'], + [\'nSml24-bl-FF'], 0], +['11se', '-n.3 -S:--: -m -l 20 -f', [\'tn', \'tn', \'FnFn'], + [\'nSml20-t-t-FF'], 0], +['11sf', '-n.3 -S:--: -m -l 24 -f', [\'tn', \'tn', \'FnFn'], + [\'nSml24-t-t-FF'], 0], +['11sg', '-n.3 -S:--: -m -l 20 -f', [\'tn', \'tn', \'FnFn', \'FnFn'], + [\'nSml20-t-tFFFF'], 0], +['11sh', '-n.3 -S:--: -m -l 24 -f', [\'tn', \'tn', \'FnFn', \'FnFn'], + [\'nSml24-t-tFFFF'], 0], +# +# left margin (-o option) and separator string (-S option) +['12aa', '-o3 -a -3 -l24 -f', [\'tn'], [\'o3a3l24f-tn'], 0], +['12ab', '-o3 -a -3 -S:--: -l24 -f', [\'tn'], [\'o3a3Sl24f-tn'], 0], +['12ac', '-o3 -a -3 -S:--: -n. -l24 -f', [\'tn'], [\'o3a3Snl24f-tn'], 0], +['12ba', '-o3 -b -3 -l24 -f', [\'tn'], [\'o3b3l24f-tn'], 0], +['12bb', '-o3 -b -3 -S:--: -l24 -f', [\'tn'], [\'o3b3Sl24f-tn'], 0], +['12bc', '-o3 -b -3 -S:--: -n. -l24 -f', [\'tn'], [\'o3b3Snl24f-tn'], 0], +['12ma', '-o3 -m -l24 -f', [\'tFFt-bl', \'tn'], [\'o3ml24f-bl-tn'], 0], +['12mb', '-o3 -m -S:--: -l24 -f', [\'tFFt-bl', \'tn'], [\'o3mSl24f-bl-tn'], 0], +['12mc', '-o3 -m -S:--: -n. -l24 -f', [\'tFFt-bl', \'tn'], + [\'o3mSnl24fbltn'], 0], +['12md', '-o3 -J -m -l24 -f', [\'tFFt-lm', \'loli'], [\'o3Jml24f-lm-lo'], 0], +# +# +# Single column output: POSIX compliant, adapt other UNIXes (SunOS.5.5.1 e.g.) +# number-separator TAB always an output TAB --> varying number/text-spacing +['13a', '-t -n -e8', [\'t_tab'], [\'tne8-t_tab'], 0], +['13b', '-t -n -e8 -o3', [\'t_tab'], [\'tne8o3-t_tab'], 0], +# +# POSIX compliant: multi-columns of equal width (unlike SunOS.5.5.1 e.g.) +# text-tab handling +['13ba', '-t -n -2 -e8', [\'t_tab'], [\'tn2e8-t_tab'], 0], +['13bb', '-t -n: -2 -e8', [\'t_tab'], [\'tn_2e8-t_tab'], 0], +['13bc', '-t -n: -2 -e8 -S----', [\'t_tab'], [\'tn_2e8S-t_tab'], 0], +['13bd', '-t -n -2 -e8 -o3', [\'t_tab'], [\'tn2e8o3-t_tab'], 0], +# number-separator TAB not treated as input text-tab, no '-e' expansion +['13be', '-t -n -2 -e5 -o3', [\'t_tab'], [\'tn2e5o3-t_tab'], 0], +# input-tab-char ':' not equal default (text) TABs +['13bf', '-t -n -2 -e:8', [\'t_tab_'], [\'tn2e8-t_tab'], 0], +# +# options -w/-s: POSIX-compliant, means adapting the interference of -w/-s +# with multi-column output from other UNIXes (SunOS e.g.); +# columns, truncated = 72 / separator = space : +['14a', '-2 -f', [\'t_notab'], [\'2f-t_notab'], 0], +# full lines, no truncation / separator = TAB : +['14b', '-2 -s -f', [\'t_notab'], [\'2sf-t_notab'], 0], +# full lines, no truncation / separator = ':' : +['14c', '-2 -s: -f', [\'t_notab'], [\'2s_f-t_notab'], 0], +# columns, truncated = 60 / separator = space : +['14d', '-2 -w60 -f', [\'t_notab'], [\'2w60f-t_notab'], 0], +# columns, truncated = 60 / no separator (SunOS-BUG: line width to small): +['14e', '-2 -s -w60 -f', [\'t_notab'], [\'2sw60f-t_notab'], 0], +# columns, truncated = 60 / separator = ':' (HP-UX.10.20-2-BUG: +# ':' missing with -m option): +['14f', '-2 -s: -w60 -f', [\'t_notab'], [\'2s_w60f-t_nota'], 0], +# +# new long-options -W/-S/-J disentangle those options (see also No.'10*') +# columns, truncated = 72 / no separator : +['14g', '-2 -S -f', [\'t_notab'], [\'2-Sf-t_notab'], 0], +# full lines, no truncation / separator = TAB : (Input: -S"") +['14h', '-2 -S" " -J -f', [\'t_notab'], [\'2sf-t_notab'], 0], +# columns, truncated = 72 / separator ':' : +['14i', '-2 -S: -f', [\'t_notab'], [\'2-S_f-t_notab'], 0], +# full lines, no truncation / separator = ':' : +['14j', '-2 -S: -J -f', [\'t_notab'], [\'2s_f-t_notab'], 0], +# columns, truncated = 60 / separator = space: +['14k', '-2 -W60 -f', [\'t_notab'], [\'2w60f-t_notab'], 0], +# columns, truncated = 60 / no separator : +['14l', '-2 -S -W60 -f', [\'t_notab'], [\'2sw60f-t_notab'], 0], +# columns, truncated = 60 / separator = ':' : +['14m', '-2 -S: -W60 -f', [\'t_notab'], [\'2s_w60f-t_nota'], 0], +# +# Tabify multiple spaces, -i option +# number of input spaces between a and b must not change; be careful +# comparing with other UNIXes (some other SunOS examples are OK !?) +# SunOS.5.5.1-BUG: 8 input spaces --> 11 output spaces between a and b; +['i-opt-a', '-tn -i5 -h ""', "a b\n", " 1 a b\n", 0], +# SunOS.5.5.1-BUG: 8 input spaces --> 9 output spaces between a and b; +['i-opt-b', '-tn -i5 -o9 -h ""', "a b\n", + " 1 a b\n", 0], +# +# line number overflow not allowed: cut off leading digits; +# don't adapt other UNIXes, no real standard to follow, a consequent +# programming of column handling may change the GNU pr concept. +['ncut-a', '-tn2 -N98', "y\ny\ny\ny\ny\n", + "98 y\n99 y\n00 y\n01 y\n02 y\n", 0], +['ncut-b', '-tn:2 -N98', "y\ny\ny\ny\ny\n", + "98:y\n99:y\n00:y\n01:y\n02:y\n", 0], + +['margin-0', '-o 0', '', '', 0], + +# BUG fixed: that leading space on 3rd line of output should not be there +['dbl-sp-a', '-d -l 14 -h ""', "1\n2\n", + "\n\n-- Date/Time -- " + . "Page 1\n\n\n1\n\n2\n\n\n\n\n\n\n", 0], +# This test failed with 1.22e and earlier. +['dbl-sp-b', '-d -t', "1\n2\n", "1\n\n2\n\n", 0], + +# This test would segfault with 2.0f and earlier. +['narrow-1', '-W1 -t', "12345\n", "1\n", 0], + +# This test would fail with textutils-2.1 and earlier. +['col-last', '-W3 -t2', "a\nb\nc\n", "a c\nb\n", 0], + +# Make sure that -02 is treated just like -2. +['col-02', '-W3 -t -02', "a\nb\nc\n", "a c\nb\n", 0], +# The -2 must override preceding column-count-specifying options. +['col-2', '-W3 -t -4 --columns=1 -2', "a\nb\nc\n", "a c\nb\n", 0], +# The --columns=2 must override preceding column-count-specifying options. +['col-long', '-W3 -t -1 --columns=2', "a\nb\nc\n", "a c\nb\n", 0], +# Make sure these fail. +['col-0', '-0', '', '', 1, + "$prog: invalid number of columns: '0'\n"], +['col-inval', '-'.'9'x100, '', '', 1, + "$prog: invalid number of columns: '". ('9'x100) ."'\n"], + +# Before coreutils-5.3.1, --pages=1:-1 would be treated like +# --pages=1:18446744073709551615. +['neg-page', '--pages=1:-1', '', '', 1, + "$prog: invalid --pages argument '1:-1'\n"], + +# Up to coreutils-6.10, this would cause pr to decrement its +# internal "input_position" below zero and sometimes segfault. +['neg-inp-pos1', '-t -e', "\b\b\b\b\b\b\tx\n", " x\n", 0], +# NB: while there are 4 backspaces in the input, there are only 3 in the output +['neg-inp-pos2', '-t -e', "abc\b\b\b\b\tx", "abc\b\b\b x\n", 0], + +# This would clobber so much of the heap, it'd segfault or abort every time. +['smash-heap', '-t -e300', "a".("\b"x50)."\t", "a\b".(" "x300)."\n", 0], +['smash-heap8', '-t -e', "a".("\b"x50)."\t", "a\b".(" "x 8)."\n", 0], + +# Before coreutils-8.13 page numbers were not handled correctly when +# headers were not printed (when -l <= 10 or -t or -T specified) +['page-range', '+1:1 -2 -l1 -s" "', "a\nb\nc\n", "a b\n", 0], +); + +# Convert the above old-style test vectors to the newer +# format used by Coreutils.pm. + +my $pfx = "$ENV{abs_srcdir}/pr"; + +# Normalize otherwise-variable output page headers. +my $common_option_prefix = '--date-format="-- Date/Time --" -h x'; + +my @Tests; +foreach my $t (@tv) + { + my ($test_name, $flags, $in, $exp, $ret, $err_msg) = @$t; + my $new_ent = [$test_name, $common_option_prefix, $flags]; + if (!ref $in) + { + push @$new_ent, {IN=>$in}; + } + else + { + foreach my $e (@$in) + { + my $file_name = $$e; + push @$new_ent, {IN=>{"$pfx/$file_name"=>undef}}; + } + } + if (!ref $exp) + { + push @$new_ent, {OUT=>$exp}; + } + else + { + foreach my $e (@$exp) + { + my $file_name = $$e; + push @$new_ent, {OUT=>{"$pfx/$file_name"=>undef}}; + } + } + $ret + and push @$new_ent, {EXIT=>$ret}, {ERR=>$err_msg}; + push @Tests, $new_ent; + } + +@Tests = triple_test \@Tests; + +my $save_temps = $ENV{DEBUG}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/readlink/can-e b/tests/readlink/can-e deleted file mode 100755 index 32b75c595..000000000 --- a/tests/readlink/can-e +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh -# tests for canonicalize-existing mode (readlink -e). - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ readlink - -pwd=$(pwd) -my_pwd=$("$abs_top_builddir/src/pwd") -tmp=d - -mkdir $tmp || framework_failure_ -cd $tmp || framework_failure_ - -mkdir subdir removed || framework_failure_ -touch regfile || framework_failure_ - -ln -s regfile link1 || framework_failure_ -ln -s subdir link2 || framework_failure_ -ln -s missing link3 || framework_failure_ -ln -s subdir/missing link4 || framework_failure_ - -cd "$pwd/$tmp/removed" || framework_failure_ - -# Skip this test if the system doesn't let you remove the working directory. -if rmdir ../removed 2>/dev/null; then - v=$(readlink -e .) && fail=1 - test -z "$v" || fail=1 -fi - -cd "$pwd/$tmp" || fail=1 - -for p in "" "$pwd/$tmp/"; do - - v=$(readlink -e "${p}regfile") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -e "${p}./regfile/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}subdir") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -e "${p}./subdir/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -e "${p}missing") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}./missing/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}link1") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -e "${p}./link1/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}link1/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}link2") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -e "${p}./link2/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -e "${p}link2/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}link3") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}./link3/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}link3/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}link4") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}./link4/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -e "${p}link4/more") && fail=1 - test -z "$v" || fail=1 -done - -Exit $fail diff --git a/tests/readlink/can-e.sh b/tests/readlink/can-e.sh new file mode 100755 index 000000000..32b75c595 --- /dev/null +++ b/tests/readlink/can-e.sh @@ -0,0 +1,104 @@ +#!/bin/sh +# tests for canonicalize-existing mode (readlink -e). + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ readlink + +pwd=$(pwd) +my_pwd=$("$abs_top_builddir/src/pwd") +tmp=d + +mkdir $tmp || framework_failure_ +cd $tmp || framework_failure_ + +mkdir subdir removed || framework_failure_ +touch regfile || framework_failure_ + +ln -s regfile link1 || framework_failure_ +ln -s subdir link2 || framework_failure_ +ln -s missing link3 || framework_failure_ +ln -s subdir/missing link4 || framework_failure_ + +cd "$pwd/$tmp/removed" || framework_failure_ + +# Skip this test if the system doesn't let you remove the working directory. +if rmdir ../removed 2>/dev/null; then + v=$(readlink -e .) && fail=1 + test -z "$v" || fail=1 +fi + +cd "$pwd/$tmp" || fail=1 + +for p in "" "$pwd/$tmp/"; do + + v=$(readlink -e "${p}regfile") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -e "${p}./regfile/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}subdir") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -e "${p}./subdir/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -e "${p}missing") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}./missing/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link1") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -e "${p}./link1/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link1/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -e "${p}./link2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -e "${p}link2/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link3") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}./link3/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link3/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link4") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}./link4/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -e "${p}link4/more") && fail=1 + test -z "$v" || fail=1 +done + +Exit $fail diff --git a/tests/readlink/can-f b/tests/readlink/can-f deleted file mode 100755 index 3f296010c..000000000 --- a/tests/readlink/can-f +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/sh -# tests for canonicalize mode (readlink -f). - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ readlink - -pwd=$(pwd) -my_pwd=$("$abs_top_builddir/src/pwd") -tmp=d - -mkdir $tmp || framework_failure_ -cd $tmp || framework_failure_ - -mkdir subdir removed || framework_failure_ -touch regfile || framework_failure_ - -ln -s regfile link1 || framework_failure_ -ln -s subdir link2 || framework_failure_ -ln -s missing link3 || framework_failure_ -ln -s subdir/missing link4 || framework_failure_ -ln -s link5 link5 || framework_failure_ - -cd "$pwd/$tmp/removed" || framework_failure_ - -# Skip this test if the system doesn't let you remove the working directory. -if rmdir ../removed 2>/dev/null; then - v=$(readlink -e .) && fail=1 - test -z "$v" || fail=1 -fi - -cd "$pwd/$tmp" || fail=1 - -for p in "" "$pwd/$tmp/"; do - - v=$(readlink -f "${p}regfile") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -f "${p}./regfile/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}regfile/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./regfile/more/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}subdir") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -f "${p}./subdir/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -f "${p}subdir/more") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -f "${p}./subdir/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -f "${p}missing") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -f "${p}./missing/") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -f "${p}missing/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./missing/more/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}link1") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -f "${p}./link1/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}link1/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./link1/more/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}link2") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -f "${p}./link2/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -f "${p}link2/more") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -f "${p}./link2/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -f "${p}link2/more/more2") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./link2/more/more2/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}link3") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -f "${p}./link3/") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -f "${p}link3/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./link3/more/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}link4") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 - - v=$(readlink -f "${p}./link4/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 - - v=$(readlink -f "${p}link4/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./link4/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}link5") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./link5/") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}link5/more") && fail=1 - test -z "$v" || fail=1 - - v=$(readlink -f "${p}./link5/more") && fail=1 - test -z "$v" || fail=1 -done - -Exit $fail diff --git a/tests/readlink/can-f.sh b/tests/readlink/can-f.sh new file mode 100755 index 000000000..3f296010c --- /dev/null +++ b/tests/readlink/can-f.sh @@ -0,0 +1,153 @@ +#!/bin/sh +# tests for canonicalize mode (readlink -f). + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ readlink + +pwd=$(pwd) +my_pwd=$("$abs_top_builddir/src/pwd") +tmp=d + +mkdir $tmp || framework_failure_ +cd $tmp || framework_failure_ + +mkdir subdir removed || framework_failure_ +touch regfile || framework_failure_ + +ln -s regfile link1 || framework_failure_ +ln -s subdir link2 || framework_failure_ +ln -s missing link3 || framework_failure_ +ln -s subdir/missing link4 || framework_failure_ +ln -s link5 link5 || framework_failure_ + +cd "$pwd/$tmp/removed" || framework_failure_ + +# Skip this test if the system doesn't let you remove the working directory. +if rmdir ../removed 2>/dev/null; then + v=$(readlink -e .) && fail=1 + test -z "$v" || fail=1 +fi + +cd "$pwd/$tmp" || fail=1 + +for p in "" "$pwd/$tmp/"; do + + v=$(readlink -f "${p}regfile") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -f "${p}./regfile/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}regfile/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./regfile/more/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}subdir") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}./subdir/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}subdir/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -f "${p}./subdir/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -f "${p}missing") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -f "${p}./missing/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -f "${p}missing/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./missing/more/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link1") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -f "${p}./link1/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link1/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./link1/more/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}./link2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -f "${p}link2/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -f "${p}./link2/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -f "${p}link2/more/more2") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./link2/more/more2/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link3") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -f "${p}./link3/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -f "${p}link3/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./link3/more/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link4") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(readlink -f "${p}./link4/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(readlink -f "${p}link4/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./link4/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link5") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./link5/") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}link5/more") && fail=1 + test -z "$v" || fail=1 + + v=$(readlink -f "${p}./link5/more") && fail=1 + test -z "$v" || fail=1 +done + +Exit $fail diff --git a/tests/readlink/can-m b/tests/readlink/can-m deleted file mode 100755 index 09a96f509..000000000 --- a/tests/readlink/can-m +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh -# tests for canonicalize-missing mode (readlink -m). - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ readlink - -pwd=$(pwd) -my_pwd=$("$abs_top_builddir/src/pwd") -tmp=d - -mkdir $tmp || framework_failure_ -cd $tmp || framework_failure_ - -mkdir subdir removed || framework_failure_ -touch regfile || framework_failure_ - -ln -s regfile link1 || framework_failure_ -ln -s subdir link2 || framework_failure_ -ln -s missing link3 || framework_failure_ -ln -s subdir/missing link4 || framework_failure_ - -cd "$pwd/$tmp/removed" || framework_failure_ - -# Skip this test if the system doesn't let you remove the working directory. -if rmdir ../removed 2>/dev/null; then - v=$(readlink -e .) && fail=1 - test -z "$v" || fail=1 -fi - -cd "$pwd/$tmp" || fail=1 - -for p in "" "$pwd/$tmp/"; do - - v=$(readlink -m "${p}regfile") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -m "${p}./regfile/") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -m "${p}regfile/more") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 - - v=$(readlink -m "${p}./regfile/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 - - v=$(readlink -m "${p}subdir") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -m "${p}./subdir/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -m "${p}subdir/more") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -m "${p}./subdir/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -m "${p}missing") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -m "${p}./missing/") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -m "${p}missing/more") || fail=1 - test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 - - v=$(readlink -m "${p}./missing/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 - - v=$(readlink -m "${p}link1") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -m "${p}./link1/") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile" || fail=1 - - v=$(readlink -m "${p}link1/more") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 - - v=$(readlink -m "${p}./link1/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 - - v=$(readlink -m "${p}link2") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -m "${p}./link2/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir" || fail=1 - - v=$(readlink -m "${p}link2/more") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -m "${p}./link2/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 - - v=$(readlink -m "${p}link2/more/more2") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more/more2" || fail=1 - - v=$(readlink -m "${p}./link2/more/more2/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/more/more2" || fail=1 - - v=$(readlink -m "${p}link3") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -m "${p}./link3/") || fail=1 - test "$v" = "$my_pwd/$tmp/missing" || fail=1 - - v=$(readlink -m "${p}link3/more") || fail=1 - test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 - - v=$(readlink -m "${p}./link3/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 - - v=$(readlink -m "${p}link4") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 - - v=$(readlink -m "${p}./link4/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 - - v=$(readlink -m "${p}link4/more") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/missing/more" || fail=1 - - v=$(readlink -m "${p}./link4/more/") || fail=1 - test "$v" = "$my_pwd/$tmp/subdir/missing/more" || fail=1 - -done - -Exit $fail diff --git a/tests/readlink/can-m.sh b/tests/readlink/can-m.sh new file mode 100755 index 000000000..09a96f509 --- /dev/null +++ b/tests/readlink/can-m.sh @@ -0,0 +1,141 @@ +#!/bin/sh +# tests for canonicalize-missing mode (readlink -m). + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ readlink + +pwd=$(pwd) +my_pwd=$("$abs_top_builddir/src/pwd") +tmp=d + +mkdir $tmp || framework_failure_ +cd $tmp || framework_failure_ + +mkdir subdir removed || framework_failure_ +touch regfile || framework_failure_ + +ln -s regfile link1 || framework_failure_ +ln -s subdir link2 || framework_failure_ +ln -s missing link3 || framework_failure_ +ln -s subdir/missing link4 || framework_failure_ + +cd "$pwd/$tmp/removed" || framework_failure_ + +# Skip this test if the system doesn't let you remove the working directory. +if rmdir ../removed 2>/dev/null; then + v=$(readlink -e .) && fail=1 + test -z "$v" || fail=1 +fi + +cd "$pwd/$tmp" || fail=1 + +for p in "" "$pwd/$tmp/"; do + + v=$(readlink -m "${p}regfile") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}./regfile/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}regfile/more") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}./regfile/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}subdir") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}./subdir/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}subdir/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}./subdir/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}missing") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}./missing/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}missing/more") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}./missing/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}link1") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}./link1/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile" || fail=1 + + v=$(readlink -m "${p}link1/more") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}./link1/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/regfile/more" || fail=1 + + v=$(readlink -m "${p}link2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}./link2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir" || fail=1 + + v=$(readlink -m "${p}link2/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}./link2/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more" || fail=1 + + v=$(readlink -m "${p}link2/more/more2") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more/more2" || fail=1 + + v=$(readlink -m "${p}./link2/more/more2/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/more/more2" || fail=1 + + v=$(readlink -m "${p}link3") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}./link3/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing" || fail=1 + + v=$(readlink -m "${p}link3/more") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}./link3/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/missing/more" || fail=1 + + v=$(readlink -m "${p}link4") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(readlink -m "${p}./link4/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing" || fail=1 + + v=$(readlink -m "${p}link4/more") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing/more" || fail=1 + + v=$(readlink -m "${p}./link4/more/") || fail=1 + test "$v" = "$my_pwd/$tmp/subdir/missing/more" || fail=1 + +done + +Exit $fail diff --git a/tests/readlink/rl-1 b/tests/readlink/rl-1 deleted file mode 100755 index 511a9890e..000000000 --- a/tests/readlink/rl-1 +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# test for readlink mode. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ readlink - -mkdir subdir || framework_failure_ -touch regfile || framework_failure_ -ln -s regfile link1 || framework_failure_ -ln -s missing link2 || framework_failure_ - - -v=$(readlink link1) || fail=1 -test "$v" = regfile || fail=1 - -v=$(readlink link2) || fail=1 -test "$v" = missing || fail=1 - -v=$(readlink subdir) && fail=1 -test -z "$v" || fail=1 - -v=$(readlink regfile) && fail=1 -test -z "$v" || fail=1 - -v=$(readlink missing) && fail=1 -test -z "$v" || fail=1 - -Exit $fail diff --git a/tests/readlink/rl-1.sh b/tests/readlink/rl-1.sh new file mode 100755 index 000000000..511a9890e --- /dev/null +++ b/tests/readlink/rl-1.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# test for readlink mode. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ readlink + +mkdir subdir || framework_failure_ +touch regfile || framework_failure_ +ln -s regfile link1 || framework_failure_ +ln -s missing link2 || framework_failure_ + + +v=$(readlink link1) || fail=1 +test "$v" = regfile || fail=1 + +v=$(readlink link2) || fail=1 +test "$v" = missing || fail=1 + +v=$(readlink subdir) && fail=1 +test -z "$v" || fail=1 + +v=$(readlink regfile) && fail=1 +test -z "$v" || fail=1 + +v=$(readlink missing) && fail=1 +test -z "$v" || fail=1 + +Exit $fail diff --git a/tests/rm/cycle b/tests/rm/cycle deleted file mode 100755 index 33e1283b6..000000000 --- a/tests/rm/cycle +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# rm (coreutils-4.5.4) could be tricked into mistakenly reporting a cycle. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -p a/b -touch a/b/file -chmod u-w a/b - - -rm -rf a a 2>&1 | sed 's/:[^:]*$//' > out || fail=1 -cat <<\EOF > exp -rm: cannot remove 'a/b/file' -rm: cannot remove 'a/b/file' -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/cycle.sh b/tests/rm/cycle.sh new file mode 100755 index 000000000..33e1283b6 --- /dev/null +++ b/tests/rm/cycle.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# rm (coreutils-4.5.4) could be tricked into mistakenly reporting a cycle. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -p a/b +touch a/b/file +chmod u-w a/b + + +rm -rf a a 2>&1 | sed 's/:[^:]*$//' > out || fail=1 +cat <<\EOF > exp +rm: cannot remove 'a/b/file' +rm: cannot remove 'a/b/file' +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/d-1 b/tests/rm/d-1 deleted file mode 100755 index f35e95125..000000000 --- a/tests/rm/d-1 +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Test "rm --dir --verbose". - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir a || framework_failure_ -> b || framework_failure_ - -rm --verbose --dir a b > out || fail=1 - -cat <<\EOF > exp || framework_failure_ -removed directory: 'a' -removed 'b' -EOF - -test -e a && fail=1 -test -e b && fail=1 - -# Compare expected and actual output. -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/d-1.sh b/tests/rm/d-1.sh new file mode 100755 index 000000000..f35e95125 --- /dev/null +++ b/tests/rm/d-1.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Test "rm --dir --verbose". + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir a || framework_failure_ +> b || framework_failure_ + +rm --verbose --dir a b > out || fail=1 + +cat <<\EOF > exp || framework_failure_ +removed directory: 'a' +removed 'b' +EOF + +test -e a && fail=1 +test -e b && fail=1 + +# Compare expected and actual output. +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/d-2 b/tests/rm/d-2 deleted file mode 100755 index a63cff60d..000000000 --- a/tests/rm/d-2 +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Ensure that 'rm -d dir' (i.e., without --recursive) gives a reasonable -# diagnostic when failing. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir d || framework_failure_ -> d/a || framework_failure_ - -rm -d d 2> out && fail=1 -printf "%s\n" \ - "rm: cannot remove 'd': Directory not empty" \ - > exp || framework_failure_ - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/d-2.sh b/tests/rm/d-2.sh new file mode 100755 index 000000000..a63cff60d --- /dev/null +++ b/tests/rm/d-2.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Ensure that 'rm -d dir' (i.e., without --recursive) gives a reasonable +# diagnostic when failing. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir d || framework_failure_ +> d/a || framework_failure_ + +rm -d d 2> out && fail=1 +printf "%s\n" \ + "rm: cannot remove 'd': Directory not empty" \ + > exp || framework_failure_ + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/d-3 b/tests/rm/d-3 deleted file mode 100755 index 2f2cf7492..000000000 --- a/tests/rm/d-3 +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Ensure that 'rm -d -i dir' (i.e., without --recursive) gives a prompt and -# then deletes the directory if it is empty - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir d || framework_failure_ - -echo "y" | rm -i -d --verbose d > out 2> out.err || fail=1 -printf "%s" \ - "rm: remove directory 'd'? " \ - > exp.err || framework_failure_ - -printf "%s\n" \ - "removed directory: 'd'" \ - > exp || framework_failure_ - -compare exp out || fail=1 -compare exp.err out.err || fail=1 - -Exit $fail diff --git a/tests/rm/d-3.sh b/tests/rm/d-3.sh new file mode 100755 index 000000000..2f2cf7492 --- /dev/null +++ b/tests/rm/d-3.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Ensure that 'rm -d -i dir' (i.e., without --recursive) gives a prompt and +# then deletes the directory if it is empty + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir d || framework_failure_ + +echo "y" | rm -i -d --verbose d > out 2> out.err || fail=1 +printf "%s" \ + "rm: remove directory 'd'? " \ + > exp.err || framework_failure_ + +printf "%s\n" \ + "removed directory: 'd'" \ + > exp || framework_failure_ + +compare exp out || fail=1 +compare exp.err out.err || fail=1 + +Exit $fail diff --git a/tests/rm/dangling-symlink b/tests/rm/dangling-symlink deleted file mode 100755 index 92a59066a..000000000 --- a/tests/rm/dangling-symlink +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# rm should not prompt before removing a dangling symlink. -# Likewise for a non-dangling symlink. -# But for fileutils-4.1.9, it would do the former and -# for fileutils-4.1.10 the latter. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -ln -s no-file dangle -ln -s / symlink - - -rm ---presume-input-tty dangle symlink & -pid=$! -# The buggy rm (fileutils-4.1.9) would hang here, waiting for input. - -# Wait up to 3.1s for rm to remove the files -check_files_removed() { - local delay="$1" - local present=0 - ls -l dangle > /dev/null 2>&1 && present=1 - ls -l symlink > /dev/null 2>&1 && present=1 - test $present = 1 && { sleep $delay; return 1; } || : -} -retry_delay_ check_files_removed .1 5 || fail=1 - -kill $pid > /dev/null 2>&1 - -Exit $fail diff --git a/tests/rm/dangling-symlink.sh b/tests/rm/dangling-symlink.sh new file mode 100755 index 000000000..92a59066a --- /dev/null +++ b/tests/rm/dangling-symlink.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# rm should not prompt before removing a dangling symlink. +# Likewise for a non-dangling symlink. +# But for fileutils-4.1.9, it would do the former and +# for fileutils-4.1.10 the latter. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +ln -s no-file dangle +ln -s / symlink + + +rm ---presume-input-tty dangle symlink & +pid=$! +# The buggy rm (fileutils-4.1.9) would hang here, waiting for input. + +# Wait up to 3.1s for rm to remove the files +check_files_removed() { + local delay="$1" + local present=0 + ls -l dangle > /dev/null 2>&1 && present=1 + ls -l symlink > /dev/null 2>&1 && present=1 + test $present = 1 && { sleep $delay; return 1; } || : +} +retry_delay_ check_files_removed .1 5 || fail=1 + +kill $pid > /dev/null 2>&1 + +Exit $fail diff --git a/tests/rm/deep-1 b/tests/rm/deep-1 deleted file mode 100755 index f739eb594..000000000 --- a/tests/rm/deep-1 +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# Test "rm" with a deep hierarchy. - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# This is a bit of a torture test for mkdir -p, too. -# GNU rm performs *much* better on systems that have a d_type member -# in the directory structure because then it does only one stat per -# command line argument. - -# If this test takes too long on your system, blame the OS. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -umask 022 - - -k20=/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k -k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20 - -# Be careful not to exceed max file name length (usu 512?). -# Doing so wouldn't affect GNU mkdir or GNU rm, but any tool that -# operates on the full pathname (like 'test') would choke. -k_deep=$k200$k200 - -t=t -# Create a directory in $t with lots of 'k' components. -deep=$t$k_deep -mkdir -p $deep || fail=1 - -# Make sure the deep dir was created. -test -d $deep || fail=1 - -rm -r $t || fail=1 - -# Make sure all of $t was deleted. -test -d $t && fail=1 - -Exit $fail diff --git a/tests/rm/deep-1.sh b/tests/rm/deep-1.sh new file mode 100755 index 000000000..f739eb594 --- /dev/null +++ b/tests/rm/deep-1.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Test "rm" with a deep hierarchy. + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This is a bit of a torture test for mkdir -p, too. +# GNU rm performs *much* better on systems that have a d_type member +# in the directory structure because then it does only one stat per +# command line argument. + +# If this test takes too long on your system, blame the OS. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +umask 022 + + +k20=/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k +k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20 + +# Be careful not to exceed max file name length (usu 512?). +# Doing so wouldn't affect GNU mkdir or GNU rm, but any tool that +# operates on the full pathname (like 'test') would choke. +k_deep=$k200$k200 + +t=t +# Create a directory in $t with lots of 'k' components. +deep=$t$k_deep +mkdir -p $deep || fail=1 + +# Make sure the deep dir was created. +test -d $deep || fail=1 + +rm -r $t || fail=1 + +# Make sure all of $t was deleted. +test -d $t && fail=1 + +Exit $fail diff --git a/tests/rm/deep-2 b/tests/rm/deep-2 deleted file mode 100755 index 266097741..000000000 --- a/tests/rm/deep-2 +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Ensure rm -r DIR does not prompt for very long full relative names in DIR. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -require_perl_ - -# Root can run this test, but it always succeeds, since for root, all -# files are writable, and write_protected_non_symlink never reaches -# the offending euidaccess_stat call. -skip_if_root_ - -mkdir x || framework_failure_ -cd x || framework_failure_ - -# Construct a hierarchy containing a relative file with a long name -: ${PERL=perl} -$PERL \ - -e 'my $d = "x" x 200; foreach my $i (1..52)' \ - -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \ - || framework_failure_ - -cd .. || framework_failure_ -echo n > no || framework_failure_ - -rm ---presume-input-tty -r x < no > out || fail=1 - -# expect empty output -test -s out && fail=1 - -# the directory must have been removed -test -d x && fail=1 - -Exit $fail diff --git a/tests/rm/deep-2.sh b/tests/rm/deep-2.sh new file mode 100755 index 000000000..266097741 --- /dev/null +++ b/tests/rm/deep-2.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Ensure rm -r DIR does not prompt for very long full relative names in DIR. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +require_perl_ + +# Root can run this test, but it always succeeds, since for root, all +# files are writable, and write_protected_non_symlink never reaches +# the offending euidaccess_stat call. +skip_if_root_ + +mkdir x || framework_failure_ +cd x || framework_failure_ + +# Construct a hierarchy containing a relative file with a long name +: ${PERL=perl} +$PERL \ + -e 'my $d = "x" x 200; foreach my $i (1..52)' \ + -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \ + || framework_failure_ + +cd .. || framework_failure_ +echo n > no || framework_failure_ + +rm ---presume-input-tty -r x < no > out || fail=1 + +# expect empty output +test -s out && fail=1 + +# the directory must have been removed +test -d x && fail=1 + +Exit $fail diff --git a/tests/rm/dir-no-w b/tests/rm/dir-no-w deleted file mode 100755 index ce33b98e5..000000000 --- a/tests/rm/dir-no-w +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# rm (without -r) must give a diagnostic for any directory. -# It must not prompt, even if that directory is unwritable. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir --mode=0500 unwritable-dir || framework_failure_ - - -# For rm from coreutils-5.0.1, this would prompt. -rm ---presume-input-tty unwritable-dir < /dev/null > out-t 2>&1 && fail=1 -cat <<\EOF > exp || fail=1 -rm: cannot remove 'unwritable-dir': Is a directory -EOF - -# When run by a non-privileged user we get this: -# rm: cannot remove directory 'unwritable-dir': Is a directory -# When run by root we get this: -# rm: cannot remove 'unwritable-dir': Is a directory -# Normalize the message. -sed 's/remove directory/remove/' out-t > out -rm -f out-t - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/dir-no-w.sh b/tests/rm/dir-no-w.sh new file mode 100755 index 000000000..ce33b98e5 --- /dev/null +++ b/tests/rm/dir-no-w.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# rm (without -r) must give a diagnostic for any directory. +# It must not prompt, even if that directory is unwritable. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir --mode=0500 unwritable-dir || framework_failure_ + + +# For rm from coreutils-5.0.1, this would prompt. +rm ---presume-input-tty unwritable-dir < /dev/null > out-t 2>&1 && fail=1 +cat <<\EOF > exp || fail=1 +rm: cannot remove 'unwritable-dir': Is a directory +EOF + +# When run by a non-privileged user we get this: +# rm: cannot remove directory 'unwritable-dir': Is a directory +# When run by root we get this: +# rm: cannot remove 'unwritable-dir': Is a directory +# Normalize the message. +sed 's/remove directory/remove/' out-t > out +rm -f out-t + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/dir-nonrecur b/tests/rm/dir-nonrecur deleted file mode 100755 index 8876e9458..000000000 --- a/tests/rm/dir-nonrecur +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Ensure that 'rm dir' (i.e., without --recursive) gives a reasonable -# diagnostic when failing. - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir d || framework_failure_ - - -rm d 2> out && fail=1 -cat <<\EOF > exp || fail=1 -rm: cannot remove 'd': Is a directory -EOF - -# Before coreutils-5.93 this test would fail on Solaris 9 and newer. -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/dir-nonrecur.sh b/tests/rm/dir-nonrecur.sh new file mode 100755 index 000000000..8876e9458 --- /dev/null +++ b/tests/rm/dir-nonrecur.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Ensure that 'rm dir' (i.e., without --recursive) gives a reasonable +# diagnostic when failing. + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir d || framework_failure_ + + +rm d 2> out && fail=1 +cat <<\EOF > exp || fail=1 +rm: cannot remove 'd': Is a directory +EOF + +# Before coreutils-5.93 this test would fail on Solaris 9 and newer. +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/dot-rel b/tests/rm/dot-rel deleted file mode 100755 index fc693596a..000000000 --- a/tests/rm/dot-rel +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Use rm -r to remove two non-empty dot-relative directories. -# This would have failed between 2004-10-18 and 2004-10-21. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir a b || framework_failure_ -touch a/f b/f || framework_failure_ - - -rm -r a b || fail=1 - -Exit $fail diff --git a/tests/rm/dot-rel.sh b/tests/rm/dot-rel.sh new file mode 100755 index 000000000..fc693596a --- /dev/null +++ b/tests/rm/dot-rel.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Use rm -r to remove two non-empty dot-relative directories. +# This would have failed between 2004-10-18 and 2004-10-21. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir a b || framework_failure_ +touch a/f b/f || framework_failure_ + + +rm -r a b || fail=1 + +Exit $fail diff --git a/tests/rm/empty-inacc b/tests/rm/empty-inacc deleted file mode 100755 index e23cb8553..000000000 --- a/tests/rm/empty-inacc +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Ensure that rm -rf removes an empty-and-inaccessible directory. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -m0 inacc || framework_failure_ - -# Also exercise the different code path that's taken for a directory -# that is empty (hence removable) and unreadable. -mkdir -m a-r -p a/unreadable - - -# This would fail for e.g., coreutils-5.93. -rm -rf inacc || fail=1 -test -d inacc && fail=1 - -# This would fail for e.g., coreutils-5.97. -rm -rf a || fail=1 -test -d a && fail=1 - -Exit $fail diff --git a/tests/rm/empty-inacc.sh b/tests/rm/empty-inacc.sh new file mode 100755 index 000000000..e23cb8553 --- /dev/null +++ b/tests/rm/empty-inacc.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Ensure that rm -rf removes an empty-and-inaccessible directory. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -m0 inacc || framework_failure_ + +# Also exercise the different code path that's taken for a directory +# that is empty (hence removable) and unreadable. +mkdir -m a-r -p a/unreadable + + +# This would fail for e.g., coreutils-5.93. +rm -rf inacc || fail=1 +test -d inacc && fail=1 + +# This would fail for e.g., coreutils-5.97. +rm -rf a || fail=1 +test -d a && fail=1 + +Exit $fail diff --git a/tests/rm/empty-name b/tests/rm/empty-name deleted file mode 100755 index b609170dc..000000000 --- a/tests/rm/empty-name +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/perl -# Make sure that rm -r '' fails. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# On SunOS 4.1.3, running rm -r '' in a nonempty directory may -# actually remove files with names of entries in the current directory -# but relative to '/' rather than relative to the current directory. - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $prog = 'rm'; - -# FIXME: copied from misc/ls-misc; factor into Coreutils.pm? -sub mk_file(@) -{ - foreach my $f (@_) - { - open (F, '>', $f) && close F - or die "creating $f: $!\n"; - } -} - -my @Tests = - ( - # test-name options input expected-output - # - ['empty-name-1', "''", {EXIT => 1}, - {ERR => "$prog: cannot remove '': No such file or directory\n"}], - - ['empty-name-2', "a '' b", {EXIT => 1}, - {ERR => "$prog: cannot remove '': No such file or directory\n"}, - {PRE => sub { mk_file qw(a b) }}, - {POST => sub {-f 'a' || -f 'b' and die "a or b remain\n" }}, - ], - ); - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/rm/empty-name.pl b/tests/rm/empty-name.pl new file mode 100755 index 000000000..b609170dc --- /dev/null +++ b/tests/rm/empty-name.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl +# Make sure that rm -r '' fails. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# On SunOS 4.1.3, running rm -r '' in a nonempty directory may +# actually remove files with names of entries in the current directory +# but relative to '/' rather than relative to the current directory. + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $prog = 'rm'; + +# FIXME: copied from misc/ls-misc; factor into Coreutils.pm? +sub mk_file(@) +{ + foreach my $f (@_) + { + open (F, '>', $f) && close F + or die "creating $f: $!\n"; + } +} + +my @Tests = + ( + # test-name options input expected-output + # + ['empty-name-1', "''", {EXIT => 1}, + {ERR => "$prog: cannot remove '': No such file or directory\n"}], + + ['empty-name-2', "a '' b", {EXIT => 1}, + {ERR => "$prog: cannot remove '': No such file or directory\n"}, + {PRE => sub { mk_file qw(a b) }}, + {POST => sub {-f 'a' || -f 'b' and die "a or b remain\n" }}, + ], + ); + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/rm/ext3-perf b/tests/rm/ext3-perf deleted file mode 100755 index 97b0a17b3..000000000 --- a/tests/rm/ext3-perf +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -# ensure that "rm -rf DIR-with-many-entries" is not O(N^2) - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -very_expensive_ - -# Using rm -rf to remove a 400k-entry directory takes: -# - 9 seconds with the patch, on a 2-yr-old system -# - 350 seconds without the patch, on a high-end system (disk 20-30% faster) -threshold_seconds=60 - -# The number of entries in our test directory. -n=400000 - -# Choose a value that is large enough to ensure an accidentally -# regressed rm would require much longer than $threshold_seconds to remove -# the directory. With n=400k, pre-patch GNU rm would require about 350 -# seconds even on a fast disk. On a relatively modern system, the -# patched version of rm requires about 10 seconds, so even if you -# choose to enable very expensive tests with a disk that is much slower, -# the test should still succeed. - -# Skip unless "." is on an ext[34] file system. -# FIXME-maybe: try to find a suitable file system or allow -# the user to specify it via an envvar. -df -T -t ext3 -t ext4dev -t ext4 . \ - || skip_ 'this test runs only on an ext3 or ext4 file system' - -# Skip if there are too few inodes free. Require some slack. -free_inodes=$(stat -f --format=%d .) || framework_failure_ -min_free_inodes=$(expr 12 \* $n / 10) -test $min_free_inodes -lt $free_inodes \ - || skip_ "too few free inodes on '.': $free_inodes;" \ - "this test requires at least $min_free_inodes" - -ok=0 -start=$(date +%s) -mkdir d && - cd d && - seq $n | xargs touch && - test -f 1 && - test -f $n && - cd .. && - ok=1 -test $ok = 1 || framework_failure_ -setup_duration=$(expr $(date +%s) - $start) -echo creating a $n-entry directory took $setup_duration seconds - -# If set-up took longer than the default $threshold_seconds, -# use the longer set-up duration as the limit. -test $threshold_seconds -lt $setup_duration \ - && threshold_seconds=$setup_duration - -start=$(date +%s) -timeout ${threshold_seconds}s rm -rf d; err=$? -duration=$(expr $(date +%s) - $start) - -case $err in - 124) fail=1; echo rm took longer than $threshold_seconds seconds;; - 0) ;; - *) fail=1;; -esac - -echo removing a $n-entry directory took $duration seconds - -Exit $fail diff --git a/tests/rm/ext3-perf.sh b/tests/rm/ext3-perf.sh new file mode 100755 index 000000000..97b0a17b3 --- /dev/null +++ b/tests/rm/ext3-perf.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# ensure that "rm -rf DIR-with-many-entries" is not O(N^2) + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +very_expensive_ + +# Using rm -rf to remove a 400k-entry directory takes: +# - 9 seconds with the patch, on a 2-yr-old system +# - 350 seconds without the patch, on a high-end system (disk 20-30% faster) +threshold_seconds=60 + +# The number of entries in our test directory. +n=400000 + +# Choose a value that is large enough to ensure an accidentally +# regressed rm would require much longer than $threshold_seconds to remove +# the directory. With n=400k, pre-patch GNU rm would require about 350 +# seconds even on a fast disk. On a relatively modern system, the +# patched version of rm requires about 10 seconds, so even if you +# choose to enable very expensive tests with a disk that is much slower, +# the test should still succeed. + +# Skip unless "." is on an ext[34] file system. +# FIXME-maybe: try to find a suitable file system or allow +# the user to specify it via an envvar. +df -T -t ext3 -t ext4dev -t ext4 . \ + || skip_ 'this test runs only on an ext3 or ext4 file system' + +# Skip if there are too few inodes free. Require some slack. +free_inodes=$(stat -f --format=%d .) || framework_failure_ +min_free_inodes=$(expr 12 \* $n / 10) +test $min_free_inodes -lt $free_inodes \ + || skip_ "too few free inodes on '.': $free_inodes;" \ + "this test requires at least $min_free_inodes" + +ok=0 +start=$(date +%s) +mkdir d && + cd d && + seq $n | xargs touch && + test -f 1 && + test -f $n && + cd .. && + ok=1 +test $ok = 1 || framework_failure_ +setup_duration=$(expr $(date +%s) - $start) +echo creating a $n-entry directory took $setup_duration seconds + +# If set-up took longer than the default $threshold_seconds, +# use the longer set-up duration as the limit. +test $threshold_seconds -lt $setup_duration \ + && threshold_seconds=$setup_duration + +start=$(date +%s) +timeout ${threshold_seconds}s rm -rf d; err=$? +duration=$(expr $(date +%s) - $start) + +case $err in + 124) fail=1; echo rm took longer than $threshold_seconds seconds;; + 0) ;; + *) fail=1;; +esac + +echo removing a $n-entry directory took $duration seconds + +Exit $fail diff --git a/tests/rm/f-1 b/tests/rm/f-1 deleted file mode 100755 index e1ed8d4fa..000000000 --- a/tests/rm/f-1 +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Test "rm -f" with a nonexistent file. - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir -p d || framework_failure_ - -rm -f d/no-such-file || fail=1 - -Exit $fail diff --git a/tests/rm/f-1.sh b/tests/rm/f-1.sh new file mode 100755 index 000000000..e1ed8d4fa --- /dev/null +++ b/tests/rm/f-1.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Test "rm -f" with a nonexistent file. + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir -p d || framework_failure_ + +rm -f d/no-such-file || fail=1 + +Exit $fail diff --git a/tests/rm/fail-2eperm b/tests/rm/fail-2eperm deleted file mode 100755 index fa2f43227..000000000 --- a/tests/rm/fail-2eperm +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Like fail-eperm, but the failure must be for a file encountered -# while trying to remove the containing directory with the sticky bit set. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -require_root_ - -# The containing directory must be owned by the user who eventually runs rm. -chown $NON_ROOT_USERNAME . - -mkdir a || framework_failure_ -chmod 1777 a || framework_failure_ -touch a/b || framework_failure_ - - -# Try to ensure that $NON_ROOT_USERNAME can access -# the required version of rm. -rm_version=$( - setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm --version | - sed -n '1s/.* //p' -) -case $rm_version in - $PACKAGE_VERSION) ;; - *) skip_ "cannot access just-built rm as user $NON_ROOT_USERNAME";; -esac -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf a 2> out-t && fail=1 - -# On some systems, we get 'Not owner'. Convert it. -# On other systems (HPUX), we get 'Permission denied'. Convert it, too. -onp='Operation not permitted' -sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t > out - -cat <<\EOF > exp -rm: cannot remove 'a/b': Operation not permitted -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/fail-2eperm.sh b/tests/rm/fail-2eperm.sh new file mode 100755 index 000000000..fa2f43227 --- /dev/null +++ b/tests/rm/fail-2eperm.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Like fail-eperm, but the failure must be for a file encountered +# while trying to remove the containing directory with the sticky bit set. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +require_root_ + +# The containing directory must be owned by the user who eventually runs rm. +chown $NON_ROOT_USERNAME . + +mkdir a || framework_failure_ +chmod 1777 a || framework_failure_ +touch a/b || framework_failure_ + + +# Try to ensure that $NON_ROOT_USERNAME can access +# the required version of rm. +rm_version=$( + setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm --version | + sed -n '1s/.* //p' +) +case $rm_version in + $PACKAGE_VERSION) ;; + *) skip_ "cannot access just-built rm as user $NON_ROOT_USERNAME";; +esac +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf a 2> out-t && fail=1 + +# On some systems, we get 'Not owner'. Convert it. +# On other systems (HPUX), we get 'Permission denied'. Convert it, too. +onp='Operation not permitted' +sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t > out + +cat <<\EOF > exp +rm: cannot remove 'a/b': Operation not permitted +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/fail-eacces b/tests/rm/fail-eacces deleted file mode 100755 index 947dfac36..000000000 --- a/tests/rm/fail-eacces +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Ensure that rm -rf unremovable-non-dir gives a diagnostic. -# Test both a regular file and a symlink -- it makes a difference to rm. -# With the symlink, rm from coreutils-6.9 would fail with a misleading -# ELOOP diagnostic. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -ok=0 -mkdir d && - touch d/f && - ln -s f d/slink && - chmod a-w d && - ok=1 -test $ok = 1 || framework_failure_ - -mkdir e && - ln -s f e/slink && - chmod a-w e && - ok=1 -test $ok = 1 || framework_failure_ - - -rm -rf d/f 2> out && fail=1 -cat <<\EOF > exp -rm: cannot remove 'd/f': Permission denied -EOF -compare exp out || fail=1 - -# This used to fail with ELOOP. -rm -rf e 2> out && fail=1 -cat <<\EOF > exp -rm: cannot remove 'e/slink': Permission denied -EOF -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/fail-eacces.sh b/tests/rm/fail-eacces.sh new file mode 100755 index 000000000..947dfac36 --- /dev/null +++ b/tests/rm/fail-eacces.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Ensure that rm -rf unremovable-non-dir gives a diagnostic. +# Test both a regular file and a symlink -- it makes a difference to rm. +# With the symlink, rm from coreutils-6.9 would fail with a misleading +# ELOOP diagnostic. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +ok=0 +mkdir d && + touch d/f && + ln -s f d/slink && + chmod a-w d && + ok=1 +test $ok = 1 || framework_failure_ + +mkdir e && + ln -s f e/slink && + chmod a-w e && + ok=1 +test $ok = 1 || framework_failure_ + + +rm -rf d/f 2> out && fail=1 +cat <<\EOF > exp +rm: cannot remove 'd/f': Permission denied +EOF +compare exp out || fail=1 + +# This used to fail with ELOOP. +rm -rf e 2> out && fail=1 +cat <<\EOF > exp +rm: cannot remove 'e/slink': Permission denied +EOF +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/hash b/tests/rm/hash deleted file mode 100755 index 344325e13..000000000 --- a/tests/rm/hash +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Exercise a bug that was fixed in 4.0s. -# Before then, rm would fail occasionally, sometimes via -# a failed assertion, others with a seg fault. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -expensive_ - -# Create a hierarchy with 3*26 leaf directories, each at depth 153. -echo "$0: creating 78 trees, each of depth 153; this will take a while..." >&2 -y=$(seq 1 150|tr -sc '\n' y|tr '\n' /) -for i in 1 2 3; do - for j in a b c d e f g h i j k l m n o p q r s t u v w x y z; do - mkdir -p t/$i/$j/$y || framework_failure_ - done -done - - -rm -r t || fail=1 - -Exit $fail diff --git a/tests/rm/hash.sh b/tests/rm/hash.sh new file mode 100755 index 000000000..344325e13 --- /dev/null +++ b/tests/rm/hash.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Exercise a bug that was fixed in 4.0s. +# Before then, rm would fail occasionally, sometimes via +# a failed assertion, others with a seg fault. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +expensive_ + +# Create a hierarchy with 3*26 leaf directories, each at depth 153. +echo "$0: creating 78 trees, each of depth 153; this will take a while..." >&2 +y=$(seq 1 150|tr -sc '\n' y|tr '\n' /) +for i in 1 2 3; do + for j in a b c d e f g h i j k l m n o p q r s t u v w x y z; do + mkdir -p t/$i/$j/$y || framework_failure_ + done +done + + +rm -r t || fail=1 + +Exit $fail diff --git a/tests/rm/i-1 b/tests/rm/i-1 deleted file mode 100755 index 67df853f5..000000000 --- a/tests/rm/i-1 +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Test "rm -i". - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -t=t -mkdir -p $t || framework_failure_ -echo > $t/a || framework_failure_ -test -f $t/a || framework_failure_ - -echo y > $t/in-y -echo n > $t/in-n - -rm -i $t/a < $t/in-n > /dev/null 2>&1 || fail=1 -# The file should not have been removed. -test -f $t/a || fail=1 - -rm -i $t/a < $t/in-y > /dev/null 2>&1 || fail=1 -# The file should have been removed this time. -test -f $t/a && fail=1 - -rm -rf $t - -Exit $fail diff --git a/tests/rm/i-1.sh b/tests/rm/i-1.sh new file mode 100755 index 000000000..67df853f5 --- /dev/null +++ b/tests/rm/i-1.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Test "rm -i". + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +t=t +mkdir -p $t || framework_failure_ +echo > $t/a || framework_failure_ +test -f $t/a || framework_failure_ + +echo y > $t/in-y +echo n > $t/in-n + +rm -i $t/a < $t/in-n > /dev/null 2>&1 || fail=1 +# The file should not have been removed. +test -f $t/a || fail=1 + +rm -i $t/a < $t/in-y > /dev/null 2>&1 || fail=1 +# The file should have been removed this time. +test -f $t/a && fail=1 + +rm -rf $t + +Exit $fail diff --git a/tests/rm/i-never b/tests/rm/i-never deleted file mode 100755 index 80e1fcd98..000000000 --- a/tests/rm/i-never +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Ensure that rm --interactive=never works does not prompt, even for -# an unwritable file. - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -touch f || framework_failure_ -chmod 0 f || framework_failure_ -touch exp || framework_failure_ - - -rm --interactive=never f > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/i-never.sh b/tests/rm/i-never.sh new file mode 100755 index 000000000..80e1fcd98 --- /dev/null +++ b/tests/rm/i-never.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Ensure that rm --interactive=never works does not prompt, even for +# an unwritable file. + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +touch f || framework_failure_ +chmod 0 f || framework_failure_ +touch exp || framework_failure_ + + +rm --interactive=never f > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/i-no-r b/tests/rm/i-no-r deleted file mode 100755 index 6b22e1ca1..000000000 --- a/tests/rm/i-no-r +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Since the rewrite for fileutils-4.1.9, 'rm -i DIR' would mistakenly -# recurse into directory DIR. rm -i (without -r) must fail in that case. -# Fixed in coreutils-4.5.2. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir dir || framework_failure_ -echo y > y || framework_failure_ - - -# This must fail. -rm -i dir < y > /dev/null 2>&1 && fail=1 - -# The directory must remain. -test -d dir || fail=1 - -Exit $fail diff --git a/tests/rm/i-no-r.sh b/tests/rm/i-no-r.sh new file mode 100755 index 000000000..6b22e1ca1 --- /dev/null +++ b/tests/rm/i-no-r.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Since the rewrite for fileutils-4.1.9, 'rm -i DIR' would mistakenly +# recurse into directory DIR. rm -i (without -r) must fail in that case. +# Fixed in coreutils-4.5.2. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir dir || framework_failure_ +echo y > y || framework_failure_ + + +# This must fail. +rm -i dir < y > /dev/null 2>&1 && fail=1 + +# The directory must remain. +test -d dir || fail=1 + +Exit $fail diff --git a/tests/rm/ignorable b/tests/rm/ignorable deleted file mode 100755 index bcf3b7eb9..000000000 --- a/tests/rm/ignorable +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Ensure that rm -f existing-non-dir/anything exits successfully - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -touch existing-non-dir || framework_failure_ - - -# With coreutils-6.3, this would exit nonzero. It should not. -# Example from Andreas Schwab. -rm -f existing-non-dir/f > out 2>&1 || fail=1 - -Exit $fail diff --git a/tests/rm/ignorable.sh b/tests/rm/ignorable.sh new file mode 100755 index 000000000..bcf3b7eb9 --- /dev/null +++ b/tests/rm/ignorable.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Ensure that rm -f existing-non-dir/anything exits successfully + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +touch existing-non-dir || framework_failure_ + + +# With coreutils-6.3, this would exit nonzero. It should not. +# Example from Andreas Schwab. +rm -f existing-non-dir/f > out 2>&1 || fail=1 + +Exit $fail diff --git a/tests/rm/inaccessible b/tests/rm/inaccessible deleted file mode 100755 index 2f045815e..000000000 --- a/tests/rm/inaccessible +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Ensure that rm works even when run from a directory -# for which the user has no access at all. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -# Skip this test if your system has neither the openat-style functions -# nor /proc/self/fd support with which to emulate them. -require_openat_support_ -skip_if_root_ - -p=$(pwd) -mkdir abs1 abs2 no-access || framework_failure_ - - -set +x -(cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1 -test -d "$p/abs1" && fail=1 -test -d "$p/abs2" && fail=1 - -cat <<\EOF > exp || fail=1 -rm: cannot remove 'rel': Permission denied -EOF - -# AIX 4.3.3 fails with a different diagnostic. -# Transform their diagnostic -# ...: The file access permissions do not allow the specified action. -# to the expected one: -sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/inaccessible.sh b/tests/rm/inaccessible.sh new file mode 100755 index 000000000..2f045815e --- /dev/null +++ b/tests/rm/inaccessible.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Ensure that rm works even when run from a directory +# for which the user has no access at all. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +# Skip this test if your system has neither the openat-style functions +# nor /proc/self/fd support with which to emulate them. +require_openat_support_ +skip_if_root_ + +p=$(pwd) +mkdir abs1 abs2 no-access || framework_failure_ + + +set +x +(cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1 +test -d "$p/abs1" && fail=1 +test -d "$p/abs2" && fail=1 + +cat <<\EOF > exp || fail=1 +rm: cannot remove 'rel': Permission denied +EOF + +# AIX 4.3.3 fails with a different diagnostic. +# Transform their diagnostic +# ...: The file access permissions do not allow the specified action. +# to the expected one: +sed 's/: The file access permissions.*/: Permission denied/'o1;mv o1 out + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/interactive-always b/tests/rm/interactive-always deleted file mode 100755 index 6312cba1c..000000000 --- a/tests/rm/interactive-always +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -# Test the --interactive[=WHEN] changes added to coreutils 6.0 - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 file4-2 \ - || framework_failure_ -# If asked, answer no to first question, then yes to second. -echo 'n -y' > in || framework_failure_ -rm -f out err || framework_failure_ - - -# The prompt has a trailing space, and no newline, so an extra -# 'echo .' is inserted after each rm to make it obvious what was asked. - -echo 'no WHEN' > err || fail=1 -rm -R --interactive file1-* < in >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file1-1 || fail=1 -test -f file1-2 && fail=1 - -echo 'WHEN=never' >> err || fail=1 -rm -R --interactive=never file2-* < in >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file2-1 && fail=1 -test -f file2-2 && fail=1 - -echo 'WHEN=once' >> err || fail=1 -rm -R --interactive=once file3-* < in >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file3-1 || fail=1 -test -f file3-2 || fail=1 - -echo 'WHEN=always' >> err || fail=1 -rm -R --interactive=always file4-* < in >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file4-1 || fail=1 -test -f file4-2 && fail=1 - -echo '-f overrides --interactive' >> err || fail=1 -rm -R --interactive=once -f file1-* < in >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file1-1 && fail=1 - -echo '--interactive overrides -f' >> err || fail=1 -rm -R -f --interactive=once file4-* < in >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file4-1 || fail=1 - -cat <<\EOF > expout || fail=1 -EOF -sed 's/@remove_empty/rm: remove regular empty file/g' <<\EOF > experr || fail=1 -no WHEN -@remove_empty 'file1-1'? @remove_empty 'file1-2'? . -WHEN=never -. -WHEN=once -rm: remove all arguments recursively? . -WHEN=always -@remove_empty 'file4-1'? @remove_empty 'file4-2'? . --f overrides --interactive -. ---interactive overrides -f -rm: remove all arguments recursively? . -EOF - -compare expout out || fail=1 -compare experr err || fail=1 - -Exit $fail diff --git a/tests/rm/interactive-always.sh b/tests/rm/interactive-always.sh new file mode 100755 index 000000000..6312cba1c --- /dev/null +++ b/tests/rm/interactive-always.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# Test the --interactive[=WHEN] changes added to coreutils 6.0 + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 file4-2 \ + || framework_failure_ +# If asked, answer no to first question, then yes to second. +echo 'n +y' > in || framework_failure_ +rm -f out err || framework_failure_ + + +# The prompt has a trailing space, and no newline, so an extra +# 'echo .' is inserted after each rm to make it obvious what was asked. + +echo 'no WHEN' > err || fail=1 +rm -R --interactive file1-* < in >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file1-1 || fail=1 +test -f file1-2 && fail=1 + +echo 'WHEN=never' >> err || fail=1 +rm -R --interactive=never file2-* < in >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file2-1 && fail=1 +test -f file2-2 && fail=1 + +echo 'WHEN=once' >> err || fail=1 +rm -R --interactive=once file3-* < in >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file3-1 || fail=1 +test -f file3-2 || fail=1 + +echo 'WHEN=always' >> err || fail=1 +rm -R --interactive=always file4-* < in >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file4-1 || fail=1 +test -f file4-2 && fail=1 + +echo '-f overrides --interactive' >> err || fail=1 +rm -R --interactive=once -f file1-* < in >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file1-1 && fail=1 + +echo '--interactive overrides -f' >> err || fail=1 +rm -R -f --interactive=once file4-* < in >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file4-1 || fail=1 + +cat <<\EOF > expout || fail=1 +EOF +sed 's/@remove_empty/rm: remove regular empty file/g' <<\EOF > experr || fail=1 +no WHEN +@remove_empty 'file1-1'? @remove_empty 'file1-2'? . +WHEN=never +. +WHEN=once +rm: remove all arguments recursively? . +WHEN=always +@remove_empty 'file4-1'? @remove_empty 'file4-2'? . +-f overrides --interactive +. +--interactive overrides -f +rm: remove all arguments recursively? . +EOF + +compare expout out || fail=1 +compare experr err || fail=1 + +Exit $fail diff --git a/tests/rm/interactive-once b/tests/rm/interactive-once deleted file mode 100755 index 982d1a4d3..000000000 --- a/tests/rm/interactive-once +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh -# Test the -I option added to coreutils 6.0 - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir -p dir1-1 dir2-1 dir2-2 || framework_failure_ -touch file1-1 file2-1 file2-2 file2-3 file3-1 file3-2 file3-3 file3-4 \ - || framework_failure_ -echo y > in-y || framework_failure_ -echo n > in-n || framework_failure_ -rm -f out err || framework_failure_ - - -# The prompt has a trailing space, and no newline, so an extra -# 'echo .' is inserted after each rm to make it obvious what was asked. - -echo 'one file, no recursion' > err || fail=1 -rm -I file1-* < in-n >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file1-1 && fail=1 - -echo 'three files, no recursion' >> err || fail=1 -rm -I file2-* < in-n >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file2-1 && fail=1 -test -f file2-2 && fail=1 -test -f file2-3 && fail=1 - -echo 'four files, no recursion, answer no' >> err || fail=1 -rm -I file3-* < in-n >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file3-1 || fail=1 -test -f file3-2 || fail=1 -test -f file3-3 || fail=1 -test -f file3-4 || fail=1 - -echo 'four files, no recursion, answer yes' >> err || fail=1 -rm -I file3-* < in-y >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -f file3-1 && fail=1 -test -f file3-2 && fail=1 -test -f file3-3 && fail=1 -test -f file3-4 && fail=1 - -echo 'one file, recursion, answer no' >> err || fail=1 -rm -I -R dir1-* < in-n >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -d dir1-1 || fail=1 - -echo 'one file, recursion, answer yes' >> err || fail=1 -rm -I -R dir1-* < in-y >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -d dir1-1 && fail=1 - -echo 'multiple files, recursion, answer no' >> err || fail=1 -rm -I -R dir2-* < in-n >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -d dir2-1 || fail=1 -test -d dir2-2 || fail=1 - -echo 'multiple files, recursion, answer yes' >> err || fail=1 -rm -I -R dir2-* < in-y >> out 2>> err || fail=1 -echo . >> err || fail=1 -test -d dir2-1 && fail=1 -test -d dir2-2 && fail=1 - -cat <<\EOF > expout || fail=1 -EOF -cat <<\EOF > experr || fail=1 -one file, no recursion -. -three files, no recursion -. -four files, no recursion, answer no -rm: remove all arguments? . -four files, no recursion, answer yes -rm: remove all arguments? . -one file, recursion, answer no -rm: remove all arguments recursively? . -one file, recursion, answer yes -rm: remove all arguments recursively? . -multiple files, recursion, answer no -rm: remove all arguments recursively? . -multiple files, recursion, answer yes -rm: remove all arguments recursively? . -EOF - -compare expout out || fail=1 -compare experr err || fail=1 - -Exit $fail diff --git a/tests/rm/interactive-once.sh b/tests/rm/interactive-once.sh new file mode 100755 index 000000000..982d1a4d3 --- /dev/null +++ b/tests/rm/interactive-once.sh @@ -0,0 +1,107 @@ +#!/bin/sh +# Test the -I option added to coreutils 6.0 + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir -p dir1-1 dir2-1 dir2-2 || framework_failure_ +touch file1-1 file2-1 file2-2 file2-3 file3-1 file3-2 file3-3 file3-4 \ + || framework_failure_ +echo y > in-y || framework_failure_ +echo n > in-n || framework_failure_ +rm -f out err || framework_failure_ + + +# The prompt has a trailing space, and no newline, so an extra +# 'echo .' is inserted after each rm to make it obvious what was asked. + +echo 'one file, no recursion' > err || fail=1 +rm -I file1-* < in-n >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file1-1 && fail=1 + +echo 'three files, no recursion' >> err || fail=1 +rm -I file2-* < in-n >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file2-1 && fail=1 +test -f file2-2 && fail=1 +test -f file2-3 && fail=1 + +echo 'four files, no recursion, answer no' >> err || fail=1 +rm -I file3-* < in-n >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file3-1 || fail=1 +test -f file3-2 || fail=1 +test -f file3-3 || fail=1 +test -f file3-4 || fail=1 + +echo 'four files, no recursion, answer yes' >> err || fail=1 +rm -I file3-* < in-y >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -f file3-1 && fail=1 +test -f file3-2 && fail=1 +test -f file3-3 && fail=1 +test -f file3-4 && fail=1 + +echo 'one file, recursion, answer no' >> err || fail=1 +rm -I -R dir1-* < in-n >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -d dir1-1 || fail=1 + +echo 'one file, recursion, answer yes' >> err || fail=1 +rm -I -R dir1-* < in-y >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -d dir1-1 && fail=1 + +echo 'multiple files, recursion, answer no' >> err || fail=1 +rm -I -R dir2-* < in-n >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -d dir2-1 || fail=1 +test -d dir2-2 || fail=1 + +echo 'multiple files, recursion, answer yes' >> err || fail=1 +rm -I -R dir2-* < in-y >> out 2>> err || fail=1 +echo . >> err || fail=1 +test -d dir2-1 && fail=1 +test -d dir2-2 && fail=1 + +cat <<\EOF > expout || fail=1 +EOF +cat <<\EOF > experr || fail=1 +one file, no recursion +. +three files, no recursion +. +four files, no recursion, answer no +rm: remove all arguments? . +four files, no recursion, answer yes +rm: remove all arguments? . +one file, recursion, answer no +rm: remove all arguments recursively? . +one file, recursion, answer yes +rm: remove all arguments recursively? . +multiple files, recursion, answer no +rm: remove all arguments recursively? . +multiple files, recursion, answer yes +rm: remove all arguments recursively? . +EOF + +compare expout out || fail=1 +compare experr err || fail=1 + +Exit $fail diff --git a/tests/rm/ir-1 b/tests/rm/ir-1 deleted file mode 100755 index 01b33bc1e..000000000 --- a/tests/rm/ir-1 +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# Test "rm -ir". - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -t=t -mkdir -p $t $t/a $t/b $t/c || framework_failure_ -> $t/a/a || framework_failure_ -> $t/b/bb || framework_failure_ -> $t/c/cc || framework_failure_ - -cat < in -y -y -y -y -y -y -y -y -n -n -n -EOF - -# Remove all but one of a, b, c -- I doubt that this test can portably -# determine which one was removed based on order of dir entries. -# This is a good argument for switching to a dejagnu-style test suite. -rm --verbose -i -r $t < in > /dev/null 2>&1 || fail=1 - -# $t should not have been removed. -test -d $t || fail=1 - -# There should be only one directory left. -case $(echo $t/*) in - $t/[abc]) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/rm/ir-1.sh b/tests/rm/ir-1.sh new file mode 100755 index 000000000..01b33bc1e --- /dev/null +++ b/tests/rm/ir-1.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Test "rm -ir". + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +t=t +mkdir -p $t $t/a $t/b $t/c || framework_failure_ +> $t/a/a || framework_failure_ +> $t/b/bb || framework_failure_ +> $t/c/cc || framework_failure_ + +cat < in +y +y +y +y +y +y +y +y +n +n +n +EOF + +# Remove all but one of a, b, c -- I doubt that this test can portably +# determine which one was removed based on order of dir entries. +# This is a good argument for switching to a dejagnu-style test suite. +rm --verbose -i -r $t < in > /dev/null 2>&1 || fail=1 + +# $t should not have been removed. +test -d $t || fail=1 + +# There should be only one directory left. +case $(echo $t/*) in + $t/[abc]) ;; + *) fail=1 ;; +esac + +Exit $fail diff --git a/tests/rm/isatty b/tests/rm/isatty deleted file mode 100755 index f28653cc8..000000000 --- a/tests/rm/isatty +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# Make sure 'chown 0 f; rm f' prompts before removing f. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - - -# Skip this test if there is no /dev/stdin file. -ls /dev/stdin >/dev/null 2>&1 \ - || skip_ 'there is no /dev/stdin file' - -touch f -chmod 0 f -rm ---presume-input-tty f > out 2>&1 & -pid=$! - -# Wait a second, to give a buggy rm (as in fileutils-4.0.40) -# enough time to remove the file. -sleep 1 - -# The file must still exist. -test -f f || fail=1 - -kill $pid > /dev/null 2>&1 - -# Note the trailing 'x' -- so I don't have to have a trailing -# blank in this file :-) -cat > exp <<\EOF -rm: remove write-protected regular empty file 'f'? x -EOF - -# Append an 'x' and a newline. -echo x >> out - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/isatty.sh b/tests/rm/isatty.sh new file mode 100755 index 000000000..f28653cc8 --- /dev/null +++ b/tests/rm/isatty.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Make sure 'chown 0 f; rm f' prompts before removing f. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + + +# Skip this test if there is no /dev/stdin file. +ls /dev/stdin >/dev/null 2>&1 \ + || skip_ 'there is no /dev/stdin file' + +touch f +chmod 0 f +rm ---presume-input-tty f > out 2>&1 & +pid=$! + +# Wait a second, to give a buggy rm (as in fileutils-4.0.40) +# enough time to remove the file. +sleep 1 + +# The file must still exist. +test -f f || fail=1 + +kill $pid > /dev/null 2>&1 + +# Note the trailing 'x' -- so I don't have to have a trailing +# blank in this file :-) +cat > exp <<\EOF +rm: remove write-protected regular empty file 'f'? x +EOF + +# Append an 'x' and a newline. +echo x >> out + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/many-dir-entries-vs-OOM b/tests/rm/many-dir-entries-vs-OOM deleted file mode 100755 index b5f10dac4..000000000 --- a/tests/rm/many-dir-entries-vs-OOM +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# In coreutils-8.12, rm,du,chmod, etc. would use too much memory -# when processing a directory with many entries (as in > 100,000). - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm du chmod - -expensive_ - -# With many files in a single directory... -mkdir d && cd d || framework_failure_ -seq 200000|xargs touch || framework_failure_ - -cd .. - -# Restricted to 40MB, each of these coreutils-8.12 programs would fail -# with a diagnostic like "rm: fts_read failed: Cannot allocate memory". -ulimit -v 40000 -du -sh d || fail=1 -chmod -R 700 d || fail=1 -rm -rf d || fail=1 - -Exit $fail diff --git a/tests/rm/many-dir-entries-vs-OOM.sh b/tests/rm/many-dir-entries-vs-OOM.sh new file mode 100755 index 000000000..b5f10dac4 --- /dev/null +++ b/tests/rm/many-dir-entries-vs-OOM.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# In coreutils-8.12, rm,du,chmod, etc. would use too much memory +# when processing a directory with many entries (as in > 100,000). + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm du chmod + +expensive_ + +# With many files in a single directory... +mkdir d && cd d || framework_failure_ +seq 200000|xargs touch || framework_failure_ + +cd .. + +# Restricted to 40MB, each of these coreutils-8.12 programs would fail +# with a diagnostic like "rm: fts_read failed: Cannot allocate memory". +ulimit -v 40000 +du -sh d || fail=1 +chmod -R 700 d || fail=1 +rm -rf d || fail=1 + +Exit $fail diff --git a/tests/rm/no-give-up b/tests/rm/no-give-up deleted file mode 100755 index 0deb262a4..000000000 --- a/tests/rm/no-give-up +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# With rm from coreutils-5.2.1 and earlier, 'rm -r' would mistakenly -# give up too early under some conditions. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -require_root_ - -mkdir d || framework_failure_ -touch d/f || framework_failure_ -chown -R $NON_ROOT_USERNAME d || framework_failure_ - -# Ensure that non-root can access files in root-owned ".". -chmod go=x . || framework_failure_ - - -# This must fail, since '.' is not writable by $NON_ROOT_USERNAME. -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf d 2>/dev/null && fail=1 - -# d must remain. -test -d d || fail=1 - -# f must have been removed. -test -f d/f && fail=1 - -Exit $fail diff --git a/tests/rm/no-give-up.sh b/tests/rm/no-give-up.sh new file mode 100755 index 000000000..0deb262a4 --- /dev/null +++ b/tests/rm/no-give-up.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# With rm from coreutils-5.2.1 and earlier, 'rm -r' would mistakenly +# give up too early under some conditions. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +require_root_ + +mkdir d || framework_failure_ +touch d/f || framework_failure_ +chown -R $NON_ROOT_USERNAME d || framework_failure_ + +# Ensure that non-root can access files in root-owned ".". +chmod go=x . || framework_failure_ + + +# This must fail, since '.' is not writable by $NON_ROOT_USERNAME. +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf d 2>/dev/null && fail=1 + +# d must remain. +test -d d || fail=1 + +# f must have been removed. +test -f d/f && fail=1 + +Exit $fail diff --git a/tests/rm/one-file-system b/tests/rm/one-file-system deleted file mode 100755 index 675c3fd0a..000000000 --- a/tests/rm/one-file-system +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# Demonstrate rm's new --one-file-system option. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -require_root_ - -cleanup_() -{ - # When you take the undesirable shortcut of making /etc/mtab a link - # to /proc/mounts, unmounting "$other_partition_tmpdir" would fail. - # So, here we unmount a/b instead. - umount a/b - rm -rf "$other_partition_tmpdir" -} -. "$abs_srcdir/other-fs-tmpdir" - -t=$other_partition_tmpdir -mkdir -p a/b $t/y -mount --bind $t a/b \ - || skip_ "This test requires mount with a working --bind option." - -cat <<\EOF > exp || framework_failure_ -rm: skipping 'a/b', since it's on a different device -EOF - - -rm --one-file-system -rf a 2> out && fail=1 -test -d $t/y || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/one-file-system.sh b/tests/rm/one-file-system.sh new file mode 100755 index 000000000..675c3fd0a --- /dev/null +++ b/tests/rm/one-file-system.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Demonstrate rm's new --one-file-system option. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +require_root_ + +cleanup_() +{ + # When you take the undesirable shortcut of making /etc/mtab a link + # to /proc/mounts, unmounting "$other_partition_tmpdir" would fail. + # So, here we unmount a/b instead. + umount a/b + rm -rf "$other_partition_tmpdir" +} +. "$abs_srcdir/other-fs-tmpdir" + +t=$other_partition_tmpdir +mkdir -p a/b $t/y +mount --bind $t a/b \ + || skip_ "This test requires mount with a working --bind option." + +cat <<\EOF > exp || framework_failure_ +rm: skipping 'a/b', since it's on a different device +EOF + + +rm --one-file-system -rf a 2> out && fail=1 +test -d $t/y || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/one-file-system2 b/tests/rm/one-file-system2 deleted file mode 100755 index 077df76e6..000000000 --- a/tests/rm/one-file-system2 +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Verify --one-file-system does delete within a file system - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir -p a/b - -rm --one-file-system -rf a || fail=1 -test -d a && fail=1 - -Exit $fail diff --git a/tests/rm/one-file-system2.sh b/tests/rm/one-file-system2.sh new file mode 100755 index 000000000..077df76e6 --- /dev/null +++ b/tests/rm/one-file-system2.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Verify --one-file-system does delete within a file system + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir -p a/b + +rm --one-file-system -rf a || fail=1 +test -d a && fail=1 + +Exit $fail diff --git a/tests/rm/r-1 b/tests/rm/r-1 deleted file mode 100755 index 858269d75..000000000 --- a/tests/rm/r-1 +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Test "rm -r --verbose". - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir a a/a || framework_failure_ -> b || framework_failure_ - -cat <<\EOF > exp || framework_failure_ -removed directory: 'a/a' -removed directory: 'a' -removed 'b' -EOF - -rm --verbose -r a b > out || fail=1 - -for d in $dirs; do - test -d $d && fail=1 -done - -# Compare expected and actual output. -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/r-1.sh b/tests/rm/r-1.sh new file mode 100755 index 000000000..858269d75 --- /dev/null +++ b/tests/rm/r-1.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Test "rm -r --verbose". + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir a a/a || framework_failure_ +> b || framework_failure_ + +cat <<\EOF > exp || framework_failure_ +removed directory: 'a/a' +removed directory: 'a' +removed 'b' +EOF + +rm --verbose -r a b > out || fail=1 + +for d in $dirs; do + test -d $d && fail=1 +done + +# Compare expected and actual output. +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/r-2 b/tests/rm/r-2 deleted file mode 100755 index c946f63db..000000000 --- a/tests/rm/r-2 +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# Test "rm -r --verbose". - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir t t/a t/a/b || framework_failure_ -> t/a/f || framework_failure_ -> t/a/b/g || framework_failure_ - -# FIXME: if this fails, it's a framework failure -cat <<\EOF | sort > t/E || framework_failure_ -removed directory: 't/a' -removed directory: 't/a/b' -removed 't/a/b/g' -removed 't/a/f' -EOF - -# Note that both the expected output (above) and the actual output lines -# are sorted, because directory entries may be processed in arbitrary order. -rm --verbose -r t/a | sort > t/O || fail=1 - -if test -d t/a; then - fail=1 -fi - -# Compare expected and actual output. -cmp t/E t/O || fail=1 - -Exit $fail diff --git a/tests/rm/r-2.sh b/tests/rm/r-2.sh new file mode 100755 index 000000000..c946f63db --- /dev/null +++ b/tests/rm/r-2.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Test "rm -r --verbose". + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir t t/a t/a/b || framework_failure_ +> t/a/f || framework_failure_ +> t/a/b/g || framework_failure_ + +# FIXME: if this fails, it's a framework failure +cat <<\EOF | sort > t/E || framework_failure_ +removed directory: 't/a' +removed directory: 't/a/b' +removed 't/a/b/g' +removed 't/a/f' +EOF + +# Note that both the expected output (above) and the actual output lines +# are sorted, because directory entries may be processed in arbitrary order. +rm --verbose -r t/a | sort > t/O || fail=1 + +if test -d t/a; then + fail=1 +fi + +# Compare expected and actual output. +cmp t/E t/O || fail=1 + +Exit $fail diff --git a/tests/rm/r-3 b/tests/rm/r-3 deleted file mode 100755 index 71c8a0f64..000000000 --- a/tests/rm/r-3 +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# Create and remove a directory with more than 254 files. - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -# An early version of my rewritten rm failed to remove all of -# the files on SunOS4 when there were 254 or more in a directory. - -# And the rm from coreutils-5.0 exposes the same problem when there -# are 338 or more files in a directory on a Darwin-6.5 system - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir t || framework_failure_ -cd t || framework_failure_ - -# Create 500 files (20 * 25). -for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j; do - files= - for j in a b c d e f g h i j k l m n o p q r s t u v w x y; do - files="$files $i$j" - done - touch $files || framework_failure_ -done - -test -f 0a || framework_failure_ -test -f by || framework_failure_ -cd .. || framework_failure_ - -rm -rf t || fail=1 -test -d t && fail=1 - -Exit $fail diff --git a/tests/rm/r-3.sh b/tests/rm/r-3.sh new file mode 100755 index 000000000..71c8a0f64 --- /dev/null +++ b/tests/rm/r-3.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Create and remove a directory with more than 254 files. + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# An early version of my rewritten rm failed to remove all of +# the files on SunOS4 when there were 254 or more in a directory. + +# And the rm from coreutils-5.0 exposes the same problem when there +# are 338 or more files in a directory on a Darwin-6.5 system + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir t || framework_failure_ +cd t || framework_failure_ + +# Create 500 files (20 * 25). +for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j; do + files= + for j in a b c d e f g h i j k l m n o p q r s t u v w x y; do + files="$files $i$j" + done + touch $files || framework_failure_ +done + +test -f 0a || framework_failure_ +test -f by || framework_failure_ +cd .. || framework_failure_ + +rm -rf t || fail=1 +test -d t && fail=1 + +Exit $fail diff --git a/tests/rm/r-4 b/tests/rm/r-4 deleted file mode 100755 index 0bfb76072..000000000 --- a/tests/rm/r-4 +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Try to remove '.' and '..' recursively. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir d || framework_failure_ -touch d/a || framework_failure_ - -rm -fr d/. 2>/dev/null && fail=1 -rm -fr d/./ 2>/dev/null && fail=1 -rm -fr d/.//// 2>/dev/null && fail=1 -rm -fr d/.. 2>/dev/null && fail=1 -rm -fr d/../ 2>/dev/null && fail=1 - -# This test is too dangerous -- if there's a bug you're wiped out! -# rm -fr / 2>/dev/null && fail=1 - -test -f d/a || fail=1 - -Exit $fail diff --git a/tests/rm/r-4.sh b/tests/rm/r-4.sh new file mode 100755 index 000000000..0bfb76072 --- /dev/null +++ b/tests/rm/r-4.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Try to remove '.' and '..' recursively. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir d || framework_failure_ +touch d/a || framework_failure_ + +rm -fr d/. 2>/dev/null && fail=1 +rm -fr d/./ 2>/dev/null && fail=1 +rm -fr d/.//// 2>/dev/null && fail=1 +rm -fr d/.. 2>/dev/null && fail=1 +rm -fr d/../ 2>/dev/null && fail=1 + +# This test is too dangerous -- if there's a bug you're wiped out! +# rm -fr / 2>/dev/null && fail=1 + +test -f d/a || fail=1 + +Exit $fail diff --git a/tests/rm/read-only b/tests/rm/read-only deleted file mode 100755 index 018648be0..000000000 --- a/tests/rm/read-only +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Ensure that rm -f nonexistent-file-on-read-only-fs succeeds. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -require_root_ - -cwd=$(pwd) -cleanup_() { cd /; umount "$cwd/mnt"; } - -skip=0 -# Create a file system, then mount it. -dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \ - || skip=1 -mkdir mnt || skip=1 -mkfs -t ext2 -F blob \ - || skip_ "failed to create ext2 file system" - -mount -oloop blob mnt || skip=1 -echo test > mnt/f || skip=1 -test -s mnt/f || skip=1 -mount -o remount,loop,ro mnt || skip=1 - -test $skip = 1 \ - && skip_ "insufficient mount/ext2 support" - -# Applying rm -f to a nonexistent file on a read-only file system must succeed. -rm -f mnt/no-such > out 2>&1 || fail=1 -# It must produce no diagnostic. -test -s out && fail=1 - -# However, trying to remove an existing file must fail. -rm -f mnt/f > out 2>&1 && fail=1 -# with a diagnostic. -test -s out || fail=1 - -Exit $fail diff --git a/tests/rm/read-only.sh b/tests/rm/read-only.sh new file mode 100755 index 000000000..018648be0 --- /dev/null +++ b/tests/rm/read-only.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Ensure that rm -f nonexistent-file-on-read-only-fs succeeds. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +require_root_ + +cwd=$(pwd) +cleanup_() { cd /; umount "$cwd/mnt"; } + +skip=0 +# Create a file system, then mount it. +dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \ + || skip=1 +mkdir mnt || skip=1 +mkfs -t ext2 -F blob \ + || skip_ "failed to create ext2 file system" + +mount -oloop blob mnt || skip=1 +echo test > mnt/f || skip=1 +test -s mnt/f || skip=1 +mount -o remount,loop,ro mnt || skip=1 + +test $skip = 1 \ + && skip_ "insufficient mount/ext2 support" + +# Applying rm -f to a nonexistent file on a read-only file system must succeed. +rm -f mnt/no-such > out 2>&1 || fail=1 +# It must produce no diagnostic. +test -s out && fail=1 + +# However, trying to remove an existing file must fail. +rm -f mnt/f > out 2>&1 && fail=1 +# with a diagnostic. +test -s out || fail=1 + +Exit $fail diff --git a/tests/rm/readdir-bug b/tests/rm/readdir-bug deleted file mode 100755 index 711e1bc0e..000000000 --- a/tests/rm/readdir-bug +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Exercise the Darwin/MacOS bug worked around on 2006-09-29, -# whereby rm would fail to remove all entries in a directory. - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -# Create a directory containing many files. -# What counts is a combination of the number of files and -# the lengths of their names. For details, see -# http://lists.gnu.org/archive/html/bug-coreutils/2006-09/msg00326.html -mkdir b || framework_failure_ -cd b || framework_failure_ -for i in $(seq 1 250); do - touch $(printf %040d $i) || framework_failure_ -done -cd .. || framework_failure_ - - -# On a buggy system, this would fail with the diagnostic, -# "cannot remove directory 'b': Directory not empty" -rm -rf b || fail=1 - -test -d b && fail=1 - -Exit $fail diff --git a/tests/rm/readdir-bug.sh b/tests/rm/readdir-bug.sh new file mode 100755 index 000000000..711e1bc0e --- /dev/null +++ b/tests/rm/readdir-bug.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Exercise the Darwin/MacOS bug worked around on 2006-09-29, +# whereby rm would fail to remove all entries in a directory. + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +# Create a directory containing many files. +# What counts is a combination of the number of files and +# the lengths of their names. For details, see +# http://lists.gnu.org/archive/html/bug-coreutils/2006-09/msg00326.html +mkdir b || framework_failure_ +cd b || framework_failure_ +for i in $(seq 1 250); do + touch $(printf %040d $i) || framework_failure_ +done +cd .. || framework_failure_ + + +# On a buggy system, this would fail with the diagnostic, +# "cannot remove directory 'b': Directory not empty" +rm -rf b || fail=1 + +test -d b && fail=1 + +Exit $fail diff --git a/tests/rm/rm1 b/tests/rm/rm1 deleted file mode 100755 index aa90c57cc..000000000 --- a/tests/rm/rm1 +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# exercise another small part of remove.c - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -p b/a/p b/c b/d || framework_failure_ -chmod u-w b/a || framework_failure_ - - -# This should fail. -rm -rf b > out 2>&1 && fail=1 -cat <<\EOF > exp -rm: cannot remove directory 'b/a/p': Permission denied -EOF - -# On some systems, rm doesn't have enough information to -# say it's a directory. -cat <<\EOF > exp2 -rm: cannot remove 'b/a/p': Permission denied -EOF - -cmp out exp > /dev/null 2>&1 || { - cmp out exp2 || fail=1 - } -test $fail = 1 && compare exp out - -test -d b/a/p || fail=1 -test -d b/c && fail=1 -test -d b/d && fail=1 - -Exit $fail diff --git a/tests/rm/rm1.sh b/tests/rm/rm1.sh new file mode 100755 index 000000000..aa90c57cc --- /dev/null +++ b/tests/rm/rm1.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# exercise another small part of remove.c + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -p b/a/p b/c b/d || framework_failure_ +chmod u-w b/a || framework_failure_ + + +# This should fail. +rm -rf b > out 2>&1 && fail=1 +cat <<\EOF > exp +rm: cannot remove directory 'b/a/p': Permission denied +EOF + +# On some systems, rm doesn't have enough information to +# say it's a directory. +cat <<\EOF > exp2 +rm: cannot remove 'b/a/p': Permission denied +EOF + +cmp out exp > /dev/null 2>&1 || { + cmp out exp2 || fail=1 + } +test $fail = 1 && compare exp out + +test -d b/a/p || fail=1 +test -d b/c && fail=1 +test -d b/d && fail=1 + +Exit $fail diff --git a/tests/rm/rm2 b/tests/rm/rm2 deleted file mode 100755 index 7bbdfeaba..000000000 --- a/tests/rm/rm2 +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# exercise another small part of remove.c - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -p a/0 || framework_failure_ -mkdir -p a/1/2 b/3 || framework_failure_ -mkdir a/2 a/3 || framework_failure_ -chmod u-x a/1 b || framework_failure_ - - -# Exercise two separate code paths -- though both result -# in the same sort of diagnostic. -# Both of these should fail. -rm -rf a b > out 2>&1 && fail=1 -cat <<\EOF > exp -rm: cannot remove 'a/1': Permission denied -rm: cannot remove 'b': Permission denied -EOF - -cat <<\EOF > exp-solaris -rm: cannot remove 'a/1/2': Permission denied -rm: cannot remove 'b/3': Permission denied -EOF - -cmp out exp > /dev/null 2>&1 \ - || { cmp out exp-solaris > /dev/null 2>&1 || fail=1; } -test $fail = 1 && compare exp out - -test -d a/0 && fail=1 -test -d a/1 || fail=1 -test -d a/2 && fail=1 -test -d a/3 && fail=1 - -chmod u+x b -test -d b/3 || fail=1 - -Exit $fail diff --git a/tests/rm/rm2.sh b/tests/rm/rm2.sh new file mode 100755 index 000000000..7bbdfeaba --- /dev/null +++ b/tests/rm/rm2.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# exercise another small part of remove.c + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -p a/0 || framework_failure_ +mkdir -p a/1/2 b/3 || framework_failure_ +mkdir a/2 a/3 || framework_failure_ +chmod u-x a/1 b || framework_failure_ + + +# Exercise two separate code paths -- though both result +# in the same sort of diagnostic. +# Both of these should fail. +rm -rf a b > out 2>&1 && fail=1 +cat <<\EOF > exp +rm: cannot remove 'a/1': Permission denied +rm: cannot remove 'b': Permission denied +EOF + +cat <<\EOF > exp-solaris +rm: cannot remove 'a/1/2': Permission denied +rm: cannot remove 'b/3': Permission denied +EOF + +cmp out exp > /dev/null 2>&1 \ + || { cmp out exp-solaris > /dev/null 2>&1 || fail=1; } +test $fail = 1 && compare exp out + +test -d a/0 && fail=1 +test -d a/1 || fail=1 +test -d a/2 && fail=1 +test -d a/3 && fail=1 + +chmod u+x b +test -d b/3 || fail=1 + +Exit $fail diff --git a/tests/rm/rm3 b/tests/rm/rm3 deleted file mode 100755 index 37ee87b22..000000000 --- a/tests/rm/rm3 +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# exercise another small part of remove.c - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -p z || framework_failure_ -cd z || framework_failure_ -touch empty empty-u || framework_failure_ -echo not-empty > fu -ln -s empty-f slink -ln -s . slinkdot -mkdir d du || framework_failure_ -chmod u-w fu du empty-u || framework_failure_ -cd .. - - -cat < in -y -y -y -y -y -y -y -y -y -EOF - -# Both of these should fail. -rm -ir z < in > out 2>&1 || fail=1 - -# Given input like 'rm: ...? rm: ...? ' (no trailing newline), -# the 'head...' part of the pipeline below removes the trailing space, so -# that sed doesn't have to deal with a line lacking a terminating newline. -# This avoids a bug whereby some vendor-provided (Tru64) versions of sed -# would mistakenly tack a newline onto the end of the output. -tr '?' '\n' < out | head --bytes=-1 | sed 's/^ //' |sort > o2 -mv o2 out - -sort < exp || fail=1 -rm: descend into directory 'z' -rm: remove regular empty file 'z/empty' -rm: remove write-protected regular file 'z/fu' -rm: remove write-protected regular empty file 'z/empty-u' -rm: remove symbolic link 'z/slink' -rm: remove symbolic link 'z/slinkdot' -rm: remove directory 'z/d' -rm: remove write-protected directory 'z/du' -rm: remove directory 'z' -EOF - -compare exp out || fail=1 - -test -d z && fail=1 - -Exit $fail diff --git a/tests/rm/rm3.sh b/tests/rm/rm3.sh new file mode 100755 index 000000000..37ee87b22 --- /dev/null +++ b/tests/rm/rm3.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# exercise another small part of remove.c + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -p z || framework_failure_ +cd z || framework_failure_ +touch empty empty-u || framework_failure_ +echo not-empty > fu +ln -s empty-f slink +ln -s . slinkdot +mkdir d du || framework_failure_ +chmod u-w fu du empty-u || framework_failure_ +cd .. + + +cat < in +y +y +y +y +y +y +y +y +y +EOF + +# Both of these should fail. +rm -ir z < in > out 2>&1 || fail=1 + +# Given input like 'rm: ...? rm: ...? ' (no trailing newline), +# the 'head...' part of the pipeline below removes the trailing space, so +# that sed doesn't have to deal with a line lacking a terminating newline. +# This avoids a bug whereby some vendor-provided (Tru64) versions of sed +# would mistakenly tack a newline onto the end of the output. +tr '?' '\n' < out | head --bytes=-1 | sed 's/^ //' |sort > o2 +mv o2 out + +sort < exp || fail=1 +rm: descend into directory 'z' +rm: remove regular empty file 'z/empty' +rm: remove write-protected regular file 'z/fu' +rm: remove write-protected regular empty file 'z/empty-u' +rm: remove symbolic link 'z/slink' +rm: remove symbolic link 'z/slinkdot' +rm: remove directory 'z/d' +rm: remove write-protected directory 'z/du' +rm: remove directory 'z' +EOF + +compare exp out || fail=1 + +test -d z && fail=1 + +Exit $fail diff --git a/tests/rm/rm4 b/tests/rm/rm4 deleted file mode 100755 index 3e22aad9d..000000000 --- a/tests/rm/rm4 +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# ensure that 'rm dir' fails without --recursive - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir dir || framework_failure_ - - -# This should fail. -rm dir > /dev/null 2>&1 && fail=1 - -test -d dir || fail=1 - -Exit $fail diff --git a/tests/rm/rm4.sh b/tests/rm/rm4.sh new file mode 100755 index 000000000..3e22aad9d --- /dev/null +++ b/tests/rm/rm4.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# ensure that 'rm dir' fails without --recursive + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir dir || framework_failure_ + + +# This should fail. +rm dir > /dev/null 2>&1 && fail=1 + +test -d dir || fail=1 + +Exit $fail diff --git a/tests/rm/rm5 b/tests/rm/rm5 deleted file mode 100755 index 56c6bbc26..000000000 --- a/tests/rm/rm5 +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# a basic test of rm -ri - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -p d/e || framework_failure_ -cat < in || framework_failure_ -y -y -y -EOF - -cat <<\EOF > exp || framework_failure_ -rm: descend into directory 'd' -rm: remove directory 'd/e' -rm: remove directory 'd' -EOF - - -rm -ir d < in > out 2>&1 || fail=1 - -# Given input like 'rm: ...? rm: ...? ' (no trailing newline), -# the 'head...' part of the pipeline below removes the trailing space, so -# that sed doesn't have to deal with a line lacking a terminating newline. -# This avoids a bug whereby some vendor-provided (Tru64) versions of sed -# would mistakenly tack a newline onto the end of the output. -tr '?' '\n' < out | head --bytes=-1 | sed 's/^ //' > o2 -mv o2 out - -# Make sure it's been removed. -test -d d && fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/rm5.sh b/tests/rm/rm5.sh new file mode 100755 index 000000000..56c6bbc26 --- /dev/null +++ b/tests/rm/rm5.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# a basic test of rm -ri + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -p d/e || framework_failure_ +cat < in || framework_failure_ +y +y +y +EOF + +cat <<\EOF > exp || framework_failure_ +rm: descend into directory 'd' +rm: remove directory 'd/e' +rm: remove directory 'd' +EOF + + +rm -ir d < in > out 2>&1 || fail=1 + +# Given input like 'rm: ...? rm: ...? ' (no trailing newline), +# the 'head...' part of the pipeline below removes the trailing space, so +# that sed doesn't have to deal with a line lacking a terminating newline. +# This avoids a bug whereby some vendor-provided (Tru64) versions of sed +# would mistakenly tack a newline onto the end of the output. +tr '?' '\n' < out | head --bytes=-1 | sed 's/^ //' > o2 +mv o2 out + +# Make sure it's been removed. +test -d d && fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/sunos-1 b/tests/rm/sunos-1 deleted file mode 100755 index 584236abc..000000000 --- a/tests/rm/sunos-1 +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# Make sure that rm -r '' fails. - -# Copyright (C) 1997-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -# On SunOS 4.1.3, running rm -r '' in a nonempty directory may -# actually remove files with names of entries in the current directory -# but relative to '/' rather than relative to the current directory. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -rm -r '' > /dev/null 2>&1 && fail=1 - -Exit $fail diff --git a/tests/rm/sunos-1.sh b/tests/rm/sunos-1.sh new file mode 100755 index 000000000..584236abc --- /dev/null +++ b/tests/rm/sunos-1.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Make sure that rm -r '' fails. + +# Copyright (C) 1997-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# On SunOS 4.1.3, running rm -r '' in a nonempty directory may +# actually remove files with names of entries in the current directory +# but relative to '/' rather than relative to the current directory. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +rm -r '' > /dev/null 2>&1 && fail=1 + +Exit $fail diff --git a/tests/rm/unread2 b/tests/rm/unread2 deleted file mode 100755 index 46fc98cd8..000000000 --- a/tests/rm/unread2 +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# exercise one small part of remove.c - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -p a/b || framework_failure_ -chmod u-r a - - -# This should fail. -rm -rf a > out 2>&1 && fail=1 -cat <<\EOF > exp -rm: cannot remove 'a': Permission denied -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/unread2.sh b/tests/rm/unread2.sh new file mode 100755 index 000000000..46fc98cd8 --- /dev/null +++ b/tests/rm/unread2.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# exercise one small part of remove.c + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -p a/b || framework_failure_ +chmod u-r a + + +# This should fail. +rm -rf a > out 2>&1 && fail=1 +cat <<\EOF > exp +rm: cannot remove 'a': Permission denied +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rm/unread3 b/tests/rm/unread3 deleted file mode 100755 index 4b8bbc2d3..000000000 --- a/tests/rm/unread3 +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Ensure that rm works even from an unreadable working directory. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm -skip_if_root_ - -mkdir -p a/1 b c d/2 e/3 || framework_failure_ - - -t=$(pwd) -cd c -chmod u=x,go= . - -# With coreutils-5.2.1, this would get a failed assertion. -rm -r "$t/a" "$t/b" || fail=1 - -# With coreutils-5.2.1, this would get the following: -# rm: cannot get current directory: Permission denied -# rm: failed to return to initial working directory: Bad file descriptor -rm -r "$t/d" "$t/e" || fail=1 - -test -d "$t/a" && fail=1 -test -d "$t/b" && fail=1 -test -d "$t/d" && fail=1 -test -d "$t/e" && fail=1 - -Exit $fail diff --git a/tests/rm/unread3.sh b/tests/rm/unread3.sh new file mode 100755 index 000000000..4b8bbc2d3 --- /dev/null +++ b/tests/rm/unread3.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Ensure that rm works even from an unreadable working directory. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm +skip_if_root_ + +mkdir -p a/1 b c d/2 e/3 || framework_failure_ + + +t=$(pwd) +cd c +chmod u=x,go= . + +# With coreutils-5.2.1, this would get a failed assertion. +rm -r "$t/a" "$t/b" || fail=1 + +# With coreutils-5.2.1, this would get the following: +# rm: cannot get current directory: Permission denied +# rm: failed to return to initial working directory: Bad file descriptor +rm -r "$t/d" "$t/e" || fail=1 + +test -d "$t/a" && fail=1 +test -d "$t/b" && fail=1 +test -d "$t/d" && fail=1 +test -d "$t/e" && fail=1 + +Exit $fail diff --git a/tests/rm/unreadable b/tests/rm/unreadable deleted file mode 100755 index ebc8511c2..000000000 --- a/tests/rm/unreadable +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl -# Test "rm" and unreadable directories. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -use strict; - -(my $program_name = $0) =~ s|.*/||; - -# Turn off localization of executable's output. -@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - -my $d = "dir-$$"; -my $mkdir = {PRE => sub {mkdir $d,0100 or die "$d: $!\n"}}; -my $prog = 'rm'; -my $uid = $<; - -my @Tests = - ( - # test-name options input expected-output - # - # Removing an empty, unwritable directory succeeds. - ['unreadable-1', '-rf', $d, {EXIT => 0}, $mkdir], - - ['unreadable-2', '-rf', $d, - {EXIT => $uid == 0 ? 0 : 1}, - {ERR => $uid == 0 ? '' - : "$prog: cannot remove '$d': Permission denied\n"}, - {PRE => sub { (mkdir $d,0700 and mkdir "$d/x",0700 and chmod 0100,$d) - or die "$d: $!\n"}} ], - ); - -my $save_temps = $ENV{SAVE_TEMPS}; -my $verbose = $ENV{VERBOSE}; - -my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); -exit $fail; diff --git a/tests/rm/unreadable.pl b/tests/rm/unreadable.pl new file mode 100755 index 000000000..ebc8511c2 --- /dev/null +++ b/tests/rm/unreadable.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +# Test "rm" and unreadable directories. + +# Copyright (C) 1998-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; + +(my $program_name = $0) =~ s|.*/||; + +# Turn off localization of executable's output. +@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + +my $d = "dir-$$"; +my $mkdir = {PRE => sub {mkdir $d,0100 or die "$d: $!\n"}}; +my $prog = 'rm'; +my $uid = $<; + +my @Tests = + ( + # test-name options input expected-output + # + # Removing an empty, unwritable directory succeeds. + ['unreadable-1', '-rf', $d, {EXIT => 0}, $mkdir], + + ['unreadable-2', '-rf', $d, + {EXIT => $uid == 0 ? 0 : 1}, + {ERR => $uid == 0 ? '' + : "$prog: cannot remove '$d': Permission denied\n"}, + {PRE => sub { (mkdir $d,0700 and mkdir "$d/x",0700 and chmod 0100,$d) + or die "$d: $!\n"}} ], + ); + +my $save_temps = $ENV{SAVE_TEMPS}; +my $verbose = $ENV{VERBOSE}; + +my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); +exit $fail; diff --git a/tests/rm/v-slash b/tests/rm/v-slash deleted file mode 100755 index 2fae859b2..000000000 --- a/tests/rm/v-slash +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# avoid extra slashes in --verbose output - -# Copyright (C) 2007-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rm - -mkdir a || framework_failure_ -touch a/x || framework_failure_ - - -rm --verbose -r a/// > out || fail=1 -cat <<\EOF > exp || fail=1 -removed 'a/x' -removed directory: 'a' -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/rm/v-slash.sh b/tests/rm/v-slash.sh new file mode 100755 index 000000000..2fae859b2 --- /dev/null +++ b/tests/rm/v-slash.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# avoid extra slashes in --verbose output + +# Copyright (C) 2007-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rm + +mkdir a || framework_failure_ +touch a/x || framework_failure_ + + +rm --verbose -r a/// > out || fail=1 +cat <<\EOF > exp || fail=1 +removed 'a/x' +removed directory: 'a' +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/rmdir/fail-perm b/tests/rmdir/fail-perm deleted file mode 100755 index 49cfb00ab..000000000 --- a/tests/rmdir/fail-perm +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# For unwritable directory 'd', 'rmdir -p d d/e/f' would emit -# diagnostics but would not fail. Fixed in 5.1.2. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rmdir - -mkdir d d/e d/e/f || framework_failure_ -chmod a-w d || framework_failure_ - - -# This rmdir command outputs two diagnostics. -# Before coreutils-5.1.2, it would mistakenly exit successfully. -# As of coreutils-5.1.2, it fails, as required. -rmdir -p d d/e/f 2> /dev/null && fail=1 - -Exit $fail diff --git a/tests/rmdir/fail-perm.sh b/tests/rmdir/fail-perm.sh new file mode 100755 index 000000000..49cfb00ab --- /dev/null +++ b/tests/rmdir/fail-perm.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# For unwritable directory 'd', 'rmdir -p d d/e/f' would emit +# diagnostics but would not fail. Fixed in 5.1.2. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rmdir + +mkdir d d/e d/e/f || framework_failure_ +chmod a-w d || framework_failure_ + + +# This rmdir command outputs two diagnostics. +# Before coreutils-5.1.2, it would mistakenly exit successfully. +# As of coreutils-5.1.2, it fails, as required. +rmdir -p d d/e/f 2> /dev/null && fail=1 + +Exit $fail diff --git a/tests/rmdir/ignore b/tests/rmdir/ignore deleted file mode 100755 index 92463b8d8..000000000 --- a/tests/rmdir/ignore +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# make sure rmdir's --ignore-fail-on-non-empty option works - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rmdir - -cwd=$(pwd) -mkdir -p "$cwd/a/b/c" "$cwd/a/x" || framework_failure_ - -rmdir -p --ignore-fail-on-non-empty "$cwd/a/b/c" || fail=1 -# $cwd/a/x should remain -test -d "$cwd/a/x" || fail=1 -# $cwd/a/b and $cwd/a/b/c should be gone -test -d "$cwd/a/b" && fail=1 -test -d "$cwd/a/b/c" && fail=1 - -Exit $fail diff --git a/tests/rmdir/ignore.sh b/tests/rmdir/ignore.sh new file mode 100755 index 000000000..92463b8d8 --- /dev/null +++ b/tests/rmdir/ignore.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# make sure rmdir's --ignore-fail-on-non-empty option works + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rmdir + +cwd=$(pwd) +mkdir -p "$cwd/a/b/c" "$cwd/a/x" || framework_failure_ + +rmdir -p --ignore-fail-on-non-empty "$cwd/a/b/c" || fail=1 +# $cwd/a/x should remain +test -d "$cwd/a/x" || fail=1 +# $cwd/a/b and $cwd/a/b/c should be gone +test -d "$cwd/a/b" && fail=1 +test -d "$cwd/a/b/c" && fail=1 + +Exit $fail diff --git a/tests/rmdir/t-slash b/tests/rmdir/t-slash deleted file mode 100755 index 38e9f20d7..000000000 --- a/tests/rmdir/t-slash +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# make sure rmdir -p works on a directory specified with a trailing slash - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ rmdir - -mkdir dir || framework_failure_ - - -# Prior to coreutils-4.5.2, this would fail with the following: -# rmdir: 'dir': No such file or directory -rmdir -p dir/ || fail=1 - -Exit $fail diff --git a/tests/rmdir/t-slash.sh b/tests/rmdir/t-slash.sh new file mode 100755 index 000000000..38e9f20d7 --- /dev/null +++ b/tests/rmdir/t-slash.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# make sure rmdir -p works on a directory specified with a trailing slash + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ rmdir + +mkdir dir || framework_failure_ + + +# Prior to coreutils-4.5.2, this would fail with the following: +# rmdir: 'dir': No such file or directory +rmdir -p dir/ || fail=1 + +Exit $fail diff --git a/tests/split/additional-suffix b/tests/split/additional-suffix deleted file mode 100755 index 8cfd3c1e6..000000000 --- a/tests/split/additional-suffix +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# show that 'split --additional-suffix=SUFFIX' works. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -printf '1\n2\n3\n4\n5\n' > in || framework_failure_ - -split --lines=2 --additional-suffix=.txt in > out || fail=1 -cat <<\EOF > exp-1 -1 -2 -EOF -cat <<\EOF > exp-2 -3 -4 -EOF -cat <<\EOF > exp-3 -5 -EOF - -compare exp-1 xaa.txt || fail=1 -compare exp-2 xab.txt || fail=1 -compare exp-3 xac.txt || fail=1 - -# Additional suffix must not contain slash -split --lines=2 --additional-suffix=a/b in 2>/dev/null > out && fail=1 - -Exit $fail diff --git a/tests/split/additional-suffix.sh b/tests/split/additional-suffix.sh new file mode 100755 index 000000000..8cfd3c1e6 --- /dev/null +++ b/tests/split/additional-suffix.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# show that 'split --additional-suffix=SUFFIX' works. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +printf '1\n2\n3\n4\n5\n' > in || framework_failure_ + +split --lines=2 --additional-suffix=.txt in > out || fail=1 +cat <<\EOF > exp-1 +1 +2 +EOF +cat <<\EOF > exp-2 +3 +4 +EOF +cat <<\EOF > exp-3 +5 +EOF + +compare exp-1 xaa.txt || fail=1 +compare exp-2 xab.txt || fail=1 +compare exp-3 xac.txt || fail=1 + +# Additional suffix must not contain slash +split --lines=2 --additional-suffix=a/b in 2>/dev/null > out && fail=1 + +Exit $fail diff --git a/tests/split/b-chunk b/tests/split/b-chunk deleted file mode 100755 index dd8b6cbdd..000000000 --- a/tests/split/b-chunk +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# test splitting into 3 chunks - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -# N can be greater than the file size -# in which case no data is extracted, or empty files are written -split -n 10 /dev/null || fail=1 -test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 -rm x?? - -# Ensure --elide-empty-files is honored -split -e -n 10 /dev/null || fail=1 -stat x?? 2>/dev/null && fail=1 - -printf '1\n2\n3\n4\n5\n' > in || framework_failure_ - -split -n 3 in > out || fail=1 -split -n 1/3 in > b1 || fail=1 -split -n 2/3 in > b2 || fail=1 -split -n 3/3 in > b3 || fail=1 -printf '1\n2' > exp-1 -printf '\n3\n' > exp-2 -printf '4\n5\n' > exp-3 - -compare exp-1 xaa || fail=1 -compare exp-2 xab || fail=1 -compare exp-3 xac || fail=1 -compare exp-1 b1 || fail=1 -compare exp-2 b2 || fail=1 -compare exp-3 b3 || fail=1 -test -f xad && fail=1 - -Exit $fail diff --git a/tests/split/b-chunk.sh b/tests/split/b-chunk.sh new file mode 100755 index 000000000..dd8b6cbdd --- /dev/null +++ b/tests/split/b-chunk.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# test splitting into 3 chunks + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +# N can be greater than the file size +# in which case no data is extracted, or empty files are written +split -n 10 /dev/null || fail=1 +test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 +rm x?? + +# Ensure --elide-empty-files is honored +split -e -n 10 /dev/null || fail=1 +stat x?? 2>/dev/null && fail=1 + +printf '1\n2\n3\n4\n5\n' > in || framework_failure_ + +split -n 3 in > out || fail=1 +split -n 1/3 in > b1 || fail=1 +split -n 2/3 in > b2 || fail=1 +split -n 3/3 in > b3 || fail=1 +printf '1\n2' > exp-1 +printf '\n3\n' > exp-2 +printf '4\n5\n' > exp-3 + +compare exp-1 xaa || fail=1 +compare exp-2 xab || fail=1 +compare exp-3 xac || fail=1 +compare exp-1 b1 || fail=1 +compare exp-2 b2 || fail=1 +compare exp-3 b3 || fail=1 +test -f xad && fail=1 + +Exit $fail diff --git a/tests/split/fail b/tests/split/fail deleted file mode 100755 index 83251e9e1..000000000 --- a/tests/split/fail +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -# split must fail when given length/count of zero. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split -getlimits_ - -touch in || framework_failure_ - - -split -a 0 in 2> /dev/null || fail=1 -split -b 0 in 2> /dev/null && fail=1 -split -C 0 in 2> /dev/null && fail=1 -split -l 0 in 2> /dev/null && fail=1 -split -n 0 in 2> /dev/null && fail=1 -split -n 1/0 in 2> /dev/null && fail=1 -split -n 0/1 in 2> /dev/null && fail=1 -split -n 2/1 in 2> /dev/null && fail=1 - -# Make sure -C doesn't create empty files. -rm -f x?? || fail=1 -echo x | split -C 1 || fail=1 -test -f xaa && test -f xab || fail=1 -test -f xac && fail=1 - -# Make sure that the obsolete -N notation still works -split -1 in 2> /dev/null || fail=1 - -# Then make sure that -0 evokes a failure. -split -0 in 2> /dev/null && fail=1 - -split --lines=$UINTMAX_MAX in || fail=1 -split --bytes=$OFF_T_MAX in || fail=1 -split --line-bytes=$OFF_T_OFLOW 2> /dev/null in && fail=1 -split --line-bytes=$SIZE_OFLOW 2> /dev/null in && fail=1 -if truncate -s$SIZE_OFLOW large; then - # Ensure we can split chunks of a large file on 32 bit hosts - split --number=$SIZE_OFLOW/$SIZE_OFLOW large >/dev/null || fail=1 -fi -split --number=r/$UINTMAX_MAX/$UINTMAX_MAX /dev/null || fail=1 -split --number=r/$UINTMAX_OFLOW /dev/null && fail=1 - -# Make sure that a huge obsolete option evokes the right failure. -split -99999999999999999991 2> out && fail=1 - -# On losing systems (x86 Solaris 5.9 c89), we get a message like this: -# split: line count option -9999999999... is too large -# while on most, we get this: -# split: line count option -99999999999999999991... is too large -# so map them both to -99*. -sed 's/99[19]*/99*/' out > out-t -mv -f out-t out - -cat <<\EOF > exp -split: line count option -99*... is too large -EOF -compare exp out || fail=1 - -# Make sure split fails when it can't read input -# (the current directory in this case) -if ! cat . >/dev/null; then - # can't read() directories - split . && fail=1 -fi - -Exit $fail diff --git a/tests/split/fail.sh b/tests/split/fail.sh new file mode 100755 index 000000000..83251e9e1 --- /dev/null +++ b/tests/split/fail.sh @@ -0,0 +1,81 @@ +#!/bin/sh +# split must fail when given length/count of zero. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split +getlimits_ + +touch in || framework_failure_ + + +split -a 0 in 2> /dev/null || fail=1 +split -b 0 in 2> /dev/null && fail=1 +split -C 0 in 2> /dev/null && fail=1 +split -l 0 in 2> /dev/null && fail=1 +split -n 0 in 2> /dev/null && fail=1 +split -n 1/0 in 2> /dev/null && fail=1 +split -n 0/1 in 2> /dev/null && fail=1 +split -n 2/1 in 2> /dev/null && fail=1 + +# Make sure -C doesn't create empty files. +rm -f x?? || fail=1 +echo x | split -C 1 || fail=1 +test -f xaa && test -f xab || fail=1 +test -f xac && fail=1 + +# Make sure that the obsolete -N notation still works +split -1 in 2> /dev/null || fail=1 + +# Then make sure that -0 evokes a failure. +split -0 in 2> /dev/null && fail=1 + +split --lines=$UINTMAX_MAX in || fail=1 +split --bytes=$OFF_T_MAX in || fail=1 +split --line-bytes=$OFF_T_OFLOW 2> /dev/null in && fail=1 +split --line-bytes=$SIZE_OFLOW 2> /dev/null in && fail=1 +if truncate -s$SIZE_OFLOW large; then + # Ensure we can split chunks of a large file on 32 bit hosts + split --number=$SIZE_OFLOW/$SIZE_OFLOW large >/dev/null || fail=1 +fi +split --number=r/$UINTMAX_MAX/$UINTMAX_MAX /dev/null || fail=1 +split --number=r/$UINTMAX_OFLOW /dev/null && fail=1 + +# Make sure that a huge obsolete option evokes the right failure. +split -99999999999999999991 2> out && fail=1 + +# On losing systems (x86 Solaris 5.9 c89), we get a message like this: +# split: line count option -9999999999... is too large +# while on most, we get this: +# split: line count option -99999999999999999991... is too large +# so map them both to -99*. +sed 's/99[19]*/99*/' out > out-t +mv -f out-t out + +cat <<\EOF > exp +split: line count option -99*... is too large +EOF +compare exp out || fail=1 + +# Make sure split fails when it can't read input +# (the current directory in this case) +if ! cat . >/dev/null; then + # can't read() directories + split . && fail=1 +fi + +Exit $fail diff --git a/tests/split/filter b/tests/split/filter deleted file mode 100755 index 7a55818e7..000000000 --- a/tests/split/filter +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# Exercise split's new --filter option. - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split -xz --version || skip_ "xz (better than gzip/bzip2) required" - -for total_n_lines in 5 3000 20000; do - seq $total_n_lines > in || framework_failure_ - for i in 2 51 598; do - - # Don't create too many files/processes. - # Starting 10k (or even "only" 1500) processes would take a long time, - # and would provide little added benefit. - case $i:$total_n_lines in 2:5);; *) continue;; esac - - split -l$i --filter='xz -1 > $FILE.xz' in out- || fail=1 - xz -dc out-* > out || fail=1 - compare in out || fail=1 - rm -f out* - done - rm -f in -done - -# Show how --elide-empty-files works with --filter: -# split does not run the command (and effectively elides the file) -# only when the output to that command would have been empty. -split -e -n 10 --filter='xz > $FILE.xz' /dev/null || fail=1 -stat x?? 2>/dev/null && fail=1 - -# Ensure this invalid combination is flagged -split -n 1/2 --filter='true' /dev/null 2>/dev/null && fail=1 - -# Ensure SIGPIPEs sent by the children don't propagate back -# where they would result in a non zero exit from split. -yes | head -n200K | split -b1G --filter='head -c1 >/dev/null' || fail=1 - -# Ensure that endless input is ignored when all filters finish -timeout 10 yes | split --filter="head -c1 >/dev/null" -n r/1 || fail=1 -timeout 10 split --filter="head -c1 >/dev/null" -n 1 /dev/zero || fail=1 - -Exit $fail diff --git a/tests/split/filter.sh b/tests/split/filter.sh new file mode 100755 index 000000000..7a55818e7 --- /dev/null +++ b/tests/split/filter.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Exercise split's new --filter option. + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split +xz --version || skip_ "xz (better than gzip/bzip2) required" + +for total_n_lines in 5 3000 20000; do + seq $total_n_lines > in || framework_failure_ + for i in 2 51 598; do + + # Don't create too many files/processes. + # Starting 10k (or even "only" 1500) processes would take a long time, + # and would provide little added benefit. + case $i:$total_n_lines in 2:5);; *) continue;; esac + + split -l$i --filter='xz -1 > $FILE.xz' in out- || fail=1 + xz -dc out-* > out || fail=1 + compare in out || fail=1 + rm -f out* + done + rm -f in +done + +# Show how --elide-empty-files works with --filter: +# split does not run the command (and effectively elides the file) +# only when the output to that command would have been empty. +split -e -n 10 --filter='xz > $FILE.xz' /dev/null || fail=1 +stat x?? 2>/dev/null && fail=1 + +# Ensure this invalid combination is flagged +split -n 1/2 --filter='true' /dev/null 2>/dev/null && fail=1 + +# Ensure SIGPIPEs sent by the children don't propagate back +# where they would result in a non zero exit from split. +yes | head -n200K | split -b1G --filter='head -c1 >/dev/null' || fail=1 + +# Ensure that endless input is ignored when all filters finish +timeout 10 yes | split --filter="head -c1 >/dev/null" -n r/1 || fail=1 +timeout 10 split --filter="head -c1 >/dev/null" -n 1 /dev/zero || fail=1 + +Exit $fail diff --git a/tests/split/guard-input b/tests/split/guard-input deleted file mode 100755 index 7a6fba3f5..000000000 --- a/tests/split/guard-input +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# ensure split doesn't overwrite input with output. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -seq 10 | tee exp-1 > xaa -ln -s xaa in2 -ln xaa in3 - -split -C 6 xaa && fail=1 -split -C 6 in2 && fail=1 -split -C 6 in3 && fail=1 -split -C 6 - < xaa && fail=1 - -compare exp-1 xaa || fail=1 - -Exit $fail diff --git a/tests/split/guard-input.sh b/tests/split/guard-input.sh new file mode 100755 index 000000000..7a6fba3f5 --- /dev/null +++ b/tests/split/guard-input.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# ensure split doesn't overwrite input with output. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +seq 10 | tee exp-1 > xaa +ln -s xaa in2 +ln xaa in3 + +split -C 6 xaa && fail=1 +split -C 6 in2 && fail=1 +split -C 6 in3 && fail=1 +split -C 6 - < xaa && fail=1 + +compare exp-1 xaa || fail=1 + +Exit $fail diff --git a/tests/split/l-chunk b/tests/split/l-chunk deleted file mode 100755 index 8199883a4..000000000 --- a/tests/split/l-chunk +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh -# test splitting into newline delineated chunks (-n l/...) - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -# invalid number of chunks -echo 'split: 1o: invalid number of chunks' > exp -split -n l/1o 2>err && fail=1 -compare exp err || fail=1 - -echo "split: '-': cannot determine file size" > exp -echo | split -n l/1 2>err && fail=1 -compare exp err || fail=1 - -# N can be greater than the file size -# in which case no data is extracted, or empty files are written -split -n l/10 /dev/null || fail=1 -test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 -rm x?? - -# Ensure the correct number of files written -# even if there is more data than the reported file size -split -n l/2 /dev/zero -test "$(stat -c %s x* | wc -l)" = '2' || fail=1 -rm x?? - -# Repeat the above, but with 1/2, not l/2: -split -n 1/2 /dev/zero || fail=1 - -# Ensure --elide-empty-files is honored -split -e -n l/10 /dev/null || fail=1 -stat x?? 2>/dev/null && fail=1 - -# 80 bytes. ~ transformed to \n below -lines=\ -12345~1~12345~1~12345~1~12345~1~12345~~~12345~1~12345~1~12345~1~12345~1~12345~1~ - -printf "%s" "$lines" | tr '~' '\n' > in || framework_failure_ - -echo 'split: 16: invalid chunk number' > exp -split -n l/16/15 in 2>err && fail=1 -compare exp err || fail=1 - -printf '%s' "\ -14 16 09 15 16 10 -14 08 08 10 14 08 08 10 -06 08 08 02 06 08 08 02 06 08 08 10 -06 08 02 06 08 00 08 02 06 08 02 06 08 00 10 -06 00 08 00 02 06 00 02 06 00 08 00 01 07 00 02 06 00 08 00 02 16 -" > exp || framework_failure_ - -sed 's/00 *//g' exp > exp.elide_empty || framework_failure_ - -DEBUGGING= -test "$DEBUGGING" && test "$VERBOSE" && set +x -for ELIDE_EMPTY in '' '-e'; do - for IO_BLKSIZE in 1 2 5 10 80 100; do - : > out - test "$DEBUGGING" && printf "\n---io-blk-size=$IO_BLKSIZE $ELIDE_EMPTY\n" - for N in 6 8 12 15 22; do - rm -f x* - - if test -z "$ELIDE_EMPTY"; then - split ---io-blksize=$IO_BLKSIZE -n l/2/$N in > chunk.k - stat x* 2>/dev/null && fail=1 - fi - - split ---io-blksize=$IO_BLKSIZE $ELIDE_EMPTY -n l/$N in - echo $(stat -c "%02s" x*) >> out - - if test -z "$ELIDE_EMPTY"; then - compare chunk.k xab || fail=1 - fi - - if test "$DEBUGGING"; then - # Output partition pattern - size=$(printf "%s" "$lines" | wc -c) - chunk_size=$(($size/$N)) - end_size=$(($chunk_size + ($size % $N))) - { - yes "$(printf %${chunk_size}s ])" | head -n$(($N-1)) - printf %${end_size}s ] - } | tr -d '\n' | sed "s/\\(^.\\{1,$size\\}\\).*/\\1/" - echo - - # Output pattern generated for comparison - for s in $(stat -c "%s" x*); do - #s=0 transitions are not shown - test "$m" = "_" && m=- || m=_ - printf "%${s}s" '' | tr ' ' $m - done - echo - - # Output lines for reference - echo "$lines" - fi - done - test -z "$ELIDE_EMPTY" && EXP=exp || EXP=exp.elide_empty - compare out $EXP || fail=1 - done -done -test "$DEBUGGING" && test "$VERBOSE" && set -x - - -# Check extraction of particular chunks -: > out -printf '1\n12345\n' > exp -split -n l/13/15 in > out -compare exp out || fail=1 -: > out -printf '' > exp -split -n l/14/15 in > out -compare exp out || fail=1 -: > out -printf '1\n12345\n1\n' > exp -split -n l/15/15 in > out -compare exp out || fail=1 - -# test input with no \n at end -printf '12\n34\n5' > in -printf '5' > exp -split -n l/7/7 in > out -compare exp out || fail=1 - -Exit $fail diff --git a/tests/split/l-chunk.sh b/tests/split/l-chunk.sh new file mode 100755 index 000000000..8199883a4 --- /dev/null +++ b/tests/split/l-chunk.sh @@ -0,0 +1,141 @@ +#!/bin/sh +# test splitting into newline delineated chunks (-n l/...) + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +# invalid number of chunks +echo 'split: 1o: invalid number of chunks' > exp +split -n l/1o 2>err && fail=1 +compare exp err || fail=1 + +echo "split: '-': cannot determine file size" > exp +echo | split -n l/1 2>err && fail=1 +compare exp err || fail=1 + +# N can be greater than the file size +# in which case no data is extracted, or empty files are written +split -n l/10 /dev/null || fail=1 +test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 +rm x?? + +# Ensure the correct number of files written +# even if there is more data than the reported file size +split -n l/2 /dev/zero +test "$(stat -c %s x* | wc -l)" = '2' || fail=1 +rm x?? + +# Repeat the above, but with 1/2, not l/2: +split -n 1/2 /dev/zero || fail=1 + +# Ensure --elide-empty-files is honored +split -e -n l/10 /dev/null || fail=1 +stat x?? 2>/dev/null && fail=1 + +# 80 bytes. ~ transformed to \n below +lines=\ +12345~1~12345~1~12345~1~12345~1~12345~~~12345~1~12345~1~12345~1~12345~1~12345~1~ + +printf "%s" "$lines" | tr '~' '\n' > in || framework_failure_ + +echo 'split: 16: invalid chunk number' > exp +split -n l/16/15 in 2>err && fail=1 +compare exp err || fail=1 + +printf '%s' "\ +14 16 09 15 16 10 +14 08 08 10 14 08 08 10 +06 08 08 02 06 08 08 02 06 08 08 10 +06 08 02 06 08 00 08 02 06 08 02 06 08 00 10 +06 00 08 00 02 06 00 02 06 00 08 00 01 07 00 02 06 00 08 00 02 16 +" > exp || framework_failure_ + +sed 's/00 *//g' exp > exp.elide_empty || framework_failure_ + +DEBUGGING= +test "$DEBUGGING" && test "$VERBOSE" && set +x +for ELIDE_EMPTY in '' '-e'; do + for IO_BLKSIZE in 1 2 5 10 80 100; do + : > out + test "$DEBUGGING" && printf "\n---io-blk-size=$IO_BLKSIZE $ELIDE_EMPTY\n" + for N in 6 8 12 15 22; do + rm -f x* + + if test -z "$ELIDE_EMPTY"; then + split ---io-blksize=$IO_BLKSIZE -n l/2/$N in > chunk.k + stat x* 2>/dev/null && fail=1 + fi + + split ---io-blksize=$IO_BLKSIZE $ELIDE_EMPTY -n l/$N in + echo $(stat -c "%02s" x*) >> out + + if test -z "$ELIDE_EMPTY"; then + compare chunk.k xab || fail=1 + fi + + if test "$DEBUGGING"; then + # Output partition pattern + size=$(printf "%s" "$lines" | wc -c) + chunk_size=$(($size/$N)) + end_size=$(($chunk_size + ($size % $N))) + { + yes "$(printf %${chunk_size}s ])" | head -n$(($N-1)) + printf %${end_size}s ] + } | tr -d '\n' | sed "s/\\(^.\\{1,$size\\}\\).*/\\1/" + echo + + # Output pattern generated for comparison + for s in $(stat -c "%s" x*); do + #s=0 transitions are not shown + test "$m" = "_" && m=- || m=_ + printf "%${s}s" '' | tr ' ' $m + done + echo + + # Output lines for reference + echo "$lines" + fi + done + test -z "$ELIDE_EMPTY" && EXP=exp || EXP=exp.elide_empty + compare out $EXP || fail=1 + done +done +test "$DEBUGGING" && test "$VERBOSE" && set -x + + +# Check extraction of particular chunks +: > out +printf '1\n12345\n' > exp +split -n l/13/15 in > out +compare exp out || fail=1 +: > out +printf '' > exp +split -n l/14/15 in > out +compare exp out || fail=1 +: > out +printf '1\n12345\n1\n' > exp +split -n l/15/15 in > out +compare exp out || fail=1 + +# test input with no \n at end +printf '12\n34\n5' > in +printf '5' > exp +split -n l/7/7 in > out +compare exp out || fail=1 + +Exit $fail diff --git a/tests/split/lines b/tests/split/lines deleted file mode 100755 index 35eb3eb2a..000000000 --- a/tests/split/lines +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# show that 'split --lines=2' works. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -printf '1\n2\n3\n4\n5\n' > in || framework_failure_ - -split --lines=2 in > out || fail=1 -cat <<\EOF > exp-1 -1 -2 -EOF -cat <<\EOF > exp-2 -3 -4 -EOF -cat <<\EOF > exp-3 -5 -EOF - -compare exp-1 xaa || fail=1 -compare exp-2 xab || fail=1 -compare exp-3 xac || fail=1 -test -f xad && fail=1 - -Exit $fail diff --git a/tests/split/lines.sh b/tests/split/lines.sh new file mode 100755 index 000000000..35eb3eb2a --- /dev/null +++ b/tests/split/lines.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# show that 'split --lines=2' works. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +printf '1\n2\n3\n4\n5\n' > in || framework_failure_ + +split --lines=2 in > out || fail=1 +cat <<\EOF > exp-1 +1 +2 +EOF +cat <<\EOF > exp-2 +3 +4 +EOF +cat <<\EOF > exp-3 +5 +EOF + +compare exp-1 xaa || fail=1 +compare exp-2 xab || fail=1 +compare exp-3 xac || fail=1 +test -f xad && fail=1 + +Exit $fail diff --git a/tests/split/numeric b/tests/split/numeric deleted file mode 100755 index ad22df621..000000000 --- a/tests/split/numeric +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Show that split --numeric-suffixes[=from] works. - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -# Check default start from 0 -printf '1\n2\n3\n4\n5\n' > in || framework_failure_ -split --numeric-suffixes --lines=2 in || fail=1 -cat <<\EOF > exp-1 -1 -2 -EOF -cat <<\EOF > exp-2 -3 -4 -EOF -cat <<\EOF > exp-3 -5 -EOF -compare exp-1 x00 || fail=1 -compare exp-2 x01 || fail=1 -compare exp-3 x02 || fail=1 - -# Check --numeric-suffixes=X -split --numeric-suffixes=1 --lines=2 in || fail=1 -cat <<\EOF > exp-1 -1 -2 -EOF -cat <<\EOF > exp-2 -3 -4 -EOF -cat <<\EOF > exp-3 -5 -EOF -compare exp-1 x01 || fail=1 -compare exp-2 x02 || fail=1 -compare exp-3 x03 || fail=1 - -# Check that split failed when suffix length is not large enough for -# the numerical suffix start value -split -a 3 --numeric-suffixes=1000 in 2> /dev/null && fail=1 - -# check invalid --numeric-suffixes start values are flagged -split --numeric-suffixes=-1 in 2> /dev/null && fail=1 -split --numeric-suffixes=one in 2> /dev/null && fail=1 - -Exit $fail diff --git a/tests/split/numeric.sh b/tests/split/numeric.sh new file mode 100755 index 000000000..ad22df621 --- /dev/null +++ b/tests/split/numeric.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Show that split --numeric-suffixes[=from] works. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +# Check default start from 0 +printf '1\n2\n3\n4\n5\n' > in || framework_failure_ +split --numeric-suffixes --lines=2 in || fail=1 +cat <<\EOF > exp-1 +1 +2 +EOF +cat <<\EOF > exp-2 +3 +4 +EOF +cat <<\EOF > exp-3 +5 +EOF +compare exp-1 x00 || fail=1 +compare exp-2 x01 || fail=1 +compare exp-3 x02 || fail=1 + +# Check --numeric-suffixes=X +split --numeric-suffixes=1 --lines=2 in || fail=1 +cat <<\EOF > exp-1 +1 +2 +EOF +cat <<\EOF > exp-2 +3 +4 +EOF +cat <<\EOF > exp-3 +5 +EOF +compare exp-1 x01 || fail=1 +compare exp-2 x02 || fail=1 +compare exp-3 x03 || fail=1 + +# Check that split failed when suffix length is not large enough for +# the numerical suffix start value +split -a 3 --numeric-suffixes=1000 in 2> /dev/null && fail=1 + +# check invalid --numeric-suffixes start values are flagged +split --numeric-suffixes=-1 in 2> /dev/null && fail=1 +split --numeric-suffixes=one in 2> /dev/null && fail=1 + +Exit $fail diff --git a/tests/split/r-chunk b/tests/split/r-chunk deleted file mode 100755 index afd9bf4be..000000000 --- a/tests/split/r-chunk +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# test splitting into round-robin chunks - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -require_ulimit_ - -# N can be greater than the file size -# in which case no data is extracted, or empty files are written -split -n r/10 /dev/null || fail=1 -test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 -rm x?? - -# Ensure --elide-empty-files is honored -split -e -n r/10 /dev/null || fail=1 -stat x?? 2>/dev/null && fail=1 - -printf '1\n2\n3\n4\n5\n' > in || framework_failure_ - -split -n r/3 in > out || fail=1 -test -s out && fail=1 - -split -n r/1/3 in > r1 || fail=1 -split -n r/2/3 in > r2 || fail=1 -split -n r/3/3 in > r3 || fail=1 - -printf '1\n4\n' > exp-1 -printf '2\n5\n' > exp-2 -printf '3\n' > exp-3 - -compare exp-1 xaa || fail=1 -compare exp-2 xab || fail=1 -compare exp-3 xac || fail=1 -compare exp-1 r1 || fail=1 -compare exp-2 r2 || fail=1 -compare exp-3 r3 || fail=1 -test -f xad && fail=1 - -# Test input without trailing \n -printf '1\n2\n3\n4\n5' | split -n r/2/3 > out -printf '2\n5' > exp -compare exp out || fail=1 - -# Ensure we fall back to appending to a file at a time -# if we hit the limit for the number of open files. -rm x* -(ulimit -n 20 && yes | head -n90 | split -n r/30 ) || fail=1 -test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "30x6" || fail=1 - -Exit $fail diff --git a/tests/split/r-chunk.sh b/tests/split/r-chunk.sh new file mode 100755 index 000000000..afd9bf4be --- /dev/null +++ b/tests/split/r-chunk.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# test splitting into round-robin chunks + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +require_ulimit_ + +# N can be greater than the file size +# in which case no data is extracted, or empty files are written +split -n r/10 /dev/null || fail=1 +test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "10x0" || fail=1 +rm x?? + +# Ensure --elide-empty-files is honored +split -e -n r/10 /dev/null || fail=1 +stat x?? 2>/dev/null && fail=1 + +printf '1\n2\n3\n4\n5\n' > in || framework_failure_ + +split -n r/3 in > out || fail=1 +test -s out && fail=1 + +split -n r/1/3 in > r1 || fail=1 +split -n r/2/3 in > r2 || fail=1 +split -n r/3/3 in > r3 || fail=1 + +printf '1\n4\n' > exp-1 +printf '2\n5\n' > exp-2 +printf '3\n' > exp-3 + +compare exp-1 xaa || fail=1 +compare exp-2 xab || fail=1 +compare exp-3 xac || fail=1 +compare exp-1 r1 || fail=1 +compare exp-2 r2 || fail=1 +compare exp-3 r3 || fail=1 +test -f xad && fail=1 + +# Test input without trailing \n +printf '1\n2\n3\n4\n5' | split -n r/2/3 > out +printf '2\n5' > exp +compare exp out || fail=1 + +# Ensure we fall back to appending to a file at a time +# if we hit the limit for the number of open files. +rm x* +(ulimit -n 20 && yes | head -n90 | split -n r/30 ) || fail=1 +test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "30x6" || fail=1 + +Exit $fail diff --git a/tests/split/suffix-auto-length b/tests/split/suffix-auto-length deleted file mode 100755 index dacc95158..000000000 --- a/tests/split/suffix-auto-length +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# Test the suffix auto widening functionality - -# Copyright (C) 2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - - -# ensure this feature is off when start number specified -truncate -s12 file.in -split file.in -b1 --numeric=89 && fail=1 -test "$(ls -1 x* | wc -l)" = 11 || fail=1 -rm -f x* - -# ensure this feature works when no start num specified -truncate -s91 file.in -for prefix in 'x' 'xx' ''; do - for add_suffix in '.txt' ''; do - split file.in "$prefix" -b1 --numeric --additional-suffix="$add_suffix" \ - || fail=1 - test "$(ls -1 $prefix*[0-9]*$add_suffix | wc -l)" = 91 || fail=1 - test -e "${prefix}89$add_suffix" || fail=1 - test -e "${prefix}9000$add_suffix" || fail=1 - rm -f $prefix*[0-9]*$add_suffix - done -done - -Exit $fail diff --git a/tests/split/suffix-auto-length.sh b/tests/split/suffix-auto-length.sh new file mode 100755 index 000000000..dacc95158 --- /dev/null +++ b/tests/split/suffix-auto-length.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Test the suffix auto widening functionality + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + + +# ensure this feature is off when start number specified +truncate -s12 file.in +split file.in -b1 --numeric=89 && fail=1 +test "$(ls -1 x* | wc -l)" = 11 || fail=1 +rm -f x* + +# ensure this feature works when no start num specified +truncate -s91 file.in +for prefix in 'x' 'xx' ''; do + for add_suffix in '.txt' ''; do + split file.in "$prefix" -b1 --numeric --additional-suffix="$add_suffix" \ + || fail=1 + test "$(ls -1 $prefix*[0-9]*$add_suffix | wc -l)" = 91 || fail=1 + test -e "${prefix}89$add_suffix" || fail=1 + test -e "${prefix}9000$add_suffix" || fail=1 + rm -f $prefix*[0-9]*$add_suffix + done +done + +Exit $fail diff --git a/tests/split/suffix-length b/tests/split/suffix-length deleted file mode 100755 index bc65e9f6d..000000000 --- a/tests/split/suffix-length +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -# Show that split -a works. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ split - -a_z='a b c d e f g h i j k l m n o p q r s t u v w x y z' - -# Generate a 27-byte file -printf %s $a_z 0 |tr -d ' ' > in || framework_failure_ - -files= -for i in $a_z; do - files="${files}xa$i " -done -files="${files}xba" - -for f in $files; do - printf "creating file '%s'"'\n' $f -done > exp || framework_failure_ - -echo split: output file suffixes exhausted \ - > exp-too-short || framework_failure_ - - -# This should fail. -split -b 1 -a 1 in 2> err && fail=1 -test -f xa || fail=1 -test -f xz || fail=1 -test -f xaa && fail=1 -test -f xaz && fail=1 -rm -f x* -compare exp-too-short err || fail=1 - -# With a longer suffix, it must succeed. -split --verbose -b 1 -a 2 in > err || fail=1 -compare exp err || fail=1 - -# Ensure that xbb is *not* created. -test -f xbb && fail=1 - -# Ensure that the 27 others files *were* created, and with expected contents. -n=1 -for f in $files; do - expected_byte=$(cut -b $n in) - b=$(cat $f) || fail=1 - test "$b" = "$expected_byte" || fail=1 - n=$(expr $n + 1) -done - -# Ensure that -a is independent of -[bCl] -split -a2 -b1000 < /dev/null || fail=1 -split -a2 -l1000 < /dev/null || fail=1 -split -a2 -C1000 < /dev/null || fail=1 - -# Ensure that -a fails early with a -n that is too large -rm -f x* -split -a2 -n1000 < /dev/null && fail=1 -test -f xaa && fail=1 - -Exit $fail diff --git a/tests/split/suffix-length.sh b/tests/split/suffix-length.sh new file mode 100755 index 000000000..bc65e9f6d --- /dev/null +++ b/tests/split/suffix-length.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# Show that split -a works. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ split + +a_z='a b c d e f g h i j k l m n o p q r s t u v w x y z' + +# Generate a 27-byte file +printf %s $a_z 0 |tr -d ' ' > in || framework_failure_ + +files= +for i in $a_z; do + files="${files}xa$i " +done +files="${files}xba" + +for f in $files; do + printf "creating file '%s'"'\n' $f +done > exp || framework_failure_ + +echo split: output file suffixes exhausted \ + > exp-too-short || framework_failure_ + + +# This should fail. +split -b 1 -a 1 in 2> err && fail=1 +test -f xa || fail=1 +test -f xz || fail=1 +test -f xaa && fail=1 +test -f xaz && fail=1 +rm -f x* +compare exp-too-short err || fail=1 + +# With a longer suffix, it must succeed. +split --verbose -b 1 -a 2 in > err || fail=1 +compare exp err || fail=1 + +# Ensure that xbb is *not* created. +test -f xbb && fail=1 + +# Ensure that the 27 others files *were* created, and with expected contents. +n=1 +for f in $files; do + expected_byte=$(cut -b $n in) + b=$(cat $f) || fail=1 + test "$b" = "$expected_byte" || fail=1 + n=$(expr $n + 1) +done + +# Ensure that -a is independent of -[bCl] +split -a2 -b1000 < /dev/null || fail=1 +split -a2 -l1000 < /dev/null || fail=1 +split -a2 -C1000 < /dev/null || fail=1 + +# Ensure that -a fails early with a -n that is too large +rm -f x* +split -a2 -n1000 < /dev/null && fail=1 +test -f xaa && fail=1 + +Exit $fail diff --git a/tests/tail-2/F-vs-missing b/tests/tail-2/F-vs-missing deleted file mode 100755 index fbdb53314..000000000 --- a/tests/tail-2/F-vs-missing +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -# demonstrate that tail -F works for currently missing dirs -# Before coreutils-8.6, tail -F missing/file would not -# notice any subsequent availability of the missing/file. - -# Copyright (C) 2010-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -debug='---disable-inotify' -debug= -tail $debug -F -s.1 missing/file > out 2>&1 & pid=$! - -check_tail_output() -{ - local delay="$1" - grep "$tail_re" out > /dev/null || - { sleep $delay; return 1; } -} - -# Wait up to 6.3s for tail to start with diagnostic: -# tail: cannot open 'missing/file' for reading: No such file or directory -tail_re='cannot open' retry_delay_ check_tail_output .1 7 || fail=1 - -mkdir missing || fail=1 -(cd missing && echo x > file) - -# Wait up to 6.3s for this to appear in the output: -# "tail: '...' has appeared; following end of new file" -tail_re='has appeared' retry_delay_ check_tail_output .1 7 || - { echo "$0: file: unexpected delay?"; cat out; fail=1; } - -kill -HUP $pid - -cleanup() -{ - local delay="$1" - rm -rf missing || - { sleep $delay; return 1; } -} - -# Try repeatedly to remove the temporary directory. -# This is normally unnecessary, because the containing directory will -# be removed by code from init.sh. However, when this particular test -# is run on an NFS-mounted volume, sometimes init.sh's cleanup code -# fails because the directory is not yet really empty, perhaps because -# the tail process (reading missing/file) is not yet killed. -retry_delay_ cleanup .1 6 - -Exit $fail diff --git a/tests/tail-2/F-vs-missing.sh b/tests/tail-2/F-vs-missing.sh new file mode 100755 index 000000000..fbdb53314 --- /dev/null +++ b/tests/tail-2/F-vs-missing.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# demonstrate that tail -F works for currently missing dirs +# Before coreutils-8.6, tail -F missing/file would not +# notice any subsequent availability of the missing/file. + +# Copyright (C) 2010-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +debug='---disable-inotify' +debug= +tail $debug -F -s.1 missing/file > out 2>&1 & pid=$! + +check_tail_output() +{ + local delay="$1" + grep "$tail_re" out > /dev/null || + { sleep $delay; return 1; } +} + +# Wait up to 6.3s for tail to start with diagnostic: +# tail: cannot open 'missing/file' for reading: No such file or directory +tail_re='cannot open' retry_delay_ check_tail_output .1 7 || fail=1 + +mkdir missing || fail=1 +(cd missing && echo x > file) + +# Wait up to 6.3s for this to appear in the output: +# "tail: '...' has appeared; following end of new file" +tail_re='has appeared' retry_delay_ check_tail_output .1 7 || + { echo "$0: file: unexpected delay?"; cat out; fail=1; } + +kill -HUP $pid + +cleanup() +{ + local delay="$1" + rm -rf missing || + { sleep $delay; return 1; } +} + +# Try repeatedly to remove the temporary directory. +# This is normally unnecessary, because the containing directory will +# be removed by code from init.sh. However, when this particular test +# is run on an NFS-mounted volume, sometimes init.sh's cleanup code +# fails because the directory is not yet really empty, perhaps because +# the tail process (reading missing/file) is not yet killed. +retry_delay_ cleanup .1 6 + +Exit $fail diff --git a/tests/tail-2/F-vs-rename b/tests/tail-2/F-vs-rename deleted file mode 100755 index 53bc00dd3..000000000 --- a/tests/tail-2/F-vs-rename +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# demonstrate that tail -F works when renaming the tailed files -# Before coreutils-8.3, tail -F a b would stop tracking additions to b -# after "mv a b". - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -touch a b || framework_failure_ - -debug='---disable-inotify' -debug= -tail $debug -F -s.1 a b > out 2>&1 & pid=$! - -check_tail_output() -{ - local delay="$1" - grep "$tail_re" out > /dev/null || - { sleep $delay; return 1; } -} - -# Wait up to 6.3s for tail to start -echo x > a -tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1 - -mv a b || fail=1 - -# Wait 6.3s for this diagnostic: -# tail: 'a' has become inaccessible: No such file or directory -tail_re='inaccessible' retry_delay_ check_tail_output .1 7 || fail=1 - -echo x > a -# Wait up to 6.3s for this to appear in the output: -# "tail: '...' has appeared; following end of new file" -tail_re='has appeared' retry_delay_ check_tail_output .1 7 || - { echo "$0: a: unexpected delay?"; cat out; fail=1; } - -echo y >> b -# Wait up to 6.3s for "y" to appear in the output: -tail_f_vs_rename_2() { - local delay="$1" - tr '\n' @ < out | grep '@@==> b <==@y@$' > /dev/null || - { sleep $delay; return 1; } -} -retry_delay_ tail_f_vs_rename_2 .1 7 || - { echo "$0: b: unexpected delay?"; cat out; fail=1; } - -echo z >> a -# Wait up to 6.3s for "z" to appear in the output: -tail_f_vs_rename_3() { - local delay="$1" - tr '\n' @ < out | grep '@@==> a <==@z@$' > /dev/null || - { sleep $delay; return 1; } -} -retry_delay_ tail_f_vs_rename_3 .1 7 || - { echo "$0: a: unexpected delay?"; cat out; fail=1; } - -kill -HUP $pid - -Exit $fail diff --git a/tests/tail-2/F-vs-rename.sh b/tests/tail-2/F-vs-rename.sh new file mode 100755 index 000000000..53bc00dd3 --- /dev/null +++ b/tests/tail-2/F-vs-rename.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# demonstrate that tail -F works when renaming the tailed files +# Before coreutils-8.3, tail -F a b would stop tracking additions to b +# after "mv a b". + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +touch a b || framework_failure_ + +debug='---disable-inotify' +debug= +tail $debug -F -s.1 a b > out 2>&1 & pid=$! + +check_tail_output() +{ + local delay="$1" + grep "$tail_re" out > /dev/null || + { sleep $delay; return 1; } +} + +# Wait up to 6.3s for tail to start +echo x > a +tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1 + +mv a b || fail=1 + +# Wait 6.3s for this diagnostic: +# tail: 'a' has become inaccessible: No such file or directory +tail_re='inaccessible' retry_delay_ check_tail_output .1 7 || fail=1 + +echo x > a +# Wait up to 6.3s for this to appear in the output: +# "tail: '...' has appeared; following end of new file" +tail_re='has appeared' retry_delay_ check_tail_output .1 7 || + { echo "$0: a: unexpected delay?"; cat out; fail=1; } + +echo y >> b +# Wait up to 6.3s for "y" to appear in the output: +tail_f_vs_rename_2() { + local delay="$1" + tr '\n' @ < out | grep '@@==> b <==@y@$' > /dev/null || + { sleep $delay; return 1; } +} +retry_delay_ tail_f_vs_rename_2 .1 7 || + { echo "$0: b: unexpected delay?"; cat out; fail=1; } + +echo z >> a +# Wait up to 6.3s for "z" to appear in the output: +tail_f_vs_rename_3() { + local delay="$1" + tr '\n' @ < out | grep '@@==> a <==@z@$' > /dev/null || + { sleep $delay; return 1; } +} +retry_delay_ tail_f_vs_rename_3 .1 7 || + { echo "$0: a: unexpected delay?"; cat out; fail=1; } + +kill -HUP $pid + +Exit $fail diff --git a/tests/tail-2/append-only b/tests/tail-2/append-only deleted file mode 100755 index c79bb7b28..000000000 --- a/tests/tail-2/append-only +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Ensure that tail -f works on an append-only file -# Requires root access to do chattr +a, as well as an ext[23] or xfs file system - -# Copyright (C) 2006-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail -require_root_ - -chattr_a_works=1 -touch f -chattr +a f 2>/dev/null || chattr_a_works=0 -( echo x > f ) 2>/dev/null && chattr_a_works=0 -echo x >> f || chattr_a_works=0 - -if test $chattr_a_works = 0; then - skip_ "chattr +a doesn't work on this file system" -fi - - -for inotify in ---disable-inotify ''; do - sleep 1 & - pid=$! - tail --pid=$pid -f $inotify f || fail=1 -done - -chattr -a f 2>/dev/null - -Exit $fail diff --git a/tests/tail-2/append-only.sh b/tests/tail-2/append-only.sh new file mode 100755 index 000000000..c79bb7b28 --- /dev/null +++ b/tests/tail-2/append-only.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Ensure that tail -f works on an append-only file +# Requires root access to do chattr +a, as well as an ext[23] or xfs file system + +# Copyright (C) 2006-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail +require_root_ + +chattr_a_works=1 +touch f +chattr +a f 2>/dev/null || chattr_a_works=0 +( echo x > f ) 2>/dev/null && chattr_a_works=0 +echo x >> f || chattr_a_works=0 + +if test $chattr_a_works = 0; then + skip_ "chattr +a doesn't work on this file system" +fi + + +for inotify in ---disable-inotify ''; do + sleep 1 & + pid=$! + tail --pid=$pid -f $inotify f || fail=1 +done + +chattr -a f 2>/dev/null + +Exit $fail diff --git a/tests/tail-2/assert b/tests/tail-2/assert deleted file mode 100755 index 043e25937..000000000 --- a/tests/tail-2/assert +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# Test for assertion failure in "test". - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -# This test fails with tail from textutils-2.0. -# It would get something like this: -# tail: tail.c:718: recheck: Assertion 'valid_file_spec (f)' failed. -# Aborted -# due to a race condition in which a dev/inode pair is reused. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -# Not "expensive" per se, but sleeping for so long is annoying. -very_expensive_ - -ok='ok ok ok' - -touch a foo -tail --follow=name a foo > err 2>&1 & -tail_pid=$! -# Arrange for the tail process to die after 12 seconds. -(sleep 12; kill $tail_pid) & - -echo sleeping for 7 seconds... - -# Give the backgrounded 'tail' a chance to start before removing foo. -# Otherwise, without --retry, tail wouldn't try to open 'foo' again. -sleep 1 - -rm -f foo -sleep 6 -echo $ok > f -mv f foo - -# echo waiting.... -wait - -case "$(cat err)" in - *$ok) ;; - *) fail=1;; -esac - -test $fail = 1 && cat err - -Exit $fail diff --git a/tests/tail-2/assert-2 b/tests/tail-2/assert-2 deleted file mode 100755 index d94d3d8e2..000000000 --- a/tests/tail-2/assert-2 +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# This variant of 'assert' would get a UMR reliably in 2.0.9. -# Due to a race condition in the test, the 'assert' script would get -# the UMR on Solaris only some of the time, and not at all on Linux/GNU. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -# Not "expensive" per se, but sleeping for so long is annoying. -very_expensive_ - -ok='ok ok ok' - -touch a -tail --follow=name a foo > err 2>&1 & -tail_pid=$! -# Arrange for the tail process to die after 12 seconds. -(sleep 12; kill $tail_pid) & -echo $ok > f -echo sleeping for 7 seconds... -sleep 7 -mv f foo - -# echo waiting.... -wait - -case "$(cat err)" in - *$ok) ;; - *) fail=1;; -esac - -test $fail = 1 && cat err - -Exit $fail diff --git a/tests/tail-2/assert-2.sh b/tests/tail-2/assert-2.sh new file mode 100755 index 000000000..d94d3d8e2 --- /dev/null +++ b/tests/tail-2/assert-2.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# This variant of 'assert' would get a UMR reliably in 2.0.9. +# Due to a race condition in the test, the 'assert' script would get +# the UMR on Solaris only some of the time, and not at all on Linux/GNU. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +# Not "expensive" per se, but sleeping for so long is annoying. +very_expensive_ + +ok='ok ok ok' + +touch a +tail --follow=name a foo > err 2>&1 & +tail_pid=$! +# Arrange for the tail process to die after 12 seconds. +(sleep 12; kill $tail_pid) & +echo $ok > f +echo sleeping for 7 seconds... +sleep 7 +mv f foo + +# echo waiting.... +wait + +case "$(cat err)" in + *$ok) ;; + *) fail=1;; +esac + +test $fail = 1 && cat err + +Exit $fail diff --git a/tests/tail-2/assert.sh b/tests/tail-2/assert.sh new file mode 100755 index 000000000..043e25937 --- /dev/null +++ b/tests/tail-2/assert.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Test for assertion failure in "test". + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# This test fails with tail from textutils-2.0. +# It would get something like this: +# tail: tail.c:718: recheck: Assertion 'valid_file_spec (f)' failed. +# Aborted +# due to a race condition in which a dev/inode pair is reused. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +# Not "expensive" per se, but sleeping for so long is annoying. +very_expensive_ + +ok='ok ok ok' + +touch a foo +tail --follow=name a foo > err 2>&1 & +tail_pid=$! +# Arrange for the tail process to die after 12 seconds. +(sleep 12; kill $tail_pid) & + +echo sleeping for 7 seconds... + +# Give the backgrounded 'tail' a chance to start before removing foo. +# Otherwise, without --retry, tail wouldn't try to open 'foo' again. +sleep 1 + +rm -f foo +sleep 6 +echo $ok > f +mv f foo + +# echo waiting.... +wait + +case "$(cat err)" in + *$ok) ;; + *) fail=1;; +esac + +test $fail = 1 && cat err + +Exit $fail diff --git a/tests/tail-2/big-4gb b/tests/tail-2/big-4gb deleted file mode 100755 index 8ace3183b..000000000 --- a/tests/tail-2/big-4gb +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# Demonstrate a bug in 'tail -cN' when operating on files of size 4G and larger -# Fixed in coreutils-4.5.2. - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail -expensive_ - -# Create a file of size exactly 4GB (2^32) with 8 bytes -# at the beginning and another set of 8 bytes at the end. -# The rest will be NUL bytes. On most modern systems, the following -# creates a file that takes up only a few KB. Here, du -sh says 16K. -echo abcdefgh | tr -d '\n' > big || framework_failure_ -echo 87654321 | tr -d '\n' > tmp || framework_failure_ -# Seek 4GB - 8 -dd bs=1 seek=4294967288 if=tmp of=big 2> err || dd_failed=1 -if test "$dd_failed" = 1; then - cat err 1>&2 - skip_ \ -'cannot create a file large enough for this test, -possibly because this system does not support large files; -Consider rerunning this test on a different file system.' -fi - - -tail -c1 big > out || fail=1 -# Append a newline. -echo >> out -cat <<\EOF > exp -1 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/tail-2/big-4gb.sh b/tests/tail-2/big-4gb.sh new file mode 100755 index 000000000..8ace3183b --- /dev/null +++ b/tests/tail-2/big-4gb.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# Demonstrate a bug in 'tail -cN' when operating on files of size 4G and larger +# Fixed in coreutils-4.5.2. + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail +expensive_ + +# Create a file of size exactly 4GB (2^32) with 8 bytes +# at the beginning and another set of 8 bytes at the end. +# The rest will be NUL bytes. On most modern systems, the following +# creates a file that takes up only a few KB. Here, du -sh says 16K. +echo abcdefgh | tr -d '\n' > big || framework_failure_ +echo 87654321 | tr -d '\n' > tmp || framework_failure_ +# Seek 4GB - 8 +dd bs=1 seek=4294967288 if=tmp of=big 2> err || dd_failed=1 +if test "$dd_failed" = 1; then + cat err 1>&2 + skip_ \ +'cannot create a file large enough for this test, +possibly because this system does not support large files; +Consider rerunning this test on a different file system.' +fi + + +tail -c1 big > out || fail=1 +# Append a newline. +echo >> out +cat <<\EOF > exp +1 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/tail-2/flush-initial b/tests/tail-2/flush-initial deleted file mode 100755 index bf68ce764..000000000 --- a/tests/tail-2/flush-initial +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# inotify-based tail -f didn't flush its initial output before blocking - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -echo line > in || fail=1 -# Output should be buffered since we're writing to file -# so we're depending on the flush to write out -tail -f in > out & -tail_pid=$! - -# Wait for 1.5s for the file to be flushed. -tail_flush() -{ - local delay="$1" - - test -s out || - { sleep "$delay"; return 1; } -} -retry_delay_ tail_flush .1 5 || fail=1 - -kill $tail_pid - -Exit $fail diff --git a/tests/tail-2/flush-initial.sh b/tests/tail-2/flush-initial.sh new file mode 100755 index 000000000..bf68ce764 --- /dev/null +++ b/tests/tail-2/flush-initial.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# inotify-based tail -f didn't flush its initial output before blocking + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +echo line > in || fail=1 +# Output should be buffered since we're writing to file +# so we're depending on the flush to write out +tail -f in > out & +tail_pid=$! + +# Wait for 1.5s for the file to be flushed. +tail_flush() +{ + local delay="$1" + + test -s out || + { sleep "$delay"; return 1; } +} +retry_delay_ tail_flush .1 5 || fail=1 + +kill $tail_pid + +Exit $fail diff --git a/tests/tail-2/follow-name b/tests/tail-2/follow-name deleted file mode 100755 index 2ab1c0119..000000000 --- a/tests/tail-2/follow-name +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# ensure that --follow=name does not imply --retry - -# Copyright (C) 2011-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -cat <<\EOF > exp || framework_failure_ -tail: cannot open 'no-such' for reading: No such file or directory -tail: no files remaining -EOF - -timeout 10 tail --follow=name no-such > out 2> err -test $? = 1 || fail=1 - -# Remove an inconsequential inotify warning so -# we can compare against the above error -sed '/inotify cannot be used/d' err > k && mv k err - -compare exp err || fail=1 - -Exit $fail diff --git a/tests/tail-2/follow-name.sh b/tests/tail-2/follow-name.sh new file mode 100755 index 000000000..2ab1c0119 --- /dev/null +++ b/tests/tail-2/follow-name.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# ensure that --follow=name does not imply --retry + +# Copyright (C) 2011-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +cat <<\EOF > exp || framework_failure_ +tail: cannot open 'no-such' for reading: No such file or directory +tail: no files remaining +EOF + +timeout 10 tail --follow=name no-such > out 2> err +test $? = 1 || fail=1 + +# Remove an inconsequential inotify warning so +# we can compare against the above error +sed '/inotify cannot be used/d' err > k && mv k err + +compare exp err || fail=1 + +Exit $fail diff --git a/tests/tail-2/follow-stdin b/tests/tail-2/follow-stdin deleted file mode 100755 index ee0d1ae82..000000000 --- a/tests/tail-2/follow-stdin +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# tail -f - would fail with the initial inotify implementation - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -echo line > exp || framework_failure_ -echo line > in || framework_failure_ - -timeout 1 tail -f < in > out 2> err - -# tail from coreutils-7.5 would fail -test $? = 124 || fail=1 - -# Ensure there was no error output. -test -s err && fail=1 - -# Ensure there was -compare exp out || fail=1 - -Exit $fail diff --git a/tests/tail-2/follow-stdin.sh b/tests/tail-2/follow-stdin.sh new file mode 100755 index 000000000..ee0d1ae82 --- /dev/null +++ b/tests/tail-2/follow-stdin.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# tail -f - would fail with the initial inotify implementation + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +echo line > exp || framework_failure_ +echo line > in || framework_failure_ + +timeout 1 tail -f < in > out 2> err + +# tail from coreutils-7.5 would fail +test $? = 124 || fail=1 + +# Ensure there was no error output. +test -s err && fail=1 + +# Ensure there was +compare exp out || fail=1 + +Exit $fail diff --git a/tests/tail-2/infloop-1 b/tests/tail-2/infloop-1 deleted file mode 100755 index 3f45f7741..000000000 --- a/tests/tail-2/infloop-1 +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# This test would fail with tail from pre-1.22i textutils. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -yes > t & -yes_pid=$! -while :; do - test -s t && break - sleep .1 -done -tail -n 1 t & -tail_pid=$! -kill $yes_pid - -# This test is racy, and can fail under unusual circumstances. -# On a very busy system, tail will fail to notice that $yes_pid is gone. -# Then the following kill will succeed and cause this test to fail. - -# Wait for up to 3 seconds for tail to detect the death of $yes_pid. -for i in $(seq 30); do - kill -0 $tail_pid || break - echo sleep 0.1s - sleep .1 -done - -kill $tail_pid && fail=1 || : - -Exit $fail diff --git a/tests/tail-2/infloop-1.sh b/tests/tail-2/infloop-1.sh new file mode 100755 index 000000000..3f45f7741 --- /dev/null +++ b/tests/tail-2/infloop-1.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# This test would fail with tail from pre-1.22i textutils. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +yes > t & +yes_pid=$! +while :; do + test -s t && break + sleep .1 +done +tail -n 1 t & +tail_pid=$! +kill $yes_pid + +# This test is racy, and can fail under unusual circumstances. +# On a very busy system, tail will fail to notice that $yes_pid is gone. +# Then the following kill will succeed and cause this test to fail. + +# Wait for up to 3 seconds for tail to detect the death of $yes_pid. +for i in $(seq 30); do + kill -0 $tail_pid || break + echo sleep 0.1s + sleep .1 +done + +kill $tail_pid && fail=1 || : + +Exit $fail diff --git a/tests/tail-2/inotify-hash-abuse b/tests/tail-2/inotify-hash-abuse deleted file mode 100755 index deec76d1b..000000000 --- a/tests/tail-2/inotify-hash-abuse +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Exercise an abort-inducing flaw in inotify-enabled tail -F. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -# 9 is a magic number, related to internal details of tail.c and hash.c -n=9 -seq $n | xargs touch || framework_failure_ - -debug='---disable-inotify' -debug= -tail $debug -s.1 -qF $(seq $n) > out 2>&1 & pid=$! - -check_tail_output() -{ - local delay="$1" - grep "$tail_re" out > /dev/null || - { sleep $delay; return 1; } -} - -# Wait up to 6.3s for tail to start -echo x > $n -tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1 - -mv 1 f || fail=1 - -# Wait 6.3s for this diagnostic: -# tail: '1' has become inaccessible: No such file or directory -tail_re='inaccessible' retry_delay_ check_tail_output .1 7 || fail=1 - -# Trigger the bug. Before the fix, this would provoke the abort. -echo a > 1 || fail=1 - -# Wait up to 2s for the buggy tail to die, -# or for the "tail: '1' has appeared; following end of new file" output -for i in $(seq 10); do - kill -0 $pid || break - grep 'has appeared;' out > /dev/null && break - sleep .2 -done - -# Kill the working tail, or fail if it has already aborted -kill $pid || fail=1 - -cat out - -Exit $fail diff --git a/tests/tail-2/inotify-hash-abuse.sh b/tests/tail-2/inotify-hash-abuse.sh new file mode 100755 index 000000000..deec76d1b --- /dev/null +++ b/tests/tail-2/inotify-hash-abuse.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Exercise an abort-inducing flaw in inotify-enabled tail -F. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +# 9 is a magic number, related to internal details of tail.c and hash.c +n=9 +seq $n | xargs touch || framework_failure_ + +debug='---disable-inotify' +debug= +tail $debug -s.1 -qF $(seq $n) > out 2>&1 & pid=$! + +check_tail_output() +{ + local delay="$1" + grep "$tail_re" out > /dev/null || + { sleep $delay; return 1; } +} + +# Wait up to 6.3s for tail to start +echo x > $n +tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1 + +mv 1 f || fail=1 + +# Wait 6.3s for this diagnostic: +# tail: '1' has become inaccessible: No such file or directory +tail_re='inaccessible' retry_delay_ check_tail_output .1 7 || fail=1 + +# Trigger the bug. Before the fix, this would provoke the abort. +echo a > 1 || fail=1 + +# Wait up to 2s for the buggy tail to die, +# or for the "tail: '1' has appeared; following end of new file" output +for i in $(seq 10); do + kill -0 $pid || break + grep 'has appeared;' out > /dev/null && break + sleep .2 +done + +# Kill the working tail, or fail if it has already aborted +kill $pid || fail=1 + +cat out + +Exit $fail diff --git a/tests/tail-2/inotify-hash-abuse2 b/tests/tail-2/inotify-hash-abuse2 deleted file mode 100755 index eb192a656..000000000 --- a/tests/tail-2/inotify-hash-abuse2 +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Exercise an abort-inducing flaw in inotify-enabled tail -F. -# Like inotify-hash-abuse, but without a hard-coded "9". - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -touch f || framework_failure_ - -debug='---disable-inotify -s .001' -debug= -tail $debug -F f & pid=$! -cleanup_() { kill $pid; } - -for i in $(seq 200); do - kill -0 $pid || break; - mv f g - touch f -done - -# Kill the working tail, or fail if it has already aborted -kill $pid || fail=1 - -Exit $fail diff --git a/tests/tail-2/inotify-hash-abuse2.sh b/tests/tail-2/inotify-hash-abuse2.sh new file mode 100755 index 000000000..eb192a656 --- /dev/null +++ b/tests/tail-2/inotify-hash-abuse2.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Exercise an abort-inducing flaw in inotify-enabled tail -F. +# Like inotify-hash-abuse, but without a hard-coded "9". + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +touch f || framework_failure_ + +debug='---disable-inotify -s .001' +debug= +tail $debug -F f & pid=$! +cleanup_() { kill $pid; } + +for i in $(seq 200); do + kill -0 $pid || break; + mv f g + touch f +done + +# Kill the working tail, or fail if it has already aborted +kill $pid || fail=1 + +Exit $fail diff --git a/tests/tail-2/inotify-race b/tests/tail-2/inotify-race deleted file mode 100755 index ab25f67d0..000000000 --- a/tests/tail-2/inotify-race +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -# Ensure that tail does not ignore data that is appended to a tailed-forever -# file between tail's initial read-to-EOF, and when the inotify watches -# are established in tail_forever_inotify. That data could be ignored -# indefinitely if no *other* data is appended, but it would be printed as -# soon as any additional appended data is detected. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -# Don't run this test by default because sometimes it's skipped as noted below. -# Also gdb has a bug in Debian's gdb-6.8-3 at least that causes it to not -# cleanup and exit correctly when it receives a SIGTERM, thus hanging the test. -very_expensive_ - -touch file || framework_failure_ -touch tail.out || framework_failure_ - -( timeout 10s gdb --version ) > gdb.out 2>&1 -case $(cat gdb.out) in - *'GNU gdb'*) ;; - *) skip_ "can't run gdb";; -esac - -# See if gdb works and -# tail_forever_inotify is compiled and not inlined -timeout 10s gdb -nx --batch-silent \ - --eval-command='break tail_forever_inotify' \ - --eval-command='run -f file' \ - --eval-command='quit' \ - tail < /dev/null > gdb.out 2>&1 - -# FIXME: The above is seen to _intermittently_ fail with: -# warning: .dynamic section for "/lib/libc.so.6" is not at the expected address -# warning: difference appears to be caused by prelink, adjusting expectations -test -s gdb.out && { cat gdb.out; skip_ "can't set breakpoints in tail"; } - -# Run "tail -f file", stopping to append a line just before -# inotify initialization, and then continue. Before the fix, -# that just-appended line would never be output. -timeout 10s gdb -nx --batch-silent \ - --eval-command='break tail_forever_inotify' \ - --eval-command='run -f file >> tail.out' \ - --eval-command="shell echo never-seen-with-tail-7.5 >> file" \ - --eval-command='continue' \ - --eval-command='quit' \ - tail < /dev/null > /dev/null 2>&1 & -pid=$! - -tail --pid=$pid -f tail.out | (read; kill $pid) - -test -s tail.out || fail=1 - -Exit $fail diff --git a/tests/tail-2/inotify-race.sh b/tests/tail-2/inotify-race.sh new file mode 100755 index 000000000..ab25f67d0 --- /dev/null +++ b/tests/tail-2/inotify-race.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# Ensure that tail does not ignore data that is appended to a tailed-forever +# file between tail's initial read-to-EOF, and when the inotify watches +# are established in tail_forever_inotify. That data could be ignored +# indefinitely if no *other* data is appended, but it would be printed as +# soon as any additional appended data is detected. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +# Don't run this test by default because sometimes it's skipped as noted below. +# Also gdb has a bug in Debian's gdb-6.8-3 at least that causes it to not +# cleanup and exit correctly when it receives a SIGTERM, thus hanging the test. +very_expensive_ + +touch file || framework_failure_ +touch tail.out || framework_failure_ + +( timeout 10s gdb --version ) > gdb.out 2>&1 +case $(cat gdb.out) in + *'GNU gdb'*) ;; + *) skip_ "can't run gdb";; +esac + +# See if gdb works and +# tail_forever_inotify is compiled and not inlined +timeout 10s gdb -nx --batch-silent \ + --eval-command='break tail_forever_inotify' \ + --eval-command='run -f file' \ + --eval-command='quit' \ + tail < /dev/null > gdb.out 2>&1 + +# FIXME: The above is seen to _intermittently_ fail with: +# warning: .dynamic section for "/lib/libc.so.6" is not at the expected address +# warning: difference appears to be caused by prelink, adjusting expectations +test -s gdb.out && { cat gdb.out; skip_ "can't set breakpoints in tail"; } + +# Run "tail -f file", stopping to append a line just before +# inotify initialization, and then continue. Before the fix, +# that just-appended line would never be output. +timeout 10s gdb -nx --batch-silent \ + --eval-command='break tail_forever_inotify' \ + --eval-command='run -f file >> tail.out' \ + --eval-command="shell echo never-seen-with-tail-7.5 >> file" \ + --eval-command='continue' \ + --eval-command='quit' \ + tail < /dev/null > /dev/null 2>&1 & +pid=$! + +tail --pid=$pid -f tail.out | (read; kill $pid) + +test -s tail.out || fail=1 + +Exit $fail diff --git a/tests/tail-2/inotify-rotate b/tests/tail-2/inotify-rotate deleted file mode 100755 index 311633a84..000000000 --- a/tests/tail-2/inotify-rotate +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -# ensure that tail -F handles rotation - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -if test "$VERBOSE" = yes; then - set -x - tail --version -fi - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -expensive_ - -# Wait several seconds for grep REGEXP FILE to succeed. -# Usage: grep_timeout REGEXP FILE -grep_timeout() -{ - local j - for j in $(seq 150); do - grep $1 $2 > /dev/null && return 0 - sleep 0.1 - done - return 1 -} - -# For details, see -# http://lists.gnu.org/archive/html/bug-coreutils/2009-11/msg00213.html - -# Perform at least this many iterations, because on multi-core systems -# the offending sequence of events can be surprisingly uncommon. -for i in $(seq 50); do - echo $i - rm -rf k x out - # Normally less than a second is required here, but with heavy load - # and a lot of disk activity, even 20 seconds is insufficient, which - # leads to this timeout killing tail before the "ok" is written below. - :>k && :>x && timeout 40 tail -F k > out 2>&1 & - pid=$! - sleep .1 - echo b > k; - # wait for b to appear in out - grep_timeout b out || fail_ failed to find b in out - while :; do grep b out > /dev/null && break; done - mv x k - # wait for tail to detect the rename - grep_timeout tail: out || { cat out; fail_ failed to detect rename; } - echo ok >> k - found=0 - # wait up to 10 seconds for "ok" to appear in out - grep_timeout ok out && found=1 - kill $pid - test $found = 0 && { cat out; fail_ failed to detect echoed '"ok"'; } -done - -Exit $fail diff --git a/tests/tail-2/inotify-rotate.sh b/tests/tail-2/inotify-rotate.sh new file mode 100755 index 000000000..311633a84 --- /dev/null +++ b/tests/tail-2/inotify-rotate.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# ensure that tail -F handles rotation + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if test "$VERBOSE" = yes; then + set -x + tail --version +fi + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +expensive_ + +# Wait several seconds for grep REGEXP FILE to succeed. +# Usage: grep_timeout REGEXP FILE +grep_timeout() +{ + local j + for j in $(seq 150); do + grep $1 $2 > /dev/null && return 0 + sleep 0.1 + done + return 1 +} + +# For details, see +# http://lists.gnu.org/archive/html/bug-coreutils/2009-11/msg00213.html + +# Perform at least this many iterations, because on multi-core systems +# the offending sequence of events can be surprisingly uncommon. +for i in $(seq 50); do + echo $i + rm -rf k x out + # Normally less than a second is required here, but with heavy load + # and a lot of disk activity, even 20 seconds is insufficient, which + # leads to this timeout killing tail before the "ok" is written below. + :>k && :>x && timeout 40 tail -F k > out 2>&1 & + pid=$! + sleep .1 + echo b > k; + # wait for b to appear in out + grep_timeout b out || fail_ failed to find b in out + while :; do grep b out > /dev/null && break; done + mv x k + # wait for tail to detect the rename + grep_timeout tail: out || { cat out; fail_ failed to detect rename; } + echo ok >> k + found=0 + # wait up to 10 seconds for "ok" to appear in out + grep_timeout ok out && found=1 + kill $pid + test $found = 0 && { cat out; fail_ failed to detect echoed '"ok"'; } +done + +Exit $fail diff --git a/tests/tail-2/pid b/tests/tail-2/pid deleted file mode 100755 index 0a26f8d3d..000000000 --- a/tests/tail-2/pid +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# Test the --pid option of tail. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail -getlimits_ - -touch empty here || framework_failure_ - - -for inotify in ---disable-inotify ''; do - # Use tail itself to create a background process to monitor, - # which will auto exit when "here" is removed. - tail -f $inotify here & - bg_pid=$! - - # Ensure that tail --pid=PID does not exit when PID is alive. - timeout 1 tail -f -s.1 --pid=$bg_pid $inotify here - test $? = 124 || fail=1 - - # Cleanup background process - kill $bg_pid - - # Ensure that tail --pid=PID exits with success status when PID is dead. - # Use an unlikely-to-be-live PID - timeout 10 tail -f -s.1 --pid=$PID_T_MAX $inotify empty - ret=$? - test $ret = 124 && skip_ "pid $PID_T_MAX present or tail too slow" - test $ret = 0 || fail=1 - - # Ensure tail doesn't wait for data when PID is dead - timeout 10 tail -f -s10 --pid=$PID_T_MAX $inotify empty - test $? = 124 && fail=1 -done - -Exit $fail diff --git a/tests/tail-2/pid.sh b/tests/tail-2/pid.sh new file mode 100755 index 000000000..0a26f8d3d --- /dev/null +++ b/tests/tail-2/pid.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Test the --pid option of tail. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail +getlimits_ + +touch empty here || framework_failure_ + + +for inotify in ---disable-inotify ''; do + # Use tail itself to create a background process to monitor, + # which will auto exit when "here" is removed. + tail -f $inotify here & + bg_pid=$! + + # Ensure that tail --pid=PID does not exit when PID is alive. + timeout 1 tail -f -s.1 --pid=$bg_pid $inotify here + test $? = 124 || fail=1 + + # Cleanup background process + kill $bg_pid + + # Ensure that tail --pid=PID exits with success status when PID is dead. + # Use an unlikely-to-be-live PID + timeout 10 tail -f -s.1 --pid=$PID_T_MAX $inotify empty + ret=$? + test $ret = 124 && skip_ "pid $PID_T_MAX present or tail too slow" + test $ret = 0 || fail=1 + + # Ensure tail doesn't wait for data when PID is dead + timeout 10 tail -f -s10 --pid=$PID_T_MAX $inotify empty + test $? = 124 && fail=1 +done + +Exit $fail diff --git a/tests/tail-2/pipe-f b/tests/tail-2/pipe-f deleted file mode 100755 index e3d8a70b5..000000000 --- a/tests/tail-2/pipe-f +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# ensure that :|tail -f doesn't hang, per POSIX - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -echo foo | timeout 10 tail -f -c3 > out || fail=1 -echo oo > exp || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/tail-2/pipe-f.sh b/tests/tail-2/pipe-f.sh new file mode 100755 index 000000000..e3d8a70b5 --- /dev/null +++ b/tests/tail-2/pipe-f.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# ensure that :|tail -f doesn't hang, per POSIX + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +echo foo | timeout 10 tail -f -c3 > out || fail=1 +echo oo > exp || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/tail-2/pipe-f2 b/tests/tail-2/pipe-f2 deleted file mode 100755 index fffd43a1a..000000000 --- a/tests/tail-2/pipe-f2 +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# Ensure that "tail -f fifo" tails indefinitely. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -mkfifo_or_skip_ fifo - -echo 1 > fifo & -echo 1 > exp || framework_failure_ - -timeout 10 tail -f fifo > out & pid=$! - -check_tail_output() -{ - local n_sec="$1" - test -s out || { sleep $n_sec; return 1; } -} - -# Wait 6.3s for tail to write something. -retry_delay_ check_tail_output .1 7 || fail=1 - -compare exp out || fail=1 - -# Kill the still-running tail, or fail if it's gone. -kill $pid || fail=1 - -Exit $fail diff --git a/tests/tail-2/pipe-f2.sh b/tests/tail-2/pipe-f2.sh new file mode 100755 index 000000000..fffd43a1a --- /dev/null +++ b/tests/tail-2/pipe-f2.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Ensure that "tail -f fifo" tails indefinitely. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +mkfifo_or_skip_ fifo + +echo 1 > fifo & +echo 1 > exp || framework_failure_ + +timeout 10 tail -f fifo > out & pid=$! + +check_tail_output() +{ + local n_sec="$1" + test -s out || { sleep $n_sec; return 1; } +} + +# Wait 6.3s for tail to write something. +retry_delay_ check_tail_output .1 7 || fail=1 + +compare exp out || fail=1 + +# Kill the still-running tail, or fail if it's gone. +kill $pid || fail=1 + +Exit $fail diff --git a/tests/tail-2/proc-ksyms b/tests/tail-2/proc-ksyms deleted file mode 100755 index ad446d350..000000000 --- a/tests/tail-2/proc-ksyms +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Prior to textutils-2.0.17, 'tail /proc/ksyms' would segfault on Linux. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - - -ksyms=/proc/ksyms -if test -r $ksyms; then - tail $ksyms > /dev/null || fail=1 -fi - -Exit $fail diff --git a/tests/tail-2/proc-ksyms.sh b/tests/tail-2/proc-ksyms.sh new file mode 100755 index 000000000..ad446d350 --- /dev/null +++ b/tests/tail-2/proc-ksyms.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Prior to textutils-2.0.17, 'tail /proc/ksyms' would segfault on Linux. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + + +ksyms=/proc/ksyms +if test -r $ksyms; then + tail $ksyms > /dev/null || fail=1 +fi + +Exit $fail diff --git a/tests/tail-2/start-middle b/tests/tail-2/start-middle deleted file mode 100755 index 5b40de45c..000000000 --- a/tests/tail-2/start-middle +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Verify that tail works even when it's reading from a file -# that is not at its beginning. Based on a report from John Roll. - -# Copyright (C) 2001-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -(echo 1; echo 2) > k || framework_failure_ - - -sh -c 'read x; tail' < k > out || fail=1 -cat < exp -2 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/tail-2/start-middle.sh b/tests/tail-2/start-middle.sh new file mode 100755 index 000000000..5b40de45c --- /dev/null +++ b/tests/tail-2/start-middle.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Verify that tail works even when it's reading from a file +# that is not at its beginning. Based on a report from John Roll. + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +(echo 1; echo 2) > k || framework_failure_ + + +sh -c 'read x; tail' < k > out || fail=1 +cat < exp +2 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/tail-2/tail-n0f b/tests/tail-2/tail-n0f deleted file mode 100755 index 2b2147a7f..000000000 --- a/tests/tail-2/tail-n0f +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Make sure that 'tail -n0 -f' and 'tail -c0 -f' sleep -# rather than doing what amounted to a busy-wait. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# This bug was fixed for 5.0.91 -# It skips the test if your system lacks a /proc/$pid/status -# file, or if its contents don't look right. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -require_proc_pid_status_ - -touch empty || framework_failure_ -echo anything > nonempty || framework_failure_ - - -for inotify in ---disable-inotify ''; do - for file in empty nonempty; do - for c_or_n in c n; do - tail --sleep=4 -${c_or_n} 0 -f $inotify $file & - pid=$! - tail_sleeping() - { - local delay="$1"; sleep $delay - state=$(get_process_status_ $pid) - case $state in - S*) ;; - *) return 1;; - esac - } - # Wait up to 1.5s for tail to sleep - retry_delay_ tail_sleeping .1 4 || - { echo $0: process in unexpected state: $state >&2; fail=1; } - kill $pid - done - done -done - -Exit $fail diff --git a/tests/tail-2/tail-n0f.sh b/tests/tail-2/tail-n0f.sh new file mode 100755 index 000000000..2b2147a7f --- /dev/null +++ b/tests/tail-2/tail-n0f.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Make sure that 'tail -n0 -f' and 'tail -c0 -f' sleep +# rather than doing what amounted to a busy-wait. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This bug was fixed for 5.0.91 +# It skips the test if your system lacks a /proc/$pid/status +# file, or if its contents don't look right. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +require_proc_pid_status_ + +touch empty || framework_failure_ +echo anything > nonempty || framework_failure_ + + +for inotify in ---disable-inotify ''; do + for file in empty nonempty; do + for c_or_n in c n; do + tail --sleep=4 -${c_or_n} 0 -f $inotify $file & + pid=$! + tail_sleeping() + { + local delay="$1"; sleep $delay + state=$(get_process_status_ $pid) + case $state in + S*) ;; + *) return 1;; + esac + } + # Wait up to 1.5s for tail to sleep + retry_delay_ tail_sleeping .1 4 || + { echo $0: process in unexpected state: $state >&2; fail=1; } + kill $pid + done + done +done + +Exit $fail diff --git a/tests/tail-2/wait b/tests/tail-2/wait deleted file mode 100755 index 587b44954..000000000 --- a/tests/tail-2/wait +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# Make sure that 'tail -f' returns immediately if a file doesn't exist -# while 'tail -F' waits for it to appear. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ tail - -touch here || framework_failure_ -{ touch unreadable && chmod a-r unreadable; } || framework_failure_ - - -for inotify in ---disable-inotify ''; do - timeout 10 tail -s0.1 -f $inotify not_here - test $? = 124 && fail=1 - - if test ! -r unreadable; then # can't test this when root - timeout 10 tail -s0.1 -f $inotify unreadable - test $? = 124 && fail=1 - fi - - timeout 1 tail -s0.1 -f $inotify here 2>tail.err - test $? = 124 || fail=1 - - # 'tail -F' must wait in any case. - - timeout 1 tail -s0.1 -F $inotify here 2>>tail.err - test $? = 124 || fail=1 - - if test ! -r unreadable; then # can't test this when root - timeout 1 tail -s0.1 -F $inotify unreadable - test $? = 124 || fail=1 - fi - - timeout 1 tail -s0.1 -F $inotify not_here - test $? = 124 || fail=1 - - grep -Ev 'inotify (resources exhausted|cannot be used)' tail.err > x - mv x tail.err - test -s tail.err && fail=1 - :>tail.err - - tail_F() - { - local delay="$1" - - touch k || framework_failure_ - tail -s.1 --max-unchanged-stats=2 -F $inotify k > tail.out & - pid=$! - sleep $delay - mv k l - sleep $delay - touch k - mv k l - sleep $delay - echo NO >> l - sleep $delay - kill $pid - rm -f k l - - test ! -s tail.out - } - retry_delay_ tail_F .1 4 || fail=1 -done - -Exit $fail diff --git a/tests/tail-2/wait.sh b/tests/tail-2/wait.sh new file mode 100755 index 000000000..587b44954 --- /dev/null +++ b/tests/tail-2/wait.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Make sure that 'tail -f' returns immediately if a file doesn't exist +# while 'tail -F' waits for it to appear. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ tail + +touch here || framework_failure_ +{ touch unreadable && chmod a-r unreadable; } || framework_failure_ + + +for inotify in ---disable-inotify ''; do + timeout 10 tail -s0.1 -f $inotify not_here + test $? = 124 && fail=1 + + if test ! -r unreadable; then # can't test this when root + timeout 10 tail -s0.1 -f $inotify unreadable + test $? = 124 && fail=1 + fi + + timeout 1 tail -s0.1 -f $inotify here 2>tail.err + test $? = 124 || fail=1 + + # 'tail -F' must wait in any case. + + timeout 1 tail -s0.1 -F $inotify here 2>>tail.err + test $? = 124 || fail=1 + + if test ! -r unreadable; then # can't test this when root + timeout 1 tail -s0.1 -F $inotify unreadable + test $? = 124 || fail=1 + fi + + timeout 1 tail -s0.1 -F $inotify not_here + test $? = 124 || fail=1 + + grep -Ev 'inotify (resources exhausted|cannot be used)' tail.err > x + mv x tail.err + test -s tail.err && fail=1 + :>tail.err + + tail_F() + { + local delay="$1" + + touch k || framework_failure_ + tail -s.1 --max-unchanged-stats=2 -F $inotify k > tail.out & + pid=$! + sleep $delay + mv k l + sleep $delay + touch k + mv k l + sleep $delay + echo NO >> l + sleep $delay + kill $pid + rm -f k l + + test ! -s tail.out + } + retry_delay_ tail_F .1 4 || fail=1 +done + +Exit $fail diff --git a/tests/touch/60-seconds b/tests/touch/60-seconds deleted file mode 100755 index 915a1d05d..000000000 --- a/tests/touch/60-seconds +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# touch -t would mistakenly reject a time specifying "60" seconds - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -echo 60.000000000 > exp || framework_failure_ - - -# Before coreutils-7.7, this would fail, complaining of -# an 'invalid date format'. Specifying 60 seconds *is* valid. -TZ=UTC0 touch -t 197001010000.60 f || fail=1 - -stat --p='%.9Y\n' f > out || fail=1 - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/touch/60-seconds.sh b/tests/touch/60-seconds.sh new file mode 100755 index 000000000..915a1d05d --- /dev/null +++ b/tests/touch/60-seconds.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# touch -t would mistakenly reject a time specifying "60" seconds + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +echo 60.000000000 > exp || framework_failure_ + + +# Before coreutils-7.7, this would fail, complaining of +# an 'invalid date format'. Specifying 60 seconds *is* valid. +TZ=UTC0 touch -t 197001010000.60 f || fail=1 + +stat --p='%.9Y\n' f > out || fail=1 + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/touch/dangling-symlink b/tests/touch/dangling-symlink deleted file mode 100755 index 1eb2ed38a..000000000 --- a/tests/touch/dangling-symlink +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Make sure touch can create a file through a dangling symlink. -# This was broken in the 4.0[e-i] test releases. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -rm -f touch-target t-symlink -ln -s touch-target t-symlink - -# This used to infloop. -touch t-symlink || fail=1 - -test -f touch-target || fail=1 -rm -f touch-target t-symlink - -if test $fail = 1; then - case $host_triplet in - *linux-gnu*) - case "$(uname -r)" in - 2.3.9[0-9]*) - skip_ \ -'**************************************************** -WARNING!!! -This version of the Linux kernel causes touch to fail -when operating on dangling symlinks. -****************************************************' - ;; - esac - ;; - esac -fi - -Exit $fail diff --git a/tests/touch/dangling-symlink.sh b/tests/touch/dangling-symlink.sh new file mode 100755 index 000000000..1eb2ed38a --- /dev/null +++ b/tests/touch/dangling-symlink.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Make sure touch can create a file through a dangling symlink. +# This was broken in the 4.0[e-i] test releases. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +rm -f touch-target t-symlink +ln -s touch-target t-symlink + +# This used to infloop. +touch t-symlink || fail=1 + +test -f touch-target || fail=1 +rm -f touch-target t-symlink + +if test $fail = 1; then + case $host_triplet in + *linux-gnu*) + case "$(uname -r)" in + 2.3.9[0-9]*) + skip_ \ +'**************************************************** +WARNING!!! +This version of the Linux kernel causes touch to fail +when operating on dangling symlinks. +****************************************************' + ;; + esac + ;; + esac +fi + +Exit $fail diff --git a/tests/touch/dir-1 b/tests/touch/dir-1 deleted file mode 100755 index b4c04fe41..000000000 --- a/tests/touch/dir-1 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Make sure touch can operate on a directory. -# This was broken in the 4.0[efg] test releases. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -touch . || fail=1 -Exit $fail diff --git a/tests/touch/dir-1.sh b/tests/touch/dir-1.sh new file mode 100755 index 000000000..b4c04fe41 --- /dev/null +++ b/tests/touch/dir-1.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Make sure touch can operate on a directory. +# This was broken in the 4.0[efg] test releases. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +touch . || fail=1 +Exit $fail diff --git a/tests/touch/empty-file b/tests/touch/empty-file deleted file mode 100755 index a150bd58e..000000000 --- a/tests/touch/empty-file +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# Make sure touch can set the mtime on an empty file. - -# Copyright (C) 1998-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -# Volker Borchert reported that touch 3.16r (and presumably all before that) -# fails to work on SunOS 4.1.3 with 'most of the recommended patches' when -# the empty file is on an NFS-mounted 4.2 volume. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -DEFAULT_SLEEP_SECONDS=2 -SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS} - - -# FIXME: find writable directories on other partitions -# and run the test in those directories, too. - -: ${TOUCH_DIR_LIST=.} - - -for d in $TOUCH_DIR_LIST; do - rm -rf $d/a $d/b $d/c - > $d/a || framework_failure_ - test -f $d/a || framework_failure_ - > $d/b || framework_failure_ - test -f $d/b || framework_failure_ - > $d/c || framework_failure_ - test -f $d/c || framework_failure_ -done - -echo sleeping for $SLEEP_SECONDS seconds... -sleep $SLEEP_SECONDS -for d in $TOUCH_DIR_LIST; do - touch $d/a || fail=1 - set x $(ls -t $d/a $d/b) - test "$*" = "x $d/a $d/b" || fail=1 -done - -echo sleeping for $SLEEP_SECONDS seconds... -sleep $SLEEP_SECONDS -for d in $TOUCH_DIR_LIST; do - touch $d/b - set x $(ls -t $d/a $d/b) - test "$*" = "x $d/b $d/a" || fail=1 - - if touch - 1< $d/c 2> /dev/null; then - set x $(ls -t $d/a $d/c) - test "$*" = "x $d/c $d/a" || fail=1 - fi - - rm -rf $d/a $d/b $d/c -done - -if test $fail != 0; then - cat 1>&2 <. + + +# Volker Borchert reported that touch 3.16r (and presumably all before that) +# fails to work on SunOS 4.1.3 with 'most of the recommended patches' when +# the empty file is on an NFS-mounted 4.2 volume. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +DEFAULT_SLEEP_SECONDS=2 +SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS} + + +# FIXME: find writable directories on other partitions +# and run the test in those directories, too. + +: ${TOUCH_DIR_LIST=.} + + +for d in $TOUCH_DIR_LIST; do + rm -rf $d/a $d/b $d/c + > $d/a || framework_failure_ + test -f $d/a || framework_failure_ + > $d/b || framework_failure_ + test -f $d/b || framework_failure_ + > $d/c || framework_failure_ + test -f $d/c || framework_failure_ +done + +echo sleeping for $SLEEP_SECONDS seconds... +sleep $SLEEP_SECONDS +for d in $TOUCH_DIR_LIST; do + touch $d/a || fail=1 + set x $(ls -t $d/a $d/b) + test "$*" = "x $d/a $d/b" || fail=1 +done + +echo sleeping for $SLEEP_SECONDS seconds... +sleep $SLEEP_SECONDS +for d in $TOUCH_DIR_LIST; do + touch $d/b + set x $(ls -t $d/a $d/b) + test "$*" = "x $d/b $d/a" || fail=1 + + if touch - 1< $d/c 2> /dev/null; then + set x $(ls -t $d/a $d/c) + test "$*" = "x $d/c $d/a" || fail=1 + fi + + rm -rf $d/a $d/b $d/c +done + +if test $fail != 0; then + cat 1>&2 <. - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch -skip_if_root_ - -file=/no-such-dir/file - -touch $file > out 2>&1 && fail=1 -cat < exp -touch: cannot touch '$file': No such file or directory -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/touch/fail-diag.sh b/tests/touch/fail-diag.sh new file mode 100755 index 000000000..b74d2a5bb --- /dev/null +++ b/tests/touch/fail-diag.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# make sure touch gives reasonable diagnostics + +# Copyright (C) 2001-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch +skip_if_root_ + +file=/no-such-dir/file + +touch $file > out 2>&1 && fail=1 +cat < exp +touch: cannot touch '$file': No such file or directory +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/touch/fifo b/tests/touch/fifo deleted file mode 100755 index 65f4328cc..000000000 --- a/tests/touch/fifo +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Make sure touch works on fifos without hanging. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -mkfifo_or_skip_ fifo - - -touch fifo || fail=1 - -Exit $fail diff --git a/tests/touch/fifo.sh b/tests/touch/fifo.sh new file mode 100755 index 000000000..65f4328cc --- /dev/null +++ b/tests/touch/fifo.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Make sure touch works on fifos without hanging. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +mkfifo_or_skip_ fifo + + +touch fifo || fail=1 + +Exit $fail diff --git a/tests/touch/no-create-missing b/tests/touch/no-create-missing deleted file mode 100755 index 88a079a01..000000000 --- a/tests/touch/no-create-missing +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Ensure that touch -c no-such-file no longer fails (it did in 4.1.8). - -# Copyright (C) 2002-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - - -touch -c no-file > /dev/null 2>&1 || fail=1 -touch -cm no-file > /dev/null 2>&1 || fail=1 -touch -ca no-file > /dev/null 2>&1 || fail=1 - -test="$abs_top_builddir/src/test" - -# If >&- works, test "touch -c -" etc. -# >&- apparently does not work in HP-UX 11.23. -# This test is ineffective unless /dev/stdout also works. -if "$test" -w /dev/stdout >/dev/null && - "$test" ! -w /dev/stdout >&-; then - touch -c - >&- 2> /dev/null || fail=1 - touch -cm - >&- 2> /dev/null || fail=1 - touch -ca - >&- 2> /dev/null || fail=1 -fi - -Exit $fail diff --git a/tests/touch/no-create-missing.sh b/tests/touch/no-create-missing.sh new file mode 100755 index 000000000..88a079a01 --- /dev/null +++ b/tests/touch/no-create-missing.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Ensure that touch -c no-such-file no longer fails (it did in 4.1.8). + +# Copyright (C) 2002-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + + +touch -c no-file > /dev/null 2>&1 || fail=1 +touch -cm no-file > /dev/null 2>&1 || fail=1 +touch -ca no-file > /dev/null 2>&1 || fail=1 + +test="$abs_top_builddir/src/test" + +# If >&- works, test "touch -c -" etc. +# >&- apparently does not work in HP-UX 11.23. +# This test is ineffective unless /dev/stdout also works. +if "$test" -w /dev/stdout >/dev/null && + "$test" ! -w /dev/stdout >&-; then + touch -c - >&- 2> /dev/null || fail=1 + touch -cm - >&- 2> /dev/null || fail=1 + touch -ca - >&- 2> /dev/null || fail=1 +fi + +Exit $fail diff --git a/tests/touch/no-dereference b/tests/touch/no-dereference deleted file mode 100755 index aee9a5cfc..000000000 --- a/tests/touch/no-dereference +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -# Ensure that touch -h works. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -ln -s nowhere dangling || framework_failure_ -touch file || framework_failure_ -ln -s file link || framework_failure_ - - -# These first tests should work on every platform. -# -h does not create files, but it warns. Use -c to silence warning. -touch -h no-file 2> err && fail=1 -test -s err || fail=1 -touch -h -c no-file 2> err || fail=1 -test -s err && fail=1 - -# -h works on regular files -touch -h file || fail=1 - -# -h coupled with -r uses timestamp of the symlink, not the referent. -touch -h -r dangling file || fail=1 -test -f nowhere && fail=1 - -# The remaining tests of -h require kernel support for changing symlink times. -grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null || -grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null || - skip_ 'this system lacks the utimensat function' - -# Changing time of dangling symlink is okay. -# Skip the test if this fails, but the error text corresponds to -# ENOSYS (possible with old kernel but new glibc). -touch -h dangling 2> err -case $? in - 0) test -f nowhere && fail=1 - test -s err && fail=1;; - 1) grep 'Function not implemented' err \ - && skip_ 'this system lacks the utimensat function' - fail=1;; - *) fail=1;; -esac - -# Change the mtime of a symlink. -touch -m -h -d 2009-10-10 link || fail=1 -case $(stat --format=%y link) in - 2009-10-10*) ;; - *) fail=1 ;; -esac -case $(stat --format=%y file) in - 2009-10-10*) fail=1;; -esac - -# Test interactions with -. -touch -h - > file || fail=1 - -test="$abs_top_builddir/src/test" - -# If >&- works, test "touch -ch -" etc. -# >&- apparently does not work in HP-UX 11.23. -# This test is ineffective unless /dev/stdout also works. -# If stdout is open, it is not a symlink. -if "$test" -w /dev/stdout >/dev/null && - "$test" ! -w /dev/stdout >&-; then - touch -h - >&- && fail=1 - touch -h -c - >&- || fail=1 -fi - -Exit $fail diff --git a/tests/touch/no-dereference.sh b/tests/touch/no-dereference.sh new file mode 100755 index 000000000..aee9a5cfc --- /dev/null +++ b/tests/touch/no-dereference.sh @@ -0,0 +1,84 @@ +#!/bin/sh +# Ensure that touch -h works. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +ln -s nowhere dangling || framework_failure_ +touch file || framework_failure_ +ln -s file link || framework_failure_ + + +# These first tests should work on every platform. +# -h does not create files, but it warns. Use -c to silence warning. +touch -h no-file 2> err && fail=1 +test -s err || fail=1 +touch -h -c no-file 2> err || fail=1 +test -s err && fail=1 + +# -h works on regular files +touch -h file || fail=1 + +# -h coupled with -r uses timestamp of the symlink, not the referent. +touch -h -r dangling file || fail=1 +test -f nowhere && fail=1 + +# The remaining tests of -h require kernel support for changing symlink times. +grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null || +grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null || + skip_ 'this system lacks the utimensat function' + +# Changing time of dangling symlink is okay. +# Skip the test if this fails, but the error text corresponds to +# ENOSYS (possible with old kernel but new glibc). +touch -h dangling 2> err +case $? in + 0) test -f nowhere && fail=1 + test -s err && fail=1;; + 1) grep 'Function not implemented' err \ + && skip_ 'this system lacks the utimensat function' + fail=1;; + *) fail=1;; +esac + +# Change the mtime of a symlink. +touch -m -h -d 2009-10-10 link || fail=1 +case $(stat --format=%y link) in + 2009-10-10*) ;; + *) fail=1 ;; +esac +case $(stat --format=%y file) in + 2009-10-10*) fail=1;; +esac + +# Test interactions with -. +touch -h - > file || fail=1 + +test="$abs_top_builddir/src/test" + +# If >&- works, test "touch -ch -" etc. +# >&- apparently does not work in HP-UX 11.23. +# This test is ineffective unless /dev/stdout also works. +# If stdout is open, it is not a symlink. +if "$test" -w /dev/stdout >/dev/null && + "$test" ! -w /dev/stdout >&-; then + touch -h - >&- && fail=1 + touch -h -c - >&- || fail=1 +fi + +Exit $fail diff --git a/tests/touch/no-rights b/tests/touch/no-rights deleted file mode 100755 index abebc5261..000000000 --- a/tests/touch/no-rights +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# Make sure touch can update the times on a file that is neither -# readable nor writable. - -# Copyright (C) 1999-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -# Make sure t2 is newer than t1. -touch -d '2000-01-01 00:00' t1 || framework_failure_ -touch -d '2000-01-02 00:00' t2 || framework_failure_ - -set x $(ls -t t1 t2) -test "$*" = "x t2 t1" || framework_failure_ - - -chmod 0 t1 -touch -d '2000-01-03 00:00' -c t1 || fail=1 - -set x $(ls -t t1 t2) -test "$*" = "x t1 t2" || fail=1 - -# Also test the combination of --no-create and -a. -touch -a --no-create t1 || fail=1 - -Exit $fail diff --git a/tests/touch/no-rights.sh b/tests/touch/no-rights.sh new file mode 100755 index 000000000..abebc5261 --- /dev/null +++ b/tests/touch/no-rights.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Make sure touch can update the times on a file that is neither +# readable nor writable. + +# Copyright (C) 1999-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +# Make sure t2 is newer than t1. +touch -d '2000-01-01 00:00' t1 || framework_failure_ +touch -d '2000-01-02 00:00' t2 || framework_failure_ + +set x $(ls -t t1 t2) +test "$*" = "x t2 t1" || framework_failure_ + + +chmod 0 t1 +touch -d '2000-01-03 00:00' -c t1 || fail=1 + +set x $(ls -t t1 t2) +test "$*" = "x t1 t2" || fail=1 + +# Also test the combination of --no-create and -a. +touch -a --no-create t1 || fail=1 + +Exit $fail diff --git a/tests/touch/not-owner b/tests/touch/not-owner deleted file mode 100755 index 63b8af249..000000000 --- a/tests/touch/not-owner +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Make sure that touch gives reasonable diagnostics when applied -# to an unwritable directory owned by some other user. - -# Copyright (C) 2003-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -if env -- test -w /; then - skip_ you have write access to /. -fi - -if env -- test -O / || env -- test -G /; then - skip_ "you own /." -fi - -skip_if_root_ - - -# Before fileutils-4.1, we'd get the following misleading -# diagnostic instead of '...: Permission denied'. -# touch: creating '/': Is a directory -touch / > out 2>&1 && fail=1 - -# On SunOS4, EPERM is 'Not owner'. -# On some *BSD systems it's 'Operation not permitted'. -# On a system where root file system is mounted read-only -# it's 'Read-only file system'. -for msg in 'Not owner' 'Operation not permitted' 'Permission denied' \ - 'Read-only file system'; do - cat > exp < /dev/null 2>&1 && { match=1; break; } -done -test "$match" = 1 || fail=1 - -test $fail = 1 && compare exp out - -Exit $fail diff --git a/tests/touch/not-owner.sh b/tests/touch/not-owner.sh new file mode 100755 index 000000000..63b8af249 --- /dev/null +++ b/tests/touch/not-owner.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Make sure that touch gives reasonable diagnostics when applied +# to an unwritable directory owned by some other user. + +# Copyright (C) 2003-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +if env -- test -w /; then + skip_ you have write access to /. +fi + +if env -- test -O / || env -- test -G /; then + skip_ "you own /." +fi + +skip_if_root_ + + +# Before fileutils-4.1, we'd get the following misleading +# diagnostic instead of '...: Permission denied'. +# touch: creating '/': Is a directory +touch / > out 2>&1 && fail=1 + +# On SunOS4, EPERM is 'Not owner'. +# On some *BSD systems it's 'Operation not permitted'. +# On a system where root file system is mounted read-only +# it's 'Read-only file system'. +for msg in 'Not owner' 'Operation not permitted' 'Permission denied' \ + 'Read-only file system'; do + cat > exp < /dev/null 2>&1 && { match=1; break; } +done +test "$match" = 1 || fail=1 + +test $fail = 1 && compare exp out + +Exit $fail diff --git a/tests/touch/now-owned-by-other b/tests/touch/now-owned-by-other deleted file mode 100755 index 3da8d35ff..000000000 --- a/tests/touch/now-owned-by-other +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# Demonstrate that "touch -d now writable-but-owned-by-other" works. - -# Copyright (C) 2008-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch -require_root_ - -group_num=$(id -g $NON_ROOT_USERNAME) - -# Create a file owned by root, and writable by $NON_ROOT_USERNAME. -echo > root-owned || framework_failure_ -chgrp +$group_num . root-owned || framework_failure_ -chmod g+w root-owned - -# Ensure that the current directory is searchable by $NON_ROOT_USERNAME. -chmod g+x . - -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" touch -d now root-owned || fail=1 - -Exit $fail diff --git a/tests/touch/now-owned-by-other.sh b/tests/touch/now-owned-by-other.sh new file mode 100755 index 000000000..3da8d35ff --- /dev/null +++ b/tests/touch/now-owned-by-other.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Demonstrate that "touch -d now writable-but-owned-by-other" works. + +# Copyright (C) 2008-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch +require_root_ + +group_num=$(id -g $NON_ROOT_USERNAME) + +# Create a file owned by root, and writable by $NON_ROOT_USERNAME. +echo > root-owned || framework_failure_ +chgrp +$group_num . root-owned || framework_failure_ +chmod g+w root-owned + +# Ensure that the current directory is searchable by $NON_ROOT_USERNAME. +chmod g+x . + +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" touch -d now root-owned || fail=1 + +Exit $fail diff --git a/tests/touch/obsolescent b/tests/touch/obsolescent deleted file mode 100755 index d403127be..000000000 --- a/tests/touch/obsolescent +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# Test touch with obsolescent 8- or 10-digit time stamps. - -# Copyright (C) 2000-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -_POSIX2_VERSION=199209; export _POSIX2_VERSION -POSIXLY_CORRECT=1; export POSIXLY_CORRECT - - -yearstart=01010000 - -for ones in 11111111 1111111111; do - for args in $ones "-- $ones" "$yearstart $ones" "-- $yearstart $ones"; do - touch $args || fail=1 - test -f $ones || fail=1 - test -f $yearstart && fail=1 - rm -f $ones || fail=1 - done -done - -y2000=0101000000 -rm -f $y2000 file || fail=1 -touch $y2000 file && test -f $y2000 && test -f file || fail=1 - -Exit $fail diff --git a/tests/touch/obsolescent.sh b/tests/touch/obsolescent.sh new file mode 100755 index 000000000..d403127be --- /dev/null +++ b/tests/touch/obsolescent.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Test touch with obsolescent 8- or 10-digit time stamps. + +# Copyright (C) 2000-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +_POSIX2_VERSION=199209; export _POSIX2_VERSION +POSIXLY_CORRECT=1; export POSIXLY_CORRECT + + +yearstart=01010000 + +for ones in 11111111 1111111111; do + for args in $ones "-- $ones" "$yearstart $ones" "-- $yearstart $ones"; do + touch $args || fail=1 + test -f $ones || fail=1 + test -f $yearstart && fail=1 + rm -f $ones || fail=1 + done +done + +y2000=0101000000 +rm -f $y2000 file || fail=1 +touch $y2000 file && test -f $y2000 && test -f file || fail=1 + +Exit $fail diff --git a/tests/touch/read-only b/tests/touch/read-only deleted file mode 100755 index ee8c1d3b0..000000000 --- a/tests/touch/read-only +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# ensure that touch can operate on read-only files - -# Copyright (C) 2005-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch -skip_if_root_ - -: > read-only || framework_failure_ -chmod 444 read-only || framework_failure_ - - -touch read-only || fail=1 - -touch - 1< read-only 2> /dev/null && { test ! -f - || fail=1; } - -Exit $fail diff --git a/tests/touch/read-only.sh b/tests/touch/read-only.sh new file mode 100755 index 000000000..ee8c1d3b0 --- /dev/null +++ b/tests/touch/read-only.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# ensure that touch can operate on read-only files + +# Copyright (C) 2005-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch +skip_if_root_ + +: > read-only || framework_failure_ +chmod 444 read-only || framework_failure_ + + +touch read-only || fail=1 + +touch - 1< read-only 2> /dev/null && { test ! -f - || fail=1; } + +Exit $fail diff --git a/tests/touch/relative b/tests/touch/relative deleted file mode 100755 index ba199fce0..000000000 --- a/tests/touch/relative +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Demonstrate using a combination of --reference and --date to -# set the time of a file back by an arbitrary amount. - -# Copyright (C) 2004-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure_ - - -# Set times back by 5 days. -touch --ref f --date='-5 days' f || fail=1 - -TZ=UTC0 ls -og --time-style=+%Y-%m-%d f > out.1 || fail -sed 's/ f$//;s/.* //' out.1 > out - -cat <<\EOF > exp || fail=1 -2004-01-11 -EOF - -compare exp out || fail=1 - -Exit $fail diff --git a/tests/touch/relative.sh b/tests/touch/relative.sh new file mode 100755 index 000000000..ba199fce0 --- /dev/null +++ b/tests/touch/relative.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Demonstrate using a combination of --reference and --date to +# set the time of a file back by an arbitrary amount. + +# Copyright (C) 2004-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure_ + + +# Set times back by 5 days. +touch --ref f --date='-5 days' f || fail=1 + +TZ=UTC0 ls -og --time-style=+%Y-%m-%d f > out.1 || fail +sed 's/ f$//;s/.* //' out.1 > out + +cat <<\EOF > exp || fail=1 +2004-01-11 +EOF + +compare exp out || fail=1 + +Exit $fail diff --git a/tests/touch/trailing-slash b/tests/touch/trailing-slash deleted file mode 100755 index f09695c07..000000000 --- a/tests/touch/trailing-slash +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# Ensure that touch honors trailing slash. - -# Copyright (C) 2009-2012 Free Software Foundation, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. "${srcdir=.}/init.sh"; path_prepend_ ../src -print_ver_ touch - -ln -s nowhere dangling || framework_failure_ -ln -s loop loop || framework_failure_ -touch file || framework_failure_ -ln -s file link1 || framework_failure_ -mkdir dir || framework_failure_ -ln -s dir link2 || framework_failure_ - - -# Trailing slash can only appear on directory or symlink-to-directory. -# Up through coreutils 8.0, Solaris 9 failed these tests. -touch no-file/ && fail=1 -touch file/ && fail=1 -touch dangling/ && fail=1 -touch loop/ && fail=1 -touch link1/ && fail=1 -touch dir/ || fail=1 - -# -c silences ENOENT, but not ENOTDIR or ELOOP -touch -c no-file/ || fail=1 -touch -c file/ && fail=1 -touch -c dangling/ || fail=1 -touch -c loop/ && fail=1 -touch -c link1/ && fail=1 -touch -c dir/ || fail=1 -test -f no-file && fail=1 -test -f nowhere && fail=1 - -# Trailing slash dereferences a symlink, even with -h. -# mtime is sufficient to show pass (besides, lstat changes atime of -# symlinks and directories under Cygwin 1.5). -touch -d 2009-10-10 -h link2/ || fail=1 -touch -h -r link2/ file || fail=1 -case $(stat --format=%y dir) in - 2009-10-10*) ;; - *) fail=1 ;; -esac -case $(stat --format=%y link2) in - 2009-10-10*) fail=1 ;; -esac -case $(stat --format=%y file) in - 2009-10-10*) ;; - *) fail=1 ;; -esac - -Exit $fail diff --git a/tests/touch/trailing-slash.sh b/tests/touch/trailing-slash.sh new file mode 100755 index 000000000..f09695c07 --- /dev/null +++ b/tests/touch/trailing-slash.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# Ensure that touch honors trailing slash. + +# Copyright (C) 2009-2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ touch + +ln -s nowhere dangling || framework_failure_ +ln -s loop loop || framework_failure_ +touch file || framework_failure_ +ln -s file link1 || framework_failure_ +mkdir dir || framework_failure_ +ln -s dir link2 || framework_failure_ + + +# Trailing slash can only appear on directory or symlink-to-directory. +# Up through coreutils 8.0, Solaris 9 failed these tests. +touch no-file/ && fail=1 +touch file/ && fail=1 +touch dangling/ && fail=1 +touch loop/ && fail=1 +touch link1/ && fail=1 +touch dir/ || fail=1 + +# -c silences ENOENT, but not ENOTDIR or ELOOP +touch -c no-file/ || fail=1 +touch -c file/ && fail=1 +touch -c dangling/ || fail=1 +touch -c loop/ && fail=1 +touch -c link1/ && fail=1 +touch -c dir/ || fail=1 +test -f no-file && fail=1 +test -f nowhere && fail=1 + +# Trailing slash dereferences a symlink, even with -h. +# mtime is sufficient to show pass (besides, lstat changes atime of +# symlinks and directories under Cygwin 1.5). +touch -d 2009-10-10 -h link2/ || fail=1 +touch -h -r link2/ file || fail=1 +case $(stat --format=%y dir) in + 2009-10-10*) ;; + *) fail=1 ;; +esac +case $(stat --format=%y link2) in + 2009-10-10*) fail=1 ;; +esac +case $(stat --format=%y file) in + 2009-10-10*) ;; + *) fail=1 ;; +esac + +Exit $fail -- cgit v1.2.3-70-g09d2