1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #ifndef VCHIQ_TEST_H |
29 | #define VCHIQ_TEST_H |
30 | |
31 | #include "vchiq_test_if.h" |
32 | |
33 | #define VCOS_LOG_CATEGORY (&vchiq_test_log_category) |
34 | |
35 | #define VERBOSE_TRACE 1 |
36 | |
37 | #define FUNC_FOURCC VCHIQ_MAKE_FOURCC('f','u','n','c') |
38 | #define FUN2_FOURCC VCHIQ_MAKE_FOURCC('f','u','n','2') |
39 | |
40 | #define SERVICE1_DATA_SIZE 1024 |
41 | #define SERVICE2_DATA_SIZE 2048 |
42 | #define FUN2_MAX_DATA_SIZE 16384 |
43 | #define FUN2_MAX_ALIGN 4096 |
44 | #define BULK_ALIGN_SIZE 4096 |
45 | |
46 | #define VCHIQ_TEST_VER 3 |
47 | |
48 | enum { |
49 | MSG_ERROR, |
50 | MSG_ONEWAY, |
51 | MSG_ASYNC, |
52 | MSG_SYNC, |
53 | MSG_CONFIG, |
54 | MSG_ECHO |
55 | }; |
56 | |
57 | struct test_params |
58 | { |
59 | int magic; /* = MSG_CONFIG */ |
60 | int blocksize; |
61 | int iters; |
62 | int verify; |
63 | int echo; |
64 | int align_size; |
65 | int client_align; |
66 | int server_align; |
67 | int client_message_quota; |
68 | int server_message_quota; |
69 | }; |
70 | |
71 | #if VERBOSE_TRACE |
72 | |
73 | #define EXPECT(_e, _v) if (_e != _v) { vcos_log_error("%d: " #_e " != " #_v, __LINE__); VCOS_BKPT; goto error_exit; } else { vcos_log_trace("%d: " #_e " == " #_v, __LINE__); } |
74 | |
75 | #define START_CALLBACK(_r, _u) \ |
76 | if (++callback_index == callback_count) { \ |
77 | if (reason != _r) { \ |
78 | vcos_log_error("%d: expected callback reason " #_r ", got %d", __LINE__, reason); VCOS_BKPT; goto error_exit; \ |
79 | } \ |
80 | else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \ |
81 | vcos_log_error("%d: expected userdata %d, got %d", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \ |
82 | } \ |
83 | else \ |
84 | { \ |
85 | vcos_log_trace("%d: " #_r ", " #_u, __LINE__); \ |
86 | } |
87 | |
88 | #define START_BULK_CALLBACK(_r, _u, _bu) \ |
89 | if (++bulk_index == bulk_count) { \ |
90 | if (reason != _r) { \ |
91 | vcos_log_error("%d: expected callback reason " #_r ", got %d", __LINE__, reason); VCOS_BKPT; goto error_exit; \ |
92 | } \ |
93 | else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \ |
94 | vcos_log_error("%d: expected userdata %d, got %d", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \ |
95 | } \ |
96 | else if ((int)bulk_userdata != _bu) { \ |
97 | vcos_log_error("%d: expected bulk_userdata %d, got %d", __LINE__, _bu, (int)bulk_userdata); VCOS_BKPT; goto error_exit; \ |
98 | } \ |
99 | else \ |
100 | { \ |
101 | vcos_log_trace("%d: " #_r ", " #_u ", " #_bu, __LINE__); \ |
102 | } |
103 | |
104 | #else |
105 | |
106 | #define EXPECT(_e, _v) if (_e != _v) { vcos_log_trace("%d: " #_e " != " #_v, __LINE__); VCOS_BKPT; goto error_exit; } |
107 | |
108 | #define START_CALLBACK(_r, _u) \ |
109 | if (++callback_index == callback_count) { \ |
110 | if (reason != _r) { \ |
111 | vcos_log_error("%d: expected callback reason " #_r ", got %d", __LINE__, reason); VCOS_BKPT; goto error_exit; \ |
112 | } \ |
113 | else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \ |
114 | vcos_log_error("%d: expected userdata %d, got %d", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \ |
115 | } |
116 | |
117 | #define START_BULK_CALLBACK(_r, _u, _bu) \ |
118 | if (++bulk_index == bulk_count) { \ |
119 | if (reason != _r) { \ |
120 | vcos_log_error("%d: expected callback reason " #_r ", got %d", __LINE__, reason); VCOS_BKPT; goto error_exit; \ |
121 | } \ |
122 | else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \ |
123 | vcos_log_error("%d: expected userdata %d, got %d", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \ |
124 | } \ |
125 | else if ((int)bulk_userdata != _bu) { \ |
126 | vcos_log_error("%d: expected bulkuserdata %d, got %d", __LINE__, _bu, (int)bulk_userdata); VCOS_BKPT; goto error_exit; \ |
127 | } |
128 | |
129 | #endif |
130 | |
131 | #define END_CALLBACK(_s) \ |
132 | return _s; \ |
133 | } |
134 | |
135 | #endif |
136 | |