aboutsummaryrefslogtreecommitdiff
path: root/scripts/test
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/test')
-rw-r--r--scripts/test/chmod.test98
-rwxr-xr-xscripts/test/link.test22
2 files changed, 69 insertions, 51 deletions
diff --git a/scripts/test/chmod.test b/scripts/test/chmod.test
index f370d601..77106a69 100644
--- a/scripts/test/chmod.test
+++ b/scripts/test/chmod.test
@@ -40,7 +40,7 @@ do
fi
DASHES=$(num2perm $u$g$o)
testing "chmod $u$g$o $type" "chmod $u$g$o $type &&
- ls -ld $type | cut -d' ' -f 1" "$DASH$DASHES\n" "" ""
+ ls -ld $type | cut -d' ' -f 1 | cut -d. -f 1" "$DASH$DASHES\n" "" ""
done
done
done
@@ -48,197 +48,197 @@ done
rm -rf dir file && mkdir dir && touch file
testing "chmod 750 dir 640 file" \
"chmod 750 dir 640 file 2>/dev/null ||
- ls -ld dir file | cut -d' ' -f 1" "drwxr-x---\n-rwxr-x---\n" "" ""
+ 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" \
"chmod 666 dir file &&
- ls -ld dir file | cut -d' ' -f 1" "drw-rw-rw-\n-rw-rw-rw-\n" "" ""
+ 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 * &&
- ls -ld dir file | cut -d' ' -f 1" "drwxrw-r-x\n-rwxrw-r-x\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "dr--r-xr-x\n-r--r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d-w-r-xr-x\n--w-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d--xr-xr-x\n---xr--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rwxr--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d-wxr-xr-x\n--w-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drw-r-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr--r-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwx-w-r-x\n-rw--w-r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwx--xr-x\n-rw---xr--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxrwxr-x\n-rw-rw-r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r-xr--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwx--xr-x\n-rw----r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr--r-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr--\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-x-w-\n-rw-r---w-\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-x--x\n-rw-r----x\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xrwx\n-rw-r--rw-\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r-x\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-x--x\n-rw-r-----\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr--\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "dr--r--r--\n-r--r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d-w--w--w-\n--w--w--w-\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d--x--x--x\n---x--x--x\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxrwxrwx\n-rw-rw-rw-\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rwxr-xr-x\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d-wx--x--x\n--w-------\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drw-r--r--\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "dr--r--r--\n-r--r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d-w-------\n--w-------\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d--x--x--x\n---x--x--x\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rw-r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drwxr-xr-x\n-rwxr-xr-x\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "d-wx--x--x\n--w-------\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "dr-xr-xr-x\n-r--r--r--\n" "" ""
+ 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 &&
- ls -ld dir file | cut -d' ' -f 1" "drw-r--r--\n-rw-r--r--\n" "" ""
+ 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
rm -rf dir file
diff --git a/scripts/test/link.test b/scripts/test/link.test
index 3bfdc1f1..769a7b67 100755
--- a/scripts/test/link.test
+++ b/scripts/test/link.test
@@ -1,8 +1,26 @@
#!/bin/bash
-[ -e testing.sh ] && . testing.sh
+# Copyright 2014 Divya Kothari <divya.s.kothari@gmail.com>
+# Copyright 2014 Naha Maggu <maggu.neha@gmail.com>
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
echo "" >foo
-testing "link has same inode" "link foo bar && stat -c '%DI%i bar'" "stat -c '%DI%i' foo" "" ""
testing "link fails on non-existent file" "link foo/foo baz || echo GOOD" "GOOD\n" "" ""
rm -f foo bar
+
+echo file1 > file
+testing "ln create_hardlink" "link file hlink && [ file -ef hlink ] &&
+ echo 'yes'; rm -rf hlink" "yes\n" "" ""
+
+echo hlink1 > hlink
+set +e
+testing "ln preserves_hardlinks" "link file hlink 2>/dev/null || echo 'yes'; rm -rf hlink" \
+ "yes\n" "" ""
+
+echo file1 > file
+testing "ln create_hardlink_and_remove_sourcefile" "link file hlink &&
+ [ file -ef hlink ] && rm -rf file && [ -f hlink ] && echo 'yes'; rm -f file hlink" \
+ "yes\n" "" ""