Commit 7d5421b6 authored by Marcin Spiewak's avatar Marcin Spiewak Committed by Tomasz Zawadzki
Browse files

test/cuse: active namespaces were tested incorrectly



A number of corrections and improvements in CUSE tests:
- spdk_nvme_ctrlr_is_active_ns and spdk_nvme_ctrlr_get_first_active_ns
  return 0 if number of active namespaces (g_active_num_ns) is 0.
  In this case we shall not report any active namespaces through
  these functions.
- increased loop count in verify_files() which wil increase wait time
  for busy systems, for which 100 ms could not be enough.
- added more test cases for nvme_cuse_update(), to test
  shrinking/expanding namespace id range.

Suggested-by: default avatarJim Harris <jim.harris@samsung.com>

Fixes #3377

Change-Id: I8fc729f079745e1f573ab4fd692fc7f5a22ef7bf
Signed-off-by: default avatarMarcin Spiewak <marcin.spiewak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23450


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 344c6525
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -28,13 +28,20 @@ static uint32_t g_active_nsid_min = 1;
bool
spdk_nvme_ctrlr_is_active_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid)
{
	return nsid >= g_active_nsid_min && nsid < g_active_num_ns + g_active_nsid_min;
	if (g_active_num_ns == 0) {
		return false;
	}
	return nsid && nsid >= g_active_nsid_min && nsid < g_active_num_ns + g_active_nsid_min;
}

uint32_t
spdk_nvme_ctrlr_get_first_active_ns(struct spdk_nvme_ctrlr *ctrlr)
{
	if (g_active_num_ns > 0) {
		return g_active_nsid_min;
	} else {
		return 0;
	}
}

uint32_t
@@ -89,7 +96,7 @@ wait_for_file(char *filename, bool exists)
{
	int i;

	for (i = 0; i < 1000; i++) {
	for (i = 0; i < 10000; i++) {
		if ((access(filename, F_OK) != -1) ^ (!exists)) {
			return true;
		}
@@ -176,6 +183,21 @@ test_cuse_update(void)
	nvme_cuse_update(&ctrlr);
	verify_devices(&ctrlr);

	g_active_num_ns = 10;
	g_active_nsid_min = 10;
	nvme_cuse_update(&ctrlr);
	verify_devices(&ctrlr);

	g_active_num_ns = 3;
	g_active_nsid_min = 13;
	nvme_cuse_update(&ctrlr);
	verify_devices(&ctrlr);

	g_active_num_ns = 10;
	g_active_nsid_min = 10;
	nvme_cuse_update(&ctrlr);
	verify_devices(&ctrlr);

	nvme_cuse_stop(&ctrlr);
}