From: Cyril H. <su...@li...> - 2013-05-02 17:22:04
|
The branch, master, has been updated via 64ae94faa975b60265effe994da8465a195d4824 (commit) via 64f445e44bb4f2e44f11c37c157ca23bedd68459 (commit) from f2ec5c633c1b50e5affa5488148a196358fb1de6 (commit) - Log ----------------------------------------------------------------- commit 64ae94faa975b60265effe994da8465a195d4824 Author: Cyril Hrubis <ch...@su...> Date: Thu May 2 18:16:57 2013 +0200 openposix/...pthread_mutexattr_gettype/speculative/3-1 The testcase tests for optional behavior. On linux the function just returns member of the passed attr structure and as a such cannot fail. This commit changes the test to return UNTESTED when the call succeeded. Signed-off-by: Cyril Hrubis <ch...@su...> commit 64f445e44bb4f2e44f11c37c157ca23bedd68459 Author: Cyril Hrubis <ch...@su...> Date: Thu May 2 15:53:16 2013 +0200 openposix/.../pthread_key_create/speculative/5-1.c * The pthread_key_create was called twice in the loop no wonder it failed with EAGAIN before the loop has reached the limit. * Cleaned up the code a litte. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: .../pthread_key_create/speculative/5-1.c | 61 ++++++++++---------- .../pthread_mutexattr_gettype/speculative/3-1.c | 16 +++-- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_key_create/speculative/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_key_create/speculative/5-1.c index b2183d5..435602c 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_key_create/speculative/5-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_key_create/speculative/5-1.c @@ -1,19 +1,22 @@ /* * Copyright (c) 2002, Intel Corporation. All rights reserved. * Created by: bing.wei.liu REMOVE-THIS AT intel DOT com + * Copyright (c) 2013 Cyril Hrubis <ch...@su...> + * * This file is licensed under the GPL license. For the full content * of this license, see the COPYING file at the top level of this * source tree. - + * * Test that pthread_key_create() * - * If successful, the pthread_key_create() function shall store the newly created key value - * at *key and shall return zero. Otherwise, an error number shall be returned to indicate - * an error: + * If successful, the pthread_key_create() function shall store the newly + * created key value at *key and shall return zero. Otherwise, an error number + * shall be returned to indicate an error: * - * [EAGAIN] - the system lacked the necessary resources to create another thread_specific - * data key, or the system imposed limit on the total number of keys per process - * [PTHREAD_KEYS_MAX] has been exceeded. + * [EAGAIN] - the system lacked the necessary resources to create another + * thread_specific data key, or the system imposed limit on the + * total number of keys per process [PTHREAD_KEYS_MAX] has been + * exceeded. * * [ENOMEM] - insufficient memory exists to create the key. * @@ -22,7 +25,8 @@ * Steps: * 1. Define an array of keys * 2. Use pthread_key_create() and create those keys - * 3. Verify that you can set and get specific values for those keys without errors. + * 3. Verify that you can set and get specific values for those keys without + * errors. * */ @@ -34,7 +38,7 @@ #include <unistd.h> #include "posixtest.h" -pthread_key_t keys[PTHREAD_KEYS_MAX]; +static pthread_key_t keys[PTHREAD_KEYS_MAX]; int main(void) { @@ -42,29 +46,26 @@ int main(void) for (i = 0; i <= PTHREAD_KEYS_MAX; i++) { rc = pthread_key_create(&keys[i], NULL); - pthread_key_t key; - rc = pthread_key_create(&key, NULL); - if (i == PTHREAD_KEYS_MAX) { - if (rc != EAGAIN) { - printf - ("Test FAILED: Expected EAGAIN when exceeded the limit of keys in a single process, but got: %d\n", - rc); - return PTS_FAIL; - } - } - else if (rc != 0) { - if (rc != EAGAIN) { - printf("Error: pthread_key_create() failed\n"); - return PTS_UNRESOLVED; - } else { - printf - ("Test FAILED: EAGAIN was returned before the key limit was exceeded\n"); - return PTS_FAIL; - } + if (rc != 0) + break; + } + + if (i == PTHREAD_KEYS_MAX) { + if (rc == EAGAIN) { + printf("Test PASSED\n"); + return PTS_PASS; + } else { + printf("Expected EAGAIN on exceeding the limit, got: %d\n", rc); + return PTS_FAIL; } } - printf("Test PASSED\n"); - return PTS_PASS; + if (rc == EAGAIN) { + printf("EAGAIN returned before the key limit was exceeded\n"); + return PTS_FAIL; + } + + printf("Error: pthread_key_create() failed with %d\n", rc); + return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_gettype/speculative/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_gettype/speculative/3-1.c index 684c64d..f4ffad7 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_gettype/speculative/3-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_gettype/speculative/3-1.c @@ -37,13 +37,15 @@ int main(void) /* Pass an invalid 'attr'. */ ret = pthread_mutexattr_gettype(&mta, &type); - if (ret != EINVAL) { - printf - ("Test FAILED: Incorrect return code. Expected EINVAL, but got: %d\n", - ret); + switch (ret) { + case 0: + printf("UNTESTED: The call didn't fail.\n"); + return PTS_UNTESTED; + case EINVAL: + printf("Test PASSED\n"); + return PTS_PASS; + default: + printf("Test FAILED: Expected EINVAL, but got: %d\n", ret); return PTS_FAIL; } - - printf("Test PASSED\n"); - return PTS_PASS; } hooks/post-receive -- ltp |