From nobody Sat Apr 27 16:47:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579536719; cv=none; d=zohomail.com; s=zohoarc; b=Ds4QWpWhPHIveO9k3X8AxzW/YtHz6Q/WyzMam3o0HRm8FNU8MeIE3CP9Nz5dqXTD1p4RuEr/2W++yv5Wj/FrUYw51pemnOtZfSlzxCLab5+GDNorL5ydXIvRH2AFXJN8lARuuXl5Wnj8HjDM6wEc+icZ5RnYKkwNkFCsI9vm8TM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579536719; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ldP/DQrNsiwmUfoD7PVlNWuTYiUXOXaFX+u76fjlV4k=; b=J9LpfZImVz+bO3gOp8uGB5yXtmZ6hR7khuCb71ZrhytDMx5XK5LufEtg6bUkzvgKXOm2Y6S7RqVcktIBNUHFzQ8DdlOpI51NW0IYgsnY4/IhGsCgNAsYnutMnf+DbBT+dZaQEnd8EyOCdxlWhY9pcu8zKWtFl5pVSYDJD5gYr5c= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579536719138321.8265361927264; Mon, 20 Jan 2020 08:11:59 -0800 (PST) Received: from localhost ([::1]:39250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itZef-0005JV-BM for importer@patchew.org; Mon, 20 Jan 2020 11:11:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55993) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itZdG-000401-1Z for qemu-devel@nongnu.org; Mon, 20 Jan 2020 11:10:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1itZdC-0005Ly-Ed for qemu-devel@nongnu.org; Mon, 20 Jan 2020 11:10:29 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43141 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1itZdB-0004bp-W8 for qemu-devel@nongnu.org; Mon, 20 Jan 2020 11:10:26 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 214141A2120; Mon, 20 Jan 2020 17:09:20 +0100 (CET) Received: from rtrkw493-lin.domain.local (rtrkw493-lin.domain.local [10.10.14.93]) by mail.rt-rk.com (Postfix) with ESMTPSA id F02131A20F0; Mon, 20 Jan 2020 17:09:19 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 1/2] tests/tcg/multiarch: Add tests for implemented rtc ioctls Date: Mon, 20 Jan 2020 17:09:13 +0100 Message-Id: <1579536554-30701-2-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579536554-30701-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579536554-30701-1-git-send-email-Filip.Bozuta@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- .../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/Rea= dAlarm/getAlarm.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/Rea= dTime/getTime.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/Set= Alarm/setAlarm.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/Set= Time/setTime.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Alarm= Interrupt/Disable/disableAlarmInterrupt.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Alarm= Interrupt/Enable/enableAlarmInterrupt.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Perio= dicInterrupt/Disable/disablePeriodicInterrupt.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Perio= dicInterrupt/Enable/enablePeriodicInterrupt.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Updat= eInterrupt/Disable/disableUpdateInterrupt.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Updat= eInterrupt/Enable/enableUpdateInterrupt.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Watch= dogInterrupt/Disable/disableWatchdogInterrupt.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Features-test/Watch= dogInterrupt/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/Cl= earVoltageLow/clearVoltageLow.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/Re= adVoltageLow/getVoltageLow.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/R= eadWakeupAlarm/getWakeupAlarm.c create mode 100644 tests/tcg/multiarch/rtc-ioctl-tests/Wakeup-alarm-test/S= etWakeupAlarm/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/getAlar= m.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct rtc_time alarm_time; + + if (ioctl(fd, RTC_ALM_READ, &alarm_time) =3D=3D 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/g= etTime.c b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/ReadTime/get= Time.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 +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D 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/s= etAlarm.c b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetAlarm/se= tAlarm.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 +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct rtc_time alarm_time =3D {13, 35, 12}; + + if (ioctl(fd, RTC_ALM_SET, &alarm_time) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Alarm set!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/se= tTime.c b/tests/tcg/multiarch/rtc-ioctl-tests/Alarm-time-test/SetTime/setTi= me.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 +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct rtc_time time =3D {54, 34, 13, 26, 8, 120, 0, 0, 0}; + + if (ioctl(fd, RTC_SET_TIME, &time) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Time set!\n"); + + return 0; +} + diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterru= pt/Disable/disableAlarmInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Fe= atures-test/AlarmInterrupt/Disable/disableAlarmInterrupt.c new file mode 100644 index 0000000..bc89802 --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Disa= ble/disableAlarmInterrupt.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_AIE_OFF) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Alarm interrupt disabled!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterru= pt/Enable/enableAlarmInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Feat= ures-test/AlarmInterrupt/Enable/enableAlarmInterrupt.c new file mode 100644 index 0000000..451cfe7 --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/AlarmInterrupt/Enab= le/enableAlarmInterrupt.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_AIE_ON) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Alarm interrupt enabled!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInte= rrupt/Disable/disablePeriodicInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-te= sts/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/D= isable/disablePeriodicInterrupt.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_PIE_OFF) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Periodic interrupt disabled!\n"); + + return 0; +} + diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/PeriodicInte= rrupt/Enable/enablePeriodicInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-test= s/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/E= nable/enablePeriodicInterrupt.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_PIE_ON) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Periodic interrupt enabled!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterr= upt/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/Dis= able/disableUpdateInterrupt.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_UIE_OFF) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Update interrupt disabled!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterr= upt/Enable/enableUpdateInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-tests/Fe= atures-test/UpdateInterrupt/Enable/enableUpdateInterrupt.c new file mode 100644 index 0000000..f10fdf3 --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/UpdateInterrupt/Ena= ble/enableUpdateInterrupt.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_UIE_ON) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Update interrupt enabled!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInte= rrupt/Disable/disableWatchdogInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-te= sts/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/D= isable/disableWatchdogInterrupt.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_WIE_OFF) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Watchdog interrupt disabled!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Features-test/WatchdogInte= rrupt/Enable/enableWatchdogInterrupt.c b/tests/tcg/multiarch/rtc-ioctl-test= s/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/E= nable/enableWatchdogInterrupt.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + if (ioctl(fd, RTC_WIE_ON) =3D=3D 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/te= sts/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 +#include +#include +#include +#include +#include +#include +#include + +int main(void) +{ + + int i, fd, retval, irqcount =3D 0; + unsigned long tmp, data; + struct rtc_time rtc_tm; + + fd =3D open("/dev/rtc", O_RDONLY); + + if (fd =3D=3D -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 =3D ioctl(fd, RTC_UIE_ON, 0); + if (retval =3D=3D -1) { + perror("ioctl"); + exit(errno); + } + + fprintf(stderr, + "Counting 5 update (1/sec) interrupts from reading /dev/rtc:"); + fflush(stderr); + + for (i =3D 1; i < 6; i++) { + /* This read will block */ + retval =3D read(fd, &data, sizeof(unsigned long)); + + if (retval =3D=3D -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 =3D 1; i < 6; i++) { + struct timeval tv =3D {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 =3D select(fd + 1, &readfds, NULL, NULL, &tv); + if (retval =3D=3D -1) { + perror("select"); + exit(errno); + } + + /* This read won't block unlike the select-less case above. */ + retval =3D read(fd, &data, sizeof(unsigned long)); + if (retval =3D=3D -1) { + perror("read"); + exit(errno); + } + + fprintf(stderr, " %d", i); + fflush(stderr); + irqcount++; + } + + /* Turn off update interrupts */ + retval =3D ioctl(fd, RTC_UIE_OFF, 0); + if (retval =3D=3D -1) { + perror("ioctl"); + exit(errno); + } + + /* Read the RTC time/date */ + retval =3D ioctl(fd, RTC_RD_TIME, &rtc_tm); + if (retval =3D=3D -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 +=3D 5; + if (rtc_tm.tm_sec >=3D 60) { + rtc_tm.tm_sec %=3D 60; + rtc_tm.tm_min++; + } + + if (rtc_tm.tm_min =3D=3D 60) { + rtc_tm.tm_min =3D 0; + rtc_tm.tm_hour++; + } + + if (rtc_tm.tm_hour =3D=3D 24) { + rtc_tm.tm_hour =3D 0; + } + + retval =3D ioctl(fd, RTC_ALM_SET, &rtc_tm); + if (retval =3D=3D -1) { + perror("ioctl"); + exit(errno); + } + + /* Read the current alarm settings */ + retval =3D ioctl(fd, RTC_ALM_READ, &rtc_tm); + if (retval =3D=3D -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 =3D ioctl(fd, RTC_AIE_ON, 0); + if (retval =3D=3D -1) { + perror("ioctl"); + exit(errno); + } + + fprintf(stderr, "Waiting 5 seconds for alarm..."); + fflush(stderr); + /* This blocks until the alarm ring causes an interrupt */ + retval =3D read(fd, &data, sizeof(unsigned long)); + if (retval =3D=3D -1) { + perror("read"); + exit(errno); + } + + irqcount++; + fprintf(stderr, " okay. Alarm rang.\n"); + + /* Disable alarm interrupts */ + retval =3D ioctl(fd, RTC_AIE_OFF, 0); + if (retval =3D=3D -1) { + perror("ioctl"); + exit(errno); + } + + /* Read periodic IRQ rate */ + retval =3D ioctl(fd, RTC_IRQP_READ, &tmp); + if (retval =3D=3D -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 =3D 2; tmp <=3D 64; tmp *=3D 2) { + + retval =3D ioctl(fd, RTC_IRQP_SET, tmp); + if (retval =3D=3D -1) { + perror("ioctl"); + exit(errno); + } + + fprintf(stderr, "\n%ldHz:\t", tmp); + fflush(stderr); + + /* Enable periodic interrupts */ + retval =3D ioctl(fd, RTC_PIE_ON, 0); + if (retval =3D=3D -1) { + perror("ioctl"); + exit(errno); + } + + for (i =3D 1; i < 21; i++) { + /* This blocks */ + retval =3D read(fd, &data, sizeof(unsigned long)); + if (retval =3D=3D -1) { + perror("read"); + exit(errno); + } + fprintf(stderr, " %d", i); + fflush(stderr); + irqcount++; + } + + /* Disable periodic interrupts */ + retval =3D ioctl(fd, RTC_PIE_OFF, 0); + if (retval =3D=3D -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-t= est/ReadEpoch/getEpoch.c b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-int= errupt-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/Rea= dEpoch/getEpoch.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int epoch; + + if (ioctl(fd, RTC_EPOCH_READ, &epoch) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Epoch: %d\n", epoch); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-t= est/ReadPeriodicInterrupt/getPeriodicInterrupt.c b/tests/tcg/multiarch/rtc-= ioctl-tests/Periodic-interrupt-epoch-test/ReadPeriodicInterrupt/getPeriodic= Interrupt.c new file mode 100644 index 0000000..4591783 --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/Rea= dPeriodicInterrupt/getPeriodicInterrupt.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + unsigned long interrupt_rate; + + if (ioctl(fd, RTC_IRQP_READ, &interrupt_rate) =3D=3D 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-t= est/SetEpoch/setEpoch.c b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-inte= rrupt-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/Set= Epoch/setEpoch.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int epoch =3D 5; + + if (ioctl(fd, RTC_EPOCH_SET, epoch) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Epoch set!\n", epoch); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-t= est/SetPeriodicInterrupt/setPeriodicInterrupt.c b/tests/tcg/multiarch/rtc-i= octl-tests/Periodic-interrupt-epoch-test/SetPeriodicInterrupt/setPeriodicIn= terrupt.c new file mode 100644 index 0000000..a0c78fe --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Periodic-interrupt-epoch-test/Set= PeriodicInterrupt/setPeriodicInterrupt.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int interrupt_rate =3D 32; + + if (ioctl(fd, RTC_IRQP_SET, interrupt_rate) =3D=3D 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/ReadPl= lCorrection/getPllCorrection.c b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-co= rrection-test/ReadPllCorrection/getPllCorrection.c new file mode 100644 index 0000000..2104050 --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/ReadPllCorrec= tion/getPllCorrection.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct rtc_pll_info info; + + if (ioctl(fd, RTC_PLL_GET, &info) =3D=3D 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/SetPll= Correction/setPllCorrection.c b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-cor= rection-test/SetPllCorrection/setPllCorrection.c new file mode 100644 index 0000000..176e895 --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Pll-correction-test/SetPllCorrect= ion/setPllCorrection.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc0", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct rtc_pll_info info =3D {1, 1, 1, 1, 1, 1, 1}; + + if (ioctl(fd, RTC_PLL_SET, &info) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Pll correction set!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ClearVolt= ageLow/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 +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int voltage; + + if (ioctl(fd, RTC_VL_CLR) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Voltage low cleared"); + + return 0; +} diff --git a/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVolta= geLow/getVoltageLow.c b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-tes= t/ReadVoltageLow/getVoltageLow.c new file mode 100644 index 0000000..8d90329 --- /dev/null +++ b/tests/tcg/multiarch/rtc-ioctl-tests/Voltage-low-test/ReadVoltageLow/g= etVoltageLow.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/proc/driver/rtc", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int voltage; + + if (ioctl(fd, RTC_VL_READ, &voltage) =3D=3D 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/ReadWake= upAlarm/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 +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDWR | O_NONBLOCK); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct rtc_wkalrm alarm; + + if (ioctl(fd, RTC_WKALM_RD, &alarm) =3D=3D 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/SetWakeu= pAlarm/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 +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + + int fd =3D open("/dev/rtc", O_RDONLY); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct rtc_time time =3D {25, 30, 10, 27, 8, 12, 0, 0, 0}; + + struct rtc_wkalrm alarm =3D {0, 0, time}; + + if (ioctl(fd, RTC_WKALM_SET, &alarm) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Wakeup alarm set!\n"); + + return 0; +} + --=20 2.7.4 From nobody Sat Apr 27 16:47:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1579536715; cv=none; d=zohomail.com; s=zohoarc; b=mq2yqkfmWZ/7fYF2QGQUU9LQd7TfWW8XjzZu6HGuw+ijq0eT9hx891QG1UuTcJTNz5jpHcGiVC6eW0khk00LmmVjgELGGwSvX5YL186EipYHUqOlUdTqEret00GPZMplJqSnEjIw4ldP1VRHmYm3W6gXgF1sUK7DmanCRn/RAGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579536715; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=JlL7zFxRaqWAVNFAg7evMDTN7aSrdVDr0pIjOv/Ach0=; b=VZrx+hToXoV6dHkJ6Lhvh345SBEI9kvbSrzxfipK2TY1naR4s1egsrRGQQ/rid7bD67V7T7V8OufWXlkNEkEd/xrVwje1ucGXS8kaPzZCxIe0UoFbVDofmupQxhlUv2fZ1ZG8lCyU7g8pQtWRAKlfXw73YnqZArXDBUYT3Jr0X4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157953671529641.06056812401289; Mon, 20 Jan 2020 08:11:55 -0800 (PST) Received: from localhost ([::1]:39246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itZeb-0005Dt-BS for importer@patchew.org; Mon, 20 Jan 2020 11:11:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55987) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itZdF-0003zy-Os for qemu-devel@nongnu.org; Mon, 20 Jan 2020 11:10:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1itZdB-0005Ld-O4 for qemu-devel@nongnu.org; Mon, 20 Jan 2020 11:10:29 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43142 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1itZdB-0004bq-9d for qemu-devel@nongnu.org; Mon, 20 Jan 2020 11:10:25 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 2E5B31A20EF; Mon, 20 Jan 2020 17:09:20 +0100 (CET) Received: from rtrkw493-lin.domain.local (rtrkw493-lin.domain.local [10.10.14.93]) by mail.rt-rk.com (Postfix) with ESMTPSA id 086611A2107; Mon, 20 Jan 2020 17:09:20 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH 2/2] tests/tcg/multiarch: Add tests for implemented alsa sound timer ioctls Date: Mon, 20 Jan 2020 17:09:14 +0100 Message-Id: <1579536554-30701-3-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579536554-30701-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579536554-30701-1-git-send-email-Filip.Bozuta@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- .../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/t= imer.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/SelectedPara= meters-tests/Info/info.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedPara= meters-tests/Params/params.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedPara= meters-tests/Status/status.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Selecting-te= st/select.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedPar= ameters-tests/Ginfo/ginfo.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedPar= ameters-tests/Gparams/gparams.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/SpecifiedPar= ameters-tests/Gstatus/gstatus.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-t= ests/NextDevice/nextDevice.c create mode 100644 tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-t= ests/Pversion/pversion.c diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/D= isable/disableEnhancedRead.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/E= nhancedRead-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 +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int tread =3D 0; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_TREAD, &tread) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Enhanced read disabled!\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/E= nable/enableEnhancedRead.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Enh= ancedRead-test/Enable/enableEnhancedRead.c new file mode 100644 index 0000000..fd9dea6 --- /dev/null +++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/EnhancedRead-test/Enable/e= nableEnhancedRead.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int tread =3D 1; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_TREAD, &tread) =3D=3D 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 +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include + +static void build_system_timer_id(struct snd_timer_id *tid) +{ + tid->dev_class =3D SNDRV_TIMER_CLASS_GLOBAL; + tid->dev_sclass =3D SNDRV_TIMER_SCLASS_NONE; + tid->card =3D -1; + tid->device =3D SNDRV_TIMER_GLOBAL_SYSTEM; + tid->subdevice =3D 0; +} + +#define TEST_IOCTL(fd, command, argument, expected) \ + do { \ + if (ioctl(fd, command, argument) < 0 && errno !=3D 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 =3D 0; + TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_PVERSION, &version, 0); +} + +static bool check_next_device(int fd) +{ + struct snd_timer_id id =3D {0}; + TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_NEXT_DEVICE, &id, 0); +} + +static bool check_tread(int fd) +{ + int tread =3D 1; + TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_TREAD, &tread, 0); +} + +static bool check_ginfo(int fd) +{ + struct snd_timer_ginfo ginfo =3D {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 =3D {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 =3D {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 =3D {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 =3D {0}; + TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_INFO, &info, 0); +} + +static bool check_params(int fd) +{ + struct snd_timer_params params =3D {0}; + params.ticks =3D 1; + params.filter =3D SNDRV_TIMER_EVENT_TICK; + TEST_IOCTL(fd, SNDRV_TIMER_IOCTL_PARAMS, ¶ms, 0); +} + +static bool check_status(int fd) +{ + struct snd_timer_status status =3D {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) =3D { + 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 =3D open("/dev/snd/timer", O_RDONLY); + if (fd < 0) { + printf("%s\n", strerror(errno)); + return EXIT_FAILURE; + } + + i =3D 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/Instructio= ns-tests/Continue/continue.c new file mode 100644 index 0000000..09e256c --- /dev/null +++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Continu= e/continue.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D ERROR) { + perror("ioctl:"); + return -1; + } + + if (ioctl(fd, SNDRV_TIMER_IOCTL_CONTINUE) =3D=3D 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-tes= ts/Pause/pause.c new file mode 100644 index 0000000..fd57693 --- /dev/null +++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Pause/p= ause.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D ERROR) { + perror("ioctl:"); + return -1; + } + + if (ioctl(fd, SNDRV_TIMER_IOCTL_PAUSE) =3D=3D 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-tes= ts/Start/start.c new file mode 100644 index 0000000..75ead93 --- /dev/null +++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Instructions-tests/Start/s= tart.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D ERROR) { + perror("ioctl:"); + return -1; + } + + if (ioctl(fd, SNDRV_TIMER_IOCTL_START) =3D=3D 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/st= op.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D ERROR) { + perror("ioctl:"); + return -1; + } + + if (ioctl(fd, SNDRV_TIMER_IOCTL_STOP) =3D=3D 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/SelectedPara= meters-tests/Info/info.c new file mode 100644 index 0000000..7a8ff28 --- /dev/null +++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/I= nfo/info.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D ERROR) { + perror("ioctl:"); + return -1; + } + + struct snd_timer_info info =3D {0}; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_INFO, &info) =3D=3D 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/Selected= Parameters-tests/Params/params.c new file mode 100644 index 0000000..c3953ca --- /dev/null +++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/P= arams/params.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D ERROR) { + perror("ioctl:"); + return -1; + } + + struct snd_timer_params params =3D {0}; + params.ticks =3D 1; + params.filter =3D SNDRV_TIMER_EVENT_TICK; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_PARAMS, ¶ms) =3D=3D 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/Selected= Parameters-tests/Status/status.c new file mode 100644 index 0000000..b56f4a5 --- /dev/null +++ b/tests/tcg/multiarch/alsa-timer-ioctl-tests/SelectedParameters-tests/S= tatus/status.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D ERROR) { + perror("ioctl:"); + return -1; + } + + struct snd_timer_status status =3D {0}; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_STATUS, &status) =3D=3D 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/sele= ct.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 +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_select select; + select.id =3D id; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_SELECT, &select) =3D=3D 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/Specified= Parameters-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 +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_ginfo ginfo; + ginfo.tid =3D id; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_GINFO, &ginfo) =3D=3D 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/Speci= fiedParameters-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 +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_ginfo ginfo; + ginfo.tid =3D id; + + gparams.period_num =3D 2; + gparams.period_den =3D 2; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_GPARAMS, &gparams) =3D=3D 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/Speci= fiedParameters-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 +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_SCLASS_NONE, -1, + SNDRV_TIMER_GLOBAL_SYSTEM, 0}; + + struct snd_timer_ginfo ginfo; + ginfo.tid =3D id; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_GSTATUS, &gstatus) =3D=3D 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/Ne= xtDevice/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/NextDevic= e/nextDevice.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + struct snd_timer_id id =3D {1, 0, 0, 0, 0}; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_NEXT_DEVICE, &id) =3D=3D 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/Pv= ersion/pversion.c b/tests/tcg/multiarch/alsa-timer-ioctl-tests/Version-id-t= ests/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 +#include +#include +#include +#include +#include + +#define ERROR -1 + +int main() +{ + int fd =3D open("/dev/snd/timer", O_RDWR); + + if (fd =3D=3D ERROR) { + perror("open"); + return -1; + } + + int version =3D 0; + + if (ioctl(fd, SNDRV_TIMER_IOCTL_PVERSION, &version) =3D=3D ERROR) { + perror("ioctl"); + return -1; + } + + printf("Timer version: %d\n", version); + + return 0; +} + --=20 2.7.4