awk: fix 'delete array[var--]' decrementing var twice
[oweals/busybox.git] / testsuite / cpio.tests
index 725e70eab0f8211a83a587cc8014303aacd9e10c..88ec086b6c8a5017b1cee938664540be9f875693 100755 (executable)
@@ -1,9 +1,11 @@
 #!/bin/sh
 # Copyright 2008 by Denys Vlasenko
-# Licensed under GPL v2, see file LICENSE for details.
+# Licensed under GPLv2, see file LICENSE in this source tree.
 
 . ./testing.sh
 
+umask 022
+
 # ls -ln shows date. Need to remove that, it's variable.
 # sed: coalesce spaces
 # cut: remove date
@@ -40,8 +42,7 @@ ls -ln cpio.testdir | $FILTER_LS" \
 0
 -rw-r--r-- 2 $user $group 0 x
 -rw-r--r-- 2 $user $group 0 y
-" \
-       "" ""
+" "" ""
 SKIP=
 
 
@@ -56,8 +57,7 @@ cpio.testdir/x
 cpio.testdir/y
 1 blocks
 0
-" \
-       "" ""
+" "" ""
 }
 
 
@@ -83,11 +83,9 @@ ls -ln cpio.testdir2/cpio.testdir | $FILTER_LS" \
 -rw-r--r-- 2 $user $group 2 nonempty
 -rw-r--r-- 2 $user $group 2 nonempty1
 -rw-r--r-- 1 $user $group 0 solo
-" \
-       "" ""
+" "" ""
 SKIP=
 
-
 # Was trying to create "/usr/bin", correct is "usr/bin".
 rm -rf cpio.testdir
 optional FEATURE_CPIO_P
@@ -98,10 +96,63 @@ ls cpio.testdir" \
 1 blocks
 0
 usr
-" \
-       "" ""
+" "" ""
+SKIP=
+
+# chown on a link was affecting file, dropping its suid/sgid bits
+rm -rf cpio.testdir
+optional FEATURE_CPIO_O FEATURE_STAT_FORMAT
+mkdir cpio.testdir
+touch cpio.testdir/file
+chmod 6755 cpio.testdir/file  # sets suid/sgid bits
+ln -sf file cpio.testdir/link
+testing "cpio restores suid/sgid bits" \
+"cd cpio.testdir && { echo file; echo link; } | cpio -ovHnewc >pack.cpio && rm ???? && cpio -idmvu <pack.cpio 2>/dev/null;
+ stat -c '%a %n' file" \
+"\
+file
+link
+6755 file
+" "" ""
 SKIP=
 
+# avoid 'not created: newer or same age file exists' message for directories
+rm -rf cpio.testdir cpio.testdir2 2>/dev/null
+mkdir cpio.testdir
+testing "cpio extracts in existing directory" \
+"$ECHO -ne '$hexdump' | bzcat | cpio -id 2>&1; echo \$?" \
+"\
+1 blocks
+0
+" "" ""
+SKIP=
+
+optional FEATURE_CPIO_O
+testing "cpio uses by default uid/gid" \
+"echo $0 | cpio -o -H newc | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \
+"\
+$user/$group
+0
+" "" ""
+SKIP=
+
+optional FEATURE_CPIO_O
+testing "cpio -R with create" \
+"echo $0 | cpio -o -H newc -R 1234:5678 | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \
+"\
+1234/5678
+0
+" "" ""
+SKIP=
+
+optional FEATURE_CPIO_O
+testing "cpio -R with extract" \
+"echo $0 | cpio -o -H newc | cpio -tv -R 8765:4321 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \
+"\
+8765/4321
+0
+" "" ""
+SKIP=
 
 # Clean up
 rm -rf cpio.testdir cpio.testdir2 2>/dev/null