All of lore.kernel.org
 help / color / mirror / Atom feed
From: DAN LI <li.dan@cn.fujitsu.com>
To: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCHv3]pthread_once/1-1.c : add error checks
Date: Wed, 06 Mar 2013 10:30:57 +0800	[thread overview]
Message-ID: <5136AA61.7030008@cn.fujitsu.com> (raw)
In-Reply-To: <51346595.80103@cn.fujitsu.com>


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.


Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
 .../conformance/interfaces/pthread_once/1-1.c           | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 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..3392e6b 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
@@ -26,7 +26,7 @@
 #include "posixtest.h"

 /* Keeps track of how many times the init function has been called. */
-int init_flag;
+static int init_flag;

 /* The init function that pthread_once calls */
 void *an_init_func()
@@ -37,16 +37,25 @@ void *an_init_func()

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

 	init_flag = 0;

 	/* 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) {
+		printf("pthread_once failed\n");
+		return PTS_UNRESOLVED;
+	}
 	/* 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) {
+		printf("pthread_once failed\n");
+		return PTS_UNRESOLVED;
+	}

 	if (init_flag != 1) {
 		printf("Test FAILED\n");
-- 
1.7.12

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  parent reply	other threads:[~2013-03-06  2:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` DAN LI [this message]
2013-03-06 13:04   ` [LTP] [PATCHv3]pthread_once/1-1.c : add " 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=5136AA61.7030008@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.