install "$@"
}
+# Prefer GNU touch to work around https://apple.stackexchange.com/a/425730/397839
+if command -v gtouch &>/dev/null; then
+ TOUCH=gtouch
+else
+ TOUCH=touch
+fi
+
# Like a mythical touch -p
function touchp() {
for arg; do
# Creates a file+directory structure with varying timestamps
function make_times() {
mkdir -p "$1"
- touch -t 199112140000 "$1/a"
- touch -t 199112140001 "$1/b"
- touch -t 199112140002 "$1/c"
+ $TOUCH -t 199112140000 "$1/a"
+ $TOUCH -t 199112140001 "$1/b"
+ $TOUCH -t 199112140002 "$1/c"
ln -s a "$1/l"
- touch -h -t 199112140003 "$1/l"
- touch -t 199112140004 "$1"
+ $TOUCH -h -t 199112140003 "$1/l"
+ $TOUCH -t 199112140004 "$1"
}
make_times "$TMP/times"
cd "$name" 2>/dev/null
done
- touch "$name"
+ $TOUCH "$name"
)
done
}
function test_ignore_readdir_race() {
rm -rf scratch/*
- touch scratch/{foo,bar}
+ $TOUCH scratch/{foo,bar}
# -links 1 forces a stat() call, which will fail for the second file
invoke_bfs scratch -mindepth 1 -ignore_readdir_race -links 1 -exec "$TESTS/remove-sibling.sh" '{}' ';'
rm -rf scratch/*
touchp scratch/foo/bar
- invoke_bfs scratch -mindepth 1 -ignore_readdir_race -execdir rm -r '{}' \; -execdir touch '{}' \;
+ invoke_bfs scratch -mindepth 1 -ignore_readdir_race -execdir rm -r '{}' \; -execdir $TOUCH '{}' \;
}
function test_perm_000() {
rm -rf scratch/*
mkdir scratch/foo
- touch scratch/foo/{1..256}
+ $TOUCH scratch/foo/{1..256}
invoke_bfs scratch/foo -delete
bfs_diff scratch
rm -rf scratch/*
mkdir scratch/{foo,mnt}
sudo mount -t tmpfs tmpfs scratch/mnt
- touch scratch/foo/bar scratch/mnt/baz
+ $TOUCH scratch/foo/bar scratch/mnt/baz
bfs_diff scratch -mount
local ret=$?
mkdir scratch/{foo,mnt}
sudo mount -t tmpfs tmpfs scratch/mnt
ln -s ../mnt scratch/foo/bar
- touch scratch/mnt/baz
+ $TOUCH scratch/mnt/baz
ln -s ../mnt/baz scratch/foo/qux
bfs_diff -L scratch -mount
rm -rf scratch/*
mkdir scratch/{foo,mnt}
sudo mount -t tmpfs tmpfs scratch/mnt
- touch scratch/foo/bar scratch/mnt/baz
+ $TOUCH scratch/foo/bar scratch/mnt/baz
bfs_diff scratch -xdev
local ret=$?
mkdir scratch/{foo,mnt}
sudo mount -t tmpfs tmpfs scratch/mnt
ln -s ../mnt scratch/foo/bar
- touch scratch/mnt/baz
+ $TOUCH scratch/mnt/baz
ln -s ../mnt/baz scratch/foo/qux
bfs_diff -L scratch -xdev
function test_inum_bind_mount() {
rm -rf scratch/*
- touch scratch/{foo,bar}
+ $TOUCH scratch/{foo,bar}
sudo mount --bind scratch/{foo,bar}
bfs_diff scratch -inum "$(inum scratch/bar)"
function test_type_bind_mount() {
rm -rf scratch/*
- touch scratch/{file,null}
+ $TOUCH scratch/{file,null}
sudo mount --bind /dev/null scratch/null
bfs_diff scratch -type c
function test_xtype_bind_mount() {
rm -rf scratch/*
- touch scratch/{file,null}
+ $TOUCH scratch/{file,null}
sudo mount --bind /dev/null scratch/null
ln -s /dev/null scratch/link
quiet invoke_bfs scratch -quit -acl || return 0
- touch scratch/{normal,acl}
+ $TOUCH scratch/{normal,acl}
set_acl scratch/acl || return 0
ln -s acl scratch/link
quiet invoke_bfs scratch -quit -acl || return 0
- touch scratch/{normal,acl}
+ $TOUCH scratch/{normal,acl}
set_acl scratch/acl || return 0
ln -s acl scratch/link
return 0
fi
- touch scratch/{normal,capable}
+ $TOUCH scratch/{normal,capable}
sudo setcap all+ep scratch/capable
ln -s capable scratch/link
return 0
fi
- touch scratch/{normal,capable}
+ $TOUCH scratch/{normal,capable}
sudo setcap all+ep scratch/capable
ln -s capable scratch/link
function make_xattrs() {
rm -rf scratch/*
- touch scratch/{normal,xattr,xattr_2}
+ $TOUCH scratch/{normal,xattr,xattr_2}
ln -s xattr scratch/link
ln -s normal scratch/xattr_link
rm -rf scratch/*
- touch scratch/{foo,bar}
+ $TOUCH scratch/{foo,bar}
chflags offline scratch/bar || return 0
bfs_diff scratch -flags -offline,nohidden