test: replace $TESTDIR/root with $initdir

The $initdir var is already set to $TESTDIR/root, it should be used
instead of direct use of $TESTDIR/root.
This commit is contained in:
Dan Streetman 2019-08-15 09:39:31 -04:00
parent f422967529
commit 0036ce06cb
3 changed files with 34 additions and 34 deletions

View File

@ -7,15 +7,15 @@ TEST_NO_NSPAWN=1
check_result_qemu() {
ret=1
mkdir -p $TESTDIR/root
mount ${LOOPDEV}p1 $TESTDIR/root
[[ -e $TESTDIR/root/testok ]] && ret=0
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
mkdir -p $initdir
mount ${LOOPDEV}p1 $initdir
[[ -e $initdir/testok ]] && ret=0
[[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR
cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
mount /dev/mapper/varcrypt $TESTDIR/root/var
cp -a $TESTDIR/root/var/log/journal $TESTDIR
umount $TESTDIR/root/var
umount $TESTDIR/root
mount /dev/mapper/varcrypt $initdir/var
cp -a $initdir/var/log/journal $TESTDIR
umount $initdir/var
umount $initdir
cryptsetup luksClose /dev/mapper/varcrypt
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
@ -30,8 +30,8 @@ test_setup() {
cryptsetup -q luksFormat --pbkdf pbkdf2 --pbkdf-force-iterations 1000 ${LOOPDEV}p2 $TESTDIR/keyfile
cryptsetup luksOpen ${LOOPDEV}p2 varcrypt <$TESTDIR/keyfile
mkfs.ext4 -L var /dev/mapper/varcrypt
mkdir -p $TESTDIR/root/var
mount /dev/mapper/varcrypt $TESTDIR/root/var
mkdir -p $initdir/var
mount /dev/mapper/varcrypt $initdir/var
# Create what will eventually be our root filesystem onto an overlay
(
@ -77,8 +77,8 @@ EOF
}
cleanup_root_var() {
ddebug "umount $TESTDIR/root/var"
mountpoint $TESTDIR/root/var && umount $TESTDIR/root/var
ddebug "umount $initdir/var"
mountpoint $initdir/var && umount $initdir/var
[[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
}

View File

@ -29,25 +29,25 @@ check_result_nspawn() {
check_result_qemu() {
local _ret=1
mkdir -p $TESTDIR/root
mount ${LOOPDEV}p1 $TESTDIR/root
[[ -e $TESTDIR/root/testok ]] && _ret=0
if [[ -s $TESTDIR/root/failed ]]; then
mkdir -p $initdir
mount ${LOOPDEV}p1 $initdir
[[ -e $initdir/testok ]] && _ret=0
if [[ -s $initdir/failed ]]; then
_ret=$(($_ret+1))
echo "=== Failed test log ==="
cat $TESTDIR/root/failed
cat $initdir/failed
else
if [[ -s $TESTDIR/root/skipped ]]; then
if [[ -s $initdir/skipped ]]; then
echo "=== Skipped test log =="
cat $TESTDIR/root/skipped
cat $initdir/skipped
fi
if [[ -s $TESTDIR/root/testok ]]; then
if [[ -s $initdir/testok ]]; then
echo "=== Passed tests ==="
cat $TESTDIR/root/testok
cat $initdir/testok
fi
fi
cp -a $TESTDIR/root/var/log/journal $TESTDIR
umount $TESTDIR/root
cp -a $initdir/var/log/journal $TESTDIR
umount $initdir
[[ -n "$TIMED_OUT" ]] && _ret=$(($_ret+1))
return $_ret
}

View File

@ -561,8 +561,8 @@ EOF
create_empty_image_rootdir() {
create_empty_image
mkdir -p $TESTDIR/root
mount ${LOOPDEV}p1 $TESTDIR/root
mkdir -p $initdir
mount ${LOOPDEV}p1 $initdir
TEST_SETUP_CLEANUP_ROOTDIR=1
}
@ -622,13 +622,13 @@ check_result_nspawn() {
# can be overridden in specific test
check_result_qemu() {
local ret=1
mkdir -p $TESTDIR/root
mount ${LOOPDEV}p1 $TESTDIR/root
[[ -e $TESTDIR/root/testok ]] && ret=0
[[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
cp -a $TESTDIR/root/var/log/journal $TESTDIR
check_asan_reports "$TESTDIR/root" || ret=$(($ret+1))
umount $TESTDIR/root
mkdir -p $initdir
mount ${LOOPDEV}p1 $initdir
[[ -e $initdir/testok ]] && ret=0
[[ -f $initdir/failed ]] && cp -a $initdir/failed $TESTDIR
cp -a $initdir/var/log/journal $TESTDIR
check_asan_reports "$initdir" || ret=$(($ret+1))
umount $initdir
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
test -s $TESTDIR/failed && ret=$(($ret+1))
@ -1677,7 +1677,7 @@ _umount_dir() {
_test_setup_cleanup() {
# only umount if create_empty_image_rootdir() was called to mount it
[[ -z $TEST_SETUP_CLEANUP_ROOTDIR ]] || _umount_dir $TESTDIR/root
[[ -z $TEST_SETUP_CLEANUP_ROOTDIR ]] || _umount_dir $initdir
}
# can be overridden in specific test
@ -1689,7 +1689,7 @@ _test_cleanup() {
# (post-test) cleanup should always ignore failure and cleanup as much as possible
(
set +e
_umount_dir $TESTDIR/root
_umount_dir $initdir
if [[ $LOOPDEV && -b $LOOPDEV ]]; then
ddebug "losetup -d $LOOPDEV"
losetup -d $LOOPDEV