aboutsummaryrefslogtreecommitdiffstats
path: root/app/test/test_cycles.c
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-12-08 14:07:29 +0100
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-12-08 14:10:05 +0100
commit6b3e017e5d25f15da73f7700f7f2ac553ef1a2e9 (patch)
tree1b1fb3f903b2282e261ade69e3c17952b3fd3464 /app/test/test_cycles.c
parent32e04ea00cd159613e04acef75e52bfca6eeff2f (diff)
Imported Upstream version 16.11
Change-Id: I1944c65ddc88a9ad70f8c0eb6731552b84fbcb77 Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'app/test/test_cycles.c')
-rw-r--r--app/test/test_cycles.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/test/test_cycles.c b/app/test/test_cycles.c
index f6c043a4..f1897979 100644
--- a/app/test/test_cycles.c
+++ b/app/test/test_cycles.c
@@ -90,3 +90,48 @@ test_cycles(void)
}
REGISTER_TEST_COMMAND(cycles_autotest, test_cycles);
+
+/*
+ * rte_delay_us_callback test
+ *
+ * - check if callback is correctly registered/unregistered
+ *
+ */
+
+static unsigned int pattern;
+static void my_rte_delay_us(unsigned int us)
+{
+ pattern += us;
+}
+
+static int
+test_user_delay_us(void)
+{
+ pattern = 0;
+
+ rte_delay_us(2);
+ if (pattern != 0)
+ return -1;
+
+ /* register custom delay function */
+ rte_delay_us_callback_register(my_rte_delay_us);
+
+ rte_delay_us(2);
+ if (pattern != 2)
+ return -1;
+
+ rte_delay_us(3);
+ if (pattern != 5)
+ return -1;
+
+ /* restore original delay function */
+ rte_delay_us_callback_register(rte_delay_us_block);
+
+ rte_delay_us(3);
+ if (pattern != 5)
+ return -1;
+
+ return 0;
+}
+
+REGISTER_TEST_COMMAND(user_delay_us, test_user_delay_us);