Skip to contentSkip to conversation

tests/tcg/multiarch: Add tests for implemented real

PATCH Superseded Filip Bozuta 2 participants 4 messages Jan 20, 2020 – Jan 21, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover tests/tcg/multiarch: Add tests for implemented real

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
Signature · 1 line
2.7.4
#1 lore raw

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

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.

---
 .../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
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadAlarm/getAlarm.c new file +33 -0
new file mode 100644
index 0000000..7cd0958
@@ -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;
+}
+
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/getTime.c new file +35 -0
new file mode 100644
index 0000000..ffb48ad
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/setAlarm.c new file +31 -0
new file mode 100644
index 0000000..ad29e82
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTime.c new file +33 -0
new file mode 100644
index 0000000..51f721d
@@ -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;
+}
+
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c new file +29 -0
new file mode 100644
index 0000000..bc89802
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c new file +29 -0
new file mode 100644
index 0000000..451cfe7
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Disable/disablePeriodicInterrupt.c new file +30 -0
new file mode 100644
index 0000000..5439794
@@ -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;
+}
+
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Enable/enablePeriodicInterrupt.c new file +29 -0
new file mode 100644
index 0000000..3d6b4e3
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Disable/disableUpdateInterrupt.c new file +29 -0
new file mode 100644
index 0000000..deda97f
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c new file +29 -0
new file mode 100644
index 0000000..f10fdf3
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Disable/disableWatchdogInterrupt.c new file +30 -0
new file mode 100644
index 0000000..bdd4e60
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Enable/enableWatchdogInterrupt.c new file +31 -0
new file mode 100644
index 0000000..1aef0a6
@@ -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;
+}
+
tests/tcg/multiarch/rtc-ioctl-tests/GlobalTest/rtc-test.c new file +227 -0

227 lines not on this page · raw message

tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadEpoch/getEpoch.c new file +32 -0
new file mode 100644
index 0000000..09c18ef
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodicInterrupt.c new file +31 -0
new file mode 100644
index 0000000..4591783
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetEpoch/setEpoch.c new file +32 -0
new file mode 100644
index 0000000..a3567c6
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicInterrupt.c new file +31 -0
new file mode 100644
index 0000000..a0c78fe
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrection/getPllCorrection.c new file +35 -0
new file mode 100644
index 0000000..2104050
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrection/setPllCorrection.c new file +32 -0
new file mode 100644
index 0000000..176e895
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVoltageLow/clearVoltageLow.c new file +32 -0
new file mode 100644
index 0000000..ba14fe4
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/getVoltageLow.c new file +32 -0
new file mode 100644
index 0000000..8d90329
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/ReadWakeupAlarm/getWakeupAlarm.c new file +36 -0
new file mode 100644
index 0000000..d81238f
@@ -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;
+}
tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c new file +34 -0
new file mode 100644
index 0000000..db0552a
@@ -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;
+}
+
Signature · 1 line
2.7.4
#2 lore raw

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

Quoted 11 lines · Filip Bozuta

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
Quoted 5 lines

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?

Quoted 4 lines

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.

Quoted 6 lines

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.

Quoted 20 lines

It is used to further test functionalities of some rtc ioctls by running rtc clock at different frequencies.

---
 .../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 +++
Quoted 8 lines
 .../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.

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadAlarm/getAlarm.c new file +19 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/getTime.c new file +19 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/setAlarm.c new file +19 -0
@@ -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>

Quoted 23 lines
tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTime.c new file +20 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c new file +19 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c new file +19 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Disable/disablePeriodicInterrupt.c new file +19 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInterrupt/Enable/enablePeriodicInterrupt.c new file +19 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Disable/disableUpdateInterrupt.c new file +19 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c new file +19 -0
@@ -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>

Quoted 23 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Disable/disableWatchdogInterrupt.c new file +20 -0
@@ -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>

Quoted 46 lines
tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInterrupt/Enable/enableWatchdogInterrupt.c new file +20 -0
@@ -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;
+    }
tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadEpoch/getEpoch.c new file +20 -0
@@ -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>

Quoted 29 lines
tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodicInterrupt.c new file +26 -0
@@ -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>

Quoted 23 lines
tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetEpoch/setEpoch.c new file +20 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicInterrupt.c new file +19 -0
@@ -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>

Quoted 23 lines
tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrection/getPllCorrection.c new file +20 -0
@@ -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>

Quoted 23 lines
tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrection/setPllCorrection.c new file +20 -0
@@ -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>

Quoted 23 lines
tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVoltageLow/clearVoltageLow.c new file +20 -0
@@ -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>

Quoted 23 lines
tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/getVoltageLow.c new file +20 -0
@@ -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>

Quoted 22 lines
tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/ReadWakeupAlarm/getWakeupAlarm.c new file +19 -0
@@ -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>

Quoted 12 lines
tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c new file +9 -0
@@ -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

tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c line 19

Quoted 10 lines
tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/SetWakeupAlarm/setWakeupAlarm.c new file +10 -0
+
+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).

Signature · 1 line
Alex Bennée
#3 lore raw

PATCH 2/2 tests/tcg/multiarch: Add tests for implemented alsa sound timer ioctls

In reply to Filip Bozuta

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

---
 .../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
tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Disable/disableEnhancedRead.c new file +29 -0
new file mode 100644
index 0000000..2f930b6
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Enable/enableEnhancedRead.c new file +29 -0
new file mode 100644
index 0000000..fd9dea6
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/GlobalTest/timer.c new file +158 -0

158 lines not on this page · raw message

tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Continue/continue.c new file +39 -0
new file mode 100644
index 0000000..09e256c
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Pause/pause.c new file +39 -0
new file mode 100644
index 0000000..fd57693
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Start/start.c new file +39 -0
new file mode 100644
index 0000000..75ead93
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Stop/stop.c new file +39 -0
new file mode 100644
index 0000000..c28b0a3
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Info/info.c new file +46 -0

46 lines not on this page · raw message

tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Params/params.c new file +44 -0

44 lines not on this page · raw message

tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/Status/status.c new file +45 -0

45 lines not on this page · raw message

tests/tcg/multiarch/alsa-timer-ioctl-tests/Selecting-test/select.c new file +34 -0
new file mode 100644
index 0000000..75425f4
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Ginfo/ginfo.c new file +43 -0

43 lines not on this page · raw message

tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gparams/gparams.c new file +37 -0
new file mode 100644
index 0000000..012a49d
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedParameters-tests/Gstatus/gstatus.c new file +36 -0
new file mode 100644
index 0000000..81a74ca
@@ -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;
+}
tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/NextDevice/nextDevice.c new file +34 -0
new file mode 100644
index 0000000..d3d1d3e
@@ -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;
+}
+
tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-tests/Pversion/pversion.c new file +30 -0
new file mode 100644
index 0000000..259846e
@@ -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;
+}
+
Signature · 1 line
2.7.4