All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH-v3] RTC Device Driver Tests
@ 2010-03-04  5:30 Silesh C V
  2010-03-04 12:55 ` Rishikesh K Rajak
  0 siblings, 1 reply; 9+ messages in thread
From: Silesh C V @ 2010-03-04  5:30 UTC (permalink / raw)
  To: risrajak, ltp-list; +Cc: Arun.sudhilal, Mohamed.Rasheed


[-- Attachment #1.1: Type: text/plain, Size: 10396 bytes --]

Hi,

Here is the new version of the RTC device driver tests.This is taken against
next branch of ltp git.

Rishi,

Can you test this patch on the machine on which the tests got stuck earlier?

Thanks,
Silesh

-----

From 0296ea1ee1d76f977cbe337da5b639
4d9034e625 Mon Sep 17 00:00:00 2001
From: Silesh C V <Silesh.Vellattu@lntinfotech.com>
Date: Thu, 4 Mar 2010 10:36:27 +0530
Subject: [PATCH] RTC Device Driver Tests

This commit contains Linux RTC device driver test cases.
Currently RTC read test, Alarm test and Update interrupts
tests are supported.

Signed-off-by: Silesh C V <Silesh.Vellattu@lntinfotech.com>
---
 testcases/kernel/device-drivers/rtc/Makefile   |   29 +++
 testcases/kernel/device-drivers/rtc/README     |   29 +++
 testcases/kernel/device-drivers/rtc/rtc-test.c |  219
++++++++++++++++++++++++
 3 files changed, 277 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/device-drivers/rtc/Makefile
 create mode 100644 testcases/kernel/device-drivers/rtc/README
 create mode 100644 testcases/kernel/device-drivers/rtc/rtc-test.c

diff --git a/testcases/kernel/device-drivers/rtc/Makefile
b/testcases/kernel/device-drivers/rtc/Makefile
new file mode 100644
index 0000000..40d6661
--- /dev/null
+++ b/testcases/kernel/device-drivers/rtc/Makefile
@@ -0,0 +1,29 @@
+#
+#  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 -I ../../../../include/
+LIBS = -L ../../../../lib/ -lltp
+SRC = rtc-test.c
+
+
+all: $(SRC)
+       $(CC) $(SRC) $(CFLAGS) $(LIBS) -o rtc-test
+
+clean:
+       rm -f rtc-test
diff --git a/testcases/kernel/device-drivers/rtc/README
b/testcases/kernel/device-drivers/rtc/README
new file mode 100644
index 0000000..a41bdda
--- /dev/null
+++ b/testcases/kernel/device-drivers/rtc/README
@@ -0,0 +1,29 @@
+rtc-test.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
+------------
+You have to build the complete LTP package before trying to build these
tests.
+After building the complete LTP sources enter this 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 --git a/testcases/kernel/device-drivers/rtc/rtc-test.c
b/testcases/kernel/device-drivers/rtc/rtc-test.c
new file mode 100644
index 0000000..6268ac9
--- /dev/null
+++ b/testcases/kernel/device-drivers/rtc/rtc-test.c
@@ -0,0 +1,219 @@
+/*   rtc-test.c
+ *
+ *   Tests for the Real Time Clock driver.
+ *
+ *   Copyright (c) Larsen & Toubro Infotech Ltd., 2010
+ *
+ *   Author : Silesh C V <Silesh.Vellattu@lntinfotech.com>
+ *
+ *   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 "test.h"
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <linux/rtc.h>
+#include <errno.h>
+#include <time.h>
+
+int rtc_fd = -1;
+char *TCID = "rtc01";
+int TST_TOTAL = 3;
+
+
+/* Read and Alarm Tests :  Read test reads the Date/time from RTC
+ * while Alarm test, sets the alarm to 5 seconds in future and
+ * waits for it to ring.The ioctls tested in these tests are
+ * RTC_RD_TIME, RTC_ALM_SET, RTC_ALM_READ, RTC_AIE_OFF  */
+
+void read_alarm_test(void)
+{
+       struct rtc_time rtc_tm;
+       int ret;
+       unsigned long data;
+       char time[25];
+       fd_set rfds;
+       struct timeval tv;
+
+       tst_resm(TINFO, "RTC READ TEST:");
+
+        /*Read RTC Time*/
+       ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
+       if (ret == -1) {
+               tst_resm(TFAIL, "RTC_RD_TIME ioctl failed");
+               return;
+       }
+
+       tst_resm(TPASS, "RTC READ TEST Passed");
+
+       strftime(time, sizeof(time), "%D %r", (struct tm *)&rtc_tm);
+
+       tst_resm(TINFO, "Current Date/time is  %s", time);
+
+       tst_resm(TINFO, "RTC ALARM TEST :");
+
+       /*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) {
+               tst_resm(TFAIL, "RTC_ALM_SET ioctl failed");
+               return;
+       }
+
+       /*Read current alarm time*/
+       ret = ioctl(rtc_fd, RTC_ALM_READ, &rtc_tm);
+       if (ret == -1) {
+               tst_resm(TFAIL, "RTC_ALM_READ ioctl failed");
+               return;
+       }
+
+       tst_resm(TINFO, "Alarm time set to %02d:%02d:%02d.",
+               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) {
+               tst_resm(TINFO, "RTC_AIE_ON ioctl failed");
+               return;
+       }
+
+       tst_resm(TINFO, "Waiting 5 seconds for the alarm...");
+
+       tv.tv_sec = 6;/*set 6 seconds as the time out*/
+       tv.tv_usec = 0;
+
+       FD_ZERO(&rfds);
+       FD_SET(rtc_fd, &rfds);
+
+       ret = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);/*wait for alarm*/
+
+       if (ret == -1) {
+               tst_resm(TFAIL, "select failed");
+               return;
+       } else if (ret) {
+               ret = read(rtc_fd, &data, sizeof(unsigned long));
+               if (ret == -1) {
+                       tst_resm(TFAIL, "read failed");
+                       return;
+               }
+               tst_resm(TINFO, "Alarm rang.");
+       } else {
+               tst_resm(TFAIL, "Timed out waiting for the alarm");
+               return;
+       }
+
+       /* Disable alarm interrupts */
+       ret = ioctl(rtc_fd, RTC_AIE_OFF, 0);
+       if (ret == -1) {
+               tst_resm(TFAIL, "RTC_AIE_OFF ioctl failed");
+               return;
+       }
+       tst_resm(TPASS, "RTC ALARM TEST Passed");
+}
+
+/* Update_interrupts_test :Once the Update interrupts is enabled,
+ * the RTC gives interrupts (1/sec) on the interrupts line(if the rtc
+ * has one). This is tested by enabling the update interrupts
+ * and then waiting for 5 interrupts.*/
+
+void update_interrupts_test(void)
+{
+       int ret, i;
+       unsigned long data;
+       fd_set rfds;
+       struct timeval tv;
+
+       tst_resm(TINFO, "RTC UPDATE INTERRUPTS TEST :");
+       /*Turn on update interrupts*/
+       ret = ioctl(rtc_fd, RTC_UIE_ON, 0);
+       if (ret == -1) {
+               tst_resm(TFAIL, "RTC_UIE_ON ioctl failed");
+               return;
+        }
+
+       tst_resm(TINFO, "Waiting for  5 update interrupts...");
+       for (i = 1; i < 6; i++) {
+
+               tv.tv_sec = 2; /*2 sec time out for each interrupt*/
+               tv.tv_usec = 0;
+
+               FD_ZERO(&rfds);
+               FD_SET(rtc_fd, &rfds);
+
+               ret = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
+               if (ret == -1) {
+                       tst_resm(TFAIL, "select failed");
+                       return;
+               } else if (ret) {
+                       ret = read(rtc_fd, &data, sizeof(unsigned long));
+                       if (ret == -1) {
+                               tst_resm(TFAIL, "read failed");
+                               return;
+                       }
+                       tst_resm(TINFO, "Update interrupt %d", i);
+               } else {
+                       tst_resm(TFAIL,
+                               "Timed out waiting for the update
interrupt");
+                       return;
+               }
+       }
+
+       /* Turn off update interrupts */
+       ret = ioctl(rtc_fd, RTC_UIE_OFF, 0);
+       if (ret == -1) {
+               tst_resm(TFAIL, "RTC_UIE_OFF ioctl failed");
+               return;
+       }
+       tst_resm(TPASS, "RTC UPDATE INTERRUPTS TEST Passed");
+}
+
+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)
+               tst_brkm(TBROK | TERRNO, tst_exit, "couldn't open %s",
rtc_dev);
+
+       /*Read and alarm tests*/
+       read_alarm_test();
+
+       /*Update interrupts test*/
+       update_interrupts_test();
+
+       close(rtc_fd);
+
+       tst_resm(TINFO, "RTC Tests Done!");
+       return 0;
+}
--
1.5.6.3

[-- Attachment #1.2: Type: text/html, Size: 12715 bytes --]

[-- Attachment #2: RTC-Device-Driver-Tests.patch --]
[-- Type: application/octet-stream, Size: 8958 bytes --]

From 0296ea1ee1d76f977cbe337da5b6394d9034e625 Mon Sep 17 00:00:00 2001
From: Silesh C V <Silesh.Vellattu@lntinfotech.com>
Date: Thu, 4 Mar 2010 10:36:27 +0530
Subject: [PATCH] RTC Device Driver Tests

This commit contains Linux RTC device driver test cases.
Currently RTC read test, Alarm test and Update interrupts
tests are supported.

Signed-off-by: Silesh C V <Silesh.Vellattu@lntinfotech.com>
---
 testcases/kernel/device-drivers/rtc/Makefile   |   29 +++
 testcases/kernel/device-drivers/rtc/README     |   29 +++
 testcases/kernel/device-drivers/rtc/rtc-test.c |  219 ++++++++++++++++++++++++
 3 files changed, 277 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/device-drivers/rtc/Makefile
 create mode 100644 testcases/kernel/device-drivers/rtc/README
 create mode 100644 testcases/kernel/device-drivers/rtc/rtc-test.c

diff --git a/testcases/kernel/device-drivers/rtc/Makefile b/testcases/kernel/device-drivers/rtc/Makefile
new file mode 100644
index 0000000..40d6661
--- /dev/null
+++ b/testcases/kernel/device-drivers/rtc/Makefile
@@ -0,0 +1,29 @@
+#
+#  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 -I ../../../../include/
+LIBS = -L ../../../../lib/ -lltp 
+SRC = rtc-test.c
+
+
+all: $(SRC)
+	$(CC) $(SRC) $(CFLAGS) $(LIBS) -o rtc-test
+
+clean:
+	rm -f rtc-test
diff --git a/testcases/kernel/device-drivers/rtc/README b/testcases/kernel/device-drivers/rtc/README
new file mode 100644
index 0000000..a41bdda
--- /dev/null
+++ b/testcases/kernel/device-drivers/rtc/README
@@ -0,0 +1,29 @@
+rtc-test.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
+------------
+You have to build the complete LTP package before trying to build these tests.
+After building the complete LTP sources enter this 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 --git a/testcases/kernel/device-drivers/rtc/rtc-test.c b/testcases/kernel/device-drivers/rtc/rtc-test.c
new file mode 100644
index 0000000..6268ac9
--- /dev/null
+++ b/testcases/kernel/device-drivers/rtc/rtc-test.c
@@ -0,0 +1,219 @@
+/*   rtc-test.c 
+ *
+ *   Tests for the Real Time Clock driver.
+ *
+ *   Copyright (c) Larsen & Toubro Infotech Ltd., 2010
+ *   
+ *   Author : Silesh C V <Silesh.Vellattu@lntinfotech.com>
+ *
+ *   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 "test.h"
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <linux/rtc.h>
+#include <errno.h>
+#include <time.h>
+
+int rtc_fd = -1;
+char *TCID = "rtc01";
+int TST_TOTAL = 3;
+
+
+/* Read and Alarm Tests :  Read test reads the Date/time from RTC
+ * while Alarm test, sets the alarm to 5 seconds in future and 
+ * waits for it to ring.The ioctls tested in these tests are 
+ * RTC_RD_TIME, RTC_ALM_SET, RTC_ALM_READ, RTC_AIE_OFF  */
+
+void read_alarm_test(void)
+{
+	struct rtc_time rtc_tm;
+	int ret;
+	unsigned long data;
+	char time[25];
+	fd_set rfds;
+	struct timeval tv;
+
+	tst_resm(TINFO, "RTC READ TEST:");
+
+	 /*Read RTC Time*/
+	ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
+	if (ret == -1) {
+		tst_resm(TFAIL, "RTC_RD_TIME ioctl failed");
+		return;
+	}
+
+	tst_resm(TPASS, "RTC READ TEST Passed");
+
+	strftime(time, sizeof(time), "%D %r", (struct tm *)&rtc_tm); 
+
+	tst_resm(TINFO, "Current Date/time is  %s", time);
+
+	tst_resm(TINFO, "RTC ALARM TEST :");
+
+	/*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) {
+		tst_resm(TFAIL, "RTC_ALM_SET ioctl failed");
+		return;
+	}
+
+	/*Read current alarm time*/
+	ret = ioctl(rtc_fd, RTC_ALM_READ, &rtc_tm);
+	if (ret == -1) {
+		tst_resm(TFAIL, "RTC_ALM_READ ioctl failed");
+		return;
+	}
+
+	tst_resm(TINFO, "Alarm time set to %02d:%02d:%02d.",
+		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) {
+		tst_resm(TINFO, "RTC_AIE_ON ioctl failed");
+		return;
+	}
+
+	tst_resm(TINFO, "Waiting 5 seconds for the alarm...");
+	
+	tv.tv_sec = 6;/*set 6 seconds as the time out*/
+	tv.tv_usec = 0;
+	
+	FD_ZERO(&rfds);
+	FD_SET(rtc_fd, &rfds);
+
+	ret = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);/*wait for alarm*/
+
+	if (ret == -1) {
+		tst_resm(TFAIL, "select failed");
+		return;
+	} else if (ret) {
+		ret = read(rtc_fd, &data, sizeof(unsigned long));
+		if (ret == -1) {
+			tst_resm(TFAIL, "read failed");
+			return;
+		}	
+		tst_resm(TINFO, "Alarm rang.");
+	} else {
+		tst_resm(TFAIL, "Timed out waiting for the alarm");
+		return;
+	}
+
+	/* Disable alarm interrupts */
+	ret = ioctl(rtc_fd, RTC_AIE_OFF, 0);
+	if (ret == -1) {
+		tst_resm(TFAIL, "RTC_AIE_OFF ioctl failed");
+		return;
+	}
+	tst_resm(TPASS, "RTC ALARM TEST Passed");
+}
+
+/* Update_interrupts_test :Once the Update interrupts is enabled, 
+ * the RTC gives interrupts (1/sec) on the interrupts line(if the rtc 
+ * has one). This is tested by enabling the update interrupts 
+ * and then waiting for 5 interrupts.*/
+
+void update_interrupts_test(void)
+{
+	int ret, i;
+	unsigned long data;
+	fd_set rfds;
+	struct timeval tv;
+
+	tst_resm(TINFO, "RTC UPDATE INTERRUPTS TEST :");
+	/*Turn on update interrupts*/
+	ret = ioctl(rtc_fd, RTC_UIE_ON, 0);
+	if (ret == -1) {
+		tst_resm(TFAIL, "RTC_UIE_ON ioctl failed");
+		return;
+        }
+
+	tst_resm(TINFO, "Waiting for  5 update interrupts...");
+	for (i = 1; i < 6; i++) {
+
+		tv.tv_sec = 2; /*2 sec time out for each interrupt*/
+		tv.tv_usec = 0;
+
+		FD_ZERO(&rfds);
+		FD_SET(rtc_fd, &rfds);
+
+		ret = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
+		if (ret == -1) {
+			tst_resm(TFAIL, "select failed");
+			return;
+		} else if (ret) {
+			ret = read(rtc_fd, &data, sizeof(unsigned long));
+			if (ret == -1) {
+				tst_resm(TFAIL, "read failed");
+				return;
+			}	
+			tst_resm(TINFO, "Update interrupt %d", i);
+		} else {
+			tst_resm(TFAIL, 
+				"Timed out waiting for the update interrupt");
+			return;
+		}
+	}
+              
+	/* Turn off update interrupts */
+	ret = ioctl(rtc_fd, RTC_UIE_OFF, 0);
+	if (ret == -1) {
+		tst_resm(TFAIL, "RTC_UIE_OFF ioctl failed");
+		return;
+	}
+	tst_resm(TPASS, "RTC UPDATE INTERRUPTS TEST Passed");
+}
+
+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)
+		tst_brkm(TBROK | TERRNO, tst_exit, "couldn't open %s", rtc_dev);
+
+	/*Read and alarm tests*/
+	read_alarm_test();
+
+	/*Update interrupts test*/
+	update_interrupts_test();
+	
+	close(rtc_fd);
+
+	tst_resm(TINFO, "RTC Tests Done!");
+	return 0;
+}
-- 
1.5.6.3


[-- Attachment #3: Type: text/plain, Size: 345 bytes --]

------------------------------------------------------------------------------
Download Intel&#174; 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

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-04  5:30 [LTP] [PATCH-v3] RTC Device Driver Tests Silesh C V
@ 2010-03-04 12:55 ` Rishikesh K Rajak
  2010-03-05  5:54   ` Silesh C V
  0 siblings, 1 reply; 9+ messages in thread
From: Rishikesh K Rajak @ 2010-03-04 12:55 UTC (permalink / raw)
  To: Silesh C V; +Cc: ltp-list, Arun.sudhilal, Mohamed.Rasheed

>Rishi,

>Can you test this patch on the machine on which the tests got stuck
>earlier?

Yes i tested and found that, it is failing.

[root@x335a rtc]# ./rtc-test /dev/rtc 
rtc01       0  TINFO  :  RTC READ TEST:
rtc01       1  TPASS  :  RTC READ TEST Passed
rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
rtc01       0  TINFO  :  RTC ALARM TEST :
rtc01       0  TINFO  :  Alarm time set to 12:38:31.
rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
rtc01       2  TFAIL  :  Timed out waiting for the alarm
rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
rtc01       0  TINFO  :  Waiting for  5 update interrupts...
rtc01       0  TINFO  :  Update interrupt 1
rtc01       0  TINFO  :  Update interrupt 2
rtc01       0  TINFO  :  Update interrupt 3
rtc01       0  TINFO  :  Update interrupt 4
rtc01       0  TINFO  :  Update interrupt 5
rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
rtc01       0  TINFO  :  RTC Tests Done!
[root@x335a rtc]# ls -l /dev/rtc*
crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
[root@x335a rtc]# 



In fact while compiling there is some warning also.
[root@x335a rtc]# make
cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
-lltp  -o rtc-test
rtc-test.c: In function ‘read_alarm_test’:
rtc-test.c:64: warning: dereferencing type-punned pointer will break
strict-aliasing rules

Please solve these problems and please send me a revised patch.

-- 
Thanks & Regards
Rishi
LTP Maintainer
IBM, LTC, Bangalore
Please join IRC #ltp @ irc.freenode.net

------------------------------------------------------------------------------
Download Intel&#174; 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-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-04 12:55 ` Rishikesh K Rajak
@ 2010-03-05  5:54   ` Silesh C V
  2010-03-05  6:14     ` Garrett Cooper
  0 siblings, 1 reply; 9+ messages in thread
From: Silesh C V @ 2010-03-05  5:54 UTC (permalink / raw)
  To: ltp-list, risrajak; +Cc: Arun.sudhilal, Mohamed.Rasheed

On 3/4/10, Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> wrote:
>>Rishi,
>
>>Can you test this patch on the machine on which the tests got stuck
>>earlier?
>
> Yes i tested and found that, it is failing.

It is supposed to fail :) . What we  wanted was a way to come out of
the tests if the
alarm fails to ring.


>
> [root@x335a rtc]# ./rtc-test /dev/rtc
> rtc01       0  TINFO  :  RTC READ TEST:
> rtc01       1  TPASS  :  RTC READ TEST Passed
> rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
> rtc01       0  TINFO  :  RTC ALARM TEST :
> rtc01       0  TINFO  :  Alarm time set to 12:38:31.
> rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
> rtc01       2  TFAIL  :  Timed out waiting for the alarm
> rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
> rtc01       0  TINFO  :  Waiting for  5 update interrupts...
> rtc01       0  TINFO  :  Update interrupt 1
> rtc01       0  TINFO  :  Update interrupt 2
> rtc01       0  TINFO  :  Update interrupt 3
> rtc01       0  TINFO  :  Update interrupt 4
> rtc01       0  TINFO  :  Update interrupt 5
> rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
> rtc01       0  TINFO  :  RTC Tests Done!
> [root@x335a rtc]# ls -l /dev/rtc*
> crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
> [root@x335a rtc]#
>
>
>
> In fact while compiling there is some warning also.
> [root@x335a rtc]# make
> cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
> -lltp  -o rtc-test
> rtc-test.c: In function ‘read_alarm_test’:
> rtc-test.c:64: warning: dereferencing type-punned pointer will break
> strict-aliasing rules

I did not get this warning on gcc-4.3.0 . Anyways I think we can get rid of this
warning by using -fno-strict-aliasing option at the cost of some optimizations.
I will send you another patch.


Thanks,
Silesh


>
> Please solve these problems and please send me a revised patch.
>
> --
> Thanks & Regards
> Rishi
> LTP Maintainer
> IBM, LTC, Bangalore
> Please join IRC #ltp @ irc.freenode.net
>


-- 
Silesh

------------------------------------------------------------------------------
Download Intel&#174; 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-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-05  5:54   ` Silesh C V
@ 2010-03-05  6:14     ` Garrett Cooper
  2010-03-05  6:54       ` Silesh C V
  0 siblings, 1 reply; 9+ messages in thread
From: Garrett Cooper @ 2010-03-05  6:14 UTC (permalink / raw)
  To: Silesh C V; +Cc: ltp-list, Arun.sudhilal, Mohamed.Rasheed

On Thu, Mar 4, 2010 at 9:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
> On 3/4/10, Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> wrote:
>>>Rishi,
>>
>>>Can you test this patch on the machine on which the tests got stuck
>>>earlier?
>>
>> Yes i tested and found that, it is failing.
>
> It is supposed to fail :) . What we  wanted was a way to come out of
> the tests if the
> alarm fails to ring.
>
>
>>
>> [root@x335a rtc]# ./rtc-test /dev/rtc
>> rtc01       0  TINFO  :  RTC READ TEST:
>> rtc01       1  TPASS  :  RTC READ TEST Passed
>> rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
>> rtc01       0  TINFO  :  RTC ALARM TEST :
>> rtc01       0  TINFO  :  Alarm time set to 12:38:31.
>> rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
>> rtc01       2  TFAIL  :  Timed out waiting for the alarm
>> rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
>> rtc01       0  TINFO  :  Waiting for  5 update interrupts...
>> rtc01       0  TINFO  :  Update interrupt 1
>> rtc01       0  TINFO  :  Update interrupt 2
>> rtc01       0  TINFO  :  Update interrupt 3
>> rtc01       0  TINFO  :  Update interrupt 4
>> rtc01       0  TINFO  :  Update interrupt 5
>> rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
>> rtc01       0  TINFO  :  RTC Tests Done!
>> [root@x335a rtc]# ls -l /dev/rtc*
>> crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
>> [root@x335a rtc]#
>>
>>
>>
>> In fact while compiling there is some warning also.
>> [root@x335a rtc]# make
>> cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
>> -lltp  -o rtc-test
>> rtc-test.c: In function ‘read_alarm_test’:
>> rtc-test.c:64: warning: dereferencing type-punned pointer will break
>> strict-aliasing rules
>
> I did not get this warning on gcc-4.3.0 . Anyways I think we can get rid of this
> warning by using -fno-strict-aliasing option at the cost of some optimizations.
> I will send you another patch.
>

Or maybe just fix the code to not type-pun by converting everything to
struct tm on the fly?

Let's look at the difference between the two structures:

struct rtc_time {
        int tm_sec;
        int tm_min;
        int tm_hour;
        int tm_mday;
        int tm_mon;
        int tm_year;
        int tm_wday;
        int tm_yday;
        int tm_isdst;
};

struct tm
{
  int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
  int tm_min;                   /* Minutes.     [0-59] */
  int tm_hour;                  /* Hours.       [0-23] */
  int tm_mday;                  /* Day.         [1-31] */
  int tm_mon;                   /* Month.       [0-11] */
  int tm_year;                  /* Year - 1900.  */
  int tm_wday;                  /* Day of week. [0-6] */
  int tm_yday;                  /* Days in year.[0-365] */
  int tm_isdst;                 /* DST.         [-1/0/1]*/

#ifdef  __USE_BSD
  long int tm_gmtoff;           /* Seconds east of UTC.  */
  __const char *tm_zone;        /* Timezone abbreviation.  */
#else
  long int __tm_gmtoff;         /* Seconds east of UTC.  */
  __const char *__tm_zone;      /* Timezone abbreviation.  */
#endif
};

Note the extra fields down below -- they increase the structure size
by a non-trivial amount (12 bytes on 32-bit, 16 bytes on 64-bit),
which means that if one of the following two cases are made in
strftime tomorrow:

1. They use one of the timezone fields and it isn't properly cleared
(not the case today, but it could be on some older versions of Linux).
2. They make assumptions about the size of the memory allocated and
thus go out of bounds.

BOOM! Segfault... could worse happen in this case after the ioctl is
written out to /dev/rtc ?

>> Please solve these problems and please send me a revised patch.

Thanks,
-Garrett

------------------------------------------------------------------------------
Download Intel&#174; 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-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-05  6:14     ` Garrett Cooper
@ 2010-03-05  6:54       ` Silesh C V
  2010-03-05  7:04         ` Garrett Cooper
  0 siblings, 1 reply; 9+ messages in thread
From: Silesh C V @ 2010-03-05  6:54 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, Arun.sudhilal, Mohamed.Rasheed

On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
> On Thu, Mar 4, 2010 at 9:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
>> On 3/4/10, Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> wrote:
>>>>Rishi,
>>>
>>>>Can you test this patch on the machine on which the tests got stuck
>>>>earlier?
>>>
>>> Yes i tested and found that, it is failing.
>>
>> It is supposed to fail :) . What we  wanted was a way to come out of
>> the tests if the
>> alarm fails to ring.
>>
>>
>>>
>>> [root@x335a rtc]# ./rtc-test /dev/rtc
>>> rtc01       0  TINFO  :  RTC READ TEST:
>>> rtc01       1  TPASS  :  RTC READ TEST Passed
>>> rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
>>> rtc01       0  TINFO  :  RTC ALARM TEST :
>>> rtc01       0  TINFO  :  Alarm time set to 12:38:31.
>>> rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
>>> rtc01       2  TFAIL  :  Timed out waiting for the alarm
>>> rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
>>> rtc01       0  TINFO  :  Waiting for  5 update interrupts...
>>> rtc01       0  TINFO  :  Update interrupt 1
>>> rtc01       0  TINFO  :  Update interrupt 2
>>> rtc01       0  TINFO  :  Update interrupt 3
>>> rtc01       0  TINFO  :  Update interrupt 4
>>> rtc01       0  TINFO  :  Update interrupt 5
>>> rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
>>> rtc01       0  TINFO  :  RTC Tests Done!
>>> [root@x335a rtc]# ls -l /dev/rtc*
>>> crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
>>> [root@x335a rtc]#
>>>
>>>
>>>
>>> In fact while compiling there is some warning also.
>>> [root@x335a rtc]# make
>>> cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
>>> -lltp  -o rtc-test
>>> rtc-test.c: In function ‘read_alarm_test’:
>>> rtc-test.c:64: warning: dereferencing type-punned pointer will break
>>> strict-aliasing rules
>>
>> I did not get this warning on gcc-4.3.0 . Anyways I think we can get rid
>> of this
>> warning by using -fno-strict-aliasing option at the cost of some
>> optimizations.
>> I will send you another patch.
>>
>
> Or maybe just fix the code to not type-pun by converting everything to
> struct tm on the fly?
>
> Let's look at the difference between the two structures:
>
> struct rtc_time {
>         int tm_sec;
>         int tm_min;
>         int tm_hour;
>         int tm_mday;
>         int tm_mon;
>         int tm_year;
>         int tm_wday;
>         int tm_yday;
>         int tm_isdst;
> };
>
> struct tm
> {
>   int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
>   int tm_min;                   /* Minutes.     [0-59] */
>   int tm_hour;                  /* Hours.       [0-23] */
>   int tm_mday;                  /* Day.         [1-31] */
>   int tm_mon;                   /* Month.       [0-11] */
>   int tm_year;                  /* Year - 1900.  */
>   int tm_wday;                  /* Day of week. [0-6] */
>   int tm_yday;                  /* Days in year.[0-365] */
>   int tm_isdst;                 /* DST.         [-1/0/1]*/
>
> #ifdef  __USE_BSD
>   long int tm_gmtoff;           /* Seconds east of UTC.  */
>   __const char *tm_zone;        /* Timezone abbreviation.  */
> #else
>   long int __tm_gmtoff;         /* Seconds east of UTC.  */
>   __const char *__tm_zone;      /* Timezone abbreviation.  */
> #endif
> };
>
> Note the extra fields down below -- they increase the structure size
> by a non-trivial amount (12 bytes on 32-bit, 16 bytes on 64-bit),
> which means that if one of the following two cases are made in
> strftime tomorrow:
>
> 1. They use one of the timezone fields and it isn't properly cleared
> (not the case today, but it could be on some older versions of Linux).
> 2. They make assumptions about the size of the memory allocated and
> thus go out of bounds.
>
> BOOM! Segfault... could worse happen in this case after the ioctl is
> written out to /dev/rtc ?

OK. Can we drop strftime then ?


>
>>> Please solve these problems and please send me a revised patch.
>
> Thanks,
> -Garrett
>


-- 
Silesh

------------------------------------------------------------------------------
Download Intel&#174; 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-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-05  6:54       ` Silesh C V
@ 2010-03-05  7:04         ` Garrett Cooper
  2010-03-05  8:34           ` Silesh C V
  0 siblings, 1 reply; 9+ messages in thread
From: Garrett Cooper @ 2010-03-05  7:04 UTC (permalink / raw)
  To: Silesh C V; +Cc: ltp-list, Arun.sudhilal, Mohamed.Rasheed

On Thu, Mar 4, 2010 at 10:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
> On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
>> On Thu, Mar 4, 2010 at 9:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
>>> On 3/4/10, Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> wrote:
>>>>>Rishi,
>>>>
>>>>>Can you test this patch on the machine on which the tests got stuck
>>>>>earlier?
>>>>
>>>> Yes i tested and found that, it is failing.
>>>
>>> It is supposed to fail :) . What we  wanted was a way to come out of
>>> the tests if the
>>> alarm fails to ring.
>>>
>>>
>>>>
>>>> [root@x335a rtc]# ./rtc-test /dev/rtc
>>>> rtc01       0  TINFO  :  RTC READ TEST:
>>>> rtc01       1  TPASS  :  RTC READ TEST Passed
>>>> rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
>>>> rtc01       0  TINFO  :  RTC ALARM TEST :
>>>> rtc01       0  TINFO  :  Alarm time set to 12:38:31.
>>>> rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
>>>> rtc01       2  TFAIL  :  Timed out waiting for the alarm
>>>> rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
>>>> rtc01       0  TINFO  :  Waiting for  5 update interrupts...
>>>> rtc01       0  TINFO  :  Update interrupt 1
>>>> rtc01       0  TINFO  :  Update interrupt 2
>>>> rtc01       0  TINFO  :  Update interrupt 3
>>>> rtc01       0  TINFO  :  Update interrupt 4
>>>> rtc01       0  TINFO  :  Update interrupt 5
>>>> rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
>>>> rtc01       0  TINFO  :  RTC Tests Done!
>>>> [root@x335a rtc]# ls -l /dev/rtc*
>>>> crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
>>>> [root@x335a rtc]#
>>>>
>>>>
>>>>
>>>> In fact while compiling there is some warning also.
>>>> [root@x335a rtc]# make
>>>> cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
>>>> -lltp  -o rtc-test
>>>> rtc-test.c: In function ‘read_alarm_test’:
>>>> rtc-test.c:64: warning: dereferencing type-punned pointer will break
>>>> strict-aliasing rules
>>>
>>> I did not get this warning on gcc-4.3.0 . Anyways I think we can get rid
>>> of this
>>> warning by using -fno-strict-aliasing option at the cost of some
>>> optimizations.
>>> I will send you another patch.
>>>
>>
>> Or maybe just fix the code to not type-pun by converting everything to
>> struct tm on the fly?
>>
>> Let's look at the difference between the two structures:
>>
>> struct rtc_time {
>>         int tm_sec;
>>         int tm_min;
>>         int tm_hour;
>>         int tm_mday;
>>         int tm_mon;
>>         int tm_year;
>>         int tm_wday;
>>         int tm_yday;
>>         int tm_isdst;
>> };
>>
>> struct tm
>> {
>>   int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
>>   int tm_min;                   /* Minutes.     [0-59] */
>>   int tm_hour;                  /* Hours.       [0-23] */
>>   int tm_mday;                  /* Day.         [1-31] */
>>   int tm_mon;                   /* Month.       [0-11] */
>>   int tm_year;                  /* Year - 1900.  */
>>   int tm_wday;                  /* Day of week. [0-6] */
>>   int tm_yday;                  /* Days in year.[0-365] */
>>   int tm_isdst;                 /* DST.         [-1/0/1]*/
>>
>> #ifdef  __USE_BSD
>>   long int tm_gmtoff;           /* Seconds east of UTC.  */
>>   __const char *tm_zone;        /* Timezone abbreviation.  */
>> #else
>>   long int __tm_gmtoff;         /* Seconds east of UTC.  */
>>   __const char *__tm_zone;      /* Timezone abbreviation.  */
>> #endif
>> };
>>
>> Note the extra fields down below -- they increase the structure size
>> by a non-trivial amount (12 bytes on 32-bit, 16 bytes on 64-bit),
>> which means that if one of the following two cases are made in
>> strftime tomorrow:
>>
>> 1. They use one of the timezone fields and it isn't properly cleared
>> (not the case today, but it could be on some older versions of Linux).
>> 2. They make assumptions about the size of the memory allocated and
>> thus go out of bounds.
>>
>> BOOM! Segfault... could worse happen in this case after the ioctl is
>> written out to /dev/rtc ?
>
> OK. Can we drop strftime then ?

Why couldn't you memset ( , 0, ) the value and set the individual
fields? One of the awesome things about strftime is that it's
localization aware if you use the right format strings (I know -- a
functional nice to have, not necessarily a need to have).

Unfortunately one of 'em is American friendly only :/ :

       %D     Equivalent  to  %m/%d/%y.  (Yecch -- for Americans only.  Ameri-
              cans should note that in other countries %d/%m/%y is rather com-
              mon.   This  means  that in international context this format is
              ambiguous and should not be used.) (SU)

>>>> Please solve these problems and please send me a revised patch.

Thanks,
-Garrett

------------------------------------------------------------------------------
Download Intel&#174; 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-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-05  7:04         ` Garrett Cooper
@ 2010-03-05  8:34           ` Silesh C V
  2010-03-05 10:51             ` Garrett Cooper
  0 siblings, 1 reply; 9+ messages in thread
From: Silesh C V @ 2010-03-05  8:34 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, Arun.sudhilal, Mohamed.Rasheed

On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
> On Thu, Mar 4, 2010 at 10:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
>> On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
>>> On Thu, Mar 4, 2010 at 9:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
>>>> On 3/4/10, Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> wrote:
>>>>>>Rishi,
>>>>>
>>>>>>Can you test this patch on the machine on which the tests got stuck
>>>>>>earlier?
>>>>>
>>>>> Yes i tested and found that, it is failing.
>>>>
>>>> It is supposed to fail :) . What we  wanted was a way to come out of
>>>> the tests if the
>>>> alarm fails to ring.
>>>>
>>>>
>>>>>
>>>>> [root@x335a rtc]# ./rtc-test /dev/rtc
>>>>> rtc01       0  TINFO  :  RTC READ TEST:
>>>>> rtc01       1  TPASS  :  RTC READ TEST Passed
>>>>> rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
>>>>> rtc01       0  TINFO  :  RTC ALARM TEST :
>>>>> rtc01       0  TINFO  :  Alarm time set to 12:38:31.
>>>>> rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
>>>>> rtc01       2  TFAIL  :  Timed out waiting for the alarm
>>>>> rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
>>>>> rtc01       0  TINFO  :  Waiting for  5 update interrupts...
>>>>> rtc01       0  TINFO  :  Update interrupt 1
>>>>> rtc01       0  TINFO  :  Update interrupt 2
>>>>> rtc01       0  TINFO  :  Update interrupt 3
>>>>> rtc01       0  TINFO  :  Update interrupt 4
>>>>> rtc01       0  TINFO  :  Update interrupt 5
>>>>> rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
>>>>> rtc01       0  TINFO  :  RTC Tests Done!
>>>>> [root@x335a rtc]# ls -l /dev/rtc*
>>>>> crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
>>>>> [root@x335a rtc]#
>>>>>
>>>>>
>>>>>
>>>>> In fact while compiling there is some warning also.
>>>>> [root@x335a rtc]# make
>>>>> cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
>>>>> -lltp  -o rtc-test
>>>>> rtc-test.c: In function ‘read_alarm_test’:
>>>>> rtc-test.c:64: warning: dereferencing type-punned pointer will break
>>>>> strict-aliasing rules
>>>>
>>>> I did not get this warning on gcc-4.3.0 . Anyways I think we can get rid
>>>> of this
>>>> warning by using -fno-strict-aliasing option at the cost of some
>>>> optimizations.
>>>> I will send you another patch.
>>>>
>>>
>>> Or maybe just fix the code to not type-pun by converting everything to
>>> struct tm on the fly?
>>>
>>> Let's look at the difference between the two structures:
>>>
>>> struct rtc_time {
>>>         int tm_sec;
>>>         int tm_min;
>>>         int tm_hour;
>>>         int tm_mday;
>>>         int tm_mon;
>>>         int tm_year;
>>>         int tm_wday;
>>>         int tm_yday;
>>>         int tm_isdst;
>>> };
>>>
>>> struct tm
>>> {
>>>   int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
>>>   int tm_min;                   /* Minutes.     [0-59] */
>>>   int tm_hour;                  /* Hours.       [0-23] */
>>>   int tm_mday;                  /* Day.         [1-31] */
>>>   int tm_mon;                   /* Month.       [0-11] */
>>>   int tm_year;                  /* Year - 1900.  */
>>>   int tm_wday;                  /* Day of week. [0-6] */
>>>   int tm_yday;                  /* Days in year.[0-365] */
>>>   int tm_isdst;                 /* DST.         [-1/0/1]*/
>>>
>>> #ifdef  __USE_BSD
>>>   long int tm_gmtoff;           /* Seconds east of UTC.  */
>>>   __const char *tm_zone;        /* Timezone abbreviation.  */
>>> #else
>>>   long int __tm_gmtoff;         /* Seconds east of UTC.  */
>>>   __const char *__tm_zone;      /* Timezone abbreviation.  */
>>> #endif
>>> };
>>>
>>> Note the extra fields down below -- they increase the structure size
>>> by a non-trivial amount (12 bytes on 32-bit, 16 bytes on 64-bit),
>>> which means that if one of the following two cases are made in
>>> strftime tomorrow:
>>>
>>> 1. They use one of the timezone fields and it isn't properly cleared
>>> (not the case today, but it could be on some older versions of Linux).
>>> 2. They make assumptions about the size of the memory allocated and
>>> thus go out of bounds.
>>>
>>> BOOM! Segfault... could worse happen in this case after the ioctl is
>>> written out to /dev/rtc ?
>>
>> OK. Can we drop strftime then ?
>
> Why couldn't you memset ( , 0, ) the value and set the individual
> fields?


Sorry . But I could not understand what you meant by setting the
individual fields.


 One of the awesome things about strftime is that it's
> localization aware if you use the right format strings (I know -- a
> functional nice to have, not necessarily a need to have).
>
> Unfortunately one of 'em is American friendly only :/ :
>
>        %D     Equivalent  to  %m/%d/%y.  (Yecch -- for Americans only.
> Ameri-
>               cans should note that in other countries %d/%m/%y is rather
> com-
>               mon.   This  means  that in international context this format
> is
>               ambiguous and should not be used.) (SU)
>
>>>>> Please solve these problems and please send me a revised patch.
>
> Thanks,
> -Garrett
>
Thanks,
Silesh

-- 
Silesh

------------------------------------------------------------------------------
Download Intel&#174; 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-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-05  8:34           ` Silesh C V
@ 2010-03-05 10:51             ` Garrett Cooper
  2010-03-06  6:15               ` Silesh C V
  0 siblings, 1 reply; 9+ messages in thread
From: Garrett Cooper @ 2010-03-05 10:51 UTC (permalink / raw)
  To: Silesh C V; +Cc: ltp-list, Arun.sudhilal, Mohamed.Rasheed

On Fri, Mar 5, 2010 at 12:34 AM, Silesh C V <saileshcv@gmail.com> wrote:
> On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
>> On Thu, Mar 4, 2010 at 10:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
>>> On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
>>>> On Thu, Mar 4, 2010 at 9:54 PM, Silesh C V <saileshcv@gmail.com> wrote:
>>>>> On 3/4/10, Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> wrote:
>>>>>>>Rishi,
>>>>>>
>>>>>>>Can you test this patch on the machine on which the tests got stuck
>>>>>>>earlier?
>>>>>>
>>>>>> Yes i tested and found that, it is failing.
>>>>>
>>>>> It is supposed to fail :) . What we  wanted was a way to come out of
>>>>> the tests if the
>>>>> alarm fails to ring.
>>>>>
>>>>>
>>>>>>
>>>>>> [root@x335a rtc]# ./rtc-test /dev/rtc
>>>>>> rtc01       0  TINFO  :  RTC READ TEST:
>>>>>> rtc01       1  TPASS  :  RTC READ TEST Passed
>>>>>> rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
>>>>>> rtc01       0  TINFO  :  RTC ALARM TEST :
>>>>>> rtc01       0  TINFO  :  Alarm time set to 12:38:31.
>>>>>> rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
>>>>>> rtc01       2  TFAIL  :  Timed out waiting for the alarm
>>>>>> rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
>>>>>> rtc01       0  TINFO  :  Waiting for  5 update interrupts...
>>>>>> rtc01       0  TINFO  :  Update interrupt 1
>>>>>> rtc01       0  TINFO  :  Update interrupt 2
>>>>>> rtc01       0  TINFO  :  Update interrupt 3
>>>>>> rtc01       0  TINFO  :  Update interrupt 4
>>>>>> rtc01       0  TINFO  :  Update interrupt 5
>>>>>> rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
>>>>>> rtc01       0  TINFO  :  RTC Tests Done!
>>>>>> [root@x335a rtc]# ls -l /dev/rtc*
>>>>>> crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
>>>>>> [root@x335a rtc]#
>>>>>>
>>>>>>
>>>>>>
>>>>>> In fact while compiling there is some warning also.
>>>>>> [root@x335a rtc]# make
>>>>>> cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
>>>>>> -lltp  -o rtc-test
>>>>>> rtc-test.c: In function ‘read_alarm_test’:
>>>>>> rtc-test.c:64: warning: dereferencing type-punned pointer will break
>>>>>> strict-aliasing rules
>>>>>
>>>>> I did not get this warning on gcc-4.3.0 . Anyways I think we can get rid
>>>>> of this
>>>>> warning by using -fno-strict-aliasing option at the cost of some
>>>>> optimizations.
>>>>> I will send you another patch.
>>>>>
>>>>
>>>> Or maybe just fix the code to not type-pun by converting everything to
>>>> struct tm on the fly?
>>>>
>>>> Let's look at the difference between the two structures:
>>>>
>>>> struct rtc_time {
>>>>         int tm_sec;
>>>>         int tm_min;
>>>>         int tm_hour;
>>>>         int tm_mday;
>>>>         int tm_mon;
>>>>         int tm_year;
>>>>         int tm_wday;
>>>>         int tm_yday;
>>>>         int tm_isdst;
>>>> };
>>>>
>>>> struct tm
>>>> {
>>>>   int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
>>>>   int tm_min;                   /* Minutes.     [0-59] */
>>>>   int tm_hour;                  /* Hours.       [0-23] */
>>>>   int tm_mday;                  /* Day.         [1-31] */
>>>>   int tm_mon;                   /* Month.       [0-11] */
>>>>   int tm_year;                  /* Year - 1900.  */
>>>>   int tm_wday;                  /* Day of week. [0-6] */
>>>>   int tm_yday;                  /* Days in year.[0-365] */
>>>>   int tm_isdst;                 /* DST.         [-1/0/1]*/
>>>>
>>>> #ifdef  __USE_BSD
>>>>   long int tm_gmtoff;           /* Seconds east of UTC.  */
>>>>   __const char *tm_zone;        /* Timezone abbreviation.  */
>>>> #else
>>>>   long int __tm_gmtoff;         /* Seconds east of UTC.  */
>>>>   __const char *__tm_zone;      /* Timezone abbreviation.  */
>>>> #endif
>>>> };
>>>>
>>>> Note the extra fields down below -- they increase the structure size
>>>> by a non-trivial amount (12 bytes on 32-bit, 16 bytes on 64-bit),
>>>> which means that if one of the following two cases are made in
>>>> strftime tomorrow:
>>>>
>>>> 1. They use one of the timezone fields and it isn't properly cleared
>>>> (not the case today, but it could be on some older versions of Linux).
>>>> 2. They make assumptions about the size of the memory allocated and
>>>> thus go out of bounds.
>>>>
>>>> BOOM! Segfault... could worse happen in this case after the ioctl is
>>>> written out to /dev/rtc ?
>>>
>>> OK. Can we drop strftime then ?
>>
>> Why couldn't you memset ( , 0, ) the value and set the individual
>> fields?
>
>
> Sorry . But I could not understand what you meant by setting the
> individual fields.

struct tm thetime;

memset(&thetime, 0, sizeof(thetime));
thetime.tm_sec = rtc_tm.tm_sec;
/* ... */

>  One of the awesome things about strftime is that it's
>> localization aware if you use the right format strings (I know -- a
>> functional nice to have, not necessarily a need to have).
>>
>> Unfortunately one of 'em is American friendly only :/ :
>>
>>        %D     Equivalent  to  %m/%d/%y.  (Yecch -- for Americans only.
>> Ameri-
>>               cans should note that in other countries %d/%m/%y is rather
>> com-
>>               mon.   This  means  that in international context this format
>> is
>>               ambiguous and should not be used.) (SU)
>>
>>>>>> Please solve these problems and please send me a revised patch.
>>
>> Thanks,
>> -Garrett
>>
> Thanks,
> Silesh
>
> --
> Silesh
>

------------------------------------------------------------------------------
Download Intel&#174; 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-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH-v3] RTC Device Driver Tests
  2010-03-05 10:51             ` Garrett Cooper
@ 2010-03-06  6:15               ` Silesh C V
  0 siblings, 0 replies; 9+ messages in thread
From: Silesh C V @ 2010-03-06  6:15 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, Arun.sudhilal, Mohamed.Rasheed


[-- Attachment #1.1: Type: text/plain, Size: 6422 bytes --]

On Fri, Mar 5, 2010 at 4:21 PM, Garrett Cooper <yanegomi@gmail.com> wrote:

> On Fri, Mar 5, 2010 at 12:34 AM, Silesh C V <saileshcv@gmail.com> wrote:
> > On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
> >> On Thu, Mar 4, 2010 at 10:54 PM, Silesh C V <saileshcv@gmail.com>
> wrote:
> >>> On 3/5/10, Garrett Cooper <yanegomi@gmail.com> wrote:
> >>>> On Thu, Mar 4, 2010 at 9:54 PM, Silesh C V <saileshcv@gmail.com>
> wrote:
> >>>>> On 3/4/10, Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> wrote:
> >>>>>>>Rishi,
> >>>>>>
> >>>>>>>Can you test this patch on the machine on which the tests got stuck
> >>>>>>>earlier?
> >>>>>>
> >>>>>> Yes i tested and found that, it is failing.
> >>>>>
> >>>>> It is supposed to fail :) . What we  wanted was a way to come out of
> >>>>> the tests if the
> >>>>> alarm fails to ring.
> >>>>>
> >>>>>
> >>>>>>
> >>>>>> [root@x335a rtc]# ./rtc-test /dev/rtc
> >>>>>> rtc01       0  TINFO  :  RTC READ TEST:
> >>>>>> rtc01       1  TPASS  :  RTC READ TEST Passed
> >>>>>> rtc01       0  TINFO  :  Current Date/time is  03/03/10 12:38:26 PM
> >>>>>> rtc01       0  TINFO  :  RTC ALARM TEST :
> >>>>>> rtc01       0  TINFO  :  Alarm time set to 12:38:31.
> >>>>>> rtc01       0  TINFO  :  Waiting 5 seconds for the alarm...
> >>>>>> rtc01       2  TFAIL  :  Timed out waiting for the alarm
> >>>>>> rtc01       0  TINFO  :  RTC UPDATE INTERRUPTS TEST :
> >>>>>> rtc01       0  TINFO  :  Waiting for  5 update interrupts...
> >>>>>> rtc01       0  TINFO  :  Update interrupt 1
> >>>>>> rtc01       0  TINFO  :  Update interrupt 2
> >>>>>> rtc01       0  TINFO  :  Update interrupt 3
> >>>>>> rtc01       0  TINFO  :  Update interrupt 4
> >>>>>> rtc01       0  TINFO  :  Update interrupt 5
> >>>>>> rtc01       3  TPASS  :  RTC UPDATE INTERRUPTS TEST Passed
> >>>>>> rtc01       0  TINFO  :  RTC Tests Done!
> >>>>>> [root@x335a rtc]# ls -l /dev/rtc*
> >>>>>> crw-r--r-- 1 root root 10, 135 Feb 20 13:51 /dev/rtc
> >>>>>> [root@x335a rtc]#
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> In fact while compiling there is some warning also.
> >>>>>> [root@x335a rtc]# make
> >>>>>> cc rtc-test.c -O2 -Wall -I ../../../../include/ -L ../../../../lib/
> >>>>>> -lltp  -o rtc-test
> >>>>>> rtc-test.c: In function ‘read_alarm_test’:
> >>>>>> rtc-test.c:64: warning: dereferencing type-punned pointer will break
> >>>>>> strict-aliasing rules
> >>>>>
> >>>>> I did not get this warning on gcc-4.3.0 . Anyways I think we can get
> rid
> >>>>> of this
> >>>>> warning by using -fno-strict-aliasing option at the cost of some
> >>>>> optimizations.
> >>>>> I will send you another patch.
> >>>>>
> >>>>
> >>>> Or maybe just fix the code to not type-pun by converting everything to
> >>>> struct tm on the fly?
> >>>>
> >>>> Let's look at the difference between the two structures:
> >>>>
> >>>> struct rtc_time {
> >>>>         int tm_sec;
> >>>>         int tm_min;
> >>>>         int tm_hour;
> >>>>         int tm_mday;
> >>>>         int tm_mon;
> >>>>         int tm_year;
> >>>>         int tm_wday;
> >>>>         int tm_yday;
> >>>>         int tm_isdst;
> >>>> };
> >>>>
> >>>> struct tm
> >>>> {
> >>>>   int tm_sec;                   /* Seconds.     [0-60] (1 leap second)
> */
> >>>>   int tm_min;                   /* Minutes.     [0-59] */
> >>>>   int tm_hour;                  /* Hours.       [0-23] */
> >>>>   int tm_mday;                  /* Day.         [1-31] */
> >>>>   int tm_mon;                   /* Month.       [0-11] */
> >>>>   int tm_year;                  /* Year - 1900.  */
> >>>>   int tm_wday;                  /* Day of week. [0-6] */
> >>>>   int tm_yday;                  /* Days in year.[0-365] */
> >>>>   int tm_isdst;                 /* DST.         [-1/0/1]*/
> >>>>
> >>>> #ifdef  __USE_BSD
> >>>>   long int tm_gmtoff;           /* Seconds east of UTC.  */
> >>>>   __const char *tm_zone;        /* Timezone abbreviation.  */
> >>>> #else
> >>>>   long int __tm_gmtoff;         /* Seconds east of UTC.  */
> >>>>   __const char *__tm_zone;      /* Timezone abbreviation.  */
> >>>> #endif
> >>>> };
> >>>>
> >>>> Note the extra fields down below -- they increase the structure size
> >>>> by a non-trivial amount (12 bytes on 32-bit, 16 bytes on 64-bit),
> >>>> which means that if one of the following two cases are made in
> >>>> strftime tomorrow:
> >>>>
> >>>> 1. They use one of the timezone fields and it isn't properly cleared
> >>>> (not the case today, but it could be on some older versions of Linux).
> >>>> 2. They make assumptions about the size of the memory allocated and
> >>>> thus go out of bounds.
> >>>>
> >>>> BOOM! Segfault... could worse happen in this case after the ioctl is
> >>>> written out to /dev/rtc ?
> >>>
> >>> OK. Can we drop strftime then ?
> >>
> >> Why couldn't you memset ( , 0, ) the value and set the individual
> >> fields?
> >
> >
> > Sorry . But I could not understand what you meant by setting the
> > individual fields.
>
> struct tm thetime;
>
> memset(&thetime, 0, sizeof(thetime));
> thetime.tm_sec = rtc_tm.tm_sec;
> /* ... */
>

I think doing this just for formatting and printing the time is a slight
overhead.
The  better approach would be to  print the time by accessing
the individual fields so that we can avoid all the conversion and type
casting
from rtc_tm to tm . Although we will miss some of the great features of
sfrtime,
this will save the code from being unnecessarily complex.I will send another
patch
omitting sfrtime.


Thanks,
Silesh


>
> >  One of the awesome things about strftime is that it's
> >> localization aware if you use the right format strings (I know -- a
> >> functional nice to have, not necessarily a need to have).
> >>
> >> Unfortunately one of 'em is American friendly only :/ :
> >>
> >>        %D     Equivalent  to  %m/%d/%y.  (Yecch -- for Americans only.
> >> Ameri-
> >>               cans should note that in other countries %d/%m/%y is
> rather
> >> com-
> >>               mon.   This  means  that in international context this
> format
> >> is
> >>               ambiguous and should not be used.) (SU)
> >>
> >>>>>> Please solve these problems and please send me a revised patch.
> >>
> >> Thanks,
> >> -Garrett
> >>
> > Thanks,
> > Silesh
> >
> > --
> > Silesh
> >
>



-- 
Silesh

[-- Attachment #1.2: Type: text/html, Size: 9262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 345 bytes --]

------------------------------------------------------------------------------
Download Intel&#174; 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

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2010-03-06  6:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04  5:30 [LTP] [PATCH-v3] RTC Device Driver Tests Silesh C V
2010-03-04 12:55 ` Rishikesh K Rajak
2010-03-05  5:54   ` Silesh C V
2010-03-05  6:14     ` Garrett Cooper
2010-03-05  6:54       ` Silesh C V
2010-03-05  7:04         ` Garrett Cooper
2010-03-05  8:34           ` Silesh C V
2010-03-05 10:51             ` Garrett Cooper
2010-03-06  6:15               ` Silesh C V

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