summaryrefslogtreecommitdiff
path: root/cesar/hal/clk/test/src/test_clk.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hal/clk/test/src/test_clk.c')
-rw-r--r--cesar/hal/clk/test/src/test_clk.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/cesar/hal/clk/test/src/test_clk.c b/cesar/hal/clk/test/src/test_clk.c
new file mode 100644
index 0000000000..7644045af9
--- /dev/null
+++ b/cesar/hal/clk/test/src/test_clk.c
@@ -0,0 +1,71 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/clk/test/src/test_clk.c
+ * \brief Test the clk dynamic configuration.
+ * \ingroup hal
+ */
+#include "common/std.h"
+#include "hal/clk/clk.h"
+
+#include "lib/test.h"
+
+uint cyg_hal_system_clock_freq = 0;
+
+bool
+hal_clk_str_to_num (uint *num, const char *str);
+
+void
+hal_clk_test_case_string_to_int (test_t t)
+{
+ test_case_begin (t, "Test function conversion");
+
+ test_begin (t, "spc300, mse500 frequency")
+ {
+ bool ret = false;
+ char frequency_mhz_str[][4] = {"147\0", "250\0"};
+ uint frequency_mhz = 0;
+ uint expected_freq_mhz[] = {147, 250};
+ uint i;
+
+ for (i = 0; i < COUNT (frequency_mhz_str); i++)
+ {
+ ret = hal_clk_str_to_num (&frequency_mhz,
+ frequency_mhz_str[i]);
+ test_fail_unless (ret);
+ test_fail_unless (frequency_mhz == expected_freq_mhz[i]);
+ }
+ }
+ test_end;
+
+ test_begin (t, "Error in parameter")
+ {
+ bool ret = false;
+ uint frequency_mhz = 0;
+ ret = hal_clk_str_to_num (&frequency_mhz, "\0");
+ test_fail_unless (!ret);
+ test_fail_unless (frequency_mhz == 0);
+ }
+ test_end;
+}
+
+void
+hal_clk_test_suite (test_t t)
+{
+ test_suite_begin (t, "System clock dynamic configuration");
+ hal_clk_test_case_string_to_int (t);
+}
+
+int main (int argc, char *argv[])
+{
+ test_t t;
+ test_init (t, argc, argv);
+ hal_clk_test_suite (t);
+ test_result (t);
+ return test_nb_failed (t);
+}