aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeng <hepeng@ict.ac.cn>2015-10-25 17:54:30 +0800
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-12-29 14:07:52 +0300
commitbbf9c099e4a9c1a9d27330e424f8e15cee3651da (patch)
treeb24d94db04328b5bf5c63cea07f5653d8e6f35c8 /test
parent7b9d15e9e5fac00cc4d93f96cf8c20dbb9483c58 (diff)
api: hash: Added crc32 and crc32c hash functions
Signed-off-by: Peng <hepeng@ict.ac.cn> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Conflicts: platform/linux-generic/Makefile.am test/validation/hash/hash.c test/validation/hash/hash.h
Diffstat (limited to 'test')
-rw-r--r--test/validation/Makefile.am1
-rw-r--r--test/validation/hash/Makefile.am10
-rw-r--r--test/validation/hash/hash.c49
-rw-r--r--test/validation/hash/hash.h24
-rw-r--r--test/validation/hash/hash_main.c12
5 files changed, 96 insertions, 0 deletions
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 4e364944..4f926ced 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -4,6 +4,7 @@ ODP_MODULES = buffer \
cpumask \
crypto \
errno \
+ hash \
init \
queue \
packet \
diff --git a/test/validation/hash/Makefile.am b/test/validation/hash/Makefile.am
new file mode 100644
index 00000000..b899b8bd
--- /dev/null
+++ b/test/validation/hash/Makefile.am
@@ -0,0 +1,10 @@
+include ../Makefile.inc
+
+noinst_LTLIBRARIES = libtesthash.la
+libtesthash_la_SOURCES = hash.c
+
+test_PROGRAMS = hash_main$(EXEEXT)
+dist_hash_main_SOURCES = hash_main.c
+hash_main_LDADD = libtesthash.la $(LIBCUNIT_COMMON) $(LIBODP)
+
+EXTRA_DIST = hash.h
diff --git a/test/validation/hash/hash.c b/test/validation/hash/hash.c
new file mode 100644
index 00000000..11b331e2
--- /dev/null
+++ b/test/validation/hash/hash.c
@@ -0,0 +1,49 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <odp.h>
+#include <odp_cunit_common.h>
+#include "hash.h"
+
+void hash_test_crc32c(void)
+{
+ uint32_t test_value = 0x12345678;
+ uint32_t ret = odp_hash_crc32c(&test_value, 4, 0);
+
+ CU_ASSERT(ret == 0xfa745634);
+
+ test_value = 0x87654321;
+ ret = odp_hash_crc32c(&test_value, 4, 0);
+
+ CU_ASSERT(ret == 0xaca37da7);
+
+ uint32_t test_values[] = {0x12345678, 0x87654321};
+
+ ret = odp_hash_crc32c(test_values, 8, 0);
+
+ CU_ASSERT(ret == 0xe6e910b0);
+}
+
+odp_testinfo_t hash_suite[] = {
+ ODP_TEST_INFO(hash_test_crc32c),
+ ODP_TEST_INFO_NULL,
+};
+
+odp_suiteinfo_t hash_suites[] = {
+ {"Hash", NULL, NULL, hash_suite},
+ ODP_SUITE_INFO_NULL
+};
+
+int hash_main(void)
+{
+ int ret = odp_cunit_register(hash_suites);
+
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+
+}
diff --git a/test/validation/hash/hash.h b/test/validation/hash/hash.h
new file mode 100644
index 00000000..46c74660
--- /dev/null
+++ b/test/validation/hash/hash.h
@@ -0,0 +1,24 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _ODP_TEST_HASH_H_
+#define _ODP_TEST_HASH_H_
+
+#include <odp_cunit_common.h>
+
+/* test functions: */
+void hash_test_crc32c(void);
+
+/* test arrays: */
+extern odp_testinfo_t hash_suite[];
+
+/* test registry: */
+extern odp_suiteinfo_t hash_suites[];
+
+/* main test program: */
+int hash_main(void);
+
+#endif
diff --git a/test/validation/hash/hash_main.c b/test/validation/hash/hash_main.c
new file mode 100644
index 00000000..4f7765ca
--- /dev/null
+++ b/test/validation/hash/hash_main.c
@@ -0,0 +1,12 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "hash.h"
+
+int main(void)
+{
+ return hash_main();
+}