public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP]  [PATCH]pthread_once/1-1.c : cleanup & add error checks
@ 2013-03-04  9:12 DAN LI
  2013-03-05  9:51 ` chrubis
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: DAN LI @ 2013-03-04  9:12 UTC (permalink / raw)
  To: LTP list


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 <li.dan@cn.fujitsu.com>
---
 .../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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-03-11 17:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-04  9:12 [LTP] [PATCH]pthread_once/1-1.c : cleanup & add error checks DAN LI
2013-03-05  9:51 ` chrubis
2013-03-05 10:44   ` [LTP] [PATCHv2]pthread_once/1-1.c : cleanup & " DAN LI
2013-03-05 15:04     ` chrubis
2013-03-06  2:30 ` [LTP] [PATCHv3]pthread_once/1-1.c : add " DAN LI
2013-03-06 13:04   ` chrubis
     [not found] ` <51394F7C.8020301@cn.fujitsu.com>
2013-03-11 17:39   ` [LTP] [PATCHv4]pthread_once/1-1.c : cleanup & " chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox