]>
git.proxmox.com Git - rustc.git/blob - src/jemalloc/test/unit/ticker.c
1 #include "test/jemalloc_test.h"
3 TEST_BEGIN(test_ticker_tick
)
10 ticker_init(&ticker
, NTICKS
);
11 for (i
= 0; i
< NREPS
; i
++) {
12 for (j
= 0; j
< NTICKS
; j
++) {
13 assert_u_eq(ticker_read(&ticker
), NTICKS
- j
,
14 "Unexpected ticker value (i=%d, j=%d)", i
, j
);
15 assert_false(ticker_tick(&ticker
),
16 "Unexpected ticker fire (i=%d, j=%d)", i
, j
);
18 assert_u32_eq(ticker_read(&ticker
), 0,
19 "Expected ticker depletion");
20 assert_true(ticker_tick(&ticker
),
21 "Expected ticker fire (i=%d)", i
);
22 assert_u32_eq(ticker_read(&ticker
), NTICKS
,
23 "Expected ticker reset");
29 TEST_BEGIN(test_ticker_ticks
)
34 ticker_init(&ticker
, NTICKS
);
36 assert_u_eq(ticker_read(&ticker
), NTICKS
, "Unexpected ticker value");
37 assert_false(ticker_ticks(&ticker
, NTICKS
), "Unexpected ticker fire");
38 assert_u_eq(ticker_read(&ticker
), 0, "Unexpected ticker value");
39 assert_true(ticker_ticks(&ticker
, NTICKS
), "Expected ticker fire");
40 assert_u_eq(ticker_read(&ticker
), NTICKS
, "Unexpected ticker value");
42 assert_true(ticker_ticks(&ticker
, NTICKS
+ 1), "Expected ticker fire");
43 assert_u_eq(ticker_read(&ticker
), NTICKS
, "Unexpected ticker value");
48 TEST_BEGIN(test_ticker_copy
)
53 ticker_init(&ta
, NTICKS
);
54 ticker_copy(&tb
, &ta
);
55 assert_u_eq(ticker_read(&tb
), NTICKS
, "Unexpected ticker value");
56 assert_true(ticker_ticks(&tb
, NTICKS
+ 1), "Expected ticker fire");
57 assert_u_eq(ticker_read(&tb
), NTICKS
, "Unexpected ticker value");
60 ticker_copy(&tb
, &ta
);
61 assert_u_eq(ticker_read(&tb
), NTICKS
- 1, "Unexpected ticker value");
62 assert_true(ticker_ticks(&tb
, NTICKS
), "Expected ticker fire");
63 assert_u_eq(ticker_read(&tb
), NTICKS
, "Unexpected ticker value");