1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Facebook */
4 #include <test_progs.h>
5 #include "test_endian.skel.h"
10 #define IN32 0x12345678U
11 #define IN64 0x123456789abcdef0ULL
14 #define OUT32 0x78563412U
15 #define OUT64 0xf0debc9a78563412ULL
17 void test_endian(void)
19 struct test_endian
* skel
;
20 struct test_endian__bss
*bss
;
23 skel
= test_endian__open_and_load();
24 if (CHECK(!skel
, "skel_open", "failed to open skeleton\n"))
32 err
= test_endian__attach(skel
);
33 if (CHECK(err
, "skel_attach", "skeleton attach failed: %d\n", err
))
38 CHECK(bss
->out16
!= OUT16
, "out16", "got 0x%llx != exp 0x%llx\n",
39 (__u64
)bss
->out16
, (__u64
)OUT16
);
40 CHECK(bss
->out32
!= OUT32
, "out32", "got 0x%llx != exp 0x%llx\n",
41 (__u64
)bss
->out32
, (__u64
)OUT32
);
42 CHECK(bss
->out64
!= OUT64
, "out16", "got 0x%llx != exp 0x%llx\n",
43 (__u64
)bss
->out64
, (__u64
)OUT64
);
45 CHECK(bss
->const16
!= OUT16
, "const16", "got 0x%llx != exp 0x%llx\n",
46 (__u64
)bss
->const16
, (__u64
)OUT16
);
47 CHECK(bss
->const32
!= OUT32
, "const32", "got 0x%llx != exp 0x%llx\n",
48 (__u64
)bss
->const32
, (__u64
)OUT32
);
49 CHECK(bss
->const64
!= OUT64
, "const64", "got 0x%llx != exp 0x%llx\n",
50 (__u64
)bss
->const64
, (__u64
)OUT64
);
52 test_endian__destroy(skel
);