MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_bsf

Function test_bsf

dpdk/app/test/test_common.c:81–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81static int
82test_bsf(void)
83{
84 uint32_t shift, pos;
85
86 /* safe versions should be able to handle 0 */
87 if (rte_bsf32_safe(0, &pos) != 0)
88 FAIL("rte_bsf32_safe");
89 if (rte_bsf64_safe(0, &pos) != 0)
90 FAIL("rte_bsf64_safe");
91
92 for (shift = 0; shift < 63; shift++) {
93 uint32_t val32;
94 uint64_t val64;
95
96 val64 = 1ULL << shift;
97 if ((uint32_t)rte_bsf64(val64) != shift)
98 FAIL("rte_bsf64");
99 if (rte_bsf64_safe(val64, &pos) != 1)
100 FAIL("rte_bsf64_safe");
101 if (pos != shift)
102 FAIL("rte_bsf64_safe");
103
104 if (shift > 31)
105 continue;
106
107 val32 = 1U << shift;
108 if ((uint32_t)rte_bsf32(val32) != shift)
109 FAIL("rte_bsf32");
110 if (rte_bsf32_safe(val32, &pos) != 1)
111 FAIL("rte_bsf32_safe");
112 if (pos != shift)
113 FAIL("rte_bsf32_safe");
114 }
115
116 return 0;
117}
118
119static int
120test_misc(void)

Callers 1

test_commonFunction · 0.85

Calls 4

rte_bsf32_safeFunction · 0.50
rte_bsf64_safeFunction · 0.50
rte_bsf64Function · 0.50
rte_bsf32Function · 0.50

Tested by

no test coverage detected