Skip to contentSkip to conversation

test: add larger input len test for CRC16-CCITT

PATCH In review Shreesh Adiga 2 participants 2 messages Jun 12 – Jun 15

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: add larger input len test for CRC16-CCITT

CRC16-CCITT test only covered len 32, 12, and 2 which meant that code paths like 4x SSE4.2 loop and AVX512 code paths which operated on larger lens like >255 never got covered.

This patch adds a 348 len input test for CRC16-CCITT similar to CRC32 test which covers the additional paths in SSE4.2 and AVX512 implementations, therefore improving the test coverage.

---
 app/test/test_crc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test/test_crc.c +8 -0
index 4ff03e3f64..11645d323d 100644
@@ -14,6 +14,7 @@
 #define CRC32_VEC_LEN2     348
 #define CRC16_VEC_LEN1     12
 #define CRC16_VEC_LEN2     2
+#define CRC16_VEC_LEN3     348
 
 /* CRC test vector */
 static const uint8_t crc_vec[CRC_VEC_LEN] = {
@@ -46,6 +47,7 @@ static const uint32_t crc32_vec2_res = 0xefaae02f;
 static const uint32_t crc16_vec_res = 0x6bec;
 static const uint32_t crc16_vec1_res = 0x8cdd;
 static const uint32_t crc16_vec2_res = 0xec5b;
+static const uint32_t crc16_vec3_res = 0x6271;
 
 static int
 crc_all_algs(const char *desc, enum rte_net_crc_type type,
@@ -137,6 +139,12 @@ crc_autotest(void)
 	ret |= crc_all_algs("16-bit CCITT CRC:  Test 6", RTE_NET_CRC16_CCITT, crc16_vec2,
 		CRC16_VEC_LEN2, crc16_vec2_res);
 
+	/* 16-bit CCITT CRC:  Test 7 */
+	memset(test_data, 0, CRC32_VEC_LEN1);
+	for (i = 0; i < CRC16_VEC_LEN3; i += 12)
+		rte_memcpy(&test_data[i], crc16_vec1, 12);
+	ret |= crc_all_algs("16-bit CCITT CRC: Test 7", RTE_NET_CRC16_CCITT, test_data,
+		CRC16_VEC_LEN3, crc16_vec3_res);
 	return ret;
 }
 
Signature · 1 line
2.53.0
#1 lore raw
Quoted 10 lines · On Fri, 12 Jun 2026 08:07:45 +0530 Shreesh Adiga <[email protected]>…

CRC16-CCITT test only covered len 32, 12, and 2 which meant that code paths like 4x SSE4.2 loop and AVX512 code paths which operated on larger lens like >255 never got covered.

This patch adds a 348 len input test for CRC16-CCITT similar to CRC32 test which covers the additional paths in SSE4.2 and AVX512 implementations, therefore improving the test coverage.

---

Looks good applied to net-next