Remove building with NOCRYPTO option
[minix.git] / tests / lib / libpthread / dlopen / t_main_pthread_create.c
blob7ba89b35ee237238a96bcbccd7ff70dd1e2bd8e8
1 /* $NetBSD: t_main_pthread_create.c,v 1.1 2013/03/21 16:50:21 christos Exp $ */
2 /*-
3 * Copyright (c) 2013 The NetBSD Foundation, Inc.
4 * All rights reserved.
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Emmanuel Dreyfus
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 __RCSID("$NetBSD: t_main_pthread_create.c,v 1.1 2013/03/21 16:50:21 christos Exp $");
37 #include <atf-c.h>
38 #include <dlfcn.h>
39 #include <pthread.h>
40 #include <unistd.h>
42 #define DSO TESTDIR "/h_pthread_dlopen.so"
44 void *
45 routine(void *arg)
47 ATF_REQUIRE((intptr_t)arg == 0xcafe);
48 return NULL;
51 ATF_TC(main_pthread_create_main);
53 ATF_TC_HEAD(main_pthread_create_main, tc)
55 atf_tc_set_md_var(tc, "descr",
56 "Test if -lpthread main can call pthread_create() in main()");
59 ATF_TC_BODY(main_pthread_create_main, tc)
61 int ret;
62 pthread_t thread;
63 void *arg = (void *)0xcafe;
65 ret = pthread_create(&thread, NULL, routine, arg);
66 ATF_REQUIRE(ret == 0);
69 ATF_TC(main_pthread_create_dso);
71 ATF_TC_HEAD(main_pthread_create_dso, tc)
73 atf_tc_set_md_var(tc, "descr",
74 "Test if -lpthread main can call pthread_create() in DSO");
77 ATF_TC_BODY(main_pthread_create_dso, tc)
79 int ret;
80 pthread_t thread;
81 void *arg = (void *)0xcafe;
82 void *handle;
83 int (*testf_dso_pthread_create)(pthread_t *, pthread_attr_t *,
84 void *(*)(void *), void *);
86 handle = dlopen(DSO, RTLD_NOW | RTLD_LOCAL);
87 ATF_REQUIRE_MSG(handle != NULL, "dlopen fails: %s", dlerror());
89 testf_dso_pthread_create = dlsym(handle, "testf_dso_pthread_create");
90 ATF_REQUIRE_MSG(testf_dso_pthread_create != NULL,
91 "dlsym fails: %s", dlerror());
93 ret = testf_dso_pthread_create(&thread, NULL, routine, arg);
94 ATF_REQUIRE(ret == 0);
96 ATF_REQUIRE(dlclose(handle) == 0);
100 ATF_TP_ADD_TCS(tp)
102 ATF_TP_ADD_TC(tp, main_pthread_create_main);
103 ATF_TP_ADD_TC(tp, main_pthread_create_dso);
105 return atf_no_error();