1a9de470cSBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 2a9de470cSBruce Richardson * Copyright(c) 2010-2014 Intel Corporation 3a9de470cSBruce Richardson */ 4a9de470cSBruce Richardson 5a9de470cSBruce Richardson #include <stdio.h> 6a9de470cSBruce Richardson #include <inttypes.h> 7a9de470cSBruce Richardson #include <string.h> 8a9de470cSBruce Richardson #include <math.h> 9a9de470cSBruce Richardson #include <rte_common.h> 107253e3d2STyler Retzlaff #include <rte_bitops.h> 11a9de470cSBruce Richardson #include <rte_hexdump.h> 12*b3e64fe5SStephen Hemminger #include <rte_random.h> 13a9de470cSBruce Richardson #include <rte_pause.h> 14a9de470cSBruce Richardson 15a9de470cSBruce Richardson #include "test.h" 16a9de470cSBruce Richardson 17*b3e64fe5SStephen Hemminger #define MAX_NUM (1 << 20) 18a9de470cSBruce Richardson 19a9de470cSBruce Richardson #define FAIL(x)\ 20a9de470cSBruce Richardson {printf(x "() test failed!\n");\ 21a9de470cSBruce Richardson return -1;} 22a9de470cSBruce Richardson 23a9de470cSBruce Richardson /* this is really a sanity check */ 24a9de470cSBruce Richardson static int 25a9de470cSBruce Richardson test_macros(int __rte_unused unused_parm) 26a9de470cSBruce Richardson { 27a9de470cSBruce Richardson #define SMALLER 0x1000U 28a9de470cSBruce Richardson #define BIGGER 0x2000U 29a9de470cSBruce Richardson #define PTR_DIFF BIGGER - SMALLER 30a9de470cSBruce Richardson 31a9de470cSBruce Richardson uintptr_t unused = 0; 32a0a388a8SShijith Thotton unsigned int smaller = SMALLER, bigger = BIGGER; 331a7374c9SDmitry Kozlyuk uint32_t arr[3]; 34a9de470cSBruce Richardson 35a9de470cSBruce Richardson RTE_SET_USED(unused); 36a9de470cSBruce Richardson 37a0a388a8SShijith Thotton RTE_SWAP(smaller, bigger); 381a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT(smaller == BIGGER && bigger == SMALLER, 391a7374c9SDmitry Kozlyuk "RTE_SWAP"); 401a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF), BIGGER, 411a7374c9SDmitry Kozlyuk "RTE_PTR_ADD"); 421a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF), SMALLER, 431a7374c9SDmitry Kozlyuk "RTE_PTR_SUB"); 441a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_PTR_DIFF(BIGGER, SMALLER), PTR_DIFF, 451a7374c9SDmitry Kozlyuk "RTE_PTR_DIFF"); 461a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_MAX(SMALLER, BIGGER), BIGGER, 471a7374c9SDmitry Kozlyuk "RTE_MAX"); 481a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_MIN(SMALLER, BIGGER), SMALLER, 491a7374c9SDmitry Kozlyuk "RTE_MIN"); 50a9de470cSBruce Richardson 511a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_PTR_ADD(arr + 1, sizeof(arr[0])), &arr[2], 521a7374c9SDmitry Kozlyuk "RTE_PTR_ADD(expr, x)"); 531a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_PTR_SUB(arr + 1, sizeof(arr[0])), &arr[0], 541a7374c9SDmitry Kozlyuk "RTE_PTR_SUB(expr, x)"); 551a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_FLOOR(arr + 2, 4), &arr[2], 561a7374c9SDmitry Kozlyuk "RTE_PTR_ALIGN_FLOOR(expr, x)"); 571a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN_CEIL(arr + 2, 4), &arr[2], 581a7374c9SDmitry Kozlyuk "RTE_PTR_ALIGN_CEIL(expr, x)"); 591a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL(RTE_PTR_ALIGN(arr + 2, 4), &arr[2], 601a7374c9SDmitry Kozlyuk "RTE_PTR_ALIGN(expr, x)"); 611a7374c9SDmitry Kozlyuk 621a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL( 631a7374c9SDmitry Kozlyuk RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 1), 4), &arr[1], 641a7374c9SDmitry Kozlyuk "RTE_PTR_ALIGN_FLOOR(x < y/2, y)"); 651a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL( 661a7374c9SDmitry Kozlyuk RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(&arr[1], 3), 4), &arr[1], 671a7374c9SDmitry Kozlyuk "RTE_PTR_ALIGN_FLOOR(x > y/2, y)"); 681a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL( 691a7374c9SDmitry Kozlyuk RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 3), 4), &arr[2], 701a7374c9SDmitry Kozlyuk "RTE_PTR_ALIGN_CEIL(x < y/2, y)"); 711a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT_EQUAL( 721a7374c9SDmitry Kozlyuk RTE_PTR_ALIGN_CEIL(RTE_PTR_ADD(&arr[1], 1), 4), &arr[2], 731a7374c9SDmitry Kozlyuk "RTE_PTR_ALIGN_CEIL(x > y/2, y)"); 741a7374c9SDmitry Kozlyuk 751a7374c9SDmitry Kozlyuk RTE_TEST_ASSERT(strncmp(RTE_STR(test), "test", sizeof("test")) == 0, 761a7374c9SDmitry Kozlyuk "RTE_STR"); 77a9de470cSBruce Richardson 78a9de470cSBruce Richardson return 0; 79a9de470cSBruce Richardson } 80a9de470cSBruce Richardson 81a9de470cSBruce Richardson static int 82a9de470cSBruce Richardson test_bsf(void) 83a9de470cSBruce Richardson { 84a9de470cSBruce Richardson uint32_t shift, pos; 85a9de470cSBruce Richardson 86a9de470cSBruce Richardson /* safe versions should be able to handle 0 */ 87a9de470cSBruce Richardson if (rte_bsf32_safe(0, &pos) != 0) 88a9de470cSBruce Richardson FAIL("rte_bsf32_safe"); 89a9de470cSBruce Richardson if (rte_bsf64_safe(0, &pos) != 0) 90a9de470cSBruce Richardson FAIL("rte_bsf64_safe"); 91a9de470cSBruce Richardson 92a9de470cSBruce Richardson for (shift = 0; shift < 63; shift++) { 93a9de470cSBruce Richardson uint32_t val32; 94a9de470cSBruce Richardson uint64_t val64; 95a9de470cSBruce Richardson 96a9de470cSBruce Richardson val64 = 1ULL << shift; 97a9de470cSBruce Richardson if ((uint32_t)rte_bsf64(val64) != shift) 98a9de470cSBruce Richardson FAIL("rte_bsf64"); 99a9de470cSBruce Richardson if (rte_bsf64_safe(val64, &pos) != 1) 100a9de470cSBruce Richardson FAIL("rte_bsf64_safe"); 101a9de470cSBruce Richardson if (pos != shift) 102a9de470cSBruce Richardson FAIL("rte_bsf64_safe"); 103a9de470cSBruce Richardson 104a9de470cSBruce Richardson if (shift > 31) 105a9de470cSBruce Richardson continue; 106a9de470cSBruce Richardson 107a9de470cSBruce Richardson val32 = 1U << shift; 108a9de470cSBruce Richardson if ((uint32_t)rte_bsf32(val32) != shift) 109a9de470cSBruce Richardson FAIL("rte_bsf32"); 110a9de470cSBruce Richardson if (rte_bsf32_safe(val32, &pos) != 1) 111a9de470cSBruce Richardson FAIL("rte_bsf32_safe"); 112a9de470cSBruce Richardson if (pos != shift) 113a9de470cSBruce Richardson FAIL("rte_bsf32_safe"); 114a9de470cSBruce Richardson } 115a9de470cSBruce Richardson 116a9de470cSBruce Richardson return 0; 117a9de470cSBruce Richardson } 118a9de470cSBruce Richardson 119a9de470cSBruce Richardson static int 120a9de470cSBruce Richardson test_misc(void) 121a9de470cSBruce Richardson { 122a9de470cSBruce Richardson char memdump[] = "memdump_test"; 123a9de470cSBruce Richardson 124a9de470cSBruce Richardson rte_memdump(stdout, "test", memdump, sizeof(memdump)); 125a9de470cSBruce Richardson rte_hexdump(stdout, "test", memdump, sizeof(memdump)); 126a9de470cSBruce Richardson 127a9de470cSBruce Richardson rte_pause(); 128a9de470cSBruce Richardson 129a9de470cSBruce Richardson return 0; 130a9de470cSBruce Richardson } 131a9de470cSBruce Richardson 132a9de470cSBruce Richardson static int 133a9de470cSBruce Richardson test_align(void) 134a9de470cSBruce Richardson { 135a9de470cSBruce Richardson #define FAIL_ALIGN(x, i, p)\ 136a9de470cSBruce Richardson {printf(x "() test failed: %u %u\n", i, p);\ 137a9de470cSBruce Richardson return -1;} 138a9de470cSBruce Richardson #define FAIL_ALIGN64(x, j, q)\ 139a9de470cSBruce Richardson {printf(x "() test failed: %"PRIu64" %"PRIu64"\n", j, q);\ 140a9de470cSBruce Richardson return -1; } 141a9de470cSBruce Richardson #define ERROR_FLOOR(res, i, pow) \ 142a9de470cSBruce Richardson (res % pow) || /* check if not aligned */ \ 143a9de470cSBruce Richardson ((res / pow) != (i / pow)) /* check if correct alignment */ 144a9de470cSBruce Richardson #define ERROR_CEIL(res, i, pow) \ 145a9de470cSBruce Richardson (res % pow) || /* check if not aligned */ \ 146a9de470cSBruce Richardson ((i % pow) == 0 ? /* check if ceiling is invoked */ \ 147a9de470cSBruce Richardson val / pow != i / pow : /* if aligned */ \ 148a9de470cSBruce Richardson val / pow != (i / pow) + 1) /* if not aligned, hence +1 */ 149a9de470cSBruce Richardson 150a9de470cSBruce Richardson uint32_t i, p, val; 151a9de470cSBruce Richardson uint64_t j, q; 152a9de470cSBruce Richardson 153a9de470cSBruce Richardson for (i = 1, p = 1; i <= MAX_NUM; i ++) { 154a9de470cSBruce Richardson if (rte_align32pow2(i) != p) 155a9de470cSBruce Richardson FAIL_ALIGN("rte_align32pow2", i, p); 156a9de470cSBruce Richardson if (i == p) 157a9de470cSBruce Richardson p <<= 1; 158a9de470cSBruce Richardson } 159a9de470cSBruce Richardson 160a9de470cSBruce Richardson for (i = 1, p = 1; i <= MAX_NUM; i++) { 161a9de470cSBruce Richardson if (rte_align32prevpow2(i) != p) 162a9de470cSBruce Richardson FAIL_ALIGN("rte_align32prevpow2", i, p); 163a9de470cSBruce Richardson if (rte_is_power_of_2(i + 1)) 164a9de470cSBruce Richardson p = i + 1; 165a9de470cSBruce Richardson } 166a9de470cSBruce Richardson 167a9de470cSBruce Richardson for (j = 1, q = 1; j <= MAX_NUM ; j++) { 168a9de470cSBruce Richardson if (rte_align64pow2(j) != q) 169a9de470cSBruce Richardson FAIL_ALIGN64("rte_align64pow2", j, q); 170a9de470cSBruce Richardson if (j == q) 171a9de470cSBruce Richardson q <<= 1; 172a9de470cSBruce Richardson } 173a9de470cSBruce Richardson 174a9de470cSBruce Richardson for (j = 1, q = 1; j <= MAX_NUM ; j++) { 175a9de470cSBruce Richardson if (rte_align64prevpow2(j) != q) 176a9de470cSBruce Richardson FAIL_ALIGN64("rte_align64prevpow2", j, q); 177a9de470cSBruce Richardson if (rte_is_power_of_2(j + 1)) 178a9de470cSBruce Richardson q = j + 1; 179a9de470cSBruce Richardson } 180a9de470cSBruce Richardson 181a9de470cSBruce Richardson for (p = 2; p <= MAX_NUM; p <<= 1) { 182a9de470cSBruce Richardson 183a9de470cSBruce Richardson if (!rte_is_power_of_2(p)) 184a9de470cSBruce Richardson FAIL("rte_is_power_of_2"); 185a9de470cSBruce Richardson 186a9de470cSBruce Richardson for (i = 1; i <= MAX_NUM; i++) { 187a9de470cSBruce Richardson /* align floor */ 188a9de470cSBruce Richardson if (RTE_ALIGN_FLOOR((uintptr_t)i, p) % p) 189a9de470cSBruce Richardson FAIL_ALIGN("RTE_ALIGN_FLOOR", i, p); 190a9de470cSBruce Richardson 191a9de470cSBruce Richardson val = RTE_PTR_ALIGN_FLOOR((uintptr_t) i, p); 192a9de470cSBruce Richardson if (ERROR_FLOOR(val, i, p)) 193a9de470cSBruce Richardson FAIL_ALIGN("RTE_PTR_ALIGN_FLOOR", i, p); 194a9de470cSBruce Richardson 195a9de470cSBruce Richardson val = RTE_ALIGN_FLOOR(i, p); 196a9de470cSBruce Richardson if (ERROR_FLOOR(val, i, p)) 197a9de470cSBruce Richardson FAIL_ALIGN("RTE_ALIGN_FLOOR", i, p); 198a9de470cSBruce Richardson 199a9de470cSBruce Richardson /* align ceiling */ 200a9de470cSBruce Richardson val = RTE_PTR_ALIGN((uintptr_t) i, p); 201a9de470cSBruce Richardson if (ERROR_CEIL(val, i, p)) 202a9de470cSBruce Richardson FAIL_ALIGN("RTE_PTR_ALIGN", i, p); 203a9de470cSBruce Richardson 204a9de470cSBruce Richardson val = RTE_ALIGN(i, p); 205a9de470cSBruce Richardson if (ERROR_CEIL(val, i, p)) 206a9de470cSBruce Richardson FAIL_ALIGN("RTE_ALIGN", i, p); 207a9de470cSBruce Richardson 208a9de470cSBruce Richardson val = RTE_ALIGN_CEIL(i, p); 209a9de470cSBruce Richardson if (ERROR_CEIL(val, i, p)) 210a9de470cSBruce Richardson FAIL_ALIGN("RTE_ALIGN_CEIL", i, p); 211a9de470cSBruce Richardson 212a9de470cSBruce Richardson val = RTE_PTR_ALIGN_CEIL((uintptr_t)i, p); 213a9de470cSBruce Richardson if (ERROR_CEIL(val, i, p)) 214a9de470cSBruce Richardson FAIL_ALIGN("RTE_PTR_ALIGN_CEIL", i, p); 215a9de470cSBruce Richardson 216a9de470cSBruce Richardson /* by this point we know that val is aligned to p */ 217a9de470cSBruce Richardson if (!rte_is_aligned((void*)(uintptr_t) val, p)) 218a9de470cSBruce Richardson FAIL("rte_is_aligned"); 219a9de470cSBruce Richardson } 220a9de470cSBruce Richardson } 221a9de470cSBruce Richardson 222*b3e64fe5SStephen Hemminger /* testing the whole space of 2^20^2 takes too long. */ 223*b3e64fe5SStephen Hemminger for (j = 1; j <= MAX_NUM ; j++) { 224*b3e64fe5SStephen Hemminger i = rte_rand_max(MAX_NUM - 1) + 1; 225*b3e64fe5SStephen Hemminger p = rte_rand_max(MAX_NUM - 1) + 1; 226*b3e64fe5SStephen Hemminger 227a9de470cSBruce Richardson val = RTE_ALIGN_MUL_CEIL(i, p); 228a9de470cSBruce Richardson if (val % p != 0 || val < i) 229a9de470cSBruce Richardson FAIL_ALIGN("RTE_ALIGN_MUL_CEIL", i, p); 230a9de470cSBruce Richardson val = RTE_ALIGN_MUL_FLOOR(i, p); 231a9de470cSBruce Richardson if (val % p != 0 || val > i) 232a9de470cSBruce Richardson FAIL_ALIGN("RTE_ALIGN_MUL_FLOOR", i, p); 233f56e5514SPavan Nikhilesh val = RTE_ALIGN_MUL_NEAR(i, p); 234f56e5514SPavan Nikhilesh if (val % p != 0 || ((val != RTE_ALIGN_MUL_CEIL(i, p)) 235f56e5514SPavan Nikhilesh & (val != RTE_ALIGN_MUL_FLOOR(i, p)))) 236f56e5514SPavan Nikhilesh FAIL_ALIGN("RTE_ALIGN_MUL_NEAR", i, p); 237a9de470cSBruce Richardson } 238a9de470cSBruce Richardson 239a9de470cSBruce Richardson return 0; 240a9de470cSBruce Richardson } 241a9de470cSBruce Richardson 242a9de470cSBruce Richardson static int 243a9de470cSBruce Richardson test_log2(void) 244a9de470cSBruce Richardson { 245a9de470cSBruce Richardson uint32_t i, base, compare; 246a9de470cSBruce Richardson const uint32_t max = 0x10000; 247a9de470cSBruce Richardson const uint32_t step = 1; 248a9de470cSBruce Richardson 24930a0df64SDavid Marchand compare = rte_log2_u32(0); 25030a0df64SDavid Marchand if (compare != 0) { 25130a0df64SDavid Marchand printf("Wrong rte_log2_u32(0) val %x, expected 0\n", compare); 25230a0df64SDavid Marchand return TEST_FAILED; 25330a0df64SDavid Marchand } 25430a0df64SDavid Marchand 25530a0df64SDavid Marchand compare = rte_log2_u64(0); 25630a0df64SDavid Marchand if (compare != 0) { 25730a0df64SDavid Marchand printf("Wrong rte_log2_u64(0) val %x, expected 0\n", compare); 25830a0df64SDavid Marchand return TEST_FAILED; 25930a0df64SDavid Marchand } 26030a0df64SDavid Marchand 26130a0df64SDavid Marchand for (i = 1; i < max; i = i + step) { 262a9de470cSBruce Richardson uint64_t i64; 263a9de470cSBruce Richardson 264a9de470cSBruce Richardson /* extend range for 64-bit */ 265a9de470cSBruce Richardson i64 = (uint64_t)i << 32; 266a9de470cSBruce Richardson base = (uint32_t)ceilf(log2(i64)); 267a9de470cSBruce Richardson compare = rte_log2_u64(i64); 268a9de470cSBruce Richardson if (base != compare) { 269a9de470cSBruce Richardson printf("Wrong rte_log2_u64(%" PRIx64 ") val %x, expected %x\n", 270a9de470cSBruce Richardson i64, compare, base); 271a9de470cSBruce Richardson return TEST_FAILED; 272a9de470cSBruce Richardson } 273a9de470cSBruce Richardson 274a9de470cSBruce Richardson base = (uint32_t)ceilf(log2((uint32_t)i)); 275a9de470cSBruce Richardson compare = rte_log2_u32((uint32_t)i); 276a9de470cSBruce Richardson if (base != compare) { 277a9de470cSBruce Richardson printf("Wrong rte_log2_u32(%x) val %x, expected %x\n", 278a9de470cSBruce Richardson i, compare, base); 279a9de470cSBruce Richardson return TEST_FAILED; 280a9de470cSBruce Richardson } 281a9de470cSBruce Richardson compare = rte_log2_u64((uint64_t)i); 282a9de470cSBruce Richardson if (base != compare) { 283a9de470cSBruce Richardson printf("Wrong rte_log2_u64(%x) val %x, expected %x\n", 284a9de470cSBruce Richardson i, compare, base); 285a9de470cSBruce Richardson return TEST_FAILED; 286a9de470cSBruce Richardson } 287a9de470cSBruce Richardson } 288a9de470cSBruce Richardson return 0; 289a9de470cSBruce Richardson } 290a9de470cSBruce Richardson 291a9de470cSBruce Richardson static int 292a9de470cSBruce Richardson test_fls(void) 293a9de470cSBruce Richardson { 294a9de470cSBruce Richardson struct fls_test_vector { 295a9de470cSBruce Richardson uint32_t arg; 296a9de470cSBruce Richardson int rc; 297a9de470cSBruce Richardson }; 298a9de470cSBruce Richardson int expected, rc; 299a9de470cSBruce Richardson uint32_t i, arg; 300a9de470cSBruce Richardson 301a9de470cSBruce Richardson const struct fls_test_vector test[] = { 302a9de470cSBruce Richardson {0x0, 0}, 303a9de470cSBruce Richardson {0x1, 1}, 304a9de470cSBruce Richardson {0x4000, 15}, 305a9de470cSBruce Richardson {0x80000000, 32}, 306a9de470cSBruce Richardson }; 307a9de470cSBruce Richardson 308a9de470cSBruce Richardson for (i = 0; i < RTE_DIM(test); i++) { 309a9de470cSBruce Richardson uint64_t arg64; 310a9de470cSBruce Richardson 311a9de470cSBruce Richardson arg = test[i].arg; 312a9de470cSBruce Richardson rc = rte_fls_u32(arg); 313a9de470cSBruce Richardson expected = test[i].rc; 314a9de470cSBruce Richardson if (rc != expected) { 315a9de470cSBruce Richardson printf("Wrong rte_fls_u32(0x%x) rc=%d, expected=%d\n", 316a9de470cSBruce Richardson arg, rc, expected); 317a9de470cSBruce Richardson return TEST_FAILED; 318a9de470cSBruce Richardson } 319a9de470cSBruce Richardson /* 64-bit version */ 320a9de470cSBruce Richardson arg = test[i].arg; 321a9de470cSBruce Richardson rc = rte_fls_u64(arg); 322a9de470cSBruce Richardson expected = test[i].rc; 323a9de470cSBruce Richardson if (rc != expected) { 324a9de470cSBruce Richardson printf("Wrong rte_fls_u64(0x%x) rc=%d, expected=%d\n", 325a9de470cSBruce Richardson arg, rc, expected); 326a9de470cSBruce Richardson return TEST_FAILED; 327a9de470cSBruce Richardson } 328a9de470cSBruce Richardson /* 64-bit version shifted by 32 bits */ 329a9de470cSBruce Richardson arg64 = (uint64_t)test[i].arg << 32; 330a9de470cSBruce Richardson rc = rte_fls_u64(arg64); 331a9de470cSBruce Richardson /* don't shift zero */ 332a9de470cSBruce Richardson expected = test[i].rc == 0 ? 0 : test[i].rc + 32; 333a9de470cSBruce Richardson if (rc != expected) { 334a9de470cSBruce Richardson printf("Wrong rte_fls_u64(0x%" PRIx64 ") rc=%d, expected=%d\n", 335a9de470cSBruce Richardson arg64, rc, expected); 336a9de470cSBruce Richardson return TEST_FAILED; 337a9de470cSBruce Richardson } 338a9de470cSBruce Richardson } 339a9de470cSBruce Richardson 340a9de470cSBruce Richardson return 0; 341a9de470cSBruce Richardson } 342a9de470cSBruce Richardson 343a9de470cSBruce Richardson static int 344a9de470cSBruce Richardson test_common(void) 345a9de470cSBruce Richardson { 346a9de470cSBruce Richardson int ret = 0; 347a9de470cSBruce Richardson ret |= test_align(); 348a9de470cSBruce Richardson ret |= test_macros(0); 349a9de470cSBruce Richardson ret |= test_misc(); 350a9de470cSBruce Richardson ret |= test_bsf(); 351a9de470cSBruce Richardson ret |= test_log2(); 352a9de470cSBruce Richardson ret |= test_fls(); 353a9de470cSBruce Richardson 354a9de470cSBruce Richardson return ret; 355a9de470cSBruce Richardson } 356a9de470cSBruce Richardson 357e0a8442cSBruce Richardson REGISTER_FAST_TEST(common_autotest, true, true, test_common); 358