From a0f56beaf63052179c69fb258478f851ef1e5ca2 Mon Sep 17 00:00:00 2001 From: Divya Kothari Date: Thu, 26 Jun 2014 07:25:20 -0500 Subject: I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice. --- scripts/test/dd.test | 83 +++++++++++++++++++++++++++++++++++ scripts/test/ln.test | 70 ++++++++++++++++++++++++++++++ scripts/test/ls.test | 49 +++++++++++++++++++++ scripts/test/mv.test | 98 +++++++++++++++++++++++++++++++++++++++++ scripts/test/printf.test | 29 +++++++++++++ scripts/test/renice.test | 110 +++++++++++++++++++++++++++++++++++++++++++++++ scripts/test/rm.test | 46 ++++++++++++++++++++ 7 files changed, 485 insertions(+) create mode 100644 scripts/test/dd.test create mode 100644 scripts/test/ln.test create mode 100644 scripts/test/ls.test create mode 100644 scripts/test/mv.test create mode 100644 scripts/test/printf.test create mode 100644 scripts/test/renice.test create mode 100644 scripts/test/rm.test (limited to 'scripts/test') diff --git a/scripts/test/dd.test b/scripts/test/dd.test new file mode 100644 index 00000000..9bdcac5b --- /dev/null +++ b/scripts/test/dd.test @@ -0,0 +1,83 @@ +#!/bin/bash + +# Copyright 2013 Robin Mittal +# Copyright 2013 Divya Kothari + +[ -f testing.sh ] && . testing.sh + +# 'dd' command, stderr prints redirecting to /dev/null +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" \ + "I WANT\n" "I WANT\n" "" +testing "dd 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" \ + "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)" \ + "dd if=input of=/dev/null $opt && echo 'yes'" "yes\n" "I WANT\n" "" +testing "dd 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" \ + "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" \ + "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" "" +unlink softlink + +ln -s file softlink +testing "dd 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 && + [ -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" \ + "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" \ + "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 "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 "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" "" + +# 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" \ + "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" \ + "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" \ + "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" \ + "I WANT\n" "" diff --git a/scripts/test/ln.test b/scripts/test/ln.test new file mode 100644 index 00000000..aea3ab04 --- /dev/null +++ b/scripts/test/ln.test @@ -0,0 +1,70 @@ +#!/bin/bash + +# Copyright 2013 Robin Mittal +# Copyright 2013 Divya Kothari + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" +#set -x + +echo file1 > file +testing "ln create_hardlink" "ln file hlink && [ file -ef hlink ] && + echo 'yes'" "yes\n" "" "" +testing "ln 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 && + [ file -ef hlink ] && cat hlink 2>/dev/null" "file1\n" "" "" + +echo slink1 > slink +testing "ln 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'" \ + "yes\n" "" "" + +echo slink1 > slink +set +e +testing "ln 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 && + 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 && + 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/ && + [ 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/ && + [ -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 && + [ -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 && + [ file -ef hlink ] && rm file && [ -f hlink ] && echo 'yes'" \ + "yes\n" "" "" +rm -f file hlink diff --git a/scripts/test/ls.test b/scripts/test/ls.test new file mode 100644 index 00000000..d052f13a --- /dev/null +++ b/scripts/test/ls.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright 2013 Robin Mittal +# Copyright 2013 Divya Kothari + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" +#set -x + +# Creating test-file/dir for testing ls +mkdir -p lstest/dir1 lstest/dir2 || exit 1 +echo "test file1" > lstest/file1.txt +echo "test file2" > lstest/file2.txt +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" \ + ".\n..\ndir1\ndir2\nfile1.txt\nfile2.txt\n.hfile1\n" "" "" +testing "ls 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" "" "" + +ln -s file1.txt lstest/slink +testing "ls softlink - long listing" "$IN && ls -l slink | awk '{ print \$NF }' ; $OUT" \ + "file1.txt\n" "" "" +rm -f lstest/slink + +rm -rf lstest/* && mkdir -p lstest/dir1 && touch lstest/file1.txt +testing "ls 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" "" "" +unset INODE + +# Removing test dir for cleanup purpose +rm -rf lstest diff --git a/scripts/test/mv.test b/scripts/test/mv.test new file mode 100644 index 00000000..53fc9992 --- /dev/null +++ b/scripts/test/mv.test @@ -0,0 +1,98 @@ +#!/bin/bash + +# Copyright 2013 Robin Mittal +# Copyright 2013 Divya Kothari + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +touch file +testing "Move 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 "Move file to a dir" "mv file dir && [ ! -e file -a -f dir/file ] && + echo 'yes'" "yes\n" "" "" +rm -rf file* dir* + +mkdir dir +testing "Move 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 "Move 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 "Move 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 "Move 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 "Move 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 "Move 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 "Move 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 "Move 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 "Move 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 "Move 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 "Move 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 "Move -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 "Move -n file new_file (exist)" "mv -n file1 file2 && + [ -e file1 -a -e file2 ] && echo 'yes'" "yes\n" "" "" +rm -f file* diff --git a/scripts/test/printf.test b/scripts/test/printf.test new file mode 100644 index 00000000..96789bd0 --- /dev/null +++ b/scripts/test/printf.test @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright 2013 Robin Mittal +# Copyright 2013 Divya Kothari + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" +#set -x + +testing "printf TEXT" "printf toyTestText" "toyTestText" "" "" +testing "printf MULTILINE_TEXT" \ + "printf 'Testing\nmultiline\ntext\nfrom\ntoybox\tcommand.\b'" \ + "Testing\nmultiline\ntext\nfrom\ntoybox\tcommand.\b" "" "" +testing "printf '%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" \ + "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" \ + "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" "" "" diff --git a/scripts/test/renice.test b/scripts/test/renice.test new file mode 100644 index 00000000..e87111cc --- /dev/null +++ b/scripts/test/renice.test @@ -0,0 +1,110 @@ +#!/bin/bash + +# Copyright 2013 Robin Mittal +# Copyright 2013 Divya Kothari + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +fun_nice_val() +{ + for each_proc in $@ + do + echo `awk '{ print $18 }' /proc/${each_proc}/stat` + done +} + +# creating processes as a test data +yes >/dev/null & +proc1=$! +yes >/dev/null & +proc2=$! +yes >/dev/null & +proc3=$! +yes >/dev/null & +proc4=$! +yes >/dev/null & +proc5=$! + +n_val1=`fun_nice_val $proc1` +n_val2=`fun_nice_val $proc2` +n_val3=`fun_nice_val $proc3` +n_val4=`fun_nice_val $proc4` +n_val5=`fun_nice_val $proc5` + +# Redirecting errors to /dev/null +arg="2>/dev/null" + +for n_v in "-1" "1" +do + for n_o in "" " -p" + do + nice_val1=$((`fun_nice_val $proc1` + $n_v)) + nice_val2=$((`fun_nice_val $proc2` + $n_v)) + 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" \ + "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" "" "" + + nice_val1=$((`fun_nice_val $proc1` + $n_v)) + nice_val2=$((`fun_nice_val $proc2` + $n_v)) + 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)" \ + "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" "" "" + done +done + +# Starting Boundary Test Here .. +loop_cnt=2 +echo -n "TEST: Boundary value test for Id($proc1)..[old_nice_val/new_nice_val]:" +cnt=0 +n_val=1 +while [ $cnt -gt -1 ] +do + old_nice_val=`fun_nice_val $proc1` + new_nice_val=`renice -n $n_val $proc1 >/dev/null 2>&1 && fun_nice_val $proc1` + echo -n "[$old_nice_val/$new_nice_val]," + if [ $old_nice_val -eq 39 -a $old_nice_val -eq $new_nice_val ] + then + echo -n " [Equals 39,doing -1] " + n_val="-1" + elif [ $old_nice_val -eq 0 -a $old_nice_val -eq $new_nice_val ] + then + echo -n " [Equals 0,doing +1] " + n_val="1" + elif [ $new_nice_val -gt 39 -o $new_nice_val -lt 0 ] + then + echo " [Test Fail] " + echo "FAIL: renice with step 1 ($proc1) (boundary value)" + cnt="-1" + elif [ $new_nice_val -eq $n_val1 -a $new_nice_val -eq $(($old_nice_val+1)) ] + then + cnt=$(($cnt + 1)) + if [ $cnt -eq $loop_cnt ] + then + echo " [Test Pass] " + echo "PASS: renice with step 1 ($proc1) (boundary value)" + cnt="-1" + fi + else + dif=`echo $(($new_nice_val-$old_nice_val))` + dif=`echo ${dif/-}` + if [ $dif -ne 1 ] + then + echo " [Test Fail] " + echo "FAIL: renice with step 1 ($proc1) (boundary value)" + cnt="-1" + fi + fi +done +# Boundary test End + +killall yes >/dev/null 2>&1 diff --git a/scripts/test/rm.test b/scripts/test/rm.test new file mode 100644 index 00000000..0dca8538 --- /dev/null +++ b/scripts/test/rm.test @@ -0,0 +1,46 @@ +#!/bin/bash + +# Copyright 2013 Robin Mittal +# Copyright 2013 Divya Kothari + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +echo "abcdefghijklmnopqrstuvwxyz" > file.txt +testing "Remove text-file" "rm file.txt && [ ! -e file.txt ] && echo 'yes'" "yes\n" "" "" +rm -f file* + +mkdir dir +testing "Remove empty directory" "rm -r dir && [ ! -d dir ] && echo 'yes'" "yes\n" "" "" +rm -rf dir + +echo "abcdefghijklmnopqrstuvwxyz" > file.txt && chmod 000 file.txt +testing "Remove 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)" \ + "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" "" "" +rm -rf file* dir* + +touch file1.txt file2.txt +mkdir dir1 dir2 +testing "rm -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" "" "" +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 && + [ -d dir1 -a -f dir1/file1.txt -a ! -d dir1/dir2 ] && echo 'yes'" \ + "yes\n" "" "" +rm -rf dir* + -- cgit v1.2.3