summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-06-06 07:35:55 +0000
committernw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-06-06 07:35:55 +0000
commitdfbe40dcc7209cd1281661d049bf50be5318e23f (patch)
treeff73596b356583777a13106178e16eb68be468a3
parent3fa821dd017eb15d11108da6097cba75dba441b5 (diff)
downloadATCD-dfbe40dcc7209cd1281661d049bf50be5318e23f.tar.gz
*** empty log message ***
-rw-r--r--ChangeLog-97a7
-rw-r--r--tests/Sigset_Ops_Test.cpp118
-rw-r--r--tests/run_tests.bat1
-rwxr-xr-xtests/run_tests.sh3
4 files changed, 129 insertions, 0 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a
index 52455f6c199..5da4fd2b7c6 100644
--- a/ChangeLog-97a
+++ b/ChangeLog-97a
@@ -1,3 +1,10 @@
+Fri Jun 06 02:16:08 1997 <nw1@COYOTE>
+
+ * Sigset_Ops_Test.cpp: Added to test correct implementation of
+ sigset manipulating functions.
+
+ * run_tests.{sh,bat}, Makefile: Added Sigset_Ops_Test.
+
Thu Jun 05 20:32:39 1997 David L. Levine <levine@cs.wustl.edu>
* tests/Timer_Queue_Test.cpp (randomize_array): removed static
diff --git a/tests/Sigset_Ops_Test.cpp b/tests/Sigset_Ops_Test.cpp
new file mode 100644
index 00000000000..ddf5fa560a9
--- /dev/null
+++ b/tests/Sigset_Ops_Test.cpp
@@ -0,0 +1,118 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// tests
+//
+// = FILENAME
+// Sigset_Ops_Test.cpp
+//
+// = DESCRIPTION
+// This program tests the correctness of following functions.
+// sigfillset(), sigemptyset(), sigaddset(), sigdelset(),
+// sigismember().
+//
+// = AUTHOR
+// Nanbor Wang
+//
+// ============================================================================
+
+
+#include "ace/OS.h"
+#include "test_config.h"
+
+void
+siglistset(sigset_t x, int *sigset)
+{
+ int empty = 1 ;
+ int retv = 0 ;
+
+ ACE_DEBUG ((LM_DEBUG, "Signal(s) in the set = %08x:\n ", x)) ;
+ for (int i = 1; i < NSIG; i++) {
+ if ((retv = ACE_OS::sigismember (&x, i)) > 0) {
+ ACE_DEBUG ((LM_DEBUG, " %d", i)) ;
+ empty = 0 ;
+ }
+ ACE_ASSERT ((sigset [i] ? retv > 0 : retv <= 0)) ;
+ }
+ if (empty) {
+ ACE_DEBUG ((LM_DEBUG, "Empty!!\n\n")) ;
+ }
+ else {
+ ACE_DEBUG ((LM_DEBUG, "\n\n")) ;
+ }
+}
+
+int
+main (int, char *[])
+{
+ ACE_START_TEST ("Sigset_Ops_Test");
+
+#if defined (ACE_LACKS_SIGSET)
+ ACE_DEBUG ((LM_DEBUG, "%n uses ACE implementation of sigset*() functions.\n\n")) ;
+#else
+ ACE_DEBUG ((LM_DEBUG, "%n uses platform's native sigset*() functions.\n\n")) ;
+#endif
+
+ sigset_t x = 0 ; // examined sigset
+ int sigset [NSIG] ; // a comparison sigset
+
+ // Two test signal numbers. I choose these low value signals to
+ // avoid exceeding the NSIG range.
+ const int tsig1 = 5 ;
+ const int tsig2 = 8 ;
+
+
+ // Testing sigfillset
+ ACE_OS::sigfillset (&x) ;
+
+ // fill the comparison set
+ for (int i = 0 ; i < NSIG ; i++)
+ sigset [i] = 1 ;
+ siglistset (x, sigset) ;
+
+ // testing sigemptyset
+ ACE_OS::sigemptyset (&x) ;
+
+ // empty the comparison set
+ for (int i = 0 ; i < NSIG ; i++)
+ sigset [i] = 0 ;
+ siglistset (x, sigset) ;
+
+ // add the first signal into set
+ ACE_OS::sigaddset (&x, tsig1) ;
+ sigset [tsig1] = 1 ;
+ siglistset (x, sigset) ;
+
+ // add the second signal into set
+ ACE_OS::sigaddset (&x, tsig2) ;
+ sigset [tsig2] = 1 ;
+ siglistset (x, sigset) ;
+
+ // then remove it
+ ACE_OS::sigdelset(&x, tsig1) ;
+ sigset [tsig1] = 0 ;
+ siglistset(x, sigset) ;
+
+ // remove the second one
+ ACE_OS::sigdelset(&x, tsig2) ;
+ sigset [tsig2] = 0 ;
+ siglistset(x, sigset) ;
+
+ // Now testing out of bound signal
+ if (ACE_OS::sigismember (&x, NSIG) >= 0)
+ ACE_ERROR ((LM_ERROR, "Platform doesn't check for valid signal number.\n")) ;
+ ACE_ASSERT (ACE_OS::last_error() == EINVAL) ;
+
+ // Test if platform can catch invalid sigset error
+ // Currently, I can only think of passing a NULL ptr
+ // If you know other situations that fall into this
+ // catagory, please let me know. Thanks.
+ ACE_DEBUG ((LM_ERROR, "Now testing invalid sigset. If your platform gets a \nsegmentation fault, then it doesn't check the error properly.\n")) ;
+
+ ACE_ASSERT (ACE_OS::sigfillset (NULL) < 0 && ACE_OS::last_error() == EFAULT) ;
+
+ ACE_END_TEST;
+ return 0;
+}
diff --git a/tests/run_tests.bat b/tests/run_tests.bat
index bd2b0d0369e..a2dcac35fd2 100644
--- a/tests/run_tests.bat
+++ b/tests/run_tests.bat
@@ -14,6 +14,7 @@ Message_Queue_Test
Simple_Message_Block_Test
Message_Block_Test
MM_Shared_Memory_Test
+Sigset_Ops_Test
@echo The following test runs for about 1 minute
Mutex_Test
Naming_Test
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 3a4c45d4821..68d7cb4f096 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -51,6 +51,9 @@ run Mem_Map_Test # uses Mem_Map
run SV_Shared_Memory_Test # uses SV_Shared_Memory, fork
run MM_Shared_Memory_Test
+
+run Sigset_Ops_Test # uses sigset*() functions
+
run Mutex_Test # uses Process_Mutex
run Timer_Queue_Test # uses Event_Handler, Timer_Queue