Skip to content

Commit

Permalink
Improve power-management/lid_close_suspend_open test case (Bugfix) (#…
Browse files Browse the repository at this point in the history
…1093)

* Fix some issues related with the test case power-management/lid_close_suspend_open (bugfix) (#1080)

- Make sure the test is executed at the appropriate time (i.e. not right after resuming the device)
- 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

* Add test power-management/lid back per Clair's comments

* Check the last suspend within the time of HoldoffTimeoutUSec as the review advised.

* Change the script per the new comments from Hanhsuan

* change the lid_close_suspend_open.sh per Stanley's advice

Co-authored-by: stanley31huang <[email protected]>

* Fix the error in ShellcheckTests

* Fix a wait time calculation issue and improve the PR per Pierre's comments

Co-authored-by: Pierre Equoy <[email protected]>

---------

Co-authored-by: stanley31huang <[email protected]>
Co-authored-by: Pierre Equoy <[email protected]>
  • Loading branch information
3 people authored Jul 4, 2024
1 parent 57e1715 commit 9409c50
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
17 changes: 16 additions & 1 deletion providers/base/bin/lid_close_suspend_open.sh
Original file line number Diff line number Diff line change
@@ -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~"
Expand Down
8 changes: 4 additions & 4 deletions providers/base/units/graphics/test-plan.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -296,15 +296,15 @@ _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
suspend/1_display_after_suspend_.*_graphics certification-status=blocker
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
Expand Down
1 change: 1 addition & 0 deletions providers/base/units/power-management/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9409c50

Please sign in to comment.