Commit 684f0446 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Enric Balletbo i Serra

Add a test for Real-Time-Clocks

Most machines have a Real Time Clock which can be used to track
the pass of time and as a wake alarm. Add a test case for RTCs.
Signed-off-by: 's avatarJavier Martinez Canillas <javier.martinez@collabora.co.uk>
parents
Test for Real Time Clocks
This test checks if all the RTC in the system are working correctly by
setting the hwclock, checking if the since_epoch value is incremented
and firing a wake alarm IRQ.
profiles:
- name: odroid-x2
variables:
device-type: odroid-x2
fdtfile: exynos4412-odroidx2
- name: odroid-xu3
variables:
device-type: odroid-xu3
fdtfile: exynos5422-odroidxu3
- name: snow
variables:
device-type: snow
fdtfile: exynos5250-snow
- name: peach-pi
variables:
device-type: peach-pi
fdtfile: exynos5800-peach-pi
{
"actions": [
{
"command": "deploy_kernel",
"parameters": {
"target_type": "ubuntu",
"dtb": "{{kernbase}}/{{fdtfile}}.dtb",
"kernel": "{{kernbase}}/zImage",
"nfsrootfs": "{{nfsrootfs}}",
"login_commands": [
"sudo su"
],
"login_prompt": "login:",
"password": "collabora",
"password_prompt": "Password:",
"username": "collabora"
}
},
{
"command": "boot_image",
"parameters": {
"test_image_prompt": "root@singularity"
}
},
{
"command": "lava_test_shell",
"parameters": {
"testdef_repos": [
{
"git-repo": "{{repobase}}/test-definitions.git",
"testdef": "kernel/rtc/rtc-test.yaml"
}
],
"timeout": 360
}
},
{
"command": "submit_results",
"parameters": {
"server": "https://lava.collabora.co.uk/RPC2/",
"stream": "{{bundle-stream}}"
}
}
],
"device_type": "{{device-type}}",
"job_name": "rtc-test-{{device-type}}",
"timeout": 480
}
metadata:
name: rtc-test
format: "Lava-Test-Shell Test Definition 1.0"
description: "Test for Real Time Clocks."
maintainer:
- javier.martinez@collabora.co.uk
scope:
- functional
devices:
- odroid-x2
- odroid-xu3
- peach-pi
- snow
environment:
- lava-test-shell
run:
steps:
- lava-test-case run-rtc-tests --shell ./kernel/rtc/scripts/rtc-test.sh
parse:
pattern: '(?P<test_case_id>\S*):\s+(?P<result>(pass|fail))'
#!/bin/bash
#
# rtc-test - Test for Real Time Clocks
#
TEST_NAME="rtc-test"
RTCPATH="/sys/class/rtc"
DEVS=($(ls ${RTCPATH}))
ret=0
for rtc in ${DEVS[@]}; do
name=$(cat ${RTCPATH}/${rtc}/name)
echo "Testing RTC ${name}"
echo "Set ${name} hardware clock"
hwclock -w -f /dev/${rtc}
ret=$?
if [ ${ret} -ne 0 ]; then
echo "set-hw-clock[${name}]:" "fail"
else
echo "set-hw-clock[${name}]:" "pass"
fi
echo "Check if ${name} since_epoch is incremented"
before=$(cat ${RTCPATH}/${rtc}/since_epoch)
sleep 1
after=$(cat ${RTCPATH}/${rtc}/since_epoch)
if [[ "${after}" -ne "${before} + 1" ]]; then
ret=1
echo "since-epoch-increment[${name}]:" "fail"
else
echo "since-epoch-increment[${name}]:" "pass"
fi
echo "Fire ${name} wakealarm IRQ"
echo +1 > ${RTCPATH}/${rtc}/wakealarm
sleep 1
value=$(cat ${RTCPATH}/${rtc}/wakealarm)
if [[ "${value}" -ne 0 ]]; then
ret=1
echo "fire-wake-alarm[${name}]:" "fail"
else
echo "fire-wake-alarm[${name}]:" "pass"
fi
done
exit ${ret}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment