From 88beac7045ad08e08533e87bcf26c3cc60373c8e Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Mon, 12 Feb 2018 19:16:31 +0100 Subject: [PATCH] ut/vhost: fix vhost_dev_register() tests All vhost_dev_register() tests are negative - they all expect error. They all were failing on a single check: *ERROR*: no cpu is selected among reactor mask(=1) *ERROR*: cpumask 0x1 is invalid (app mask is 0x1) That's because we mock cpumask parsing. Even when "parsed", the real cpumask would always be == 0. Our unit tests were treating this as a valid behavior. To really test what they should, we have to properly implement cpumask parsing. That's what this patch does. We should also assert against a specific error code, not just != 0. But that's a matter for a separate commit. Change-Id: Iae93b31292a0d9aee4e773ef568b2052a1de714d Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/399442 Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- test/unit/lib/vhost/vhost.c/vhost_ut.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/unit/lib/vhost/vhost.c/vhost_ut.c b/test/unit/lib/vhost/vhost.c/vhost_ut.c index 923dcd659..14fe2c918 100644 --- a/test/unit/lib/vhost/vhost.c/vhost_ut.c +++ b/test/unit/lib/vhost/vhost.c/vhost_ut.c @@ -57,7 +57,23 @@ struct spdk_cpuset *spdk_app_get_core_mask(void) return g_app_core_mask; } -DEFINE_STUB(spdk_app_parse_core_mask, int, (const char *mask, struct spdk_cpuset *cpumask), 0); +int +spdk_app_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask) +{ + int ret; + struct spdk_cpuset *validmask; + + ret = spdk_cpuset_parse(cpumask, mask); + if (ret < 0) { + return ret; + } + + validmask = spdk_app_get_core_mask(); + spdk_cpuset_and(cpumask, validmask); + + return 0; +} + DEFINE_STUB(spdk_env_get_first_core, uint32_t, (void), 0); DEFINE_STUB(spdk_env_get_next_core, uint32_t, (uint32_t prev_core), 0); DEFINE_STUB(spdk_env_get_last_core, uint32_t, (void), 0);