Lines Matching +full:key +full:- +full:int
4 * SPDX-License-Identifier: Apache-2.0
16 static pthread_key_t key; variable
28 zassert_ok(pthread_setspecific(key, value), "pthread_setspecific failed"); in thread_top()
29 zassert_equal(pthread_getspecific(key), value, "set and retrieved values are different"); in thread_top()
42 for (int i = 0; i < N_KEY; i++) { in thread_func()
53 zassert_ok(pthread_key_create(&key, NULL), "insufficient memory to create key"); in make_key()
58 for (int i = 0; i < N_KEY; i++) { in make_keys()
68 * create a key via pthread_key_create() API. It then sets the
69 * thread-specific value to the key using pthread_setspecific() and
71 * are equal. It then deletes the key using pthread_key_delete().
72 * Both the sub-tests do the above, but one with multiple threads
73 * using the same key and the other with a single thread using
77 ZTEST(key, test_key_1toN_thread) in ZTEST() argument
82 zassert_ok(pthread_once(&key_once, make_key), "attempt to create key failed"); in ZTEST()
84 /* Different threads set different values to same key */ in ZTEST()
86 for (int i = 0; i < N_THR; i++) { in ZTEST()
91 for (int i = 0; i < N_THR; i++) { in ZTEST()
95 zassert_ok(pthread_key_delete(key), "attempt to delete key failed"); in ZTEST()
98 ZTEST(key, test_key_Nto1_thread) in ZTEST() argument
111 for (int i = 0; i < N_KEY; i++) { in ZTEST()
116 ZTEST(key, test_key_resource_leak) in ZTEST() argument
118 pthread_key_t key; in ZTEST() local
121 zassert_ok(pthread_key_create(&key, NULL), "failed to create key %zu", i); in ZTEST()
122 zassert_ok(pthread_key_delete(key), "failed to delete key %zu", i); in ZTEST()
126 ZTEST(key, test_correct_key_is_deleted) in ZTEST() argument
128 pthread_key_t key; in ZTEST() local
129 size_t j = CONFIG_POSIX_THREAD_KEYS_MAX - 1; in ZTEST()
133 zassert_ok(pthread_key_create(&keys[i], NULL), "failed to create key %zu", i); in ZTEST()
136 key = keys[j]; in ZTEST()
138 zassert_ok(pthread_key_create(&keys[j], NULL), "failed to create key %zu", j); in ZTEST()
140 zassert_equal(key, keys[j], "deleted key %x instead of key %x", keys[j], key); in ZTEST()
143 zassert_ok(pthread_key_delete(keys[i]), "failed to delete key %zu", i); in ZTEST()
149 int value = 42; in setspecific_thread()
150 int *alloc_count = count; in setspecific_thread()
153 pthread_key_t key; in setspecific_thread() local
155 zassert_ok(pthread_key_create(&key, NULL), "failed to create key"); in setspecific_thread()
156 if (pthread_setspecific(key, &value) == ENOMEM) { in setspecific_thread()
165 ZTEST(key, test_thread_specific_data_deallocation) in ZTEST() argument
168 static int alloc_count_t0; in ZTEST()
169 static int alloc_count_t1; in ZTEST()
195 ZTEST_SUITE(key, NULL, NULL, before, NULL, NULL);