aboutsummaryrefslogtreecommitdiff
path: root/test/validation/hash
diff options
context:
space:
mode:
Diffstat (limited to 'test/validation/hash')
-rw-r--r--test/validation/hash/.gitignore1
-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/hash/.gitignore b/test/validation/hash/.gitignore
new file mode 100644
index 000000000..6d0bc9314
--- /dev/null
+++ b/test/validation/hash/.gitignore
@@ -0,0 +1 @@
+hash_main
diff --git a/test/validation/hash/Makefile.am b/test/validation/hash/Makefile.am
new file mode 100644
index 000000000..b899b8bd3
--- /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 000000000..11b331e28
--- /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 000000000..46c74660d
--- /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 000000000..4f7765ca2
--- /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();
+}