test/crypto: add packet soft expiry cases
[dpdk.git] / app / test / test_common.c
index 94d3674..ef177ce 100644 (file)
@@ -30,9 +30,13 @@ test_macros(int __rte_unused unused_parm)
        return -1;}
 
        uintptr_t unused = 0;
+       unsigned int smaller = SMALLER, bigger  = BIGGER;
 
        RTE_SET_USED(unused);
 
+       RTE_SWAP(smaller, bigger);
+       if (smaller != BIGGER && bigger != SMALLER)
+               FAIL_MACRO(RTE_SWAP);
        if ((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF) != BIGGER)
                FAIL_MACRO(RTE_PTR_ADD);
        if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER)
@@ -199,6 +203,10 @@ test_align(void)
                        val = RTE_ALIGN_MUL_FLOOR(i, p);
                        if (val % p != 0 || val > i)
                                FAIL_ALIGN("RTE_ALIGN_MUL_FLOOR", i, p);
+                       val = RTE_ALIGN_MUL_NEAR(i, p);
+                       if (val % p != 0 || ((val != RTE_ALIGN_MUL_CEIL(i, p))
+                               & (val != RTE_ALIGN_MUL_FLOOR(i, p))))
+                               FAIL_ALIGN("RTE_ALIGN_MUL_NEAR", i, p);
                }
        }
 
@@ -212,7 +220,19 @@ test_log2(void)
        const uint32_t max = 0x10000;
        const uint32_t step = 1;
 
-       for (i = 0; i < max; i = i + step) {
+       compare = rte_log2_u32(0);
+       if (compare != 0) {
+               printf("Wrong rte_log2_u32(0) val %x, expected 0\n", compare);
+               return TEST_FAILED;
+       }
+
+       compare = rte_log2_u64(0);
+       if (compare != 0) {
+               printf("Wrong rte_log2_u64(0) val %x, expected 0\n", compare);
+               return TEST_FAILED;
+       }
+
+       for (i = 1; i < max; i = i + step) {
                uint64_t i64;
 
                /* extend range for 64-bit */