aboutsummaryrefslogtreecommitdiffstats
path: root/file_cmds/tests
diff options
context:
space:
mode:
Diffstat (limited to 'file_cmds/tests')
-rw-r--r--file_cmds/tests/cp.sh23
-rw-r--r--file_cmds/tests/file_cmds.plist36
-rw-r--r--file_cmds/tests/touch.sh14
3 files changed, 73 insertions, 0 deletions
diff --git a/file_cmds/tests/cp.sh b/file_cmds/tests/cp.sh
new file mode 100644
index 0000000..24afa56
--- /dev/null
+++ b/file_cmds/tests/cp.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Regression test for 69452380
+function regression_69452380()
+{
+ echo "Verifying that cp -p preserves symlink's attributes, rather than the attributes of the symlink's target."
+ test_dir=`mktemp -d /tmp/69452380_src_XXXX`
+ touch ${test_dir}/target
+ mkdir ${test_dir}/link_dir
+ # Create symlink (must use relative path for the failure to occur)
+ cd ${test_dir}/link_dir
+ ln -s ../target link
+ # cp (with attribute preservation) the test dir containing both the
+ # target and the link (in a subdirectory) to a new dir.
+ # Prior to 69452380, this failed because we followed the symlink to
+ # try and preserve attributes for a non-existing file, instead of
+ # preserving the attributes of the symlink itself.
+ cp -R -P -p ${test_dir} /tmp/69452380_tgt_${RANDOM}
+}
+
+set -eu -o pipefail
+
+regression_69452380
diff --git a/file_cmds/tests/file_cmds.plist b/file_cmds/tests/file_cmds.plist
index 4e4d135..337d4b4 100644
--- a/file_cmds/tests/file_cmds.plist
+++ b/file_cmds/tests/file_cmds.plist
@@ -12,6 +12,42 @@
<key>Command</key>
<array>
<string>/bin/sh</string>
+ <string>cp.sh</string>
+ </array>
+ <key>AsRoot</key>
+ <false/>
+ <key>TestName</key>
+ <string>cp</string>
+ <key>WhenToRun</key>
+ <array>
+ <string>PRESUBMISSION</string>
+ <string>NIGHTLY</string>
+ </array>
+ <key>WorkingDirectory</key>
+ <string>/AppleInternal/Tests/file_cmds</string>
+ </dict>
+ <dict>
+ <key>Command</key>
+ <array>
+ <string>/bin/sh</string>
+ <string>touch.sh</string>
+ </array>
+ <key>AsRoot</key>
+ <false/>
+ <key>TestName</key>
+ <string>touch</string>
+ <key>WhenToRun</key>
+ <array>
+ <string>PRESUBMISSION</string>
+ <string>NIGHTLY</string>
+ </array>
+ <key>WorkingDirectory</key>
+ <string>/AppleInternal/Tests/file_cmds</string>
+ </dict>
+ <dict>
+ <key>Command</key>
+ <array>
+ <string>/bin/sh</string>
<string>chgrp.sh</string>
</array>
<key>AsRoot</key>
diff --git a/file_cmds/tests/touch.sh b/file_cmds/tests/touch.sh
new file mode 100644
index 0000000..d38684d
--- /dev/null
+++ b/file_cmds/tests/touch.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+file_name=`mktemp /tmp/XXXXXX`
+file_ctime=`/usr/bin/stat -f%c ${file_name}`
+
+/usr/bin/touch $file_name
+file_mtime=`/usr/bin/stat -f%m ${file_name}`
+
+if [ "$file_ctime" -gt "$file_mtime" ]; then
+ echo "file's mod time ($file_mtime) should be later than the file's creation time ($file_ctime)"
+ exit 1
+fi
+
+exit 0