Merge tag 'samsung-soc-5.10' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk...
[linux-2.6-microblaze.git] / tools / testing / selftests / bpf / prog_tests / btf_dump.c
index cb33a7e..39fb81d 100644 (file)
@@ -12,15 +12,16 @@ void btf_dump_printf(void *ctx, const char *fmt, va_list args)
 static struct btf_dump_test_case {
        const char *name;
        const char *file;
+       bool known_ptr_sz;
        struct btf_dump_opts opts;
 } btf_dump_test_cases[] = {
-       {"btf_dump: syntax", "btf_dump_test_case_syntax", {}},
-       {"btf_dump: ordering", "btf_dump_test_case_ordering", {}},
-       {"btf_dump: padding", "btf_dump_test_case_padding", {}},
-       {"btf_dump: packing", "btf_dump_test_case_packing", {}},
-       {"btf_dump: bitfields", "btf_dump_test_case_bitfields", {}},
-       {"btf_dump: multidim", "btf_dump_test_case_multidim", {}},
-       {"btf_dump: namespacing", "btf_dump_test_case_namespacing", {}},
+       {"btf_dump: syntax", "btf_dump_test_case_syntax", true, {}},
+       {"btf_dump: ordering", "btf_dump_test_case_ordering", false, {}},
+       {"btf_dump: padding", "btf_dump_test_case_padding", true, {}},
+       {"btf_dump: packing", "btf_dump_test_case_packing", true, {}},
+       {"btf_dump: bitfields", "btf_dump_test_case_bitfields", true, {}},
+       {"btf_dump: multidim", "btf_dump_test_case_multidim", false, {}},
+       {"btf_dump: namespacing", "btf_dump_test_case_namespacing", false, {}},
 };
 
 static int btf_dump_all_types(const struct btf *btf,
@@ -62,6 +63,18 @@ static int test_btf_dump_case(int n, struct btf_dump_test_case *t)
                goto done;
        }
 
+       /* tests with t->known_ptr_sz have no "long" or "unsigned long" type,
+        * so it's impossible to determine correct pointer size; but if they
+        * do, it should be 8 regardless of host architecture, becaues BPF
+        * target is always 64-bit
+        */
+       if (!t->known_ptr_sz) {
+               btf__set_pointer_size(btf, 8);
+       } else {
+               CHECK(btf__pointer_size(btf) != 8, "ptr_sz", "exp %d, got %zu\n",
+                     8, btf__pointer_size(btf));
+       }
+
        snprintf(out_file, sizeof(out_file), "/tmp/%s.output.XXXXXX", t->file);
        fd = mkstemp(out_file);
        if (CHECK(fd < 0, "create_tmp", "failed to create file: %d\n", fd)) {