diff --git a/providers/base/bin/lid_close_suspend_open.sh b/providers/base/bin/lid_close_suspend_open.sh index 84ad0abef8..be63b916b9 100755 --- a/providers/base/bin/lid_close_suspend_open.sh +++ b/providers/base/bin/lid_close_suspend_open.sh @@ -1,4 +1,19 @@ -#! /usr/bin/bash +#!/usr/bin/bash + +holdoff_timeout_usec=$(gdbus introspect --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 -p | grep HoldoffTimeoutUSec | awk '{print $5}' | awk -F\; '{print $1}') +holdoff_timeout_sec=$((holdoff_timeout_usec / 1000000)) + +previous_sleep_log=$(journalctl --output=short-unix --since "$holdoff_timeout_sec seconds ago" -b 0 -r | grep "suspend exit") +if [[ "$holdoff_timeout_sec" != 0 && "$previous_sleep_log" != "" ]]; then + # set the previous_sleep_time + previous_sleep_time=$(echo "$previous_sleep_log" | awk -F'.' '{ print $1 }') + # sleep a period of time. wait_time = holdoff_time - wakeup_time_from_last_suspend + sleep_time=$(("$holdoff_timeout_sec" - ($(date +"%s") - "$previous_sleep_time"))) + echo "DUT was resumed less than ${holdoff_timeout_sec} seconds ago. Waiting for ${sleep_time} seconds before running the test..." + sleep "$sleep_time" +fi +echo "System is ready for suspend test" + prev_suspend_number=$(cat /sys/power/suspend_stats/success) echo "Number of successful suspends until now: $prev_suspend_number" echo "Please close the lid and wait for 5 sec to make it suspend~" diff --git a/providers/base/units/graphics/test-plan.pxu b/providers/base/units/graphics/test-plan.pxu index 39ef346e09..8ace0f0b0d 100644 --- a/providers/base/units/graphics/test-plan.pxu +++ b/providers/base/units/graphics/test-plan.pxu @@ -210,8 +210,6 @@ include: # depending on the amount of graphic cards available on the SUT: # suspend/suspend_advanced_auto (one GPU) # or suspend/{{ index }}_suspend_after_switch_to_card_{{ product_slug }}_auto (two GPUs) - power-management/lid_close_suspend_open certification-status=blocker - power-management/lid certification-status=blocker after-suspend-miscellanea/chvt suspend/1_display_after_suspend_.*_graphics certification-status=blocker after-suspend-graphics/1_maximum_resolution_.* certification-status=blocker @@ -220,6 +218,8 @@ include: after-suspend-graphics/1_video_.* certification-status=blocker after-suspend-graphics/1_cycle_resolution_.* certification-status=non-blocker suspend/1_xrandr_screens_after_suspend.tar.gz_auto + power-management/lid_close_suspend_open certification-status=blocker + power-management/lid certification-status=blocker id: after-suspend-graphics-discrete-gpu-cert-full unit: test plan @@ -296,8 +296,6 @@ _description: After suspend tests (integrated GPU, certification blockers only) include: after-suspend-graphics/1_auto_switch_card_.* certification-status=blocker suspend/1_suspend_after_switch_to_card_.*_auto certification-status=blocker - power-management/lid_close_suspend_open certification-status=blocker - power-management/lid certification-status=blocker suspend/1_gl_support_after_suspend_.*_auto certification-status=blocker suspend/1_driver_version_after_suspend_.*_auto certification-status=blocker suspend/1_resolution_after_suspend_.*_auto certification-status=blocker @@ -305,6 +303,8 @@ include: suspend/1_glxgears_after_suspend_.*_graphics certification-status=blocker suspend/1_rotation_after_suspend_.*_graphics certification-status=blocker suspend/1_video_after_suspend_.*_graphics certification-status=blocker + power-management/lid_close_suspend_open certification-status=blocker + power-management/lid certification-status=blocker id: after-suspend-graphics-discrete-gpu-cert-blockers unit: test plan diff --git a/providers/base/units/power-management/jobs.pxu b/providers/base/units/power-management/jobs.pxu index b2468f2b61..b37ad4232c 100644 --- a/providers/base/units/power-management/jobs.pxu +++ b/providers/base/units/power-management/jobs.pxu @@ -189,6 +189,7 @@ _steps: 4. Open the lid _verification: Did the system suspend when the lid was closed, and resume back when the lid was opened? + Note: Systemd will not react to lid events if the DUT was just started or resumed. Please make sure the DUT has been running for long enough before running this test. command: lid_close_suspend_open.sh _summary: Test the functionality of the laptop's lid sensor for suspend/resume actions.