Apache HTTPD
testthread.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "apr_thread_proc.h"
18#include "apr_errno.h"
19#include "apr_general.h"
20#include "apr_time.h"
21#include "testutil.h"
22
23#if APR_HAS_THREADS
24
26static apr_thread_once_t *control = NULL;
27static int x = 0;
28static int value = 0;
29
30static apr_thread_t *t1;
31static apr_thread_t *t2;
32static apr_thread_t *t3;
33static apr_thread_t *t4;
34
35/* just some made up number to check on later */
36static apr_status_t exit_ret_val = 123;
37
38static void init_func(void)
39{
40 value++;
41}
42
44{
45 int i;
46
47 apr_thread_once(control, init_func);
48
49 for (i = 0; i < 10000; i++) {
51 x++;
53 }
55 return NULL;
56}
57
58static void thread_init(abts_case *tc, void *data)
59{
60 apr_status_t rv;
61
62 rv = apr_thread_once_init(&control, p);
64
67}
68
69static void create_threads(abts_case *tc, void *data)
70{
71 apr_status_t rv;
72
81}
82
83static void join_threads(abts_case *tc, void *data)
84{
86
95}
96
97static void check_locks(abts_case *tc, void *data)
98{
99 ABTS_INT_EQUAL(tc, 40000, x);
100}
101
102static void check_thread_once(abts_case *tc, void *data)
103{
104 ABTS_INT_EQUAL(tc, 1, value);
105}
106
107#else
108
109static void threads_not_impl(abts_case *tc, void *data)
110{
111 ABTS_NOT_IMPL(tc, "Threads not implemented on this platform");
112}
113
114#endif
115
117{
118 suite = ADD_SUITE(suite)
119
120#if !APR_HAS_THREADS
122#else
128#endif
129
130 return suite;
131}
132
void abts_run_test(abts_suite *ts, test_func f, void *value)
Definition abts.c:175
#define ADD_SUITE(suite)
Definition abts.h:67
#define ABTS_NOT_IMPL(a, b)
Definition abts.h:129
#define ABTS_INT_EQUAL(a, b, c)
Definition abts.h:109
APR Error Codes.
APR Miscellaneous library routines.
APR Thread and Process Library.
APR Time Library.
apr_size_t size
const char * value
Definition apr_env.h:51
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
void * data
const char * s
Definition apr_strings.h:95
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
apr_status_t apr_thread_exit(apr_thread_t *thd, apr_status_t retval)
Definition thread.c:157
apr_status_t apr_thread_join(apr_status_t *retval, apr_thread_t *thd)
Definition thread.c:166
apr_status_t apr_thread_create(apr_thread_t **new, apr_threadattr_t *attr, apr_thread_start_t func, void *data, apr_pool_t *pool)
Definition thread.c:73
static apr_table_t * t1
Definition testtable.c:34
static void threads_not_impl(abts_case *tc, void *data)
Definition testthread.c:109
abts_suite * testthread(abts_suite *suite)
Definition testthread.c:116