1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

tests: Add tests to cover unhandled programmer params paths

Unhandled programmer params are considered as an error for
initialisation procedure, adding tests to run those scenarios.

BUG=b:181803212
TEST=ninja test

Change-Id: Ia64f6362f46a029e168bfdb3bdb903328fd1f9c7
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67199
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Anastasia Klimchuk 2022-08-30 12:52:50 +10:00
parent 5fbe87ce50
commit 33af2e695d
3 changed files with 64 additions and 0 deletions

View File

@ -55,8 +55,66 @@ void dummy_probe_variable_size_test_success(void **state)
run_probe_lifecycle(state, &dummy_io, &programmer_dummy, "size=8388608,emulate=VARIABLE_SIZE", "Opaque flash chip");
}
void dummy_init_fails_unhandled_param_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
/*
* Programmer init should fail due to `dummy_init` failure caused by
* invalid value of `emulate` param. There is unhandled param left
* at the end of param string.
*/
run_init_error_path(state, &dummy_io, &programmer_dummy, "bus=spi,emulate=INVALID,unhandled=value", 1);
}
void dummy_init_success_invalid_param_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
/*
* Programmer init should fail despite of the fact that `dummy_init`
* is successful, due to invalid param at the end of param string.
*/
run_init_error_path(state, &dummy_io, &programmer_dummy,
"bus=spi,emulate=W25Q128FV,invalid=value", ERROR_FATAL);
}
void dummy_init_success_unhandled_param_test_success(void **state)
{
struct io_mock_fallback_open_state dummy_fallback_open_state = {
.noc = 0,
.paths = { NULL },
};
const struct io_mock dummy_io = {
.fallback_open_state = &dummy_fallback_open_state,
};
/*
* Programmer init should fail despite of the fact that `dummy_init`
* is successful, due to unhandled param at the end of param string.
* Unhandled param `voltage` is not used for dummyflasher.
*/
run_init_error_path(state, &dummy_io, &programmer_dummy,
"bus=spi,emulate=W25Q128FV,voltage=3.5V", ERROR_FATAL);
}
#else
SKIP_TEST(dummy_basic_lifecycle_test_success)
SKIP_TEST(dummy_probe_lifecycle_test_success)
SKIP_TEST(dummy_probe_variable_size_test_success)
SKIP_TEST(dummy_init_fails_unhandled_param_test_success)
SKIP_TEST(dummy_init_success_invalid_param_test_success)
SKIP_TEST(dummy_init_success_unhandled_param_test_success)
#endif /* CONFIG_DUMMY */

View File

@ -410,6 +410,9 @@ int main(int argc, char *argv[])
cmocka_unit_test(dummy_basic_lifecycle_test_success),
cmocka_unit_test(dummy_probe_lifecycle_test_success),
cmocka_unit_test(dummy_probe_variable_size_test_success),
cmocka_unit_test(dummy_init_fails_unhandled_param_test_success),
cmocka_unit_test(dummy_init_success_invalid_param_test_success),
cmocka_unit_test(dummy_init_success_unhandled_param_test_success),
cmocka_unit_test(nicrealtek_basic_lifecycle_test_success),
cmocka_unit_test(raiden_debug_basic_lifecycle_test_success),
cmocka_unit_test(dediprog_basic_lifecycle_test_success),

View File

@ -45,6 +45,9 @@ void probe_spi_st95_test_success(void **state); /* spi95.c */
void dummy_basic_lifecycle_test_success(void **state);
void dummy_probe_lifecycle_test_success(void **state);
void dummy_probe_variable_size_test_success(void **state);
void dummy_init_fails_unhandled_param_test_success(void **state);
void dummy_init_success_invalid_param_test_success(void **state);
void dummy_init_success_unhandled_param_test_success(void **state);
void nicrealtek_basic_lifecycle_test_success(void **state);
void raiden_debug_basic_lifecycle_test_success(void **state);
void dediprog_basic_lifecycle_test_success(void **state);