diff mbox series

[1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls

Message ID 1579536554-30701-2-git-send-email-Filip.Bozuta@rt-rk.com
State New
Headers show
Series [1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls | expand

Commit Message

Filip Bozuta Jan. 20, 2020, 4:09 p.m. UTC
This patch adds tests for following 22 implemented rtc ioctls:

* RTC_AIE_ON     * RTC_ALM_SET      * RTC_WKALM_SET
* RTC_AIE_OFF    * RTC_ALM_READ     * RTC_WKALM_RD
* RTC_UIE_ON     * RTC_RD_TIME      * RTC_PLL_GET
* RTC_UIE_OFF    * RTC_SET_TIME     * RTC_PLL_SET
* RTC_PIE_ON     * RTC_IRQP_READ    * RTC_VL_READ
* RTC_PIE_OFF    * RTC_IRQP_SET     * RTC_VL_CLR
* RTC_WIE_ON     * RTC_EPOCH_READ
* RTC_WIE_OFF    * RTC_EPOCH_SET

Names and descriptions of these ioctls can be found in patches that
implement them.

Test folder for these ioctl tests is located at
"tests/tcg/multiarch/rtc-ioctl-tests/"

Tests for individual ioctls are located in separate folders. These
folders are arranged by the same way these ioctls are implemented
in patches. These test files are simple programs that use these ioctls
to set/read or turn on/off some rtc features.

Besides tests for individual ioctls, a global rtc ioctl test was
added at "tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/rtc-test.c"
This test file was downloaded from linux kernel and is located at
"linux/drivers/rtc/rtc-test.c".
This file was modified a little bit so that it doesn't have styling
problems identified by "scripts/checkpatch.pl".
It is used to further test functionalities of some rtc ioctls by
running rtc clock at different frequencies.

Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
 .../Alarm-time-test/ReadAlarm/getAlarm.c           |  33 +++
 .../Alarm-time-test/ReadTime/getTime.c             |  35 ++++
 .../Alarm-time-test/SetAlarm/setAlarm.c            |  31 +++
 .../Alarm-time-test/SetTime/setTime.c              |  33 +++
 .../AlarmInterrupt/Disable/disableAlarmInterrupt.c |  29 +++
 .../AlarmInterrupt/Enable/enableAlarmInterrupt.c   |  29 +++
 .../Disable/disablePeriodicInterrupt.c             |  30 +++
 .../Enable/enablePeriodicInterrupt.c               |  29 +++
 .../Disable/disableUpdateInterrupt.c               |  29 +++
 .../UpdateInterrupt/Enable/enableUpdateInterrupt.c |  29 +++
 .../Disable/disableWatchdogInterrupt.c             |  30 +++
 .../Enable/enableWatchdogInterrupt.c               |  31 +++
 .../rtc-ioctl-tests/GlobalTest/rtc-test.c          | 227 +++++++++++++++++++++
 .../ReadEpoch/getEpoch.c                           |  32 +++
 .../ReadPeriodicInterrupt/getPeriodicInterrupt.c   |  31 +++
 .../SetEpoch/setEpoch.c                            |  32 +++
 .../SetPeriodicInterrupt/setPeriodicInterrupt.c    |  31 +++
 .../ReadPllCorrection/getPllCorrection.c           |  35 ++++
 .../SetPllCorrection/setPllCorrection.c            |  32 +++
 .../ClearVoltageLow/clearVoltageLow.c              |  32 +++
 .../ReadVoltageLow/getVoltageLow.c                 |  32 +++
 .../ReadWakeupAlarm/getWakeupAlarm.c               |  36 ++++
 .../SetWakeupAlarm/setWakeupAlarm.c                |  34 +++
 23 files changed, 922 insertions(+)
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadAlarm/getAlarm.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/getTime.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/setAlarm.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTime.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Disable/disablePeriodicInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Enable/enablePeriodicInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Disable/disableUpdateInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Disable/disableWatchdogInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Enable/enableWatchdogInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/rtc-test.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadEpoch/getEpoch.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodicInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetEpoch/setEpoch.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicInterrupt.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrection/getPllCorrection.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrection/setPllCorrection.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVoltageLow/clearVoltageLow.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/getVoltageLow.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/ReadWakeupAlarm/getWakeupAlarm.c
 create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c

Comments

Alex Bennée Jan. 21, 2020, 4:57 p.m. UTC | #1
Filip Bozuta <Filip.Bozuta@rt-rk.com> writes:

> This patch adds tests for following 22 implemented rtc ioctls:
>
> * RTC_AIE_ON     * RTC_ALM_SET      * RTC_WKALM_SET
> * RTC_AIE_OFF    * RTC_ALM_READ     * RTC_WKALM_RD
> * RTC_UIE_ON     * RTC_RD_TIME      * RTC_PLL_GET
> * RTC_UIE_OFF    * RTC_SET_TIME     * RTC_PLL_SET
> * RTC_PIE_ON     * RTC_IRQP_READ    * RTC_VL_READ
> * RTC_PIE_OFF    * RTC_IRQP_SET     * RTC_VL_CLR
> * RTC_WIE_ON     * RTC_EPOCH_READ
> * RTC_WIE_OFF    * RTC_EPOCH_SET
>
> Names and descriptions of these ioctls can be found in patches that
> implement them.
>
> Test folder for these ioctl tests is located at
> "tests/tcg/multiarch/rtc-ioctl-tests/"

There is a lot of repetition in these tests - any particular reason not
to just roll up the tests into a single executable with shared setup and
test code?

> Tests for individual ioctls are located in separate folders. These
> folders are arranged by the same way these ioctls are implemented
> in patches. These test files are simple programs that use these ioctls
> to set/read or turn on/off some rtc features.

The default handling of check-tcg won't pick up tests in
sub-directories:

  MULTIARCH_SRCS   =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c))

so I'm guessing it's not actually run in check-tcg.

> Besides tests for individual ioctls, a global rtc ioctl test was
> added at "tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/rtc-test.c"
> This test file was downloaded from linux kernel and is located at
> "linux/drivers/rtc/rtc-test.c".
> This file was modified a little bit so that it doesn't have styling
> problems identified by "scripts/checkpatch.pl".

This raises an interesting philosophical point about if we should be
porting tests for the linux source tree into QEMU.

> It is used to further test functionalities of some rtc ioctls by
> running rtc clock at different frequencies.
>
> Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
> ---
>  .../Alarm-time-test/ReadAlarm/getAlarm.c           |  33 +++
>  .../Alarm-time-test/ReadTime/getTime.c             |  35 ++++
>  .../Alarm-time-test/SetAlarm/setAlarm.c            |  31 +++
>  .../Alarm-time-test/SetTime/setTime.c              |  33 +++
>  .../AlarmInterrupt/Disable/disableAlarmInterrupt.c |  29 +++
>  .../AlarmInterrupt/Enable/enableAlarmInterrupt.c   |  29 +++
>  .../Disable/disablePeriodicInterrupt.c             |  30 +++
>  .../Enable/enablePeriodicInterrupt.c               |  29 +++
>  .../Disable/disableUpdateInterrupt.c               |  29 +++
>  .../UpdateInterrupt/Enable/enableUpdateInterrupt.c |  29 +++
>  .../Disable/disableWatchdogInterrupt.c             |  30 +++
>  .../Enable/enableWatchdogInterrupt.c               |  31 +++
>  .../rtc-ioctl-tests/GlobalTest/rtc-test.c          | 227 +++++++++++++++++++++
>  .../ReadEpoch/getEpoch.c                           |  32 +++
>  .../ReadPeriodicInterrupt/getPeriodicInterrupt.c   |  31 +++
>  .../SetEpoch/setEpoch.c                            |  32 +++
>  .../SetPeriodicInterrupt/setPeriodicInterrupt.c    |  31 +++
>  .../ReadPllCorrection/getPllCorrection.c           |  35 ++++
>  .../SetPllCorrection/setPllCorrection.c            |  32 +++
>  .../ClearVoltageLow/clearVoltageLow.c              |  32 +++
>  .../ReadVoltageLow/getVoltageLow.c                 |  32 +++
>  .../ReadWakeupAlarm/getWakeupAlarm.c               |  36 ++++
>  .../SetWakeupAlarm/setWakeupAlarm.c                |  34 +++

I can't say I'm keen about having a bunch of camelCased and PascalCased
filenames and directories.
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadAlarm/getAlarm.c
> @@ -0,0 +1,33 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/getTime.c
> @@ -0,0 +1,35 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/setAlarm.c
> @@ -0,0 +1,31 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTime.c
> @@ -0,0 +1,33 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <sys/capability.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c
> @@ -0,0 +1,29 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c
> @@ -0,0 +1,29 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Disable/disablePeriodicInterrupt.c
> @@ -0,0 +1,30 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Enable/enablePeriodicInterrupt.c
> @@ -0,0 +1,29 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Disable/disableUpdateInterrupt.c
> @@ -0,0 +1,29 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c
> @@ -0,0 +1,29 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Disable/disableWatchdogInterrupt.c
> @@ -0,0 +1,30 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Enable/enableWatchdogInterrupt.c
> @@ -0,0 +1,31 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadEpoch/getEpoch.c
> @@ -0,0 +1,32 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodicInterrupt.c
> @@ -0,0 +1,31 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
> +
> +    unsigned long interrupt_rate;
> +
> +    if (ioctl(fd, RTC_IRQP_READ, &interrupt_rate) == ERROR) {
> +        perror("ioctl");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetEpoch/setEpoch.c
> @@ -0,0 +1,32 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicInterrupt.c
> @@ -0,0 +1,31 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrection/getPllCorrection.c
> @@ -0,0 +1,35 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrection/setPllCorrection.c
> @@ -0,0 +1,32 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc0", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVoltageLow/clearVoltageLow.c
> @@ -0,0 +1,32 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/getVoltageLow.c
> @@ -0,0 +1,32 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <linux/ioctl.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/proc/driver/rtc", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/ReadWakeupAlarm/getWakeupAlarm.c
> @@ -0,0 +1,36 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>
> --- /dev/null
> +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c
> @@ -0,0 +1,34 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/rtc.h>
> +#include <fcntl.h>
> +#include <linux/input.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +#define ERROR -1
> +
> +int main()
> +{
> +
> +    int fd = open("/dev/rtc", O_RDONLY);
> +
> +    if (fd == ERROR) {
> +        perror("open");
> +        return -1;
> +    }
<snip>

By all means introduce the patches in multiple steps but I think a
single test file would be preferable and you could then share all the
setup logic (not that there is much).
diff mbox series

Patch

diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadAlarm/getAlarm.c b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadAlarm/getAlarm.c
new file mode 100644
index 0000000..7cd0958
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadAlarm/getAlarm.c
@@ -0,0 +1,33 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_time alarm_time;
+
+    if (ioctl(fd, RTC_ALM_READ, &alarm_time) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Alarm Second: %d, Alarm Minute: %d, Alarm Hour: %d\n",
+           alarm_time.tm_sec, alarm_time.tm_min, alarm_time.tm_hour);
+
+    return 0;
+}
+
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/getTime.c b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/getTime.c
new file mode 100644
index 0000000..ffb48ad
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/getTime.c
@@ -0,0 +1,35 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_time cur_time;
+
+    if (ioctl(fd, RTC_RD_TIME, &cur_time) < 0) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Second: %d, Minute: %d, Hour: %d, Day: %d, Month: %d, Year: %d\n",
+           cur_time.tm_sec, cur_time.tm_min, cur_time.tm_hour,
+           cur_time.tm_mday, cur_time.tm_mon, cur_time.tm_year);
+
+    printf("Time set!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/setAlarm.c b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/setAlarm.c
new file mode 100644
index 0000000..ad29e82
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/setAlarm.c
@@ -0,0 +1,31 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_time alarm_time = {13, 35, 12};
+
+    if (ioctl(fd, RTC_ALM_SET, &alarm_time) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Alarm set!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTime.c b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTime.c
new file mode 100644
index 0000000..51f721d
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTime.c
@@ -0,0 +1,33 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/capability.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_time time = {54, 34, 13, 26, 8, 120, 0, 0, 0};
+
+    if (ioctl(fd, RTC_SET_TIME, &time) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Time set!\n");
+
+    return 0;
+}
+
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c
new file mode 100644
index 0000000..bc89802
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c
@@ -0,0 +1,29 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_AIE_OFF) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Alarm interrupt disabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c
new file mode 100644
index 0000000..451cfe7
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c
@@ -0,0 +1,29 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_AIE_ON) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Alarm interrupt enabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Disable/disablePeriodicInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Disable/disablePeriodicInterrupt.c
new file mode 100644
index 0000000..5439794
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Disable/disablePeriodicInterrupt.c
@@ -0,0 +1,30 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_PIE_OFF) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Periodic interrupt disabled!\n");
+
+    return 0;
+}
+
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Enable/enablePeriodicInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Enable/enablePeriodicInterrupt.c
new file mode 100644
index 0000000..3d6b4e3
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Enable/enablePeriodicInterrupt.c
@@ -0,0 +1,29 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_PIE_ON) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Periodic interrupt enabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Disable/disableUpdateInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Disable/disableUpdateInterrupt.c
new file mode 100644
index 0000000..deda97f
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Disable/disableUpdateInterrupt.c
@@ -0,0 +1,29 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_UIE_OFF) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Update interrupt disabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c
new file mode 100644
index 0000000..f10fdf3
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c
@@ -0,0 +1,29 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_UIE_ON) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Update interrupt enabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Disable/disableWatchdogInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Disable/disableWatchdogInterrupt.c
new file mode 100644
index 0000000..bdd4e60
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Disable/disableWatchdogInterrupt.c
@@ -0,0 +1,30 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_WIE_OFF) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Watchdog interrupt disabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Enable/enableWatchdogInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Enable/enableWatchdogInterrupt.c
new file mode 100644
index 0000000..1aef0a6
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Enable/enableWatchdogInterrupt.c
@@ -0,0 +1,31 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    if (ioctl(fd, RTC_WIE_ON) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Watchdog interrupt enabled!\n");
+
+    return 0;
+}
+
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/rtc-test.c b/tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/rtc-test.c
new file mode 100644
index 0000000..f4799c2
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/rtc-test.c
@@ -0,0 +1,227 @@ 
+/*
+ *  Real Time Clock Driver Test/Example Program
+ *
+ *  Compile with:
+ *      gcc -s -Wall -Wstrict-prototypes rtctest.c -o rtctest
+ *
+ *  Copyright (C) 1996, Paul Gortmaker.
+ *
+ *  Released under the GNU General Public License, version 2,
+ *  included herein by reference.
+ *
+ */
+
+#include <stdio.h>
+#include <linux/rtc.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+int main(void)
+{
+
+    int i, fd, retval, irqcount = 0;
+    unsigned long tmp, data;
+    struct rtc_time rtc_tm;
+
+    fd = open("/dev/rtc", O_RDONLY);
+
+    if (fd == -1) {
+        perror("/dev/rtc");
+        exit(errno);
+    }
+
+    fprintf(stderr, "\n\t\t\tRTC Driver Test Example.\n\n");
+
+    /* Turn on update interrupts (one per second) */
+    retval = ioctl(fd, RTC_UIE_ON, 0);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    fprintf(stderr,
+            "Counting 5 update (1/sec) interrupts from reading /dev/rtc:");
+    fflush(stderr);
+
+    for (i = 1; i < 6; i++) {
+        /* This read will block */
+        retval = read(fd, &data, sizeof(unsigned long));
+
+        if (retval == -1) {
+            perror("read");
+            exit(errno);
+        }
+
+        fprintf(stderr, " %d", i);
+        fflush(stderr);
+        irqcount++;
+    }
+
+    fprintf(stderr, "\nAgain, from using select(2) on /dev/rtc:");
+    fflush(stderr);
+
+    for (i = 1; i < 6; i++) {
+        struct timeval tv = {5, 0};    /* 5 second timeout on select */
+        fd_set readfds;
+
+        FD_ZERO(&readfds);
+        FD_SET(fd, &readfds);
+
+        /* The select will wait until an RTC interrupt happens. */
+        retval = select(fd + 1, &readfds, NULL, NULL, &tv);
+        if (retval == -1) {
+            perror("select");
+            exit(errno);
+        }
+
+        /* This read won't block unlike the select-less case above. */
+        retval = read(fd, &data, sizeof(unsigned long));
+        if (retval == -1) {
+            perror("read");
+            exit(errno);
+        }
+
+        fprintf(stderr, " %d", i);
+        fflush(stderr);
+        irqcount++;
+    }
+
+    /* Turn off update interrupts */
+    retval = ioctl(fd, RTC_UIE_OFF, 0);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    /* Read the RTC time/date */
+    retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    fprintf(stderr, "\n\nCurrent RTC date/time is %d-%d-%d, %02d:%02d:%02d.\n",
+            rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900,
+            rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
+
+    /* Set the alarm to 5 sec in the future, and check for rollover */
+    rtc_tm.tm_sec += 5;
+    if (rtc_tm.tm_sec >= 60) {
+        rtc_tm.tm_sec %= 60;
+        rtc_tm.tm_min++;
+    }
+
+    if (rtc_tm.tm_min == 60) {
+        rtc_tm.tm_min = 0;
+        rtc_tm.tm_hour++;
+    }
+
+    if (rtc_tm.tm_hour == 24) {
+        rtc_tm.tm_hour = 0;
+    }
+
+    retval = ioctl(fd, RTC_ALM_SET, &rtc_tm);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    /* Read the current alarm settings */
+    retval = ioctl(fd, RTC_ALM_READ, &rtc_tm);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    fprintf(stderr, "Alarm time now set to %02d:%02d:%02d.\n",
+            rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
+
+    /* Enable alarm interrupts */
+    retval = ioctl(fd, RTC_AIE_ON, 0);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    fprintf(stderr, "Waiting 5 seconds for alarm...");
+    fflush(stderr);
+    /* This blocks until the alarm ring causes an interrupt */
+    retval = read(fd, &data, sizeof(unsigned long));
+    if (retval == -1) {
+        perror("read");
+        exit(errno);
+    }
+
+    irqcount++;
+    fprintf(stderr, " okay. Alarm rang.\n");
+
+    /* Disable alarm interrupts */
+    retval = ioctl(fd, RTC_AIE_OFF, 0);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    /* Read periodic IRQ rate */
+    retval = ioctl(fd, RTC_IRQP_READ, &tmp);
+    if (retval == -1) {
+        perror("ioctl");
+        exit(errno);
+    }
+
+    fprintf(stderr, "\nPeriodic IRQ rate was %ldHz.\n", tmp);
+
+    fprintf(stderr, "Counting 20 interrupts at:");
+    fflush(stderr);
+
+    /* The frequencies 128Hz, 256Hz, ... 8192Hz are only allowed for root. */
+    for (tmp = 2; tmp <= 64; tmp *= 2) {
+
+        retval = ioctl(fd, RTC_IRQP_SET, tmp);
+        if (retval == -1) {
+            perror("ioctl");
+            exit(errno);
+        }
+
+        fprintf(stderr, "\n%ldHz:\t", tmp);
+        fflush(stderr);
+
+        /* Enable periodic interrupts */
+        retval = ioctl(fd, RTC_PIE_ON, 0);
+        if (retval == -1) {
+            perror("ioctl");
+            exit(errno);
+        }
+
+        for (i = 1; i < 21; i++) {
+            /* This blocks */
+            retval = read(fd, &data, sizeof(unsigned long));
+            if (retval == -1) {
+                perror("read");
+                exit(errno);
+            }
+            fprintf(stderr, " %d", i);
+            fflush(stderr);
+            irqcount++;
+        }
+
+        /* Disable periodic interrupts */
+        retval = ioctl(fd, RTC_PIE_OFF, 0);
+        if (retval == -1) {
+            perror("ioctl");
+            exit(errno);
+        }
+    }
+
+    fprintf(stderr, "\n\n\t\t\t *** Test complete ***\n");
+    fprintf(stderr, "\nTyping \"cat /proc/interrupts\" will show %d
+            more events on IRQ 8.\n\n", irqcount);
+
+    close(fd);
+    return 0;
+
+} /* end main */
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadEpoch/getEpoch.c b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadEpoch/getEpoch.c
new file mode 100644
index 0000000..09c18ef
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadEpoch/getEpoch.c
@@ -0,0 +1,32 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int epoch;
+
+    if (ioctl(fd, RTC_EPOCH_READ, &epoch) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Epoch: %d\n", epoch);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodicInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodicInterrupt.c
new file mode 100644
index 0000000..4591783
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodicInterrupt.c
@@ -0,0 +1,31 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    unsigned long interrupt_rate;
+
+    if (ioctl(fd, RTC_IRQP_READ, &interrupt_rate) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Interrupt rate: %d\n", interrupt_rate);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetEpoch/setEpoch.c b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetEpoch/setEpoch.c
new file mode 100644
index 0000000..a3567c6
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetEpoch/setEpoch.c
@@ -0,0 +1,32 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int epoch = 5;
+
+    if (ioctl(fd, RTC_EPOCH_SET, epoch) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Epoch set!\n", epoch);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicInterrupt.c
new file mode 100644
index 0000000..a0c78fe
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicInterrupt.c
@@ -0,0 +1,31 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int interrupt_rate = 32;
+
+    if (ioctl(fd, RTC_IRQP_SET, interrupt_rate) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Periodic interrupt_rate %d is set!\n", interrupt_rate);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrection/getPllCorrection.c b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrection/getPllCorrection.c
new file mode 100644
index 0000000..2104050
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrection/getPllCorrection.c
@@ -0,0 +1,35 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_pll_info info;
+
+    if (ioctl(fd, RTC_PLL_GET, &info) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Pll control: %d, Pll value: %d, Pll max: %d,
+            Pll min: %d, Pll posmult: %d, Pll negmult: %d,  Pll clock: %ld\n",
+            info.pll_ctrl, info.pll_value, info.pll_max, info.pll_min,
+            info.pll_posmult, info.pll_negmult, info.pll_clock);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrection/setPllCorrection.c b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrection/setPllCorrection.c
new file mode 100644
index 0000000..176e895
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrection/setPllCorrection.c
@@ -0,0 +1,32 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc0", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_pll_info info = {1, 1, 1, 1, 1, 1, 1};
+
+    if (ioctl(fd, RTC_PLL_SET, &info) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Pll correction set!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVoltageLow/clearVoltageLow.c b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVoltageLow/clearVoltageLow.c
new file mode 100644
index 0000000..ba14fe4
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVoltageLow/clearVoltageLow.c
@@ -0,0 +1,32 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int voltage;
+
+    if (ioctl(fd, RTC_VL_CLR) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Voltage low cleared");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/getVoltageLow.c b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/getVoltageLow.c
new file mode 100644
index 0000000..8d90329
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/getVoltageLow.c
@@ -0,0 +1,32 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ioctl.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/proc/driver/rtc", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int voltage;
+
+    if (ioctl(fd, RTC_VL_READ, &voltage) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Voltage low: %d\n", voltage);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/ReadWakeupAlarm/getWakeupAlarm.c b/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/ReadWakeupAlarm/getWakeupAlarm.c
new file mode 100644
index 0000000..d81238f
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/ReadWakeupAlarm/getWakeupAlarm.c
@@ -0,0 +1,36 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_wkalrm alarm;
+
+    if (ioctl(fd, RTC_WKALM_RD, &alarm) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Alarm enabled: %d, Alarm pending: %d, Alarm second %d,
+            Alarm minute: %d, Alarm hour: %d, Alarm day: %d,
+            Alarm month: %d\n",
+            alarm.enabled, alarm.pending, alarm.time.tm_sec, alarm.time.tm_min,
+            alarm.time.tm_hour, alarm.time.tm_mday, alarm.time.tm_mon,
+            alarm.time.tm_year);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c b/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c
new file mode 100644
index 0000000..db0552a
--- /dev/null
+++ b/tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c
@@ -0,0 +1,34 @@ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define ERROR -1
+
+int main()
+{
+
+    int fd = open("/dev/rtc", O_RDONLY);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct rtc_time time = {25, 30, 10, 27, 8, 12, 0, 0, 0};
+
+    struct rtc_wkalrm alarm = {0, 0, time};
+
+    if (ioctl(fd, RTC_WKALM_SET, &alarm) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Wakeup alarm set!\n");
+
+    return 0;
+}
+