Patrick Williams | 691668f | 2023-11-01 08:19:10 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 2 | /* Test pldm_msgbuf_extract() separately because we can't do _Generic() in C++ |
| 3 | * code, i.e. gtest */ |
| 4 | |
| 5 | #include <endian.h> |
| 6 | #include <float.h> |
| 7 | #include <stdio.h> |
| 8 | #include <stdlib.h> |
| 9 | |
| 10 | /* We're exercising the implementation so disable the asserts for now */ |
| 11 | #ifndef NDEBUG |
| 12 | #define NDEBUG 1 |
| 13 | #endif |
| 14 | #include "msgbuf.h" |
| 15 | |
| 16 | /* Given we disabled asserts above, set up our own expectation framework */ |
| 17 | #define expect(cond) __expect(__func__, __LINE__, (cond)) |
| 18 | #define __expect(fn, line, cond) \ |
| 19 | do \ |
| 20 | { \ |
| 21 | if (!(cond)) \ |
| 22 | { \ |
| 23 | fprintf(stderr, "%s:%d: failed expectation: %s\n", fn, line, \ |
| 24 | #cond); \ |
| 25 | exit(EXIT_FAILURE); \ |
| 26 | } \ |
| 27 | } while (0) |
| 28 | |
| 29 | static void test_msgbuf_extract_generic_uint8(void) |
| 30 | { |
| 31 | struct pldm_msgbuf _ctx; |
| 32 | struct pldm_msgbuf* ctx = &_ctx; |
| 33 | uint8_t buf[1] = {0xa5}; |
| 34 | uint8_t val; |
| 35 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 36 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 37 | expect(pldm_msgbuf_extract(ctx, val) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 38 | expect(val == 0xa5); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 39 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static void test_msgbuf_extract_generic_int8(void) |
| 43 | { |
| 44 | struct pldm_msgbuf _ctx; |
| 45 | struct pldm_msgbuf* ctx = &_ctx; |
| 46 | int8_t buf[1] = {-1}; |
| 47 | int8_t val; |
| 48 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 49 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 50 | expect(pldm_msgbuf_extract(ctx, val) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 51 | expect(val == -1); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 52 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static void test_msgbuf_extract_generic_uint16(void) |
| 56 | { |
| 57 | struct pldm_msgbuf _ctx; |
| 58 | struct pldm_msgbuf* ctx = &_ctx; |
| 59 | uint16_t buf[1] = {0x5aa5}; |
| 60 | uint16_t val; |
| 61 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 62 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 63 | expect(pldm_msgbuf_extract(ctx, val) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 64 | expect(val == 0x5aa5); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 65 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | static void test_msgbuf_extract_generic_int16(void) |
| 69 | { |
| 70 | struct pldm_msgbuf _ctx; |
| 71 | struct pldm_msgbuf* ctx = &_ctx; |
| 72 | int16_t buf[1] = {(int16_t)(htole16((uint16_t)INT16_MIN))}; |
| 73 | int16_t val; |
| 74 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 75 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 76 | expect(pldm_msgbuf_extract(ctx, val) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 77 | expect(val == INT16_MIN); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 78 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static void test_msgbuf_extract_generic_uint32(void) |
| 82 | { |
| 83 | struct pldm_msgbuf _ctx; |
| 84 | struct pldm_msgbuf* ctx = &_ctx; |
| 85 | uint32_t buf[1] = {0x5a00ffa5}; |
| 86 | uint32_t val; |
| 87 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 88 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 89 | expect(pldm_msgbuf_extract(ctx, val) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 90 | expect(val == 0x5a00ffa5); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 91 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | static void test_msgbuf_extract_generic_int32(void) |
| 95 | { |
| 96 | struct pldm_msgbuf _ctx; |
| 97 | struct pldm_msgbuf* ctx = &_ctx; |
| 98 | int32_t buf[1] = {(int32_t)(htole32((uint32_t)INT32_MIN))}; |
| 99 | int32_t val; |
| 100 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 101 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 102 | expect(pldm_msgbuf_extract(ctx, val) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 103 | expect(val == INT32_MIN); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 104 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static void test_msgbuf_extract_generic_real32(void) |
| 108 | { |
| 109 | struct pldm_msgbuf _ctx; |
| 110 | struct pldm_msgbuf* ctx = &_ctx; |
| 111 | uint32_t buf[1]; |
| 112 | uint32_t xform; |
| 113 | real32_t val; |
| 114 | |
| 115 | val = FLT_MAX; |
| 116 | memcpy(&xform, &val, sizeof(val)); |
| 117 | buf[0] = htole32(xform); |
| 118 | val = 0; |
| 119 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 120 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 121 | expect(pldm_msgbuf_extract(ctx, val) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 122 | expect(val == FLT_MAX); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 123 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 124 | } |
| 125 | |
Andrew Jeffery | 369b121 | 2023-04-20 15:44:48 +0930 | [diff] [blame] | 126 | static void test_msgbuf_extract_array_generic_uint8(void) |
| 127 | { |
| 128 | struct pldm_msgbuf _ctx; |
| 129 | struct pldm_msgbuf* ctx = &_ctx; |
| 130 | uint32_t buf[1] = {0}; |
| 131 | uint8_t arr[1]; |
| 132 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 133 | expect(pldm_msgbuf_init_errno(ctx, sizeof(buf), buf, sizeof(buf)) == 0); |
| 134 | expect(pldm_msgbuf_extract_array(ctx, 1, arr, 1) == 0); |
Andrew Jeffery | 369b121 | 2023-04-20 15:44:48 +0930 | [diff] [blame] | 135 | expect(arr[0] == 0); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 136 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Andrew Jeffery | 369b121 | 2023-04-20 15:44:48 +0930 | [diff] [blame] | 137 | } |
| 138 | |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 139 | static void test_msgbuf_insert_generic_int32(void) |
| 140 | { |
| 141 | struct pldm_msgbuf _ctx; |
| 142 | struct pldm_msgbuf* ctx = &_ctx; |
| 143 | int32_t src = -12345; |
| 144 | int32_t checkVal = 0; |
| 145 | uint8_t buf[sizeof(int32_t)] = {0}; |
| 146 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 147 | expect(pldm_msgbuf_init_errno(ctx, 0, buf, sizeof(buf)) == 0); |
| 148 | expect(pldm_msgbuf_insert(ctx, src) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 149 | |
| 150 | struct pldm_msgbuf _ctxExtract; |
| 151 | struct pldm_msgbuf* ctxExtract = &_ctxExtract; |
| 152 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 153 | expect(pldm_msgbuf_init_errno(ctxExtract, 0, buf, sizeof(buf)) == 0); |
| 154 | expect(pldm_msgbuf_extract(ctxExtract, checkVal) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 155 | |
| 156 | expect(src == checkVal); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 157 | expect(pldm_msgbuf_destroy(ctxExtract) == 0); |
| 158 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | static void test_msgbuf_insert_generic_uint32(void) |
| 162 | { |
| 163 | struct pldm_msgbuf _ctx; |
| 164 | struct pldm_msgbuf* ctx = &_ctx; |
| 165 | uint32_t src = 0xf1223344; |
| 166 | uint32_t checkVal = 0; |
| 167 | uint8_t buf[sizeof(uint32_t)] = {0}; |
| 168 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 169 | expect(pldm_msgbuf_init_errno(ctx, 0, buf, sizeof(buf)) == 0); |
| 170 | expect(pldm_msgbuf_insert(ctx, src) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 171 | |
| 172 | struct pldm_msgbuf _ctxExtract; |
| 173 | struct pldm_msgbuf* ctxExtract = &_ctxExtract; |
| 174 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 175 | expect(pldm_msgbuf_init_errno(ctxExtract, 0, buf, sizeof(buf)) == 0); |
| 176 | expect(pldm_msgbuf_extract(ctxExtract, checkVal) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 177 | |
| 178 | expect(src == checkVal); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 179 | expect(pldm_msgbuf_destroy(ctxExtract) == 0); |
| 180 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static void test_msgbuf_insert_generic_uint16(void) |
| 184 | { |
| 185 | struct pldm_msgbuf _ctx; |
| 186 | struct pldm_msgbuf* ctx = &_ctx; |
| 187 | uint16_t src = 0xf344; |
| 188 | uint16_t checkVal = 0; |
| 189 | uint8_t buf[sizeof(uint16_t)] = {0}; |
| 190 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 191 | expect(pldm_msgbuf_init_errno(ctx, 0, buf, sizeof(uint16_t)) == 0); |
| 192 | expect(pldm_msgbuf_insert(ctx, src) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 193 | |
| 194 | struct pldm_msgbuf _ctxExtract; |
| 195 | struct pldm_msgbuf* ctxExtract = &_ctxExtract; |
| 196 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 197 | expect(pldm_msgbuf_init_errno(ctxExtract, 0, buf, sizeof(buf)) == 0); |
| 198 | expect(pldm_msgbuf_extract(ctxExtract, checkVal) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 199 | |
| 200 | expect(src == checkVal); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 201 | expect(pldm_msgbuf_destroy(ctxExtract) == 0); |
| 202 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | static void test_msgbuf_insert_generic_int16(void) |
| 206 | { |
| 207 | struct pldm_msgbuf _ctx; |
| 208 | struct pldm_msgbuf* ctx = &_ctx; |
| 209 | int16_t src = -12; |
| 210 | int16_t checkVal = 0; |
| 211 | uint8_t buf[sizeof(int16_t)] = {0}; |
| 212 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 213 | expect(pldm_msgbuf_init_errno(ctx, 0, buf, sizeof(uint16_t)) == 0); |
| 214 | expect(pldm_msgbuf_insert(ctx, src) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 215 | |
| 216 | struct pldm_msgbuf _ctxExtract; |
| 217 | struct pldm_msgbuf* ctxExtract = &_ctxExtract; |
| 218 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 219 | expect(pldm_msgbuf_init_errno(ctxExtract, 0, buf, sizeof(buf)) == 0); |
| 220 | expect(pldm_msgbuf_extract(ctxExtract, checkVal) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 221 | |
| 222 | expect(src == checkVal); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 223 | expect(pldm_msgbuf_destroy(ctxExtract) == 0); |
| 224 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | static void test_msgbuf_insert_generic_uint8(void) |
| 228 | { |
| 229 | struct pldm_msgbuf _ctx; |
| 230 | struct pldm_msgbuf* ctx = &_ctx; |
| 231 | uint8_t src = 0xf4; |
| 232 | uint8_t checkVal = 0; |
| 233 | uint8_t buf[sizeof(uint8_t)] = {0}; |
| 234 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 235 | expect(pldm_msgbuf_init_errno(ctx, 0, buf, sizeof(buf)) == 0); |
| 236 | expect(pldm_msgbuf_insert(ctx, src) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 237 | |
| 238 | struct pldm_msgbuf _ctxExtract; |
| 239 | struct pldm_msgbuf* ctxExtract = &_ctxExtract; |
| 240 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 241 | expect(pldm_msgbuf_init_errno(ctxExtract, 0, buf, sizeof(buf)) == 0); |
| 242 | expect(pldm_msgbuf_extract(ctxExtract, checkVal) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 243 | |
| 244 | expect(src == checkVal); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 245 | expect(pldm_msgbuf_destroy(ctxExtract) == 0); |
| 246 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | static void test_msgbuf_insert_generic_int8(void) |
| 250 | { |
| 251 | struct pldm_msgbuf _ctx; |
| 252 | struct pldm_msgbuf* ctx = &_ctx; |
| 253 | int8_t src = -4; |
| 254 | int8_t checkVal = 0; |
| 255 | uint8_t buf[sizeof(int8_t)] = {0}; |
| 256 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 257 | expect(pldm_msgbuf_init_errno(ctx, 0, buf, sizeof(buf)) == 0); |
| 258 | expect(pldm_msgbuf_insert(ctx, src) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 259 | |
| 260 | struct pldm_msgbuf _ctxExtract; |
| 261 | struct pldm_msgbuf* ctxExtract = &_ctxExtract; |
| 262 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 263 | expect(pldm_msgbuf_init_errno(ctxExtract, 0, buf, sizeof(buf)) == 0); |
| 264 | expect(pldm_msgbuf_extract(ctxExtract, checkVal) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 265 | |
| 266 | expect(src == checkVal); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 267 | expect(pldm_msgbuf_destroy(ctxExtract) == 0); |
| 268 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | static void test_msgbuf_insert_array_generic_uint8(void) |
| 272 | { |
| 273 | struct pldm_msgbuf _ctx; |
| 274 | struct pldm_msgbuf* ctx = &_ctx; |
| 275 | uint8_t src[6] = {0x11, 0x22, 0x44, 0x55, 0x66, 0x77}; |
| 276 | uint8_t buf[6] = {0}; |
| 277 | uint8_t retBuff[6] = {0}; |
| 278 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 279 | expect(pldm_msgbuf_init_errno(ctx, 0, buf, sizeof(buf)) == 0); |
| 280 | expect(pldm_msgbuf_insert_array(ctx, sizeof(src), src, sizeof(src)) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 281 | |
| 282 | struct pldm_msgbuf _ctxExtract; |
| 283 | struct pldm_msgbuf* ctxExtract = &_ctxExtract; |
| 284 | |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 285 | expect(pldm_msgbuf_init_errno(ctxExtract, 0, buf, sizeof(buf)) == 0); |
Andrew Jeffery | 0a1be3c | 2024-08-11 08:34:10 +0000 | [diff] [blame] | 286 | expect(pldm_msgbuf_extract_array(ctxExtract, sizeof(retBuff), retBuff, |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 287 | sizeof(retBuff)) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 288 | |
| 289 | expect(memcmp(src, retBuff, sizeof(retBuff)) == 0); |
Andrew Jeffery | 830c1eb | 2024-10-04 10:48:10 +0930 | [diff] [blame] | 290 | expect(pldm_msgbuf_destroy(ctxExtract) == 0); |
| 291 | expect(pldm_msgbuf_destroy(ctx) == 0); |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 292 | } |
| 293 | |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 294 | typedef void (*testfn)(void); |
| 295 | |
Andrew Jeffery | 369b121 | 2023-04-20 15:44:48 +0930 | [diff] [blame] | 296 | static const testfn tests[] = {test_msgbuf_extract_generic_uint8, |
| 297 | test_msgbuf_extract_generic_int8, |
| 298 | test_msgbuf_extract_generic_uint16, |
| 299 | test_msgbuf_extract_generic_int16, |
| 300 | test_msgbuf_extract_generic_uint32, |
| 301 | test_msgbuf_extract_generic_int32, |
| 302 | test_msgbuf_extract_generic_real32, |
| 303 | test_msgbuf_extract_array_generic_uint8, |
Thu Nguyen | 062c876 | 2023-04-22 20:45:04 +0700 | [diff] [blame] | 304 | test_msgbuf_insert_generic_uint8, |
| 305 | test_msgbuf_insert_generic_int8, |
| 306 | test_msgbuf_insert_generic_uint16, |
| 307 | test_msgbuf_insert_generic_int16, |
| 308 | test_msgbuf_insert_generic_uint32, |
| 309 | test_msgbuf_insert_generic_int32, |
| 310 | test_msgbuf_insert_array_generic_uint8, |
Andrew Jeffery | 369b121 | 2023-04-20 15:44:48 +0930 | [diff] [blame] | 311 | NULL}; |
Andrew Jeffery | c63f63a | 2023-02-24 22:29:33 +1030 | [diff] [blame] | 312 | |
| 313 | int main(void) |
| 314 | { |
| 315 | testfn const* testp = &tests[0]; |
| 316 | |
| 317 | while (*testp) |
| 318 | { |
| 319 | (*testp)(); |
| 320 | testp++; |
| 321 | } |
| 322 | |
| 323 | return 0; |
| 324 | } |