09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin#!/bin/bash
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin# ex: ts=8 sw=4 sts=4 et filetype=sh
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny VereshchaginTEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin. $TEST_BASE_DIR/test-functions
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagintest_run() {
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin dwarn "skipping QEMU"
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin if check_nspawn; then
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin timeout --foreground 30s systemd-nspawn --kill-signal=SIGKILL --boot --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin check_result_nspawn || return 1
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin else
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin dwarn "can't run systemd-nspawn, skipping"
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin fi
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin return 0
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin}
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagintest_setup() {
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin create_empty_image
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin mkdir -p $TESTDIR/root
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin mount ${LOOPDEV}p1 $TESTDIR/root
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin # Create what will eventually be our root filesystem onto an overlay
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin (
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin LOG_LEVEL=5
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin setup_basic_environment
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin # setup the testsuite service
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin cat >$initdir/etc/systemd/system/testsuite.service <<EOF
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin[Unit]
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny VereshchaginDescription=Testsuite service
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny VereshchaginAfter=multi-user.target
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin[Service]
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny VereshchaginExecStart=/test-segfault.sh
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny VereshchaginType=oneshot
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny VereshchaginEOF
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin cp test-segfault.sh $initdir/
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin setup_testsuite
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin ) || return 1
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin setup_nspawn_root
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin ddebug "umount $TESTDIR/root"
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin umount $TESTDIR/root
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin}
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagintest_cleanup() {
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin umount $TESTDIR/root 2>/dev/null
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin [[ $LOOPDEV ]] && losetup -d $LOOPDEV
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin return 0
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin}
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagin
09f6f45a29d8691b67152d4e6f5bbb1453be778eEvgeny Vereshchagindo_test "$@"