diff mbox series

[API-NEXT,v2,3/3] validation: chksum: add test chksum suite

Message ID 1506452407-23070-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/3] api: chksum: add ones complement sum function | expand

Commit Message

Github ODP bot Sept. 26, 2017, 7 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Create chksum test suite and ones complement sum test
in there.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 193 (psavol:next-ip-checksum)
 ** https://github.com/Linaro/odp/pull/193
 ** Patch: https://github.com/Linaro/odp/pull/193.patch
 ** Base sha: e04e5f90df69e3031622b77fb5273b85d47eb966
 ** Merge commit sha: 18d37c68b9d3a13db328316de06eed14113d0fc2
 **/
 test/common_plat/m4/configure.m4                   |  1 +
 test/common_plat/validation/api/Makefile.am        |  1 +
 test/common_plat/validation/api/chksum/.gitignore  |  1 +
 test/common_plat/validation/api/chksum/Makefile.am |  5 ++
 test/common_plat/validation/api/chksum/chksum.c    | 70 ++++++++++++++++++++++
 test/common_plat/validation/api/chksum/chksum.h    | 24 ++++++++
 .../validation/api/chksum/chksum_main.c            | 12 ++++
 test/linux-generic/Makefile.am                     |  1 +
 8 files changed, 115 insertions(+)
 create mode 100644 test/common_plat/validation/api/chksum/.gitignore
 create mode 100644 test/common_plat/validation/api/chksum/Makefile.am
 create mode 100644 test/common_plat/validation/api/chksum/chksum.c
 create mode 100644 test/common_plat/validation/api/chksum/chksum.h
 create mode 100644 test/common_plat/validation/api/chksum/chksum_main.c
diff mbox series

Patch

diff --git a/test/common_plat/m4/configure.m4 b/test/common_plat/m4/configure.m4
index 13a13bd50..c06daea28 100644
--- a/test/common_plat/m4/configure.m4
+++ b/test/common_plat/m4/configure.m4
@@ -11,6 +11,7 @@  AC_CONFIG_FILES([test/common_plat/Makefile
 		 test/common_plat/validation/api/atomic/Makefile
 		 test/common_plat/validation/api/barrier/Makefile
 		 test/common_plat/validation/api/buffer/Makefile
+		 test/common_plat/validation/api/chksum/Makefile
 		 test/common_plat/validation/api/classification/Makefile
 		 test/common_plat/validation/api/cpumask/Makefile
 		 test/common_plat/validation/api/crypto/Makefile
diff --git a/test/common_plat/validation/api/Makefile.am b/test/common_plat/validation/api/Makefile.am
index b00fb2e95..65b2e3b9c 100644
--- a/test/common_plat/validation/api/Makefile.am
+++ b/test/common_plat/validation/api/Makefile.am
@@ -1,6 +1,7 @@ 
 ODP_MODULES = atomic \
 	      barrier \
 	      buffer \
+	      chksum \
 	      classification \
 	      cpumask \
 	      crypto \
diff --git a/test/common_plat/validation/api/chksum/.gitignore b/test/common_plat/validation/api/chksum/.gitignore
new file mode 100644
index 000000000..c69e8c470
--- /dev/null
+++ b/test/common_plat/validation/api/chksum/.gitignore
@@ -0,0 +1 @@ 
+chksum_main
diff --git a/test/common_plat/validation/api/chksum/Makefile.am b/test/common_plat/validation/api/chksum/Makefile.am
new file mode 100644
index 000000000..46f3643ef
--- /dev/null
+++ b/test/common_plat/validation/api/chksum/Makefile.am
@@ -0,0 +1,5 @@ 
+include ../Makefile.inc
+
+test_PROGRAMS = chksum_main$(EXEEXT)
+chksum_main_SOURCES = chksum_main.c chksum.c chksum.h
+chksum_main_LDADD = $(LIBCUNIT_COMMON) $(LIBODP)
diff --git a/test/common_plat/validation/api/chksum/chksum.c b/test/common_plat/validation/api/chksum/chksum.c
new file mode 100644
index 000000000..c3255d697
--- /dev/null
+++ b/test/common_plat/validation/api/chksum/chksum.c
@@ -0,0 +1,70 @@ 
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+#include "chksum.h"
+
+#define NUM_IP_HDR   5
+#define IP_HDR_LEN   20
+
+uint8_t ip_hdr_test_vect[NUM_IP_HDR][IP_HDR_LEN] ODP_ALIGNED(4) = {
+	{	0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+		0xAB, 0x33, 0xC0, 0xA8, 0x2C, 0xA2, 0xC0, 0xA8, 0x21, 0x99
+	},
+	{	0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+		0xAB, 0xCA, 0xC0, 0xA8, 0x2C, 0x5E, 0xC0, 0xA8, 0x21, 0x46
+	},
+	{	0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+		0xAB, 0x64, 0xC0, 0xA8, 0x2C, 0x20, 0xC0, 0xA8, 0x21, 0xEA
+	},
+	{       0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+		0xAB, 0x59, 0xC0, 0xA8, 0x2C, 0xD2, 0xC0, 0xA8, 0x21, 0x43
+	},
+	{	0x45, 0x00, 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11,
+		0xAC, 0x06, 0xC0, 0xA8, 0x2C, 0x5C, 0xC0, 0xA8, 0x21, 0x0C
+	}
+};
+
+/* Test ones complement sum with IPv4 headers */
+void chksum_ones_complement_ip(void)
+{
+	int i;
+	uint16_t sum, res;
+
+	for (i = 0; i < NUM_IP_HDR; i++) {
+		sum = odp_chksum_ones_comp16(ip_hdr_test_vect[0], IP_HDR_LEN);
+		res = ~sum;
+
+		CU_ASSERT(res == 0);
+	}
+}
+
+odp_testinfo_t chksum_suite[] = {
+	ODP_TEST_INFO(chksum_ones_complement_ip),
+	ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t chksum_suites[] = {
+	{"Checksum", NULL, NULL, chksum_suite},
+	ODP_SUITE_INFO_NULL
+};
+
+int chksum_main(int argc, char *argv[])
+{
+	int ret;
+
+	/* parse common options: */
+	if (odp_cunit_parse_options(argc, argv))
+		return -1;
+
+	ret = odp_cunit_register(chksum_suites);
+
+	if (ret == 0)
+		ret = odp_cunit_run();
+
+	return ret;
+}
diff --git a/test/common_plat/validation/api/chksum/chksum.h b/test/common_plat/validation/api/chksum/chksum.h
new file mode 100644
index 000000000..2086aeae7
--- /dev/null
+++ b/test/common_plat/validation/api/chksum/chksum.h
@@ -0,0 +1,24 @@ 
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#ifndef _ODP_TEST_CHKSUM_H_
+#define _ODP_TEST_CHKSUM_H_
+
+#include <odp_cunit_common.h>
+
+/* test functions: */
+void chksum_ones_complement_ip(void);
+
+/* test arrays: */
+extern odp_testinfo_t chksum_suite[];
+
+/* test registry: */
+extern odp_suiteinfo_t chksum_suites[];
+
+/* main test program: */
+int chksum_main(int argc, char *argv[]);
+
+#endif
diff --git a/test/common_plat/validation/api/chksum/chksum_main.c b/test/common_plat/validation/api/chksum/chksum_main.c
new file mode 100644
index 000000000..bec10ddd4
--- /dev/null
+++ b/test/common_plat/validation/api/chksum/chksum_main.c
@@ -0,0 +1,12 @@ 
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include "chksum.h"
+
+int main(int argc, char *argv[])
+{
+	return chksum_main(argc, argv);
+}
diff --git a/test/linux-generic/Makefile.am b/test/linux-generic/Makefile.am
index 4be5d94e9..0d3635880 100644
--- a/test/linux-generic/Makefile.am
+++ b/test/linux-generic/Makefile.am
@@ -13,6 +13,7 @@  TESTS = validation/api/pktio/pktio_run.sh \
 	$(ALL_API_VALIDATION_DIR)/atomic/atomic_main$(EXEEXT) \
 	$(ALL_API_VALIDATION_DIR)/barrier/barrier_main$(EXEEXT) \
 	$(ALL_API_VALIDATION_DIR)/buffer/buffer_main$(EXEEXT) \
+	$(ALL_API_VALIDATION_DIR)/chksum/chksum_main$(EXEEXT) \
 	$(ALL_API_VALIDATION_DIR)/classification/classification_main$(EXEEXT) \
 	$(ALL_API_VALIDATION_DIR)/cpumask/cpumask_main$(EXEEXT) \
 	$(ALL_API_VALIDATION_DIR)/crypto/crypto_main$(EXEEXT) \