test/bdevio: setup separate suites for each target
With this patch each target has separate suite, tests are ran just once for all setup suites. Suite init/fini functions were added that move current g_current_io_target ahead for next suite. Results what works for particular bdev are of more use rather than combination for all bdevs. This will come useful when we want to perform RPC for only select targets. In case of CUnit library error, application is stopped without returning number of failures. This is because at that point its numbers are not reliable. Change-Id: Ie82b6e33374841bf829da09a16a401fddd1fd81c Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455199 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
cdd089a8c5
commit
6a8d00949b
@ -70,6 +70,7 @@ struct bdevio_request {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct io_target *g_io_targets = NULL;
|
struct io_target *g_io_targets = NULL;
|
||||||
|
struct io_target *g_current_io_target = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
execute_spdk_function(spdk_event_fn fn, void *arg1, void *arg2)
|
execute_spdk_function(spdk_event_fn fn, void *arg1, void *arg2)
|
||||||
@ -356,48 +357,44 @@ blockdev_write_read(uint32_t data_length, uint32_t iov_len, int pattern, uint64_
|
|||||||
char *rx_buf = NULL;
|
char *rx_buf = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
target = g_io_targets;
|
target = g_current_io_target;
|
||||||
while (target != NULL) {
|
|
||||||
if (data_length < spdk_bdev_get_block_size(target->bdev) ||
|
|
||||||
data_length / spdk_bdev_get_block_size(target->bdev) > spdk_bdev_get_num_blocks(target->bdev)) {
|
|
||||||
target = target->next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!write_zeroes) {
|
if (data_length < spdk_bdev_get_block_size(target->bdev) ||
|
||||||
initialize_buffer(&tx_buf, pattern, data_length);
|
data_length / spdk_bdev_get_block_size(target->bdev) > spdk_bdev_get_num_blocks(target->bdev)) {
|
||||||
initialize_buffer(&rx_buf, 0, data_length);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
blockdev_write(target, tx_buf, offset, data_length, iov_len);
|
if (!write_zeroes) {
|
||||||
} else {
|
initialize_buffer(&tx_buf, pattern, data_length);
|
||||||
initialize_buffer(&tx_buf, 0, data_length);
|
initialize_buffer(&rx_buf, 0, data_length);
|
||||||
initialize_buffer(&rx_buf, pattern, data_length);
|
|
||||||
|
|
||||||
blockdev_write_zeroes(target, tx_buf, offset, data_length);
|
blockdev_write(target, tx_buf, offset, data_length, iov_len);
|
||||||
}
|
} else {
|
||||||
|
initialize_buffer(&tx_buf, 0, data_length);
|
||||||
|
initialize_buffer(&rx_buf, pattern, data_length);
|
||||||
|
|
||||||
|
blockdev_write_zeroes(target, tx_buf, offset, data_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (expected_rc == 0) {
|
if (expected_rc == 0) {
|
||||||
CU_ASSERT_EQUAL(g_completion_success, true);
|
CU_ASSERT_EQUAL(g_completion_success, true);
|
||||||
} else {
|
} else {
|
||||||
CU_ASSERT_EQUAL(g_completion_success, false);
|
CU_ASSERT_EQUAL(g_completion_success, false);
|
||||||
}
|
}
|
||||||
blockdev_read(target, rx_buf, offset, data_length, iov_len);
|
blockdev_read(target, rx_buf, offset, data_length, iov_len);
|
||||||
|
|
||||||
if (expected_rc == 0) {
|
if (expected_rc == 0) {
|
||||||
CU_ASSERT_EQUAL(g_completion_success, true);
|
CU_ASSERT_EQUAL(g_completion_success, true);
|
||||||
} else {
|
} else {
|
||||||
CU_ASSERT_EQUAL(g_completion_success, false);
|
CU_ASSERT_EQUAL(g_completion_success, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_completion_success) {
|
if (g_completion_success) {
|
||||||
rc = blockdev_write_read_data_match(rx_buf, tx_buf, data_length);
|
rc = blockdev_write_read_data_match(rx_buf, tx_buf, data_length);
|
||||||
/* Assert the write by comparing it with values read
|
/* Assert the write by comparing it with values read
|
||||||
* from each blockdev */
|
* from each blockdev */
|
||||||
CU_ASSERT_EQUAL(rc, 0);
|
CU_ASSERT_EQUAL(rc, 0);
|
||||||
}
|
|
||||||
|
|
||||||
target = target->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,33 +683,29 @@ blockdev_write_read_offset_plus_nbytes_equals_bdev_size(void)
|
|||||||
uint32_t block_size;
|
uint32_t block_size;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
target = g_io_targets;
|
target = g_current_io_target;
|
||||||
while (target != NULL) {
|
bdev = target->bdev;
|
||||||
bdev = target->bdev;
|
|
||||||
|
|
||||||
block_size = spdk_bdev_get_block_size(bdev);
|
block_size = spdk_bdev_get_block_size(bdev);
|
||||||
|
|
||||||
/* The start offset has been set to a marginal value
|
/* The start offset has been set to a marginal value
|
||||||
* such that offset + nbytes == Total size of
|
* such that offset + nbytes == Total size of
|
||||||
* blockdev. */
|
* blockdev. */
|
||||||
offset = ((spdk_bdev_get_num_blocks(bdev) - 1) * block_size);
|
offset = ((spdk_bdev_get_num_blocks(bdev) - 1) * block_size);
|
||||||
|
|
||||||
initialize_buffer(&tx_buf, 0xA3, block_size);
|
initialize_buffer(&tx_buf, 0xA3, block_size);
|
||||||
initialize_buffer(&rx_buf, 0, block_size);
|
initialize_buffer(&rx_buf, 0, block_size);
|
||||||
|
|
||||||
blockdev_write(target, tx_buf, offset, block_size, 0);
|
blockdev_write(target, tx_buf, offset, block_size, 0);
|
||||||
CU_ASSERT_EQUAL(g_completion_success, true);
|
CU_ASSERT_EQUAL(g_completion_success, true);
|
||||||
|
|
||||||
blockdev_read(target, rx_buf, offset, block_size, 0);
|
blockdev_read(target, rx_buf, offset, block_size, 0);
|
||||||
CU_ASSERT_EQUAL(g_completion_success, true);
|
CU_ASSERT_EQUAL(g_completion_success, true);
|
||||||
|
|
||||||
rc = blockdev_write_read_data_match(rx_buf, tx_buf, block_size);
|
rc = blockdev_write_read_data_match(rx_buf, tx_buf, block_size);
|
||||||
/* Assert the write by comparing it with values read
|
/* Assert the write by comparing it with values read
|
||||||
* from each blockdev */
|
* from each blockdev */
|
||||||
CU_ASSERT_EQUAL(rc, 0);
|
CU_ASSERT_EQUAL(rc, 0);
|
||||||
|
|
||||||
target = target->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -731,26 +724,22 @@ blockdev_write_read_offset_plus_nbytes_gt_bdev_size(void)
|
|||||||
CU_ASSERT_TRUE(data_length < BUFFER_SIZE);
|
CU_ASSERT_TRUE(data_length < BUFFER_SIZE);
|
||||||
pattern = 0xA3;
|
pattern = 0xA3;
|
||||||
|
|
||||||
target = g_io_targets;
|
target = g_current_io_target;
|
||||||
while (target != NULL) {
|
bdev = target->bdev;
|
||||||
bdev = target->bdev;
|
|
||||||
|
|
||||||
/* The start offset has been set to a valid value
|
/* The start offset has been set to a valid value
|
||||||
* but offset + nbytes is greater than the Total size
|
* but offset + nbytes is greater than the Total size
|
||||||
* of the blockdev. The test should fail. */
|
* of the blockdev. The test should fail. */
|
||||||
offset = ((spdk_bdev_get_num_blocks(bdev) * spdk_bdev_get_block_size(bdev)) - 1024);
|
offset = ((spdk_bdev_get_num_blocks(bdev) * spdk_bdev_get_block_size(bdev)) - 1024);
|
||||||
|
|
||||||
initialize_buffer(&tx_buf, pattern, data_length);
|
initialize_buffer(&tx_buf, pattern, data_length);
|
||||||
initialize_buffer(&rx_buf, 0, data_length);
|
initialize_buffer(&rx_buf, 0, data_length);
|
||||||
|
|
||||||
blockdev_write(target, tx_buf, offset, data_length, 0);
|
blockdev_write(target, tx_buf, offset, data_length, 0);
|
||||||
CU_ASSERT_EQUAL(g_completion_success, false);
|
CU_ASSERT_EQUAL(g_completion_success, false);
|
||||||
|
|
||||||
blockdev_read(target, rx_buf, offset, data_length, 0);
|
blockdev_read(target, rx_buf, offset, data_length, 0);
|
||||||
CU_ASSERT_EQUAL(g_completion_success, false);
|
CU_ASSERT_EQUAL(g_completion_success, false);
|
||||||
|
|
||||||
target = target->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -837,17 +826,13 @@ blockdev_test_reset(void)
|
|||||||
{
|
{
|
||||||
struct io_target *target;
|
struct io_target *target;
|
||||||
|
|
||||||
target = g_io_targets;
|
target = g_current_io_target;
|
||||||
while (target != NULL) {
|
blockdev_reset(target);
|
||||||
blockdev_reset(target);
|
/* Workaround: NVMe-oF target doesn't support reset yet - so for now
|
||||||
/* Workaround: NVMe-oF target doesn't support reset yet - so for now
|
* don't fail the test if it's an NVMe bdev.
|
||||||
* don't fail the test if it's an NVMe bdev.
|
*/
|
||||||
*/
|
if (!spdk_bdev_io_type_supported(target->bdev, SPDK_BDEV_IO_TYPE_NVME_IO)) {
|
||||||
if (!spdk_bdev_io_type_supported(target->bdev, SPDK_BDEV_IO_TYPE_NVME_IO)) {
|
CU_ASSERT_EQUAL(g_completion_success, true);
|
||||||
CU_ASSERT_EQUAL(g_completion_success, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
target = target->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,11 +918,8 @@ blockdev_test_nvme_passthru_rw(void)
|
|||||||
{
|
{
|
||||||
struct io_target *target;
|
struct io_target *target;
|
||||||
|
|
||||||
target = g_io_targets;
|
target = g_current_io_target;
|
||||||
while (target != NULL) {
|
blockdev_nvme_passthru_rw(target);
|
||||||
blockdev_nvme_passthru_rw(target);
|
|
||||||
target = target->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -966,11 +948,8 @@ blockdev_test_nvme_passthru_vendor_specific(void)
|
|||||||
{
|
{
|
||||||
struct io_target *target;
|
struct io_target *target;
|
||||||
|
|
||||||
target = g_io_targets;
|
target = g_current_io_target;
|
||||||
while (target != NULL) {
|
blockdev_nvme_passthru_vendor_specific(target);
|
||||||
blockdev_nvme_passthru_vendor_specific(target);
|
|
||||||
target = target->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -992,22 +971,37 @@ stop_init_thread(unsigned num_failures)
|
|||||||
spdk_event_call(event);
|
spdk_event_call(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
__run_ut_thread(void *arg1, void *arg2)
|
suite_init(void)
|
||||||
{
|
{
|
||||||
CU_pSuite suite = NULL;
|
if (g_current_io_target == NULL) {
|
||||||
unsigned num_failures;
|
g_current_io_target = g_io_targets;
|
||||||
|
|
||||||
if (CU_initialize_registry() != CUE_SUCCESS) {
|
|
||||||
stop_init_thread(CU_get_error());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
suite = CU_add_suite("components_suite", NULL, NULL);
|
static int
|
||||||
|
suite_fini(void)
|
||||||
|
{
|
||||||
|
g_current_io_target = g_current_io_target->next;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SUITE_NAME_MAX 64
|
||||||
|
|
||||||
|
static int
|
||||||
|
__setup_ut_on_single_target(struct io_target *target)
|
||||||
|
{
|
||||||
|
unsigned rc = 0;
|
||||||
|
CU_pSuite suite = NULL;
|
||||||
|
char name[SUITE_NAME_MAX];
|
||||||
|
|
||||||
|
snprintf(name, sizeof(name), "bdevio tests on: %s", spdk_bdev_get_name(target->bdev));
|
||||||
|
suite = CU_add_suite(name, suite_init, suite_fini);
|
||||||
if (suite == NULL) {
|
if (suite == NULL) {
|
||||||
CU_cleanup_registry();
|
CU_cleanup_registry();
|
||||||
stop_init_thread(CU_get_error());
|
rc = CU_get_error();
|
||||||
return;
|
return -rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -1047,14 +1041,39 @@ __run_ut_thread(void *arg1, void *arg2)
|
|||||||
blockdev_test_nvme_passthru_vendor_specific) == NULL
|
blockdev_test_nvme_passthru_vendor_specific) == NULL
|
||||||
) {
|
) {
|
||||||
CU_cleanup_registry();
|
CU_cleanup_registry();
|
||||||
stop_init_thread(CU_get_error());
|
rc = CU_get_error();
|
||||||
return;
|
return -rc;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
__run_ut_thread(void *arg1, void *arg2)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
struct io_target *target;
|
||||||
|
unsigned num_failures;
|
||||||
|
|
||||||
|
if (CU_initialize_registry() != CUE_SUCCESS) {
|
||||||
|
/* CUnit error, probably won't recover */
|
||||||
|
rc = CU_get_error();
|
||||||
|
stop_init_thread(-rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target = g_io_targets;
|
||||||
|
while (target != NULL) {
|
||||||
|
rc = __setup_ut_on_single_target(target);
|
||||||
|
if (rc < 0) {
|
||||||
|
/* CUnit error, probably won't recover */
|
||||||
|
stop_init_thread(-rc);
|
||||||
|
}
|
||||||
|
target = target->next;
|
||||||
|
}
|
||||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||||
CU_basic_run_tests();
|
CU_basic_run_tests();
|
||||||
num_failures = CU_get_number_of_failures();
|
num_failures = CU_get_number_of_failures();
|
||||||
CU_cleanup_registry();
|
CU_cleanup_registry();
|
||||||
|
|
||||||
stop_init_thread(num_failures);
|
stop_init_thread(num_failures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user