1.Add error checks to:

  Make sure this case not slip into one situation that
  the first pthread_once fails, and the second successes,
  then the case passes with bypassing its assertion.

  Give more detailed and exact execute result.

2.Replace "posixtest.h" with "testfrmw.h" as the log frame
  to keep consistent with other cases in the same directory.


Signed-off-by: DAN LI <[email protected]>
---
 .../conformance/interfaces/pthread_once/1-1.c      | 32 ++++++++++++++++------
 1 file changed, 23 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..c7ae170 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,17 @@
  *   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
+
 #include <pthread.h>
 #include <stdio.h>
-#include "posixtest.h"
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "../testfrmw/testfrmw.h"
+#include "../testfrmw/testfrmw.c"

 /* Keeps track of how many times the init function has been called. */
 int init_flag;
@@ -37,23 +45,29 @@ 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;
+       output("TEST PASSED\n");

+       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