toolkit/func/core/pkg_cpio/10-cpio.sh

35 lines
872 B
Bash
Raw Normal View History

2021-07-05 06:50:25 +00:00
#!/bin/bash
r_log "cpio" "Test basic cpio stuff"
OUTTER=/var/tmp/cpio/out
INNER=/var/tmp/cpio/in
PASSER=/var/tmp/cpio/pass
# Nothing should be here. Clean up first.
[ -d /var/tmp/cpio ] && /bin/rm -rf /var/tmp/cpio
r_log "cpio" "Test basic copy out"
mkdir -p "$OUTTER" "$INNER" "$PASSER"
# Ensure at least one file exists in /tmp to prevent errors.
echo 1 > $(mktemp)
2021-07-06 20:16:01 +00:00
# shellcheck disable=2012
find /tmp -type f | cpio -o > "$OUTTER"/cpio.out 2> /dev/null
2021-07-05 06:50:25 +00:00
r_checkExitStatus $?
r_log "cpio" "Test basic copy in"
pushd "$INNER" || exit 1
cpio -i < "$OUTTER"/cpio.out
r_checkExitStatus $?
popd || exit 1
r_log "cpio" "Test basic passthrough"
pushd "$INNER" || exit 1
find /tmp | cpio -pd "$PASSER"
r_checkExitStatus $?
popd || exit 1
r_log "cpio" "Checking that the directories (pass and in) are the same"
diff "$PASSER" "$INNER" &> /dev/null
r_checkExitStatus $?