Commit [a416ab] Maximize Restore History

Major reorganisation of source code; new routine and tests added.

rpj rpj 2002-02-18

1 2 3 .. 8 > >> (Page 1 of 8)
removed attr_getscope.c
removed attr_getstackaddr.c
removed attr_getstacksize.c
removed attr_init.c
removed attr_is_attr.c
removed attr_setdetachstate.c
removed attr_setscope.c
removed attr_setstackaddr.c
removed attr_setstacksize.c
removed barrier_attr_destroy.c
changed tests/ChangeLog
changed tests/GNUmakefile
changed tests/Makefile
changed tests/condvar3_1.c
changed tests/exit4.c
changed ChangeLog
changed GNUmakefile
changed Makefile
changed Nmakefile.tests
changed attr.c
changed barrier.c
copied attr_destroy.c -> tests/condvar1_1.c
copied attr_getdetachstate.c -> tests/condvar1_2.c
attr_getscope.c
File was removed.
attr_getstackaddr.c
File was removed.
attr_getstacksize.c
File was removed.
attr_init.c
File was removed.
attr_is_attr.c
File was removed.
attr_setdetachstate.c
File was removed.
attr_setscope.c
File was removed.
attr_setstackaddr.c
File was removed.
attr_setstacksize.c
File was removed.
barrier_attr_destroy.c
File was removed.
tests/ChangeLog Diff Switch to side-by-side view
Loading...
tests/GNUmakefile Diff Switch to side-by-side view
Loading...
tests/Makefile Diff Switch to side-by-side view
Loading...
tests/condvar3_1.c Diff Switch to side-by-side view
Loading...
tests/exit4.c Diff Switch to side-by-side view
Loading...
ChangeLog Diff Switch to side-by-side view
Loading...
GNUmakefile Diff Switch to side-by-side view
Loading...
Makefile Diff Switch to side-by-side view
Loading...
Nmakefile.tests Diff Switch to side-by-side view
Loading...
attr.c Diff Switch to side-by-side view
Loading...
barrier.c Diff Switch to side-by-side view
Loading...
attr_destroy.c to tests/condvar1_1.c
--- a/attr_destroy.c
+++ b/tests/condvar1_1.c
@@ -1,8 +1,8 @@
 /*
- * attr_destroy.c
+ * File: condvar1_1.c
  *
- * Description:
- * This translation unit implements operations on thread attribute objects.
+ *
+ * --------------------------------------------------------------------------
  *
  * --------------------------------------------------------------------------
  *
@@ -32,49 +32,86 @@
  *      License along with this library in the file COPYING.LIB;
  *      if not, write to the Free Software Foundation, Inc.,
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test Synopsis:
+ * - Test CV linked list management.
+ *
+ * Test Method (Validation or Falsification):
+ * - Validation:
+ *   Initiate and destry several CVs in random order.
+ *
+ * Requirements Tested:
+ * - 
+ *
+ * Features Tested:
+ * - 
+ *
+ * Cases Tested:
+ * - 
+ *
+ * Description:
+ * - Creates and then imediately destroys a CV. Does not
+ *   test the CV.
+ *
+ * Environment:
+ * - 
+ *
+ * Input:
+ * - None.
+ *
+ * Output:
+ * - File name, Line number, and failed expression on failure.
+ * - No output on success.
+ *
+ * Assumptions:
+ * -
+ *
+ * Pass Criteria:
+ * - All initialised CVs destroyed without segfault.
+ * - Successfully broadcasts all remaining CVs after
+ *   each CV is removed.
+ *
+ * Fail Criteria:
  */
 
-#include "pthread.h"
-#include "implement.h"
+#include <stdlib.h>
+#include "test.h"
 
+enum {
+  NUM_CV = 100
+};
+
+static pthread_cond_t cv[NUM_CV];
 
 int
-pthread_attr_destroy(pthread_attr_t *attr)
-     /*
-      * ------------------------------------------------------
-      * DOCPUBLIC
-      *      Destroys a thread attributes object.
-      *
-      * PARAMETERS
-      *      attr
-      *              pointer to an instance of pthread_attr_t
-      *
-      *
-      * DESCRIPTION
-      *      Destroys a thread attributes object.
-      *
-      *      NOTES:
-      *              1)      Does not affect threads created with 'attr'.
-      *
-      * RESULTS
-      *              0               successfully destroyed attr,
-      *              EINVAL          'attr' is invalid.
-      *
-      * ------------------------------------------------------
-      */
+main()
 {
-  if (is_attr(attr) != 0)
+  int i, j;
+
+  for (i = 0; i < NUM_CV; i++)
     {
-      return EINVAL;
+      /* Traverse the list before every init of a CV. */
+      assert(pthread_timechange_handler_np(NULL) == (void *) 0);
+      assert(pthread_cond_init(&cv[i], NULL) == 0);
     }
 
-  /*
-   * Set the attribute object to a specific invalid value.
-   */
-  (*attr)->valid = 0;
-  free (*attr);
-  *attr = NULL;
+  j = NUM_CV;
+  (void) srand((unsigned)time(NULL));
+
+  do
+    {
+      i = (NUM_CV - 1) * rand() / RAND_MAX;
+      if (cv[i] != NULL)
+        {
+          j--;
+          assert(pthread_cond_destroy(&cv[i]) == 0);
+          /* Traverse the list every time we remove a CV. */
+          assert(pthread_timechange_handler_np(NULL) == (void *) 0);
+        }
+    }
+  while (j > 0);
 
   return 0;
 }
-
attr_getdetachstate.c to tests/condvar1_2.c
--- a/attr_getdetachstate.c
+++ b/tests/condvar1_2.c
@@ -1,8 +1,8 @@
 /*
- * attr_getdetachstate.c
+ * File: condvar1_2.c
  *
- * Description:
- * This translation unit implements operations on thread attribute objects.
+ *
+ * --------------------------------------------------------------------------
  *
  * --------------------------------------------------------------------------
  *
@@ -32,58 +32,91 @@
  *      License along with this library in the file COPYING.LIB;
  *      if not, write to the Free Software Foundation, Inc.,
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Test Synopsis:
+ * - Test CV linked list management and serialisation.
+ *
+ * Test Method (Validation or Falsification):
+ * - Validation:
+ *   Initiate and destroy several CVs in random order.
+ *   Asynchronously traverse the CV list and broadcast.
+ *
+ * Requirements Tested:
+ * - 
+ *
+ * Features Tested:
+ * - 
+ *
+ * Cases Tested:
+ * - 
+ *
+ * Description:
+ * - Creates and then imediately destroys a CV. Does not
+ *   test the CV.
+ *
+ * Environment:
+ * - 
+ *
+ * Input:
+ * - None.
+ *
+ * Output:
+ * - File name, Line number, and failed expression on failure.
+ * - No output on success.
+ *
+ * Assumptions:
+ * -
+ *
+ * Pass Criteria:
+ * - All initialised CVs destroyed without segfault.
+ * - Successfully broadcasts all remaining CVs after
+ *   each CV is removed.
+ *
+ * Fail Criteria:
  */
 
-#include "pthread.h"
-#include "implement.h"
+#include <stdlib.h>
+#include "test.h"
 
+enum {
+  NUM_CV = 100
+};
+
+static pthread_cond_t cv[NUM_CV];
 
 int
-pthread_attr_getdetachstate(const pthread_attr_t *attr,
-                            int *detachstate)
-     /*
-      * ------------------------------------------------------
-      * DOCPUBLIC
-      *      This function determines whether threads created with
-      *      'attr' will run detached.
-      *
-      * PARAMETERS
-      *      attr
-      *              pointer to an instance of pthread_attr_t
-      *
-      *      detachstate
-      *              pointer to an integer into which is returned one
-      *              of:
-      *
-      *              PTHREAD_CREATE_JOINABLE
-      *                              Thread ID is valid, must be joined
-      *
-      *              PTHREAD_CREATE_DETACHED
-      *                              Thread ID is invalid, cannot be joined,
-      *                              canceled, or modified
-      *
-      *
-      * DESCRIPTION
-      *      This function determines whether threads created with
-      *      'attr' will run detached.
-      *
-      *      NOTES:
-      *              1)      You cannot join or cancel detached threads.
-      *
-      * RESULTS
-      *              0               successfully retrieved detach state,
-      *              EINVAL          'attr' is invalid
-      *
-      * ------------------------------------------------------
-      */
+main()
 {
-  if (is_attr(attr) != 0 || detachstate == NULL)
+  int i, j;
+  int result = -1;
+  pthread_t t;
+
+  for (i = 0; i < NUM_CV; i++)
     {
-      *detachstate = PTHREAD_CREATE_DETACHED;
-      return EINVAL;
+      assert(pthread_cond_init(&cv[i], NULL) == 0);
     }
 
-  *detachstate = (*attr)->detachstate;
+  j = NUM_CV;
+  (void) srand((unsigned)time(NULL));
+
+  /* Traverse the list asynchronously. */
+  assert(pthread_create(&t, NULL, pthread_timechange_handler_np, NULL) == 0);
+
+  do
+    {
+      i = (NUM_CV - 1) * rand() / RAND_MAX;
+      if (cv[i] != NULL)
+        {
+          j--;
+          assert(pthread_cond_destroy(&cv[i]) == 0);
+        }
+    }
+  while (j > 0);
+
+  assert(pthread_join(t, (void **) &result) == 0);
+  assert (result == 0);
+
   return 0;
 }
-
1 2 3 .. 8 > >> (Page 1 of 8)