mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
This checks the correctness of data returned by flash read host command. BUG=chrome-os-partner:19236 TEST=Pass all tests. BRANCH=None Change-Id: I3b97addb9b14922e9f33a71b865000ae9a8d40a8 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60963 Reviewed-by: Randall Spangler <rspangler@chromium.org>
99 lines
1.7 KiB
C
99 lines
1.7 KiB
C
/* 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 <signal.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "console.h"
|
|
#include "host_command.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) { }
|
|
|
|
#ifdef TEST_COVERAGE
|
|
extern void __gcov_flush(void);
|
|
|
|
void test_end_hook(int sig)
|
|
{
|
|
__gcov_flush();
|
|
exit(0);
|
|
}
|
|
|
|
void register_test_end_hook(void)
|
|
{
|
|
signal(SIGTERM, test_end_hook);
|
|
}
|
|
#else
|
|
void register_test_end_hook(void)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
void test_reset(void)
|
|
{
|
|
__test_error_count = 0;
|
|
}
|
|
|
|
void test_pass(void)
|
|
{
|
|
ccprintf("Pass!\n");
|
|
}
|
|
|
|
void test_fail(void)
|
|
{
|
|
ccprintf("Fail!\n");
|
|
}
|
|
|
|
void test_print_result(void)
|
|
{
|
|
if (__test_error_count)
|
|
ccprintf("Fail! (%d tests)\n", __test_error_count);
|
|
else
|
|
ccprintf("Pass!\n");
|
|
}
|
|
|
|
int test_get_error_count(void)
|
|
{
|
|
return __test_error_count;
|
|
}
|
|
|
|
#ifdef HAS_TASK_HOSTCMD
|
|
int test_send_host_command(int command, int version, const void *params,
|
|
int params_size, void *resp, int resp_size)
|
|
{
|
|
struct host_cmd_handler_args args;
|
|
int rv;
|
|
|
|
args.version = version;
|
|
args.command = command;
|
|
args.params = params;
|
|
args.params_size = params_size;
|
|
args.response = resp;
|
|
args.response_max = resp_size;
|
|
args.response_size = 0;
|
|
|
|
rv = host_command_process(&args);
|
|
|
|
if (args.response != resp)
|
|
memcpy(resp, args.response, args.response_size);
|
|
|
|
return rv;
|
|
}
|
|
#endif /* TASK_HAS_HOSTCMD */
|
|
|
|
static int command_run_test(int argc, char **argv)
|
|
{
|
|
run_test();
|
|
return EC_SUCCESS;
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(runtest, command_run_test,
|
|
NULL, NULL, NULL);
|