diff options
Diffstat (limited to 'tests')
69 files changed, 861 insertions, 861 deletions
diff --git a/tests/basename.test b/tests/basename.test index 2f7a2ec3..9d3b2961 100755 --- a/tests/basename.test +++ b/tests/basename.test @@ -5,19 +5,19 @@ #testing "name" "command" "result" "infile" "stdin" # Removal of extra /'s -testing "basename /-only" "basename ///////" "/\n" "" "" -testing "basename trailing /" "basename a//////" "a\n" "" "" -testing "basename combined" "basename /////a///b///c///d/////" "d\n" "" "" +testing "/-only" "basename ///////" "/\n" "" "" +testing "trailing /" "basename a//////" "a\n" "" "" +testing "combined" "basename /////a///b///c///d/////" "d\n" "" "" # Standard suffix behavior. -testing "basename suffix" "basename a/b/c/d.suffix .suffix" "d\n" "" "" +testing "suffix" "basename a/b/c/d.suffix .suffix" "d\n" "" "" # A suffix cannot be the entire result. -testing "basename suffix=result" "basename .txt .txt" ".txt\n" "" "" +testing "suffix=result" "basename .txt .txt" ".txt\n" "" "" # Deal with suffix appearing in the filename -testing "basename reappearing suffix 1" "basename a.txt.txt .txt" "a.txt\n" "" "" -testing "basename reappearing suffix 2" "basename a.txt.old .txt" "a.txt.old\n" "" "" +testing "reappearing suffix 1" "basename a.txt.txt .txt" "a.txt\n" "" "" +testing "reappearing suffix 2" "basename a.txt.old .txt" "a.txt.old\n" "" "" # A suffix should be a real suffix, only a the end. -testing "basename invalid suffix" "basename isthisasuffix? suffix" "isthisasuffix?\n" "" "" +testing "invalid suffix" "basename isthisasuffix? suffix" "isthisasuffix?\n" "" "" diff --git a/tests/blkid.test b/tests/blkid.test index b80cf4f0..9cde4899 100755 --- a/tests/blkid.test +++ b/tests/blkid.test @@ -7,38 +7,38 @@ BDIR="$TOPDIR/tests/blkid" bzcat "$BDIR"/squashfs.bz2 > temp.img -testing "blkid file" "blkid temp.img" 'temp.img: TYPE="squashfs"\n' "" "" +testing "file" "blkid temp.img" 'temp.img: TYPE="squashfs"\n' "" "" rm temp.img -testing "blkid cramfs" 'bzcat "$BDIR"/cramfs.bz2 | blkid -' \ +testing "cramfs" 'bzcat "$BDIR"/cramfs.bz2 | blkid -' \ '-: LABEL="mycramfs" TYPE="cramfs"\n' "" "" -testing "blkid ext2" 'bzcat "$BDIR"/ext2.bz2 | blkid -' \ +testing "ext2" 'bzcat "$BDIR"/ext2.bz2 | blkid -' \ '-: LABEL="myext2" UUID="e59093ba-4135-4fdb-bcc4-f20beae4dfaf" TYPE="ext2"\n' \ "" "" -testing "blkid ext3" 'bzcat "$BDIR"/ext3.bz2 | blkid -' \ +testing "ext3" 'bzcat "$BDIR"/ext3.bz2 | blkid -' \ '-: LABEL="myext3" UUID="79d1c877-1a0f-4e7d-b21d-fc32ae3ef101" TYPE="ext3"\n' \ "" "" -testing "blkid ext4" 'bzcat "$BDIR"/ext4.bz2 | blkid -' \ +testing "ext4" 'bzcat "$BDIR"/ext4.bz2 | blkid -' \ '-: LABEL="myext4" UUID="dc4b7c00-c0c0-4600-af7e-0335f09770fa" TYPE="ext4"\n' \ "" "" -testing "blkid f2fs" 'bzcat "$BDIR"/f2fs.bz2 | blkid -' \ +testing "f2fs" 'bzcat "$BDIR"/f2fs.bz2 | blkid -' \ '-: LABEL="" UUID="b53d3619-c204-4c0b-8504-36363578491c" TYPE="f2fs"\n' \ "" "" -testing "blkid msdos" 'bzcat "$BDIR"/msdos.bz2 | blkid -' \ +testing "msdos" 'bzcat "$BDIR"/msdos.bz2 | blkid -' \ '-: LABEL="mymsdos " UUID="5108-1e6e" TYPE="vfat"\n' "" "" -testing "blkid ntfs" 'bzcat "$BDIR"/ntfs.bz2 | blkid -' \ +testing "ntfs" 'bzcat "$BDIR"/ntfs.bz2 | blkid -' \ '-: UUID="8585600838bfe16e" TYPE="ntfs"\n' "" "" -testing "blkid reiserfs" 'bzcat "$BDIR"/reiser3.bz2 | blkid -' \ +testing "reiserfs" 'bzcat "$BDIR"/reiser3.bz2 | blkid -' \ '-: LABEL="myreiser" UUID="a5b99bec-45cc-41d7-986e-32f4b6fc28f2" TYPE="reiserfs"\n' \ "" "" -testing "blkid squashfs" 'bzcat "$BDIR"/squashfs.bz2 | blkid -' \ +testing "squashfs" 'bzcat "$BDIR"/squashfs.bz2 | blkid -' \ '-: TYPE="squashfs"\n' "" "" -testing "blkid vfat" 'bzcat "$BDIR"/vfat.bz2 | blkid -' \ +testing "vfat" 'bzcat "$BDIR"/vfat.bz2 | blkid -' \ '-: LABEL="myvfat " UUID="1db9-5673" TYPE="vfat"\n' "" "" -testing "blkid xfs" 'bzcat "$BDIR"/xfs.bz2 | blkid -' \ +testing "xfs" 'bzcat "$BDIR"/xfs.bz2 | blkid -' \ '-: LABEL="XFS_test" UUID="d63a1dc3-27d5-4dd4-8b38-f4f97f495c6f" TYPE="xfs"\n' \ "" "" -#testing "blkid minix" 'bzcat "$BDIR"/minix.bz2 | blkid -' +#testing "minix" 'bzcat "$BDIR"/minix.bz2 | blkid -' #adfs bfs btrfs cramfs jfs nilfs romfs #vfat // fat32 fat12 fat16 diff --git a/tests/bzcat.test b/tests/bzcat.test index 8bc5f5c9..4eacc684 100755 --- a/tests/bzcat.test +++ b/tests/bzcat.test @@ -11,7 +11,7 @@ tar -cjf file.tar.bz2 file # Get system bzcat bzcatExe=`which bzcat` $bzcatExe file.tar.bz2 > bzcatOut -testing "bzcat - decompresses a single file" "bzcat file.tar.bz2 > Tempfile && echo "yes"; diff Tempfile bzcatOut && echo "yes"; rm -rf file* bzcatOut Tempfile" "yes\nyes\n" "" "" +testing "- decompresses a single file" "bzcat file.tar.bz2 > Tempfile && echo "yes"; diff Tempfile bzcatOut && echo "yes"; rm -rf file* bzcatOut Tempfile" "yes\nyes\n" "" "" #testing "name" "command" "result" "infile" "stdin" echo "hello" > file1 @@ -23,4 +23,4 @@ tar -cjf file3.tar.bz2 file3 # Get system bzcat bzcatExe=`which bzcat` $bzcatExe file1.tar.bz2 file2.tar.bz2 file3.tar.bz2 > bzcatOut -testing "bzcat - decompresses multiple files" "bzcat file1.tar.bz2 file2.tar.bz2 file3.tar.bz2 > Tempfile && echo "yes" ; diff Tempfile bzcatOut && echo "yes"; rm -rf file* bzcatOut Tempfile " "yes\nyes\n" "" "" +testing "- decompresses multiple files" "bzcat file1.tar.bz2 file2.tar.bz2 file3.tar.bz2 > Tempfile && echo "yes" ; diff Tempfile bzcatOut && echo "yes"; rm -rf file* bzcatOut Tempfile " "yes\nyes\n" "" "" diff --git a/tests/cat.test b/tests/cat.test index 7be515dd..8845070e 100755 --- a/tests/cat.test +++ b/tests/cat.test @@ -7,25 +7,25 @@ echo "one" > file1 echo "two" > file2 testing "cat" "cat && echo yes" "oneyes\n" "" "one" -testing "cat -" "cat - && echo yes" "oneyes\n" "" "one" -testing "cat file1 file2" "cat file1 file2" "one\ntwo\n" "" "" -testing "cat - file" "cat - file1" "zero\none\n" "" "zero\n" -testing "cat file -" "cat file1 -" "one\nzero\n" "" "zero\n" +testing "-" "cat - && echo yes" "oneyes\n" "" "one" +testing "file1 file2" "cat file1 file2" "one\ntwo\n" "" "" +testing "- file" "cat - file1" "zero\none\n" "" "zero\n" +testing "file -" "cat file1 -" "one\nzero\n" "" "zero\n" -testing "cat file1 notfound file2" \ +testing "file1 notfound file2" \ "cat file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \ "one\ntwo\ncat: notfound: No such file or directory\n" "" "" FILE="$(readlink -f /proc/self/exe)" -testing "cat file1" \ +testing "file1" \ 'cat "$FILE" > file1 && cmp "$FILE" file1 && echo yes' \ "yes\n" "" "" -testing "cat - file1" \ +testing "- file1" \ "cat - file1 | diff -a -U 0 - file1 | tail -n 1" \ "-hello\n" "" "hello\n" -testing "cat > /dev/full" \ +testing "> /dev/full" \ "cat - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \ "cat: xwrite: No space left on device\n" "" "zero\n" diff --git a/tests/chattr.test b/tests/chattr.test index ad9f2686..bbf8b099 100755 --- a/tests/chattr.test +++ b/tests/chattr.test @@ -11,64 +11,64 @@ IN="cd testattr" OUT="cd .." _t="abcdefghijklmnopqrstuvwxyz" -testing "chattr [-/+]i FILE[write]" "$IN && echo "$_t" > testFile && +testing "[-/+]i FILE[write]" "$IN && echo "$_t" > testFile && chattr +i testFile && lsattr testFile && echo "$_t" > testFile; chattr -i testFile; rm -rf testFile; $OUT " "----i-------- testFile\n" "" "" -testing "chattr [-/+]i FILE[re-write]" "$IN && echo "$_t" > testFile && +testing "[-/+]i FILE[re-write]" "$IN && echo "$_t" > testFile && chattr +i testFile && echo \"$_t\" > testFile || chattr -i testFile && echo \"$_t\" > testFile && lsattr testFile; rm -rf testFile; $OUT" \ "------------- testFile\n" "" "" -testing "chattr [-/+]i FILE[append]" "$IN && echo "$_t" > testFile && +testing "[-/+]i FILE[append]" "$IN && echo "$_t" > testFile && chattr +i testFile && echo \"$_t\" >> testFile || lsattr testFile && chattr -i testFile; rm -rf testFile; $OUT" "----i-------- testFile\n" "" "" -testing "chattr [-/+]i FILE[move]" "$IN && echo "$_t" > testFile && +testing "[-/+]i FILE[move]" "$IN && echo "$_t" > testFile && chattr +i testFile && mv testFile testFile1 || lsattr testFile && chattr -i testFile; rm -rf testFile; $OUT" "----i-------- testFile\n" "" "" -testing "chattr [-/+]i FILE[delete]" "$IN && echo "$_t" > testFile && +testing "[-/+]i FILE[delete]" "$IN && echo "$_t" > testFile && chattr +i testFile && rm -f testFile || lsattr testFile && chattr -i testFile; rm -rf testFile; $OUT" "----i-------- testFile\n" "" "" -testing "chattr [-/+]i FILE[read]" "$IN && echo "$_t" > testFile && +testing "[-/+]i FILE[read]" "$IN && echo "$_t" > testFile && chattr +i testFile && cat testFile && lsattr testFile && chattr -i testFile; rm -rf testFile; $OUT" "$_t\n----i-------- testFile\n" "" "" -testing "chattr [-/+]a FILE[write]" "$IN && echo "$_t" > testFile && +testing "[-/+]a FILE[write]" "$IN && echo "$_t" > testFile && chattr +a testFile && echo $_t > testFile || lsattr testFile && chattr -a testFile; rm -rf testFile; $OUT" "-----a------- testFile\n" "" "" -testing "chattr [-/+]a FILE[re-write]" "$IN && echo "$_t" > testFile && +testing "[-/+]a FILE[re-write]" "$IN && echo "$_t" > testFile && chattr +a testFile && echo $_t > testFile || lsattr testFile && chattr -a testFile && echo $_t > testFile && cat testFile && lsattr testFile; rm -rf testFile; $OUT" "-----a------- testFile\n$_t\n------------- testFile\n" "" "" -testing "chattr [-/+]a FILE[append]" "$IN && echo "$_t" > testFile && +testing "[-/+]a FILE[append]" "$IN && echo "$_t" > testFile && chattr +a testFile && echo $_t >> testFile && cat testFile && lsattr testFile && chattr -a testFile; rm -rf testFile; $OUT" \ "$_t\n$_t\n-----a------- testFile\n" "" "" -testing "chattr [-/+]a FILE[move]" "$IN && echo "$_t" > testFile && +testing "[-/+]a FILE[move]" "$IN && echo "$_t" > testFile && chattr +a testFile && mv testFile testFile1 || lsattr testFile && chattr -a testFile; rm -rf testFile; $OUT" "-----a------- testFile\n" "" "" -testing "chattr [-/+]a FILE[delete]" "$IN && echo "$_t" > testFile && +testing "[-/+]a FILE[delete]" "$IN && echo "$_t" > testFile && chattr +a testFile && rm -f testFile || lsattr testFile && chattr -a testFile; rm -rf testFile; $OUT" "-----a------- testFile\n" "" "" -testing "chattr [-/+]a FILE[read]" "$IN && echo "$_t" > testFile && +testing "[-/+]a FILE[read]" "$IN && echo "$_t" > testFile && chattr +a testFile && cat testFile && lsattr testFile && chattr -a testFile; rm -rf testFile; $OUT" "$_t\n-----a------- testFile\n" "" "" for attr in "A" "a" "c" "D" "d" "i" "j" "s" "S" "t" "T" "u" do - testing "chattr [-/+]$attr FILE" "$IN && echo "$_t" > testFile && + testing "[-/+]$attr FILE" "$IN && echo "$_t" > testFile && chattr +$attr testFile && cat testFile && chattr -$attr testFile && lsattr testFile; rm -rf testFile; $OUT" "$_t\n------------- testFile\n" "" "" done for attr in "A" "a" "c" "D" "d" "i" "j" "s" "S" "t" "T" "u" do - testing "chattr -$attr FILE" "$IN && echo "$_t" > testFile && chattr -$attr testFile && + testing "-$attr FILE" "$IN && echo "$_t" > testFile && chattr -$attr testFile && cat testFile && lsattr testFile; rm -rf testFile; $OUT" "$_t\n------------- testFile\n" "" "" done -testing "chattr [-/+]AacDdijsStTu FILE" "$IN && echo "$_t" > testFile && +testing "[-/+]AacDdijsStTu FILE" "$IN && echo "$_t" > testFile && chattr +AacDdijsStTu testFile && cat testFile && chattr -AacDdijsStTu testFile && lsattr testFile; rm -rf testFile; $OUT" "$_t\n------------- testFile\n" "" "" -testing "chattr [-/+]AacDdijsStTu(random) FILE" \ +testing "[-/+]AacDdijsStTu(random) FILE" \ "$IN && echo "$_t" > testFile && chattr +AacDdijsStTu testFile && cat testFile && chattr -A testFile && chattr -a testFile && chattr -c testFile && chattr -D testFile && @@ -77,7 +77,7 @@ testing "chattr [-/+]AacDdijsStTu(random) FILE" \ chattr -T testFile && chattr -u testFile && lsattr testFile && chattr -AacDdijsStTu testFile; rm -rf testFile; $OUT" \ "$_t\n------------- testFile\n" "" "" -testing "chattr [-/+]AacDdijsStTu FILE*" "$IN && +testing "[-/+]AacDdijsStTu FILE*" "$IN && echo "$_t" > testFile && echo "$_t" > testFile1 && echo "$_t" > testFile2 && echo "$_t" > testFile3 && echo "$_t" > testFile4 && echo "$_t" > testFile5 && @@ -87,7 +87,7 @@ testing "chattr [-/+]AacDdijsStTu FILE*" "$IN && chattr +AacDdijsStTu testFile* && cat testFile9 && chattr -AacDdijsStTu testFile* && lsattr testFile*; rm -rf testFile*; $OUT" \ "$_t\n------------- testFile\n------------- testFile1\n------------- testFile10\n------------- testFile11\n------------- testFile2\n------------- testFile3\n------------- testFile4\n------------- testFile5\n------------- testFile6\n------------- testFile7\n------------- testFile8\n------------- testFile9\n" "" "" -testing "chattr [-/+]AacDdijsStTu(random) FILE*" \ +testing "[-/+]AacDdijsStTu(random) FILE*" \ "$IN && echo "$_t" > testFile && chattr +AacDdijsStTu testFile* && cat testFile && chattr -A testFile* && chattr -a testFile* && chattr -c testFile* && chattr -D testFile* && @@ -96,29 +96,29 @@ testing "chattr [-/+]AacDdijsStTu(random) FILE*" \ chattr -T testFile* && chattr -u testFile* && lsattr testFile; rm -rf testFile; $OUT" \ "$_t\n------------- testFile\n" "" "" -testing "chattr [-/+]i FILE[write]" \ +testing "[-/+]i FILE[write]" \ "$IN && echo "$_t" > testFile && chattr +i testFile && echo \"$_t\" > testFile || lsattr testFile && chattr -i testFile; rm -rf testFile; $OUT" "----i-------- testFile\n" "" "" -testing "chattr [-/+]A FILE[write]" \ +testing "[-/+]A FILE[write]" \ "$IN && echo "$_t" > testFile && chattr +A testFile && echo \"$_t\" > testFile && lsattr testFile && chattr -A testFile; rm -rf testFile; $OUT" "-------A----- testFile\n" "" "" -testing "chattr [-/+]s FILE[write]" \ +testing "[-/+]s FILE[write]" \ "$IN && echo "$_t" > testFile && chattr +s testFile && echo \"$_t\" > testFile && lsattr testFile && chattr -s testFile rm -rf testFile; $OUT" "s------------ testFile\n" "" "" -testing "chattr -v version FILE[write]" \ +testing "-v version FILE[write]" \ "$IN && echo "$_t" > testFile && chattr -v 1234 testFile && echo \"$_t\" > testFile && lsattr -v testFile; rm -rf testFile" \ " 1234 ------------- testFile\n" "" "" _a="-------A-----" -testing "chattr -R [-/+]a FILE" "$IN && touch aa && chattr -R +A aa && lsattr aa && +testing "-R [-/+]a FILE" "$IN && touch aa && chattr -R +A aa && lsattr aa && chattr -R -A aa; rm -rf aa; $OUT" "$_a aa\n" "" "" -testing "chattr -R [-/+]a FILE.." "$IN && touch aa bb && +testing "-R [-/+]a FILE.." "$IN && touch aa bb && chattr -R +A aa bb && lsattr aa bb && chattr -R -A aa bb; rm -rf aa bb; $OUT" "$_a aa\n$_a bb\n" "" "" diff --git a/tests/chgrp.test b/tests/chgrp.test index 5a741d9b..16cd776a 100755 --- a/tests/chgrp.test +++ b/tests/chgrp.test @@ -32,71 +32,71 @@ OUT="&& cd .. && echo \$(ls -lR testdir | awk '{print \$4}')" #testing "name" "command" "result" "infile" "stdin" # Basic smoketest -testing "chgrp dir" "$IN chgrp root dir $OUT" \ +testing "dir" "$IN chgrp root dir $OUT" \ "root $GRP $GRP $GRP $GRP $GRP $GRP\n" "" "" -testing "chgrp file" "$IN chgrp root dir/file $OUT" \ +testing "file" "$IN chgrp root dir/file $OUT" \ "$GRP $GRP $GRP root $GRP $GRP $GRP\n" "" "" -testing "chgrp dir and file" "$IN chgrp root dir dir/file $OUT" \ +testing "dir and file" "$IN chgrp root dir dir/file $OUT" \ "root $GRP $GRP root $GRP $GRP $GRP\n" "" "" # symlinks (affect target, not symlink) -testing "chgrp symlink->file" "$IN chgrp root dir2/file $OUT" \ +testing "symlink->file" "$IN chgrp root dir2/file $OUT" \ "$GRP $GRP $GRP root $GRP $GRP $GRP\n" "" "" -testing "chgrp symlink->dir" "$IN chgrp root dir2/dir $OUT" \ +testing "symlink->dir" "$IN chgrp root dir2/dir $OUT" \ "$GRP $GRP root $GRP $GRP $GRP $GRP\n" "" "" -testing "chgrp -h symlink->dir" "$IN chgrp -h root dir2/dir $OUT" \ +testing "-h symlink->dir" "$IN chgrp -h root dir2/dir $OUT" \ "$GRP $GRP $GRP $GRP $GRP root $GRP\n" "" "" # What does -h do (affect symlink, not target) -testing "chgrp -h symlink->file" "$IN chgrp -h root dir2/file $OUT" \ +testing "-h symlink->file" "$IN chgrp -h root dir2/file $OUT" \ "$GRP $GRP $GRP $GRP $GRP $GRP root\n" "" "" -testing "chgrp -h symlink->dir" "$IN chgrp -h root dir2/dir $OUT" \ +testing "-h symlink->dir" "$IN chgrp -h root dir2/dir $OUT" \ "$GRP $GRP $GRP $GRP $GRP root $GRP\n" "" "" # chgrp -R (note, -h is implied by -R) -testing "chgrp -R dir" "$IN chgrp -R root dir $OUT" \ +testing "-R dir" "$IN chgrp -R root dir $OUT" \ "root $GRP root root root $GRP $GRP\n" "" "" -testing "chgrp -R dir2" "$IN chgrp -R root dir2 $OUT" \ +testing "-R dir2" "$IN chgrp -R root dir2 $OUT" \ "$GRP root $GRP $GRP $GRP root root\n" "" "" -testing "chgrp -R symlink->dir" "$IN chgrp -R root dir2/dir $OUT" \ +testing "-R symlink->dir" "$IN chgrp -R root dir2/dir $OUT" \ "$GRP $GRP $GRP $GRP $GRP root $GRP\n" "" "" -testing "chgrp -R symlink->file" "$IN chgrp -R root dir2/file $OUT" \ +testing "-R symlink->file" "$IN chgrp -R root dir2/file $OUT" \ "$GRP $GRP $GRP $GRP $GRP $GRP root\n" "" "" # chgrp -RP (same as -R by itself) -testing "chgrp -RP dir2" "$IN chgrp -RP root dir2 $OUT" \ +testing "-RP dir2" "$IN chgrp -RP root dir2 $OUT" \ "$GRP root $GRP $GRP $GRP root root\n" "" "" -testing "chgrp -RP symlink->dir" "$IN chgrp -RP root dir2/dir $OUT" \ +testing "-RP symlink->dir" "$IN chgrp -RP root dir2/dir $OUT" \ "$GRP $GRP $GRP $GRP $GRP root $GRP\n" "" "" -testing "chgrp -RP symlink->file" "$IN chgrp -RP root dir2/file $OUT" \ +testing "-RP symlink->file" "$IN chgrp -RP root dir2/file $OUT" \ "$GRP $GRP $GRP $GRP $GRP $GRP root\n" "" "" # chgrp -RH (change target but only recurse through symlink->dir on cmdline) -testing "chgrp -RH dir2" "$IN chgrp -RH root dir2 $OUT" \ +testing "-RH dir2" "$IN chgrp -RH root dir2 $OUT" \ "$GRP root root root $GRP $GRP $GRP\n" "" "" -testing "chgrp -RH symlink->dir" "$IN chgrp -RH root dir2/dir $OUT" \ +testing "-RH symlink->dir" "$IN chgrp -RH root dir2/dir $OUT" \ "$GRP $GRP root $GRP root $GRP $GRP\n" "" "" -testing "chgrp -RH symlink->file" "$IN chgrp -RH root dir2/file $OUT" \ +testing "-RH symlink->file" "$IN chgrp -RH root dir2/file $OUT" \ "$GRP $GRP $GRP root $GRP $GRP $GRP\n" "" "" # chgrp -RL (change target and always recurse through symlink->dir) -testing "chgrp -RL dir2" "$IN chgrp -RL root dir2 $OUT" \ +testing "-RL dir2" "$IN chgrp -RL root dir2 $OUT" \ "$GRP root root root root $GRP $GRP\n" "" "" -testing "chgrp -RL symlink->dir" "$IN chgrp -RL root dir2/dir $OUT" \ +testing "-RL symlink->dir" "$IN chgrp -RL root dir2/dir $OUT" \ "$GRP $GRP root $GRP root $GRP $GRP\n" "" "" -testing "chgrp -RL symlink->file" "$IN chgrp -RL root dir2/file $OUT" \ +testing "-RL symlink->file" "$IN chgrp -RL root dir2/file $OUT" \ "$GRP $GRP $GRP root $GRP $GRP $GRP\n" "" "" # -HLP are NOPs without -R -testing "chgrp -H without -R" "$IN chgrp -H root dir2/dir $OUT" \ +testing "-H without -R" "$IN chgrp -H root dir2/dir $OUT" \ "$GRP $GRP root $GRP $GRP $GRP $GRP\n" "" "" -testing "chgrp -L without -R" "$IN chgrp -L root dir2/dir $OUT" \ +testing "-L without -R" "$IN chgrp -L root dir2/dir $OUT" \ "$GRP $GRP root $GRP $GRP $GRP $GRP\n" "" "" -testing "chgrp -P without -R" "$IN chgrp -P root dir2/dir $OUT" \ +testing "-P without -R" "$IN chgrp -P root dir2/dir $OUT" \ "$GRP $GRP root $GRP $GRP $GRP $GRP\n" "" "" rm -rf testdir diff --git a/tests/chmod.test b/tests/chmod.test index 887f738c..c2b64bd0 100755 --- a/tests/chmod.test +++ b/tests/chmod.test @@ -41,205 +41,205 @@ do DASH=- fi DASHES=$(num2perm $u$g$o) - testing "chmod $u$g$o $type" "chmod $u$g$o $type && + testing "$u$g$o $type" "chmod $u$g$o $type && ls -ld $type | cut -d' ' -f 1 | cut -d. -f 1" "$DASH$DASHES\n" "" "" done done done rm -rf dir file && mkdir dir && touch file -testing "chmod 750 dir 640 file" \ +testing "750 dir 640 file" \ "chmod 750 dir 640 file 2>/dev/null || ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x---\n-rwxr-x---\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod 666 dir file" \ +testing "666 dir file" \ "chmod 666 dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-rw-rw-\n-rw-rw-rw-\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod 765 *" "chmod 765 * && +testing "765 *" "chmod 765 * && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxrw-r-x\n-rwxrw-r-x\n" "" "" ##### u,g,o,a=r,w,x rm -rf dir file && mkdir dir && touch file -testing "chmod u=r dir file" "chmod u=r dir file && +testing "u=r dir file" "chmod u=r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr--r-xr-x\n-r--r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u=w dir file" "chmod u=w dir file && +testing "u=w dir file" "chmod u=w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-w-r-xr-x\n--w-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u=x dir file" "chmod u=x dir file && +testing "u=x dir file" "chmod u=x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d--xr-xr-x\n---xr--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u+r dir file" "chmod u+r dir file && +testing "u+r dir file" "chmod u+r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u+w dir file" "chmod u+w dir file && +testing "u+w dir file" "chmod u+w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u+x dir file" "chmod u+x dir file && +testing "u+x dir file" "chmod u+x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rwxr--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u-r dir file" "chmod u-r dir file && +testing "u-r dir file" "chmod u-r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-wxr-xr-x\n--w-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u-w dir file" "chmod u-w dir file && +testing "u-w dir file" "chmod u-w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod u-x dir file" "chmod u-x dir file && +testing "u-x dir file" "chmod u-x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-r-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g=r dir file" "chmod g=r dir file && +testing "g=r dir file" "chmod g=r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr--r-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g=w dir file" "chmod g=w dir file && +testing "g=w dir file" "chmod g=w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwx-w-r-x\n-rw--w-r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g=x dir file" "chmod g=x dir file && +testing "g=x dir file" "chmod g=x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwx--xr-x\n-rw---xr--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g+r dir file" "chmod g+r dir file && +testing "g+r dir file" "chmod g+r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g+w dir file" "chmod g+w dir file && +testing "g+w dir file" "chmod g+w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxrwxr-x\n-rw-rw-r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g+x dir file" "chmod g+x dir file && +testing "g+x dir file" "chmod g+x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r-xr--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g-r dir file" "chmod g-r dir file && +testing "g-r dir file" "chmod g-r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwx--xr-x\n-rw----r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g-w dir file" "chmod g-w dir file && +testing "g-w dir file" "chmod g-w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod g-x dir file" "chmod g-x dir file && +testing "g-x dir file" "chmod g-x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr--r-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o=r dir file" "chmod o=r dir file && +testing "o=r dir file" "chmod o=r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr--\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o=w dir file" "chmod o=w dir file && +testing "o=w dir file" "chmod o=w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x-w-\n-rw-r---w-\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o=x dir file" "chmod o=x dir file && +testing "o=x dir file" "chmod o=x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x--x\n-rw-r----x\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o+r dir file" "chmod o+r dir file && +testing "o+r dir file" "chmod o+r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o+w dir file" "chmod o+w dir file && +testing "o+w dir file" "chmod o+w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xrwx\n-rw-r--rw-\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o+x dir file" "chmod o+x dir file && +testing "o+x dir file" "chmod o+x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r-x\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o-r dir file" "chmod o-r dir file && +testing "o-r dir file" "chmod o-r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-x--x\n-rw-r-----\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o-w dir file" "chmod o-w dir file && +testing "o-w dir file" "chmod o-w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod o-x dir file" "chmod o-x dir file && +testing "o-x dir file" "chmod o-x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr--\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a=r dir file" "chmod a=r dir file && +testing "a=r dir file" "chmod a=r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr--r--r--\n-r--r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a=w dir file" "chmod a=w dir file && +testing "a=w dir file" "chmod a=w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-w--w--w-\n--w--w--w-\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a=x dir file" "chmod a=x dir file && +testing "a=x dir file" "chmod a=x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d--x--x--x\n---x--x--x\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a+r dir file" "chmod a+r dir file && +testing "a+r dir file" "chmod a+r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a+w dir file" "chmod a+w dir file && +testing "a+w dir file" "chmod a+w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxrwxrwx\n-rw-rw-rw-\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a+x dir file" "chmod a+x dir file && +testing "a+x dir file" "chmod a+x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rwxr-xr-x\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a-r dir file" "chmod a-r dir file && +testing "a-r dir file" "chmod a-r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-wx--x--x\n--w-------\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a-w dir file" "chmod a-w dir file && +testing "a-w dir file" "chmod a-w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod a-x dir file" "chmod a-x dir file && +testing "a-x dir file" "chmod a-x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-r--r--\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod =r dir file" "chmod =r dir file && +testing "=r dir file" "chmod =r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr--r--r--\n-r--r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod =w dir file" "chmod =w dir file && +testing "=w dir file" "chmod =w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-w-------\n--w-------\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod =x dir file" "chmod =x dir file && +testing "=x dir file" "chmod =x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d--x--x--x\n---x--x--x\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod +r dir file" "chmod +r dir file && +testing "+r dir file" "chmod +r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod +w dir file" "chmod +w dir file && +testing "+w dir file" "chmod +w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod +x dir file" "chmod +x dir file && +testing "+x dir file" "chmod +x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drwxr-xr-x\n-rwxr-xr-x\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod -r dir file" "chmod -r dir file && +testing "-r dir file" "chmod -r dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "d-wx--x--x\n--w-------\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod -w dir file" "chmod -w dir file && +testing "-w dir file" "chmod -w dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" "" rm -rf dir file && mkdir dir && touch file -testing "chmod -x dir file" "chmod -x dir file && +testing "-x dir file" "chmod -x dir file && ls -ld dir file | cut -d' ' -f 1 | cut -d. -f 1" "drw-r--r--\n-rw-r--r--\n" "" "" # Removing test files for cleanup purpose diff --git a/tests/chown.test b/tests/chown.test index 408d5f34..95ad727a 100755 --- a/tests/chown.test +++ b/tests/chown.test @@ -29,13 +29,13 @@ OUT="&& echo \$(ls -l testdir/file | awk '{print \$3,\$4}')" #testing "name" "command" "result" "infile" "stdin" # Basic smoketest -testing "chown initial" "chown root:root $F $OUT" "root root\n" "" "" -testing "chown usr:grp" "chown $USR:$GRP $F $OUT" "$USR $GRP\n" "" "" -testing "chown root" "chown root $F $OUT" "root $GRP\n" "" "" +testing "initial" "chown root:root $F $OUT" "root root\n" "" "" +testing "usr:grp" "chown $USR:$GRP $F $OUT" "$USR $GRP\n" "" "" +testing "root" "chown root $F $OUT" "root $GRP\n" "" "" # TODO: can we test "owner:"? -testing "chown :grp" "chown root:root $F && chown :$GRP $F $OUT" \ +testing ":grp" "chown root:root $F && chown :$GRP $F $OUT" \ "root $GRP\n" "" "" -testing "chown :" "chown $USR:$GRP $F && chown : $F $OUT" \ +testing ":" "chown $USR:$GRP $F && chown : $F $OUT" \ "$USR $GRP\n" "" "" rm -rf testdir diff --git a/tests/cksum.test b/tests/cksum.test index 152dc12c..01938f43 100755 --- a/tests/cksum.test +++ b/tests/cksum.test @@ -6,24 +6,24 @@ #testing "name" "command" "result" "infile" "stdin" # Default behavior on stdin and on files. -testing "cksum on stdin" "echo -n hello | cksum" "3287646509 5\n" "" "" +testing "on stdin" "echo -n hello | cksum" "3287646509 5\n" "" "" echo -n "hello" > tmpfile -testing "cksum on file" "cksum tmpfile" "3287646509 5 tmpfile\n" "" "" +testing "on file" "cksum tmpfile" "3287646509 5 tmpfile\n" "" "" rm -f tmpfile touch one two -testing "cksum on multiple files" "cksum one two" "4294967295 0 one\n4294967295 0 two\n" "" "" +testing "on multiple files" "cksum one two" "4294967295 0 one\n4294967295 0 two\n" "" "" rm -f one two # Check the length suppression, both calculate the CRC on 'abc' but the second # option has length suppression on and has the length concatenated to 'abc'. -testing "cksum on abc including length" "echo -n 'abc' | cksum" "1219131554 3\n" "" "" -testing "cksum on abc excluding length" "echo -ne 'abc\x3' | cksum -N" "1219131554 4\n" "" "" +testing "on abc including length" "echo -n 'abc' | cksum" "1219131554 3\n" "" "" +testing "on abc excluding length" "echo -ne 'abc\x3' | cksum -N" "1219131554 4\n" "" "" # cksum on no contents gives 0xffffffff (=4294967295) -testing "cksum on no data post-inversion" "echo -n "" | cksum" "4294967295 0\n" "" "" +testing "on no data post-inversion" "echo -n "" | cksum" "4294967295 0\n" "" "" # If we do preinversion we will then get 0. -testing "cksum on no data pre+post-inversion" "echo -n "" | cksum -P" "0 0\n" "" "" +testing "on no data pre+post-inversion" "echo -n "" | cksum -P" "0 0\n" "" "" # If we skip the post-inversion we also get 0 -testing "cksum on no data no inversion" "echo -n "" | cksum -I" "0 0\n" "" "" +testing "on no data no inversion" "echo -n "" | cksum -I" "0 0\n" "" "" # Two wrongs make a right. -testing "cksum on no data pre-inversion" "echo -n "" | cksum -PI" "4294967295 0\n" "" "" +testing "on no data pre-inversion" "echo -n "" | cksum -PI" "4294967295 0\n" "" "" diff --git a/tests/cmp.test b/tests/cmp.test index ef53b37d..c3e8f5be 100755 --- a/tests/cmp.test +++ b/tests/cmp.test @@ -2,34 +2,34 @@ [ -f testing.sh ] && . testing.sh -testing "cmp not enough arguments [fail]" "cmp input 2>/dev/null || echo yes" "yes\n" "foo" "" -testing "cmp missing file1 [fail]" "cmp file1 input 2>/dev/null || echo yes" "yes\n" "foo" "" +testing "not enough arguments [fail]" "cmp input 2>/dev/null || echo yes" "yes\n" "foo" "" +testing "missing file1 [fail]" "cmp file1 input 2>/dev/null || echo yes" "yes\n" "foo" "" #mkdir dir -#testing "cmp directory [fail]" "cmp dir dir 2>/dev/null || echo yes" \ +#testing "directory [fail]" "cmp dir dir 2>/dev/null || echo yes" \ #"yes\n" "" "" #rmdir dir echo "ab c" > input2 -testing "cmp identical files, stdout" "cmp input input2" "" "ab\nc\n" "" -testing "cmp identical files, return code" "cmp input input2 && echo yes" "yes\n" "ab\nc\n" "" +testing "identical files, stdout" "cmp input input2" "" "ab\nc\n" "" +testing "identical files, return code" "cmp input input2 && echo yes" "yes\n" "ab\nc\n" "" -testing "cmp EOF, stderr" "cmp input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" "" -testing "cmp EOF, return code" "cmp input input2 2>/dev/null || echo yes" "yes\n" "ab\nc\nx" "" +testing "EOF, stderr" "cmp input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" "" +testing "EOF, return code" "cmp input input2 2>/dev/null || echo yes" "yes\n" "ab\nc\nx" "" # The gnu/dammit version fails this because posix says "char" and they don't. -testing "cmp diff, stdout" "cmp input input2" "input input2 differ: char 4, line 2\n" "ab\nx\nx" "" -testing "cmp diff, return code" "cmp input input2 > /dev/null || echo yes" "yes\n" "ab\nx\nx" "" +testing "diff, stdout" "cmp input input2" "input input2 differ: char 4, line 2\n" "ab\nx\nx" "" +testing "diff, return code" "cmp input input2 > /dev/null || echo yes" "yes\n" "ab\nx\nx" "" -testing "cmp -s EOF, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nc\nx" "" -testing "cmp -s diff, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nx\nx" "" +testing "-s EOF, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nc\nx" "" +testing "-s diff, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nx\nx" "" -testing "cmp -l EOF, stderr" "cmp -l input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" "" -testing "cmp -l diff and EOF, stdout and stderr" "cmp -l input input2 2>&1 | sort" "4 170 143\ncmp: EOF on input2\n" "ab\nx\nx" "" +testing "-l EOF, stderr" "cmp -l input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" "" +testing "-l diff and EOF, stdout and stderr" "cmp -l input input2 2>&1 | sort" "4 170 143\ncmp: EOF on input2\n" "ab\nx\nx" "" rm input2 -testing "cmp stdin and file" "cmp input -" "input - differ: char 4, line 2\n" "ab\nc\n" "ab\nx\n" -#testing "cmp stdin and stdin" "cmp input -" "" "" "ab\nc\n" +testing "stdin and file" "cmp input -" "input - differ: char 4, line 2\n" "ab\nc\n" "ab\nx\n" +#testing "stdin and stdin" "cmp input -" "" "" "ab\nc\n" diff --git a/tests/cp.test b/tests/cp.test index 43272565..2b89e2f2 100755 --- a/tests/cp.test +++ b/tests/cp.test @@ -7,45 +7,45 @@ dd if=/dev/urandom of=random bs=64 count=1 2> /dev/null #testing "name" "command" "result" "infile" "stdin" -testing "cp not enough arguments [fail]" "cp one 2>/dev/null || echo yes" \ +testing "not enough arguments [fail]" "cp one 2>/dev/null || echo yes" \ "yes\n" "" "" -testing "cp -missing source [fail]" "cp missing two 2>/dev/null || echo yes" \ +testing "-missing source [fail]" "cp missing two 2>/dev/null || echo yes" \ "yes\n" "" "" -testing "cp file->file" "cp random two && cmp random two && echo yes" \ +testing "file->file" "cp random two && cmp random two && echo yes" \ "yes\n" "" "" rm two mkdir two -testing "cp file->dir" "cp random two && cmp random two/random && echo yes" \ +testing "file->dir" "cp random two && cmp random two/random && echo yes" \ "yes\n" "" "" rm two/random -testing "cp file->dir/file" \ +testing "file->dir/file" \ "cp random two/random && cmp random two/random && echo yes" \ "yes\n" "" "" -testing "cp -r dir->missing" \ +testing "-r dir->missing" \ "cp -r two three && cmp random three/random && echo yes" \ "yes\n" "" "" touch walrus -testing "cp -r dir->file [fail]" \ +testing "-r dir->file [fail]" \ "cp -r two walrus 2>/dev/null || echo yes" "yes\n" "" "" touch two/three -testing "cp -r dir hits file." \ +testing "-r dir hits file." \ "cp -r three two 2>/dev/null || echo yes" "yes\n" "" "" rm -rf two three walrus touch two chmod 000 two -testing "cp file->inaccessable [fail]" \ +testing "file->inaccessable [fail]" \ "cp random two 2>/dev/null || echo yes" "yes\n" "" "" rm -f two touch two chmod 000 two -testing "cp -f file->inaccessable" \ +testing "-f file->inaccessable" \ "cp -f random two && cmp random two && echo yes" "yes\n" "" "" mkdir sub chmod 000 sub -testing "cp file->inaccessable_dir [fail]" \ +testing "file->inaccessable_dir [fail]" \ "cp random sub 2>/dev/null || echo yes" "yes\n" "" "" rm two rmdir sub @@ -56,21 +56,21 @@ rmdir sub #mkdir dir #touch file -#testing "cp -rf dir file [fail]" "cp -rf dir file 2>/dev/null || echo yes" \ +#testing "-rf dir file [fail]" "cp -rf dir file 2>/dev/null || echo yes" \ # "yes\n" "" "" #rm -rf dir file touch one two -testing "cp file1 file2 missing [fail]" \ +testing "file1 file2 missing [fail]" \ "cp one two missing 2>/dev/null || echo yes" "yes\n" "" "" mkdir dir -testing "cp dir file missing [fail]" \ +testing "dir file missing [fail]" \ "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" "" -testing "cp -rf dir file missing [fail]" \ +testing "-rf dir file missing [fail]" \ "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" "" -testing "cp file1 file2 file [fail]" \ +testing "file1 file2 file [fail]" \ "cp random one two 2>/dev/null || echo yes" "yes\n" "" "" -testing "cp file1 file2 dir" \ +testing "file1 file2 dir" \ "cp random one dir && cmp random dir/random && cmp one dir/one && echo yes" \ "yes\n" "" "" rm one two random @@ -79,13 +79,13 @@ rm -rf dir mkdir -p one/two/three/four touch one/two/three/five touch one/{six,seven,eight} -testing "cp -r /abspath dest" \ +testing "-r /abspath dest" \ "cp -r \"$(readlink -f one)\" dir && diff -r one dir && echo yes" \ "yes\n" "" "" -testing "cp -r dir again" "cp -r one/. dir && diff -r one dir && echo yes" \ +testing "-r dir again" "cp -r one/. dir && diff -r one dir && echo yes" \ "yes\n" "" "" mkdir dir2 -testing "cp -r dir1/* dir2" \ +testing "-r dir1/* dir2" \ "cp -r one/* dir2 && diff -r one dir2 && echo yes" "yes\n" "" "" rm -rf one dir dir2 diff --git a/tests/cpio.test b/tests/cpio.test index 2d91b06d..5158efa4 100755 --- a/tests/cpio.test +++ b/tests/cpio.test @@ -7,14 +7,14 @@ # plus file sizes of at least 0-4. touch a bb ccc dddd -testing "cpio name padding" "cpio -o -H newc|cpio -it" "a\nbb\nccc\ndddd\n" "" "a\nbb\nccc\ndddd\n" +testing "name padding" "cpio -o -H newc|cpio -it" "a\nbb\nccc\ndddd\n" "" "a\nbb\nccc\ndddd\n" rm a bb ccc dddd touch a printf '1' >b printf '22' >c printf '333' >d -testing "cpio file padding" "cpio -o -H newc|cpio -it" "a\nb\nc\nd\n" "" "a\nb\nc\nd\n" +testing "file padding" "cpio -o -H newc|cpio -it" "a\nb\nc\nd\n" "" "a\nb\nc\nd\n" rm a b c d touch a @@ -25,15 +25,15 @@ printf '333' >dddd # the relevant bit should be here: # 110*5 + 4*3 + 2 + 6*3 = 550 + 12 + 20 = 582 # files are padded to n*4, names are padded to 2 + n*4 due to the header length -testing "cpio archive length" "cpio -o -H newc|dd ibs=2 skip=291 count=5 2>/dev/null" "TRAILER!!!" "" "a\nbb\nccc\ndddd\n" -testing "cpio archive magic" "cpio -o -H newc|dd ibs=2 count=3 2>/dev/null" "070701" "" "a\n" +testing "archive length" "cpio -o -H newc|dd ibs=2 skip=291 count=5 2>/dev/null" "TRAILER!!!" "" "a\nbb\nccc\ndddd\n" +testing "archive magic" "cpio -o -H newc|dd ibs=2 count=3 2>/dev/null" "070701" "" "a\n" # check name length (8 bytes before the empty "crc") -testing "cpio name length" "cpio -o -H newc|dd ibs=2 skip=47 count=4 2>/dev/null" "00000002" "" "a\n" +testing "name length" "cpio -o -H newc|dd ibs=2 skip=47 count=4 2>/dev/null" "00000002" "" "a\n" rm a bb ccc dddd # archive dangling symlinks and empty files even if we cannot open them touch a; chmod a-rwx a; ln -s a/cant b -testing "cpio archives unreadable empty files" "cpio -o -H newc|cpio -it" "a\nb\n" "" "a\nb\n" +testing "archives unreadable empty files" "cpio -o -H newc|cpio -it" "a\nb\n" "" "a\nb\n" chmod u+rw a; rm -f a b diff --git a/tests/cut.test b/tests/cut.test index a0019527..f84acea8 100755 --- a/tests/cut.test +++ b/tests/cut.test @@ -14,20 +14,20 @@ echo "one:two:three:four:five:six:seven alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu the quick brown fox jumps over the lazy dog" >abc.txt -testing "cut with -c (a-b)" "cut -c 4-10 abc.txt" ":two:th\nha:beta\n quick \n" "" "" -testing "cut with -f (a-)" "cut -d ':' -f 5- abc.txt" "five:six:seven\nepsilon:zeta:eta:teta:iota:kappa:lambda:mu\nthe quick brown fox jumps over the lazy dog\n" "" "" +testing "with -c (a-b)" "cut -c 4-10 abc.txt" ":two:th\nha:beta\n quick \n" "" "" +testing "with -f (a-)" "cut -d ':' -f 5- abc.txt" "five:six:seven\nepsilon:zeta:eta:teta:iota:kappa:lambda:mu\nthe quick brown fox jumps over the lazy dog\n" "" "" -testing "cut with -f (a)" "cut -d ' ' -f 3 abc.txt" "one:two:three:four:five:six:seven\nalpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu\nbrown\n" "" "" +testing "with -f (a)" "cut -d ' ' -f 3 abc.txt" "one:two:three:four:five:six:seven\nalpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu\nbrown\n" "" "" -testing "cut with echo, -c (a-b)" "echo 'ref_categorie=test' | cut -c 1-15 " "ref_categorie=t\n" "" "" -testing "cut with echo, -c (a)" "echo 'ref_categorie=test' | cut -c 14" "=\n" "" "" +testing "with echo, -c (a-b)" "echo 'ref_categorie=test' | cut -c 1-15 " "ref_categorie=t\n" "" "" +testing "with echo, -c (a)" "echo 'ref_categorie=test' | cut -c 14" "=\n" "" "" # Modifying abc.txt data as per new testcase echo "abcdefghijklmnopqrstuvwxyz" >abc.txt -testing "cut with -c (a,b,c)" "cut -c 4,5,20 abc.txt" "det\n" "" "" +testing "with -c (a,b,c)" "cut -c 4,5,20 abc.txt" "det\n" "" "" -testing "cut with -b (a,b,c)" "cut -b 4,5,20 abc.txt" "det\n" "" "" +testing "with -b (a,b,c)" "cut -b 4,5,20 abc.txt" "det\n" "" "" # Modifying abc.txt data as per testcase echo "406378:Sales:Itorre:Jan @@ -35,13 +35,13 @@ echo "406378:Sales:Itorre:Jan 636496:Research:Ancholie:Mel 396082:Sales:Jucacion:Ed" >abc.txt -testing "cut with -d -f(:) -s" "cut -d: -f3 -s abc.txt" "Itorre\nNasium\nAncholie\nJucacion\n" "" "" +testing "with -d -f(:) -s" "cut -d: -f3 -s abc.txt" "Itorre\nNasium\nAncholie\nJucacion\n" "" "" -testing "cut with -d -f( ) -s" "cut -d' ' -f3 -s abc.txt && echo yes" "yes\n" "" "" +testing "with -d -f( ) -s" "cut -d' ' -f3 -s abc.txt && echo yes" "yes\n" "" "" -testing "cut with -d -f(a) -s" "cut -da -f3 -s abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" "" +testing "with -d -f(a) -s" "cut -da -f3 -s abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" "" -testing "cut with -d -f(a) -s -n" "cut -da -f3 -s -n abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" "" +testing "with -d -f(a) -s -n" "cut -da -f3 -s -n abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" "" # Removing abc.txt file for cleanup purpose rm abc.txt diff --git a/tests/date.test b/tests/date.test index 62c0ed63..1d77faa5 100644 --- a/tests/date.test +++ b/tests/date.test @@ -5,22 +5,22 @@ #testing "name" "command" "result" "infile" "stdin" # Test Unix date parsing. -testing "date -d @0" "TZ=UTC date -d @0 2>&1" "Thu Jan 1 00:00:00 GMT 1970\n" "" "" -testing "date -d @0x123" "TZ=UTC date -d @0x123 2>&1" "date: bad date '@0x123'\n" "" "" +testing "-d @0" "TZ=UTC date -d @0 2>&1" "Thu Jan 1 00:00:00 GMT 1970\n" "" "" +testing "-d @0x123" "TZ=UTC date -d @0x123 2>&1" "date: bad date '@0x123'\n" "" "" # Test basic date parsing. # Note that toybox's -d format is not the same as coreutils'. -testing "date -d 06021234" "TZ=UTC date -d 06021234 2>&1" "Sun Jun 2 12:34:00 UTC 1900\n" "" "" -testing "date -d 060212341982" "TZ=UTC date -d 060212341982 2>&1" "Sun Jun 2 12:34:00 UTC 1982\n" "" "" -testing "date -d 123" "TZ=UTC date -d 123 2>&1" "date: bad date '123'\n" "" "" +testing "-d 06021234" "TZ=UTC date -d 06021234 2>&1" "Sun Jun 2 12:34:00 UTC 1900\n" "" "" +testing "-d 060212341982" "TZ=UTC date -d 060212341982 2>&1" "Sun Jun 2 12:34:00 UTC 1982\n" "" "" +testing "-d 123" "TZ=UTC date -d 123 2>&1" "date: bad date '123'\n" "" "" # Test parsing 2- and 4-digit years. -testing "date -d 1110143115.30" "TZ=UTC date -d 1110143115.30 2>&1" "Sun Nov 10 14:31:30 UTC 1915\n" "" "" -testing "date -d 111014312015.30" "TZ=UTC date -d 111014312015.30 2>&1" "Sun Nov 10 14:31:30 UTC 2015\n" "" "" +testing "-d 1110143115.30" "TZ=UTC date -d 1110143115.30 2>&1" "Sun Nov 10 14:31:30 UTC 1915\n" "" "" +testing "-d 111014312015.30" "TZ=UTC date -d 111014312015.30 2>&1" "Sun Nov 10 14:31:30 UTC 2015\n" "" "" # Accidentally given a Unix time, we should trivially reject that. -testing "date Unix time missing @" "TZ=UTC date 1438053157 2>&1" \ +testing "Unix time missing @" "TZ=UTC date 1438053157 2>&1" \ "date: bad date '1438053157'; Wed February 38 05:31:00 UTC 2057 != Sun Mar 10 05:31:00 UTC 2058\n" "" "" # But some invalid dates are more subtle, like Febuary 29th in a non-leap year. -testing "date Feb 29th" "TZ=UTC date 022900001975 2>&1" \ +testing "Feb 29th" "TZ=UTC date 022900001975 2>&1" \ "date: bad date '022900001975'; Wed Feb 29 00:00:00 UTC 1975 != Sat Mar 1 00:00:00 UTC 1975\n" "" "" diff --git a/tests/dd.test b/tests/dd.test index 9bdcac5b..42cd170a 100755 --- a/tests/dd.test +++ b/tests/dd.test @@ -10,74 +10,74 @@ opt="2>/dev/null" #testing "name" "command" "result" "infile" "stdin" -testing "dd if=(file)" "dd if=input $opt" "I WANT\n" "I WANT\n" "" -testing "dd of=(file)" "dd of=file $opt && cat file" "I WANT\n" "" "I WANT\n" -testing "dd if=file of=file" "dd if=input of=foo $opt && cat foo && rm -f foo" \ +testing "if=(file)" "dd if=input $opt" "I WANT\n" "I WANT\n" "" +testing "of=(file)" "dd of=file $opt && cat file" "I WANT\n" "" "I WANT\n" +testing "if=file of=file" "dd if=input of=foo $opt && cat foo && rm -f foo" \ "I WANT\n" "I WANT\n" "" -testing "dd if=file | dd of=file" "dd if=input $opt | dd of=foo $opt && +testing "if=file | dd of=file" "dd if=input $opt | dd of=foo $opt && cat foo && rm -f foo" "I WANT\n" "I WANT\n" "" -testing "dd (stdout)" "dd $opt" "I WANT\n" "" "I WANT\n" -testing "dd sync,noerror" \ +testing "(stdout)" "dd $opt" "I WANT\n" "" "I WANT\n" +testing "sync,noerror" \ "dd if=input of=outFile seek=8860 bs=1M conv=sync,noerror $opt && stat -c \"%s\" outFile && rm -f outFile" "9291431936\n" "I WANT\n" "" -testing "dd if=file of=(null)" \ +testing "if=file of=(null)" \ "dd if=input of=/dev/null $opt && echo 'yes'" "yes\n" "I WANT\n" "" -testing "dd with if of bs" \ +testing "with if of bs" \ "dd if=/dev/zero of=sda.txt bs=512 count=1 $opt && stat -c '%s' sda.txt && rm -f sda.txt" "512\n" "" "" -testing "dd with if of ibs obs" \ +testing "with if of ibs obs" \ "dd if=/dev/zero of=sda.txt ibs=512 obs=256 count=1 $opt && stat -c '%s' sda.txt && rm -f sda.txt" "512\n" "" "" -testing "dd with if of ibs obs count" \ +testing "with if of ibs obs count" \ "dd if=/dev/zero of=sda.txt ibs=512 obs=256 count=3 $opt && stat -c '%s' sda.txt && rm -f sda.txt" "1536\n" "" "" ln -s input softlink -testing "dd if=softlink" "dd if=softlink $opt" "I WANT\n" "I WANT\n" "" +testing "if=softlink" "dd if=softlink $opt" "I WANT\n" "I WANT\n" "" unlink softlink ln -s file softlink -testing "dd if=file of=softlink" "dd if=input of=softlink $opt && +testing "if=file of=softlink" "dd if=input of=softlink $opt && [ -f file -a -L softlink ] && cat softlink" "I WANT\n" "I WANT\n" "" unlink softlink && rm -f file -testing "dd if=file of=file (same file)" "dd if=input of=input $opt && +testing "if=file of=file (same file)" "dd if=input of=input $opt && [ -f input ] && cat input && echo 'yes'" "yes\n" "I WANT\n" "" -testing "dd with ibs obs bs" "dd ibs=2 obs=5 bs=9 $opt" "I WANT\n" "" "I WANT\n" -testing "dd with ibs obs bs if" "dd ibs=2 obs=5 bs=9 if=input $opt" \ +testing "with ibs obs bs" "dd ibs=2 obs=5 bs=9 $opt" "I WANT\n" "" "I WANT\n" +testing "with ibs obs bs if" "dd ibs=2 obs=5 bs=9 if=input $opt" \ "I WANT\n" "I WANT\n" "" -testing "dd with ibs obs count" "dd ibs=1 obs=1 count=1 $opt" "I" "" "I WANT\n" -testing "dd with ibs obs count if" "dd ibs=1 obs=1 count=3 if=input $opt" \ +testing "with ibs obs count" "dd ibs=1 obs=1 count=1 $opt" "I" "" "I WANT\n" +testing "with ibs obs count if" "dd ibs=1 obs=1 count=3 if=input $opt" \ "I W" "I WANT\n" "" -testing "dd with count" "dd count=1 $opt" "I WANT\n" "" "I WANT\n" -testing "dd with count if" "dd count=1 if=input $opt" "I WANT\n" "I WANT\n" "" +testing "with count" "dd count=1 $opt" "I WANT\n" "" "I WANT\n" +testing "with count if" "dd count=1 if=input $opt" "I WANT\n" "I WANT\n" "" -testing "dd with skip" "dd skip=0 $opt" "I WANT\n" "" "I WANT\n" -testing "dd with skip if" "dd skip=0 if=input $opt" "I WANT\n" "I WANT\n" "" +testing "with skip" "dd skip=0 $opt" "I WANT\n" "" "I WANT\n" +testing "with skip if" "dd skip=0 if=input $opt" "I WANT\n" "I WANT\n" "" -testing "dd with seek" "dd seek=0 $opt" "I WANT\n" "" "I WANT\n" -testing "dd with seek if" "dd seek=0 if=input $opt" "I WANT\n" "I WANT\n" "" +testing "with seek" "dd seek=0 $opt" "I WANT\n" "" "I WANT\n" +testing "with seek if" "dd seek=0 if=input $opt" "I WANT\n" "I WANT\n" "" # These type of conv is not supported in toybox: 'ascii', 'ebcdic', 'ibm', # 'block', 'unblock', 'nocreat', 'notronc', 'lcase', 'ucase', 'excl', 'swab' # Testing only 'notrunc', 'noerror', 'fsync', 'sync' -testing "dd conv=notrunc" "dd conv=notrunc $opt" "I WANT\n" "" "I WANT\n" -testing "dd conv=notrunc with IF" "dd conv=notrunc if=input $opt" "I WANT\n" \ +testing "conv=notrunc" "dd conv=notrunc $opt" "I WANT\n" "" "I WANT\n" +testing "conv=notrunc with IF" "dd conv=notrunc if=input $opt" "I WANT\n" \ "I WANT\n" "" -testing "dd conv=noerror" "dd conv=noerror $opt" "I WANT\n" "" "I WANT\n" -testing "dd conv=noerror with IF" "dd conv=noerror if=input $opt" "I WANT\n" \ +testing "conv=noerror" "dd conv=noerror $opt" "I WANT\n" "" "I WANT\n" +testing "conv=noerror with IF" "dd conv=noerror if=input $opt" "I WANT\n" \ "I WANT\n" "" -testing "dd conv=fsync" "dd conv=fsync $opt" "I WANT\n" "" "I WANT\n" -testing "dd conv=fsync with IF" "dd conv=fsync if=input $opt" "I WANT\n" \ +testing "conv=fsync" "dd conv=fsync $opt" "I WANT\n" "" "I WANT\n" +testing "conv=fsync with IF" "dd conv=fsync if=input $opt" "I WANT\n" \ "I WANT\n" "" -testing "dd conv=sync" "dd conv=sync $opt | head -n 1" "I WANT\n" "" "I WANT\n" -testing "dd conv=sync with IF" "dd conv=sync if=input $opt | head -n 1" "I WANT\n" \ +testing "conv=sync" "dd conv=sync $opt | head -n 1" "I WANT\n" "" "I WANT\n" +testing "conv=sync with IF" "dd conv=sync if=input $opt | head -n 1" "I WANT\n" \ "I WANT\n" "" diff --git a/tests/dirname.test b/tests/dirname.test index a0075384..3ea89197 100755 --- a/tests/dirname.test +++ b/tests/dirname.test @@ -4,7 +4,7 @@ #testing "name" "command" "result" "infile" "stdin" -testing "dirname /-only" "dirname ///////" "/\n" "" "" -testing "dirname trailing /" "dirname a//////" ".\n" "" "" -testing "dirname combined" "dirname /////a///b///c///d/////" "/////a///b///c\n" "" "" -testing "dirname /a/" "dirname /////a///" "/\n" "" "" +testing "/-only" "dirname ///////" "/\n" "" "" +testing "trailing /" "dirname a//////" ".\n" "" "" +testing "combined" "dirname /////a///b///c///d/////" "/////a///b///c\n" "" "" +testing "/a/" "dirname /////a///" "/\n" "" "" diff --git a/tests/du.test b/tests/du.test index 81fb5282..a0960743 100755 --- a/tests/du.test +++ b/tests/du.test @@ -9,23 +9,23 @@ # while -k is the default on most Linux systems mkdir -p du_test/test du_2/foo -testing "du (no options)" "du -k du_test" "4\tdu_test/test\n8\tdu_test\n" "" "" -testing "du -s" "du -k -s du_test" "8\tdu_test\n" "" "" +testing "(no options)" "du -k du_test" "4\tdu_test/test\n8\tdu_test\n" "" "" +testing "-s" "du -k -s du_test" "8\tdu_test\n" "" "" ln -s ../du_2 du_test/xyz # "du shall count the size of the symbolic link" # The tests assume that like for most POSIX systems symbolic # links are stored directly in the inode so that the # allocated file space is zero. -testing "du counts symlinks without following" "du -ks du_test" "8\tdu_test\n" "" "" -testing "du -L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" "" +testing "counts symlinks without following" "du -ks du_test" "8\tdu_test\n" "" "" +testing "-L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" "" ln -s . du_test/up -testing "du -L avoid endless loop" "du -ksL du_test" "16\tdu_test\n" "" "" +testing "-L avoid endless loop" "du -ksL du_test" "16\tdu_test\n" "" "" rm du_test/up # if -H and -L are specified, the last takes priority -testing "du -HL follows symlinks" "du -ksHL du_test" "16\tdu_test\n" "" "" -testing "du -H does not follow unspecified symlinks" "du -ksH du_test" "8\tdu_test\n" "" "" -testing "du -LH does not follow unspecified symlinks" "du -ksLH du_test" "8\tdu_test\n" "" "" -testing "du -H follows specified symlinks" "du -ksH du_test/xyz" "8\tdu_test/xyz\n" "" "" +testing "-HL follows symlinks" "du -ksHL du_test" "16\tdu_test\n" "" "" +testing "-H does not follow unspecified symlinks" "du -ksH du_test" "8\tdu_test\n" "" "" +testing "-LH does not follow unspecified symlinks" "du -ksLH du_test" "8\tdu_test\n" "" "" +testing "-H follows specified symlinks" "du -ksH du_test/xyz" "8\tdu_test/xyz\n" "" "" rm -rf du_test du_2 diff --git a/tests/echo.test b/tests/echo.test index 3f562fd8..58499640 100755 --- a/tests/echo.test +++ b/tests/echo.test @@ -12,26 +12,26 @@ CMD="$(which echo)" #testing "name" "command" "result" "infile" "stdin" testing "echo" "$CMD && echo yes" "\nyes\n" "" "" -testing "echo 1 2 3" "$CMD one two three" "one two three\n" "" "" -testing "echo with spaces" "$CMD 'one two three'" \ +testing "1 2 3" "$CMD one two three" "one two three\n" "" "" +testing "with spaces" "$CMD 'one two three'" \ "one two three\n" "" "" -testing "echo -n" "$CMD -n" "" "" "" -testing "echo -n one" "$CMD -n one" "one" "" "" -testing "echo one -n" "$CMD one -n" "one -n\n" "" "" -testing "echo -en" "$CMD -en 'one\ntwo'" "one\ntwo" "" "" -testing "echo --hello" "$CMD --hello" "--hello\n" "" "" -testing "echo -e all" "$CMD -e '\a\b\c\f\n\r\t\v\\\0123'" \ +testing "-n" "$CMD -n" "" "" "" +testing "-n one" "$CMD -n one" "one" "" "" +testing "one -n" "$CMD one -n" "one -n\n" "" "" +testing "-en" "$CMD -en 'one\ntwo'" "one\ntwo" "" "" +testing "--hello" "$CMD --hello" "--hello\n" "" "" +testing "-e all" "$CMD -e '\a\b\c\f\n\r\t\v\\\0123'" \ "\a\b\c\f\n\r\t\v\\\0123\n" "" "" -testing "echo -nex hello" "$CMD -nex hello" "-nex hello\n" "" "" +testing "-nex hello" "$CMD -nex hello" "-nex hello\n" "" "" # Octal formatting tests -testing "echo -e octal values" \ +testing "-e octal values" \ "$CMD -ne '\01234 \0060 \060 \0130\0131\0132 \077\012'" \ "S4 0 0 XYZ ?\n" "" "" # Hexadecimal value tests -testing "echo -e hexadecimal values" \ +testing "-e hexadecimal values" \ "$CMD -ne '\x534 \x30 \x58\x59\x5a \x3F\x0A'"\ "S4 0 XYZ ?\n" "" "" -testing "echo -e \p" "$CMD -e '\\p'" "\\p\n" "" "" +testing "-e \p" "$CMD -e '\\p'" "\\p\n" "" "" diff --git a/tests/expand.test b/tests/expand.test index 510f89f5..d93d0707 100755 --- a/tests/expand.test +++ b/tests/expand.test @@ -7,11 +7,11 @@ # some basic tests -testing "expand default" "expand input" " foo bar\n" "\tfoo\tbar\n" "" -testing "expand default stdin" "expand" " foo bar\n" "" "\tfoo\tbar\n" -testing "expand single" "expand -t 2 input" " foo bar\n" "\tfoo\tbar\n" "" -testing "expand tablist" "expand -t 5,10,12 input" " foo bar foo\n" "\tfoo\tbar\tfoo\n" "" -testing "expand backspace" "expand input" "foobarfoo\b\b bar\n" "foobarfoo\b\b\tbar\n" "" +testing "default" "expand input" " foo bar\n" "\tfoo\tbar\n" "" +testing "default stdin" "expand" " foo bar\n" "" "\tfoo\tbar\n" +testing "single" "expand -t 2 input" " foo bar\n" "\tfoo\tbar\n" "" +testing "tablist" "expand -t 5,10,12 input" " foo bar foo\n" "\tfoo\tbar\tfoo\n" "" +testing "backspace" "expand input" "foobarfoo\b\b bar\n" "foobarfoo\b\b\tbar\n" "" # advanced tests @@ -22,12 +22,12 @@ for i in $(seq $POW); do BIGTAB=$BIGTAB$BIGTAB TABSTOP=$[$TABSTOP*2] done -testing "expand long tab single" "expand -t $TABSTOP input" "${BIGTAB}foo\n" "\tfoo\n" "" -testing "expand long tab tablist" "expand -t $TABSTOP,$[TABSTOP+5] input" \ +testing "long tab single" "expand -t $TABSTOP input" "${BIGTAB}foo\n" "\tfoo\n" "" +testing "long tab tablist" "expand -t $TABSTOP,$[TABSTOP+5] input" \ "${BIGTAB}foo bar\n" "\tfoo\tbar\n" "" -testing "expand multiline single" "expand -t 4 input" "foo \n bar\n" "foo\t\n\tbar\n" "" -testing "expand multiline tablist" "expand -t 4,8 input" \ +testing "multiline single" "expand -t 4 input" "foo \n bar\n" "foo\t\n\tbar\n" "" +testing "multiline tablist" "expand -t 4,8 input" \ "foo bar\n bar foo\n" "foo\t\tbar\n\tbar\tfoo\n" "" POW=15 BIGLINE="foo " @@ -40,5 +40,5 @@ else EXPANDLINE="${BIGLINE} foo\n" fi BIGLINE="${BIGLINE}\tfoo\n" -testing "expand long line single" "expand input" \ +testing "long line single" "expand input" \ "${EXPANDLINE}" "$BIGLINE" "" diff --git a/tests/expr.test b/tests/expr.test index 33900d7a..c95d0301 100755 --- a/tests/expr.test +++ b/tests/expr.test @@ -2,20 +2,20 @@ [ -f testing.sh ] && . testing.sh -testing "expr integer" "expr 5" "5\n" "" "" -testing "expr integer negative" "expr -5" "-5\n" "" "" -testing "expr string" "expr astring" "astring\n" "" "" -testing "expr 1 + 3" "expr 1 + 3" "4\n" "" "" -testing "expr 5 + 6 * 3" "expr 5 + 6 \* 3" "23\n" "" "" -testing "expr ( 5 + 6 ) * 3" "expr \( 5 + 6 \) \* 3" "33\n" "" "" -testing "expr * / same priority" "expr 4 \* 3 / 2" "6\n" "" "" -testing "expr / * same priority" "expr 3 / 2 \* 4" "4\n" "" "" -testing "expr & before |" "expr 0 \| 1 \& 0" "0\n" "" "" -testing "expr | after &" "expr 1 \| 0 \& 0" "1\n" "" "" -testing "expr | & same priority" "expr 0 \& 0 \| 1" "1\n" "" "" -testing "expr % * same priority" "expr 3 % 2 \* 4" "4\n" "" "" -testing "expr * % same priority" "expr 3 \* 2 % 4" "2\n" "" "" -testing "expr = > same priority" "expr 0 = 2 \> 3" "0\n" "" "" -testing "expr > = same priority" "expr 3 \> 2 = 1" "1\n" "" "" -testing "expr string becomes integer" "expr ab21xx : '[^0-9]*\([0-9]*\)' + 3" \ +testing "integer" "expr 5" "5\n" "" "" +testing "integer negative" "expr -5" "-5\n" "" "" +testing "string" "expr astring" "astring\n" "" "" +testing "1 + 3" "expr 1 + 3" "4\n" "" "" +testing "5 + 6 * 3" "expr 5 + 6 \* 3" "23\n" "" "" +testing "( 5 + 6 ) * 3" "expr \( 5 + 6 \) \* 3" "33\n" "" "" +testing "* / same priority" "expr 4 \* 3 / 2" "6\n" "" "" +testing "/ * same priority" "expr 3 / 2 \* 4" "4\n" "" "" +testing "& before |" "expr 0 \| 1 \& 0" "0\n" "" "" +testing "| after &" "expr 1 \| 0 \& 0" "1\n" "" "" +testing "| & same priority" "expr 0 \& 0 \| 1" "1\n" "" "" +testing "% * same priority" "expr 3 % 2 \* 4" "4\n" "" "" +testing "* % same priority" "expr 3 \* 2 % 4" "2\n" "" "" +testing "= > same priority" "expr 0 = 2 \> 3" "0\n" "" "" +testing "> = same priority" "expr 3 \> 2 = 1" "1\n" "" "" +testing "string becomes integer" "expr ab21xx : '[^0-9]*\([0-9]*\)' + 3" \ "24\n" "" "" diff --git a/tests/factor.test b/tests/factor.test index ed1cc226..2ec557a3 100755 --- a/tests/factor.test +++ b/tests/factor.test @@ -4,19 +4,19 @@ #testing "name" "command" "result" "infile" "stdin" -testing "factor -32" "factor -32" "-32: -1 2 2 2 2 2\n" "" "" -testing "factor 0" "factor 0" "0: 0\n" "" "" -testing "factor 1" "factor 1" "1: 1\n" "" "" -testing "factor 2" "factor 2" "2: 2\n" "" "" -testing "factor 3" "factor 3" "3: 3\n" "" "" -testing "factor 4" "factor 4" "4: 2 2\n" "" "" -testing "factor 10000000017" "factor 10000000017" \ +testing "-32" "factor -32" "-32: -1 2 2 2 2 2\n" "" "" +testing "0" "factor 0" "0: 0\n" "" "" +testing "1" "factor 1" "1: 1\n" "" "" +testing "2" "factor 2" "2: 2\n" "" "" +testing "3" "factor 3" "3: 3\n" "" "" +testing "4" "factor 4" "4: 2 2\n" "" "" +testing "10000000017" "factor 10000000017" \ "10000000017: 3 3 3 7 7 7 1079797\n" "" "" -testing "factor 10000000018" "factor 10000000018" \ +testing "10000000018" "factor 10000000018" \ "10000000018: 2 131 521 73259\n" "" "" -testing "factor 10000000019" "factor 10000000019" \ +testing "10000000019" "factor 10000000019" \ "10000000019: 10000000019\n" "" "" -testing "factor 3 6 from stdin" "factor" "3: 3\n6: 2 3\n" "" "3 6" -testing "factor stdin newline" "factor" "3: 3\n6: 2 3\n" "" "3\n6\n" +testing "3 6 from stdin" "factor" "3: 3\n6: 2 3\n" "" "3 6" +testing "stdin newline" "factor" "3: 3\n6: 2 3\n" "" "3\n6\n" diff --git a/tests/find.test b/tests/find.test index 710684ec..580d1959 100755 --- a/tests/find.test +++ b/tests/find.test @@ -18,30 +18,30 @@ chmod a=r perm/all-read-only # Testing operators -testing "find -type l -a -type d -o -type p" \ +testing "-type l -a -type d -o -type p" \ "find dir -type l -a -type d -o -type p" "dir/fifo\n" "" "" -testing "find -type l -type d -o -type p" "find dir -type l -type d -o -type p" \ +testing "-type l -type d -o -type p" "find dir -type l -type d -o -type p" \ "dir/fifo\n" "" "" -testing "find -type l -o -type d -a -type p" \ +testing "-type l -o -type d -a -type p" \ "find dir -type l -o -type d -a -type p" "dir/link\n" "" "" -testing "find -type l -o -type d -type p" "find dir -type l -o -type d -type p" \ +testing "-type l -o -type d -type p" "find dir -type l -o -type d -type p" \ "dir/link\n" "" "" -testing "find -type l ( -type d -o -type l )" \ +testing "-type l ( -type d -o -type l )" \ "find dir -type l \( -type d -o -type l \)" "dir/link\n" "" "" -testing "find extra parentheses" \ +testing "extra parentheses" \ "find dir \( \( -type l \) \( -type d -o \( \( -type l \) \) \) \)" \ "dir/link\n" "" "" -testing "find ( -type p -o -type d ) -type p" \ +testing "( -type p -o -type d ) -type p" \ "find dir \( -type p -o -type d \) -type p" "dir/fifo\n" "" "" -testing "find -type l -o -type d -type p -o -type f" \ +testing "-type l -o -type d -type p -o -type f" \ "find dir -type l -o -type d -type p -o -type f | sort" \ "dir/file\ndir/link\n" "" "" # Testing short-circuit evaluations -testing "find -type f -a -print" \ +testing "-type f -a -print" \ "find dir -type f -a -print" "dir/file\n" "" "" -testing "find -print -o -print" \ +testing "-print -o -print" \ "find dir -type f -a \( -print -o -print \)" "dir/file\n" "" "" # these were erroring or segfaulting: @@ -50,44 +50,44 @@ testing "find -print -o -print" \ # Testing previous failures -testing "find -type f -user -exec" \ +testing "-type f -user -exec" \ "find dir -type f -user $USER -exec ls {} \\;" "dir/file\n" "" "" -testing "find -type l -newer -exec" \ +testing "-type l -newer -exec" \ "find dir -type l -newer dir/file -exec ls {} \\;" "dir/link\n" "" "" -testing "find -perm (exact success)" \ +testing "-perm (exact success)" \ "find perm -type f -perm 0444" "perm/all-read-only\n" "" "" -testing "find -perm (exact failure)" \ +testing "-perm (exact failure)" \ "find perm -type f -perm 0400" "" "" "" -testing "find -perm (min success)" \ +testing "-perm (min success)" \ "find perm -type f -perm -0400" "perm/all-read-only\n" "" "" -testing "find -perm (min failure)" \ +testing "-perm (min failure)" \ "find perm -type f -perm -0600" "" "" "" -testing "find -perm (any success)" \ +testing "-perm (any success)" \ "find perm -type f -perm -0444" "perm/all-read-only\n" "" "" -testing "find -perm (any failure)" \ +testing "-perm (any failure)" \ "find perm -type f -perm -0222" "" "" "" # Still fails -testing "find unterminated -exec {}" \ +testing "unterminated -exec {}" \ "find dir -type f -exec ls {} 2>/dev/null || echo bad" "bad\n" "" "" -testing "find -exec {} +" \ +testing "-exec {} +" \ "find dir -type f -exec ls {} +" "dir/file\n" "" "" # `find . -iname` was segfaulting -testing "find -name file" \ +testing "-name file" \ "find dir -name file" "dir/file\n" "" "" -testing "find -name FILE" \ +testing "-name FILE" \ "find dir -name FILE" "" "" "" -testing "find -iname file" \ +testing "-iname file" \ "find dir -iname FILE" "dir/file\n" "" "" -testing "find -iname FILE" \ +testing "-iname FILE" \ "find dir -iname FILE" "dir/file\n" "" "" -testing "find -name (no arguments)" \ +testing "-name (no arguments)" \ "find dir -name 2>&1" "find: '-name' needs 1 arg\n" "" "" -testing "find -iname (no arguments)" \ +testing "-iname (no arguments)" \ "find dir -iname 2>&1" "find: '-iname' needs 1 arg\n" "" "" rm -rf dir diff --git a/tests/fstype.test b/tests/fstype.test index cf0987ad..cc7a6206 100755 --- a/tests/fstype.test +++ b/tests/fstype.test @@ -7,16 +7,16 @@ BDIR="$TOPDIR/tests/blkid" bzcat "$BDIR"/squashfs.bz2 > temp.img -testing "fstype file" "fstype temp.img" 'squashfs\n' "" "" +testing "file" "fstype temp.img" 'squashfs\n' "" "" rm temp.img for i in cramfs ext2 ext3 ext4 f2fs ntfs squashfs vfat xfs do - testing "fstype $i" 'bzcat "$BDIR"/$i.bz2 | fstype -' "$i\n" "" "" + testing "$i" 'bzcat "$BDIR"/$i.bz2 | fstype -' "$i\n" "" "" done -testing "fstype msdos" 'bzcat "$BDIR"/msdos.bz2 | fstype -' 'vfat\n' "" "" -testing "fstype reiserfs" 'bzcat "$BDIR"/reiser3.bz2 | fstype -' 'reiserfs\n' "" "" +testing "msdos" 'bzcat "$BDIR"/msdos.bz2 | fstype -' 'vfat\n' "" "" +testing "reiserfs" 'bzcat "$BDIR"/reiser3.bz2 | fstype -' 'reiserfs\n' "" "" #testing "blkid minix" 'bzcat "$BDIR"/minix.bz2 | blkid -' #adfs bfs btrfs cramfs jfs nilfs romfs diff --git a/tests/grep.test b/tests/grep.test index 4b52b5b4..227fee00 100755 --- a/tests/grep.test +++ b/tests/grep.test @@ -7,105 +7,105 @@ #testing "name" "command" "result" "infile" "stdin" -testing "grep -c" "grep -c 123 input" "3\n" "123\ncount 123\n123\nfasdfasdf" "" +testing "-c" "grep -c 123 input" "3\n" "123\ncount 123\n123\nfasdfasdf" "" echo -e "this is test" > foo echo -e "this is test2" > foo2 echo -e "this is foo3" > foo3 -testing "grep -l" "grep -l test foo foo2 foo3" "foo\nfoo2\n" "" "" +testing "-l" "grep -l test foo foo2 foo3" "foo\nfoo2\n" "" "" rm foo foo2 foo3 -testing "grep -q" "grep -q test input && echo yes" "yes\n" "this is a test\n" "" -testing "grep -E" "grep -E '[0-9]' input" "1234123asdfas123123\n1\n" \ +testing "-q" "grep -q test input && echo yes" "yes\n" "this is a test\n" "" +testing "-E" "grep -E '[0-9]' input" "1234123asdfas123123\n1\n" \ "1234123asdfas123123\nabc\n1\nabcde" "" -testing "grep -e" "grep -e '[0-9]' input" "1234123asdfas123123\n1\n" \ +testing "-e" "grep -e '[0-9]' input" "1234123asdfas123123\n1\n" \ "1234123asdfas123123\nabc\n1\nabcde" "" -testing "grep -e -e" "grep -e one -e two -e three input" \ +testing "-e -e" "grep -e one -e two -e three input" \ "two\ntwo\nthree\none\n" "two\ntwo\nthree\nand\none\n" "" -testing "grep -F" "grep -F is input" "this is test\nthis is test2\n" \ +testing "-F" "grep -F is input" "this is test\nthis is test2\n" \ "this is test\nthis is test2\ntest case" "" echo -e "this is test\nthis is test2\ntest case" > foo echo -e "hello this is test" > foo2 echo -e "hi hello" > foo3 -testing "grep -H" "grep -H is foo foo2 foo3" "foo:this is test\nfoo:this is test2\nfoo2:hello this is test\n" "" "" +testing "-H" "grep -H is foo foo2 foo3" "foo:this is test\nfoo:this is test2\nfoo2:hello this is test\n" "" "" rm foo foo2 foo3 -testing "grep -b" "grep -b is input" "0:this is test\n13:this is test2\n" \ +testing "-b" "grep -b is input" "0:this is test\n13:this is test2\n" \ "this is test\nthis is test2\ntest case" "" -testing "grep -i" "grep -i is input" "thisIs test\nthis is test2\n" \ +testing "-i" "grep -i is input" "thisIs test\nthis is test2\n" \ "thisIs test\nthis is test2\ntest case" "" -testing "grep -n" "grep -n is input" "1:this is test\n2:this is test2\n" \ +testing "-n" "grep -n is input" "1:this is test\n2:this is test2\n" \ "this is test\nthis is test2\ntest case" "" -testing "grep -o" "grep -o is input" "is\nis\nis\nis\n" \ +testing "-o" "grep -o is input" "is\nis\nis\nis\n" \ "this is test\nthis is test2\ntest case" "" -testing "grep -s" "grep -hs hello asdf input 2>&1" "hello\n" "hello\n" "" -testing "grep -v" "grep -v abc input" "1234123asdfas123123\n1ABa\n" \ +testing "-s" "grep -hs hello asdf input 2>&1" "hello\n" "hello\n" "" +testing "-v" "grep -v abc input" "1234123asdfas123123\n1ABa\n" \ "1234123asdfas123123\n1ABabc\nabc\n1ABa\nabcde" "" -testing "grep -w" "grep -w abc input" "abc\n123 abc\nabc 123\n123 abc 456\n" \ +testing "-w" "grep -w abc input" "abc\n123 abc\nabc 123\n123 abc 456\n" \ "1234123asdfas123123\n1ABabc\nabc\n1ABa\nabcde\n123 abc\nabc 123\n123 abc 456\n" "" -testing "grep -x" "grep -x abc input" "abc\n" \ +testing "-x" "grep -x abc input" "abc\n" \ "aabcc\nabc\n" "" -testing "grep -H (standard input)" "grep -H abc" "(standard input):abc\n" \ +testing "-H (standard input)" "grep -H abc" "(standard input):abc\n" \ "" "abc\n" -testing "grep -l (standard input)" "grep -l abc" "(standard input)\n" \ +testing "-l (standard input)" "grep -l abc" "(standard input)\n" \ "" "abc\n" -testing "grep -n two inputs" "grep -hn def - input" "2:def\n2:def\n" \ +testing "-n two inputs" "grep -hn def - input" "2:def\n2:def\n" \ "abc\ndef\n" "abc\ndef\n" -testing "grep pattern with newline" "grep 'abc +testing "pattern with newline" "grep 'abc def' input" "aabcc\nddeff\n" \ "aaaa\naabcc\n\dddd\nddeff\nffff\n" "" -testing "grep -lH" "grep -lH abc input" "input\n" "abc\n" "" -testing "grep -cn" "grep -cn abc input" "1\n" "abc\n" "" -testing "grep -cH" "grep -cH abc input" "input:1\n" "abc\n" "" -testing "grep -qs" "grep -qs abc none input && echo yes" "yes\n" "abc\n" "" -testing "grep -hl" "grep -hl abc input" "input\n" "abc\n" "" -testing "grep -b stdin" "grep -b one" "0:one\n4:one\n8:one\n" "" "one\none\none\n" -testing "grep -o overlap" "grep -bo aaa" "1:aaa\n" "" "baaaa\n" +testing "-lH" "grep -lH abc input" "input\n" "abc\n" "" +testing "-cn" "grep -cn abc input" "1\n" "abc\n" "" +testing "-cH" "grep -cH abc input" "input:1\n" "abc\n" "" +testing "-qs" "grep -qs abc none input && echo yes" "yes\n" "abc\n" "" +testing "-hl" "grep -hl abc input" "input\n" "abc\n" "" +testing "-b stdin" "grep -b one" "0:one\n4:one\n8:one\n" "" "one\none\none\n" +testing "-o overlap" "grep -bo aaa" "1:aaa\n" "" "baaaa\n" # nonobvious: -co counts lines, not matches -testing "grep -co" "grep -co one input" "1\n" "one one one\n" "" -testing "grep -nom" "grep -nom 2 one" "1:one\n1:one\n1:one\n2:one\n2:one\n" \ +testing "-co" "grep -co one input" "1\n" "one one one\n" "" +testing "-nom" "grep -nom 2 one" "1:one\n1:one\n1:one\n2:one\n2:one\n" \ "" "one one one\none one\none" -testing "grep -vo" "grep -vo one input" "two\nthree\n" "onetwoonethreeone\n" "" -testing "grep no newline" "grep -h one input -" \ +testing "-vo" "grep -vo one input" "two\nthree\n" "onetwoonethreeone\n" "" +testing "no newline" "grep -h one input -" \ "hello one\nthere one\n" "hello one" "there one" -testing "grep -e multi" "grep -e one -ethree input" \ +testing "-e multi" "grep -e one -ethree input" \ "three\none\n" "three\ntwo\none\n" "" # Suppress filenames for recursive test because dunno order they'd occur in mkdir sub echo -e "one\ntwo\nthree" > sub/one echo -e "three\ntwo\none" > sub/two -testing "grep -hr" "grep -hr one sub" "one\none\n" "" "" -testing "grep -r file" "grep -r three sub/two" "three\n" "" "" -testing "grep -r dir" "grep -r one sub | sort" "sub/one:one\nsub/two:one\n" \ +testing "-hr" "grep -hr one sub" "one\none\n" "" "" +testing "-r file" "grep -r three sub/two" "three\n" "" "" +testing "-r dir" "grep -r one sub | sort" "sub/one:one\nsub/two:one\n" \ "" "" rm -rf sub # -x exact match trumps -F's "empty string matches whole line" behavior -testing "grep -Fx ''" "grep -Fx '' input" "" "one one one\n" "" -testing "grep -F ''" "grep -F '' input" "one one one\n" "one one one\n" "" -testing "grep -F -e blah -e ''" "grep -F -e blah -e '' input" "one one one\n" \ +testing "-Fx ''" "grep -Fx '' input" "" "one one one\n" "" +testing "-F ''" "grep -F '' input" "one one one\n" "one one one\n" "" +testing "-F -e blah -e ''" "grep -F -e blah -e '' input" "one one one\n" \ "one one one\n" "" -testing "grep -e blah -e ''" "grep -e blah -e '' input" "one one one\n" \ +testing "-e blah -e ''" "grep -e blah -e '' input" "one one one\n" \ "one one one\n" "" -testing "grep -w ''" "grep -w '' input" "" "one one one\n" "" -testing "grep -w '' 2" "grep -w '' input" "one two\n" "one two\n" "" -testing "grep -w \\1" "grep -wo '\\(x\\)\\1'" "xx\n" "" "xx" -testing "grep -o ''" "grep -o '' input" "" "one one one\n" "" -testing "grep backref" 'grep -e "a\(b\)" -e "b\(c\)\1"' "bcc\nab\n" \ +testing "-w ''" "grep -w '' input" "" "one one one\n" "" +testing "-w '' 2" "grep -w '' input" "one two\n" "one two\n" "" +testing "-w \\1" "grep -wo '\\(x\\)\\1'" "xx\n" "" "xx" +testing "-o ''" "grep -o '' input" "" "one one one\n" "" +testing "backref" 'grep -e "a\(b\)" -e "b\(c\)\1"' "bcc\nab\n" \ "" "bcc\nbcb\nab\n" -testing "grep -A" "grep -A 2 yes" "yes\nno\nno\n--\nyes\nno\nno\nyes\nno\n" \ +testing "-A" "grep -A 2 yes" "yes\nno\nno\n--\nyes\nno\nno\nyes\nno\n" \ "" "yes\nno\nno\nno\nyes\nno\nno\nyes\nno" -testing "grep -B" "grep -B 1 yes" "no\nyes\n--\nno\nyes\nno\nyes\n" \ +testing "-B" "grep -B 1 yes" "no\nyes\n--\nno\nyes\nno\nyes\n" \ "" "no\nno\nno\nyes\nno\nno\nyes\nno\nyes" -testing "grep -C" "grep -C 1 yes" \ +testing "-C" "grep -C 1 yes" \ "yes\nno\n--\nno\nyes\nno\nno\nyes\nno\nyes\nno\n" \ "" "yes\nno\nno\nno\nyes\nno\nno\nyes\nno\nyes\nno\nno" -testing "grep -HnC" "grep -HnC1 two" \ +testing "-HnC" "grep -HnC1 two" \ "(standard input)-1-one\n(standard input):2:two\n(standard input)-3-three\n" \ "" "one\ntwo\nthree" diff --git a/tests/groupadd.test b/tests/groupadd.test index 0395e01a..091dccf7 100755 --- a/tests/groupadd.test +++ b/tests/groupadd.test @@ -15,33 +15,33 @@ arg="&>/dev/null" #testing "name" "command" "result" "infile" "stdin" -testing "groupadd group_name (text)" "groupadd toyTestGroup && +testing "group_name (text)" "groupadd toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" -testing "groupadd group_name (alphanumeric)" "groupadd toy1Test2Group3 && +testing "group_name (alphanumeric)" "groupadd toy1Test2Group3 && grep '^toy1Test2Group3:' /etc/group $arg && groupdel toy1Test2Group3 $arg && echo 'yes'" "yes\n" "" "" -testing "groupadd group_name (numeric)" "groupadd 987654321 && +testing "group_name (numeric)" "groupadd 987654321 && grep '^987654321:' /etc/group $arg && groupdel 987654321 $arg && echo 'yes'" "yes\n" "" "" -testing "groupadd group_name (with ./-)" "groupadd toy.1Test-2Group.3 && +testing "group_name (with ./-)" "groupadd toy.1Test-2Group.3 && grep '^toy.1Test-2Group.3:' /etc/group $arg && groupdel toy.1Test-2Group.3 $arg && echo 'yes'" "yes\n" "" "" _s210=`echo $_s70$_s70$_s70` -testing "groupadd group_name (long string)" "groupadd $_s210 && +testing "group_name (long string)" "groupadd $_s210 && grep '^$_s210:' /etc/group $arg && groupdel $_s210 $arg && echo 'yes'" \ "yes\n" "" "" -testing "groupadd group_name with group_id" "groupadd -g 49999 toyTestGroup && +testing "group_name with group_id" "groupadd -g 49999 toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" -testing "groupadd group_name with group_id (system_group)" \ +testing "group_name with group_id (system_group)" \ "groupadd -g 49999 -S toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" -testing "groupadd group_name (system_group)" "groupadd -S toyTestGroup && +testing "group_name (system_group)" "groupadd -S toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" -testing "groupadd group_name (add/del user)" "groupadd toyTestGroup && +testing "group_name (add/del user)" "groupadd toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupadd $USER toyTestGroup && grep '^toyTestGroup:.*:.*:.*$USER.*' /etc/group $arg && groupdel $USER toyTestGroup $arg || groupdel toyTestGroup && @@ -50,7 +50,7 @@ testing "groupadd group_name (add/del user)" "groupadd toyTestGroup && echo "Testing to add single group multiple times after removing it..." for each in {01..20} do - testing "groupadd group_name ($each)" "groupadd toyTestGroup && + testing "group_name ($each)" "groupadd toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" done diff --git a/tests/groupdel.test b/tests/groupdel.test index 6abb4bfc..ea9ee9ad 100755 --- a/tests/groupdel.test +++ b/tests/groupdel.test @@ -10,18 +10,18 @@ arg="&>/dev/null" #testing "name" "command" "result" "infile" "stdin" -testing "groupdel group_name (text)" "groupadd toyTestGroup && +testing "group_name (text)" "groupadd toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" -testing "groupdel group_name (alphanumeric)" "groupadd toy1Test2Group3 && +testing "group_name (alphanumeric)" "groupadd toy1Test2Group3 && grep '^toy1Test2Group3:' /etc/group $arg && groupdel toy1Test2Group3 $arg && echo 'yes'" "yes\n" "" "" -testing "groupdel group_name (numeric)" "groupadd 987654321 && +testing "group_name (numeric)" "groupadd 987654321 && grep '^987654321:' /etc/group $arg && groupdel 987654321 $arg && echo 'yes'" "yes\n" "" "" -testing "groupdel group_name (with ./-)" "groupadd toy.1Test-2Group.3 && +testing "group_name (with ./-)" "groupadd toy.1Test-2Group.3 && grep '^toy.1Test-2Group.3:' /etc/group $arg && groupdel toy.1Test-2Group.3 $arg && echo 'yes'" "yes\n" "" "" -testing "groupdel group_name with group_id" "groupadd -g 49999 toyTestGroup && +testing "group_name with group_id" "groupadd -g 49999 toyTestGroup && grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg && echo 'yes'" "yes\n" "" "" diff --git a/tests/head.test b/tests/head.test index d4eecd9a..83d93996 100755 --- a/tests/head.test +++ b/tests/head.test @@ -7,7 +7,7 @@ testing "head, stdin" "head -n 1 && echo yes" "one\nyes\n" "" "one\ntwo" testing "head, stdin via -" "head -n 1 - && echo yes" "one\nyes\n" "" "one\ntwo" testing "head, file" "head input -n 1 && echo yes" "one\nyes\n" "one\ntwo" "" -testing "head -number" "head -2 input && echo yes" "one\ntwo\nyes\n" \ +testing "-number" "head -2 input && echo yes" "one\ntwo\nyes\n" \ "one\ntwo\nthree\nfour" "" testing "head, default lines" "head" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" "" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12" diff --git a/tests/hostname.test b/tests/hostname.test index 56e4a2a3..5107ce22 100755 --- a/tests/hostname.test +++ b/tests/hostname.test @@ -14,5 +14,5 @@ hostnameOut=`$hostnameExe` # New hostname NewHostname="NewHostName.system" -testing "hostname get" "hostname" "$hostnameOut\n" "" "" -testing "hostname set, Get and then Reset" "hostname $NewHostname; hostname; hostname $hostnameOut; hostname" "$NewHostname\n$hostnameOut\n" "" "" +testing "get" "hostname" "$hostnameOut\n" "" "" +testing "set, Get and then Reset" "hostname $NewHostname; hostname; hostname $hostnameOut; hostname" "$NewHostname\n$hostnameOut\n" "" "" diff --git a/tests/ifconfig.test b/tests/ifconfig.test index c30c74c9..34fcde0a 100755 --- a/tests/ifconfig.test +++ b/tests/ifconfig.test @@ -35,76 +35,76 @@ ifconfig dummy0 up # Test Description: Disable the dummy0 interface # Results Expected: After calling ifconfig, no lines with dummy0 are displayed -testing "ifconfig dummy0 down and if config /-only" \ +testing "dummy0 down and if config /-only" \ "ifconfig dummy0 down && ifconfig dummy0 | grep dummy | wc -l" \ "0\n" "" "" # Test Description: Enable the dummy0 interface # Results Expected: After calling ifconfig, one line with dummy0 is displayed -testing "ifconfig dummy0 up" \ +testing "dummy0 up" \ "ifconfig dummy0 up && ifconfig dummy0 | grep dummy | wc -l" \ "1\n" "" "" # Test Description: Set the ip address of the dummy0 interface # Results Expected: After calling ifconfig dummy0, one line displays the ip # address selected -testing "ifconfig dummy0 10.240.240.240" \ +testing "dummy0 10.240.240.240" \ "ifconfig dummy0 10.240.240.240 && ifconfig dummy0 | grep 10\.240\.240\.240 | wc -l" \ "1\n" "" "" # Test Description: Change the netmask to the interface # Results Expected: After calling ifconfig dummy0, one line displays the # netmask selected -testing "ifconfig dummy0 netmask 255.255.240.0" \ +testing "dummy0 netmask 255.255.240.0" \ "ifconfig dummy0 netmask 255.255.240.0 && ifconfig dummy0 | grep 255\.255\.240\.0 | wc -l" \ "1\n" "" "" # Test Description: Change the broadcast address to the interface # Results Expected: After calling ifconfig dummy0, one line displays the # broadcast address selected -testing "ifconfig dummy0 broadcast 10.240.240.255" \ +testing "dummy0 broadcast 10.240.240.255" \ "ifconfig dummy0 broadcast 10.240.240.255 && ifconfig dummy0 | grep 10\.240\.240\.255 | wc -l" \ "1\n" "" "" # Test Description: Revert to the default ip address # Results Expected: After calling ifconfig dummy0, there are no lines # displaying the ip address previously selected -testing "ifconfig dummy0 default" \ +testing "dummy0 default" \ "ifconfig dummy0 default && ifconfig dummy0 | grep 10\.240\.240\.240 | wc -l" \ "0\n" "" "" # Test Description: Change the Maximum transmission unit (MTU) of the interface # Results Expected: After calling ifconfig dummy0, there is one line with the # selected MTU -testing "ifconfig dummy0 mtu 1269" \ +testing "dummy0 mtu 1269" \ "ifconfig dummy0 mtu 1269 && ifconfig dummy0 | grep 1269 | wc -l" \ "1\n" "" "" # Test Description: Verify ifconfig add fails with such a small mtu # Results Expected: There is one line of error message containing # "No buffer space available" -testing "ifconfig dummy0 add ::2 -- too small mtu" \ +testing "dummy0 add ::2 -- too small mtu" \ "ifconfig dummy0 add ::2 2>&1 | grep No\ buffer\ space\ available | wc -l" \ "1\n" "" "" # Test Description: Change the Maximum transmission unit (MTU) of the interface # Results Expected: After calling ifconfig dummy0, there is one line with the # selected MTU -testing "ifconfig dummy0 mtu 2000" \ +testing "dummy0 mtu 2000" \ "ifconfig dummy0 mtu 2000 && ifconfig dummy0 | grep 2000 | wc -l" \ "1\n" "" "" # Test Description: Verify ifconfig add succeeds with a larger mtu # Results Expected: after calling ifconfig dummy0, there is one line with the # selected ip address -testing "ifconfig dummy0 add ::2" \ +testing "dummy0 add ::2" \ "ifconfig dummy0 add ::2/126 && ifconfig dummy0 | grep \:\:2\/126 | wc -l" \ "1\n" "" "" # Test Description: Verify ifconfig del removes the selected ip6 address # Results Expected: after calling ifconfig dummy0, there are no lines with the # selected ip address -testing "ifconfig dummy0 del ::2" \ +testing "dummy0 del ::2" \ "ifconfig dummy0 del ::2/126 && ifconfig dummy0 | grep \:\:2 | wc -l" \ "0\n" "" "" @@ -112,21 +112,21 @@ testing "ifconfig dummy0 del ::2" \ # preparation for the next test # Results Expected: After calling ifconfig dummy0, there are no lines with the # NOARP flag -testing "ifconfig dummy0 arp down" \ +testing "dummy0 arp down" \ "ifconfig dummy0 arp down && ifconfig dummy0 | grep -i NOARP | wc -l" \ "0\n" "" "" # Test Description: Call the pointtopoint option with no argument # Results Expected: After calling ifconfig dummy0, there is one line with the # NOARP and UP flags -testing "ifconfig dummy0 pointtopoint" \ +testing "dummy0 pointtopoint" \ "ifconfig dummy0 pointtopoint && ifconfig dummy0 | grep -i NOARP | grep -i UP | wc -l" \ "1\n" "" "" # Test Description: Test the pointtopoint option and set the ipaddress # Results Expected: After calling ifconfig dummy0, there is one line with the # word inet and the selected ip address -testing "ifconfig dummy0 pointtopoint 127.0.0.2" \ +testing "dummy0 pointtopoint 127.0.0.2" \ "ifconfig dummy0 pointtopoint 127.0.0.2 && ifconfig dummy0 | grep -i inet | grep -i 127\.0\.0\.2 | wc -l" \ "1\n" "" "" @@ -135,56 +135,56 @@ testing "ifconfig dummy0 pointtopoint 127.0.0.2" \ # Test Description: Enable allmulti mode on the interface # Results Expected: After calling ifconfig dummy0, there is one line with the # allmulti flag -testing "ifconfig dummy0 allmulti" \ +testing "dummy0 allmulti" \ "ifconfig dummy0 allmulti && ifconfig dummy0 | grep -i allmulti | wc -l" "1\n" \ "" "" # Test Description: Disable multicast mode the interface # Results Expected: After calling ifconfig dummy0, there are no lines with the # allmulti flag -testing "ifconfig dummy0 -allmulti" \ +testing "dummy0 -allmulti" \ "ifconfig dummy0 -allmulti && ifconfig dummy0 | grep -i allmulti | wc -l" "0\n" \ "" "" # Test Description: Disable NOARP mode on the interface # Results Expected: After calling ifconfig dummy0, there are no lines with the # NOARP flag -testing "ifconfig dummy0 arp" \ +testing "dummy0 arp" \ "ifconfig dummy0 arp && ifconfig dummy0 | grep -i NOARP | wc -l" "0\n" \ "" "" # Test Description: Enable NOARP mode on the interface # Results Expected: After calling ifconfig dummy0, there is one line with the # NOARP flag -testing "ifconfig dummy0 -arp" \ +testing "dummy0 -arp" \ "ifconfig dummy0 -arp && ifconfig dummy0 | grep -i NOARP | wc -l" "1\n" \ "" "" # Test Description: Enable multicast mode on the interface # Results Expected: After calling ifconfig dummy0, there is one line with the # multicast flag -testing "ifconfig dummy0 multicast" \ +testing "dummy0 multicast" \ "ifconfig dummy0 multicast && ifconfig dummy0 | grep -i multicast | wc -l" \ "1\n" "" "" # Test Description: Disable multicast mode the interface # Results Expected: After calling ifconfig dummy0, there are no lines with the # multicast flag -testing "ifconfig dummy0 -multicast" \ +testing "dummy0 -multicast" \ "ifconfig dummy0 -multicast && ifconfig dummy0 | grep -i multicast | wc -l" \ "0\n" "" "" # Test Description: Enable promiscuous mode the interface # Results Expected: After calling ifconfig dummy0, there is one line with the # promisc flag -testing "ifconfig dummy0 promisc" \ +testing "dummy0 promisc" \ "ifconfig dummy0 promisc && ifconfig dummy0 | grep -i promisc | wc -l" "1\n" \ "" "" # Disable promiscuous mode the interface # Results Expected: After calling ifconfig dummy0, there are no lines with the # promisc flag -testing "ifconfig dummy0 -promisc" \ +testing "dummy0 -promisc" \ "ifconfig dummy0 -promisc && ifconfig dummy0 | grep -i promisc | wc -l" "0\n" \ "" "" diff --git a/tests/link.test b/tests/link.test index 5851129f..d91b7946 100755 --- a/tests/link.test +++ b/tests/link.test @@ -8,19 +8,19 @@ #testing "name" "command" "result" "infile" "stdin" echo "" >foo -testing "link fails on non-existent file" "link foo/foo baz || echo GOOD" "GOOD\n" "" "" +testing "fails on non-existent file" "link foo/foo baz || echo GOOD" "GOOD\n" "" "" rm -f foo bar echo file1 > file -testing "link create_hardlink" "link file hlink && [ file -ef hlink ] && +testing "create_hardlink" "link file hlink && [ file -ef hlink ] && echo 'yes'; rm -rf hlink" "yes\n" "" "" echo hlink1 > hlink set +e -testing "link preserves_hardlinks" "link file hlink 2>/dev/null || echo 'yes'; rm -rf hlink" \ +testing "preserves_hardlinks" "link file hlink 2>/dev/null || echo 'yes'; rm -rf hlink" \ "yes\n" "" "" echo file1 > file -testing "link create_hardlink_and_remove_sourcefile" "link file hlink && +testing "create_hardlink_and_remove_sourcefile" "link file hlink && [ file -ef hlink ] && rm -rf file && [ -f hlink ] && echo 'yes'; rm -f file hlink" \ "yes\n" "" "" diff --git a/tests/ln.test b/tests/ln.test index aea3ab04..3e70cd83 100755 --- a/tests/ln.test +++ b/tests/ln.test @@ -9,62 +9,62 @@ #set -x echo file1 > file -testing "ln create_hardlink" "ln file hlink && [ file -ef hlink ] && +testing "create_hardlink" "ln file hlink && [ file -ef hlink ] && echo 'yes'" "yes\n" "" "" -testing "ln create_softlink" "ln -s file slink && [ -L slink ] && +testing "create_softlink" "ln -s file slink && [ -L slink ] && readlink slink" "file\n" "" "" rm slink hlink echo hlink1 > hlink -testing "ln force_create_hardlink" "ln -f file hlink && +testing "force_create_hardlink" "ln -f file hlink && [ file -ef hlink ] && cat hlink 2>/dev/null" "file1\n" "" "" echo slink1 > slink -testing "ln force_create_softlink" "ln -f -s file slink && +testing "force_create_softlink" "ln -f -s file slink && [ -L slink ] && readlink slink" "file\n" "" "" rm slink hlink echo hlink1 > hlink set +e -testing "ln preserves_hardlinks" "ln file hlink 2>/dev/null || echo 'yes'" \ +testing "preserves_hardlinks" "ln file hlink 2>/dev/null || echo 'yes'" \ "yes\n" "" "" echo slink1 > slink set +e -testing "ln preserves_softlinks" "ln -s file slink 2>/dev/null || echo 'yes'" \ +testing "preserves_softlinks" "ln -s file slink 2>/dev/null || echo 'yes'" \ "yes\n" "" "" rm slink hlink mkdir dir -testing "ln multilevel_symbolic_links" "ln -s dir slink && +testing "multilevel_symbolic_links" "ln -s dir slink && ln -s file slink && [ -L slink -a -L slink/file ] && readlink slink && readlink slink/file" "dir\nfile\n" "" "" rm slink -testing "ln no_dereference" "ln -s dir slink && +testing "no_dereference" "ln -s dir slink && ln -n -s file slink 2>/dev/null || [ -L slink ] && readlink slink" \ "dir\n" "" "" rm -rf file dir slink touch file1 file2 && mkdir dir -testing "ln create_multiple_hardlinks" "ln file* dir/ && +testing "create_multiple_hardlinks" "ln file* dir/ && [ file1 -ef dir/file1 -a file2 -ef dir/file2 ] && echo 'yes'" "yes\n" "" "" rm -rf file* dir touch file1 file2 && mkdir dir -testing "ln create_multiple_softlinks" "ln -s file* dir/ && +testing "create_multiple_softlinks" "ln -s file* dir/ && [ -L dir/file1 -a -L dir/file2 ] && readlink dir/file1 && readlink dir/file2" "file1\nfile2\n" "" "" rm -rf file* dir echo file1 > file -testing "ln create_softlink_and_remove_sourcefile" "ln -s file slink && +testing "create_softlink_and_remove_sourcefile" "ln -s file slink && [ -L slink ] && rm file && cat slink 2>/dev/null || echo 'yes' " \ "yes\n" "" "" rm -f file slink echo file1 > file -testing "ln create_hardlink_and_remove_sourcefile" "ln file hlink && +testing "create_hardlink_and_remove_sourcefile" "ln file hlink && [ file -ef hlink ] && rm file && [ -f hlink ] && echo 'yes'" \ "yes\n" "" "" rm -f file hlink diff --git a/tests/ls.test b/tests/ls.test index 9866eb78..07850de2 100755 --- a/tests/ls.test +++ b/tests/ls.test @@ -17,36 +17,36 @@ echo "hidden file1" > lstest/.hfile1 IN="cd lstest" OUT="cd .. " -testing "ls no argument" "$IN && ls; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" -testing "ls with wild char" "$IN && ls file*; $OUT" "file1.txt\nfile2.txt\n" "" "" -testing "ls with wild char - long listing" "$IN && ls -1 file*; $OUT" "file1.txt\nfile2.txt\n" "" "" -testing "ls with -p" "$IN && ls -p; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" "" -testing "ls with -a" "$IN && ls -a; $OUT" \ +testing "no argument" "$IN && ls; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" +testing "with wild char" "$IN && ls file*; $OUT" "file1.txt\nfile2.txt\n" "" "" +testing "with wild char - long listing" "$IN && ls -1 file*; $OUT" "file1.txt\nfile2.txt\n" "" "" +testing "with -p" "$IN && ls -p; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" "" +testing "with -a" "$IN && ls -a; $OUT" \ ".\n..\ndir1\ndir2\nfile1.txt\nfile2.txt\n.hfile1\n" "" "" -testing "ls with -A" "$IN && ls -A; $OUT" \ +testing "with -A" "$IN && ls -A; $OUT" \ "dir1\ndir2\nfile1.txt\nfile2.txt\n.hfile1\n" "" "" -testing "ls with -d" "$IN && ls -d; $OUT" ".\n" "" "" -testing "ls with wild char and -d *" "$IN && ls -d *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" -testing "ls with -k" "$IN && ls -k; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" -testing "ls with -m" "$IN && ls -m; $OUT" "dir1, dir2, file1.txt, file2.txt\n" "" "" -testing "ls with -F" "$IN && ls -F; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" "" -testing "ls with -dk *" "$IN && ls -dk *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" +testing "with -d" "$IN && ls -d; $OUT" ".\n" "" "" +testing "with wild char and -d *" "$IN && ls -d *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" +testing "with -k" "$IN && ls -k; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" +testing "with -m" "$IN && ls -m; $OUT" "dir1, dir2, file1.txt, file2.txt\n" "" "" +testing "with -F" "$IN && ls -F; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" "" +testing "with -dk *" "$IN && ls -dk *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "" ln -s file1.txt lstest/slink -testing "ls softlink - long listing" "$IN && ls -l slink | awk '{ print \$NF }' ; $OUT" \ +testing "softlink - long listing" "$IN && ls -l slink | awk '{ print \$NF }' ; $OUT" \ "file1.txt\n" "" "" rm -f lstest/slink ln -s /dev/null/nosuchfile lstest/nosuchfile -testing "ls with -d - broken softlink" "$IN && ls -d nosuchfile; $OUT" "nosuchfile\n" "" "" +testing "with -d - broken softlink" "$IN && ls -d nosuchfile; $OUT" "nosuchfile\n" "" "" rm -f lstest/nosuchfile rm -rf lstest/* && mkdir -p lstest/dir1 && touch lstest/file1.txt -testing "ls nested recursively" "$IN && ls -R; $OUT" \ +testing "nested recursively" "$IN && ls -R; $OUT" \ ".:\ndir1\nfile1.txt\n\n./dir1:\n" "" "" rm -rf lstest/* && touch lstest/file1.txt && INODE=`stat -c %i lstest/file1.txt` -testing "ls with -i" "$IN && ls -i 2>/dev/null; $OUT" "$INODE file1.txt\n" "" "" +testing "with -i" "$IN && ls -i 2>/dev/null; $OUT" "$INODE file1.txt\n" "" "" unset INODE # Removing test dir for cleanup purpose diff --git a/tests/lsattr.test b/tests/lsattr.test index 5616dfc5..c2c7c617 100755 --- a/tests/lsattr.test +++ b/tests/lsattr.test @@ -12,24 +12,24 @@ _p=$PWD _b="-------------" _A="-------A-----" -testing "lsattr file" "lsattr file" "$_A file\n" "" "" -testing "lsattr file_path" "lsattr $_p/file" "$_A $_p/file\n" "" "" -testing "lsattr -R file" "lsattr -R file" "$_A file\n" "" "" -testing "lsattr -R file_path" "lsattr -R $_p/file" "$_A $_p/file\n" "" "" -testing "lsattr -a file" "lsattr -a file" "$_A file\n" "" "" -testing "lsattr -a file_path" "lsattr -a $_p/file" "$_A $_p/file\n" "" "" -testing "lsattr -d ." "lsattr -d ." "$_b .\n" "" "" -testing "lsattr -d dir_path" "lsattr -d $_p" "$_b $_p\n" "" "" -testing "lsattr -d file" "lsattr -d file" "$_A file\n" "" "" -testing "lsattr -d file_path" "lsattr -d $_p/file" "$_A $_p/file\n" "" "" +testing "file" "lsattr file" "$_A file\n" "" "" +testing "file_path" "lsattr $_p/file" "$_A $_p/file\n" "" "" +testing "-R file" "lsattr -R file" "$_A file\n" "" "" +testing "-R file_path" "lsattr -R $_p/file" "$_A $_p/file\n" "" "" +testing "-a file" "lsattr -a file" "$_A file\n" "" "" +testing "-a file_path" "lsattr -a $_p/file" "$_A $_p/file\n" "" "" +testing "-d ." "lsattr -d ." "$_b .\n" "" "" +testing "-d dir_path" "lsattr -d $_p" "$_b $_p\n" "" "" +testing "-d file" "lsattr -d file" "$_A file\n" "" "" +testing "-d file_path" "lsattr -d $_p/file" "$_A $_p/file\n" "" "" sp_44=" " -testing "lsattr -l file" "lsattr -l file" "file $sp_44 No_Atime\n" "" "" +testing "-l file" "lsattr -l file" "file $sp_44 No_Atime\n" "" "" _v="12345" -testing "lsattr -v file" "chattr -v $_v * && lsattr -v file" \ +testing "-v file" "chattr -v $_v * && lsattr -v file" \ "$_v $_A file\n" "" "" -testing "lsattr -v file_path" "chattr -v $_v * && lsattr -v $_p/file" \ +testing "-v file_path" "chattr -v $_v * && lsattr -v $_p/file" \ "$_v $_A $_p/file\n" "" "" -testing "lsattr -Radlv file1 file2" "chattr -v $_v * && +testing "-Radlv file1 file2" "chattr -v $_v * && lsattr -Radlv file input" \ "$_v file $sp_44 No_Atime\n$_v input $sp_44 ---\n" "" "" diff --git a/tests/md5sum.test b/tests/md5sum.test index 741ec62f..c4dfec94 100755 --- a/tests/md5sum.test +++ b/tests/md5sum.test @@ -7,16 +7,16 @@ # These tests are from RFC 1321 appendix 5, reshuffled slightly to test # varying argument numbers -testing "md5sum ''" "md5sum" "d41d8cd98f00b204e9800998ecf8427e -\n" "" "" -testing "md5sum infile" "md5sum input" \ +testing "''" "md5sum" "d41d8cd98f00b204e9800998ecf8427e -\n" "" "" +testing "infile" "md5sum input" \ "0cc175b9c0f1b6a831c399e269772661 input\n" "a" "" -testing "md5sum two files" "md5sum - input" \ +testing "two files" "md5sum - input" \ "900150983cd24fb0d6963f7d28e17f72 -\nf96b697d7cb7938d525a2f31aaf161d0 input\n" \ "message digest" "abc" -testing "md5sum 4" "md5sum" "c3fcd3d76192e4007dfb496cca67e13b -\n" \ +testing "4" "md5sum" "c3fcd3d76192e4007dfb496cca67e13b -\n" \ "" "abcdefghijklmnopqrstuvwxyz" -testing "md5sum 5" "md5sum" "d174ab98d277d9f5a5611c2c9f419d9f -\n" \ +testing "5" "md5sum" "d174ab98d277d9f5a5611c2c9f419d9f -\n" \ "" "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" -testing "md5sum 6" "md5sum" "57edf4a22be3c955ac49da2e2107b67a -\n" \ +testing "6" "md5sum" "57edf4a22be3c955ac49da2e2107b67a -\n" \ "" "12345678901234567890123456789012345678901234567890123456789012345678901234567890" diff --git a/tests/mkdir.test b/tests/mkdir.test index 8b2f99f5..e1bdb887 100755 --- a/tests/mkdir.test +++ b/tests/mkdir.test @@ -8,66 +8,66 @@ testing "mkdir" "mkdir one && [ -d one ] && echo yes" "yes\n" "" "" rmdir one touch existing -testing "mkdir existing" \ +testing "existing" \ "mkdir existing 2> /dev/null || [ -f existing ] && echo yes" "yes\n" "" "" rm existing -testing "mkdir one two" \ +testing "one two" \ "mkdir one two && [ -d one ] && [ -d two ] && echo yes" "yes\n" "" "" rmdir one two -testing "mkdir missing/one" \ +testing "missing/one" \ "mkdir missing/one 2> /dev/null || [ ! -d missing ] && echo yes" "yes\n" "" "" -testing "mkdir -p" \ +testing "-p" \ "mkdir -p one/two/three && [ -d one/two/three ] && echo yes" "yes\n" "" "" rm -rf one mkdir existing -testing "mkdir -p existing" "mkdir -p existing && echo yes" "yes\n" "" "" +testing "-p existing" "mkdir -p existing && echo yes" "yes\n" "" "" rmdir existing umask 123 -testing "mkdir (default permissions)" \ +testing "(default permissions)" \ "mkdir one && stat -c %a one" "654\n" "" "" rmdir one -testing "mkdir -m 124" \ +testing "-m 124" \ "mkdir -m 124 one && stat -c %a one" "124\n" "" "" rmdir one umask 000 -testing "mkdir -p -m 653" \ +testing "-p -m 653" \ "mkdir -p -m 653 one/two && stat -c %a one && stat -c %a one/two" \ "777\n653\n" "" "" rm -rf one -testing "mkdir -p one/two/ (trailing slash)" \ +testing "-p one/two/ (trailing slash)" \ "mkdir -p one/two/ && [ -d one/two ] && echo yes" "yes\n" "" "" rm -rf one umask 022 -testing "mkdir -p -m 777 (022 umask)" \ +testing "-p -m 777 (022 umask)" \ "mkdir -p -m 777 one/two && stat -c %a one && stat -c %a one/two" \ "755\n777\n" "" "" rm -rf one umask 377 -testing "mkdir -p -m 777 (377 umask)" \ +testing "-p -m 777 (377 umask)" \ "mkdir -p -m 777 one/two && stat -c %a one && stat -c %a one/two" \ "700\n777\n" "" "" umask 002 rm -rf one -testing "mkdir -vp" "mkdir -vp walrus 2>&1" \ +testing "-vp" "mkdir -vp walrus 2>&1" \ "mkdir: created directory 'walrus'\n" "" "" -testing "mkdir -vp exists" "mkdir -vp walrus 2>&1" \ +testing "-vp exists" "mkdir -vp walrus 2>&1" \ "" "" "" rm -rf walrus touch two -testing "mkdir continue after fail" \ +testing "continue after fail" \ "mkdir -m 777 one two three 2>/dev/null || stat -c %a three" \ "777\n" "" "" rm -rf one two three diff --git a/tests/mkfifo.test b/tests/mkfifo.test index b0253fed..faaad1ff 100755 --- a/tests/mkfifo.test +++ b/tests/mkfifo.test @@ -8,21 +8,21 @@ testing "mkfifo" "mkfifo one && [ -p one ] && echo yes" "yes\n" "" "" rm one touch existing -testing "mkfifo existing" \ +testing "existing" \ "mkfifo existing 2> /dev/null || [ -f existing ] && echo yes" "yes\n" "" "" rm existing -testing "mkfifo one two" \ +testing "one two" \ "mkfifo one two && [ -p one ] && [ -p two ] && echo yes" "yes\n" "" "" rm one two umask 123 -testing "mkfifo (default permissions)" \ +testing "(default permissions)" \ "mkfifo one && stat -c %a one" "644\n" "" "" rm one umask 000 -testing "mkfifo -m 124" \ +testing "-m 124" \ "mkfifo -m 124 one && stat -c %a one" "124\n" "" "" rm -f one diff --git a/tests/modinfo.test b/tests/modinfo.test index ac94ce0f..0a8c2bec 100755 --- a/tests/modinfo.test +++ b/tests/modinfo.test @@ -14,17 +14,17 @@ #We expect they have ne2k-pci as a module. -testing "modinfo gets right number of fields" "modinfo ne2k-pci |cut -d: -f1 |grep -v ver|sort" "alias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nauthor\ndepends\ndescription\nfilename\nlicense\nparm\nparm\nparm\n" "" "" -testing "modinfo treats - and _ as equivalent" "modinfo ne2k_pci |cut -d: -f1 |grep -v ver|sort" "alias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nauthor\ndepends\ndescription\nfilename\nlicense\nparm\nparm\nparm\n" "" "" +testing "gets right number of fields" "modinfo ne2k-pci |cut -d: -f1 |grep -v ver|sort" "alias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nauthor\ndepends\ndescription\nfilename\nlicense\nparm\nparm\nparm\n" "" "" +testing "treats - and _ as equivalent" "modinfo ne2k_pci |cut -d: -f1 |grep -v ver|sort" "alias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nalias\nauthor\ndepends\ndescription\nfilename\nlicense\nparm\nparm\nparm\n" "" "" # Output of -F filename should be an absolute path to the module. # Otherwise, initrd generating scripts will break. -testing "modinfo -F filename gets absolute path" "[ -e `modinfo -F filename ne2k-pci` ] && echo ne2k-pci " "ne2k-pci\n" "" "" +testing "-F filename gets absolute path" "[ -e `modinfo -F filename ne2k-pci` ] && echo ne2k-pci " "ne2k-pci\n" "" "" -testing "modinfo supports multiple modules" "modinfo -F filename ne2k-pci 8390 | wc -l" "2\n" "" "" +testing "supports multiple modules" "modinfo -F filename ne2k-pci 8390 | wc -l" "2\n" "" "" -testing "modinfo does not output filename for bad module" "modinfo -F filename zxcvbnm__9753" "" "" "" +testing "does not output filename for bad module" "modinfo -F filename zxcvbnm__9753" "" "" "" diff --git a/tests/mount.test b/tests/mount.test index d64bfc62..6590b946 100755 --- a/tests/mount.test +++ b/tests/mount.test @@ -20,69 +20,69 @@ reCreateTmpFs() { } reCreateTmpFs -testing "mount $root_fs /mnt" \ +testing "$root_fs /mnt" \ "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" "" -testing "mount $tmp_b_fs /mnt" \ +testing "$tmp_b_fs /mnt" \ "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" "" reCreateTmpFs chmod 444 /mnt -testing "mount $root_fs /mnt (read_only dir)" \ +testing "$root_fs /mnt (read_only dir)" \ "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" "" -testing "mount $tmp_b_fs /mnt (read_only dir)" \ +testing "$tmp_b_fs /mnt (read_only dir)" \ "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" "" reCreateTmpFs chmod 755 /mnt -testing "mount -w $root_fs /mnt (write_only mode)" \ +testing "-w $root_fs /mnt (write_only mode)" \ "mount -w $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" "" -testing "mount -w $tmp_b_fs /mnt (write_only mode)" \ +testing "-w $tmp_b_fs /mnt (write_only mode)" \ "mount -w $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" "" reCreateTmpFs -testing "mount -rw $tmp_b_fs /mnt (read_write mode)" \ +testing "-rw $tmp_b_fs /mnt (read_write mode)" \ 'mount -rw $tmp_b_fs /mnt >/dev/null && mkdir /mnt/testDir && \ sleep 1 && ! test -e /mnt/testDir && umount /mnt' "" "" "" reCreateTmpFs -testing "mount $tmp_b_fs /mnt -t fs_type" \ +testing "$tmp_b_fs /mnt -t fs_type" \ "mount $tmp_b_fs /mnt -t $tmp_b_fs_type >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" "" reCreateTmpFs mkdir -p testDir1/testDir2 testDir echo "abcdefghijklmnopqrstuvwxyz" > testDir1/testDir2/testFile -testing "mount -o bind dir1 dir2" \ +testing "-o bind dir1 dir2" \ 'mount -o bind testDir1 testDir >/dev/null 2>&1 && \ cat testDir/testDir2/testFile && sleep 1 && umount testDir' \ "abcdefghijklmnopqrstuvwxyz\n" "" "" -testing "mount -o rbind dir1 dir2" \ +testing "-o rbind dir1 dir2" \ 'mount -o rbind testDir1 testDir >/dev/null 2>&1 && \ cat testDir/testDir2/testFile && sleep 1 && umount testDir' \ "abcdefghijklmnopqrstuvwxyz\n" "" "" -testing "mount -o loop $tmp_b_fs /mnt" \ +testing "-o loop $tmp_b_fs /mnt" \ "mount -o loop $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDirp && sleep 1 && umount -d /mnt && ! test -e /mnt/testDirp" "" "" "" reCreateTmpFs mkdir testDir2 -testing "mount -o move mount_1 mount_2" \ +testing "-o move mount_1 mount_2" \ "mount $tmp_b_fs testDir1 && mkdir testDir1/testDirr && mount -o move testDir1 testDir2 && test -r testDir2/testDirr && sleep 1 && umount testDir2" "" "" "" reCreateTmpFs -testing "mount -o rw $tmp_b_fs /mnt" \ +testing "-o rw $tmp_b_fs /mnt" \ "mount -o rw $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir && sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" "" reCreateTmpFs -testing "mount -o ro $tmp_b_fs /mnt" \ +testing "-o ro $tmp_b_fs /mnt" \ "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" "" reCreateTmpFs -testing "mount -o ro,remount $tmp_b_fs /mnt" \ +testing "-o ro,remount $tmp_b_fs /mnt" \ "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" "" reCreateTmpFs diff --git a/tests/mv.test b/tests/mv.test index ae39fb68..ab2ca5ed 100755 --- a/tests/mv.test +++ b/tests/mv.test @@ -8,98 +8,98 @@ #testing "name" "command" "result" "infile" "stdin" touch file -testing "mv old_file to new_file" "mv file file1 && [ ! -e file -a -f file1 ] && +testing "old_file to new_file" "mv file file1 && [ ! -e file -a -f file1 ] && echo 'yes'" "yes\n" "" "" rm -f file* touch file mkdir dir -testing "mv file to a dir" "mv file dir && [ ! -e file -a -f dir/file ] && +testing "file to a dir" "mv file dir && [ ! -e file -a -f dir/file ] && echo 'yes'" "yes\n" "" "" rm -rf file* dir* mkdir dir -testing "mv old_dir to new_dir" "mv dir dir1 && [ ! -e dir -a -d dir1 ] && +testing "old_dir to new_dir" "mv dir dir1 && [ ! -e dir -a -d dir1 ] && echo 'yes'" "yes\n" "" "" rm -rf dir* mkdir dir1 dir2 touch file1 file2 dir1/file3 ln -s file1 link1 -testing "mv multiple files/dir to a dir" "mv file1 file2 link1 dir1 dir2 && +testing "multiple files/dir to a dir" "mv file1 file2 link1 dir1 dir2 && [ ! -e file1 -a ! -e file2 -a ! -e link1 -a ! -e dir1 ] && [ -f dir2/file1 -a -f dir2/file2 -a -L dir2/link1 -a -d dir2/dir1 ] && [ -f dir2/dir1/file3 ] && readlink dir2/link1" "file1\n" "" "" rm -rf file* link* dir* touch file1 -testing "mv a empty file to new_file" "mv file1 file2 && +testing "a empty file to new_file" "mv file1 file2 && [ ! -e file1 -a -f file2 ] && stat -c %s file2" "0\n" "" "" rm -rf file* mkdir dir1 -testing "mv enpty dir to new_dir" "mv dir1 dir2 && +testing "enpty dir to new_dir" "mv dir1 dir2 && [ ! -d dir1 -a -d dir2 ] && echo 'yes'" "yes\n" "" "" rm -rf dir* dd if=/dev/zero of=file1 seek=10k count=1 >/dev/null 2>&1 -testing "mv file new_file (random file)" "mv file1 file2 && +testing "file new_file (random file)" "mv file1 file2 && [ ! -e file1 -a -f file2 ] && stat -c %s file2" "5243392\n" "" "" rm -f file* touch file1 ln -s file1 link1 -testing "mv link new_link (softlink)" "mv link1 link2 && +testing "link new_link (softlink)" "mv link1 link2 && [ ! -e link1 -a -L link2 ] && readlink link2" "file1\n" "" "" unlink tLink2 &>/dev/null rm -f file* link* touch file1 ln file1 link1 -testing "mv link new_link (hardlink)" "mv link1 link2 && +testing "link new_link (hardlink)" "mv link1 link2 && [ ! -e link1 -a -f link2 -a file1 -ef link2 ] && echo 'yes'" "yes\n" "" "" unlink link2 &>/dev/null rm -f file* link* touch file1 chmod a-r file1 -testing "mv file new_file (unreadable)" "mv file1 file2 && +testing "file new_file (unreadable)" "mv file1 file2 && [ ! -e file1 -a -f file2 ] && echo 'yes'" "yes\n" "" "" rm -f file* touch file1 ln file1 link1 mkdir dir1 -testing "mv file link dir (hardlink)" "mv file1 link1 dir1 && +testing "file link dir (hardlink)" "mv file1 link1 dir1 && [ ! -e file1 -a ! -e link1 -a -f dir1/file1 -a -f dir1/link1 ] && [ dir1/file1 -ef dir1/link1 ] && echo 'yes'" "yes\n" "" "" rm -rf file* link* dir* mkdir -p dir1/dir2 dir3 touch dir1/dir2/file1 dir1/dir2/file2 -testing "mv dir1/dir2 dir3/new_dir" "mv dir1/dir2 dir3/dir4 && +testing "dir1/dir2 dir3/new_dir" "mv dir1/dir2 dir3/dir4 && [ ! -e dir1/dir2 -a -d dir3/dir4 -a -f dir3/dir4/file1 ] && [ -f dir3/dir4/file2 ] && echo 'yes'" "yes\n" "" "" rm -rf file* dir* mkdir dir1 dir2 -testing "mv dir new_dir (already exist)" "mv dir1 dir2 && +testing "dir new_dir (already exist)" "mv dir1 dir2 && [ ! -e dir1 -a -d dir2/dir1 ] && echo 'yes'" "yes\n" "" "" rm -rf dir* touch file1 file2 -testing "mv -f file new_file (exist)" "mv -f file1 file2 && +testing "-f file new_file (exist)" "mv -f file1 file2 && [ ! -e file1 -a -e file2 ] && echo 'yes'" "yes\n" "" "" rm -f file* touch file1 file2 -testing "mv -n file new_file (exist)" "mv -n file1 file2 && +testing "-n file new_file (exist)" "mv -n file1 file2 && [ -e file1 -a -e file2 ] && echo 'yes'" "yes\n" "" "" rm -f file* touch file1 file2 chmod 400 file1 file2 -testing "mv file over unwritable file with no stdin" \ +testing "file over unwritable file with no stdin" \ "</dev/null mv file2 file1 && [ -e file -a ! -e file2 ] && echo 'yes'" \ "yes\n" "" "" rm -f file* diff --git a/tests/nl.test b/tests/nl.test index 958cb41e..499734d3 100755 --- a/tests/nl.test +++ b/tests/nl.test @@ -7,20 +7,20 @@ testing "nl" "nl" " 1\tone\n 2\ttwo\n 3\tthree\n" \ "" "one\ntwo\nthree\n" -testing "nl explicit defaults" "nl -nrn -b a" \ +testing "explicit defaults" "nl -nrn -b a" \ " 1\tone\n 2\ttwo\n 3\tthree\n" "" "one\ntwo\nthree\n" # -n ln rn rz -testing "nl -nln" "nl -nln" "1 \tone\n2 \ttwo\n3 \tthree\n" \ +testing "-nln" "nl -nln" "1 \tone\n2 \ttwo\n3 \tthree\n" \ "" "one\ntwo\nthree\n" -testing "nl -nln -w" "nl -nln -w 8" \ +testing "-nln -w" "nl -nln -w 8" \ "1 \tone\n2 \ttwo\n3 \tthree\n" "" "one\ntwo\nthree\n" -testing "nl -nrz" "nl -nrz" "000001\tone\n000002\ttwo\n000003\tthree\n" \ +testing "-nrz" "nl -nrz" "000001\tone\n000002\ttwo\n000003\tthree\n" \ "" "one\ntwo\nthree\n" -testing "nl -nrz -w" "nl -w3 -nrz" "001\tone\n002\ttwo\n003\tthree\n" \ +testing "-nrz -w" "nl -w3 -nrz" "001\tone\n002\ttwo\n003\tthree\n" \ "" "one\ntwo\nthree\n" @@ -31,20 +31,20 @@ testing "nl -nrz -w" "nl -w3 -nrz" "001\tone\n002\ttwo\n003\tthree\n" \ # nl -w 3 -bpthe README # Yeah. And I doubt utf8 fontmetrics are used either. -testing "nl -b t" "nl -b t" " \n 1\tone\n \n 2\ttwo\n" \ +testing "-b t" "nl -b t" " \n 1\tone\n \n 2\ttwo\n" \ "" "\none\n\ntwo\n" -testing "nl -b n" "nl -b n" " one\n two\n three\n" \ +testing "-b n" "nl -b n" " one\n two\n three\n" \ "" "one\ntwo\nthree\n" -testing "nl -sook -b p" "nl -sook -bpoing" \ +testing "-sook -b p" "nl -sook -bpoing" \ " one\n 1ookboing\n 2ooksproingy\n" \ "" "one\nboing\nsproingy\n" -testing "nl -v" "nl -v 42" " 42\tone\n 43\ttwo\n 44\tthree\n" \ +testing "-v" "nl -v 42" " 42\tone\n 43\ttwo\n 44\tthree\n" \ "" "one\ntwo\nthree\n" -testing "nl -l" "nl -ba -l2 -w2 - input" \ +testing "-l" "nl -ba -l2 -w2 - input" \ " 1\tone\n \n 2\t\n 3\ttwo\n \n 4\t\n \n 5\tthree\n 6\tfour\n \n 7\t\n \n 8\tbang\n \n" \ "\n\nbang\n\n" "one\n\n\ntwo\n\n\n\nthree\nfour\n\n" -testing "nl no space" "nl -w 1 -v 42" "42\tline\n" "" "line\n" +testing "no space" "nl -w 1 -v 42" "42\tline\n" "" "line\n" # Should test for -E but no other implementation seems to have it? -#testing "nl -E" "nl -w2 -sx -Ebp'(one|two)'" " 1x" "one\nand\ntwo\n" +#testing "-E" "nl -w2 -sx -Ebp'(one|two)'" " 1x" "one\nand\ntwo\n" diff --git a/tests/pgrep.test b/tests/pgrep.test index 2af12204..753a55ab 100755 --- a/tests/pgrep.test +++ b/tests/pgrep.test @@ -20,14 +20,14 @@ proc_parent=`cat /proc/${proc}/stat | awk '{ print $4 }'` #echo "# Parent Process id of $proc is $proc_parent" # Testcases for pgrep command -testing "pgrep pattern" "pgrep yes" "$proc\n" "" "" -testing "pgrep wildCardPattern" "pgrep ^y.*s$" "$proc\n" "" "" -testing "pgrep -l pattern" "pgrep -l yes" "$proc yes\n" "" "" -testing "pgrep -f pattern" "pgrep -f yes" "$proc\n" "" "" -testing "pgrep -n pattern" "pgrep -n yes" "$proc\n" "" "" -testing "pgrep -o pattern" "pgrep -o yes" "$proc\n" "" "" -testing "pgrep -s" "pgrep -s $session_id yes" "$proc\n" "" "" -testing "pgrep -P" "pgrep -P $proc_parent yes" "$proc\n" "" "" +testing "pattern" "pgrep yes" "$proc\n" "" "" +testing "wildCardPattern" "pgrep ^y.*s$" "$proc\n" "" "" +testing "-l pattern" "pgrep -l yes" "$proc yes\n" "" "" +testing "-f pattern" "pgrep -f yes" "$proc\n" "" "" +testing "-n pattern" "pgrep -n yes" "$proc\n" "" "" +testing "-o pattern" "pgrep -o yes" "$proc\n" "" "" +testing "-s" "pgrep -s $session_id yes" "$proc\n" "" "" +testing "-P" "pgrep -P $proc_parent yes" "$proc\n" "" "" #Clean-up killall yes >/dev/null 2>&1 diff --git a/tests/pkill.test b/tests/pkill.test index e753d31f..7a20ae5c 100755 --- a/tests/pkill.test +++ b/tests/pkill.test @@ -14,7 +14,7 @@ killall yes >/dev/null 2>&1 yes >/dev/null & sleep 1 -testing "pkill pattern" "pkill yes && sleep 1 && (pgrep yes || echo 'yes')" \ +testing "pattern" "pkill yes && sleep 1 && (pgrep yes || echo 'yes')" \ "yes\n" "" "" killall yes >/dev/null 2>&1 @@ -22,19 +22,19 @@ yes >/dev/null & yes print1 >/dev/null & yes print2 >/dev/null & sleep 1 -testing "pkill pattern (multiple)" "pkill yes && sleep 1 && +testing "pattern (multiple)" "pkill yes && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 yes >/dev/null & sleep 1 -testing "pkill -f pattern (one)" "pkill -f yes && sleep 1 && +testing "-f pattern (one)" "pkill -f yes && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 yes print1 >/dev/null & sleep 1 -testing "pkill -f pattern args" "pkill -f \"yes print1\" && sleep 1 && +testing "-f pattern args" "pkill -f \"yes print1\" && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 @@ -42,13 +42,13 @@ yes >/dev/null & yes print1 >/dev/null & yes print2 >/dev/null & sleep 1 -testing "pkill -f pattern (multiple)" "pkill -f yes && sleep 1 && +testing "-f pattern (multiple)" "pkill -f yes && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 yes >/dev/null & sleep 1 -testing "pkill -s 0 -f pattern (regexp)" "pkill -s 0 -f ye* && sleep 1 && +testing "-s 0 -f pattern (regexp)" "pkill -s 0 -f ye* && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 @@ -57,7 +57,7 @@ proc1=$! yes >/dev/null & proc2=$! sleep 1 -testing "pkill -n pattern" "pkill -n yes && sleep 1 && pgrep yes" \ +testing "-n pattern" "pkill -n yes && sleep 1 && pgrep yes" \ "$proc1\n" "" "" killall yes >/dev/null 2>&1 @@ -66,19 +66,19 @@ proc1=$! yes >/dev/null & proc2=$! sleep 1 -testing "pkill -o pattern" "pkill -o yes && sleep 1 && pgrep yes" \ +testing "-o pattern" "pkill -o yes && sleep 1 && pgrep yes" \ "$proc2\n" "" "" killall yes >/dev/null 2>&1 yes >/dev/null & sleep 1 -testing "pkill -s (blank) pattern" "pkill -s '' yes && sleep 1 && +testing "-s (blank) pattern" "pkill -s '' yes && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 yes >/dev/null & sleep 1 -testing "pkill -s 0 pattern" "pkill -s 0 yes && sleep 1 && +testing "-s 0 pattern" "pkill -s 0 yes && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 @@ -86,7 +86,7 @@ yes >/dev/null & proc=$! proc_p=`cat /proc/${proc}/stat | awk '{ print $4 }'` sleep 1 -testing "pkill -P parent_prodId pattern" "pkill -P $proc_p yes && sleep 1 && +testing "-P parent_prodId pattern" "pkill -P $proc_p yes && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 @@ -94,7 +94,7 @@ yes >/dev/null & proc=$! proc_parent=`cat /proc/${proc}/stat | awk '{ print $4 }'` sleep 1 -testing "pkill -9 pattern" "pkill -9 yes && sleep 1 && +testing "-9 pattern" "pkill -9 yes && sleep 1 && (pgrep yes || echo 'yes')" "yes\n" "" "" killall yes >/dev/null 2>&1 diff --git a/tests/printf.test b/tests/printf.test index 20d5982d..7b077f0c 100755 --- a/tests/printf.test +++ b/tests/printf.test @@ -10,52 +10,52 @@ # Disable shell builtin PRINTF="$(which printf)" -testing "printf text" "$PRINTF TEXT" "TEXT" "" "" -testing "printf escapes" "$PRINTF 'one\ntwo\n\v\t\r\f\e\b\athree'" \ +testing "text" "$PRINTF TEXT" "TEXT" "" "" +testing "escapes" "$PRINTF 'one\ntwo\n\v\t\r\f\e\b\athree'" \ "one\ntwo\n\v\t\r\f\e\b\athree" "" "" -testing "printf %b escapes" "$PRINTF %b 'one\ntwo\n\v\t\r\f\e\b\athree'" \ +testing "%b escapes" "$PRINTF %b 'one\ntwo\n\v\t\r\f\e\b\athree'" \ "one\ntwo\n\v\t\r\f\e\b\athree" "" "" -testing "printf null" "$PRINTF 'x\0y' | od -An -tx1" ' 78 00 79\n' "" "" -testing "printf trailing slash" "$PRINTF 'abc\'" 'abc\' "" "" -testing "printf octal" "$PRINTF ' \1\002\429\045x'" ' \001\002"9%x' "" "" -testing "printf not octal" "$PRINTF '\9'" '\9' "" "" -testing "printf hex" "$PRINTF 'A\x1b\x2B\x3Q\xa' | od -An -tx1" \ +testing "null" "$PRINTF 'x\0y' | od -An -tx1" ' 78 00 79\n' "" "" +testing "trailing slash" "$PRINTF 'abc\'" 'abc\' "" "" +testing "octal" "$PRINTF ' \1\002\429\045x'" ' \001\002"9%x' "" "" +testing "not octal" "$PRINTF '\9'" '\9' "" "" +testing "hex" "$PRINTF 'A\x1b\x2B\x3Q\xa' | od -An -tx1" \ ' 41 1b 2b 03 51 0a\n' "" "" -testing "printf %x" "$PRINTF '%x\n' 0x2a" "2a\n" "" "" +testing "%x" "$PRINTF '%x\n' 0x2a" "2a\n" "" "" -testing "printf %d 42" "$PRINTF %d 42" "42" "" "" -testing "printf %d 0x2a" "$PRINTF %d 0x2a" "42" "" "" -testing "printf %d 052" "$PRINTF %d 052" "42" "" "" +testing "%d 42" "$PRINTF %d 42" "42" "" "" +testing "%d 0x2a" "$PRINTF %d 0x2a" "42" "" "" +testing "%d 052" "$PRINTF %d 052" "42" "" "" -testing "printf %s width precision" \ +testing "%s width precision" \ "$PRINTF '%3s,%.3s,%10s,%10.3s' abcde fghij klmno pqrst" \ "abcde,fgh, klmno, pqr" "" "" # posix: "The format operand shall be reused as often as necessary to satisfy # the argument operands." -testing "printf extra args" "$PRINTF 'abc%s!%ddef\n' X 42 ARG 36" \ +testing "extra args" "$PRINTF 'abc%s!%ddef\n' X 42 ARG 36" \ "abcX!42def\nabcARG!36def\n" "" "" -testing "printf '%3c'" "$PRINTF '%3c' x" " x" "" "" -testing "printf '%-3c'" "$PRINTF '%-3c' x" "x " "" "" -testing "printf '%+d'" "$PRINTF '%+d' 5" "+5" "" "" +testing "'%3c'" "$PRINTF '%3c' x" " x" "" "" +testing "'%-3c'" "$PRINTF '%-3c' x" "x " "" "" +testing "'%+d'" "$PRINTF '%+d' 5" "+5" "" "" -testing "printf '%5d%4d' 1 21 321 4321 54321" \ +testing "'%5d%4d' 1 21 321 4321 54321" \ "$PRINTF '%5d%4d' 1 21 321 4321 54321" " 1 21 321432154321 0" "" "" -testing "printf '%c %c' 78 79" "$PRINTF '%c %c' 78 79" "7 7" "" "" -testing "printf '%d %d' 78 79" "$PRINTF '%d %d' 78 79" "78 79" "" "" -testing "printf '%f %f' 78 79" "$PRINTF '%f %f' 78 79" \ +testing "'%c %c' 78 79" "$PRINTF '%c %c' 78 79" "7 7" "" "" +testing "'%d %d' 78 79" "$PRINTF '%d %d' 78 79" "78 79" "" "" +testing "'%f %f' 78 79" "$PRINTF '%f %f' 78 79" \ "78.000000 79.000000" "" "" -testing "printf 'f f' 78 79" "$PRINTF 'f f' 78 79" "f f" "" "" -testing "printf '%i %i' 78 79" "$PRINTF '%i %i' 78 79" "78 79" "" "" -testing "printf '%o %o' 78 79" "$PRINTF '%o %o' 78 79" "116 117" "" "" -testing "printf '%u %u' 78 79" "$PRINTF '%u %u' 78 79" "78 79" "" "" -testing "printf '%u %u' -1 -2" "$PRINTF '%u %u' -1 -2" \ +testing "'f f' 78 79" "$PRINTF 'f f' 78 79" "f f" "" "" +testing "'%i %i' 78 79" "$PRINTF '%i %i' 78 79" "78 79" "" "" +testing "'%o %o' 78 79" "$PRINTF '%o %o' 78 79" "116 117" "" "" +testing "'%u %u' 78 79" "$PRINTF '%u %u' 78 79" "78 79" "" "" +testing "'%u %u' -1 -2" "$PRINTF '%u %u' -1 -2" \ "18446744073709551615 18446744073709551614" "" "" -testing "printf '%x %X' 78 79" "$PRINTF '%x %X' 78 79" "4e 4F" "" "" -testing "printf '%g %G' 78 79" "$PRINTF '%g %G' 78 79" "78 79" "" "" -testing "printf '%s %s' 78 79" "$PRINTF '%s %s' 78 79" "78 79" "" "" +testing "'%x %X' 78 79" "$PRINTF '%x %X' 78 79" "4e 4F" "" "" +testing "'%g %G' 78 79" "$PRINTF '%g %G' 78 79" "78 79" "" "" +testing "'%s %s' 78 79" "$PRINTF '%s %s' 78 79" "78 79" "" "" -testing "printf %.s acts like %.0s" "$PRINTF %.s_ 1 2 3 4 5" "_____" "" "" +testing "%.s acts like %.0s" "$PRINTF %.s_ 1 2 3 4 5" "_____" "" "" diff --git a/tests/pwd.test b/tests/pwd.test index b02055b1..68d22e35 100755 --- a/tests/pwd.test +++ b/tests/pwd.test @@ -8,7 +8,7 @@ testing "pwd" "[ $(stat -c %i "$(pwd)") = $(stat -c %i .) ] && echo yes" \ "yes\n" "" "" -testing "pwd -P" "[ $(stat -c %i "$(pwd -P)") = $(stat -c %i .) ] && echo yes" \ +testing "-P" "[ $(stat -c %i "$(pwd -P)") = $(stat -c %i .) ] && echo yes" \ "yes\n" "" "" @@ -16,11 +16,11 @@ ln -s . sym cd sym testing "pwd" "[ $(stat -c %i "$(pwd)") = $(stat -c %i "$PWD") ] && echo yes" \ "yes\n" "" "" -testing "pwd -P" "[ $(stat -c %i "$(pwd -P)") = $(stat -c %i "$PWD") ] || echo yes" \ +testing "-P" "[ $(stat -c %i "$(pwd -P)") = $(stat -c %i "$PWD") ] || echo yes" \ "yes\n" "" "" cd .. rm sym export PWD=walrus -testing "pwd (bad PWD)" "[ "$(pwd)" = "$(cd . ; pwd)" ] && echo yes" \ +testing "(bad PWD)" "[ "$(pwd)" = "$(cd . ; pwd)" ] && echo yes" \ "yes\n" "" "" diff --git a/tests/readlink.test b/tests/readlink.test index 6c7b147f..bb259859 100755 --- a/tests/readlink.test +++ b/tests/readlink.test @@ -6,54 +6,54 @@ APWD="$(pwd -P)" -testing "readlink missing" "readlink notfound || echo yes" "yes\n" "" "" +testing "missing" "readlink notfound || echo yes" "yes\n" "" "" # simple tests on a file touch file -testing "readlink file" "readlink file || echo yes" "yes\n" "" "" -testing "readlink -f dir" "readlink -f ." "$APWD\n" "" "" -testing "readlink -f missing" "readlink -f notfound" "$APWD/notfound\n" "" "" +testing "file" "readlink file || echo yes" "yes\n" "" "" +testing "-f dir" "readlink -f ." "$APWD\n" "" "" +testing "-f missing" "readlink -f notfound" "$APWD/notfound\n" "" "" ln -sf notfound link -testing "readlink link" "readlink link" "notfound\n" "" "" -testing "readlink link->missing" "readlink -f link" "$APWD/notfound\n" "" "" +testing "link" "readlink link" "notfound\n" "" "" +testing "link->missing" "readlink -f link" "$APWD/notfound\n" "" "" ln -sf ../../ link -testing "readlink stays relative" "readlink link" "../../\n" "" "" +testing "stays relative" "readlink link" "../../\n" "" "" rm link ln -sf file link -testing "readlink -f link->file" "readlink -f link" "$APWD/file\n" "" "" +testing "-f link->file" "readlink -f link" "$APWD/file\n" "" "" ln -sf . link -testing "readlink -f link->dir" "readlink -f link" "$APWD\n" "" "" +testing "-f link->dir" "readlink -f link" "$APWD\n" "" "" ln -snf link link -testing "readlink link->link (recursive)" "readlink link" "link\n" "" "" -testing "readlink -f link->link (recursive)" \ +testing "link->link (recursive)" "readlink link" "link\n" "" "" +testing "-f link->link (recursive)" \ "readlink -f link 2>/dev/null || echo yes" "yes\n" "" "" -testing "readlink -q notlink" "readlink -q file || echo yes" "yes\n" "" "" -testing "readlink -q link" "readlink -q link && echo yes" "yes\n" "" "" -testing "readlink -q notfound" "readlink -q notfound || echo yes" "yes\n" "" "" -testing "readlink -e found" "readlink -e file" "$APWD/file\n" "" "" -testing "readlink -e notfound" \ +testing "-q notlink" "readlink -q file || echo yes" "yes\n" "" "" +testing "-q link" "readlink -q link && echo yes" "yes\n" "" "" +testing "-q notfound" "readlink -q notfound || echo yes" "yes\n" "" "" +testing "-e found" "readlink -e file" "$APWD/file\n" "" "" +testing "-e notfound" \ "readlink -e notfound 2>/dev/null || echo yes" "yes\n" "" "" -testing "readlink -nf ." "readlink -nf ." "$APWD" "" "" +testing "-nf ." "readlink -nf ." "$APWD" "" "" mkdir sub && ln -s . here && ln -s ./sub dir && touch sub/bang || exit 1 -testing "readlink -f multi" "readlink -f dir/../here/dir/bang" \ +testing "-f multi" "readlink -f dir/../here/dir/bang" \ "$APWD/sub/bang\n" "" "" -testing "readlink -f link/missing" "readlink -f dir/boing" \ +testing "-f link/missing" "readlink -f dir/boing" \ "$APWD/sub/boing\n" "" "" -testing "readlink -f /dev/null/file" \ +testing "-f /dev/null/file" \ "readlink -f /dev/null/file 2>/dev/null || echo yes" "yes\n" "" "" ln -sf / link || exit 1 -testing "readlink -f link->/" "readlink -e link/dev" "/dev\n" "" "" -testing "readlink -f /dev/null/.." \ +testing "-f link->/" "readlink -e link/dev" "/dev\n" "" "" +testing "-f /dev/null/.." \ "readlink -f link/null/.. 2>/dev/null || echo yes" "yes\n" "" "" rm -f link && ln -sf link link || exit 1 -testing "readlink recurse" "readlink link" "link\n" "" "" +testing "recurse" "readlink link" "link\n" "" "" rm file link sub/bang dir here rmdir sub @@ -62,6 +62,6 @@ rmdir sub ln -s link1 link2 ln -s link2 link1 -testing "readlink follow recursive2" "readlink -f link1 || echo yes" \ +testing "follow recursive2" "readlink -f link1 || echo yes" \ "yes\n" "" "" rm link1 link2 diff --git a/tests/renice.test b/tests/renice.test index e87111cc..e350c272 100755 --- a/tests/renice.test +++ b/tests/renice.test @@ -45,7 +45,7 @@ do nice_val3=$((`fun_nice_val $proc3` + $n_v)) nice_val4=$((`fun_nice_val $proc4` + $n_v)) nice_val5=$((`fun_nice_val $proc5` + $n_v)) - testing "renice with -n=$n_v and with$n_o multiple_pids" \ + testing "with -n=$n_v and with$n_o multiple_pids" \ "renice -n $n_v$n_o $proc1 $proc2 $proc3 $proc4 $proc5 && fun_nice_val $proc1 $proc2 $proc3 $proc4 $proc5" \ "$nice_val1\n$nice_val2\n$nice_val3\n$nice_val4\n$nice_val5\n" "" "" @@ -55,7 +55,7 @@ do nice_val3=$((`fun_nice_val $proc3` + $n_v)) nice_val4=$((`fun_nice_val $proc4` + $n_v)) nice_val5=$((`fun_nice_val $proc5` + $n_v)) - testing "renice with -n=$n_v and with$n_o multiple_pids (some invalid)" \ + testing "with -n=$n_v and with$n_o multiple_pids (some invalid)" \ "renice -n $n_v$n_o $proc1 $proc2 88888 99999 $proc3 $proc4 $proc5 $arg || fun_nice_val $proc1 $proc2 $proc3 $proc4 $proc5" \ "$nice_val1\n$nice_val2\n$nice_val3\n$nice_val4\n$nice_val5\n" "" "" diff --git a/tests/rev.test b/tests/rev.test index c7622b9d..ede78c2a 100755 --- a/tests/rev.test +++ b/tests/rev.test @@ -7,17 +7,17 @@ echo -e "one" > file1 echo -e "two" > file2 testing "rev" "rev && echo yes" "orez\nyes\n" "" "zero\n" -testing "rev -" "rev - && echo yes" "orez\nyes\n" "" "zero\n" -testing "rev file1 file2" "rev file1 file2" "eno\nowt\n" "" "" -testing "rev - file" "rev - file1" "orez\neno\n" "" "zero\n" -testing "rev file -" "rev file1 -" "eno\norez\n" "" "zero\n" -testing "rev no trailing newline" "rev -" "cba\nfed\n" "" "abc\ndef" +testing "-" "rev - && echo yes" "orez\nyes\n" "" "zero\n" +testing "file1 file2" "rev file1 file2" "eno\nowt\n" "" "" +testing "- file" "rev - file1" "orez\neno\n" "" "zero\n" +testing "file -" "rev file1 -" "eno\norez\n" "" "zero\n" +testing "no trailing newline" "rev -" "cba\nfed\n" "" "abc\ndef" -testing "rev file1 notfound file2" \ +testing "file1 notfound file2" \ "rev file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \ "eno\nowt\nrev: notfound: No such file or directory\n" "" "" -testing "rev different input sizes"\ +testing "different input sizes"\ "rev"\ "\n1\n21\n321\n4321\n54321\n4321\n321\n21\n1\n\n"\ "" "\n1\n12\n123\n1234\n12345\n1234\n123\n12\n1\n\n" diff --git a/tests/rm.test b/tests/rm.test index 3fe71448..624d60fd 100755 --- a/tests/rm.test +++ b/tests/rm.test @@ -8,21 +8,21 @@ #testing "name" "command" "result" "infile" "stdin" echo "abcdefghijklmnopqrstuvwxyz" > file.txt -testing "rm text-file" "rm file.txt && [ ! -e file.txt ] && echo 'yes'" "yes\n" "" "" +testing "text-file" "rm file.txt && [ ! -e file.txt ] && echo 'yes'" "yes\n" "" "" rm -f file* mkdir dir -testing "rm empty directory" "rm -r dir && [ ! -d dir ] && echo 'yes'" "yes\n" "" "" +testing "empty directory" "rm -r dir && [ ! -d dir ] && echo 'yes'" "yes\n" "" "" rm -rf dir echo "abcdefghijklmnopqrstuvwxyz" > file.txt && chmod 000 file.txt -testing "rm text file(mode 000)" "rm -f file.txt && [ ! -e file.txt ] && echo 'yes'" \ +testing "text file(mode 000)" "rm -f file.txt && [ ! -e file.txt ] && echo 'yes'" \ "yes\n" "" "" rm -f file* touch file1.txt file2.txt mkdir dir1 dir2 -testing "rm -r (multiple files and dirs)" \ +testing "-r (multiple files and dirs)" \ "rm -r file1.txt file2.txt dir1 dir2 2>/dev/null && [ ! -e file1.txt -a ! -e file2.txt -a ! -d dir1 -a ! -d dir2 ] && echo 'yes'" \ "yes\n" "" "" @@ -30,7 +30,7 @@ rm -rf file* dir* touch file1.txt file2.txt mkdir dir1 dir2 -testing "rm -rf (present + missing files and dirs)" \ +testing "-rf (present + missing files and dirs)" \ "rm -rf file1.txt file2.txt file3.txt dir1 dir2 dir3 2>/dev/null && [ ! -e file1.txt -a ! -e file2.txt -a ! -d dir1 -a ! -d dir2 ] && echo 'yes'" \ "yes\n" "" "" @@ -39,7 +39,7 @@ rm -rf file* dir* # testing with nested dirs. mkdir -p dir1/dir2/dir3 dir1/dir2/dir4 touch dir1/file1.txt dir1/dir2/file2.txt dir1/dir2/dir3/file3.txt -testing "rm -r nested_dir" "rm -r dir1/dir2/ 2>/dev/null && +testing "-r nested_dir" "rm -r dir1/dir2/ 2>/dev/null && [ -d dir1 -a -f dir1/file1.txt -a ! -d dir1/dir2 ] && echo 'yes'" \ "yes\n" "" "" rm -rf dir* diff --git a/tests/rmdir.test b/tests/rmdir.test index a7b027e0..5b36bbc1 100755 --- a/tests/rmdir.test +++ b/tests/rmdir.test @@ -8,48 +8,48 @@ mkdir one testing "rmdir" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" "" touch walrus -testing "rmdir file" \ +testing "file" \ "rmdir walrus 2> /dev/null || [ -f walrus ] && echo yes" "yes\n" "" "" mkdir one two -testing "rmdir one two" \ +testing "one two" \ "rmdir one two 2> /dev/null && [ ! -d one ] && [ ! -d two ] && echo yes" \ "yes\n" "" "" mkdir one two three -testing "rmdir one missing two file three" \ +testing "one missing two file three" \ "rmdir one missing two walrus three 2> /dev/null || [ ! -d three ] && echo yes" \ "yes\n" "" "" rm walrus mkdir one chmod 000 one -testing "rmdir mode 000" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" "" +testing "mode 000" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" "" mkdir temp touch temp/thing -testing "rmdir non-empty" \ +testing "non-empty" \ "rmdir temp 2>/dev/null || [ -d temp ] && echo yes" "yes\n" "" "" -testing "rmdir -p dir/file" \ +testing "-p dir/file" \ "rmdir -p temp/thing 2>/dev/null || [ -f temp/thing ] && echo yes" \ "yes\n" "" "" mkdir -p temp/one/two/three -testing "rmdir -p part of path" \ +testing "-p part of path" \ "rmdir -p temp/one/two/three 2>/dev/null || [ -d temp ] && [ ! -e temp/one ] && echo yes" \ "yes\n" "" "" rm -rf temp mkdir -p one/two/three -testing "rmdir -p one/two/three" \ +testing "-p one/two/three" \ "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" "" mkdir -p one/two/three -testing "rmdir -p one/two/three/" \ +testing "-p one/two/three/" \ "rmdir -p one/two/three/ && [ ! -e one ] && echo yes" "yes\n" "" "" #mkdir -p one/two/three #chmod 000 one/two/three one/two one -#testing "rmdir -p one/two/three" \ +#testing "-p one/two/three" \ # "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" "" diff --git a/tests/sed.test b/tests/sed.test index c62f9c4d..280b466a 100755 --- a/tests/sed.test +++ b/tests/sed.test @@ -63,21 +63,21 @@ testing 'sed regex address overlap' 'sed -n /on/,/off/p' "on\nzap\noffon\n" "" \ # abcdDi testing 'sed prodigaler newline' 'sed -e a\\ -e woo' 'one\nwoo\n' '' 'one' -testing "sed aci" \ +testing "aci" \ "sed -e '3a boom' -e '/hre/i bang' -e '3a whack' -e '3c bong'" \ "one\ntwo\nbang\nbong\nboom\nwhack\nfour\n" "" \ "one\ntwo\nthree\nfour\n" -testing "sed b loop" "sed ':woo;=;b woo' | head -n 5" '1\n1\n1\n1\n1\n' "" "X" -testing "sed b skip" "sed -n '2b zap;d;:zap;p'" "two\n" "" "one\ntwo\nthree" -testing "sed b end" "sed -n '2b;p'" "one\nthree" "" "one\ntwo\nthree" -testing "sed c range" "sed '2,4c blah'" "one\nblah\nfive\nsix" "" \ +testing "b loop" "sed ':woo;=;b woo' | head -n 5" '1\n1\n1\n1\n1\n' "" "X" +testing "b skip" "sed -n '2b zap;d;:zap;p'" "two\n" "" "one\ntwo\nthree" +testing "b end" "sed -n '2b;p'" "one\nthree" "" "one\ntwo\nthree" +testing "c range" "sed '2,4c blah'" "one\nblah\nfive\nsix" "" \ "one\ntwo\nthree\nfour\nfive\nsix" -testing "sed c {range}" "sed -e '2,4{c blah' -e '}'" \ +testing "c {range}" "sed -e '2,4{c blah' -e '}'" \ "one\nblah\nblah\nblah\nfive\nsix" \ "" "one\ntwo\nthree\nfour\nfive\nsix" -testing "sed c multiple continuation" \ +testing "c multiple continuation" \ "sed -e 'c\\' -e 'two\\' -e ''" "two\n\n" "" "hello" -testing "sed D further processing depends on whether line is blank" \ +testing "D further processing depends on whether line is blank" \ "sed -e '/one/,/three/{' -e 'i meep' -e'N;2D;}'" \ "meep\nmeep\ntwo\nthree\n" "" "one\ntwo\nthree\n" testing 'sed newline staying away' 'sed s/o/x/' 'xne\ntwx' '' 'one\ntwo' @@ -88,7 +88,7 @@ testing 'sed newline staying away' 'sed s/o/x/' 'xne\ntwx' '' 'one\ntwo' # all the s/// test -testing "sed match empty line" "sed -e 's/^\$/@/'" "@\n" "" "\n" +testing "match empty line" "sed -e 's/^\$/@/'" "@\n" "" "\n" testing 'sed \1' "sed 's/t\\(w\\)o/za\\1py/'" "one\nzawpy\nthree" "" \ "one\ntwo\nthree" @@ -112,12 +112,12 @@ testing 'sed s///#comment' "sed -e 's/TWO/four/i#comment'" "one\nfour\nthree" \ testing 'sed N flushes pending a and advances match counter' \ "sed -e 'a woo' -e 'N;\$p'" 'woo\none\ntwo\none\ntwo' "" 'one\ntwo' -testing "sed delimiter in regex [char range] doesn't count" "sed -e 's/[/]//'" \ +testing "delimiter in regex [char range] doesn't count" "sed -e 's/[/]//'" \ "onetwo\n" "" 'one/two\n' -testing "sed delete regex range start line after trigger" \ +testing "delete regex range start line after trigger" \ "sed -e '/one/,/three/{' -e 'i meep' -e '1D;}'" \ "meep\nmeep\ntwo\nmeep\nthree" "" "one\ntwo\nthree" -testing "sed blank pattern repeats last pattern" \ +testing "blank pattern repeats last pattern" \ "sed -e '/^three/s//abc&def/'" \ "one two three\nabcthreedef four five\nfive six seven\n" "" \ "one two three\nthree four five\nfive six seven\n" @@ -132,19 +132,19 @@ hello'" "merp\nhello\n" "" "merp" testing "" "sed -e '/x/c\' -e 'y'" 'y\n' '' 'x\n' testing "" "sed -e 's/a[([]*b/X/'" 'X' '' 'a[(b' testing "" "sed 'y/a\\bc/de\f/'" "db\f" "" "abc" -testing "sed [a-a] (for perl)" "sed '"'s/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g'"'" \ +testing "[a-a] (for perl)" "sed '"'s/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g'"'" \ 'he\ llo' "" "he llo" # You have to match the first line of a range in order to activate # the range, numeric and ascii work the same way -testing "sed skip start of range" "sed -e n -e '1,2s/b/c/'" "a\nb\n" "" "a\nb\n" +testing "skip start of range" "sed -e n -e '1,2s/b/c/'" "a\nb\n" "" "a\nb\n" #echo meep | sed/sed -e '1a\' -e 'huh' #echo blah | sed/sed -f <(echo -e "1a\\\\\nboom") #echo merp | sed/sed "1a\\ #hello" -testing "sed bonus backslashes" \ +testing "bonus backslashes" \ "sed -e 'a \l \x\' -e \"\$(echo -e 'ab\\\nc')\"" \ "hello\nl x\nab\nc\n" "" "hello\n" # -i with $ last line test diff --git a/tests/seq.test b/tests/seq.test index c9e1c019..71079785 100755 --- a/tests/seq.test +++ b/tests/seq.test @@ -4,45 +4,45 @@ #testing "name" "command" "result" "infile" "stdin" -testing "seq (exit with error)" "seq 2> /dev/null || echo yes" "yes\n" "" "" -testing "seq (exit with error)" "seq 1 2 3 4 2> /dev/null || echo yes" \ +testing "(exit with error)" "seq 2> /dev/null || echo yes" "yes\n" "" "" +testing "(exit with error)" "seq 1 2 3 4 2> /dev/null || echo yes" \ "yes\n" "" "" -testing "seq one argument" "seq 3" "1\n2\n3\n" "" "" -testing "seq two arguments" "seq 5 7" "5\n6\n7\n" "" "" -testing "seq two arguments reversed" "seq 7 5" "" "" "" -testing "seq two arguments equal" "seq 3 3" "3\n" "" "" -testing "seq two arguments equal, arbitrary negative step" "seq 1 -15 1" \ +testing "one argument" "seq 3" "1\n2\n3\n" "" "" +testing "two arguments" "seq 5 7" "5\n6\n7\n" "" "" +testing "two arguments reversed" "seq 7 5" "" "" "" +testing "two arguments equal" "seq 3 3" "3\n" "" "" +testing "two arguments equal, arbitrary negative step" "seq 1 -15 1" \ "1\n" "" "" -testing "seq two arguments equal, arbitrary positive step" "seq 1 +15 1" \ +testing "two arguments equal, arbitrary positive step" "seq 1 +15 1" \ "1\n" "" "" -testing "seq count up by 2" "seq 4 2 8" "4\n6\n8\n" "" "" -testing "seq count down by 2" "seq 8 -2 4" "8\n6\n4\n" "" "" -testing "seq count wrong way #1" "seq 4 -2 8" "" "" "" -testing "seq count wrong way #2" "seq 8 2 4" "" "" "" -testing "seq count by .3" "seq 3 .3 4" "3\n3.3\n3.6\n3.9\n" "" "" -testing "seq count by -.9" "seq .7 -.9 -2.2" "0.7\n-0.2\n-1.1\n-2\n" "" "" -testing "seq count by zero" "seq 4 0 8 | head -n 10" "" "" "" -testing "seq separator -" "seq -s - 1 3" "1-2-3\n" "" "" -testing "seq format string" 'seq -f %+01g -10 5 10' "-10\n-5\n+0\n+5\n+10\n" \ +testing "count up by 2" "seq 4 2 8" "4\n6\n8\n" "" "" +testing "count down by 2" "seq 8 -2 4" "8\n6\n4\n" "" "" +testing "count wrong way #1" "seq 4 -2 8" "" "" "" +testing "count wrong way #2" "seq 8 2 4" "" "" "" +testing "count by .3" "seq 3 .3 4" "3\n3.3\n3.6\n3.9\n" "" "" +testing "count by -.9" "seq .7 -.9 -2.2" "0.7\n-0.2\n-1.1\n-2\n" "" "" +testing "count by zero" "seq 4 0 8 | head -n 10" "" "" "" +testing "separator -" "seq -s - 1 3" "1-2-3\n" "" "" +testing "format string" 'seq -f %+01g -10 5 10' "-10\n-5\n+0\n+5\n+10\n" \ "" "" -testing "seq separator and format string" "seq -f \%03g -s \; 5 -1 0" "005;004;003;002;001;000\n" "" "" -testing "seq padding" "seq -s, -w -2 19 120" "-02,017,036,055,074,093,112\n" \ +testing "separator and format string" "seq -f \%03g -s \; 5 -1 0" "005;004;003;002;001;000\n" "" "" +testing "padding" "seq -s, -w -2 19 120" "-02,017,036,055,074,093,112\n" \ "" "" -testing "seq padding" "seq -s, -w -2 3 12" "-2,01,04,07,10\n" "" "" -testing "seq padding" "seq -s, -w -2.2 3.3 12" "-2.2,01.1,04.4,07.7,11.0\n" \ +testing "padding" "seq -s, -w -2 3 12" "-2,01,04,07,10\n" "" "" +testing "padding" "seq -s, -w -2.2 3.3 12" "-2.2,01.1,04.4,07.7,11.0\n" \ "" "" # Test -f format filtering for i in %f %e %g "boo %f yah" "% f" %-1.2f %+-f "%+ - f" %.2f %3.f "%'.2f" \ %%%f%% do - testing "seq filter -f \"$i\"" "seq -f \"$i\" 1 3 > /dev/null && echo yes" \ + testing "filter -f \"$i\"" "seq -f \"$i\" 1 3 > /dev/null && echo yes" \ "yes\n" "" "" done # Test -f format filtering failures for i in %d %s "" "boo %f %f yah" "%*f" %-1.2.3f '%2$f' %1-f "%1 f" \ %2..2f %%%f%%% do - testing "seq filter reject -f '$i'" \ + testing "filter reject -f '$i'" \ "seq -f '$i' 1 3 2>/dev/null || echo no" "no\n" "" "" done diff --git a/tests/sha1sum.test b/tests/sha1sum.test index cd621fd1..b4d4b753 100755 --- a/tests/sha1sum.test +++ b/tests/sha1sum.test @@ -6,22 +6,22 @@ # These tests are based on RFC3174 which were based on FIPS PUB 180-1 -testing "sha1sum TEST1" \ +testing "TEST1" \ "sha1sum" \ "a9993e364706816aba3e25717850c26c9cd0d89d -\n" \ "" "abc" -testing "sha1sum TEST2" \ +testing "TEST2" \ "sha1sum" \ "84983e441c3bd26ebaae4aa1f95129e5e54670f1 -\n" \ "" "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" -testing "sha1sum TEST3" \ +testing "TEST3" \ 'dd if=/dev/zero bs=1000 count=1000 2>/dev/null | tr \\0 a | sha1sum' \ "34aa973cd4c4daa4f61eeb2bdbad27316534016f -\n" \ "" "" -testing "sha1sum TEST4" \ +testing "TEST4" \ 'for i in `seq 1 10`; do echo -n 0123456701234567012345670123456701234567012345670123456701234567 ; done | sha1sum' \ "dea356a2cddd90c7a7ecedc5ebb563934f460452 -\n" \ "" "" @@ -33,22 +33,22 @@ testing "sha1sum" \ "a9993e364706816aba3e25717850c26c9cd0d89d -\n" \ "" "abc" -testing "sha1sum -" \ +testing "-" \ "sha1sum -" \ "a9993e364706816aba3e25717850c26c9cd0d89d -\n" \ "" "abc" -testing "sha1sum file" \ +testing "file" \ "sha1sum file1" \ "a9993e364706816aba3e25717850c26c9cd0d89d file1\n" \ "" "" -testing "sha1sum file1 file2" \ +testing "file1 file2" \ "sha1sum file1 file2" \ "a9993e364706816aba3e25717850c26c9cd0d89d file1\n589c22335a381f122d129225f5c0ba3056ed5811 file2\n" \ "" "" -testing "sha1sum file1 file2 -" \ +testing "file1 file2 -" \ "sha1sum file1 file2 -" \ "a9993e364706816aba3e25717850c26c9cd0d89d file1\n589c22335a381f122d129225f5c0ba3056ed5811 file2\na9993e364706816aba3e25717850c26c9cd0d89d -\n" \ "" "abc" diff --git a/tests/sort.test b/tests/sort.test index 2845e79c..cda3db51 100755 --- a/tests/sort.test +++ b/tests/sort.test @@ -8,10 +8,10 @@ # The basic tests. These should work even with the small config. testing "sort" "sort input" "a\nb\nc\n" "c\na\nb\n" "" -testing "sort #2" "sort input" "010\n1\n3\n" "3\n1\n010\n" "" -testing "sort stdin" "sort" "a\nb\nc\n" "" "b\na\nc\n" -testing "sort numeric" "sort -n input" "1\n3\n010\n" "3\n1\n010\n" "" -testing "sort reverse" "sort -r input" "wook\nwalrus\npoint\npabst\naargh\n" \ +testing "#2" "sort input" "010\n1\n3\n" "3\n1\n010\n" "" +testing "stdin" "sort" "a\nb\nc\n" "" "b\na\nc\n" +testing "numeric" "sort -n input" "1\n3\n010\n" "3\n1\n010\n" "" +testing "reverse" "sort -r input" "wook\nwalrus\npoint\npabst\naargh\n" \ "point\nwook\npabst\naargh\nwalrus\n" "" # These tests require the full option set. @@ -29,7 +29,7 @@ egg 1 2 papyrus # Sorting with keys -testing "sort one key" "sort -k4,4 input" \ +testing "one key" "sort -k4,4 input" \ "999 3 0 algebra egg 1 2 papyrus 7 3 42 soup @@ -41,7 +41,7 @@ egg 1 2 papyrus # at the whitespace), then the global fallback sort does an alpha sort on # the whole string (starting at the beginning of the line). -testing "sort key range with numeric option" "sort -k2,3n input" \ +testing "key range with numeric option" "sort -k2,3n input" \ "42 1 010 zoology 42 1 3 woot egg 1 2 papyrus @@ -52,7 +52,7 @@ egg 1 2 papyrus # Numeric sort on field 2 (again, ignore field 3 because it's numeric), # then do a _reversed_ alpha sort on the whole line as a tiebreaker. -testing "sort key range with numeric option and global reverse" \ +testing "key range with numeric option and global reverse" \ "sort -k2,3n -r input" \ "egg 1 2 papyrus 42 1 3 woot @@ -64,7 +64,7 @@ testing "sort key range with numeric option and global reverse" \ # Reversed numeric sort on field 2 (numeric ignores field 3), then # break ties with alpha sort on whole line. -testing "sort key range with multiple options" "sort -k2,3rn input" \ +testing "key range with multiple options" "sort -k2,3rn input" \ "7 3 42 soup 999 3 0 algebra 42 1 010 zoology @@ -72,12 +72,12 @@ testing "sort key range with multiple options" "sort -k2,3rn input" \ egg 1 2 papyrus " "$data" "" -testing "sort key doesn't strip leading blanks, disables fallback global sort" \ +testing "key doesn't strip leading blanks, disables fallback global sort" \ "sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n" # Test case contributed by Joey Hess: -testing "sort key edge case with -t" "sort -n -k4 -t/" \ +testing "key edge case with -t" "sort -n -k4 -t/" \ "/usr/lib/finish-install.d/1 /usr/lib/finish-install.d/4 /usr/lib/prebaseconfig.d/2 @@ -88,7 +88,7 @@ testing "sort key edge case with -t" "sort -n -k4 -t/" \ /usr/lib/prebaseconfig.d/6 " -testing "sort -x" "sort -x" "010\na0\n 0c0\n" "" "a0\n010\n 0c0\n" +testing "-x" "sort -x" "010\na0\n 0c0\n" "" "a0\n010\n 0c0\n" # Test that -f applies to key or fallback independently @@ -99,7 +99,7 @@ testing "" "sort -f -k2,2" "A b b\na B C\na B a\n" "" "a B a\nA b b\na B C\n" optional SORT_FLOAT # not numbers < NaN < -infinity < numbers < +infinity -testing "sort -g" "sort -g" \ +testing "-g" "sort -g" \ "bork\nNaN\n-inf\n0.4\n1.222\n01.37\n2.1\n+infinity\n" "" \ "01.37\n1.222\n2.1\n0.4\nNaN\nbork\n-inf\n+infinity\n" diff --git a/tests/split.test b/tests/split.test index d86b0250..2a27c093 100755 --- a/tests/split.test +++ b/tests/split.test @@ -7,24 +7,24 @@ testing "split" "seq 1 12345 | split && ls xa[a-z] | wc -l" "13\n" "" "" rm xa[a-z] -testing "split -" "seq 1 12345 | split - && ls xa[a-z] | wc -l" "13\n" "" "" +testing "-" "seq 1 12345 | split - && ls xa[a-z] | wc -l" "13\n" "" "" rm xa[a-z] seq 1 12345 > file -testing "split file" "split file && ls xa[a-z] | wc -l" "13\n" "" "" +testing "file" "split file && ls xa[a-z] | wc -l" "13\n" "" "" rm xa[a-z] -testing "split -l" "split file -l 10k && wc -l xab" "2105 xab\n" "" "" +testing "-l" "split file -l 10k && wc -l xab" "2105 xab\n" "" "" rm xa[ab] -testing "split suffix exhaustion" \ +testing "suffix exhaustion" \ "split file -l 10 -a 1 walrus 2>/dev/null || ls walrus* | wc -l" "26\n" "" "" rm walrus* -testing "split bytes" \ +testing "bytes" \ "toybox seq 1 20000 | split -b 100 -a 3 - whang && ls whang* | wc -l && wc -c whangbpw" "1089\n94 whangbpw\n" "" "" -testing "split reassembly" \ +testing "reassembly" \ 'diff -u <(ls whang* | sort | xargs cat) <(seq 1 20000) && echo yes' \ "yes\n" "" "" diff --git a/tests/tac.test b/tests/tac.test index 96f25310..5c095b4b 100755 --- a/tests/tac.test +++ b/tests/tac.test @@ -8,19 +8,19 @@ echo -e "one-A\none-B" > file1 echo -e "two-A\ntwo-B" > file2 testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n" -testing "tac -" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n" -testing "tac file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n" "" "" -testing "tac - file" "tac - file1" "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n" -testing "tac file -" "tac file1 -" "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n" +testing "-" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n" +testing "file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n" "" "" +testing "- file" "tac - file1" "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n" +testing "file -" "tac file1 -" "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n" -testing "tac file1 notfound file2" \ +testing "file1 notfound file2" \ "tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \ "one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" "" -testing "tac no trailing newline" "tac -" "defabc\n" "" "abc\ndef" +testing "no trailing newline" "tac -" "defabc\n" "" "abc\ndef" # xputs used by tac does not propagate this error condition properly. -#testing "tac > /dev/full" \ +#testing "> /dev/full" \ # "tac - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \ # "tac: write: No space left on device\n" "" "zero\n" diff --git a/tests/tail.test b/tests/tail.test index f4b86673..b3d744aa 100755 --- a/tests/tail.test +++ b/tests/tail.test @@ -7,38 +7,38 @@ BIGTEST="one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" echo -ne "$BIGTEST" > file1 testing "tail" "tail && echo yes" "oneyes\n" "" "one" -testing "tail file" "tail file1" \ +testing "file" "tail file1" \ "two\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" "" "" -testing "tail -n in bounds" "tail -n 3 file1" "nine\nten\neleven\n" "" "" -testing "tail -n out of bounds" "tail -n 999 file1" "$BIGTEST" "" "" -testing "tail -n+ in bounds" "tail -n +3 file1" \ +testing "-n in bounds" "tail -n 3 file1" "nine\nten\neleven\n" "" "" +testing "-n out of bounds" "tail -n 999 file1" "$BIGTEST" "" "" +testing "-n+ in bounds" "tail -n +3 file1" \ "three\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" "" "" -testing "tail -n+ outof bounds" "tail -n +999 file1" "" "" "" -testing "tail -c in bounds" "tail -c 27 file1" \ +testing "-n+ outof bounds" "tail -n +999 file1" "" "" "" +testing "-c in bounds" "tail -c 27 file1" \ "even\neight\nnine\nten\neleven\n" "" "" -testing "tail -c out of bounds" "tail -c 999 file1" "$BIGTEST" "" "" -testing "tail -c+ in bounds" "tail -c +27 file1" \ +testing "-c out of bounds" "tail -c 999 file1" "$BIGTEST" "" "" +testing "-c+ in bounds" "tail -c +27 file1" \ "x\nseven\neight\nnine\nten\neleven\n" "" "" -testing "tail -c+ out of bonds" "tail -c +999 file1" "" "" "" +testing "-c+ out of bonds" "tail -c +999 file1" "" "" "" rm file1 -testing "tail stdin no trailing newline" "tail -n 1 - " "c" "" "a\nb\nc" -testing "tail file no trailing newline" "tail -n 1 input" "c" "a\nb\nc" "" +testing "stdin no trailing newline" "tail -n 1 - " "c" "" "a\nb\nc" +testing "file no trailing newline" "tail -n 1 input" "c" "a\nb\nc" "" optional TAIL_SEEK -testing "tail noseek -n in bounds" "tail -n 3" "nine\nten\neleven\n" \ +testing "noseek -n in bounds" "tail -n 3" "nine\nten\neleven\n" \ "" "$BIGTEST" -testing "tail noseek -n out of bounds" "tail -n 999" "$BIGTEST" "" "$BIGTEST" -testing "tail noseek -n+ in bounds" "tail -n +3" \ +testing "noseek -n out of bounds" "tail -n 999" "$BIGTEST" "" "$BIGTEST" +testing "noseek -n+ in bounds" "tail -n +3" \ "three\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" "" \ "$BIGTEST" -testing "tail noseek -n+ outof bounds" "tail -n +999" "" "" "$BIGTEST" -testing "tail noseek -c in bounds" "tail -c 27" \ +testing "noseek -n+ outof bounds" "tail -n +999" "" "" "$BIGTEST" +testing "noseek -c in bounds" "tail -c 27" \ "even\neight\nnine\nten\neleven\n" "" "$BIGTEST" -testing "tail noseek -c out of bounds" "tail -c 999" "$BIGTEST" "" "$BIGTEST" -testing "tail noseek -c+ in bounds" "tail -c +27" \ +testing "noseek -c out of bounds" "tail -c 999" "$BIGTEST" "" "$BIGTEST" +testing "noseek -c+ in bounds" "tail -c +27" \ "x\nseven\neight\nnine\nten\neleven\n" "" "$BIGTEST" -testing "tail noseek -c+ out of bonds" "tail -c +999" "" "" "$BIGTEST" +testing "noseek -c+ out of bonds" "tail -c +999" "" "" "$BIGTEST" makebigfile() { @@ -55,7 +55,7 @@ makebigfile() } makebigfile > bigfile -testing "tail -c 12345 -n 3 bigfile" "tail -c 12345 -n 3 bigfile | md5sum" \ +testing "-c 12345 -n 3 bigfile" "tail -c 12345 -n 3 bigfile | md5sum" \ "347bbdcbad8a313f4dc7bd558c5bfcb8 -\n" "" "" -testing "tail -n 3 -c 12345 bigfile" "tail -n 3 -c 12345 bigfile | md5sum" \ +testing "-n 3 -c 12345 bigfile" "tail -n 3 -c 12345 bigfile | md5sum" \ "1698825a750288284ec3ba7d8a59f302 -\n" "" "" diff --git a/tests/tar.test b/tests/tar.test index 034b7a3b..80ba5551 100755 --- a/tests/tar.test +++ b/tests/tar.test @@ -10,31 +10,31 @@ #Creating dir mkdir dir/dir1 -p echo "This is testdata" > dir/dir1/file -testing "tar tgz - compession, extraction and data validation" "tar -czf dir.tgz dir/ && [ -e dir.tgz ] && echo 'yes'; rm -rf dir; tar -xf dir.tgz && [ -f dir/dir1/file ] && cat dir/dir1/file; rm -rf dir.tgz" "yes\nThis is testdata\n" "" "" +testing "tgz - compession, extraction and data validation" "tar -czf dir.tgz dir/ && [ -e dir.tgz ] && echo 'yes'; rm -rf dir; tar -xf dir.tgz && [ -f dir/dir1/file ] && cat dir/dir1/file; rm -rf dir.tgz" "yes\nThis is testdata\n" "" "" #Creating dir mkdir dir/dir1 -p echo "This is testdata" > dir/dir1/file -testing "tar tar.gz - compession, extraction and data validation" "tar -czf dir.tar.gz dir/ && [ -e dir.tar.gz ] && echo 'yes'; rm -rf dir; tar -xf dir.tar.gz && [ -f dir/dir1/file ] && cat dir/dir1/file; rm -rf dir.tar.gz" "yes\nThis is testdata\n" "" "" +testing "tar.gz - compession, extraction and data validation" "tar -czf dir.tar.gz dir/ && [ -e dir.tar.gz ] && echo 'yes'; rm -rf dir; tar -xf dir.tar.gz && [ -f dir/dir1/file ] && cat dir/dir1/file; rm -rf dir.tar.gz" "yes\nThis is testdata\n" "" "" #Creating dir mkdir dir/dir1 -p echo "This is testdata" > dir/dir1/file -testing "tar verbose compression" "tar -cvzf dir.tgz dir/; rm -rf dir.tgz" "dir/\ndir/dir1/\ndir/dir1/file\n" "" "" +testing "verbose compression" "tar -cvzf dir.tgz dir/; rm -rf dir.tgz" "dir/\ndir/dir1/\ndir/dir1/file\n" "" "" rm -rf dir/ #creating test file dd if=/dev/zero of=testFile ibs=4096 obs=4096 count=1000 2>/dev/null -testing "tar - compession and extraction of a file" "tar -czf testFile.tgz testFile && [ -e testFile.tgz ] && echo 'yes'; rm -rf testFile; tar -xf testFile.tgz && [ -f testFile ] && echo 'yes'; rm -rf testFile.tgz" "yes\nyes\n" "" "" +testing "- compession and extraction of a file" "tar -czf testFile.tgz testFile && [ -e testFile.tgz ] && echo 'yes'; rm -rf testFile; tar -xf testFile.tgz && [ -f testFile ] && echo 'yes'; rm -rf testFile.tgz" "yes\nyes\n" "" "" #creating empty test file touch testFile -testing "tar - compession and extraction of a empty file" "tar -czf testFile.tgz testFile && [ -e testFile.tgz ] && echo 'yes'; rm -rf testFile; tar -xf testFile.tgz && [ -f testFile ] && echo 'yes'; rm -rf testFile.tgz" "yes\nyes\n" "" "" +testing "- compession and extraction of a empty file" "tar -czf testFile.tgz testFile && [ -e testFile.tgz ] && echo 'yes'; rm -rf testFile; tar -xf testFile.tgz && [ -f testFile ] && echo 'yes'; rm -rf testFile.tgz" "yes\nyes\n" "" "" #Creating dir mkdir dir/dir1 -p touch dir/dir1/file1 dir/dir1/file2 dir/dir1/file3 dir/dir1/file4 -testing "tar -t option" "tar -czf dir.tar.gz dir/; rm -rf dir; tar -tf dir.tar.gz | sort; rm -rf dir.tar.gz" "dir/\ndir/dir1/\ndir/dir1/file1\ndir/dir1/file2\ndir/dir1/file3\ndir/dir1/file4\n" "" "" +testing "-t option" "tar -czf dir.tar.gz dir/; rm -rf dir; tar -tf dir.tar.gz | sort; rm -rf dir.tar.gz" "dir/\ndir/dir1/\ndir/dir1/file1\ndir/dir1/file2\ndir/dir1/file3\ndir/dir1/file4\n" "" "" rm -rf dir/ #Creating nested directory @@ -42,20 +42,20 @@ mkdir -p dir/dir1 dir/dir2 dir/dir3 dir/dir4 echo "This is testdata" > dir/dir1/file; echo "Dont exclude me" > dir/dir3/file1 ; echo "Exclude me" > dir/dir3/file2 ; echo "YO" > dir/dir4/file1 ; echo "Hello" >dir/dir4/file2; echo "Dont" > dir/dir2/file1 echo -ne "dir/dir4\ndir/dir3/file2\n" > exclude_file -testing "tar create with files excluded : -X" "tar -czf dir.tgz dir/ -X exclude_file ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir3/file1\n" "" "" +testing "create with files excluded : -X" "tar -czf dir.tgz dir/ -X exclude_file ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir3/file1\n" "" "" rm -rf exclude_file #Creating nested directory mkdir dir/dir1 -p ; mkdir dir/dir2 ; mkdir dir/dir3 ; mkdir dir/dir4 echo "This is testdata" > dir/dir1/file echo "Dont exclude me" > dir/dir3/file1 ; echo "Exclude me" > dir/dir3/file2 ; echo "YO" > dir/dir4/file1 ; echo "Hello" >dir/dir4/file2; echo "Dont" > dir/dir2/file1 -testing "tar with pattern --exclude" "tar --exclude=dir/dir3/* -czf dir.tgz dir/ ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir4/\ndir/dir4/file1\ndir/dir4/file2\n" "" "" +testing "with pattern --exclude" "tar --exclude=dir/dir3/* -czf dir.tgz dir/ ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir4/\ndir/dir4/file1\ndir/dir4/file2\n" "" "" #Creating directory to be compressed mkdir dir/dir1 -p echo "This is testdata" > dir/dir1/file mkdir temp -testing "tar extract with -C Dir" "tar -czf dir.tgz dir/ ;rm -rf dir ;tar -xf dir.tgz -C temp/ ; [ -e temp/dir ] && echo 'yes' ; rm -rf dir dir.tgz" "yes\n" "" "" +testing "extract with -C Dir" "tar -czf dir.tgz dir/ ;rm -rf dir ;tar -xf dir.tgz -C temp/ ; [ -e temp/dir ] && echo 'yes' ; rm -rf dir dir.tgz" "yes\n" "" "" rm -rf temp #Creating nested directory @@ -63,28 +63,28 @@ mkdir dir/dir1 -p ; mkdir dir/dir2 ; mkdir dir/dir3 ; mkdir dir/dir4 ; mkdir t echo "dir1/file" > dir/dir1/file ; echo "temp_dir/file" > temp_dir/file echo "dir3/file1" > dir/dir3/file1 ; echo "dir3/file2" > dir/dir3/file2 ; echo "YO" > dir/dir4/file1 ; echo "Hello" >dir/dir4/file2; echo "dir2/file1" > dir/dir2/file1 echo "temp_dir/file" > exclude_file -testing "tar create with extra files/directory included : -T" "tar -czf dir.tgz dir/ -T exclude_file ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir3/file1\ndir/dir3/file2\ndir/dir4/\ndir/dir4/file1\ndir/dir4/file2\ntemp_dir/file\n" "" "" +testing "create with extra files/directory included : -T" "tar -czf dir.tgz dir/ -T exclude_file ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir3/file1\ndir/dir3/file2\ndir/dir4/\ndir/dir4/file1\ndir/dir4/file2\ntemp_dir/file\n" "" "" rm -rf exclude_file rm -rf temp_dir #Creating dir mkdir dir/dir1 -p echo "Inside dir/dir1" > dir/dir1/file ; echo "Hello Inside dir" > dir/file -testing "tar extract to STDOUT : -O" " tar -czf dir.tgz dir/ ; rm -rf dir ; tar -xf dir.tgz -O ; [ -e 'Inside dir/dir1/\nHello Inside dir\n' ] && echo 'yes'; rm -rf dir.tgz " "" "" "" +testing "extract to STDOUT : -O" " tar -czf dir.tgz dir/ ; rm -rf dir ; tar -xf dir.tgz -O ; [ -e 'Inside dir/dir1/\nHello Inside dir\n' ] && echo 'yes'; rm -rf dir.tgz " "" "" "" #Creating short filename f="filename_with_100_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" echo "This is testdata" > $f -testing "tar shortname filename" "tar -cf testFile.tar $f && [ -e testFile.tar ] && echo 'yes'; rm -f $f; tar -xf testFile.tar && [ -f $f ] && cat $f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -f $f" "yes\nThis is testdata\n" "" "" +testing "shortname filename" "tar -cf testFile.tar $f && [ -e testFile.tar ] && echo 'yes'; rm -f $f; tar -xf testFile.tar && [ -f $f ] && cat $f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -f $f" "yes\nThis is testdata\n" "" "" #Creating long filename f="filename_with_101_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" echo "This is testdata" > $f -testing "tar longname filename" "tar -cf testFile.tar $f && [ -e testFile.tar ] && echo 'yes'; rm -f $f; tar -xf testFile.tar && [ -f $f ] && cat $f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -f $f" "yes\nThis is testdata\nLongLink\n" "" "" +testing "longname filename" "tar -cf testFile.tar $f && [ -e testFile.tar ] && echo 'yes'; rm -f $f; tar -xf testFile.tar && [ -f $f ] && cat $f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -f $f" "yes\nThis is testdata\nLongLink\n" "" "" #Creating long pathname d="dirname_with_50_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxxx" f="filename_with_50_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxx" mkdir $d echo "This is testdata" > $d/$f -testing "tar longname pathname" "tar -cf testFile.tar $d/$f && [ -e testFile.tar ] && echo 'yes'; rm -rf $d; tar -xf testFile.tar && [ -f $d/$f ] && cat $d/$f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -rf $d" "yes\nThis is testdata\nLongLink\n" "" "" +testing "longname pathname" "tar -cf testFile.tar $d/$f && [ -e testFile.tar ] && echo 'yes'; rm -rf $d; tar -xf testFile.tar && [ -f $d/$f ] && cat $d/$f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -rf $d" "yes\nThis is testdata\nLongLink\n" "" "" diff --git a/tests/test.test b/tests/test.test index f5011573..40a90864 100755 --- a/tests/test.test +++ b/tests/test.test @@ -25,17 +25,17 @@ type_test() printf "%s" $result } -testing "test -b" "type_test -b" "" "" "" -testing "test -c" "type_test -c" "L" "" "" -testing "test -d" "type_test -d" "d" "" "" -testing "test -f" "type_test -f" "fs" "" "" -testing "test -h" "type_test -h" "L" "" "" -testing "test -L" "type_test -L" "L" "" "" -testing "test -s" "type_test -s" "ds" "" "" -testing "test -S" "type_test -S" "" "" "" -testing "test -p" "type_test -p" "p" "" "" -testing "test -e" "type_test -e" "dfLsp" "" "" -testing "test ! -e" "type_test ! -e" "n" "" "" +testing "-b" "type_test -b" "" "" "" +testing "-c" "type_test -c" "L" "" "" +testing "-d" "type_test -d" "d" "" "" +testing "-f" "type_test -f" "fs" "" "" +testing "-h" "type_test -h" "L" "" "" +testing "-L" "type_test -L" "L" "" "" +testing "-s" "type_test -s" "ds" "" "" +testing "-S" "type_test -S" "" "" "" +testing "-p" "type_test -p" "p" "" "" +testing "-e" "type_test -e" "dfLsp" "" "" +testing "! -e" "type_test ! -e" "n" "" "" rm f L s p rmdir d @@ -43,10 +43,10 @@ rmdir d # TODO: Test rwx gu t testing "test" "test "" || test a && echo yes" "yes\n" "" "" -testing "test -n" "test -n "" || test -n a && echo yes" "yes\n" "" "" -testing "test -z" "test -n a || test -n "" && echo yes" "yes\n" "" "" -testing "test a = b" "test a = b || test "" = "" && echo yes" "yes\n" "" "" -testing "test a != b" "test "" != "" || test a = b && echo yes" "yes\n" "" "" +testing "-n" "test -n "" || test -n a && echo yes" "yes\n" "" "" +testing "-z" "test -n a || test -n "" && echo yes" "yes\n" "" "" +testing "a = b" "test a = b || test "" = "" && echo yes" "yes\n" "" "" +testing "a != b" "test "" != "" || test a = b && echo yes" "yes\n" "" "" arith_test() { @@ -55,12 +55,12 @@ arith_test() test -3 $1 -5 && echo g } -testing "test -eq" "arith_test -eq" "e\n" "" "" -testing "test -ne" "arith_test -ne" "l\ng\n" "" "" -testing "test -gt" "arith_test -gt" "g\n" "" "" -testing "test -ge" "arith_test -ge" "e\ng\n" "" "" -testing "test -lt" "arith_test -lt" "l\n" "" "" -testing "test -le" "arith_test -le" "l\ne\n" "" "" +testing "-eq" "arith_test -eq" "e\n" "" "" +testing "-ne" "arith_test -ne" "l\ng\n" "" "" +testing "-gt" "arith_test -gt" "g\n" "" "" +testing "-ge" "arith_test -ge" "e\ng\n" "" "" +testing "-lt" "arith_test -lt" "l\n" "" "" +testing "-le" "arith_test -le" "l\ne\n" "" "" # test ! = -o a # test ! \( = -o a \) diff --git a/tests/test_human_readable.test b/tests/test_human_readable.test index 26ebd668..0f1bfb7a 100755 --- a/tests/test_human_readable.test +++ b/tests/test_human_readable.test @@ -4,16 +4,16 @@ #testing "name" "command" "result" "infile" "stdin" -testing "test_human_readable l 1024" "test_human_readable 123456789" "118M\n" "" "" -testing "test_human_readable l 1000" "test_human_readable -i 123456789" "123M\n" "" "" -testing "test_human_readable s 1024" "test_human_readable 5675" "5.5K\n" "" "" -testing "test_human_readable s 1000" "test_human_readable -i 5675" "5.6k\n" "" "" +testing "l 1024" "test_human_readable 123456789" "118M\n" "" "" +testing "l 1000" "test_human_readable -i 123456789" "123M\n" "" "" +testing "s 1024" "test_human_readable 5675" "5.5K\n" "" "" +testing "s 1000" "test_human_readable -i 5675" "5.6k\n" "" "" # An example input where we give a better result than coreutils. # 267350/1024=261.08. We say 261K and coreutils says 262K. testing "test_human_readable" "test_human_readable 267350" "261K\n" "" "" -testing "test_human_readable -b" "test_human_readable -b 123" "123B\n" "" "" -testing "test_human_readable -b" "test_human_readable -b 123456789" "118M\n" "" "" -testing "test_human_readable -s" "test_human_readable -s 123456789" "118 M\n" "" "" -testing "test_human_readable -bs" "test_human_readable -bs 123456789" "118 M\n" "" "" +testing "-b" "test_human_readable -b 123" "123B\n" "" "" +testing "-b" "test_human_readable -b 123456789" "118M\n" "" "" +testing "-s" "test_human_readable -s 123456789" "118 M\n" "" "" +testing "-bs" "test_human_readable -bs 123456789" "118 M\n" "" "" diff --git a/tests/touch.test b/tests/touch.test index d6430d0d..d386156d 100755 --- a/tests/touch.test +++ b/tests/touch.test @@ -5,26 +5,26 @@ #testing "name" "command" "result" "infile" "stdin" testing "touch" "touch walrus && [ -e walrus ] && echo yes" "yes\n" "" "" -testing "touch 1 2 3" "touch one two three && rm one two three && echo yes" "yes\n" \ +testing "1 2 3" "touch one two three && rm one two three && echo yes" "yes\n" \ "" "" -testing "touch -c" "touch -c walrus && [ -e walrus ] && echo yes" "yes\n" "" "" -testing "touch -c missing" "touch -c warrus && [ ! -e warrus ] && echo yes" \ +testing "-c" "touch -c walrus && [ -e walrus ] && echo yes" "yes\n" "" "" +testing "-c missing" "touch -c warrus && [ ! -e warrus ] && echo yes" \ "yes\n" "" "" -testing "touch -d" \ +testing "-d" \ "touch -d 2009-02-13T23:31:30Z walrus && date -r walrus +%s" \ "1234567890\n" "" "" -testing "touch -d nanoseconds" \ +testing "-d nanoseconds" \ "touch -d 2009-02-13T23:31:30.123456789Z walrus && date -r walrus +%s.%N" \ "1234567890.123456789\n" "" "" -testing "touch -r" \ +testing "-r" \ "touch -r walrus walrus2 && date -r walrus2 +%s.%N" \ "1234567890.123456789\n" "" "" -#testing "touch -a" -#testing "touch -m" -#testing "touch -am" -#testing "touch -t" +#testing "-a" +#testing "-m" +#testing "-am" +#testing "-t" rm walrus walrus2 diff --git a/tests/truncate.test b/tests/truncate.test index ee2b2bb8..1d19aa1b 100755 --- a/tests/truncate.test +++ b/tests/truncate.test @@ -5,24 +5,24 @@ #testing "name" "command" "result" "infile" "stdin" SIZE='&& stat -c %s freep' -testing "truncate 0" "truncate -s 0 freep $SIZE" "0\n" "" "" -testing "truncate 12345" "truncate -s 12345 freep $SIZE" "12345\n" "" "" -testing "truncate 1m" "truncate -s 1m freep $SIZE" "1048576\n" "" "" -testing "truncate is sparse" "truncate -s 1g freep && stat -c %b freep" \ +testing "0" "truncate -s 0 freep $SIZE" "0\n" "" "" +testing "12345" "truncate -s 12345 freep $SIZE" "12345\n" "" "" +testing "1m" "truncate -s 1m freep $SIZE" "1048576\n" "" "" +testing "is sparse" "truncate -s 1g freep && stat -c %b freep" \ "0\n" "" "" -testing "truncate +" "truncate -s 1k freep && truncate -s +1k freep $SIZE" \ +testing "+" "truncate -s 1k freep && truncate -s +1k freep $SIZE" \ "2048\n" "" "" -testing "truncate -" "truncate -s 4k freep && truncate -s -1k freep $SIZE" \ +testing "-" "truncate -s 4k freep && truncate -s -1k freep $SIZE" \ "3072\n" "" "" -testing "truncate < hit" \ +testing "< hit" \ "truncate -s 5k freep && truncate -s \<4k freep $SIZE" "4096\n" "" "" -testing "truncate < miss" \ +testing "< miss" \ "truncate -s 4k freep && truncate -s \<6k freep $SIZE" "4096\n" "" "" -testing "truncate > hit" \ +testing "> hit" \ "truncate -s 3k freep && truncate -s \>4k freep $SIZE" "4096\n" "" "" -testing "truncate > miss" \ +testing "> miss" \ "truncate -s 4k freep && truncate -s \>2k freep $SIZE" "4096\n" "" "" -testing "truncate /" "truncate -s 7k freep && truncate -s /3k freep $SIZE" \ +testing "/" "truncate -s 7k freep && truncate -s /3k freep $SIZE" \ "6144\n" "" "" -testing "truncate %" "truncate -s 7k freep && truncate -s %3k freep $SIZE" \ +testing "%" "truncate -s 7k freep && truncate -s %3k freep $SIZE" \ "9216\n" "" "" diff --git a/tests/useradd.test b/tests/useradd.test index 90b65019..d0b68ee6 100755 --- a/tests/useradd.test +++ b/tests/useradd.test @@ -21,83 +21,83 @@ arg="&>/dev/null" pass=`echo -ne 'password\npassword\n'` user="toyTestUser" -testing "useradd (text)" "useradd $user $arg || +testing "(text)" "useradd $user $arg || grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg user="toy1Test2User3" -testing "useradd (alphanumeric)" "useradd $user $arg || +testing "(alphanumeric)" "useradd $user $arg || grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg user="987654321" -testing "useradd (numeric)" "useradd $user $arg || +testing "(numeric)" "useradd $user $arg || grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg user="toy.1Test-2User_3" -testing "useradd (with ./-/_)" "useradd $user $arg || +testing "(with ./-/_)" "useradd $user $arg || grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg # 70 characters long string; hereafter, we will use it as per our need. user="abcdefghijklmnopqrstuvwxyz123456789abcdefghijklmnopqrstuvwxyz123456789" -testing "useradd (long string)" "useradd $user $arg || +testing "(long string)" "useradd $user $arg || grep '^$user:' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg user="toyTestUser" -testing "useradd dir" "useradd -h $PWD/dir $user $arg || +testing "dir" "useradd -h $PWD/dir $user $arg || grep '^$user:.*dir' /etc/passwd $arg && [ -d $PWD/dir ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg rm -rf $PWD/dir gecos="aaa,bbb,ccc,ddd,eee" -testing "useradd gecos" "useradd -g '$gecos' $user $arg || +testing "gecos" "useradd -g '$gecos' $user $arg || grep '^$user:.*$gecos' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg shl="/bin/sh" -testing "useradd shell" "useradd -s $shl $user $arg || +testing "shell" "useradd -s $shl $user $arg || grep '^$user:.*$shl$' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg g_name="root" g_id=`grep $g_name':.*:.*' /etc/group | cut -d : -f 3` -testing "useradd group" "useradd -G $g_name $user $arg || +testing "group" "useradd -G $g_name $user $arg || grep '^$user:.*:.*:$g_id:.*' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg -testing "useradd (system user)" "useradd -S $user $arg || +testing "(system user)" "useradd -S $user $arg || grep '^$user:.*:.*:.*' /etc/passwd $arg && [ ! -e /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg -testing "useradd -D" "useradd -D $user $arg || +testing "-D" "useradd -D $user $arg || grep '^$user:.*:.*:.*' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg -testing "useradd -H" "useradd -H $user $arg || +testing "-H" "useradd -H $user $arg || grep '^$user:.*:.*:.*' /etc/passwd $arg && [ ! -e /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg -testing "useradd dir and -H" "useradd -H -h $PWD/dir $user $arg || +testing "dir and -H" "useradd -H -h $PWD/dir $user $arg || grep '^$user:.*dir' /etc/passwd $arg && [ ! -e $PWD/dir ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg -testing "useradd -u" "useradd -u 49999 $user $arg || +testing "-u" "useradd -u 49999 $user $arg || grep '^$user:x:49999:.*' /etc/passwd $arg && [ -d /home/$user ] && echo 'yes'" "yes\n" "" "$pass" userdel -r $user $arg diff --git a/tests/uudecode.test b/tests/uudecode.test index b9d7d012..2c3bba6a 100755 --- a/tests/uudecode.test +++ b/tests/uudecode.test @@ -4,24 +4,24 @@ #testing "name" "command" "result" "infile" "stdin" -testing "uudecode uu empty file" "uudecode -o /dev/stdout && echo yes" \ +testing "uu empty file" "uudecode -o /dev/stdout && echo yes" \ "yes\n" "" "begin 744 test\n\`\nend\n" -testing "uudecode uu 1-char" "uudecode -o /dev/stdout" "a" "" \ +testing "uu 1-char" "uudecode -o /dev/stdout" "a" "" \ "begin 744 test\n!80 \n\`\nend\n" -testing "uudecode uu 2-char" "uudecode -o /dev/stdout" "ab" "" \ +testing "uu 2-char" "uudecode -o /dev/stdout" "ab" "" \ "begin 744 test\n\"86( \n\`\nend\n" -testing "uudecode uu 3-char" "uudecode -o /dev/stdout" "abc" "" \ +testing "uu 3-char" "uudecode -o /dev/stdout" "abc" "" \ "begin 744 test\n#86)C\n\`\nend\n" -testing "uudecode b64 empty file" "uudecode -o /dev/stdout && echo yes" \ +testing "b64 empty file" "uudecode -o /dev/stdout && echo yes" \ "yes\n" "" "begin-base64 744 test\n====\n" -testing "uudecode b64 1-char" "uudecode -o /dev/stdout" "a" "" \ +testing "b64 1-char" "uudecode -o /dev/stdout" "a" "" \ "begin-base64 744 test\nYQ==\n====\n" -testing "uudecode b64 2-char" "uudecode -o /dev/stdout" "ab" "" \ +testing "b64 2-char" "uudecode -o /dev/stdout" "ab" "" \ "begin-base64 744 test\nYWI=\n====\n" -testing "uudecode b64 3-char" "uudecode -o /dev/stdout" "abc" "" \ +testing "b64 3-char" "uudecode -o /dev/stdout" "abc" "" \ "begin-base64 744 test\nYWJj\n====\n" -testing "uudecode filename" "uudecode && echo -ne 'abc' | cmp uudecode-fn-test /dev/stdin && echo -ne yes && rm uudecode-fn-test" \ +testing "filename" "uudecode && echo -ne 'abc' | cmp uudecode-fn-test /dev/stdin && echo -ne yes && rm uudecode-fn-test" \ "yes" "" "begin-base64 744 uudecode-fn-test\nYWJj\n====\n" diff --git a/tests/uuencode.test b/tests/uuencode.test index 7c19faa3..b2a61dc1 100755 --- a/tests/uuencode.test +++ b/tests/uuencode.test @@ -4,23 +4,23 @@ #testing "name" "command" "result" "infile" "stdin" -testing "uuencode not enough args [fail]" "uuencode 2>/dev/null" "" "" "" +testing "not enough args [fail]" "uuencode 2>/dev/null" "" "" "" -testing "uuencode uu empty file" "uuencode test" \ +testing "uu empty file" "uuencode test" \ "begin 744 test\nend\n" "" "" -testing "uuencode uu 1-char" "uuencode test" \ +testing "uu 1-char" "uuencode test" \ "begin 744 test\n!80\`\`\nend\n" "" "a" -testing "uuencode uu 2-char" "uuencode test" \ +testing "uu 2-char" "uuencode test" \ "begin 744 test\n\"86(\`\nend\n" "" "ab" -testing "uuencode uu 3-char" "uuencode test" \ +testing "uu 3-char" "uuencode test" \ "begin 744 test\n#86)C\nend\n" "" "abc" -testing "uuencode b64 empty file" "uuencode -m test" \ +testing "b64 empty file" "uuencode -m test" \ "begin-base64 744 test\n====\n" "" "" -testing "uuencode b64 1-char" "uuencode -m test" \ +testing "b64 1-char" "uuencode -m test" \ "begin-base64 744 test\nYQ==\n====\n" "" "a" -testing "uuencode b64 2-char" "uuencode -m test" \ +testing "b64 2-char" "uuencode -m test" \ "begin-base64 744 test\nYWI=\n====\n" "" "ab" -testing "uuencode b64 3-char" "uuencode -m test" \ +testing "b64 3-char" "uuencode -m test" \ "begin-base64 744 test\nYWJj\n====\n" "" "abc" diff --git a/tests/wc.test b/tests/wc.test index 40891323..abb237e8 100755 --- a/tests/wc.test +++ b/tests/wc.test @@ -12,13 +12,13 @@ lines EOF testing "wc" "wc >/dev/null && echo yes" "yes\n" "" "" -testing "wc empty file" "wc" "0 0 0\n" "" "" -testing "wc standard input" "wc" "1 3 5\n" "" "a b\nc" -testing "wc -c" "wc -c file1" "26 file1\n" "" "" -testing "wc -l" "wc -l file1" "4 file1\n" "" "" -testing "wc -w" "wc -w file1" "5 file1\n" "" "" -testing "wc format" "wc file1" "4 5 26 file1\n" "" "" -testing "wc multiple files" "wc input - file1" \ +testing "empty file" "wc" "0 0 0\n" "" "" +testing "standard input" "wc" "1 3 5\n" "" "a b\nc" +testing "-c" "wc -c file1" "26 file1\n" "" "" +testing "-l" "wc -l file1" "4 file1\n" "" "" +testing "-w" "wc -w file1" "5 file1\n" "" "" +testing "format" "wc file1" "4 5 26 file1\n" "" "" +testing "multiple files" "wc input - file1" \ "1 2 3 input\n0 2 3 -\n4 5 26 file1\n5 9 32 total\n" "a\nb" "a b" optional TOYBOX_I18N @@ -32,14 +32,14 @@ for i in $(seq 1 8192) do printf "ü" >> file1 done -testing "wc -m" "wc -m file1" "8193 file1\n" "" "" +testing "-m" "wc -m file1" "8193 file1\n" "" "" printf " " > file1 for i in $(seq 1 8192) do printf "ü" >> file1 done -testing "wc -m (invalid chars)" "wc -m file1" "8193 file1\n" "" "" -testing "wc -mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" "" +testing "-m (invalid chars)" "wc -m file1" "8193 file1\n" "" "" +testing "-mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" "" else printf "skipping tests for wc -m" diff --git a/tests/xargs.test b/tests/xargs.test index e49445d6..c99de403 100755 --- a/tests/xargs.test +++ b/tests/xargs.test @@ -5,31 +5,31 @@ #testing "name" "command" "result" "infile" "stdin" testing "xargs" "xargs && echo yes" "hello\nyes\n" "" "hello" -testing "xargs spaces" "xargs" \ +testing "spaces" "xargs" \ "one two three four\n" "" "one two\tthree \nfour\n\n" -testing "xargs -n 0" "xargs -n 0 2>/dev/null || echo ok" "ok\n" \ +testing "-n 0" "xargs -n 0 2>/dev/null || echo ok" "ok\n" \ "" "one \ntwo\n three" -testing "xargs -n 2" "xargs -n 2" "one two\nthree\n" "" "one \ntwo\n three" -testing "xargs -n exact match" "xargs -n 3" "one two three\n" "" "one two three" +testing "-n 2" "xargs -n 2" "one two\nthree\n" "" "one \ntwo\n three" +testing "-n exact match" "xargs -n 3" "one two three\n" "" "one two three" testing "xargs2" "xargs -n2" "one two\nthree four\nfive\n" "" \ "one two three four five" -testing "xargs -s too long" "xargs -s 9 echo 2>/dev/null || echo ok" \ +testing "-s too long" "xargs -s 9 echo 2>/dev/null || echo ok" \ "one\ntwo\nok\n" "" "one two three" -testing "xargs -s 13" "xargs -s 13 echo" "one two\nthree\n" "" "one \ntwo\n three" -testing "xargs -s 12" "xargs -s 12 echo" "one\ntwo\nthree\n" "" "one \ntwo\n three" +testing "-s 13" "xargs -s 13 echo" "one two\nthree\n" "" "one \ntwo\n three" +testing "-s 12" "xargs -s 12 echo" "one\ntwo\nthree\n" "" "one \ntwo\n three" touch one two three -testing "xargs command -opt" "xargs -n2 ls -1" "one\ntwo\nthree\n" "" \ +testing "command -opt" "xargs -n2 ls -1" "one\ntwo\nthree\n" "" \ "one two three" rm one two three exit -testing "xargs -n exact match" -testing "xargs -s exact match" -testing "xargs -s 0" -testing "xargs -s impossible" +testing "-n exact match" +testing "-s exact match" +testing "-s 0" +testing "-s impossible" # xargs command_not_found - returns 127 # xargs false - returns 1 diff --git a/tests/xxd.test b/tests/xxd.test index 68f52be4..187bda51 100644 --- a/tests/xxd.test +++ b/tests/xxd.test @@ -9,38 +9,38 @@ echo -n > file2 # Note that the xxd in vim-common on Ubuntu 14 uses %07x for the file offset. -testing "xxd file1" "xxd file1" \ +testing "file1" "xxd file1" \ "00000000: 7468 6973 2069 7320 736f 6d65 2074 6578 this is some tex\n00000010: 740a t.\n" \ "" "" -testing "xxd file1 -l" "xxd -l 2 file1" \ +testing "file1 -l" "xxd -l 2 file1" \ "00000000: 7468 th\n" \ "" "" -testing "xxd file2" "xxd file2" "" "" "" -testing "xxd -" "xxd -" \ +testing "file2" "xxd file2" "" "" "" +testing "-" "xxd -" \ "00000000: 6865 6c6c 6f hello\n" "" "hello" testing "xxd" "xxd" \ "00000000: 776f 726c 64 world\n" "" "world" -testing "xxd -c 8 -g 4 file1" "xxd -c 8 -g 4 file1" \ +testing "-c 8 -g 4 file1" "xxd -c 8 -g 4 file1" \ "00000000: 74686973 20697320 this is \n00000008: 736f6d65 20746578 some tex\n00000010: 740a t.\n" "" "" -testing "xxd -c 8 -g 3 file1" "xxd -c 8 -g 3 file1" \ +testing "-c 8 -g 3 file1" "xxd -c 8 -g 3 file1" \ "00000000: 746869 732069 7320 this is \n00000008: 736f6d 652074 6578 some tex\n00000010: 740a t.\n" "" "" -testing "xxd -p" "xxd -p file1" "7468697320697320736f6d6520746578740a\n" "" "" +testing "-p" "xxd -p file1" "7468697320697320736f6d6520746578740a\n" "" "" -testing "xxd -r" "xxd file1 | xxd -r" "this is some text\n" "" "" -testing "xxd -r -p" "xxd -p file1 | xxd -r -p" "this is some text\n" "" "" +testing "-r" "xxd file1 | xxd -r" "this is some text\n" "" "" +testing "-r -p" "xxd -p file1 | xxd -r -p" "this is some text\n" "" "" -testing "xxd -r garbage" "echo '0000: 68 65 6c6c 6fxxxx' | xxd -r -" "hello" "" "" +testing "-r garbage" "echo '0000: 68 65 6c6c 6fxxxx' | xxd -r -" "hello" "" "" # -r will only read -c bytes (default 16) before skipping to the next line, # ignoring the rest. -testing "xxd -r long" \ +testing "-r long" \ "echo '0000: 40404040404040404040404040404040404040404040404040404040404040404040404040404040' | xxd -r -" \ "@@@@@@@@@@@@@@@@" "" "" # -r -p ignores the usual -p 30-byte/line limit (or any limit set by -c) and # will take as many bytes as you give it. -testing "xxd -r -p long" \ +testing "-r -p long" \ "echo '40404040404040404040404040404040404040404040404040404040404040404040404040404040' | xxd -r -p -" \ "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" "" "" diff --git a/tests/xzcat.test b/tests/xzcat.test index e82ca881..4aaf35f9 100755 --- a/tests/xzcat.test +++ b/tests/xzcat.test @@ -11,7 +11,7 @@ tar -cJf file.xz file # Get system xzcat xzcatExe=`which xzcat` $xzcatExe file.xz > xzcatOut -testing "xzcat - decompresses a single file" "xzcat file.xz > Tempfile && echo "yes"; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile" "yes\nyes\n" "" "" +testing "- decompresses a single file" "xzcat file.xz > Tempfile && echo "yes"; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile" "yes\nyes\n" "" "" #testing "name" "command" "result" "infile" "stdin" echo "hello" > file1 @@ -23,4 +23,4 @@ tar -cJf file3.xz file3 # Get system xzcat xzcatExe=`which xzcat` $xzcatExe file1.xz file2.xz file3.xz > xzcatOut -testing "xzcat - decompresses multiple files" "xzcat file1.xz file2.xz file3.xz > Tempfile && echo "yes" ; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile " "yes\nyes\n" "" "" +testing "- decompresses multiple files" "xzcat file1.xz file2.xz file3.xz > Tempfile && echo "yes" ; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile " "yes\nyes\n" "" "" diff --git a/tests/zcat.test b/tests/zcat.test index c1297c91..ccd472cd 100755 --- a/tests/zcat.test +++ b/tests/zcat.test @@ -11,7 +11,7 @@ tar -czf file.gz file # Get system zcat zcatExe=`which zcat` $zcatExe file.gz > zcatOut -testing "zcat - decompresses a single file" "zcat file.gz > Tempfile && echo "yes"; diff Tempfile zcatOut && echo "yes"; rm -rf file* zcatOut Tempfile" "yes\nyes\n" "" "" +testing "- decompresses a single file" "zcat file.gz > Tempfile && echo "yes"; diff Tempfile zcatOut && echo "yes"; rm -rf file* zcatOut Tempfile" "yes\nyes\n" "" "" #testing "name" "command" "result" "infile" "stdin" echo "hello" > file1 @@ -23,4 +23,4 @@ tar -czf file3.gz file3 # Get system zcat zcatExe=`which zcat` $zcatExe file1.gz file2.gz file3.gz > zcatOut -testing "zcat - decompresses multiple files" "zcat file1.gz file2.gz file3.gz > Tempfile && echo "yes" ; diff Tempfile zcatOut && echo "yes"; rm -rf file* zcatOut Tempfile " "yes\nyes\n" "" "" +testing "- decompresses multiple files" "zcat file1.gz file2.gz file3.gz > Tempfile && echo "yes" ; diff Tempfile zcatOut && echo "yes"; rm -rf file* zcatOut Tempfile " "yes\nyes\n" "" "" |