From f8d173e147e8a818977269ec619c197b60dc389f Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Wed, 20 Mar 2024 17:54:24 +0800 Subject: [PATCH 1/7] Fix some issues related with the test case power-management/lid_close_suspend_open (bugfix) (#1080) - Include a note to ensure the test is executed at the appropriate time - Fix the typo in the test order number - Remove functionally similar test cases power-management/lid from the test plan - Adjust the place of test case to avoid running it just after the suspend case --- providers/base/units/graphics/test-plan.pxu | 6 ++---- providers/base/units/power-management/jobs.pxu | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/providers/base/units/graphics/test-plan.pxu b/providers/base/units/graphics/test-plan.pxu index 39ef346e09..9540d0faa0 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,7 @@ 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 id: after-suspend-graphics-discrete-gpu-cert-full unit: test plan @@ -296,8 +295,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 +302,7 @@ 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 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..93baf49842 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 hold off on reacting to lid events in a period of time after system startup or resume. So please make sure the system doesn't just resume from a suspend before run the test.) command: lid_close_suspend_open.sh _summary: Test the functionality of the laptop's lid sensor for suspend/resume actions. From 886464d5703236b71febd98366393e21ade2f4c1 Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Wed, 20 Mar 2024 17:54:24 +0800 Subject: [PATCH 2/7] Add test power-management/lid back per Clair's comments --- providers/base/units/graphics/test-plan.pxu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/providers/base/units/graphics/test-plan.pxu b/providers/base/units/graphics/test-plan.pxu index 9540d0faa0..8ace0f0b0d 100644 --- a/providers/base/units/graphics/test-plan.pxu +++ b/providers/base/units/graphics/test-plan.pxu @@ -219,6 +219,7 @@ include: 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 @@ -303,6 +304,7 @@ include: 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 From 779c743bc91dacd46a21a35e26196ad870dc20da Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Thu, 25 Apr 2024 18:08:23 +0800 Subject: [PATCH 3/7] Check the last suspend within the time of HoldoffTimeoutUSec as the review advised. --- providers/base/bin/lid_close_suspend_open.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/providers/base/bin/lid_close_suspend_open.sh b/providers/base/bin/lid_close_suspend_open.sh index 84ad0abef8..5e4ba9d3ff 100755 --- a/providers/base/bin/lid_close_suspend_open.sh +++ b/providers/base/bin/lid_close_suspend_open.sh @@ -1,4 +1,16 @@ -#! /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=$(echo "scale=0; $holdoff_timeout_usec / 1000000" | bc) + +if [ "$holdoff_timeout_sec" -ne 0 ]; then + while (journalctl --since "$holdoff_timeout_sec seconds ago" -b 0 -r | grep "suspend exit" >/dev/null 2>&1) + do + echo "The system just resume from suspend, please wait for $holdoff_timeout_sec seconds and continue the test" + sleep 1 + done +fi + 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~" From 44fb02aa5b6b9b454ddac5cde8233bce41e554fd Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Tue, 30 Apr 2024 15:54:52 +0800 Subject: [PATCH 4/7] Change the script per the new comments from Hanhsuan --- providers/base/bin/lid_close_suspend_open.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/providers/base/bin/lid_close_suspend_open.sh b/providers/base/bin/lid_close_suspend_open.sh index 5e4ba9d3ff..c497a91b9e 100755 --- a/providers/base/bin/lid_close_suspend_open.sh +++ b/providers/base/bin/lid_close_suspend_open.sh @@ -4,11 +4,16 @@ holdoff_timeout_usec=$(gdbus introspect --system --dest org.freedesktop.login1 - holdoff_timeout_sec=$(echo "scale=0; $holdoff_timeout_usec / 1000000" | bc) if [ "$holdoff_timeout_sec" -ne 0 ]; then + if (journalctl --since "$holdoff_timeout_sec seconds ago" -b 0 -r | grep "suspend exit" >/dev/null 2>&1); then + echo "The system just resume from suspend, the lid event will be hold off on in $holdoff_timeout_sec seconds" + echo "Please wait for the new prompt before starting the test." + fi while (journalctl --since "$holdoff_timeout_sec seconds ago" -b 0 -r | grep "suspend exit" >/dev/null 2>&1) do - echo "The system just resume from suspend, please wait for $holdoff_timeout_sec seconds and continue the test" - sleep 1 + echo "waiting... " + sleep 3 done + echo "" fi prev_suspend_number=$(cat /sys/power/suspend_stats/success) @@ -66,4 +71,4 @@ do done echo "=============================================================" echo "Lid is not closed within $runTime!!!" -exit 1 +exit 1 \ No newline at end of file From ed500bafc98ccb767757434b5d9a526591002538 Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Fri, 24 May 2024 18:17:46 +0800 Subject: [PATCH 5/7] change the lid_close_suspend_open.sh per Stanley's advice Co-authored-by: stanley31huang --- providers/base/bin/lid_close_suspend_open.sh | 22 +++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/providers/base/bin/lid_close_suspend_open.sh b/providers/base/bin/lid_close_suspend_open.sh index c497a91b9e..653fd1a474 100755 --- a/providers/base/bin/lid_close_suspend_open.sh +++ b/providers/base/bin/lid_close_suspend_open.sh @@ -3,18 +3,16 @@ 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=$(echo "scale=0; $holdoff_timeout_usec / 1000000" | bc) -if [ "$holdoff_timeout_sec" -ne 0 ]; then - if (journalctl --since "$holdoff_timeout_sec seconds ago" -b 0 -r | grep "suspend exit" >/dev/null 2>&1); then - echo "The system just resume from suspend, the lid event will be hold off on in $holdoff_timeout_sec seconds" - echo "Please wait for the new prompt before starting the test." - fi - while (journalctl --since "$holdoff_timeout_sec seconds ago" -b 0 -r | grep "suspend exit" >/dev/null 2>&1) - do - echo "waiting... " - sleep 3 - done - echo "" +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 + sleep_time=$(( $(date +"%s") - "$previous_sleep_time" )) + echo "sleep for $sleep_time seconds ..." + 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" @@ -71,4 +69,4 @@ do done echo "=============================================================" echo "Lid is not closed within $runTime!!!" -exit 1 \ No newline at end of file +exit 1 From 3b529c4a1b961877c6821b11779c6e61c540eb85 Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Thu, 27 Jun 2024 11:58:37 +0800 Subject: [PATCH 6/7] Fix the error in ShellcheckTests --- providers/base/bin/lid_close_suspend_open.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/base/bin/lid_close_suspend_open.sh b/providers/base/bin/lid_close_suspend_open.sh index 653fd1a474..06278c643e 100755 --- a/providers/base/bin/lid_close_suspend_open.sh +++ b/providers/base/bin/lid_close_suspend_open.sh @@ -6,7 +6,7 @@ holdoff_timeout_sec=$(echo "scale=0; $holdoff_timeout_usec / 1000000" | bc) 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 }') + previous_sleep_time=$(echo "$previous_sleep_log" | awk -F'.' '{ print $1 }') # sleep a period of time sleep_time=$(( $(date +"%s") - "$previous_sleep_time" )) echo "sleep for $sleep_time seconds ..." From 90ccfd72e47411f8705d03201e94b0e71bca2560 Mon Sep 17 00:00:00 2001 From: eugene2021 Date: Fri, 28 Jun 2024 16:42:15 +0800 Subject: [PATCH 7/7] Fix a wait time calculation issue and improve the PR per Pierre's comments Co-authored-by: Pierre Equoy --- providers/base/bin/lid_close_suspend_open.sh | 8 ++++---- providers/base/units/power-management/jobs.pxu | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/providers/base/bin/lid_close_suspend_open.sh b/providers/base/bin/lid_close_suspend_open.sh index 06278c643e..be63b916b9 100755 --- a/providers/base/bin/lid_close_suspend_open.sh +++ b/providers/base/bin/lid_close_suspend_open.sh @@ -1,15 +1,15 @@ #!/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=$(echo "scale=0; $holdoff_timeout_usec / 1000000" | bc) +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 - sleep_time=$(( $(date +"%s") - "$previous_sleep_time" )) - echo "sleep for $sleep_time seconds ..." + # 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" diff --git a/providers/base/units/power-management/jobs.pxu b/providers/base/units/power-management/jobs.pxu index 93baf49842..b37ad4232c 100644 --- a/providers/base/units/power-management/jobs.pxu +++ b/providers/base/units/power-management/jobs.pxu @@ -189,7 +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 hold off on reacting to lid events in a period of time after system startup or resume. So please make sure the system doesn't just resume from a suspend before run the test.) + 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.