test: Pass commandline arguments to run_test

run_test is called by the "runtest" console command. Console commands
can take arguments, so pass along the arguments to run_test to allow
parameters to be passed to run_test.

The following command was used for automatic replacement:

git grep --name-only 'void run_test(void)' |\
xargs sed -i 's#void run_test(void)#void run_test(int argc, char **argv)##'

BRANCH=none
BUG=b:155897971
TEST=make buildall -j
TEST=Build and flash flash_write_protect test
     > runtest 1

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Ib20b955d5ec6b98f525c94c24aadefd7a6a320a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2209418
Reviewed-by: Yicheng Li <yichengli@chromium.org>
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Tested-by: Yicheng Li <yichengli@chromium.org>
This commit is contained in:
Tom Hughes 2020-05-19 14:05:12 -07:00 committed by Commit Bot
parent 3590a14bcf
commit 99434726be
85 changed files with 86 additions and 86 deletions

View File

@ -29,7 +29,7 @@ struct test_util_tag {
int __test_error_count;
/* Weak reference function as an entry point for unit test */
test_mockable void run_test(void) { }
test_mockable void run_test(int argc, char **argv) { }
/* Default dummy test init */
test_mockable void test_init(void) { }
@ -199,7 +199,7 @@ DECLARE_HOOK(HOOK_SYSJUMP, preserve_state, HOOK_PRIO_DEFAULT);
static int command_run_test(int argc, char **argv)
{
run_test();
run_test(argc, argv);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(runtest, command_run_test,

View File

@ -91,7 +91,7 @@ void __idle(void *d)
void _run_test(void *d)
{
run_test();
run_test(0, NULL);
}
#define TASK(n, r, d, s) {r, d},

View File

@ -61,7 +61,7 @@ test_static int test_my_function(void)
```c
/* The test framework will call the function named "run_test" */
void run_test(void)
void run_test(int argc, char **argv)
{
/* Each unit test can be run using the RUN_TEST macro: */
RUN_TEST(test_my_function);

View File

@ -131,7 +131,7 @@ static int hostcmd_fill(const uint8_t *data, size_t size)
static pthread_cond_t done_cond;
static pthread_mutex_t lock;
void run_test(void)
void run_test(int argc, char **argv)
{
ccprints("Fuzzing task started");
wait_for_task_started();

View File

@ -161,7 +161,7 @@ enum tcpc_cc_voltage_status next_cc1, next_cc2;
const int MAX_MESSAGES = 8;
static struct message messages[MAX_MESSAGES];
void run_test(void)
void run_test(int argc, char **argv)
{
uint8_t port = PORT0;
int i;

View File

@ -139,7 +139,7 @@ void before_test(void);
void after_test(void);
/* Test entry point */
void run_test(void);
void run_test(int argc, char **argv);
/* Test entry point for fuzzing tests. */
int test_fuzz_one_input(const uint8_t *data, unsigned int size);

View File

@ -125,7 +125,7 @@ void before_test(void)
accel_cal_reset(&cal);
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -644,7 +644,7 @@ static void test_aes_speed(void)
ccprintf("AES duration %lld us\n", (long long)(t1.val - t0.val));
}
void run_test(void)
void run_test(int argc, char **argv)
{
watchdog_reload();

View File

@ -198,7 +198,7 @@ static int test_decode(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -90,7 +90,7 @@ static int test_param_failures(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_param_failures);

View File

@ -95,7 +95,7 @@ static int test_hostcommand(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -129,7 +129,7 @@ static int test_hostcommand(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -272,7 +272,7 @@ static void button_test_init(void)
button_state[i] = UNCHANGED;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -119,7 +119,7 @@ static int test_queue_overflow(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
queue = &overflow_queue.queue;

View File

@ -782,7 +782,7 @@ static int test_unknown_dualrole_capability(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -492,7 +492,7 @@ static int test_ramp_limit(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -55,7 +55,7 @@ static int test_GENMASK_ULL(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -273,7 +273,7 @@ static int test_output_channel(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -63,7 +63,7 @@ static int test_kat0(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -29,7 +29,7 @@ uint32_t log2(int32_t val)
return log2_mult * (val1 + val2)/2;
}
void run_test(void)
void run_test(int argc, char **argv)
{
const int loopcount = 512;

View File

@ -51,7 +51,7 @@ static int test_hook(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -105,7 +105,7 @@ static int test_fan(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_fan);

View File

@ -498,7 +498,7 @@ int task_test(void *data)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
msleep(30); /* Wait for TASK_ID_TEST to initialize */
task_wake(TASK_ID_TEST);

View File

@ -300,7 +300,7 @@ static int test_mat44_fp_solve(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -5,7 +5,7 @@
#include "test_util.h"
void run_test(void)
void run_test(int argc, char **argv)
{
/* No tests yet */
test_print_result();

View File

@ -614,7 +614,7 @@ test_static int test_command_read_match_secret_unreadable(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_hkdf_expand);
RUN_TEST(test_derive_encryption_key_failure_seed_not_set);

View File

@ -169,7 +169,7 @@ test_static int test_fp_set_sensor_mode(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_fp_enc_status_valid_flags);
RUN_TEST(test_fp_tpm_seed_not_set);

View File

@ -159,7 +159,7 @@ static int test_repeating_deferred(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -300,7 +300,7 @@ static int test_hostcmd_clears_unused_data(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
wait_for_task_started();
test_reset();

View File

@ -180,7 +180,7 @@ static int test_i2c_write(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -157,7 +157,7 @@ static int test_debounce_charge_done(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -71,7 +71,7 @@ static int interrupt_disable_test(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -24,7 +24,7 @@ static int test_blank(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -17,7 +17,7 @@ static int test_invalid_value(void)
return EC_ERROR_UNKNOWN;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -62,7 +62,7 @@ static int test_kasa_calculate(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -323,7 +323,7 @@ static int test_vivaldi_top_keys(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();
wait_for_task_started();

View File

@ -286,7 +286,7 @@ int fifo_underrun(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
ec_int_level = 1;
test_reset();

View File

@ -483,7 +483,7 @@ int test_task(void *data)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
msleep(30); /* Wait for TASK_ID_TEST to initialize */
task_wake(TASK_ID_TEST);

View File

@ -83,7 +83,7 @@ static int test_debounce(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -319,7 +319,7 @@ test_static int test_als_lightbar(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
/* Ensure tasks are started before running tests */
usleep(SECOND);

View File

@ -81,7 +81,7 @@ static int test_mag_cal_computes_bias(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -78,7 +78,7 @@ static int test_rotate(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -91,7 +91,7 @@ static int test_lid_angle_less180(void)
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -99,7 +99,7 @@ static int test_lid_angle_less180(void)
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -332,7 +332,7 @@ static int test_lid_angle(void)
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -353,7 +353,7 @@ void before_test(void)
motion_sense_fifo_reset();
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();
motion_sense_fifo_init();

View File

@ -176,7 +176,7 @@ test_static int test_mpu_get_rw_regions(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
enum ec_image cur_image = system_get_image_copy();

View File

@ -109,7 +109,7 @@ int mutex_main_task(void *unused)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
wait_for_task_started();
task_wake(TASK_ID_MTX1);

View File

@ -126,7 +126,7 @@ static int test_newton_fit_calculate(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -222,7 +222,7 @@ void before_test(void)
online_calibration_init();
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -59,7 +59,7 @@ int task_tick(void *data)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
wait_for_task_started();
task_wake(TASK_ID_TICK);

View File

@ -89,7 +89,7 @@ static int test_debounce(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -297,7 +297,7 @@ test_static int test_vsnprintf_combined(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -416,7 +416,7 @@ void before_test(void)
queue_init(&test_queue8);
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -116,7 +116,7 @@ test_static int test_lock_rollback(void)
return EC_ERROR_UNKNOWN;
}
void run_test(void)
void run_test(int argc, char **argv)
{
ccprintf("Running rollback test\n");
RUN_TEST(test_lock_rollback);

View File

@ -185,7 +185,7 @@ test_static int test_add_entropy(void)
return rv;
}
void run_test(void)
void run_test(int argc, char **argv)
{
ccprintf("Running rollback_entropy test\n");
RUN_TEST(test_add_entropy);

View File

@ -19,7 +19,7 @@
static uint32_t rsa_workbuf[3 * RSANUMBYTES/4];
void run_test(void)
void run_test(int argc, char **argv)
{
int good;

View File

@ -96,7 +96,7 @@ static int test_time_conversion(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_time_conversion);

View File

@ -713,7 +713,7 @@ static int test_low_battery_hostevents(void)
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_charge_state);
RUN_TEST(test_low_battery);

View File

@ -172,7 +172,7 @@ static int test_hmac(const uint8_t *key, int key_len,
return 1;
}
void run_test(void)
void run_test(int argc, char **argv)
{
ccprintf("Testing short message (8 bytes)\n");
if (!test_sha256(sha256_8_input, sizeof(sha256_8_input),

View File

@ -207,7 +207,7 @@ static int shmem_is_ok(int line)
*/
static uint32_t test_map;
void run_test(void)
void run_test(int argc, char **argv)
{
int index;
const int shmem_size = shared_mem_size();

View File

@ -39,7 +39,7 @@ static int test_static_if_unused_no_fail(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -24,7 +24,7 @@
/* This is intended to cause a compilation error. */
TEST_MACRO(CONFIG_FOO) __maybe_unused int foo;
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -123,7 +123,7 @@ static int test_resets(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -44,7 +44,7 @@ test_static int test_rtc_alarm(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_rtc_alarm);

View File

@ -128,7 +128,7 @@ static int test_adc(void)
}
#endif
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -92,7 +92,7 @@ static void fail_and_clean_up(void)
test_fail();
}
void run_test(void)
void run_test(int argc, char **argv)
{
uint32_t state = system_get_scratchpad();

View File

@ -642,7 +642,7 @@ static int test_thermistor_linear_interpolate(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_init_val);
RUN_TEST(test_sensors_can_be_read);

View File

@ -56,7 +56,7 @@ int timer_calib_task(void *data)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
task_wake(TASK_ID_TESTTMR);
}

View File

@ -68,7 +68,7 @@ int task_timer(void *seed)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
wait_for_task_started();
task_wake(TASK_ID_TMRD);

View File

@ -62,7 +62,7 @@ test_static int test_host_uptime_info_command_failure(void)
return EC_RES_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -66,7 +66,7 @@ int test_pd_get_cc_state(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
RUN_TEST(test_pd_get_cc_state);

View File

@ -900,7 +900,7 @@ static int test_sink(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();
init_ports();

View File

@ -422,7 +422,7 @@ static int test_command_pd_dualrole5(void)
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -92,7 +92,7 @@ void before_test(void)
pd_set_suspend(PORT0, 0);
}
void run_test(void)
void run_test(int argc, char **argv)
{
/* Let tasks settle down */
task_wait_event(MINUTE);

View File

@ -161,7 +161,7 @@ static int test_vbus_gpio_discharge(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -173,7 +173,7 @@ static int test_ppc_is_vbus_present(void)
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -1359,7 +1359,7 @@ void before_test(void)
cycle_through_state_machine(PORT0, 10, MSEC);
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -985,7 +985,7 @@ int test_task(void *u)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();
#if defined(TEST_USB_SM_FRAMEWORK_H3)

View File

@ -1498,7 +1498,7 @@ static int test_ctvpd_behavior_case6(void)
}
#endif
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -615,7 +615,7 @@ void before_test(void)
mock_tcpc.should_print_call = true;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -441,7 +441,7 @@ test_static int test_is_aligned(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -260,7 +260,7 @@ static int test_snprintf(void)
TEST_CHECK(strncmp(buffer, "1234", sizeof(buffer)));
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -131,7 +131,7 @@ static int test_vboot(void)
return EC_SUCCESS;
}
void run_test(void)
void run_test(int argc, char **argv)
{
test_reset();

View File

@ -180,7 +180,7 @@ static void test_x25519_speed(void)
ccprintf("X25519 duration %lld us\n", (long long)(t1.val - t0.val));
}
void run_test(void)
void run_test(int argc, char **argv)
{
watchdog_reload();
/* do not check speed, just as a benchmark */