Lines Matching +full:fixed +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
55 int i, mode, err, prog_fd, res; in verif_log_subtest() local
61 bpf_object__for_each_program(prog, skel->obj) { in verif_log_subtest()
74 insns = bpf_program__insns(skel->progs.good_prog); in verif_log_subtest()
75 insn_cnt = bpf_program__insn_cnt(skel->progs.good_prog); in verif_log_subtest()
85 memset(logs.reference + fixed_log_sz, 0, sizeof(logs.reference) - fixed_log_sz); in verif_log_subtest()
88 * we get -ENOSPC and beginning of the full verifier log. This only in verif_log_subtest()
93 * But if provided too short log buf, kernel will NULL-out log->ubuf in verif_log_subtest()
96 * Long story short, we do the following -ENOSPC test only for in verif_log_subtest()
101 opts.log_level = log_level | 8; /* fixed-length log */ in verif_log_subtest()
106 if (!ASSERT_EQ(prog_fd, -ENOSPC, "unexpected_log_fixed_prog_load_result")) { in verif_log_subtest()
122 /* rotating mode, then fixed mode */ in verif_log_subtest()
123 for (mode = 1; mode >= 0; mode--) { in verif_log_subtest()
126 logs.filler[sizeof(logs.filler) - 1] = '\0'; in verif_log_subtest()
128 logs.buf[sizeof(logs.buf) - 1] = '\0'; in verif_log_subtest()
132 opts.log_level = log_level | (mode ? 0 : 8 /* BPF_LOG_FIXED */); in verif_log_subtest()
135 "log_%s_%d", mode ? "roll" : "fixed", i); in verif_log_subtest()
140 "log_%s_prog_load_%d", mode ? "roll" : "fixed", i); in verif_log_subtest()
141 if (!ASSERT_EQ(prog_fd, -ENOSPC, op_name)) { in verif_log_subtest()
148 "log_%s_strlen_%d", mode ? "roll" : "fixed", i); in verif_log_subtest()
149 ASSERT_EQ(strlen(logs.buf), i - 1, op_name); in verif_log_subtest()
151 if (mode) in verif_log_subtest()
152 exp_log = logs.reference + fixed_log_sz - i; in verif_log_subtest()
157 "log_%s_contents_%d", mode ? "roll" : "fixed", i); in verif_log_subtest()
158 if (!ASSERT_STRNEQ(logs.buf, exp_log, i - 1, op_name)) { in verif_log_subtest()
160 strncmp(logs.buf, exp_log, i - 1), in verif_log_subtest()
167 "log_%s_unused_%d", mode ? "roll" : "fixed", i); in verif_log_subtest()
177 /* (FIXED) get actual log size */ in verif_log_subtest()
183 ASSERT_NEQ(res, -ENOSPC, "prog_load_res_fixed"); in verif_log_subtest()
188 /* (FIXED, NULL) get actual log size */ in verif_log_subtest()
194 ASSERT_NEQ(res, -ENOSPC, "prog_load_res_fixed_null"); in verif_log_subtest()
203 ASSERT_NEQ(res, -ENOSPC, "prog_load_res_rolling"); in verif_log_subtest()
214 ASSERT_NEQ(res, -ENOSPC, "prog_load_res_rolling_null"); in verif_log_subtest()
217 /* (FIXED) expect -ENOSPC for one byte short log */ in verif_log_subtest()
220 opts.log_size = log_true_sz_fixed - 1; in verif_log_subtest()
223 ASSERT_EQ(res, -ENOSPC, "prog_load_res_too_short_fixed"); in verif_log_subtest()
225 /* (FIXED) expect *not* -ENOSPC with exact log_true_size buffer */ in verif_log_subtest()
231 ASSERT_NEQ(res, -ENOSPC, "prog_load_res_just_right_fixed"); in verif_log_subtest()
233 /* (ROLLING) expect -ENOSPC for one byte short log */ in verif_log_subtest()
236 opts.log_size = log_true_sz_rolling - 1; in verif_log_subtest()
238 ASSERT_EQ(res, -ENOSPC, "prog_load_res_too_short_rolling"); in verif_log_subtest()
240 /* (ROLLING) expect *not* -ENOSPC with exact log_true_size buffer */ in verif_log_subtest()
246 ASSERT_NEQ(res, -ENOSPC, "prog_load_res_just_right_rolling"); in verif_log_subtest()
288 * force-cast btf_type pointer and manually override size to invalid in verif_btf_log_subtest()
294 t->size = 3; in verif_btf_log_subtest()
311 memset(logs.reference + fixed_log_sz, 0, sizeof(logs.reference) - fixed_log_sz); in verif_btf_log_subtest()
315 opts.log_level = 1 | 8; /* fixed-length log */ in verif_btf_log_subtest()
318 ASSERT_EQ(res, -ENOSPC, "half_log_fd"); in verif_btf_log_subtest()
330 logs.filler[sizeof(logs.filler) - 1] = '\0'; in verif_btf_log_subtest()
332 logs.buf[sizeof(logs.buf) - 1] = '\0'; in verif_btf_log_subtest()
339 if (!ASSERT_EQ(res, -ENOSPC, op_name)) in verif_btf_log_subtest()
342 exp_log = logs.reference + fixed_log_sz - i; in verif_btf_log_subtest()
361 /* (FIXED) get actual log size */ in verif_btf_log_subtest()
367 ASSERT_NEQ(res, -ENOSPC, "btf_load_res_fixed"); in verif_btf_log_subtest()
372 /* (FIXED, NULL) get actual log size */ in verif_btf_log_subtest()
378 ASSERT_NEQ(res, -ENOSPC, "btf_load_res_fixed_null"); in verif_btf_log_subtest()
387 ASSERT_NEQ(res, -ENOSPC, "btf_load_res_rolling"); in verif_btf_log_subtest()
398 ASSERT_NEQ(res, -ENOSPC, "btf_load_res_rolling_null"); in verif_btf_log_subtest()
401 /* (FIXED) expect -ENOSPC for one byte short log */ in verif_btf_log_subtest()
404 opts.log_size = log_true_sz_fixed - 1; in verif_btf_log_subtest()
407 ASSERT_EQ(res, -ENOSPC, "btf_load_res_too_short_fixed"); in verif_btf_log_subtest()
409 /* (FIXED) expect *not* -ENOSPC with exact log_true_size buffer */ in verif_btf_log_subtest()
415 ASSERT_NEQ(res, -ENOSPC, "btf_load_res_just_right_fixed"); in verif_btf_log_subtest()
417 /* (ROLLING) expect -ENOSPC for one byte short log */ in verif_btf_log_subtest()
420 opts.log_size = log_true_sz_rolling - 1; in verif_btf_log_subtest()
422 ASSERT_EQ(res, -ENOSPC, "btf_load_res_too_short_rolling"); in verif_btf_log_subtest()
424 /* (ROLLING) expect *not* -ENOSPC with exact log_true_size buffer */ in verif_btf_log_subtest()
430 ASSERT_NEQ(res, -ENOSPC, "btf_load_res_just_right_rolling"); in verif_btf_log_subtest()
438 if (test__start_subtest("good_prog-level1")) in test_verifier_log()
440 if (test__start_subtest("good_prog-level2")) in test_verifier_log()
442 if (test__start_subtest("bad_prog-level1")) in test_verifier_log()
444 if (test__start_subtest("bad_prog-level2")) in test_verifier_log()