Commit 219fbc90 authored by Kalwas, Jacek's avatar Kalwas, Jacek Committed by Tomasz Zawadzki
Browse files

examples/nvme/hello_world: add data check



Without data check application exits with 0 code even when running on
top of null bdev.

Additionally removed \n char from the write data to simplify c-string
meant for comparison.

Change-Id: Ie9ad11f1b7bdbaab80e28ee9b77ce81cacc46b7e
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20238


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent db331d80
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
#include "spdk/string.h"
#include "spdk/log.h"

#define DATA_BUFFER_STRING "Hello world!"

struct ctrlr_entry {
	struct spdk_nvme_ctrlr		*ctrlr;
	TAILQ_ENTRY(ctrlr_entry)	link;
@@ -80,13 +82,18 @@ read_complete(void *arg, const struct spdk_nvme_cpl *completion)
		exit(1);
	}

	if (strcmp(sequence->buf, DATA_BUFFER_STRING)) {
		fprintf(stderr, "Read data doesn't match write data\n");
		exit(1);
	}

	/*
	 * The read I/O has completed.  Print the contents of the
	 *  buffer, free the buffer, then mark the sequence as
	 *  completed.  This will trigger the hello_world() function
	 *  to exit its polling loop.
	 */
	printf("%s", sequence->buf);
	printf("%s\n", sequence->buf);
	spdk_free(sequence->buf);
}

@@ -227,11 +234,11 @@ hello_world(void)
		}

		/*
		 * Print "Hello world!" to sequence.buf.  We will write this data to LBA
		 * Print DATA_BUFFER_STRING to sequence.buf. We will write this data to LBA
		 *  0 on the namespace, and then later read it back into a separate buffer
		 *  to demonstrate the full I/O path.
		 */
		snprintf(sequence.buf, 0x1000, "%s", "Hello world!\n");
		snprintf(sequence.buf, 0x1000, "%s", DATA_BUFFER_STRING);

		/*
		 * Write the data buffer to LBA 0 of this namespace.  "write_complete" and