Bugzilla bug #39674: added a test selintr.c to verify that the select()
authorwtc%netscape.com
Thu, 25 May 2000 21:29:38 +0000
changeset 1380 8a74c7a2321050373daf517d60a211ccfb0918ce
parent 1379 38258f8a1f1d64707ac003c4f3f28b4c98cde5a7
child 1381 69bfb358fe2ec3dfb53b82e481257c89746a973b
push idunknown
push userunknown
push dateunknown
bugs39674
Bugzilla bug #39674: added a test selintr.c to verify that the select() wrapper in classic NSPR properly blocks the SIGALRM clocks. Added file: selintr.c Modified files: Makefile, Makefile.in, runtests.ksh
pr/tests/Makefile
pr/tests/Makefile.in
pr/tests/runtests.ksh
pr/tests/selintr.c
--- a/pr/tests/Makefile
+++ b/pr/tests/Makefile
@@ -124,16 +124,17 @@ CSRCS =             \
 	ranfile.c       \
 	randseed.c      \
 	rwlocktest.c    \
 	sel_spd.c  		\
 	selct_er.c	    \
 	selct_nm.c	    \
 	selct_to.c	    \
 	select2.c  		\
+	selintr.c  		\
 	sem.c 	  		\
 	sema.c 	  		\
 	semaerr.c 		\
 	semaerr1.c 		\
 	semaping.c 		\
 	semapong.c 		\
 	sendzlf.c 		\
 	server_test.c	\
--- a/pr/tests/Makefile.in
+++ b/pr/tests/Makefile.in
@@ -128,16 +128,17 @@ CSRCS =             \
 	ranfile.c       \
 	randseed.c	\
 	rwlocktest.c    \
 	sel_spd.c  		\
 	selct_er.c	    \
 	selct_nm.c	    \
 	selct_to.c	    \
 	select2.c  		\
+	selintr.c  		\
 	sem.c 	  		\
 	sema.c			\
 	semaerr.c		\
 	semaerr1.c		\
 	semaping.c		\
 	semapong.c		\
 	sendzlf.c		\
 	server_test.c	\
--- a/pr/tests/runtests.ksh
+++ b/pr/tests/runtests.ksh
@@ -146,16 +146,17 @@ priotest
 provider
 ranfile
 randseed
 rwlocktest
 sel_spd
 selct_er
 selct_nm
 selct_to
+selintr
 sema
 semaerr
 semaping
 sendzlf
 server_test
 servr_kk
 servr_uk
 servr_ku
new file mode 100644
--- /dev/null
+++ b/pr/tests/selintr.c
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.1 (the "NPL"); you may not use this file except in
+ * compliance with the NPL.  You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ * 
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ * 
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation.  Portions created by Netscape are
+ * Copyright (C) 2000 Netscape Communications Corporation.  All Rights
+ * Reserved.
+ */
+
+/*
+ * Test whether classic NSPR's select() wrapper properly blocks
+ * the periodic SIGALRM clocks.  On some platforms (such as
+ * HP-UX and SINIX) an interrupted select() system call is
+ * restarted with the originally specified timeout, ignoring
+ * the time that has elapsed.  If a select() call is interrupted
+ * repeatedly, it will never time out.  (See Bugzilla bug #39674.)
+ */
+
+#if !defined(XP_UNIX)
+
+/*
+ * This test is applicable to Unix only.
+ */
+
+int main()
+{
+    return 0;
+}
+
+#else /* XP_UNIX */
+
+#include "nspr.h"
+
+#include <sys/time.h>
+#include <stdio.h>
+
+int main()
+{
+    struct timeval timeout;
+    int rv;
+
+    PR_SetError(0, 0);  /* force NSPR to initialize */
+    PR_EnableClockInterrupts();
+
+    /* 2 seconds timeout */
+    timeout.tv_sec = 2;
+    timeout.tv_usec = 0;
+    rv = select(1, NULL, NULL, NULL, &timeout);
+    printf("select returned %d\n", rv);
+    return 0;
+}
+
+#endif /* XP_UNIX */