From: DAN LI <li.dan@cn.fujitsu.com>
To: LTP list <ltp-list@lists.sourceforge.net>
Subject: [LTP] [PATCH]pthread_once/1-1.c : cleanup & add error checks
Date: Mon, 04 Mar 2013 17:12:53 +0800 [thread overview]
Message-ID: <51346595.80103@cn.fujitsu.com> (raw)
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
next reply other threads:[~2013-03-04 9:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 9:12 DAN LI [this message]
2013-03-05 9:51 ` [LTP] [PATCH]pthread_once/1-1.c : cleanup & add error checks 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51346595.80103@cn.fujitsu.com \
--to=li.dan@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox