aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2023-08-11 13:01:41 +0300
committerMatias Elo <matias.elo@nokia.com>2023-10-23 10:59:18 +0300
commitab22998f4d2ec452d48831689d9112ef37d78b04 (patch)
treefbab7b237d0b6bc9c97a716cd6454af1cb6c86f4
parentbdebb244d66b6baa6a2a1c3650e18cb90f9400a4 (diff)
helper: macros: add test application
Add test application for new ODPH_MIN() and ODPH_MAX() macros. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
-rw-r--r--helper/test/.gitignore1
-rw-r--r--helper/test/Makefile.am10
-rw-r--r--helper/test/macros.c46
3 files changed, 53 insertions, 4 deletions
diff --git a/helper/test/.gitignore b/helper/test/.gitignore
index e1e5ab7b2..3db451f68 100644
--- a/helper/test/.gitignore
+++ b/helper/test/.gitignore
@@ -4,6 +4,7 @@ chksum
cli
cuckootable
iplookuptable
+macros
odpthreads
parse
process
diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am
index a8fcee574..80aac1083 100644
--- a/helper/test/Makefile.am
+++ b/helper/test/Makefile.am
@@ -3,10 +3,11 @@ include $(top_srcdir)/test/Makefile.inc
EXECUTABLES = version \
debug \
chksum \
- cuckootable \
- parse\
- table \
- iplookuptable
+ cuckootable \
+ macros \
+ parse\
+ table \
+ iplookuptable
#These are platform specific extensions that are not portable
#They are a convenience to app writers who have chosen to
@@ -39,6 +40,7 @@ dist_check_SCRIPTS = odpthreads_as_processes odpthreads_as_pthreads
chksum_SOURCES = chksum.c
cuckootable_SOURCES = cuckootable.c
+macros_SOURCES = macros.c
odpthreads_SOURCES = odpthreads.c
parse_SOURCES = parse.c
table_SOURCES = table.c
diff --git a/helper/test/macros.c b/helper/test/macros.c
new file mode 100644
index 000000000..cb6bd491a
--- /dev/null
+++ b/helper/test/macros.c
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Nokia
+ */
+
+#include <odp_api.h>
+#include <odp/helper/odph_api.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ int a, b;
+ int ret = 0;
+
+ printf("Running helper macro tests\n");
+
+ if (ODPH_MIN(0, 10) != 0)
+ ret++;
+
+ if (ODPH_MAX(0, 10) != 10)
+ ret++;
+
+ if (ODPH_MIN(-1, 10) != -1)
+ ret++;
+
+ if (ODPH_MAX(-1, 10) != 10)
+ ret++;
+
+ a = 0;
+ b = 10;
+ if (ODPH_MIN(a--, b--) != 0)
+ ret++;
+
+ a = 0;
+ b = 10;
+ if (ODPH_MAX(++a, ++b) != 11)
+ ret++;
+
+ if (!ret)
+ printf("All tests passed\n");
+ else
+ printf("%d tests failed\n", ret);
+
+ return ret ? EXIT_FAILURE : EXIT_SUCCESS;
+}