Skip to content

Commit 220fc5a

Browse files
committed
Fix: Add validations to suspend_trigger (Bugfix)
* Run "systemctl list-jobs suspend" to check if there are suspend jobs running before running one more. * If "systemctl list-jobs suspend" detects suspend jobs running wait for a while before proceeding. * Set "set -o pipefail" on the Checkbox job definition for the job to be marked as "failed" when exiting on error.
1 parent aed87f5 commit 220fc5a

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

providers/base/bin/suspend_trigger.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ def main(args=sys.argv[1:]):
6767
str(args.sleep_delay),
6868
]
6969
suspend_cmd = ["systemctl", "suspend"]
70+
list_jobs_cmd = ["systemctl", "list-jobs", "*suspend*"]
71+
timeout = 10
72+
while timeout > 0:
73+
output = subprocess.check_output(
74+
list_jobs_cmd,
75+
stderr=subprocess.STDOUT,
76+
universal_newlines=True,
77+
).strip()
78+
if "No jobs running." in output or "No jobs listed." in output:
79+
break
80+
print("Suspend jobs ongoing, waiting...")
81+
time.sleep(1)
82+
timeout -= 1
83+
else:
84+
print("Timed out waiting for suspend jobs to finish")
85+
return 1
7086
print("Running: {}".format(" ".join(rtcwake_cmd)))
7187
subprocess.check_call(rtcwake_cmd)
7288
print(
@@ -80,6 +96,8 @@ def main(args=sys.argv[1:]):
8096
print("Removing {}...".format(log_path))
8197
os.remove(log_path)
8298

99+
return 0
100+
83101

84102
if __name__ == "__main__":
85103
sys.exit(main())

providers/base/units/stress/suspend_cycles_reboot.pxu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ estimated_duration: 75.0
7979
environ: PLAINBOX_SESSION_SHARE STRESS_S3_INIT_DELAY STRESS_S3_SLEEP_DELAY STRESS_S3_WAIT_DELAY LD_LIBRARY_PATH RTC_DEVICE_FILE
8080
user: root
8181
command:
82+
set -o pipefail
8283
echo "Current boot ID is: $(tr -d - < /proc/sys/kernel/random/boot_id)"
8384
suspend_trigger.py --wait "${STRESS_S3_INIT_DELAY:-120}" --check-delay "${STRESS_S3_WAIT_DELAY:-45}" --sleep-delay "${STRESS_S3_SLEEP_DELAY:-30}" --rtc-device "${RTC_DEVICE_FILE:-/dev/rtc0}" 2>&1 | tee -a "$PLAINBOX_SESSION_SHARE"/suspend_cycles_with_reboot_total.log
8485
summary:
@@ -105,6 +106,7 @@ environ: PLAINBOX_SESSION_SHARE STRESS_S3_INIT_DELAY STRESS_S3_SLEEP_DELAY STRES
105106
after: stress-tests/suspend_cycles_reboot{{suspend_reboot_previous}}
106107
user: root
107108
command:
109+
set -o pipefail
108110
echo "Current boot ID is: $(tr -d - < /proc/sys/kernel/random/boot_id)"
109111
suspend_trigger.py --wait "${STRESS_S3_INIT_DELAY:-120}" --check-delay "${STRESS_S3_WAIT_DELAY:-45}" --sleep-delay "${STRESS_S3_SLEEP_DELAY:-30}" --rtc-device "${RTC_DEVICE_FILE:-/dev/rtc0}" 2>&1 | tee -a "$PLAINBOX_SESSION_SHARE"/suspend_cycles_with_reboot_total.log
110112
summary:
@@ -129,6 +131,7 @@ environ: PLAINBOX_SESSION_SHARE STRESS_S3_INIT_DELAY STRESS_S3_SLEEP_DELAY STRES
129131
after: stress-tests/suspend_cycles_{{suspend_id_previous}}_reboot{{suspend_reboot_id}}
130132
user: root
131133
command:
134+
set -o pipefail
132135
echo "Current boot ID is: $(tr -d - < /proc/sys/kernel/random/boot_id)"
133136
suspend_trigger.py --check-delay "${STRESS_S3_WAIT_DELAY:-45}" --sleep-delay "${STRESS_S3_SLEEP_DELAY:-30}" --rtc-device "${RTC_DEVICE_FILE:-/dev/rtc0}" 2>&1 | tee -a "$PLAINBOX_SESSION_SHARE"/suspend_cycles_with_reboot_total.log
134137
summary:

0 commit comments

Comments
 (0)