All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tests/tcg/multiarch: Add tests for implemented real
@ 2020-01-20 16:09 Filip Bozuta
  2020-01-20 16:09 ` [PATCH 1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls Filip Bozuta
  2020-01-20 16:09 ` [PATCH 2/2] tests/tcg/multiarch: Add tests for implemented alsa sound timer ioctls Filip Bozuta
  0 siblings, 2 replies; 4+ messages in thread
From: Filip Bozuta @ 2020-01-20 16:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.bennee, laurent

This series covers tests for implemented rtc and alsa timer ioctls. The names
of ioctls that are covered by these tests can be found in patch descriptions.
The functionalities of each ioctl that is tested can be found in patches that
implement them.

Some of the features that are accessible through these ioctls are not supported
on all test host pc's. These tests were written so that the implemented ioctls
can be properly tested on pc's that support all of their features.

Both rtc and alsa timer test folders contain separate programs that test functionalities
of individual ioctls and one global program that tests multiple ioctls at once.
Individual tests were written manually while the global tests were obtained remotely and
modified so that they fit the QEMU coding style.

Filip Bozuta (2):
  tests/tcg/multiarch: Add tests for implemented rtc ioctls
  tests/tcg/multiarch: Add tests for implemented alsa sound timer ioctls

 .../Disable/disableEnhancedRead.c                  |  29 +++
 .../EnhancedRead-test/Enable/enableEnhancedRead.c  |  29 +++
 .../alsa-timer-ioctl-tests/GlobalTest/timer.c      | 158 ++++++++++++++
 .../Instructions-tests/Continue/continue.c         |  39 ++++
 .../Instructions-tests/Pause/pause.c               |  39 ++++
 .../Instructions-tests/Start/start.c               |  39 ++++
 .../Instructions-tests/Stop/stop.c                 |  39 ++++
 .../SelectedParameters-tests/Info/info.c           |  46 +++++
 .../SelectedParameters-tests/Params/params.c       |  44 ++++
 .../SelectedParameters-tests/Status/status.c       |  45 ++++
 .../alsa-timer-ioctl-tests/Selecting-test/select.c |  34 +++
 .../SpecifiedParameters-tests/Ginfo/ginfo.c        |  43 ++++
 .../SpecifiedParameters-tests/Gparams/gparams.c    |  37 ++++
 .../SpecifiedParameters-tests/Gstatus/gstatus.c    |  36 ++++
 .../Version-id-tests/NextDevice/nextDevice.c       |  34 +++
 .../Version-id-tests/Pversion/pversion.c           |  30 +++
 .../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 +++
 39 files changed, 1643 insertions(+)
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Disable/disableEnhancedRead.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Enable/enableEnhancedRead.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/GlobalTest/timer.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Continue/continue.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Pause/pause.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Start/start.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Stop/stop.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Info/info.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Params/params.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Status/status.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Selecting-test/select.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Ginfo/ginfo.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gparams/gparams.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gstatus/gstatus.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/NextDevice/nextDevice.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/Pversion/pversion.c
 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

-- 
2.7.4



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls
  2020-01-20 16:09 [PATCH 0/2] tests/tcg/multiarch: Add tests for implemented real Filip Bozuta
@ 2020-01-20 16:09 ` Filip Bozuta
  2020-01-21 16:57   ` Alex Bennée
  2020-01-20 16:09 ` [PATCH 2/2] tests/tcg/multiarch: Add tests for implemented alsa sound timer ioctls Filip Bozuta
  1 sibling, 1 reply; 4+ messages in thread
From: Filip Bozuta @ 2020-01-20 16:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.bennee, laurent

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

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;
+}
+
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tests/tcg/multiarch: Add tests for implemented alsa sound timer ioctls
  2020-01-20 16:09 [PATCH 0/2] tests/tcg/multiarch: Add tests for implemented real Filip Bozuta
  2020-01-20 16:09 ` [PATCH 1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls Filip Bozuta
@ 2020-01-20 16:09 ` Filip Bozuta
  1 sibling, 0 replies; 4+ messages in thread
From: Filip Bozuta @ 2020-01-20 16:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.bennee, laurent

This patch adds tests for following 14 implemented alsa timer ioctls:

* SNDRV_TIMER_IOCTL_PVERSION        * SNDRV_TIMER_IOCTL_INFO
* SNDRV_TIMER_IOCTL_NEXT_DEVICE     * SNDRV_TIMER_IOCTL_PARAMS
* SNDRV_TIMER_IOCTL_TREAD           * SNDRV_TIMER_IOCTL_STATUS
* SNDRV_TIMER_IOCTL_GINFO           * SNDRV_TIMER_IOCTL_START
* SNDRV_TIMER_IOCTL_GPARAMS         * SNDRV_TIMER_IOCTL_STOP
* SNDRV_TIMER_IOCTL_GSTATUS         * SNDRV_TIMER_IOCTL_CONTINUE
* SNDRV_TIMER_IOCTL_SELECT          * SNDRV_TIMER_IOCTL_PAUSE

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/alsa-timer-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 some alsa timer features or to run some simple
alsa timer instructions.

Besides tests for individual ioctls, a global alsa ioctl test was
added at "tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/timer.c".
This test file was downloaded from a git repository that contains
alsa ioctl test suite. This repository is located at
"https://github.com/takaswie/alsa-ioctl-test".
It is used to test all of the alsa timer ioctls at once by running
a test macro defined in that file. The file was modified a little
bit by adding an output line that shows which test passed and at
which test the program aborts. It was also modified so that it
doesn't have styling problems detected by 'scripts/checkpatch.pl'.

Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
 .../Disable/disableEnhancedRead.c                  |  29 ++++
 .../EnhancedRead-test/Enable/enableEnhancedRead.c  |  29 ++++
 .../alsa-timer-ioctl-tests/GlobalTest/timer.c      | 158 +++++++++++++++++++++
 .../Instructions-tests/Continue/continue.c         |  39 +++++
 .../Instructions-tests/Pause/pause.c               |  39 +++++
 .../Instructions-tests/Start/start.c               |  39 +++++
 .../Instructions-tests/Stop/stop.c                 |  39 +++++
 .../SelectedParameters-tests/Info/info.c           |  46 ++++++
 .../SelectedParameters-tests/Params/params.c       |  44 ++++++
 .../SelectedParameters-tests/Status/status.c       |  45 ++++++
 .../alsa-timer-ioctl-tests/Selecting-test/select.c |  34 +++++
 .../SpecifiedParameters-tests/Ginfo/ginfo.c        |  43 ++++++
 .../SpecifiedParameters-tests/Gparams/gparams.c    |  37 +++++
 .../SpecifiedParameters-tests/Gstatus/gstatus.c    |  36 +++++
 .../Version-id-tests/NextDevice/nextDevice.c       |  34 +++++
 .../Version-id-tests/Pversion/pversion.c           |  30 ++++
 16 files changed, 721 insertions(+)
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Disable/disableEnhancedRead.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Enable/enableEnhancedRead.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/GlobalTest/timer.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Continue/continue.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Pause/pause.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Start/start.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Stop/stop.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Info/info.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Params/params.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Status/status.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Selecting-test/select.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Ginfo/ginfo.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gparams/gparams.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gstatus/gstatus.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/NextDevice/nextDevice.c
 create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/Pversion/pversion.c

diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Disable/disableEnhancedRead.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Disable/disableEnhancedRead.c
new file mode 100644
index 0000000..2f930b6
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Disable/disableEnhancedRead.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int tread = 0;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_TREAD, &tread) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Enhanced read disabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Enable/enableEnhancedRead.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Enable/enableEnhancedRead.c
new file mode 100644
index 0000000..fd9dea6
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Enable/enableEnhancedRead.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int tread = 1;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_TREAD, &tread) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Enhanced read enabled!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/GlobalTest/timer.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/GlobalTest/timer.c
new file mode 100644
index 0000000..b7cfcbd
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/GlobalTest/timer.c
@@ -0,0 +1,158 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <sys/ioctl.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <sound/asound.h>
+
+static void build_system_timer_id(struct snd_timer_id *tid)
+{
+    tid->dev_class = SNDRV_TIMER_CLASS_GLOBAL;
+    tid->dev_sclass = SNDRV_TIMER_SCLASS_NONE;
+    tid->card = -1;
+    tid->device = SNDRV_TIMER_GLOBAL_SYSTEM;
+    tid->subdevice = 0;
+}
+
+#define TEST_IOCTL(fd, command, argument, expected)                    \
+    do {                                                               \
+        if (ioctl(fd, command, argument) < 0 && errno != expected) {   \
+            printf("%s: %s\n", #command, strerror(errno));             \
+            return false;                                              \
+        }                                                              \
+        printf("%s: Test passed!\n", #command);                        \
+        return true;                                                   \
+    } while (0)                                                         \
+
+static bool check_pversion(int fd)
+{
+    int version = 0;
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_PVERSION, &version, 0);
+}
+
+static bool check_next_device(int fd)
+{
+    struct snd_timer_id id = {0};
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_NEXT_DEVICE, &id, 0);
+}
+
+static bool check_tread(int fd)
+{
+    int tread = 1;
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_TREAD, &tread, 0);
+}
+
+static bool check_ginfo(int fd)
+{
+    struct snd_timer_ginfo ginfo = {0};
+    build_system_timer_id(&ginfo.tid);
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_GINFO, &ginfo, 0);
+}
+
+static bool check_gparams(int fd)
+{
+    struct snd_timer_gparams gparams = {0};
+    build_system_timer_id(&gparams.tid);
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_GPARAMS, &gparams, ENOSYS);
+}
+
+static bool check_gstatus(int fd)
+{
+    struct snd_timer_gstatus gstatus = {0};
+    build_system_timer_id(&gstatus.tid);
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_GSTATUS, &gstatus, 0);
+}
+
+static bool check_select(int fd)
+{
+    struct snd_timer_select select = {0};
+    build_system_timer_id(&select.id);
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_SELECT, &select, 0);
+}
+
+static bool check_info(int fd)
+{
+    struct snd_timer_info info = {0};
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_INFO, &info, 0);
+}
+
+static bool check_params(int fd)
+{
+    struct snd_timer_params params = {0};
+    params.ticks = 1;
+    params.filter = SNDRV_TIMER_EVENT_TICK;
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_PARAMS, &params, 0);
+}
+
+static bool check_status(int fd)
+{
+    struct snd_timer_status status = {0};
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_STATUS, &status, 0);
+}
+
+static bool check_start(int fd)
+{
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_START, NULL, 0);
+}
+
+static bool check_stop(int fd)
+{
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_STOP, NULL, 0);
+}
+
+static bool check_continue(int fd)
+{
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_CONTINUE, NULL, 0);
+}
+
+static bool check_pause(int fd)
+{
+    TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_PAUSE, NULL, 0);
+}
+
+int main(void)
+{
+    bool (*const funcs[])(int) = {
+        check_pversion,
+        check_next_device,
+        check_tread,
+        check_ginfo,
+        check_gparams,
+        check_gstatus,
+        check_select,
+        check_info,
+        check_params,
+        check_status,
+        check_start,
+        check_pause,
+        check_continue,
+        check_stop,
+        NULL,
+    };
+    unsigned int i;
+    int fd;
+
+    fd = open("/dev/snd/timer", O_RDONLY);
+    if (fd < 0) {
+        printf("%s\n", strerror(errno));
+        return EXIT_FAILURE;
+    }
+
+    i = 0;
+    while (funcs[i]) {
+        if (!funcs[i++](fd)) {
+            printf("Timer test aborts.\n");
+            return EXIT_FAILURE;
+        }
+    }
+
+    return EXIT_SUCCESS;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Continue/continue.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Continue/continue.c
new file mode 100644
index 0000000..09e256c
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Continue/continue.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_CONTINUE) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("Timer continued!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Pause/pause.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Pause/pause.c
new file mode 100644
index 0000000..fd57693
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Pause/pause.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_PAUSE) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("Timer paused!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Start/start.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Start/start.c
new file mode 100644
index 0000000..75ead93
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Start/start.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_START) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("Timer started!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Stop/stop.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Stop/stop.c
new file mode 100644
index 0000000..c28b0a3
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Stop/stop.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_STOP) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("Timer stopped!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Info/info.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Info/info.c
new file mode 100644
index 0000000..7a8ff28
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Info/info.c
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    struct snd_timer_info info = {0};
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_INFO, &info) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("flags: %u\n", info.flags);
+    printf("card: %d\n", info.card);
+    printf("id: %s\n", info.id);
+    printf("name: %s\n", info.name);
+    printf("resolution: %lu\n", info.resolution);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Params/params.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Params/params.c
new file mode 100644
index 0000000..c3953ca
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Params/params.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    struct snd_timer_params params = {0};
+    params.ticks = 1;
+    params.filter = SNDRV_TIMER_EVENT_TICK;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_PARAMS, &params) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("Parameters set!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Status/status.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Status/status.c
new file mode 100644
index 0000000..b56f4a5
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Status/status.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    struct snd_timer_status status = {0};
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_STATUS, &status) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("resolution: %d\n", status.resolution);
+    printf("lost: %d\n", status.lost);
+    printf("overrun: %d\n", status.overrun);
+    printf("queue: %d\n", status.queue);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/Selecting-test/select.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Selecting-test/select.c
new file mode 100644
index 0000000..75425f4
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Selecting-test/select.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_select select;
+    select.id = id;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) == ERROR) {
+        perror("ioctl:");
+        return -1;
+    }
+
+    printf("Global timer selected!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Ginfo/ginfo.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Ginfo/ginfo.c
new file mode 100644
index 0000000..cd5d1da
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Ginfo/ginfo.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_ginfo ginfo;
+    ginfo.tid = id;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_GINFO, &ginfo) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("flags: %u\n", ginfo.flags);
+    printf("card: %d\n", ginfo.card);
+    printf("id: %s\n", ginfo.id);
+    printf("name: %s\n", ginfo.name);
+    printf("reserved0: %lu\n", ginfo.reserved0);
+    printf("resolution: %lu\n", ginfo.resolution);
+    printf("resolution_min: %lu\n", ginfo.resolution_min);
+    printf("reolution_max: %lu\n", ginfo.resolution_max);
+    printf("clients: %u\n", ginfo.clients);
+    printf("reserved: %s\n", ginfo.reserved);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gparams/gparams.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gparams/gparams.c
new file mode 100644
index 0000000..012a49d
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gparams/gparams.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_ginfo ginfo;
+    ginfo.tid = id;
+
+    gparams.period_num = 2;
+    gparams.period_den = 2;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_GPARAMS, &gparams) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Parameters set!\n");
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gstatus/gstatus.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gstatus/gstatus.c
new file mode 100644
index 0000000..81a74ca
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gstatus/gstatus.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
+                              SNDRV_TIMER_SCLASS_NONE, -1,
+                              SNDRV_TIMER_GLOBAL_SYSTEM, 0};
+
+    struct snd_timer_ginfo ginfo;
+    ginfo.tid = id;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_GSTATUS, &gstatus) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("resolution: %lu\n", gstatus.resolution);
+    printf("resolution_num: %lu\n", gstatus.resolution_num);
+    printf("resolution_den: %lu\n", gstatus.resolution_den);
+
+    return 0;
+}
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/NextDevice/nextDevice.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/NextDevice/nextDevice.c
new file mode 100644
index 0000000..d3d1d3e
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/NextDevice/nextDevice.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    struct snd_timer_id id = {1, 0, 0, 0, 0};
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_NEXT_DEVICE, &id) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Timer dev_class: %d\n", id.dev_class);
+    printf("Timer dev_sclass: %d\n", id.dev_class);
+    printf("Timer card: %d\n", id.dev_class);
+    printf("Timer device: %d\n", id.dev_class);
+    printf("Timer subdevice: %d\n", id.dev_class);
+
+    return 0;
+}
+
diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/Pversion/pversion.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/Pversion/pversion.c
new file mode 100644
index 0000000..259846e
--- /dev/null
+++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/Pversion/pversion.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sound/asound.h>
+
+#define ERROR -1
+
+int main()
+{
+    int fd = open("/dev/snd/timer", O_RDWR);
+
+    if (fd == ERROR) {
+        perror("open");
+        return -1;
+    }
+
+    int version = 0;
+
+    if (ioctl(fd, SNDRV_TIMER_IOCTL_PVERSION, &version) == ERROR) {
+        perror("ioctl");
+        return -1;
+    }
+
+    printf("Timer version: %d\n", version);
+
+    return 0;
+}
+
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls
  2020-01-20 16:09 ` [PATCH 1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls Filip Bozuta
@ 2020-01-21 16:57   ` Alex Bennée
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2020-01-21 16:57 UTC (permalink / raw)
  To: Filip Bozuta; +Cc: qemu-devel, laurent


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).

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-21 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 16:09 [PATCH 0/2] tests/tcg/multiarch: Add tests for implemented real Filip Bozuta
2020-01-20 16:09 ` [PATCH 1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls Filip Bozuta
2020-01-21 16:57   ` Alex Bennée
2020-01-20 16:09 ` [PATCH 2/2] tests/tcg/multiarch: Add tests for implemented alsa sound timer ioctls Filip Bozuta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.