1 Star 0 Fork 49

AliOS Auto/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0104-tests-also-run-TEST-01-BASIC-in-an-unprivileged-cont.patch 3.21 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:59 . import systemd-239-29.el8.src.rpm
From 91bd0b915aa17f44625a0c0ce84ed73b6d33968e Mon Sep 17 00:00:00 2001
From: Evgeny Vereshchagin <evvers@ya.ru>
Date: Thu, 30 Aug 2018 07:01:18 +0300
Subject: [PATCH] tests: also run TEST-01-BASIC in an unprivileged container
(#9957)
This should make it much easier to catch regressions like
https://github.com/systemd/systemd/issues/9914 and
https://github.com/systemd/systemd/issues/8535.
(cherry picked from commit 746fbd9c34af5ed8b6d9aa7a9cbd7cac63a3afce)
---
test/TEST-01-BASIC/test.sh | 1 +
test/test-functions | 23 +++++++++++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh
index 8b21ba05d3..1d2f833478 100755
--- a/test/TEST-01-BASIC/test.sh
+++ b/test/TEST-01-BASIC/test.sh
@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="Basic systemd setup"
+RUN_IN_UNPRIVILEGED_CONTAINER=yes
. $TEST_BASE_DIR/test-functions
diff --git a/test/test-functions b/test/test-functions
index 8164858c2a..670c2625f7 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -190,7 +190,7 @@ $KERNEL_APPEND \
run_nspawn() {
[[ -d /run/systemd/system ]] || return 1
- local _nspawn_cmd="$BUILD_DIR/systemd-nspawn $NSPAWN_ARGUMENTS --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $PATH_TO_INIT $KERNEL_APPEND"
+ local _nspawn_cmd="$BUILD_DIR/systemd-nspawn $NSPAWN_ARGUMENTS --register=no --kill-signal=SIGKILL --directory=$TESTDIR/$1 $PATH_TO_INIT $KERNEL_APPEND"
if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
_nspawn_cmd="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
fi
@@ -450,9 +450,9 @@ EOF
check_result_nspawn() {
ret=1
- [[ -e $TESTDIR/nspawn-root/testok ]] && ret=0
- [[ -f $TESTDIR/nspawn-root/failed ]] && cp -a $TESTDIR/nspawn-root/failed $TESTDIR
- cp -a $TESTDIR/nspawn-root/var/log/journal $TESTDIR
+ [[ -e $TESTDIR/$1/testok ]] && ret=0
+ [[ -f $TESTDIR/$1/failed ]] && cp -a $TESTDIR/$1/failed $TESTDIR
+ cp -a $TESTDIR/$1/var/log/journal $TESTDIR
[[ -f $TESTDIR/failed ]] && cat $TESTDIR/failed
ls -l $TESTDIR/journal/*/*.journal
test -s $TESTDIR/failed && ret=$(($ret+1))
@@ -662,6 +662,9 @@ setup_nspawn_root() {
cp -ar $initdir $TESTDIR/nspawn-root
# we don't mount in the nspawn root
rm -f $TESTDIR/nspawn-root/etc/fstab
+ if [[ "$RUN_IN_UNPRIVILEGED_CONTAINER" = "yes" ]]; then
+ cp -ar $TESTDIR/nspawn-root $TESTDIR/unprivileged-nspawn-root
+ fi
}
setup_basic_dirs() {
@@ -1478,11 +1481,19 @@ test_run() {
fi
fi
if [ -z "$TEST_NO_NSPAWN" ]; then
- if run_nspawn; then
- check_result_nspawn || return 1
+ if run_nspawn "nspawn-root"; then
+ check_result_nspawn "nspawn-root" || return 1
else
dwarn "can't run systemd-nspawn, skipping"
fi
+
+ if [[ "$RUN_IN_UNPRIVILEGED_CONTAINER" = "yes" ]]; then
+ if NSPAWN_ARGUMENTS="-U --private-network $NSPAWN_ARGUMENTS" run_nspawn "unprivileged-nspawn-root"; then
+ check_result_nspawn "unprivileged-nspawn-root" || return 1
+ else
+ dwarn "can't run systemd-nspawn, skipping"
+ fi
+ fi
fi
return 0
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/banma-autoos/systemd.git
git@gitee.com:banma-autoos/systemd.git
banma-autoos
systemd
systemd
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385