The I/O splitting tests don't pass the I/Os through the normal
completion path, so we need to free the children ourselves.
Fixes all Valgrind warnings for nvme_ns_cmd_ut.
Change-Id: Iaf7d9f7f4cab71428a0123ee30d0f6042001e423
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
nvme_ut is testing multi-threaded operations, and Valgrind's thread
behavior is different than running the program natively. Under
Valgrind, the unit test essentially hangs waiting for the global
variable to be updated.
Change-Id: Id3665002c16ac3e695c50325375305a76f72cee4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
nvme_alloc_request() does not zero out the request (this is
intentional, since the real implementation uses a mempool where requests
get reused). Add nvme_allocate_request() wrapper that initializes the
request correctly. This fixes all uses of uninitialized memory caught
by Valgrind in nvme_qpair_ut. This test was also failing in practice on
FreeBSD due to non-zero buffers returned from malloc().
Change-Id: I2d6ea29289bd4887aaa9120fba6bce10088e6917
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
The default version of nvme_impl.h was cleaned up to release the pthread
mutex attr on failure cases, but the unit test version did not receive
this update.
Change-Id: I899b7dc809393dc8e6fd24ed98e1d0a61ecf1c95
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Check the LBA and block count fields of the I/Os generated by the
splitting function to ensure they were split correctly.
Change-Id: I84abb1ac462fb7423d51a1be384fd1be68dfecae
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Instead of repeating the check for conditions that must be fulfilled to
continue the tests, just use CU_ASSERT_FATAL, which will abort the test
and return.
Change-Id: If617b286a587d9efb1ce57b90061634ed5bc7ae8
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
The current implementation of nvme_assert in the unit test nvme_impl.h
just prints the message and continues.
We should not be triggering assert conditions, even in the unit test
code, so make nvme_assert actually call assert(). This lets us catch
mistakes in the unit tests more easily.
Also fix the two unit tests that currently trigger an assert:
- The I/O splitting test in nvme_ns_cmd_ut was passing an invalid
combination of NULL payload with non-zero lba_count.
- The ctrlr_cmd test was passing an invalid number of entries to
nvme_ctrlr_cmd_get_error_page(). This case should probably not be an
assert but rather an error code. However, the function does not
return a status code currently, so it is not trivial to make that
change. For now, just drop the asserting test case and the code added
to the test to work around it.
While we're here, fix the macros in the unit test nvme_impl.h so they
are usable in single-line conditionals without braces - that is the
whole point of the do { ... } while (0) pattern, so there should be no
trailing semicolon.
Change-Id: Iad503c5c5d19a426d48c80d9a7d6da12ff2c982a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Cover more functions and conditions for nvme_ctrlr_cmd.
Remove unnecessary lines in nvme_ctrlr_ut.
Update nvme_qpair_ut.
Remove unnecessary header file.
Change-Id: I8c5a75573b26210ca57711b366acd55ab96614c0
Signed-off-by: Liang Yan <liangx.yan@intel.com>
Move dependency includes into a new spdk.deps.mk file,
then include it at the end of Makefiles that build
source files.
Also add a test to autobuild.sh to confirm that
binaries are regenerated if we make after touching a
header file.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: If6a1905706a840f92cbdf3ace7fbdb27fe2de213
Initialize the full nvme_namespace structure in prepare_for_test() so
that e.g. ns->id is not used uninitialized.
Also check for request allocation failure - if the request is NULL, we
can't run the rest of the tests that dereference request without
crashing.
Change-Id: I3010ca3e81f153a4d0201498a14a963c2b9e960d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This helps enable FreeBSD, where pciaccess pci_device_has_kernel_driver()
is not functional. The function will return 0 if there is no driver
attached, or the Linux uio or FreeBSD nic_uio driver is attached. It will
return 1 otherwise.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I0921e61c9040b1e0411b5dc40b36fc7f2721c8c5
GCC generates a series of 64-bit MOV instructions for the memcpy() into
the submission queue. We can do better with 128-bit SSE2 instructions.
DPDK already has a memcpy implementation that is optimized for small
inline copies, so use it instead of memcpy.
Change-Id: I5f09259b4d5cb089ace4a8ea6d2078c03fee84f3
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Use {} consistently rather than {0} when initializing structs as part of
definitions.
Fixes warnings about initializing subobjects when compiling with clang.
Change-Id: I507fdf47e7c41455033d6c3d5edc563ec4667dee
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
nvme_ctrlr_cmd_set_async_event_config() is called from within nvme_ctrlr
but was never stubbed out in its unit test.
Change-Id: I44002540e74ee010f21d0cf2d089d1dc51217a2f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This prevents warnings about unused phys_addr variable in the unit
tests.
Change-Id: I022483735ba92eb112e541e6de37dc9a8c5d2b8e
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Replace unnecessary allocation with a stack variable.
Clears up a potential NULL pointer dereference indicated by scan-build.
Change-Id: I81a7591729b0f1630bab9ce378716bd2369d6b85
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
act_tr is supposed to be allocated with the system allocator
(malloc/calloc) rather than nvme_malloc.
Additionally, the size was incorrect - act_tr is an array of pointers,
not a single struct nvme_tracker.
Change-Id: I2c66b4891d11d0a8a32e3740c27fcfb42b1db2d7
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
nvme_dump_command is totally unused aside from the unit test.
nvme_dump_completion was used in qpair, but it can be replaced with the
equivalent nvme_qpair_print_completion.
Also added the missing nvme_completion fields to nvme_qpair_print_completion
that had been printed by nvme_dump_command.
Change-Id: Ia5ee66f3553df06febe8f465d42e49a84c555dd2
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Make nvme_pcicfg_read32 set the referenced variable and make
nvme_pcicfg_write32 appear to read it so that the compiler doesn't warn
about unused/uninitialized data.
Change-Id: I4f06c0cca2fc11a8c6c5a60543c1c50a2f6a412d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Replace a bunch of allocations with stack variables.
Remove many unnecessary variables.
The actual tests are unchanged (and still not testing very much), but
this removes a lot of cruft that should make it easier to see what the
tests are actually doing.
Change-Id: I2c4810391cbf4d8edde88d5bc1c0dddcba3ae175
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>