2020-02-06 18:59:18 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
test_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
export PATH="$test_directory/..:$PATH"
|
|
|
|
|
2024-08-03 21:34:46 -04:00
|
|
|
# export so that uname hook in gen2stage4 has access to var
|
2020-02-06 20:48:31 -05:00
|
|
|
export TEST_UNAME="test-uname"
|
|
|
|
uname() { echo "$TEST_UNAME"; }
|
2020-02-06 18:59:18 -05:00
|
|
|
export -f uname
|
|
|
|
|
2024-08-03 21:34:46 -04:00
|
|
|
# bypasses gen2stage4 root check
|
2020-02-06 18:59:18 -05:00
|
|
|
whoami() { echo "root"; }
|
|
|
|
export -f whoami
|
|
|
|
|
2024-08-03 15:57:26 -04:00
|
|
|
# bypasses root check
|
|
|
|
id() { echo "0"; }
|
|
|
|
export -f id
|
|
|
|
|
2020-02-06 18:59:18 -05:00
|
|
|
skip_if_not_root() {
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
|
|
skip "Must be root for this test."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
d() {
|
|
|
|
mkdir -p "${1}"
|
|
|
|
}
|
|
|
|
|
|
|
|
f() {
|
|
|
|
mkdir -p "$(dirname "${1}")" && touch "${1}"
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_tar_includes() {
|
|
|
|
test -f "${1}" || test -d "${1}"
|
2024-08-04 02:13:16 -04:00
|
|
|
tar --list -f "${2-test.tar.xz}" | grep -q "^${1}$"
|
2020-02-06 18:59:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_tar_includes_partial() {
|
2024-08-04 02:13:16 -04:00
|
|
|
tar --list -f "${2-test.tar.xz}" | grep -q "${1}"
|
2020-02-06 18:59:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_tar_excludes() {
|
|
|
|
test -f "${1}" || test -d "${1}"
|
2024-08-04 02:13:16 -04:00
|
|
|
! tar --list -f "${2-test.tar.xz}" | grep -q "^${1}$"
|
2020-02-06 18:59:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_tar_excludes_partial() {
|
2024-08-04 02:13:16 -04:00
|
|
|
! tar --list -f "${2-test.tar.xz}" | grep -q "${1}"
|
2020-02-06 18:59:18 -05:00
|
|
|
}
|