|
From: Silesh C V <sai...@gm...> - 2010-02-25 06:40:22
|
Hi Garrett,
Thanks for the review and suggestions.
On 2/25/10, Garrett Cooper <yan...@gm...> wrote:
> On Wed, Feb 24, 2010 at 4:10 AM, Silesh C V <sai...@gm...> wrote:
>>
>> Hi ,
>>
>> This patch contains tests for the linux RTC driver.The patch is taken
>> against feb intermediate release.I have also attached the patch.Please
>> find
>> the test log at the end of this mail.Build/Run instructions are explained
>> in
>> the README.
>>
>>
>> Signed-off-By: Silesh C V <Sil...@ln...>
>> --
>> diff -purN ltp-intermediate-20100228.
>> orig/testcases/kernel/device-drivers/rtc/Makefile
>> ltp-intermediate-20100228/testcases/kernel/device-drivers/rtc/Makefile
>> ---
>> ltp-intermediate-20100228.orig/testcases/kernel/device-drivers/rtc/Makefile
>> 1970-01-01 05:30:00.000000000 +0530
>> +++ ltp-intermediate-20100228/testcases/kernel/device-drivers/rtc/Makefile
>> 2010-02-24 15:21:33.000000000 +0530
>> @@ -0,0 +1,28 @@
>> +#
>> +# Copyright (c) Larsen & Toubro Infotech Ltd., 2010
>> +#
>> +# This program is free software; you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation; either version 2 of the License, or
>> +# (at your option) any later version.
>> +#
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
>> +# the GNU General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program; if not, write to the Free Software
>> +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
>> USA
>> +#
>> +#
>> +
>> +CFLAGS = -O2 -Wall
>> +SRC = test_rtc.c
>> +
>> +
>> +all: $(SRC)
>> + $(CC) $(CFLAGS) $(SRC) -o rtc-test
>> +
>> +clean:
>> + rm -f rtc-test
>
> Please integrate into the Makefile infrastructure. See README.mk-devel
> for more details.
I can see that under kernel/ directory, the device-drivers directory
does not follow the new Makefile infrastructure. I tried adding
device-drivers SUBDIRS to testcases/kernel/Makefile. As none of the
other device driver test cases follow this Makefile approach, the
build breaks .
>
>> diff -purN
>> ltp-intermediate-20100228.orig/testcases/kernel/device-drivers/rtc/README
>> ltp-intermediate-20100228/testcases/kernel/device-drivers/rtc/README
>> ---
>> ltp-intermediate-20100228.orig/testcases/kernel/device-drivers/rtc/README
>> 1970-01-01 05:30:00.000000000 +0530
>> +++ ltp-intermediate-20100228/testcases/kernel/device-drivers/rtc/README
>> 2010-02-24 14:34:01.000000000 +0530
>> @@ -0,0 +1,29 @@
>> +test_rtc.c : Test the Real Time Clock driver
>> +
>> +Tests supported as of now
>> +--------------------------
>> +1. Read test : This reads the time/date from the RTC
>> + ioctls tested :- RTC_RD_TIME.
>> +
>> +2. Alarm Test: Sets the alarm to 5 seconds in future and makes sure it
>> rings.
>> + ioctls tested :- RTC_ALM_SET, RTC_ALM_READ, RTC_AIE_ON, RTC_AIE_OFF.
>> +
>> +3. Update interrupts test : Sets Update interrupts enable on, waits for
>> five
>> + interrupts and then turns it off.
>> + ioctls tested :- RTC_UIE_ON, RTC_UIE_OFF.
>> +
>> +
>> +How to Build
>> +------------
>> +
>> +Enter rtc directory and issue a 'make' .
>> +
>> +How to Run
>> +----------
>> +
>> + The tests assume the rtc device node to be "/dev/rtc". If you have
>> a
>> +different node run the test with the name of the node as a parameter.
>> +
>> +Eg. If your node is /dev/rtc0, then run the test as
>> +
>> + $ ./rtc-test /dev/rtc0
>> diff -purN
>> ltp-intermediate-20100228.orig/testcases/kernel/device-drivers/rtc/test_rtc.c
>> ltp-intermediate-20100228/testcases/kernel/device-drivers/rtc/test_rtc.c
>> ---
>> ltp-intermediate-20100228.orig/testcases/kernel/device-drivers/rtc/test_rtc.c
>> 1970-01-01 05:30:00.000000000 +0530
>> +++
>> ltp-intermediate-20100228/testcases/kernel/device-drivers/rtc/test_rtc.c
>> 2010-02-24 15:17:59.000000000 +0530
>> @@ -0,0 +1,175 @@
>> +/* test_rtc.c
>> + *
>> + * Copyright (c) Larsen & Toubro Infotech Ltd., 2010
>> + *
>> + * Contact : Silesh C V <Sil...@ln...>
>> + *
>> + * This program is free software; you can redistribute it and/or
>> modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
>> + * the GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
>> USA
>> + *
>> + */
>> +
>> +#include <sys/ioctl.h>
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <fcntl.h>
>> +#include <unistd.h>
>> +#include <linux/rtc.h>
>> +#include <errno.h>
>> +
>> +int rtc_fd = -1;
>> +
>> +void read_alarm_test(void)
>> +{
>> + struct rtc_time rtc_tm;
>> + int ret;
>> + unsigned long data;
>> +
>> + printf("\nRTC READ TEST:\n");
>> +
>> + /*Read RTC Time*/
>> + ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
>> + if (ret == -1) {
>> + perror("RTC_RD_TIME ioctl");
>> + printf("RTC READ TEST Failed\n");
>> + return;
>> + }
>> +
>> + printf("RTC READ TEST Passed");
>> + printf("\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);
>
> strftime(3) ?
OK. Coming in the next patch.
>
>> + printf("\nRTC ALARM TEST :\n");
>> +
>> + /*set Alarm to 5 Seconds*/
>> + rtc_tm.tm_sec += 5;
>> + if (rtc_tm.tm_sec >= 60) {
>> + rtc_tm.tm_sec %= 60;
>> + rtc_tm.tm_min++;
>> + }
>> +
>> + if (rtc_tm.tm_min == 60) {
>> + rtc_tm.tm_min = 0;
>> + rtc_tm.tm_hour++;
>> + }
>> +
>> + if (rtc_tm.tm_hour == 24)
>> + rtc_tm.tm_hour = 0;
>> +
>> + ret = ioctl(rtc_fd, RTC_ALM_SET, &rtc_tm);
>> + if (ret == -1) {
>> + perror("RTC_ALM_SET ioctl");
>> + printf("RTC ALARM TEST Failed\n");
>> + return;
>> + }
>> +
>> + /*Read current alarm time*/
>> + ret = ioctl(rtc_fd, RTC_ALM_READ, &rtc_tm);
>> + if (ret == -1) {
>> + perror("RTC_ALM_READ ioctl");
>> + printf("RTC ALARM TEST Failed\n");
>> + return;
>> + }
>> +
>> + printf("Alarm time set to %02d:%02d:%02d.\n",
>> + rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
>> + /* Enable alarm interrupts */
>> + ret = ioctl(rtc_fd, RTC_AIE_ON, 0);
>> + if (ret == -1) {
>> + perror("RTC_AIE_ON ioctl");
>> + printf("RTC ALARM TEST Failed\n");
>> + return;
>> + }
>> +
>> + printf("Waiting 5 seconds for the alarm...\n");
>> + ret = read(rtc_fd, &data, sizeof(unsigned long));
>> + if (ret == -1) {
>> + perror("read");
>> + printf("RTC ALARM TEST Failed\n");
>> + return;
>> + }
>> +
>> + printf("Alarm rang.\n");
>> + /* Disable alarm interrupts */
>> + ret = ioctl(rtc_fd, RTC_AIE_OFF, 0);
>> + if (ret == -1) {
>> + perror("RTC_AIE_OFF ioctl");
>> + printf("RTC ALARM TEST Failed\n");
>> + return;
>> + }
>> +
>> + printf("RTC ALARM TEST Passed\n");
>> +}
>> +
>> +void update_interrupts_test(void)
>> +{
>> + int ret, i;
>> + unsigned long data;
>> +
>> + printf("\nRTC UPDATE INTERRUPTS TEST :\n");
>> + /*Turn on update interrupts*/
>> + ret = ioctl(rtc_fd, RTC_UIE_ON, 0);
>> + if (ret == -1) {
>> + perror("RTC_UIE_ON ioctl");
>> + printf("RTC UPDATE INTERRUPTS TEST Failed\n");
>> + return;
>> + }
>> +
>> + printf("Waiting for 5 update interrupts...\n");
>> + for (i = 1; i < 6; i++) {
>> + ret = read(rtc_fd, &data, sizeof(unsigned long));
>> + if (ret == -1) {
>> + perror("read");
>> + printf("RTC UPDATE INTERRUPTS TEST Failed\n");
>> + return;
>> + }
>> + printf("Update interrupt %d\n", i);
>> + }
>> +
>> + /* Turn off update interrupts */
>> + ret = ioctl(rtc_fd, RTC_UIE_OFF, 0);
>> + if (ret == -1) {
>> + perror("RTC_UIE_OFF ioctl");
>> + printf("RTC UPDATE INTERRUPTS TEST Failed\n");
>> + return;
>> + }
>> + printf("RTC UPDATE INTERRUPTS TEST Passed\n");
>
> tst_resm(ret == -1 ? TFAIL : TPASS, "RTC update interrupts test %s",
> ret == -1 ? "failed" : "passed");
>
This can be done only when we build the test along with LTP .But as
the problem I mentioned
earlier the device-driver directory is still out of the overall LTP build .
>> +}
>> +
>> +int main(int argc, char **argv)
>> +{
>> + char *rtc_dev = "/dev/rtc"
>> +
>> +
>> + if (argc == 2)
>> + rtc_dev = argv[1];
>> +
>> + rtc_fd = open(rtc_dev, O_RDONLY);
>> + if (rtc_fd < 0) {
>> + perror(rtc_dev);
>
> tst_brkm(TBROK | TERRNO, tst_exit, "couldn't open %s", rtc_dev);
Same here.
>
>> + exit(errno);
>> + }
>> +
>> + /*Read and alarm tests*/
>> + read_alarm_test();
>> +
>> + /*Update interrupts test*/
>> + update_interrupts_test();
>> +
>> + close(rtc_fd);
>> +
>> + printf("\nRTC Tests Done!\n");
>> + return 0;
>> +}
>
> 1. Please rename the test sourcefile to rtc-test.c because the current
> naming is unnecessarily inconsistent.
OK.
> 2. Please replace printfs with tst_res(3) calls so this can be
> properly integrated into LTP.
Same issue as I explained earlier.
>
> Thanks!
> -Garrett
Thanks,
Silesh.
>
>> --
>> test log
>> ------------------------------
>> RTC READ TEST:
>> RTC READ TEST Passed
>> Current RTC date/time is 24-2-2010, 17:03:05.
>>
>> RTC ALARM TEST :
>> Alarm time set to 17:03:10.
>> Waiting 5 seconds for the alarm...
>> Alarm rang.
>> RTC ALARM TEST Passed
>>
>> RTC UPDATE INTERRUPTS TEST :
>> Waiting for 5 update interrupts...
>> Update interrupt 1
>> Update interrupt 2
>> Update interrupt 3
>> Update interrupt 4
>> Update interrupt 5
>> RTC UPDATE INTERRUPTS TEST Passed
>>
>> RTC Tests Done!
>> ---------------------------------------------------------
>>
>>
>> Thanks .
>> Silesh
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Ltp-list mailing list
>> Ltp...@li...
>> https://lists.sourceforge.net/lists/listinfo/ltp-list
>>
>>
>
--
Silesh
|