Skip to content

Commit

Permalink
Fix a wait time calculation issue and improve the PR per Pierre's com…
Browse files Browse the repository at this point in the history
…ments

Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>
  • Loading branch information
eugene-yujinwu and pieqq committed Jun 28, 2024
1 parent 3b529c4 commit 90ccfd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions providers/base/bin/lid_close_suspend_open.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion providers/base/units/power-management/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 90ccfd7

Please sign in to comment.