Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2020 Facebook */
0003 
0004 #include <test_progs.h>
0005 #include "test_endian.skel.h"
0006 
0007 static int duration;
0008 
0009 #define IN16 0x1234
0010 #define IN32 0x12345678U
0011 #define IN64 0x123456789abcdef0ULL
0012 
0013 #define OUT16 0x3412
0014 #define OUT32 0x78563412U
0015 #define OUT64 0xf0debc9a78563412ULL
0016 
0017 void test_endian(void)
0018 {
0019     struct test_endian* skel;
0020     struct test_endian__bss *bss;
0021     int err;
0022 
0023     skel = test_endian__open_and_load();
0024     if (CHECK(!skel, "skel_open", "failed to open skeleton\n"))
0025         return;
0026     bss = skel->bss;
0027 
0028     bss->in16 = IN16;
0029     bss->in32 = IN32;
0030     bss->in64 = IN64;
0031 
0032     err = test_endian__attach(skel);
0033     if (CHECK(err, "skel_attach", "skeleton attach failed: %d\n", err))
0034         goto cleanup;
0035 
0036     usleep(1);
0037 
0038     CHECK(bss->out16 != OUT16, "out16", "got 0x%llx != exp 0x%llx\n",
0039           (__u64)bss->out16, (__u64)OUT16);
0040     CHECK(bss->out32 != OUT32, "out32", "got 0x%llx != exp 0x%llx\n",
0041           (__u64)bss->out32, (__u64)OUT32);
0042     CHECK(bss->out64 != OUT64, "out16", "got 0x%llx != exp 0x%llx\n",
0043           (__u64)bss->out64, (__u64)OUT64);
0044 
0045     CHECK(bss->const16 != OUT16, "const16", "got 0x%llx != exp 0x%llx\n",
0046           (__u64)bss->const16, (__u64)OUT16);
0047     CHECK(bss->const32 != OUT32, "const32", "got 0x%llx != exp 0x%llx\n",
0048           (__u64)bss->const32, (__u64)OUT32);
0049     CHECK(bss->const64 != OUT64, "const64", "got 0x%llx != exp 0x%llx\n",
0050           (__u64)bss->const64, (__u64)OUT64);
0051 cleanup:
0052     test_endian__destroy(skel);
0053 }