1.Make log style keep consistent with other cases in the same directory.
2.Add error checks to strengthen the robustness of this case.

Signed-off-by: DAN LI <[email protected]>
---
 .../conformance/interfaces/pthread_once/1-1.c      | 70 +++++++++++++++++++---
 1 file changed, 61 insertions(+), 9 deletions(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
index 3a7c861..03b2875 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
@@ -21,9 +21,53 @@
  *   passed to it.  If it does, the test fails.
  */

+/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */
+#define _POSIX_C_SOURCE 200112L
+
+/******************************************************************************/
+/****************************** standard includes 
*****************************/
+/******************************************************************************/
 #include <pthread.h>
 #include <stdio.h>
-#include "posixtest.h"
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/******************************************************************************/
+/******************************   Test framework   
****************************/
+/******************************************************************************/
+#include "../testfrmw/testfrmw.h"
+#include "../testfrmw/testfrmw.c"
+/* This header is responsible for defining the following macros:
+ * UNRESOLVED(ret, descr);
+ *    where descr is a description of the error and ret is an int
+ *    (error code for example)
+ * FAILED(descr);
+ *    where descr is a short text saying why the test has failed.
+ * PASSED();
+ *    No parameter.
+ *
+ * Both three macros shall terminate the calling process.
+ * The testcase shall not terminate in any other maneer.
+ *
+ * The other file defines the functions
+ * void output_init()
+ * void output(char * string, ...)
+ *
+ * Those may be used to output information.
+ */
+
+/******************************************************************************/
+/******************************** Configuration 
*******************************/
+/******************************************************************************/
+#ifndef VERBOSE
+#define VERBOSE 1
+#endif
+
+/******************************************************************************/
+/*******************************    Test case   
*******************************/
+/******************************************************************************/
+

 /* Keeps track of how many times the init function has been called. */
 int init_flag;
@@ -37,23 +81,31 @@ void *an_init_func()

 int main()
 {
+       int ret = 0;
+
        pthread_once_t once_control = PTHREAD_ONCE_INIT;

        init_flag = 0;

+       output_init();
+
        /* Call pthread_once, passing it the once_control */
-       pthread_once(&once_control, (void *)an_init_func);
+       ret = pthread_once(&once_control, (void *)an_init_func);
+       if (ret != 0)
+               UNRESOLVED(ret, "pthread_once failed");

        /* Call pthread_once again. The init function should not be
         * called. */
-       pthread_once(&once_control, (void *)an_init_func);
+       ret = pthread_once(&once_control, (void *)an_init_func);
+       if (ret != 0)
+               UNRESOLVED(ret, "pthread_once failed");

-       if (init_flag != 1) {
-               printf("Test FAILED\n");
-               return PTS_FAIL;
-       }
+       if (init_flag != 1)
+               FAILED("an_init_func runs two times\n");

-       printf("Test PASSED\n");
-       return PTS_PASS;
+#if VERBOSE > 0
+       output("TEST PASSED\n");
+#endif

+       PASSED;
 }
-- 
1.7.12

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to