#!/bin/sh RTC_DEVICE="/dev/rtc" if [ ! -e $RTC_DEVICE ]; then echo "SKIP: rtc device does not exist" exit 1 else echo "PASS: rtc device exists" fi /sbin/hwclock -f $RTC_DEVICE > /dev/null 2>&1 if [ $? -ne 0 ]; then echo "FAIL: rtc device open failed" exit 1 else echo "PASS: rtc device open success" fi dmesg -n 1 /sbin/hwclock --systohc > /dev/null 2>&1 if [ $? -ne 0 ]; then echo "FAIL: sync system clock and hardware clock failed" dmesg -n 7 exit 1 else echo "PASS: sync system clock and hardware clock success" fi dmesg -n 7 time_check() { RTC_TIME=$(/sbin/hwclock -r |awk '{print $4}') SYS_TIME=$(date +%m/%d/%Y-%X |awk '{print $1}' |awk -F- '{print $2}') if [ "$RTC_TIME" = "$SYS_TIME" ] ; then return 0 fi return 1 } exit_code=1 if time_check || time_check ; then echo "PASS: system time same with hardware time" exit_code=0 else echo "FAIL: system time different with hardware time" exit_code=1 fi exit $exit_code