|
|
2f7d91 |
From c53791854050661d34417f12755837abd74d213a Mon Sep 17 00:00:00 2001
|
|
|
2f7d91 |
From: Evgeny Vereshchagin <evvers@ya.ru>
|
|
|
2f7d91 |
Date: Tue, 17 Nov 2015 11:21:23 +0000
|
|
|
2f7d91 |
Subject: [PATCH] tests: add basic journal test
|
|
|
2f7d91 |
|
|
|
2f7d91 |
(cherry picked from commit 1c36b4a73b876258fbe01fbe9bc9b750b7dcc9ce)
|
|
|
2f7d91 |
(cherry picked from commit e974b9915ccc7bf56d23fd6fc67631990d893c89)
|
|
|
2f7d91 |
Resolves: #1803802
|
|
|
2f7d91 |
---
|
|
|
2f7d91 |
test/TEST-04-JOURNAL/Makefile | 1 +
|
|
|
2f7d91 |
test/TEST-04-JOURNAL/test-journal.sh | 18 +++++++
|
|
|
2f7d91 |
test/TEST-04-JOURNAL/test.sh | 76 ++++++++++++++++++++++++++++
|
|
|
2f7d91 |
test/test-functions | 2 +-
|
|
|
2f7d91 |
4 files changed, 96 insertions(+), 1 deletion(-)
|
|
|
2f7d91 |
create mode 120000 test/TEST-04-JOURNAL/Makefile
|
|
|
2f7d91 |
create mode 100755 test/TEST-04-JOURNAL/test-journal.sh
|
|
|
2f7d91 |
create mode 100755 test/TEST-04-JOURNAL/test.sh
|
|
|
2f7d91 |
|
|
|
2f7d91 |
diff --git a/test/TEST-04-JOURNAL/Makefile b/test/TEST-04-JOURNAL/Makefile
|
|
|
2f7d91 |
new file mode 120000
|
|
|
2f7d91 |
index 0000000000..e9f93b1104
|
|
|
2f7d91 |
--- /dev/null
|
|
|
2f7d91 |
+++ b/test/TEST-04-JOURNAL/Makefile
|
|
|
2f7d91 |
@@ -0,0 +1 @@
|
|
|
2f7d91 |
+../TEST-01-BASIC/Makefile
|
|
|
2f7d91 |
\ No newline at end of file
|
|
|
2f7d91 |
diff --git a/test/TEST-04-JOURNAL/test-journal.sh b/test/TEST-04-JOURNAL/test-journal.sh
|
|
|
2f7d91 |
new file mode 100755
|
|
|
2f7d91 |
index 0000000000..c75f396ceb
|
|
|
2f7d91 |
--- /dev/null
|
|
|
2f7d91 |
+++ b/test/TEST-04-JOURNAL/test-journal.sh
|
|
|
2f7d91 |
@@ -0,0 +1,18 @@
|
|
|
2f7d91 |
+#!/bin/bash
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+set -x
|
|
|
2f7d91 |
+set -e
|
|
|
2f7d91 |
+set -o pipefail
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+# Test stdout stream
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+# Skip empty lines
|
|
|
2f7d91 |
+ID=$(journalctl --new-id128 | sed -n 2p)
|
|
|
2f7d91 |
+>/expected
|
|
|
2f7d91 |
+printf $'\n\n\n' | systemd-cat -t "$ID" --level-prefix false
|
|
|
2f7d91 |
+journalctl --flush
|
|
|
2f7d91 |
+journalctl -b -o cat -t "$ID" >/output
|
|
|
2f7d91 |
+cmp /expected /output
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+touch /testok
|
|
|
2f7d91 |
+exit 0
|
|
|
2f7d91 |
diff --git a/test/TEST-04-JOURNAL/test.sh b/test/TEST-04-JOURNAL/test.sh
|
|
|
2f7d91 |
new file mode 100755
|
|
|
2f7d91 |
index 0000000000..e37cb7d412
|
|
|
2f7d91 |
--- /dev/null
|
|
|
2f7d91 |
+++ b/test/TEST-04-JOURNAL/test.sh
|
|
|
2f7d91 |
@@ -0,0 +1,76 @@
|
|
|
2f7d91 |
+#!/bin/bash
|
|
|
2f7d91 |
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
2f7d91 |
+# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
2f7d91 |
+TEST_DESCRIPTION="Journal-related tests"
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+. $TEST_BASE_DIR/test-functions
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+check_result_qemu() {
|
|
|
2f7d91 |
+ ret=1
|
|
|
2f7d91 |
+ mkdir -p $TESTDIR/root
|
|
|
2f7d91 |
+ mount ${LOOPDEV}p1 $TESTDIR/root
|
|
|
2f7d91 |
+ [[ -e $TESTDIR/root/testok ]] && ret=0
|
|
|
2f7d91 |
+ [[ -f $TESTDIR/root/failed ]] && cp -a $TESTDIR/root/failed $TESTDIR
|
|
|
2f7d91 |
+ cp -a $TESTDIR/root/var/log/journal $TESTDIR
|
|
|
2f7d91 |
+ umount $TESTDIR/root
|
|
|
2f7d91 |
+ [[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
|
|
|
2f7d91 |
+ ls -l $TESTDIR/journal/*/*.journal
|
|
|
2f7d91 |
+ test -s $TESTDIR/failed && ret=$(($ret+1))
|
|
|
2f7d91 |
+ return $ret
|
|
|
2f7d91 |
+}
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+test_run() {
|
|
|
2f7d91 |
+ if run_qemu; then
|
|
|
2f7d91 |
+ check_result_qemu || return 1
|
|
|
2f7d91 |
+ else
|
|
|
2f7d91 |
+ dwarn "can't run QEMU, skipping"
|
|
|
2f7d91 |
+ fi
|
|
|
2f7d91 |
+ if check_nspawn; then
|
|
|
2f7d91 |
+ run_nspawn
|
|
|
2f7d91 |
+ check_result_nspawn || return 1
|
|
|
2f7d91 |
+ else
|
|
|
2f7d91 |
+ dwarn "can't run systemd-nspawn, skipping"
|
|
|
2f7d91 |
+ fi
|
|
|
2f7d91 |
+ return 0
|
|
|
2f7d91 |
+}
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+test_setup() {
|
|
|
2f7d91 |
+ create_empty_image
|
|
|
2f7d91 |
+ mkdir -p $TESTDIR/root
|
|
|
2f7d91 |
+ mount ${LOOPDEV}p1 $TESTDIR/root
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+ # Create what will eventually be our root filesystem onto an overlay
|
|
|
2f7d91 |
+ (
|
|
|
2f7d91 |
+ LOG_LEVEL=5
|
|
|
2f7d91 |
+ eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+ setup_basic_environment
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+ # setup the testsuite service
|
|
|
2f7d91 |
+ cat >$initdir/etc/systemd/system/testsuite.service <
|
|
|
2f7d91 |
+[Unit]
|
|
|
2f7d91 |
+Description=Testsuite service
|
|
|
2f7d91 |
+After=multi-user.target
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+[Service]
|
|
|
2f7d91 |
+ExecStart=/test-journal.sh
|
|
|
2f7d91 |
+Type=oneshot
|
|
|
2f7d91 |
+EOF
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+ cp test-journal.sh $initdir/
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+ setup_testsuite
|
|
|
2f7d91 |
+ )
|
|
|
2f7d91 |
+ setup_nspawn_root
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+ ddebug "umount $TESTDIR/root"
|
|
|
2f7d91 |
+ umount $TESTDIR/root
|
|
|
2f7d91 |
+}
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+test_cleanup() {
|
|
|
2f7d91 |
+ umount $TESTDIR/root 2>/dev/null
|
|
|
2f7d91 |
+ [[ $LOOPDEV ]] && losetup -d $LOOPDEV
|
|
|
2f7d91 |
+ return 0
|
|
|
2f7d91 |
+}
|
|
|
2f7d91 |
+
|
|
|
2f7d91 |
+do_test "$@"
|
|
|
2f7d91 |
diff --git a/test/test-functions b/test/test-functions
|
|
|
2f7d91 |
index e50ce556fd..d5e9650903 100644
|
|
|
2f7d91 |
--- a/test/test-functions
|
|
|
2f7d91 |
+++ b/test/test-functions
|
|
|
2f7d91 |
@@ -12,7 +12,7 @@ if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
|
|
|
2f7d91 |
ROOTLIBDIR=/usr/lib/systemd
|
|
|
2f7d91 |
fi
|
|
|
2f7d91 |
|
|
|
2f7d91 |
-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe chmod chown ln"
|
|
|
2f7d91 |
+BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe chmod chown ln sed cmp tee"
|
|
|
2f7d91 |
DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname"
|
|
|
2f7d91 |
|
|
|
2f7d91 |
function find_qemu_bin() {
|