From 19de08066d6259f6358e89ad2fde4f6704010f05 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Mon, 11 Sep 2017 09:10:33 -0700 Subject: [PATCH] test/mock: add pthread_self This will be used to simulate multi-threading for bdev unit tests. While here, alphabetize the existing calls - calloc had been inserted out of order in a couple of places. Signed-off-by: Jim Harris Change-Id: I559cd1fd79e78f03ebdac313e0bbedbcdde4a8c1 Reviewed-on: https://review.gerrithub.io/377968 Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Paul Luse --- include/spdk_internal/mock.h | 2 ++ lib/ut_mock/mock.c | 4 +++- mk/spdk.mock.unittest.mk | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/spdk_internal/mock.h b/include/spdk_internal/mock.h index aa3893af3..a28e3df4c 100644 --- a/include/spdk_internal/mock.h +++ b/include/spdk_internal/mock.h @@ -121,4 +121,6 @@ DECLARE_WRAPPER(pthread_mutex_init, int, DECLARE_WRAPPER(pthread_mutexattr_init, int, (pthread_mutexattr_t *attr)); +DECLARE_WRAPPER(pthread_self, pthread_t, (void)); + #endif /* SPDK_INTERNAL_MOCK_H */ diff --git a/lib/ut_mock/mock.c b/lib/ut_mock/mock.c index e642c7680..1afb56699 100644 --- a/lib/ut_mock/mock.c +++ b/lib/ut_mock/mock.c @@ -33,6 +33,8 @@ #include "spdk_internal/mock.h" +DEFINE_WRAPPER(calloc, void *, (size_t nmemb, size_t size), (nmemb, size), (void *)MOCK_PASS_THRU) + DEFINE_WRAPPER(pthread_mutex_init, int, (pthread_mutex_t *mtx, const pthread_mutexattr_t *attr), (mtx, attr), MOCK_PASS_THRU) @@ -40,4 +42,4 @@ DEFINE_WRAPPER(pthread_mutex_init, int, DEFINE_WRAPPER(pthread_mutexattr_init, int, (pthread_mutexattr_t *attr), (attr), MOCK_PASS_THRU) -DEFINE_WRAPPER(calloc, void *, (size_t nmemb, size_t size), (nmemb, size), (void *)MOCK_PASS_THRU) +DEFINE_WRAPPER(pthread_self, pthread_t, (void), (), (pthread_t)MOCK_PASS_THRU) diff --git a/mk/spdk.mock.unittest.mk b/mk/spdk.mock.unittest.mk index 58a36aeec..dff2c9690 100644 --- a/mk/spdk.mock.unittest.mk +++ b/mk/spdk.mock.unittest.mk @@ -30,5 +30,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -LDFLAGS += -Wl,--wrap,pthread_mutexattr_init -Wl,--wrap,pthread_mutex_init \ - -Wl,--wrap,calloc +LDFLAGS += \ + -Wl,--wrap,calloc \ + -Wl,--wrap,pthread_mutexattr_init \ + -Wl,--wrap,pthread_mutex_init \ + -Wl,--wrap,pthread_self