summaryrefslogtreecommitdiffhomepage
path: root/test/nxt_lib_unit_test.h
blob: bbb2d5f4a963b85787aaca9ca56b8f5bf2add448 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_LIB_UNIT_TEST_H_INCLUDED_
#define _NXT_LIB_UNIT_TEST_H_INCLUDED_


#define NXT_LIB_UNIT_TEST_STATIC


typedef nxt_bool_t (*nxt_msec_less_t)(nxt_msec_t first, nxt_msec_t second);


#define NXT_RBT_NODES  1500


#if (__i386__ || __i386 || __amd64__ || __amd64)
#if (NXT_GCC || NXT_CLANG)

#define NXT_UNIT_TEST_RTDTSC  1

nxt_inline uint64_t
nxt_rdtsc(void)
{
    uint32_t  eax, edx;

    __asm__ volatile ("rdtsc" : "=a" (eax), "=d" (edx));

    return ((uint64_t) edx << 32) | eax;
}

#endif
#endif


nxt_int_t nxt_term_parse_unit_test(nxt_thread_t *thr);
nxt_int_t nxt_msec_diff_unit_test(nxt_thread_t *thr, nxt_msec_less_t);
nxt_int_t nxt_exp_approximation(nxt_thread_t *thr);
double nxt_event_conn_exponential_approximation(double n);

nxt_int_t nxt_rbtree_unit_test(nxt_thread_t *thr, nxt_uint_t n);
nxt_int_t nxt_rbtree1_unit_test(nxt_thread_t *thr, nxt_uint_t n);

#if (NXT_UNIT_TEST_RTDTSC)

nxt_int_t nxt_rbtree_mb_start(nxt_thread_t *thr);
void nxt_rbtree_mb_insert(nxt_thread_t *thr);
void nxt_rbtree_mb_delete(nxt_thread_t *thr);

nxt_int_t nxt_rbtree1_mb_start(nxt_thread_t *thr);
void nxt_rbtree1_mb_insert(nxt_thread_t *thr);
void nxt_rbtree1_mb_delete(nxt_thread_t *thr);

#endif

nxt_int_t nxt_mem_cache_pool_unit_test(nxt_thread_t *thr, nxt_uint_t runs,
    nxt_uint_t nblocks, size_t max_size);
nxt_int_t nxt_mem_zone_unit_test(nxt_thread_t *thr, nxt_uint_t runs,
    nxt_uint_t nblocks, size_t max_size);
nxt_int_t nxt_lvlhsh_unit_test(nxt_thread_t *thr, nxt_uint_t n,
    nxt_bool_t use_pool);

nxt_int_t nxt_gmtime_unit_test(nxt_thread_t *thr);
nxt_int_t nxt_sprintf_unit_test(nxt_thread_t *thr);
nxt_int_t nxt_malloc_unit_test(nxt_thread_t *thr);
nxt_int_t nxt_utf8_unit_test(nxt_thread_t *thr);


#endif /* _NXT_LIB_UNIT_TEST_H_INCLUDED_ */