diff --git a/Runner/suites/Platform/systemd/README.md b/Runner/suites/Platform/systemd/README.md new file mode 100755 index 00000000..b17b20ad --- /dev/null +++ b/Runner/suites/Platform/systemd/README.md @@ -0,0 +1,27 @@ +# systemd Suite + +This folder contains test scripts for validating `systemd` functionality on the platform. Particularly for **Qualcomm RB3Gen2** and platforms based on `meta-qcom` and `meta-qcom-distros`. + +## Contents + +- **directory/**: Each directory contains individual test script run.sh for specific `systemd` features. +- **README.md**: This documentation file. + +## Usage + +1. Ensure all dependencies are installed as specified in the root documentation. +2. Run the suite using run-test.sh in root directory Runner/: + ``` + ./run-test.sh + for e.g. ./run-test.sh systemdPID + ``` +3. Review the test results stored in file named in respective directory. + +## Purpose + +The `systemd` suite helps maintain reliability by ensuring that service management and related features work as expected on QCOM platforms. + +These scripts focus on +- Validate systemctl commands +- Check failed services +- Basic systemd validation diff --git a/Runner/suites/Platform/systemd/checkFailedServices/README.md b/Runner/suites/Platform/systemd/checkFailedServices/README.md new file mode 100755 index 00000000..cfc667c6 --- /dev/null +++ b/Runner/suites/Platform/systemd/checkFailedServices/README.md @@ -0,0 +1,50 @@ +# checkFailedServices Validation Test + +## Overview + +This test script checks for any failed systemd services on the device. It is intended for use on platforms running systemd and is part of the Qualcomm Linux Testkit. + +## Usage + +1. Ensure the testkit environment is set up and the board has systemd as init manager. +2. Make the script executable if not already so: + ```sh + chmod +x run.sh + ``` +3. Run the test: + ```sh + ./run.sh + ``` +4. Check the result: + - If the test passes, `checkFailedServices.res` will contain `checkFailedServices PASS`. + - If the test fails, `checkFailedServices.res` will contain `checkFailedServices FAIL` and the failed services will be logged. + +## Integration + +This test can be invoked by the top-level runner as: +```sh +cd Runner +./run-test.sh checkFailedServices +``` +The `.res` file can be parsed by CI/LAVA to determine the overall test status. + +## Result Format + +- **PASS**: No failed services detected. +- **FAIL**: One or more services are in a failed state. + +The result is written to `checkFailedServices.res` in the same directory. + +## Dependencies + +- **systemctl**: Must be available and functional (systemd-based system). +- **POSIX shell**: Script is written for `/bin/sh`. + +## Logging + +- Uses `log_info`, `log_pass`, and `log_fail` from `functestlib.sh` for standardized output. + +## License + +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +SPDX-License-Identifier: BSD-3-Clause-Clear diff --git a/Runner/suites/Platform/systemd/checkFailedServices/run.sh b/Runner/suites/Platform/systemd/checkFailedServices/run.sh new file mode 100755 index 00000000..d4a11d3a --- /dev/null +++ b/Runner/suites/Platform/systemd/checkFailedServices/run.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Robustly find and source init_env +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +# Only source if not already loaded (idempotent) +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# Always source functestlib.sh, using $TOOLS exported by init_env +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="checkFailedServices" +test_path=$(find_test_case_by_name "$TESTNAME") +cd "$test_path" || exit 1 +res_file="./$TESTNAME.res" + +# Function to check for any failed services and print them +check_failed_services() { + log_info "----------------------------------------------------" + log_info "-------- Starting $TESTNAME Functional Test --------" + failed_services=$(systemctl --failed --no-legend --plain | awk '{print $1}') + if [ -z "$failed_services" ]; then + log_pass "No service is in failed state on device" + echo "$TESTNAME PASS" > "$res_file" + else + log_fail "------ List of failed services --------" + log_fail "$failed_services" + log_fail "--------------------------------------" + echo "$TESTNAME FAIL" > "$res_file" + fi + log_info "----------------------------------------------------" + log_info "-------- Stopping $TESTNAME Functional Test --------" +} + +# Call the functions +check_failed_services diff --git a/Runner/suites/Platform/systemd/systemctlStartStop/README.md b/Runner/suites/Platform/systemd/systemctlStartStop/README.md new file mode 100755 index 00000000..6cf32002 --- /dev/null +++ b/Runner/suites/Platform/systemd/systemctlStartStop/README.md @@ -0,0 +1,53 @@ +# systemctlStartStop + +## Overview + +This script tests the ability to stop and start the `systemd-user-sessions.service` using `systemctl`. It is intended for use on platforms running systemd and is part of the Qualcomm Linux Testkit. + +## How It Works + +- The script robustly locates and sources the `init_env` environment setup file. +- It sources `functestlib.sh` for logging and utility functions. +- It checks if `systemd-user-sessions.service` is active. +- It attempts to stop the service and verifies it is stopped. +- It then starts the service again and verifies it is running. +- Results are logged and written to `systemctlStartStop.res`. + +## Usage + +1. Ensure the testkit environment is set up and the board is running systemd. +2. Make the script executable if not already so: + ```sh + chmod +x run.sh + ``` +3. Run the test(requires sudo access): + ```sh + ./run.sh + ``` +4. Check the result in `systemctlStartStop.res`: + - `systemctlStartStop PASS` if the service was stopped and started successfully. + - `systemctlStartStop FAIL` if any step failed. + +## Integration + +This test can be invoked by the top-level runner as: +```sh +cd Runner +./run-test.sh systemctlStartStop +``` +The `.res` file will be parsed by CI/LAVA to determine the overall test status. + +## Dependencies + +- `systemctl` (systemd-based system) +- POSIX shell (`/bin/sh`) +- `init_env` and `functestlib.sh` from the testkit + +## Logging + +- Uses `log_info`, `log_pass`, and `log_fail` from `functestlib.sh` for standardized output. + +## License + +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +SPDX-License-Identifier: BSD-3-Clause-Clear diff --git a/Runner/suites/Platform/systemd/systemctlStartStop/run.sh b/Runner/suites/Platform/systemd/systemctlStartStop/run.sh new file mode 100755 index 00000000..fa7a0bf5 --- /dev/null +++ b/Runner/suites/Platform/systemd/systemctlStartStop/run.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Robustly find and source init_env +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +# Only source if not already loaded (idempotent) +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# Always source functestlib.sh, using $TOOLS exported by init_env +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="systemctlStartStop" +test_path=$(find_test_case_by_name "$TESTNAME") +cd "$test_path" || exit 1 +res_file="./$TESTNAME.res" + +# Function to check if systemctl start command works for systemd-user-sessions.service +check_systemctl_start_stop() { + log_info "----------------------------------------------------" + log_info "-------- Starting $TESTNAME Functional Test --------" + log_info "-------- Stopping systemd-user-sessions.service --------" + if ! systemctl is-active --quiet systemd-user-sessions.service; then + log_info "Service is not active before proceeding with stop command" + echo "$TESTNAME Fail" > "$res_file" + exit 1 + fi + systemctl stop systemd-user-sessions.service + sleep 5 + if systemctl is-active --quiet systemd-user-sessions.service; then + log_fail "Failed to stop service systemd-user-sessions.service" + echo "$TESTNAME FAIL" > "$res_file" + exit 1 + fi + log_pass "Successfully stopped service systemd-user-sessions.service" + log_info "-------- Starting systemd-user-sessions.service --------" + systemctl start systemd-user-sessions.service + sleep 5 + if systemctl is-active --quiet systemd-user-sessions.service; then + log_pass "systemd-user-sessions.service started successfully with systemctl command" + echo "$TESTNAME PASS" > "$res_file" + else + log_fail "Failed to start systemd-user-sessions.service with systemctl start command" + echo "$TESTNAME FAIL" > "$res_file" + fi + log_info "----------------------------------------------------" + log_info "-------- Stopping $TESTNAME Functional Test --------" +} + + +# Call the functions +check_systemctl_start_stop diff --git a/Runner/suites/Platform/systemd/systemdPID/README.md b/Runner/suites/Platform/systemd/systemdPID/README.md new file mode 100755 index 00000000..e03c325c --- /dev/null +++ b/Runner/suites/Platform/systemd/systemdPID/README.md @@ -0,0 +1,51 @@ +# systemdPID + +## Overview + +This script verifies that the `systemd` process is running as PID 1 on the device. It is intended for use on platforms running systemd and is part of the Qualcomm Linux Testkit. + +## How It Works + +- The script robustly locates and sources the `init_env` environment setup file. +- It sources `functestlib.sh` for logging and utility functions. +- It checks if the process with PID 1 is `systemd` using `ps`. +- If `systemd` is PID 1, the test passes; otherwise, it fails. + +## Usage + +1. Ensure the testkit environment is set up and the board is having systemd as init manager. +2. Make the script executable if not already so: + ```sh + chmod +x run.sh + ``` +3. Run the test: + ```sh + ./run.sh + ``` +4. Check the result in `systemdPID.res`: + - `systemdPID PASS` if `systemd` is PID 1. + - `systemdPID FAIL` if not. + +## Integration + +This test can be invoked by the top-level runner as: +```sh +cd Runner +./run-test.sh systemdPID +``` +The `.res` file can be parsed by CI/LAVA to determine the overall test status. + +## Dependencies + +- `ps` +- POSIX shell (`/bin/sh`) +- `init_env` and `functestlib.sh` from the testkit + +## Logging + +- Uses `log_info`, `log_pass`, and `log_fail` from `functestlib.sh` for standardized output. + +## License + +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +SPDX-License-Identifier: BSD-3-Clause-Clear diff --git a/Runner/suites/Platform/systemd/systemdPID/run.sh b/Runner/suites/Platform/systemd/systemdPID/run.sh new file mode 100755 index 00000000..13669244 --- /dev/null +++ b/Runner/suites/Platform/systemd/systemdPID/run.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Robustly find and source init_env +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +# Only source if not already loaded (idempotent) +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# Always source functestlib.sh, using $TOOLS exported by init_env +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="systemdPID" +test_path=$(find_test_case_by_name "$TESTNAME") +cd "$test_path" || exit 1 +res_file="./$TESTNAME.res" + +# Function to check if systemd is running with PID 1 + +check_systemd_pid() { + log_info "----------------------------------------------------" + log_info "-------- Starting $TESTNAME Functional Test --------" + if [ "$(ps -p 1 -o comm=)" = "systemd" ]; then + log_pass "Systemd init started with PID 1" + echo "$TESTNAME PASS" > "$res_file" + else + log_fail "Systemd init did not start with PID 1" + echo "$TESTNAME FAIL" > "$res_file" + fi + log_info "----------------------------------------------------" + log_info "-------- Stopping $TESTNAME Functional Test --------" +} + +# Call the functions +check_systemd_pid