diff --git a/autopackage.sh b/autopackage.sh index 0bd446a1b..d54d05d55 100755 --- a/autopackage.sh +++ b/autopackage.sh @@ -36,7 +36,7 @@ fi timing_enter build_release if [ $(uname -s) = Linux ]; then - ./configure $(get_config_params) --disable-debug --enable-lto --disable-unit-tests + ./configure $(get_config_params) --disable-debug --enable-lto else # LTO needs a special compiler to work on BSD. ./configure $(get_config_params) --disable-debug diff --git a/configure b/configure index 6655dd53e..b9d1e8177 100755 --- a/configure +++ b/configure @@ -499,11 +499,6 @@ if [[ "${CONFIG[ISAL]}" = "n" ]] && [[ "${CONFIG[REDUCE]}" = "y" ]]; then exit 1 fi -if [[ "${CONFIG[LTO]}" = "y" ]] && [[ "${CONFIG[UNIT_TESTS]}" = "y" ]]; then - echo "ERROR Conflicting options: --enable-lto is not compatible with --enable-unit-tests." - exit 1 -fi - if [ -z "${CONFIG[ENV]}" ]; then CONFIG[ENV]=$rootdir/lib/env_dpdk echo "Using default SPDK env in ${CONFIG[ENV]}" diff --git a/include/spdk_internal/mock.h b/include/spdk_internal/mock.h index 705378fac..8de44ae55 100644 --- a/include/spdk_internal/mock.h +++ b/include/spdk_internal/mock.h @@ -122,4 +122,14 @@ DECLARE_WRAPPER(sendmsg, ssize_t, (int sockfd, const struct msghdr *msg, int fla DECLARE_WRAPPER(writev, ssize_t, (int fd, const struct iovec *iov, int iovcnt)); +/* unlink is done a bit differently. */ +extern char *g_unlink_path; +extern void (*g_unlink_callback)(void); +/* If g_unlink_path is NULL, __wrap_unlink will return ENOENT. + * If the __wrap_unlink() parameter does not match g_unlink_path, it will return ENOENT. + * If g_unlink_path does match, and g_unlink_callback has been set, g_unlink_callback will + * be called before returning 0. + */ +int __wrap_unlink(const char *path); + #endif /* SPDK_INTERNAL_MOCK_H */ diff --git a/lib/ut_mock/mock.c b/lib/ut_mock/mock.c index a7b2a23d3..cfe51c1d5 100644 --- a/lib/ut_mock/mock.c +++ b/lib/ut_mock/mock.c @@ -48,3 +48,24 @@ DEFINE_WRAPPER(sendmsg, ssize_t, (int sockfd, const struct msghdr *msg, int flag flags)) DEFINE_WRAPPER(writev, ssize_t, (int fd, const struct iovec *iov, int iovcnt), (fd, iov, iovcnt)) + +char *g_unlink_path; +void (*g_unlink_callback)(void); + +int +__attribute__((used)) +__wrap_unlink(const char *path) +{ + if (g_unlink_path == NULL) { + return ENOENT; + } + + if (strcmp(g_unlink_path, path) != 0) { + return ENOENT; + } + + if (g_unlink_callback) { + g_unlink_callback(); + } + return 0; +} diff --git a/test/unit/lib/reduce/reduce.c/reduce_ut.c b/test/unit/lib/reduce/reduce.c/reduce_ut.c index 8759721a0..9c94a4ac6 100644 --- a/test/unit/lib/reduce/reduce.c/reduce_ut.c +++ b/test/unit/lib/reduce/reduce.c/reduce_ut.c @@ -176,17 +176,10 @@ persistent_pm_buf_destroy(void) g_persistent_pm_buf_len = 0; } -int __wrap_unlink(const char *path); - -int -__wrap_unlink(const char *path) +static void +unlink_cb(void) { - if (strcmp(g_path, path) != 0) { - return ENOENT; - } - persistent_pm_buf_destroy(); - return 0; } static void @@ -1296,6 +1289,9 @@ main(int argc, char **argv) CU_ADD_TEST(suite, overlapped); CU_ADD_TEST(suite, compress_algorithm); + g_unlink_path = g_path; + g_unlink_callback = unlink_cb; + CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); num_failures = CU_get_number_of_failures();