You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
3.6 KiB
138 lines
3.6 KiB
From 29aa21d94bc7ff10f3f7ef0b7f490f3903f5c6fd Mon Sep 17 00:00:00 2001
|
|
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
|
|
Date: Fri, 15 Mar 2024 16:03:09 -0400
|
|
Subject: [PATCH 104/157] test: pass flags to services
|
|
|
|
Commit 4c12714d1ca0 ("test: run tests on system level mdadm") removed
|
|
MDADM_NO_SYSTEMCTL flag from test suite. This causes imsm tests to fail
|
|
as mdadm no longer triggers mdmon and flags exists only within session.
|
|
|
|
Use systemd set/unset-environment to pass necessary flags.
|
|
|
|
Introduce colors to grab users attention to warnings and key messages.
|
|
|
|
Make test suite setup systemd environment.
|
|
Add setup/clean_systemd_env() functions.
|
|
Warn user about altering systemd environment.
|
|
|
|
Add colors to success/fail messages and warnings.
|
|
|
|
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
|
|
---
|
|
test | 8 +++-----
|
|
tests/func.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++-
|
|
2 files changed, 48 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/test b/test
|
|
index 47f53ad7..3a05bc9b 100755
|
|
--- a/test
|
|
+++ b/test
|
|
@@ -127,7 +127,7 @@ do_test() {
|
|
dmesg | grep -iq "error\|call trace\|segfault" | grep -v "systemd" &&
|
|
die "dmesg prints errors when testing $_basename!"
|
|
fi
|
|
- echo "succeeded"
|
|
+ succeed "succeeded\n"
|
|
_fail=0
|
|
else
|
|
save_log fail
|
|
@@ -315,10 +315,8 @@ parse_args() {
|
|
}
|
|
|
|
print_warning() {
|
|
- cat <<-EOF
|
|
- Warning! Tests are performed on system level mdadm!
|
|
- If you want to test local build, you need to install it first!
|
|
- EOF
|
|
+ warn "Warning! Tests are performed on system level mdadm!\n"
|
|
+ echo "If you want to test local build, you need to install it first!"
|
|
}
|
|
|
|
main() {
|
|
diff --git a/tests/func.sh b/tests/func.sh
|
|
index b2e4d122..8c142c76 100644
|
|
--- a/tests/func.sh
|
|
+++ b/tests/func.sh
|
|
@@ -23,6 +23,28 @@ mdsize12=19988
|
|
# ddf needs bigger devices as 32Meg is reserved!
|
|
ddfsize=65536
|
|
|
|
+# Systemd flags
|
|
+devname_as_serial_flag="IMSM_DEVNAME_AS_SERIAL=1"
|
|
+no_platform_flag="IMSM_NO_PLATFORM=1"
|
|
+
|
|
+# Common colors
|
|
+COLOR_FAIL='\033[0;31m' #RED
|
|
+COLOR_WARN='\033[1;33m' #YELLOW
|
|
+COLOR_SUCCESS='\033[0;32m' #GREEN
|
|
+COLOR_NONE='\033[0m'
|
|
+
|
|
+fail() {
|
|
+ printf "${COLOR_FAIL}$1${COLOR_NONE}"
|
|
+}
|
|
+
|
|
+warn() {
|
|
+ printf "${COLOR_WARN}$1${COLOR_NONE}"
|
|
+}
|
|
+
|
|
+succeed() {
|
|
+ printf "${COLOR_SUCCESS}$1${COLOR_NONE}"
|
|
+}
|
|
+
|
|
# $1 is optional parameter, it shows why to save log
|
|
save_log() {
|
|
status=$1
|
|
@@ -36,7 +58,8 @@ save_log() {
|
|
cat /proc/mdstat >> $logdir/$logfile
|
|
array=($(mdadm -Ds | cut -d' ' -f2))
|
|
[ "$1" == "fail" ] &&
|
|
- echo "FAILED - see $logdir/$_basename.log and $logdir/$logfile for details"
|
|
+ fail "FAILED"
|
|
+ echo " - see $logdir/$_basename.log and $logdir/$logfile for details\n"
|
|
if [ $DEVTYPE == 'lvm' ]
|
|
then
|
|
# not supported lvm type yet
|
|
@@ -86,6 +109,7 @@ cleanup() {
|
|
$mdadm --zero ${disks[@]} &> /dev/null
|
|
;;
|
|
esac
|
|
+ clean_systemd_env
|
|
}
|
|
|
|
do_clean()
|
|
@@ -176,11 +200,31 @@ restore_selinux() {
|
|
setenforce $sys_selinux
|
|
}
|
|
|
|
+setup_systemd_env() {
|
|
+ warn "Warning! Test suite will set up systemd environment!\n"
|
|
+ echo "Use \"systemctl show-environment\" to show systemd environment variables"
|
|
+ for env_var in $devname_as_serial_flag $no_platform_flag
|
|
+ do
|
|
+ systemctl set-environment $env_var
|
|
+ echo "Added $env_var" to systemd environment, use \
|
|
+ \"systemctl unset-environment $env_var\" to remove it.
|
|
+ done
|
|
+}
|
|
+
|
|
+clean_systemd_env() {
|
|
+ for env_var in $devname_as_serial_flag $no_platform_flag
|
|
+ do
|
|
+ systemctl unset-environment $env_var
|
|
+ echo "Removed $env_var from systemd environment."
|
|
+ done
|
|
+}
|
|
+
|
|
do_setup() {
|
|
trap cleanup 0 1 3 15
|
|
trap ctrl_c 2
|
|
|
|
check_env
|
|
+ setup_systemd_env
|
|
[ -d $logdir ] || mkdir -p $logdir
|
|
|
|
devlist=
|
|
--
|
|
2.41.0
|
|
|