summaryrefslogtreecommitdiff
path: root/common/test_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/test_util.c')
-rw-r--r--common/test_util.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/common/test_util.c b/common/test_util.c
new file mode 100644
index 0000000000..8594f3468e
--- /dev/null
+++ b/common/test_util.c
@@ -0,0 +1,36 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Test utilities.
+ */
+
+#include "console.h"
+#include "test_util.h"
+#include "util.h"
+
+int __test_error_count;
+
+/* Weak reference function as an entry point for unit test */
+test_mockable void run_test(void) { }
+
+void test_reset(void)
+{
+ __test_error_count = 0;
+}
+
+void test_print_result(void)
+{
+ if (__test_error_count)
+ ccprintf("Fail! (%d tests)\n", __test_error_count);
+ else
+ ccprintf("Pass!\n");
+}
+
+static int command_run_test(int argc, char **argv)
+{
+ run_test();
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(runtest, command_run_test,
+ NULL, NULL, NULL);