2013-01-25 23:10:00 +04:00
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
2013-02-22 21:59:07 +04:00
TEST_DESCRIPTION = "Job-related tests"
2013-01-25 23:10:00 +04:00
2013-04-23 04:39:40 +04:00
. $TEST_BASE_DIR /test-functions
2013-01-25 23:10:00 +04:00
# Uncomment this to debug failures
#DEBUGFAIL="systemd.unit=multi-user.target"
2013-11-06 02:32:56 +04:00
check_result_qemu( ) {
2013-01-25 23:10:00 +04:00
ret = 1
mkdir -p $TESTDIR /root
mount ${ LOOPDEV } p1 $TESTDIR /root
[ [ -e $TESTDIR /root/testok ] ] && ret = 0
2013-09-17 03:07:43 +04:00
[ [ -f $TESTDIR /root/failed ] ] && cp -a $TESTDIR /root/failed $TESTDIR
2013-01-25 23:10:00 +04:00
cp -a $TESTDIR /root/var/log/journal $TESTDIR
umount $TESTDIR /root
2013-09-17 03:07:43 +04:00
[ [ -f $TESTDIR /failed ] ] && cat $TESTDIR /failed
2013-01-25 23:10:00 +04:00
ls -l $TESTDIR /journal/*/*.journal
test -s $TESTDIR /failed && ret = $(( $ret + 1 ))
return $ret
}
test_run( ) {
if check_qemu ; then
2013-11-06 02:32:56 +04:00
run_qemu
check_result_qemu || return 1
2013-01-25 23:10:00 +04:00
else
dwarn "can't run qemu-kvm, skipping"
fi
if check_nspawn; then
2013-11-06 02:32:56 +04:00
run_nspawn
check_result_nspawn || return 1
2013-01-25 23:10:00 +04:00
else
dwarn "can't run systemd-nspawn, skipping"
fi
return 0
}
test_setup( ) {
2013-11-06 02:32:56 +04:00
create_empty_image
2013-01-25 23:10:00 +04:00
mkdir -p $TESTDIR /root
mount ${ LOOPDEV } p1 $TESTDIR /root
# Create what will eventually be our root filesystem onto an overlay
(
LOG_LEVEL = 5
eval $( udevadm info --export --query= env --name= ${ LOOPDEV } p2)
2013-11-06 02:32:56 +04:00
setup_basic_environment
2013-01-25 23:10:00 +04:00
# setup the testsuite service
cat >$initdir /etc/systemd/system/testsuite.service <<EOF
[ Unit]
Description = Testsuite service
After = multi-user.target
[ Service]
ExecStart = /test-jobs.sh
Type = oneshot
EOF
# copy the units used by this test
2013-02-22 21:59:07 +04:00
cp $TEST_BASE_DIR /{ hello.service,sleep.service,hello-after-sleep.target,unstoppable.service} \
$initdir /etc/systemd/system
2013-01-25 23:10:00 +04:00
cp test-jobs.sh $initdir /
2013-11-06 02:32:56 +04:00
setup_testsuite
2013-01-25 23:10:00 +04:00
)
2013-11-06 02:32:56 +04:00
setup_nspawn_root
2013-01-25 23:10:00 +04:00
ddebug " umount $TESTDIR /root "
umount $TESTDIR /root
}
test_cleanup( ) {
umount $TESTDIR /root 2>/dev/null
[ [ $LOOPDEV ] ] && losetup -d $LOOPDEV
return 0
}
do_test " $@ "