Skip to content

Commit

Permalink
Retire hwclock (BugFix) (#1134)
Browse files Browse the repository at this point in the history
Retire hwclock
  • Loading branch information
seankingyang authored Apr 3, 2024
1 parent 51710bb commit 4c58a14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
16 changes: 14 additions & 2 deletions providers/base/units/power-management/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,22 @@ id: power-management/rtc
flags: also-after-suspend
requires:
rtc.state == 'supported'
executable.name == 'hwclock'
cpuinfo.other != 'emulated by qemu'
user: root
command: hwclock -r
environ: RTC_DEVICE_FILE
command:
if [[ -n "$RTC_DEVICE_FILE" ]]; then
rtc_path="/sys/class/rtc/${RTC_DEVICE_FILE/#\/dev\/}"
else
rtc_path="/sys/class/rtc/rtc0"
fi
if [[ -f "${rtc_path}/since_epoch" ]]; then
rtc_time=$(cat "${rtc_path}/since_epoch")
echo "RTC time: ${rtc_time} seconds since epoch."
else
echo "RTC time information not available."
exit 1
fi
estimated_duration: 0.02
_summary: Test that RTC functions properly (if present)
_description:
Expand Down
15 changes: 7 additions & 8 deletions providers/base/units/rtc/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,18 @@ plugin: shell
user: root
category_id: rtc_category
estimated_duration: 5
environ:
command:
rtctime=$(date +"%s" -d "$( hwclock --rtc /dev/{rtc} -u)")
rtc_date=$(date -d "@$rtctime")
systime=$(date +"%s")
systime_date=$(date -d "@$systime")
result=$(("$systime" - "$rtctime"))
rtc_time=$(cat "/sys/class/rtc/{rtc}/since_epoch")
sys_time=$(date +"%s")
result=$(("$sys_time" - "$rtc_time"))
if [[ "$result" -le "5" ]]; then
echo "{rtc} Clock synchronized with System Clock"
echo "$rtc_date"
echo "RTC clock= $rtc_time"
else
echo "{rtc} Clock not synchronized with System Clock"
echo "System clock=" "$systime_date"
echo "RTC clock=" "$rtc_date"
echo "System clock= $sys_time"
echo "RTC clock= $rtc_time"
exit 1
fi
flags: also-after-suspend

0 comments on commit 4c58a14

Please sign in to comment.