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.boz...@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


Reply via email to