1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-03 06:53:18 +02:00

libflashrom: Deprecate probing v1 API

flashrom_flash_probe marked as deprecated and existing tests are
updated to use probing v2 API

Change-Id: I88f78ac0c93ce99a555b42f87aa0a695089e0b3f
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/88202
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
This commit is contained in:
Anastasia Klimchuk
2025-06-26 12:58:34 +10:00
parent f1f0dd6ab3
commit b41fc17099
9 changed files with 33 additions and 41 deletions

View File

@ -129,7 +129,9 @@ void ch341a_spi_probe_lifecycle_test_success(void **state)
.fallback_open_state = &ch341a_spi_fallback_open_state,
};
run_probe_lifecycle(state, &ch341a_spi_io, &programmer_ch341a_spi, "", "W25Q128.V");
const char *expected_matched_names[1] = {"W25Q128.V"};
run_probe_v2_lifecycle(state, &ch341a_spi_io, &programmer_ch341a_spi, "", "W25Q128.V",
expected_matched_names, 1);
}
#else

View File

@ -39,7 +39,9 @@ void dummy_probe_lifecycle_test_success(void **state)
.fallback_open_state = &dummy_fallback_open_state,
};
run_probe_lifecycle(state, &dummy_io, &programmer_dummy, "bus=spi,emulate=W25Q128FV", "W25Q128.V");
const char *expected_matched_names[1] = {"W25Q128.V"};
run_probe_v2_lifecycle(state, &dummy_io, &programmer_dummy, "bus=spi,emulate=W25Q128FV", "W25Q128.V",
expected_matched_names, 1);
}
void dummy_probe_v2_one_match_for_W25Q128FV(void **state)
@ -103,7 +105,9 @@ void dummy_probe_variable_size_test_success(void **state)
.fallback_open_state = &dummy_fallback_open_state,
};
run_probe_lifecycle(state, &dummy_io, &programmer_dummy, "size=8388608,emulate=VARIABLE_SIZE", "Opaque flash chip");
const char *expected_matched_names[1] = {"Opaque flash chip"};
run_probe_v2_lifecycle(state, &dummy_io, &programmer_dummy, "size=8388608,emulate=VARIABLE_SIZE", "Opaque flash chip",
expected_matched_names, 1);
}
void dummy_init_fails_unhandled_param_test_success(void **state)

View File

@ -15,25 +15,6 @@
#include "lifecycle.h"
static void probe_chip(const struct programmer_entry *prog,
struct flashrom_programmer *flashprog,
const char *const chip_name,
const char **expected_matched_names, /* unused in probe v1 */
unsigned int expected_matched_count /* unused in probe v1 */)
{
struct flashrom_flashctx *flashctx;
printf("Testing flashrom_flash_probe for programmer=%s, chip=%s ... \n", prog->name, chip_name);
assert_int_equal(0, flashrom_flash_probe(&flashctx, flashprog, chip_name));
if (chip_name)
assert_int_equal(0, strcmp(chip_name, flashctx->chip->name));
printf("... flashrom_flash_probe for programmer=%s successful\n", prog->name);
flashrom_flash_release(flashctx); /* cleanup */
}
static void probe_chip_v2(const struct programmer_entry *prog,
struct flashrom_programmer *flashprog,
const char *const chip_name,
@ -103,16 +84,6 @@ void run_basic_lifecycle(void **state, const struct io_mock *io,
NULL /* action */);
}
void run_probe_lifecycle(void **state, const struct io_mock *io,
const struct programmer_entry *prog, const char *param, const char *const chip_name)
{
/* Each probe lifecycle should run independently, without cache. */
clear_spi_id_cache();
run_lifecycle(state, io, prog, param, chip_name,
NULL /* expected_matched_names, */, 0 /* expected_matched_count, */,
&probe_chip);
}
void run_probe_v2_lifecycle(void **state, const struct io_mock *io,
const struct programmer_entry *prog, const char *param,
const char *const chip_name,

View File

@ -31,9 +31,6 @@
void run_basic_lifecycle(void **state, const struct io_mock *io,
const struct programmer_entry *prog, const char *param);
void run_probe_lifecycle(void **state, const struct io_mock *io,
const struct programmer_entry *prog, const char *param, const char *const chip_name);
void run_probe_v2_lifecycle(void **state, const struct io_mock *io,
const struct programmer_entry *prog, const char *param,
const char *const chip_name,

View File

@ -89,7 +89,9 @@ void linux_mtd_probe_lifecycle_test_success(void **state)
.fallback_open_state = &linux_mtd_fallback_open_state,
};
run_probe_lifecycle(state, &linux_mtd_io, &programmer_linux_mtd, "", "Opaque flash chip");
const char *expected_matched_names[1] = {"Opaque flash chip"};
run_probe_v2_lifecycle(state, &linux_mtd_io, &programmer_linux_mtd, "", "Opaque flash chip",
expected_matched_names, 1);
}
#else
SKIP_TEST(linux_mtd_probe_lifecycle_test_success)

View File

@ -65,7 +65,9 @@ void linux_spi_probe_lifecycle_test_success(void **state)
.fallback_open_state = &linux_spi_fallback_open_state,
};
run_probe_lifecycle(state, &linux_spi_io, &programmer_linux_spi, "dev=/dev/null", "W25Q128.V");
const char *expected_matched_names[1] = {"W25Q128.V"};
run_probe_v2_lifecycle(state, &linux_spi_io, &programmer_linux_spi, "dev=/dev/null", "W25Q128.V",
expected_matched_names, 1);
}
#else
SKIP_TEST(linux_spi_probe_lifecycle_test_success)

View File

@ -212,7 +212,9 @@ void spidriver_probe_lifecycle_test_success(void **state)
.fallback_open_state = &spidriver_fallback_open_state,
};
run_probe_lifecycle(state, &spidriver_io, &programmer_spidriver, "dev=/dev/null", "W25Q128.V");
const char *expected_matched_names[1] = {"W25Q128.V"};
run_probe_v2_lifecycle(state, &spidriver_io, &programmer_spidriver, "dev=/dev/null", "W25Q128.V",
expected_matched_names, 1);
}
#else
SKIP_TEST(spidriver_probe_lifecycle_test_success)