From cde3e3dee4676dcd52a31fcb45fd04598e7f67b3 Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Fri, 28 Aug 2026 20:54:47 +0530 Subject: [PATCH 1/3] utils: add generic EFI text variable helpers Provide shared discovery, text payload verification, and safe efivarfs write support for suites that must select a firmware-provided boot configuration. The helpers preserve machine-readable command-substitution output and reuse the existing efivarfs mount restoration flow. Signed-off-by: Srikanth Muppandam --- Runner/utils/lib_system.sh | 155 +++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/Runner/utils/lib_system.sh b/Runner/utils/lib_system.sh index 80f590980..36b5f14bf 100755 --- a/Runner/utils/lib_system.sh +++ b/Runner/utils/lib_system.sh @@ -342,6 +342,161 @@ efi_variable_list_contains() { grep -Fxq "$var_name" "$EFI_LIST_LOG" 2>/dev/null } +# Find one EFI variable by its name suffix and print its GUID-qualified name. +# Args: +# $1 - EFI variable name without the GUID, for example VendorDtbOverlays +# $2 - file that receives efivar list output +# Diagnostic output is written to stderr so command-substitution callers only +# receive the variable name. +efi_find_variable_by_name() { + efvbn_name="$1" + efvbn_log_file="$2" + efvbn_matches="" + efvbn_count=0 + + if [ -z "$efvbn_name" ] || [ -z "$efvbn_log_file" ]; then + printf '%s\n' "efi_find_variable_by_name requires variable name and log file" >&2 + return 1 + fi + + if ! command -v efivar >/dev/null 2>&1; then + printf '%s\n' "efivar command is unavailable" >&2 + return 1 + fi + + if ! efivar -l > "$efvbn_log_file" 2>&1; then + printf '%s\n' "efivar could not list EFI variables" >&2 + return 1 + fi + + efvbn_matches="$(awk -v suffix="-$efvbn_name" ' + length($0) > length(suffix) && substr($0, length($0) - length(suffix) + 1) == suffix { + print + } + ' "$efvbn_log_file")" + efvbn_count="$(printf '%s\n' "$efvbn_matches" | awk 'NF { count++ } END { print count + 0 }')" + + if [ "$efvbn_count" -ne 1 ]; then + printf '%s\n' "Expected one EFI variable named $efvbn_name, found $efvbn_count" >&2 + return 1 + fi + + printf '%s\n' "$efvbn_matches" + return 0 +} + +# Return success when an EFI variable printout contains a text payload. +# Args: +# $1 - EFI variable name in GUID-Name form +# $2 - expected text payload, without a trailing newline +# $3 - file that receives efivar print output +efi_text_variable_matches() { + etvm_var_name="$1" + etvm_value="$2" + etvm_log_file="$3" + etvm_data_file="" + etvm_expected_bytes="" + etvm_expected_pattern="" + + if [ -z "$etvm_var_name" ] || [ -z "$etvm_value" ] || [ -z "$etvm_log_file" ]; then + log_warn "efi_text_variable_matches requires variable name, value, and log file" + return 1 + fi + + if ! command -v efivar >/dev/null 2>&1; then + log_warn "efivar command is unavailable" + return 1 + fi + + if ! efivar -n "$etvm_var_name" -p > "$etvm_log_file" 2>&1; then + return 1 + fi + + etvm_data_file="$(mktemp "${TMPDIR:-/tmp}/efivar_payload.XXXXXX" 2>/dev/null || true)" + if [ -z "$etvm_data_file" ]; then + log_warn "Could not create temporary EFI variable payload" + return 1 + fi + + if ! printf '%s' "$etvm_value" > "$etvm_data_file"; then + log_warn "Could not write temporary EFI variable payload" + rm -f "$etvm_data_file" + return 1 + fi + + etvm_expected_bytes="$(od -An -tx1 -v "$etvm_data_file" 2>/dev/null | tr '\n' ' ' | tr -s ' ' | sed 's/^ //; s/ $//')" + rm -f "$etvm_data_file" + + if [ -z "$etvm_expected_bytes" ]; then + log_warn "Could not derive EFI variable payload bytes" + return 1 + fi + + etvm_expected_pattern="$(printf '%s\n' "$etvm_expected_bytes" | sed 's/ /[[:space:]][[:space:]]*/g')" + grep -Eq "$etvm_expected_pattern" "$etvm_log_file" +} + +# Write a text payload to an EFI variable and verify its printed byte value. +# Args: +# $1 - EFI variable name in GUID-Name form +# $2 - text payload, written without a trailing newline +# $3 - file that receives efivar write and print output +# The caller is responsible for arranging efi_restore_efivarfs_ro during +# cleanup when efi_try_remount_rw changes the mount state. +efi_write_text_variable() { + ewtv_var_name="$1" + ewtv_value="$2" + ewtv_log_file="$3" + ewtv_data_file="" + + if [ -z "$ewtv_var_name" ] || [ -z "$ewtv_value" ] || [ -z "$ewtv_log_file" ]; then + log_warn "efi_write_text_variable requires variable name, value, and log file" + return 1 + fi + + if ! command -v efivar >/dev/null 2>&1; then + log_warn "efivar command is unavailable" + return 1 + fi + + if ! efi_mount_is_rw && ! efi_try_remount_rw; then + log_warn "efivarfs is not writable" + return 1 + fi + + ewtv_data_file="$(mktemp "${TMPDIR:-/tmp}/efivar_payload.XXXXXX" 2>/dev/null || true)" + if [ -z "$ewtv_data_file" ]; then + log_warn "Could not create temporary EFI variable payload" + return 1 + fi + + if ! printf '%s' "$ewtv_value" > "$ewtv_data_file"; then + log_warn "Could not write temporary EFI variable payload" + rm -f "$ewtv_data_file" + return 1 + fi + + if ! efivar -n "$ewtv_var_name" -w -f "$ewtv_data_file" > "$ewtv_log_file" 2>&1; then + log_warn "efivar write failed for $ewtv_var_name" + rm -f "$ewtv_data_file" + return 1 + fi + + rm -f "$ewtv_data_file" + + if ! efi_text_variable_matches \ + "$ewtv_var_name" \ + "$ewtv_value" \ + "$ewtv_log_file"; then + log_warn "EFI variable printout does not contain the requested payload" + return 1 + fi + + sync + log_info "EFI variable updated and verified: $ewtv_var_name" + return 0 +} + # --------------------------------------------------------------------------- # Compatibility wrappers for existing EFI_Variable_Validation/run.sh names # --------------------------------------------------------------------------- From fa142852d769207b48b7a0e1fac3f46f28d70050 Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Fri, 28 Aug 2026 20:55:09 +0530 Subject: [PATCH 2/3] camera: add desktop CAMX overlay preparation Allow Camera_NHX to recover the CAMX package set on Debian, Ubuntu, and CentOS only when --overlay is requested. With an explicit --fit-dtb value, discover VendorDtbOverlays dynamically, select the requested FIT DTB for the next boot, and report a clean reboot-required result before validation. Signed-off-by: Srikanth Muppandam --- Runner/config/pkg_command_map.conf | 13 ++ .../Camera/Camera_NHX/README_Camera_NHX.md | 57 ++++++- .../Multimedia/Camera/Camera_NHX/run.sh | 142 +++++++++++++++++- 3 files changed, 209 insertions(+), 3 deletions(-) diff --git a/Runner/config/pkg_command_map.conf b/Runner/config/pkg_command_map.conf index a7313dad3..f620c50a0 100755 --- a/Runner/config/pkg_command_map.conf +++ b/Runner/config/pkg_command_map.conf @@ -369,3 +369,16 @@ ubuntu:Sensors:ssc_drva_test=qcom-sensors-test-core qcom-sensors-test-apps centos:Sensors:ssc_sensor_info=qcom-sensing-hub centos:Sensors:see_workhorse=qcom-sensors-test-core qcom-sensors-test-apps centos:Sensors:ssc_drva_test=qcom-sensors-test-core qcom-sensors-test-apps + +# --------------------------------------------------------------------------- +# Camera NHX optional CAMX overlay package set. +# +# Installed only when Camera_NHX explicitly requests --overlay. Debian and +# Ubuntu use apt, while CentOS uses its configured RPM provider. No Yocto or +# opkg mapping is provided, so meta-qcom continues using its image-provided +# camera stack. +# --------------------------------------------------------------------------- + +debian:package-set:camera-nhx=camx-dkms camx-glymur libcamx-glymur1 camx-firmware-glymur camx-nhx +ubuntu:package-set:camera-nhx=camx-dkms camx-glymur libcamx-glymur1 camx-firmware-glymur camx-nhx +centos:package-set:camera-nhx=camx-dkms camx-glymur libcamx-glymur1 camx-firmware-glymur camx-nhx diff --git a/Runner/suites/Multimedia/Camera/Camera_NHX/README_Camera_NHX.md b/Runner/suites/Multimedia/Camera/Camera_NHX/README_Camera_NHX.md index 2539b8410..eb3359e2a 100644 --- a/Runner/suites/Multimedia/Camera/Camera_NHX/README_Camera_NHX.md +++ b/Runner/suites/Multimedia/Camera/Camera_NHX/README_Camera_NHX.md @@ -2,7 +2,7 @@ Camera NHX validation test for the Qualcomm CAMX proprietary camera stack. This test runs `nhx.sh`, collects generated image dumps, validates dumps (existence + non-zero size), and produces a PASS/FAIL `.res` file suitable for LAVA gating. -The test supports the legacy/default NHX flow and optional target-specific JSON selection for preview, video, preview+video, and snapshot validation. +The test supports the legacy/default NHX flow, optional target-specific JSON selection for preview, video, preview+video, and snapshot validation, and an opt-in desktop CAMX package and FIT-DTB selection flow. --- @@ -12,6 +12,8 @@ The test supports the legacy/default NHX flow and optional target-specific JSON - Utilities: - `Runner/utils/functestlib.sh` - `Runner/utils/camera/lib_camera.sh` + - `Runner/utils/lib_pkg_provider.sh` for optional desktop package recovery + - `Runner/utils/lib_system.sh` for EFI variable discovery and update - Target-specific NHX JSON configs: - `Runner/suites/Multimedia/Camera/Camera_NHX/Kodiak/*.json` - `Runner/suites/Multimedia/Camera/Camera_NHX/Lemans/*.json` @@ -104,6 +106,44 @@ Snapshot JSON files are currently expected only for targets where the files are --- +## Desktop CAMX overlay flow + +Yocto and meta-qcom LAVA images keep their image-provided camera stack and do +not use this flow. On Debian, Ubuntu, and CentOS, an explicit overlay request +installs the `camera-nhx` package set: + +```text +camx-dkms camx-glymur libcamx-glymur1 camx-firmware-glymur camx-nhx +``` + +To select a FIT DTB, pass its compatibility name with `--fit-dtb`. For CAMX, +the compatibility name is `camx`: + +```sh +./run.sh --overlay --fit-dtb camx +``` + +The test discovers the platform's `VendorDtbOverlays` EFI variable with +`efivar -l`. The EFI variable GUID is never supplied by the user or hardcoded +in the test. It writes the requested FIT DTB name without a trailing newline, +verifies the value through `efivar -p`, and synchronizes storage. + +When a new DTB selection is written, the test records `Camera_NHX SKIP` with a +reboot-required message instead of rebooting within the LAVA test shell. Reboot +the target, then rerun the same command to perform NHX validation with the new +device tree: + +```sh +reboot +./run.sh --overlay --fit-dtb camx +``` + +If the requested FIT DTB is already selected, the test continues directly to +the normal NHX checks. `--overlay` without `--fit-dtb` only performs the +optional package preparation and does not change the boot DTB. + +--- + ## NHX JSON selection ### Default behavior @@ -231,12 +271,19 @@ NHX JSON argument ## Command usage ```sh -./run.sh [--json JSON_FILE] [--target TARGET] [--help] +./run.sh [--overlay] [--fit-dtb NAME] [--json JSON_FILE] [--target TARGET] [--help] ``` Options: ```text +--overlay Install the optional Camera NHX CAMX package set on Debian, + Ubuntu, or CentOS. + +--fit-dtb NAME Select NAME as the FIT DTB compatibility name for the next + boot. Requires --overlay on a supported desktop distro. + Use camx to select the CAMX DTB overlay. + --json JSON_FILE NHX JSON file to pass to nhx.sh. Can be absolute, relative to Camera_NHX/, or relative to the target folder when --target is provided. @@ -253,6 +300,10 @@ Examples: ./run.sh ``` +```sh +./run.sh --overlay --fit-dtb camx +``` + ```sh ./run.sh --json Lemans/Prev_plus_Video_YUVNV12_MaxResolution_NHX.json ``` @@ -403,6 +454,8 @@ run: ### SKIP - Missing CAMX prerequisites, such as DT patterns, camera module artifact/loaded state, ICP firmware, CAMX packages, or `nhx.sh` +- The requested FIT DTB selection was written and a reboot is required before validation +- `VendorDtbOverlays` is unavailable when `--overlay --fit-dtb` was requested - `fdtdump` is not available or camera node evidence is inconclusive - Requested `--json` file is not found - Requested JSON filename is ambiguous and `--target` was not supplied diff --git a/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh b/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh index 6150c529a..5ebc37d1e 100755 --- a/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh +++ b/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh @@ -37,9 +37,17 @@ fi # shellcheck disable=SC1090,SC1091 . "$TOOLS/functestlib.sh" +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/lib_system.sh" + # shellcheck disable=SC1090,SC1091 . "$TOOLS/camera/lib_camera.sh" +if [ -r "$TOOLS/lib_pkg_provider.sh" ]; then + # shellcheck disable=SC1090,SC1091 + . "$TOOLS/lib_pkg_provider.sh" +fi + LOG_DIR="$SCRIPT_DIR/logs" OUT_DIR="$SCRIPT_DIR/out" DUMP_DIR="/var/cache/camera/nativehaltest" @@ -50,6 +58,8 @@ TS=$(date "+%Y%m%d_%H%M%S") RUN_LOG="$LOG_DIR/${TESTNAME}_${TS}.log" SUMMARY_TXT="$OUT_DIR/${TESTNAME}_summary_${TS}.txt" DMESG_DIR="$LOG_DIR/dmesg_${TS}" +CAMX_EFI_LOG="$LOG_DIR/${TESTNAME}_camx_efi_${TS}.log" +CAMX_EFI_LIST_LOG="$LOG_DIR/${TESTNAME}_camx_efi_list_${TS}.log" NHX_OUTDIR="$OUT_DIR/nhx_${TS}" @@ -70,9 +80,15 @@ NHX_JSON="${NHX_JSON:-}" NHX_TARGET="${NHX_TARGET:-}" NHX_JSON_RESOLVED="" NHX_JSON_ARG="" +OVERLAY_REQUESTED=0 +FIT_DTB_NAME="" # shellcheck disable=SC2317 cleanup() { + if command -v efi_restore_efivarfs_ro >/dev/null 2>&1; then + efi_restore_efivarfs_ro >/dev/null 2>&1 || true + fi + if [ "$CAM_SERVER_STOPPED_FOR_TEST" -eq 1 ] && [ "$CAM_SERVER_PRESENT" -eq 1 ]; then systemd_service_start_safe "cam-server" >/dev/null 2>&1 || true fi @@ -86,9 +102,15 @@ trap 'cleanup' EXIT INT TERM usage() { cat <&2 + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + FIT_DTB_NAME="$2" + shift 2 + ;; + --fit-dtb=*) + FIT_DTB_NAME="${1#--fit-dtb=}" + shift + ;; --json) if [ "$#" -lt 2 ]; then echo "[ERROR] --json requires an argument" >&2 @@ -146,6 +187,105 @@ while [ "$#" -gt 0 ]; do esac done +if [ "$OVERLAY_REQUESTED" -eq 1 ]; then + for required_helper in \ + pkg_provider_init \ + pkg_ensure_optional_package_set_present \ + pkg_verify_package_set_installed; do + if ! command -v "$required_helper" >/dev/null 2>&1; then + log_fail "$TESTNAME FAIL - required package helper is unavailable: $required_helper" + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 + fi + done + + pkg_provider_init + + if ! pkg_ensure_optional_package_set_present \ + camera-nhx \ + qli-staging \ + auto \ + --overlay; then + log_fail "$TESTNAME FAIL - failed to ensure Camera NHX CAMX package set" + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 + fi + + log_pass "Camera NHX CAMX package set is ready" + + CAMX_OVERLAY_OS_ID="$(pkg_detect_os_id 2>/dev/null || true)" + case "$CAMX_OVERLAY_OS_ID" in + debian|ubuntu|centos) + if [ -z "$FIT_DTB_NAME" ]; then + log_info "No FIT DTB compatibility name was requested, skipping EFI overlay selection" + else + + case "$FIT_DTB_NAME" in + *[!A-Za-z0-9._-]* ) + log_fail "$TESTNAME FAIL - invalid FIT DTB compatibility name: $FIT_DTB_NAME" + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 + ;; + esac + + for required_helper in \ + efi_find_variable_by_name \ + efi_text_variable_matches \ + efi_write_text_variable \ + efi_restore_efivarfs_ro; do + if ! command -v "$required_helper" >/dev/null 2>&1; then + log_fail "$TESTNAME FAIL - required EFI helper is unavailable: $required_helper" + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 + fi + done + + if ! CHECK_DEPS_NO_EXIT=1 check_dependencies efivar mount mktemp od tr sed grep sync awk; then + log_skip "$TESTNAME SKIP - CAMX overlay selection requires efivar and EFI runtime tools" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + + CAMX_DTB_OVERLAY_VARIABLE="$(efi_find_variable_by_name \ + VendorDtbOverlays \ + "$CAMX_EFI_LIST_LOG" 2>>"$CAMX_EFI_LOG")" + if [ -z "$CAMX_DTB_OVERLAY_VARIABLE" ]; then + log_skip "$TESTNAME SKIP - VendorDtbOverlays EFI variable was not found" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + + if efi_text_variable_matches \ + "$CAMX_DTB_OVERLAY_VARIABLE" \ + "$FIT_DTB_NAME" \ + "$CAMX_EFI_LOG"; then + log_info "FIT DTB compatibility name is already selected: $FIT_DTB_NAME" + else + log_info "Selecting FIT DTB compatibility name for the next boot: $FIT_DTB_NAME" + + if ! efi_write_text_variable \ + "$CAMX_DTB_OVERLAY_VARIABLE" \ + "$FIT_DTB_NAME" \ + "$CAMX_EFI_LOG"; then + log_fail "$TESTNAME FAIL - could not select FIT DTB compatibility name: $FIT_DTB_NAME" + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 + fi + + log_skip "$TESTNAME SKIP - FIT DTB compatibility name selected, reboot required before NHX validation" + echo "$TESTNAME SKIP" >"$RES_FILE" + exit 0 + fi + fi + ;; + *) + log_info "CAMX device-tree overlay selection is not applicable, os=${CAMX_OVERLAY_OS_ID:-unknown}" + ;; + esac +else + log_info "Camera NHX overlay package installation not requested" +fi + # ----------------------------------------------------------------------------- # Deps check # ----------------------------------------------------------------------------- From 5dc21322a58154062eef7edea73df20677fd0984 Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Mon, 31 Aug 2026 23:10:14 +0530 Subject: [PATCH 3/3] camera: restore qti camera server around NHX NHX requires the camera server to be stopped before it runs on desktop CAMX images. Prefer qti-cam-server.service, retain the legacy cam-server.service fallback, and restore only a service state changed by the test. Signed-off-by: Srikanth Muppandam --- .../Multimedia/Camera/Camera_NHX/run.sh | 79 ++++++++++++------- Runner/utils/functestlib.sh | 14 ++++ 2 files changed, 66 insertions(+), 27 deletions(-) diff --git a/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh b/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh index 5ebc37d1e..05d2dcbdf 100755 --- a/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh +++ b/Runner/suites/Multimedia/Camera/Camera_NHX/run.sh @@ -74,6 +74,7 @@ if [ -z "$MARKER" ]; then fi CAM_SERVER_PRESENT=0 +CAM_SERVER_SERVICE="" CAM_SERVER_STOPPED_FOR_TEST=0 NHX_JSON="${NHX_JSON:-}" @@ -90,7 +91,7 @@ cleanup() { fi if [ "$CAM_SERVER_STOPPED_FOR_TEST" -eq 1 ] && [ "$CAM_SERVER_PRESENT" -eq 1 ]; then - systemd_service_start_safe "cam-server" >/dev/null 2>&1 || true + systemd_service_start_safe "$CAM_SERVER_SERVICE" >/dev/null 2>&1 || true fi if [ -n "${MARKER:-}" ]; then @@ -492,36 +493,59 @@ log_info "NHX_OUTDIR=$NHX_OUTDIR" log_info "CKSUM_TOOL=${CKSUM_TOOL:-none}" # ----------------------------------------------------------------------------- -# cam-server stop before NHX +# Camera server stop before NHX # ----------------------------------------------------------------------------- -if systemd_service_exists "cam-server"; then +CAM_SERVER_SERVICE="$( + systemd_service_first_existing \ + "qti-cam-server.service" \ + "cam-server.service" \ + 2>/dev/null || true +)" + +if [ -n "$CAM_SERVER_SERVICE" ]; then CAM_SERVER_PRESENT=1 CAM_SERVER_TS_BEFORE_STOP='5 minutes ago' - log_info "cam-server status before stop" - systemd_service_status_log "cam-server BEFORE stop (status only)" "$RUN_LOG" "cam-server" || true + log_info "Camera server selected for NHX: $CAM_SERVER_SERVICE" + log_info "Camera server status before NHX" + systemd_service_status_log "Camera server BEFORE NHX (status only)" \ + "$RUN_LOG" "$CAM_SERVER_SERVICE" || true + + log_info "Camera server stdout before NHX" + systemd_service_stdout_since "Camera server BEFORE NHX (stdout recent)" \ + "$RUN_LOG" "$CAM_SERVER_TS_BEFORE_STOP" "$CAM_SERVER_SERVICE" || true - log_info "cam-server stdout before stop" - systemd_service_stdout_since "cam-server BEFORE stop (stdout recent)" \ - "$RUN_LOG" "$CAM_SERVER_TS_BEFORE_STOP" "cam-server.service" || true + if systemd_service_is_active "$CAM_SERVER_SERVICE"; then + log_info "Stopping active camera server before nhx.sh" + + if ! systemd_service_stop_safe "$CAM_SERVER_SERVICE"; then + log_fail "$TESTNAME FAIL - unable to stop active $CAM_SERVER_SERVICE before nhx.sh" + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 + fi + + if systemd_service_is_active "$CAM_SERVER_SERVICE"; then + log_fail "$TESTNAME FAIL - $CAM_SERVER_SERVICE remains active after stop request" + echo "$TESTNAME FAIL" >"$RES_FILE" + exit 0 + fi - log_info "Stopping cam-server before nhx.sh" - if systemd_service_stop_safe "cam-server"; then CAM_SERVER_STOPPED_FOR_TEST=1 CAM_SERVER_TS_AFTER_STOP="$(date '+%Y-%m-%d %H:%M:%S')" - log_info "cam-server status after stop" - systemd_service_status_log "cam-server AFTER stop (status only)" "$RUN_LOG" "cam-server" || true + log_info "Camera server status after stop" + systemd_service_status_log "Camera server AFTER stop (status only)" \ + "$RUN_LOG" "$CAM_SERVER_SERVICE" || true - log_info "cam-server stdout after stop" - systemd_service_stdout_since "cam-server AFTER stop (stdout since stop marker)" \ - "$RUN_LOG" "$CAM_SERVER_TS_AFTER_STOP" "cam-server.service" || true + log_info "Camera server stdout after stop" + systemd_service_stdout_since "Camera server AFTER stop (stdout since stop marker)" \ + "$RUN_LOG" "$CAM_SERVER_TS_AFTER_STOP" "$CAM_SERVER_SERVICE" || true else - log_warn "Failed to stop cam-server before nhx.sh" + log_info "Camera server was already inactive, leaving it inactive after NHX" fi else - log_info "cam-server service not present, continuing" + log_info "No qti-cam-server.service or cam-server.service present, continuing" fi # ----------------------------------------------------------------------------- @@ -616,25 +640,26 @@ else fi # ----------------------------------------------------------------------------- -# cam-server start after NHX +# Restore camera server state after NHX # ----------------------------------------------------------------------------- if [ "$CAM_SERVER_STOPPED_FOR_TEST" -eq 1 ]; then - log_info "Starting cam-server after nhx.sh" - if systemd_service_start_safe "cam-server"; then + log_info "Restoring camera server after nhx.sh: $CAM_SERVER_SERVICE" + if systemd_service_start_safe "$CAM_SERVER_SERVICE"; then CAM_SERVER_STOPPED_FOR_TEST=0 CAM_SERVER_TS_AFTER_START="$(date '+%Y-%m-%d %H:%M:%S')" - log_info "cam-server status after start" - systemd_service_status_log "cam-server AFTER start (status only)" "$RUN_LOG" "cam-server" || true + log_info "Camera server status after restore" + systemd_service_status_log "Camera server AFTER restore (status only)" \ + "$RUN_LOG" "$CAM_SERVER_SERVICE" || true - log_info "cam-server stdout after start" - systemd_service_stdout_since "cam-server AFTER start (stdout since start marker)" \ - "$RUN_LOG" "$CAM_SERVER_TS_AFTER_START" "cam-server.service" || true + log_info "Camera server stdout after restore" + systemd_service_stdout_since "Camera server AFTER restore (stdout since restore marker)" \ + "$RUN_LOG" "$CAM_SERVER_TS_AFTER_START" "$CAM_SERVER_SERVICE" || true else - log_warn "Failed to start cam-server after nhx.sh" + log_warn "Failed to restore camera server after nhx.sh: $CAM_SERVER_SERVICE" fi else - log_info "cam-server was not stopped for test, skipping restart" + log_info "Camera server state was not changed for NHX, skipping restore" fi # ----------------------------------------------------------------------------- diff --git a/Runner/utils/functestlib.sh b/Runner/utils/functestlib.sh index e8ab66ff8..2415afe94 100755 --- a/Runner/utils/functestlib.sh +++ b/Runner/utils/functestlib.sh @@ -4398,6 +4398,20 @@ systemd_service_exists() { systemctl cat "$svc" >/dev/null 2>&1 } +# Print the first existing systemd service/unit from the supplied candidates. +systemd_service_first_existing() { + for svc in "$@"; do + [ -n "$svc" ] || continue + + if systemd_service_exists "$svc"; then + printf '%s\n' "$svc" + return 0 + fi + done + + return 1 +} + # Check whether a systemd service/unit is currently active. systemd_service_is_active() { svc="$1"