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-12 15:41:56 +0100
commit3d9b72106bd664b1267533e7278ff817f942e3c6 (patch)
tree52a6964f40e029d55d73bc18208971eff2297891 /app/test/test_cycles.c
parenta83862b166241910d0474f801cb2e6afa4c6875b (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);