1/*
2 * Copyright (c) 2002, Intel Corporation. All rights reserved.
3 * Created by:  bing.wei.liu REMOVE-THIS AT intel DOT com
4 * This file is licensed under the GPL license.  For the full content
5 * of this license, see the COPYING file at the top level of this
6 * source tree.
7
8 * Test that pthread_getspecific()
9 *
10 * It shall return the thread-specific data value associated with the given 'key'.  If no
11 * thread-specific data value is associated with 'key, then the value NULL shall be returned.
12 * It does not return any errors.
13 *
14 * Steps:
15 * 1.  Create pthread_key_t object and do no specify a key accociated with this key
16 * 2.  Call pthread_getspecific() and check that the value returns NULL.
17 *
18 */
19
20#include <pthread.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <unistd.h>
24#include "posixtest.h"
25
26int main(void)
27{
28	pthread_key_t key;
29	void *rc;
30
31	if (pthread_key_create(&key, NULL) != 0) {
32		printf("Error: pthread_key_create() failed\n");
33		return PTS_UNRESOLVED;
34	}
35
36	rc = pthread_getspecific(key);
37	if (rc != NULL) {
38		printf
39		    ("Test FAILED: Did not return correct value, expected NULL, but got %ld\n",
40		     (long)rc);
41		return PTS_FAIL;
42	}
43
44	if (pthread_key_delete(key) != 0) {
45		printf("Error: pthread_key_delete() failed\n");
46		return PTS_UNRESOLVED;
47	}
48
49	printf("Test PASSED\n");
50	return PTS_PASS;
51}
52