Lines Matching +full:1 +full:- +full:d
1 // SPDX-License-Identifier: GPL-2.0
29 struct btf_dump *d; in btf_dump_all_types() local
32 d = btf_dump__new(btf, btf_dump_printf, ctx, NULL); in btf_dump_all_types()
33 err = libbpf_get_error(d); in btf_dump_all_types()
37 for (id = 1; id < type_cnt; id++) { in btf_dump_all_types()
38 err = btf_dump__dump_type(d, id); in btf_dump_all_types()
44 btf_dump__free(d); in btf_dump_all_types()
52 int err = 0, fd = -1; in test_btf_dump_case()
55 snprintf(test_file, sizeof(test_file), "%s.bpf.o", t->file); in test_btf_dump_case()
59 err = -PTR_ERR(btf); in test_btf_dump_case()
64 /* tests with t->known_ptr_sz have no "long" or "unsigned long" type, in test_btf_dump_case()
67 * target is always 64-bit in test_btf_dump_case()
69 if (!t->known_ptr_sz) { in test_btf_dump_case()
72 CHECK(btf__pointer_size(btf) != 8, "ptr_sz", "exp %d, got %zu\n", in test_btf_dump_case()
76 snprintf(out_file, sizeof(out_file), "/tmp/%s.output.XXXXXX", t->file); in test_btf_dump_case()
83 if (CHECK(f == NULL, "open_tmp", "failed to open file: %s(%d)\n", in test_btf_dump_case()
92 if (CHECK(err, "btf_dump", "failure during C dumping: %d\n", err)) { in test_btf_dump_case()
96 snprintf(test_file, sizeof(test_file), "progs/%s.c", t->file); in test_btf_dump_case()
97 if (access(test_file, R_OK) == -1) in test_btf_dump_case()
102 snprintf(test_file, sizeof(test_file), "%s.c", t->file); in test_btf_dump_case()
105 * START-EXPECTED-OUTPUT and END-EXPECTED-OUTPUT lines in test case. in test_btf_dump_case()
111 "awk '/START-EXPECTED-OUTPUT/{out=1;next} " in test_btf_dump_case()
112 "/END-EXPECTED-OUTPUT/{out=0} " in test_btf_dump_case()
114 "out {sub(/^[ \\t]*\\*/, \"\"); print}' '%s' | diff -u - '%s'", in test_btf_dump_case()
118 "differing test output, output=%s, err=%d, diff cmd:\n%s\n", in test_btf_dump_case()
136 struct btf_dump *d = NULL; in test_btf_dump_incremental() local
145 d = btf_dump__new(btf, btf_dump_printf, dump_buf_file, NULL); in test_btf_dump_incremental()
146 if (!ASSERT_OK(libbpf_get_error(d), "btf_dump__new")) in test_btf_dump_incremental()
153 * enum x { X = 1 }; in test_btf_dump_incremental()
155 * enum { Y = 1 }; in test_btf_dump_incremental()
163 ASSERT_EQ(id, 1, "enum_declaration_id"); in test_btf_dump_incremental()
166 err = btf__add_enum_value(btf, "X", 1); in test_btf_dump_incremental()
171 err = btf__add_enum_value(btf, "Y", 1); in test_btf_dump_incremental()
185 for (i = 1; i < btf__type_cnt(btf); i++) { in test_btf_dump_incremental()
186 err = btf_dump__dump_type(d, i); in test_btf_dump_incremental()
197 " X = 1,\n" in test_btf_dump_incremental()
201 " Y = 1,\n" in test_btf_dump_incremental()
214 * enum { VAL___2 = 1 } x; in test_btf_dump_incremental()
235 for (i = 1; i < btf__type_cnt(btf); i++) { in test_btf_dump_incremental()
236 err = btf_dump__dump_type(d, i); in test_btf_dump_incremental()
246 " Y___2 = 1,\n" in test_btf_dump_incremental()
254 btf_dump__free(d); in test_btf_dump_incremental()
266 strncat(s, new, STRSIZE - strlen(s) - 1); in btf_dump_snprintf()
269 static int btf_dump_data(struct btf *btf, struct btf_dump *d, in btf_dump_data() argument
287 name += strlen(prefix) + 1; in btf_dump_data()
291 return -ENOENT; in btf_dump_data()
294 ret = btf_dump__dump_type_data(d, type_id, ptr, ptr_sz, &opts); in btf_dump_data()
297 return -EINVAL; in btf_dump_data()
299 if (!ASSERT_EQ(ret, -E2BIG, "failed to return -E2BIG")) in btf_dump_data()
300 return -EINVAL; in btf_dump_data()
303 return -EFAULT; in btf_dump_data()
350 static void test_btf_dump_int_data(struct btf *btf, struct btf_dump *d, in test_btf_dump_int_data() argument
357 * a 128-bit value to anything larger than a 64-bit value. in test_btf_dump_int_data()
359 i = (i << 64) | (i - 1); in test_btf_dump_int_data()
362 TEST_BTF_DUMP_DATA_C(btf, d, NULL, str, int, BTF_F_COMPACT, 1234); in test_btf_dump_int_data()
363 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_int_data()
365 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, 0, "(int)1234", 1234); in test_btf_dump_int_data()
368 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, BTF_F_COMPACT, "(int)0", 0); in test_btf_dump_int_data()
369 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_int_data()
371 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, BTF_F_COMPACT | BTF_F_ZERO, in test_btf_dump_int_data()
373 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, in test_btf_dump_int_data()
376 TEST_BTF_DUMP_DATA_C(btf, d, NULL, str, int, BTF_F_COMPACT, -4567); in test_btf_dump_int_data()
377 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_int_data()
378 "-4567", -4567); in test_btf_dump_int_data()
379 TEST_BTF_DUMP_DATA(btf, d, NULL, str, int, 0, "(int)-4567", -4567); in test_btf_dump_int_data()
381 TEST_BTF_DUMP_DATA_OVER(btf, d, NULL, str, int, sizeof(int)-1, "", 1); in test_btf_dump_int_data()
389 TEST_BTF_DUMP_DATA(btf, d, NULL, str, unsigned __int128, BTF_F_COMPACT, in test_btf_dump_int_data()
392 ASSERT_OK(btf_dump_data(btf, d, "unsigned __int128", NULL, 0, &i, 16, str, in test_btf_dump_int_data()
396 TEST_BTF_DUMP_DATA(btf, d, NULL, str, __int128 unsigned, BTF_F_COMPACT, in test_btf_dump_int_data()
399 ASSERT_OK(btf_dump_data(btf, d, "__int128 unsigned", NULL, 0, &i, 16, str, in test_btf_dump_int_data()
408 static void test_btf_dump_float_data(struct btf *btf, struct btf_dump *d, in test_btf_dump_float_data() argument
412 float t2 = -1.234567; in test_btf_dump_float_data()
415 double t5 = -5.678912; in test_btf_dump_float_data()
418 long double t8 = -9.876543; in test_btf_dump_float_data()
426 ASSERT_OK(btf_dump_data(btf, d, "test_float", NULL, 0, &t1, 4, str, in test_btf_dump_float_data()
428 ASSERT_OK(btf_dump_data(btf, d, "test_float", NULL, 0, &t2, 4, str, in test_btf_dump_float_data()
429 "(test_float)-1.234567"), "dump float"); in test_btf_dump_float_data()
430 ASSERT_OK(btf_dump_data(btf, d, "test_float", NULL, 0, &t3, 4, str, in test_btf_dump_float_data()
434 ASSERT_OK(btf_dump_data(btf, d, "test_double", NULL, 0, &t4, 8, str, in test_btf_dump_float_data()
436 ASSERT_OK(btf_dump_data(btf, d, "test_double", NULL, 0, &t5, 8, str, in test_btf_dump_float_data()
437 "(test_double)-5.678912"), "dump double"); in test_btf_dump_float_data()
438 ASSERT_OK(btf_dump_data(btf, d, "test_double", NULL, 0, &t6, 8, str, in test_btf_dump_float_data()
442 ASSERT_OK(btf_dump_data(btf, d, "test_long_double", NULL, 0, &t7, 16, in test_btf_dump_float_data()
445 ASSERT_OK(btf_dump_data(btf, d, "test_long_double", NULL, 0, &t8, 16, in test_btf_dump_float_data()
446 str, "(test_long_double)-9.876543"), in test_btf_dump_float_data()
448 ASSERT_OK(btf_dump_data(btf, d, "test_long_double", NULL, 0, &t9, 16, in test_btf_dump_float_data()
453 static void test_btf_dump_char_data(struct btf *btf, struct btf_dump *d, in test_btf_dump_char_data() argument
457 TEST_BTF_DUMP_DATA_C(btf, d, NULL, str, char, BTF_F_COMPACT, 100); in test_btf_dump_char_data()
458 TEST_BTF_DUMP_DATA(btf, d, NULL, str, char, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_char_data()
460 TEST_BTF_DUMP_DATA(btf, d, NULL, str, char, 0, "(char)100", 100); in test_btf_dump_char_data()
462 TEST_BTF_DUMP_DATA(btf, d, NULL, str, char, BTF_F_COMPACT, in test_btf_dump_char_data()
464 TEST_BTF_DUMP_DATA(btf, d, NULL, str, char, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_char_data()
466 TEST_BTF_DUMP_DATA(btf, d, NULL, str, char, BTF_F_COMPACT | BTF_F_ZERO, in test_btf_dump_char_data()
468 TEST_BTF_DUMP_DATA(btf, d, NULL, str, char, BTF_F_COMPACT | BTF_F_NONAME | BTF_F_ZERO, in test_btf_dump_char_data()
470 TEST_BTF_DUMP_DATA(btf, d, NULL, str, char, 0, "(char)0", 0); in test_btf_dump_char_data()
472 TEST_BTF_DUMP_DATA_OVER(btf, d, NULL, str, char, sizeof(char)-1, "", 100); in test_btf_dump_char_data()
475 static void test_btf_dump_typedef_data(struct btf *btf, struct btf_dump *d, in test_btf_dump_typedef_data() argument
479 TEST_BTF_DUMP_DATA_C(btf, d, NULL, str, uint64_t, BTF_F_COMPACT, 100); in test_btf_dump_typedef_data()
480 TEST_BTF_DUMP_DATA(btf, d, NULL, str, u64, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_typedef_data()
481 "1", 1); in test_btf_dump_typedef_data()
482 TEST_BTF_DUMP_DATA(btf, d, NULL, str, u64, 0, "(u64)1", 1); in test_btf_dump_typedef_data()
484 TEST_BTF_DUMP_DATA(btf, d, NULL, str, u64, BTF_F_COMPACT, "(u64)0", 0); in test_btf_dump_typedef_data()
485 TEST_BTF_DUMP_DATA(btf, d, NULL, str, u64, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_typedef_data()
487 TEST_BTF_DUMP_DATA(btf, d, NULL, str, u64, BTF_F_COMPACT | BTF_F_ZERO, in test_btf_dump_typedef_data()
489 TEST_BTF_DUMP_DATA(btf, d, NULL, str, u64, in test_btf_dump_typedef_data()
492 TEST_BTF_DUMP_DATA(btf, d, NULL, str, u64, 0, "(u64)0", 0); in test_btf_dump_typedef_data()
495 TEST_BTF_DUMP_DATA_C(btf, d, NULL, str, atomic_t, BTF_F_COMPACT, in test_btf_dump_typedef_data()
496 {.counter = (int)1,}); in test_btf_dump_typedef_data()
497 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_typedef_data()
498 "{1,}", { .counter = 1 }); in test_btf_dump_typedef_data()
499 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, 0, in test_btf_dump_typedef_data()
501 " .counter = (int)1,\n" in test_btf_dump_typedef_data()
503 {.counter = 1,}); in test_btf_dump_typedef_data()
505 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, BTF_F_COMPACT, "(atomic_t){}", in test_btf_dump_typedef_data()
507 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, BTF_F_COMPACT | BTF_F_NONAME, in test_btf_dump_typedef_data()
509 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, 0, in test_btf_dump_typedef_data()
513 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, BTF_F_COMPACT | BTF_F_ZERO, in test_btf_dump_typedef_data()
516 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, in test_btf_dump_typedef_data()
519 TEST_BTF_DUMP_DATA(btf, d, NULL, str, atomic_t, BTF_F_ZERO, in test_btf_dump_typedef_data()
526 TEST_BTF_DUMP_DATA_OVER(btf, d, NULL, str, atomic_t, sizeof(atomic_t)-1, in test_btf_dump_typedef_data()
527 "(atomic_t){\n", { .counter = 1}); in test_btf_dump_typedef_data()
530 static void test_btf_dump_enum_data(struct btf *btf, struct btf_dump *d, in test_btf_dump_enum_data() argument
534 TEST_BTF_DUMP_DATA_C(btf, d, "enum", str, enum bpf_cmd, BTF_F_COMPACT, in test_btf_dump_enum_data()
536 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, BTF_F_COMPACT, in test_btf_dump_enum_data()
538 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, in test_btf_dump_enum_data()
542 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, 0, in test_btf_dump_enum_data()
545 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, in test_btf_dump_enum_data()
548 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, in test_btf_dump_enum_data()
552 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, in test_btf_dump_enum_data()
555 TEST_BTF_DUMP_DATA_C(btf, d, "enum", str, enum bpf_cmd, BTF_F_COMPACT, 2000); in test_btf_dump_enum_data()
556 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, in test_btf_dump_enum_data()
559 TEST_BTF_DUMP_DATA(btf, d, "enum", str, enum bpf_cmd, 0, in test_btf_dump_enum_data()
562 TEST_BTF_DUMP_DATA_OVER(btf, d, "enum", str, enum bpf_cmd, in test_btf_dump_enum_data()
563 sizeof(enum bpf_cmd) - 1, "", BPF_MAP_CREATE); in test_btf_dump_enum_data()
566 static void test_btf_dump_struct_data(struct btf *btf, struct btf_dump *d, in test_btf_dump_struct_data() argument
582 TEST_BTF_DUMP_DATA_C(btf, d, "struct", str, struct btf_enum, BTF_F_COMPACT, in test_btf_dump_struct_data()
583 {.name_off = (__u32)3,.val = (__s32)-1,}); in test_btf_dump_struct_data()
584 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, in test_btf_dump_struct_data()
586 "{3,-1,}", in test_btf_dump_struct_data()
587 { .name_off = 3, .val = -1,}); in test_btf_dump_struct_data()
588 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, 0, in test_btf_dump_struct_data()
591 " .val = (__s32)-1,\n" in test_btf_dump_struct_data()
593 { .name_off = 3, .val = -1,}); in test_btf_dump_struct_data()
594 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, in test_btf_dump_struct_data()
596 "{-1,}", in test_btf_dump_struct_data()
597 { .name_off = 0, .val = -1,}); in test_btf_dump_struct_data()
598 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, in test_btf_dump_struct_data()
600 "{0,-1,}", in test_btf_dump_struct_data()
601 { .name_off = 0, .val = -1,}); in test_btf_dump_struct_data()
603 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, BTF_F_COMPACT, in test_btf_dump_struct_data()
606 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, in test_btf_dump_struct_data()
610 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, 0, in test_btf_dump_struct_data()
614 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, in test_btf_dump_struct_data()
618 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct btf_enum, in test_btf_dump_struct_data()
627 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct list_head, BTF_F_COMPACT, in test_btf_dump_struct_data()
629 { .next = (struct list_head *)1 }); in test_btf_dump_struct_data()
630 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct list_head, 0, in test_btf_dump_struct_data()
634 { .next = (struct list_head *)1 }); in test_btf_dump_struct_data()
636 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct list_head, BTF_F_COMPACT, in test_btf_dump_struct_data()
639 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct list_head, 0, in test_btf_dump_struct_data()
650 ret = btf_dump__dump_type_data(d, type_id, fops, type_sz, &opts); in test_btf_dump_struct_data()
662 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_prog_info, BTF_F_COMPACT, in test_btf_dump_struct_data()
665 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_prog_info, in test_btf_dump_struct_data()
669 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_prog_info, 0, in test_btf_dump_struct_data()
679 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_prog_info, BTF_F_COMPACT, in test_btf_dump_struct_data()
682 /* handle non-printable characters */ in test_btf_dump_struct_data()
683 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_prog_info, BTF_F_COMPACT, in test_btf_dump_struct_data()
684 "(struct bpf_prog_info){.name = (char[16])[1,2,3,],}", in test_btf_dump_struct_data()
685 { .name = {1, 2, 3, 0}}); in test_btf_dump_struct_data()
687 /* struct with non-char array */ in test_btf_dump_struct_data()
688 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct __sk_buff, BTF_F_COMPACT, in test_btf_dump_struct_data()
689 "(struct __sk_buff){.cb = (__u32[5])[1,2,3,4,5,],}", in test_btf_dump_struct_data()
690 { .cb = {1, 2, 3, 4, 5,},}); in test_btf_dump_struct_data()
691 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct __sk_buff, in test_btf_dump_struct_data()
693 "{[1,2,3,4,5,],}", in test_btf_dump_struct_data()
694 { .cb = { 1, 2, 3, 4, 5},}); in test_btf_dump_struct_data()
695 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct __sk_buff, 0, in test_btf_dump_struct_data()
698 " 1,\n" in test_btf_dump_struct_data()
705 { .cb = { 1, 2, 3, 4, 5},}); in test_btf_dump_struct_data()
706 /* For non-char, arrays, show non-zero values only */ in test_btf_dump_struct_data()
707 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct __sk_buff, BTF_F_COMPACT, in test_btf_dump_struct_data()
708 "(struct __sk_buff){.cb = (__u32[5])[0,0,1,0,0,],}", in test_btf_dump_struct_data()
709 { .cb = { 0, 0, 1, 0, 0},}); in test_btf_dump_struct_data()
710 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct __sk_buff, 0, in test_btf_dump_struct_data()
715 " 1,\n" in test_btf_dump_struct_data()
720 { .cb = { 0, 0, 1, 0, 0},}); in test_btf_dump_struct_data()
723 TEST_BTF_DUMP_DATA_C(btf, d, "struct", str, struct bpf_insn, BTF_F_COMPACT, in test_btf_dump_struct_data()
724 {.code = (__u8)1,.dst_reg = (__u8)0x2,.src_reg = (__u8)0x3,.off = (__s16)4,.imm = (__s32)5,}); in test_btf_dump_struct_data()
725 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_insn, in test_btf_dump_struct_data()
727 "{1,0x2,0x3,4,5,}", in test_btf_dump_struct_data()
728 { .code = 1, .dst_reg = 0x2, .src_reg = 0x3, .off = 4, in test_btf_dump_struct_data()
730 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_insn, 0, in test_btf_dump_struct_data()
732 " .code = (__u8)1,\n" in test_btf_dump_struct_data()
738 {.code = 1, .dst_reg = 2, .src_reg = 3, .off = 4, .imm = 5}); in test_btf_dump_struct_data()
741 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_insn, BTF_F_COMPACT, in test_btf_dump_struct_data()
743 { .code = 0, .dst_reg = 1}); in test_btf_dump_struct_data()
752 ret = btf_dump__dump_type_data(d, type_id, zero_data, type_sz, &opts); in test_btf_dump_struct_data()
761 TEST_BTF_DUMP_DATA(btf, d, "struct", str, struct bpf_sock_ops, BTF_F_COMPACT, in test_btf_dump_struct_data()
762 …(struct bpf_sock_ops){.op = (__u32)1,(union){.args = (__u32[4])[1,2,3,4,],.reply = (__u32)1,.reply… in test_btf_dump_struct_data()
763 { .op = 1, .args = { 1, 2, 3, 4}}); in test_btf_dump_struct_data()
766 TEST_BTF_DUMP_DATA(btf, d, "union", str, union bpf_iter_link_info, BTF_F_COMPACT, in test_btf_dump_struct_data()
767 …1,},.cgroup = (struct){.order = (enum bpf_cgroup_iter_order)BPF_CGROUP_ITER_SELF_ONLY,.cgroup_fd =… in test_btf_dump_struct_data()
768 { .cgroup = { .order = 1, .cgroup_fd = 1, }}); in test_btf_dump_struct_data()
779 ret = btf_dump__dump_type_data(d, type_id, skb, type_sz, &opts); in test_btf_dump_struct_data()
789 * field is - we can't trust its value so shouldn't display it. in test_btf_dump_struct_data()
791 TEST_BTF_DUMP_DATA_OVER(btf, d, "struct", str, struct bpf_sock_ops, in test_btf_dump_struct_data()
792 sizeof(struct bpf_sock_ops) - 1, in test_btf_dump_struct_data()
793 "(struct bpf_sock_ops){\n\t.op = (__u32)1,\n", in test_btf_dump_struct_data()
794 { .op = 1, .skb_hwtstamp = 2}); in test_btf_dump_struct_data()
795 TEST_BTF_DUMP_DATA_OVER(btf, d, "struct", str, struct bpf_sock_ops, in test_btf_dump_struct_data()
796 sizeof(struct bpf_sock_ops) - 1, in test_btf_dump_struct_data()
797 "(struct bpf_sock_ops){\n\t.op = (__u32)1,\n", in test_btf_dump_struct_data()
798 { .op = 1, .skb_hwtstamp = 0}); in test_btf_dump_struct_data()
801 static void test_btf_dump_var_data(struct btf *btf, struct btf_dump *d, in test_btf_dump_var_data() argument
805 TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int, BTF_F_COMPACT, in test_btf_dump_var_data()
808 TEST_BTF_DUMP_VAR(btf, d, NULL, str, "bpf_cgrp_storage_busy", int, BTF_F_COMPACT, in test_btf_dump_var_data()
812 static void test_btf_datasec(struct btf *btf, struct btf_dump *d, char *str, in test_btf_datasec() argument
831 ret = btf_dump__dump_type_data(d, type_id, data, data_sz, &opts); in test_btf_datasec()
842 struct btf_dump *d; in test_btf_dump_datasec_data() local
848 d = btf_dump__new(btf, btf_dump_snprintf, str, NULL); in test_btf_dump_datasec_data()
849 if (!ASSERT_OK_PTR(d, "could not create BTF dump")) in test_btf_dump_datasec_data()
852 test_btf_datasec(btf, d, str, "license", in test_btf_dump_datasec_data()
856 btf_dump__free(d); in test_btf_dump_datasec_data()
862 struct btf_dump *d; in test_btf_dump() local
869 if (!test__start_subtest(t->name)) in test_btf_dump()
881 d = btf_dump__new(btf, btf_dump_snprintf, str, NULL); in test_btf_dump()
882 if (!ASSERT_OK_PTR(d, "could not create BTF dump")) in test_btf_dump()
887 test_btf_dump_int_data(btf, d, str); in test_btf_dump()
889 test_btf_dump_float_data(btf, d, str); in test_btf_dump()
891 test_btf_dump_char_data(btf, d, str); in test_btf_dump()
893 test_btf_dump_typedef_data(btf, d, str); in test_btf_dump()
895 test_btf_dump_enum_data(btf, d, str); in test_btf_dump()
897 test_btf_dump_struct_data(btf, d, str); in test_btf_dump()
899 test_btf_dump_var_data(btf, d, str); in test_btf_dump()
900 btf_dump__free(d); in test_btf_dump()