| 3198 | }; |
| 3199 | |
| 3200 | static int |
| 3201 | run_test(const struct bpf_test *tst) |
| 3202 | { |
| 3203 | int32_t ret, rv; |
| 3204 | int64_t rc; |
| 3205 | struct rte_bpf *bpf; |
| 3206 | struct rte_bpf_jit jit; |
| 3207 | uint8_t tbuf[tst->arg_sz]; |
| 3208 | |
| 3209 | printf("%s(%s) start\n", __func__, tst->name); |
| 3210 | |
| 3211 | bpf = rte_bpf_load(&tst->prm); |
| 3212 | if (bpf == NULL) { |
| 3213 | printf("%s@%d: failed to load bpf code, error=%d(%s);\n", |
| 3214 | __func__, __LINE__, rte_errno, strerror(rte_errno)); |
| 3215 | return -1; |
| 3216 | } |
| 3217 | |
| 3218 | tst->prepare(tbuf); |
| 3219 | rc = rte_bpf_exec(bpf, tbuf); |
| 3220 | ret = tst->check_result(rc, tbuf); |
| 3221 | if (ret != 0) { |
| 3222 | printf("%s@%d: check_result(%s) failed, error: %d(%s);\n", |
| 3223 | __func__, __LINE__, tst->name, ret, strerror(ret)); |
| 3224 | } |
| 3225 | |
| 3226 | /* repeat the same test with jit, when possible */ |
| 3227 | rte_bpf_get_jit(bpf, &jit); |
| 3228 | if (jit.func != NULL) { |
| 3229 | |
| 3230 | tst->prepare(tbuf); |
| 3231 | rc = jit.func(tbuf); |
| 3232 | rv = tst->check_result(rc, tbuf); |
| 3233 | ret |= rv; |
| 3234 | if (rv != 0) { |
| 3235 | printf("%s@%d: check_result(%s) failed, " |
| 3236 | "error: %d(%s);\n", |
| 3237 | __func__, __LINE__, tst->name, |
| 3238 | rv, strerror(rv)); |
| 3239 | } |
| 3240 | } |
| 3241 | |
| 3242 | rte_bpf_destroy(bpf); |
| 3243 | return ret; |
| 3244 | |
| 3245 | } |
| 3246 | |
| 3247 | static int |
| 3248 | test_bpf(void) |
no test coverage detected