1 #ifndef _INTERCEPTOR_TEST_H_
2 #define _INTERCEPTOR_TEST_H_
3 
4 
5 struct ictcnt {
6         int cnt;
7         int min;
8         int max;
9 };
10 
11 struct ictest {
12         struct ictcnt conf_init;
13         struct ictcnt on_new;
14 
15         /* intercepted interceptor_test.config1 and .config2 properties */
16         char *config1;
17         char *config2;
18 
19         /* intercepted session.timeout.ms and socket.timeout.ms */
20         char *session_timeout_ms;
21         char *socket_timeout_ms;
22 };
23 
24 #define ictest_init(ICT) memset((ICT), 0, sizeof(ictest))
25 #define ictest_cnt_init(CNT,MIN,MAX) do {                               \
26                 (CNT)->cnt = 0;                                         \
27                 (CNT)->min = MIN;                                       \
28                 (CNT)->max = MAX;                                       \
29         } while (0)
30 
31 #define ictest_free(ICT) do {                                           \
32                 if ((ICT)->config1) free((ICT)->config1);               \
33                 if ((ICT)->config2) free((ICT)->config2);               \
34                 if ((ICT)->session_timeout_ms) free((ICT)->session_timeout_ms); \
35                 if ((ICT)->socket_timeout_ms) free((ICT)->socket_timeout_ms); \
36         } while (0)
37 
38 #define ICTEST_CNT_CHECK(F) do {                                        \
39                 if (ictest.F.cnt > ictest.F.max)                        \
40                         TEST_FAIL("interceptor %s count %d > max %d",   \
41                                   # F, ictest.F.cnt, ictest.F.max);    \
42         } while (0)
43 
44 /* The ictest struct is defined and set up by the calling test. */
45 extern struct ictest ictest;
46 
47 #endif /* _INTERCEPTOR_TEST_H_ */
48