summaryrefslogtreecommitdiff
path: root/common/test_util.c
blob: 8594f3468e6b0cd011e167881d18924fa2c84aa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);