Skip to content

Commit 123cf16

Browse files
committed
test script for systemd validation
Signed-off-by: Abhishek Sinha <[email protected]>
1 parent 377a8b4 commit 123cf16

File tree

1 file changed

+52
-0
lines changed
  • Runner/suites/Platform/systemd

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
5+
# Function to check if systemd is running with PID 1
6+
directory=$(dirname "$0")
7+
check_systemd_pid() {
8+
if [ "$(ps -p 1 -o comm=)" == "systemd" ]; then
9+
echo "PASS: Check systemd PID" > $directory/CheckSystemdPID.res
10+
else
11+
echo "FAIL: Check systemd PID" > $directory/CheckSystemdPID.res
12+
fi
13+
}
14+
15+
# Function to check if systemctl stop command works for systemd-user-sessions.service
16+
check_systemctl_stop() {
17+
systemctl stop systemd-user-sessions.service
18+
if systemctl is-active --quiet systemd-user-sessions.service; then
19+
echo "FAIL: Systemctl Stop Service" > $directory/CheckSystemctlStop.res
20+
else
21+
echo "PASS: Systemctl Stop Service" > $directory/CheckSystemctlStop.res
22+
fi
23+
}
24+
25+
# Function to check if systemctl start command works for systemd-user-sessions.service
26+
check_systemctl_start() {
27+
systemctl start systemd-user-sessions.service
28+
if systemctl is-active --quiet systemd-user-sessions.service; then
29+
echo "PASS: Systemctl Start Service" > $directory/CheckSystemctlStart.res
30+
else
31+
echo "FAIL: Systemctl Start Service" > $directory/CheckSystemctlStart.res
32+
fi
33+
}
34+
35+
# Function to check for any failed services and print them
36+
check_failed_services() {
37+
failed_services=$(systemctl --failed --no-legend --plain | awk '{print $1}')
38+
if [ -z "$failed_services" ]; then
39+
echo "PASS: Check failed services" > $directory/CheckFailedServices.res
40+
else
41+
echo "FAIL: Check failed services" > $directory/CheckFailedServices.res
42+
echo "$failed_services"
43+
fi
44+
45+
}
46+
47+
# Call the functions
48+
check_systemd_pid
49+
check_systemctl_stop
50+
check_systemctl_start
51+
check_failed_services
52+

0 commit comments

Comments
 (0)