Also add a QB_IPC_NATIVE type that selects the best ipc type available.
Signed-off-by: Angus <angus@anguss-mac-mini>
---
check | 2 +-
configure.ac | 10 +--
examples/ipcserver.c | 2 +-
include/os_base.h | 18 +++--
include/qb/qbipc_common.h | 1 +
lib/Makefile.am | 5 ++
lib/ipc_int.h | 4 --
lib/ipcs.c | 12 +++-
lib/ringbuffer_helper.c | 36 +++++-----
lib/ringbuffer_int.h | 6 +-
lib/rpl_sem.c | 165 +++++++++++++++++++++++++++++++++++++++++++++
lib/rpl_sem.h | 64 ++++++++++++++++++
tests/check_ipc.c | 121 ++++++++++++++++++++-------------
13 files changed, 353 insertions(+), 93 deletions(-)
create mode 100644 lib/rpl_sem.c
create mode 100644 lib/rpl_sem.h
diff --git a/check b/check
index 0fc50b9..3584ef2 100755
--- a/check
+++ b/check
@@ -120,7 +120,7 @@ check_bsd() {
# bsd-like
echo "checking bed"
echo "======================="
- check "ac_cv_func_clock_gettime=no ac_cv_func_epoll_create1=no
ac_cv_func_epoll_create=no"
+ check "ac_cv_func_sem_timedwait=no ac_cv_func_clock_gettime=no
ac_cv_func_epoll_create1=no ac_cv_func_epoll_create=no"
}
check_mac() {
diff --git a/configure.ac b/configure.ac
index 2ff9fb8..b498c08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,18 +143,18 @@ AC_FUNC_MMAP
AC_CHECK_FUNCS([alarm clock_gettime ftruncate gettimeofday localtime localtime_r \
memset munmap socket strchr strrchr strdup strerror strstr \
poll epoll_create epoll_create1 random rand getrlimit sysconf \
- pthread_spin_lock pthread_setschedparam \
+ pthread_spin_lock pthread_setschedparam sem_timedwait \
sched_get_priority_max sched_setscheduler])
+AM_CONDITIONAL(HAVE_SEM_TIMEDWAIT,
+ [test "x$ac_cv_func_sem_timedwait" = xyes])
+
AC_CONFIG_LIBOBJ_DIR(lib)
AC_REPLACE_FUNCS(strlcpy strlcat strchrnul)
## local defines
PACKAGE_FEATURES=""
-if test x$ac_cv_func_timerfd_create = xyes; then
- PACKAGE_FEATURES="$PACKAGE_FEATURES timerfd"
-fi
if test x$ac_cv_func_epoll_create = xyes; then
PACKAGE_FEATURES="$PACKAGE_FEATURES epoll"
fi
@@ -243,7 +243,7 @@ case "$host_os" in
AC_DEFINE_UNQUOTED([QB_BSD], [1],
[Compiling for BSD platform])
AC_DEFINE_UNQUOTED([MAP_ANONYMOUS], [MAP_ANON],
- [Shared memory define for Darwin platform])
+ [Shared memory define for BSD platform])
case "$host_os" in
*freebsd[[234567]]*)
;;
diff --git a/examples/ipcserver.c b/examples/ipcserver.c
index 6e2fc6a..7e62fc7 100644
--- a/examples/ipcserver.c
+++ b/examples/ipcserver.c
@@ -247,7 +247,7 @@ main(int32_t argc, char *argv[])
{
const char *options = "mpsugh";
int32_t opt;
- enum qb_ipc_type ipc_type = QB_IPC_SHM;
+ enum qb_ipc_type ipc_type = QB_IPC_NATIVE;
struct qb_ipcs_service_handlers sh = {
.connection_accept = s1_connection_accept_fn,
.connection_created = s1_connection_created_fn,
diff --git a/include/os_base.h b/include/os_base.h
index 1420fe5..4dd0555 100644
--- a/include/os_base.h
+++ b/include/os_base.h
@@ -112,17 +112,15 @@
* but it really does not. The unistd.h header file is wrong.
*/
#if defined(DISABLE_POSIX_THREAD_PROCESS_SHARED) || defined(__UCLIBC__)
-#undef HAVE_POSIX_SHARED_SEMAPHORE
-#undef HAVE_PTHREAD_SHARED_SPIN_LOCK
+ #undef HAVE_POSIX_SHARED_SEMAPHORE
+ #undef HAVE_PTHREAD_SHARED_SPIN_LOCK
#else
-#if _POSIX_THREAD_PROCESS_SHARED > 0
-#define HAVE_POSIX_SHARED_SEMAPHORE 1
-
-#if defined(HAVE_PTHREAD_SPIN_LOCK)
-#define HAVE_PTHREAD_SHARED_SPIN_LOCK 1
-#endif /* HAVE_PTHREAD_SPIN_LOCK */
-
-#endif /* _POSIX_THREAD_PROCESS_SHARED */
+ #if _POSIX_THREAD_PROCESS_SHARED > 0
+ #define HAVE_POSIX_SHARED_SEMAPHORE 1
+ #if defined(HAVE_PTHREAD_SPIN_LOCK)
+ #define HAVE_PTHREAD_SHARED_SPIN_LOCK 1
+ #endif /* HAVE_PTHREAD_SPIN_LOCK */
+ #endif /* _POSIX_THREAD_PROCESS_SHARED */
#endif /* DISABLE_POSIX_THREAD_PROCESS_SHARED */
#ifndef HAVE_STRCHRNUL
diff --git a/include/qb/qbipc_common.h b/include/qb/qbipc_common.h
index 269de56..0a4118c 100644
--- a/include/qb/qbipc_common.h
+++ b/include/qb/qbipc_common.h
@@ -47,6 +47,7 @@ enum qb_ipc_type {
QB_IPC_SHM,
QB_IPC_POSIX_MQ,
QB_IPC_SYSV_MQ,
+ QB_IPC_NATIVE,
};
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 14a00a8..dec3d28 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -56,6 +56,11 @@ if HAVE_POSIX_MQ
libqb_la_SOURCES+=ipc_posix_mq.c
endif
+if HAVE_SEM_TIMEDWAIT
+else
+ libqb_la_SOURCES+=rpl_sem.c
+endif
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libqb.pc
diff --git a/lib/ipc_int.h b/lib/ipc_int.h
index 16bc5c7..62559bd 100644
--- a/lib/ipc_int.h
+++ b/lib/ipc_int.h
@@ -35,10 +35,6 @@
#include <qb/qbipc_common.h>
#include <qb/qbrb.h>
-#ifdef HAVE_POSIX_SHARED_SEMAPHORE
-#include <semaphore.h>
-#endif /* HAVE_POSIX_SHARED_SEMAPHORE */
-
#define QB_IPC_MAX_WAIT_MS 2000
/*
diff --git a/lib/ipcs.c b/lib/ipcs.c
index 5f5560f..49c995f 100644
--- a/lib/ipcs.c
+++ b/lib/ipcs.c
@@ -42,9 +42,15 @@ qb_ipcs_create(const char *name,
if (s == NULL) {
return NULL;
}
+ if (type == QB_IPC_NATIVE) {
+#ifdef HAVE_SEM_TIMEDWAIT
+ s->type = QB_IPC_SHM;
+#else
+ s->type = QB_IPC_SOCKET;
+#endif /* HAVE_SEM_TIMEDWAIT */
+ }
s->pid = getpid();
- s->type = type;
s->needs_sock_for_poll = QB_FALSE;
s->poll_priority = QB_LOOP_MED;
s->ref_count = 1;
@@ -91,7 +97,11 @@ qb_ipcs_run(struct qb_ipcs_service *s)
qb_ipcs_us_init((struct qb_ipcs_service *)s);
break;
case QB_IPC_SHM:
+#ifdef HAVE_SEM_TIMEDWAIT
qb_ipcs_shm_init((struct qb_ipcs_service *)s);
+#else
+ res = -ENOTSUP;
+#endif /* HAVE_SEM_TIMEDWAIT */
break;
case QB_IPC_POSIX_MQ:
#ifdef HAVE_POSIX_MQ
diff --git a/lib/ringbuffer_helper.c b/lib/ringbuffer_helper.c
index 4634771..f66d9bf 100644
--- a/lib/ringbuffer_helper.c
+++ b/lib/ringbuffer_helper.c
@@ -34,11 +34,11 @@ my_posix_sem_timedwait(qb_ringbuffer_t * rb, int32_t ms_timeout)
sem_wait_again:
if (ms_timeout > 0) {
- res = sem_timedwait(&rb->shared_hdr->posix_sem, &ts_timeout);
+ res = rpl_sem_timedwait(&rb->shared_hdr->posix_sem, &ts_timeout);
} else if (ms_timeout == 0) {
- res = sem_trywait(&rb->shared_hdr->posix_sem);
+ res = rpl_sem_trywait(&rb->shared_hdr->posix_sem);
} else {
- res = sem_wait(&rb->shared_hdr->posix_sem);
+ res = rpl_sem_wait(&rb->shared_hdr->posix_sem);
}
if (res == -1) {
switch (errno) {
@@ -63,7 +63,7 @@ sem_wait_again:
static int32_t
my_posix_sem_post(qb_ringbuffer_t * rb)
{
- if (sem_post(&rb->shared_hdr->posix_sem) < 0) {
+ if (rpl_sem_post(&rb->shared_hdr->posix_sem) < 0) {
return -errno;
} else {
return 0;
@@ -74,7 +74,7 @@ static ssize_t
my_posix_getvalue_fn(struct qb_ringbuffer_s *rb)
{
int val;
- if (sem_getvalue(&rb->shared_hdr->posix_sem, &val) < 0) {
+ if (rpl_sem_getvalue(&rb->shared_hdr->posix_sem, &val) < 0) {
return -errno;
} else {
return val;
@@ -84,7 +84,7 @@ my_posix_getvalue_fn(struct qb_ringbuffer_s *rb)
static int32_t
my_posix_sem_destroy(qb_ringbuffer_t * rb)
{
- if (sem_destroy(&rb->shared_hdr->posix_sem) == -1) {
+ if (rpl_sem_destroy(&rb->shared_hdr->posix_sem) == -1) {
return -errno;
} else {
return 0;
@@ -101,14 +101,13 @@ my_posix_sem_create(struct qb_ringbuffer_s *rb, uint32_t flags)
}
pshared = 1;
}
- if (sem_init(&rb->shared_hdr->posix_sem, pshared, 0) == -1) {
+ if (rpl_sem_init(&rb->shared_hdr->posix_sem, pshared, 0) == -1) {
return -errno;
} else {
return 0;
}
}
-#ifndef HAVE_POSIX_SHARED_SEMAPHORE
static int32_t
my_sysv_sem_timedwait(qb_ringbuffer_t * rb, int32_t ms_timeout)
{
@@ -249,25 +248,24 @@ my_sysv_sem_create(qb_ringbuffer_t * rb, uint32_t flags)
return res;
}
-#endif /* NOT HAVE_POSIX_SHARED_SEMAPHORE */
int32_t
qb_rb_sem_create(struct qb_ringbuffer_s * rb, uint32_t flags)
{
-#ifndef HAVE_POSIX_SHARED_SEMAPHORE
- if (rb->flags & QB_RB_FLAG_SHARED_PROCESS) {
+ int32_t rc;
+
+ rc = my_posix_sem_create(rb, flags);
+ if (rc == 0) {
+ rb->sem_timedwait_fn = my_posix_sem_timedwait;
+ rb->sem_post_fn = my_posix_sem_post;
+ rb->sem_getvalue_fn = my_posix_getvalue_fn;
+ rb->sem_destroy_fn = my_posix_sem_destroy;
+ } else {
rb->sem_timedwait_fn = my_sysv_sem_timedwait;
rb->sem_post_fn = my_sysv_sem_post;
rb->sem_getvalue_fn = my_sysv_getvalue_fn;
rb->sem_destroy_fn = my_sysv_sem_destroy;
return my_sysv_sem_create(rb, flags);
- } else
-#endif /* NOT HAVE_POSIX_SHARED_SEMAPHORE */
- {
- rb->sem_timedwait_fn = my_posix_sem_timedwait;
- rb->sem_post_fn = my_posix_sem_post;
- rb->sem_getvalue_fn = my_posix_getvalue_fn;
- rb->sem_destroy_fn = my_posix_sem_destroy;
- return my_posix_sem_create(rb, flags);
}
+ return rc;
}
diff --git a/lib/ringbuffer_int.h b/lib/ringbuffer_int.h
index 3a7f22d..35283c7 100644
--- a/lib/ringbuffer_int.h
+++ b/lib/ringbuffer_int.h
@@ -32,9 +32,7 @@
#ifdef HAVE_SYS_IPC_H
#include <sys/ipc.h>
#endif
-#include <pthread.h>
-#include <semaphore.h>
-
+#include "rpl_sem.h"
#include "util_int.h"
#include <qb/qbutil.h>
#include <qb/qbrb.h>
@@ -55,7 +53,7 @@ struct qb_ringbuffer_shared_s {
char hdr_path[PATH_MAX];
char data_path[PATH_MAX];
int32_t ref_count;
- sem_t posix_sem;
+ rpl_sem_t posix_sem;
char user_data[1];
};
diff --git a/lib/rpl_sem.c b/lib/rpl_sem.c
new file mode 100644
index 0000000..cdc005c
--- /dev/null
+++ b/lib/rpl_sem.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2007 Pingtel Corp., certain elements licensed under a Contributor
Agreement.
+ * Contributors retain copyright to elements licensed under a Contributor Agreement.
+ * Licensed to the User under the LGPL license.
+ *
+ * Modified by: Angus Salkeld <asalkeld(a)redhat.com>
+ * Copyright (C) 2012 Red Hat, Inc.
+ * To conform to posix API and support process shared semaphores.
+ *
+ * The bsd posix semaphore implementation does not have support for timing
+ * out while waiting for a synchronization object. This uses the
+ * pthread_cond_timedwait function and a mutex to build all the other
+ * synchronization objecs with timeout capabilities.
+ */
+
+#include "os_base.h"
+#include <pthread.h>
+#include "rpl_sem.h"
+
+int
+rpl_sem_init(rpl_sem_t * sem, int pshared, unsigned int count)
+{
+ int rc;
+ pthread_mutexattr_t mattr;
+ pthread_condattr_t cattr;
+
+#if defined(DISABLE_POSIX_THREAD_PROCESS_SHARED)
+ if (pshared) {
+ errno = ENOSYS;
+ return -1;
+ }
+#endif
+ sem->count = count;
+
+ (void)pthread_mutexattr_init(&mattr);
+ (void)pthread_condattr_init(&cattr);
+ if (pshared) {
+ rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
+ if (rc != 0) {
+ goto cleanup;
+ }
+ rc = pthread_condattr_setpshared(&cattr, PTHREAD_PROCESS_SHARED);
+ if (rc != 0) {
+ goto cleanup;
+ }
+ }
+ rc = pthread_mutex_init(&sem->mutex, &mattr);
+ if (rc != 0) {
+ goto cleanup;
+ }
+ rc = pthread_cond_init(&sem->cond, &cattr);
+
+ if (rc != 0) {
+ goto cleanup_mutex;
+ }
+ return 0;
+
+cleanup_mutex:
+ pthread_mutex_destroy(&sem->mutex);
+
+cleanup:
+ pthread_mutexattr_destroy(&mattr);
+ pthread_condattr_destroy(&cattr);
+ return rc;
+}
+
+int
+rpl_sem_wait(rpl_sem_t * sem)
+{
+ int retval = 0;
+
+ pthread_mutex_lock(&sem->mutex);
+
+ /* wait for sem->count to be not zero, or error
+ */
+ while (retval == 0 && !sem->count) {
+ retval = pthread_cond_wait(&sem->cond, &sem->mutex);
+ }
+ switch (retval) {
+ case 0:
+ /* retval is 0 and sem->count is not, the sem is ours
+ */
+ sem->count--;
+ break;
+
+ default:
+ errno = retval;
+ retval = -1;
+ }
+
+ pthread_mutex_unlock(&sem->mutex);
+ return retval;
+}
+
+int
+rpl_sem_timedwait(rpl_sem_t * sem, const struct timespec *timeout)
+{
+ int retval = 0;
+ pthread_mutex_lock(&sem->mutex);
+
+ /* wait for sem->count to be not zero, or error
+ */
+ while (0 == retval && !sem->count) {
+ retval = pthread_cond_timedwait(&sem->cond, &sem->mutex, timeout);
+ }
+
+ switch (retval) {
+ case 0:
+ /* retval is 0 and sem->count is not, the sem is ours
+ */
+ sem->count--;
+ break;
+
+ case ETIMEDOUT:
+ /* timedout waiting for count to be not zero
+ */
+ errno = EAGAIN;
+ retval = -1;
+ break;
+
+ default:
+ errno = retval;
+ retval = -1;
+ }
+ pthread_mutex_unlock(&sem->mutex);
+ return retval;
+}
+
+int
+rpl_sem_trywait(rpl_sem_t * sem)
+{
+ pthread_mutex_lock(&sem->mutex);
+ if (sem->count) {
+ sem->count--;
+ pthread_mutex_unlock(&sem->mutex);
+ return 0;
+ }
+ errno = EAGAIN;
+ pthread_mutex_unlock(&sem->mutex);
+ return -1;
+}
+
+int
+rpl_sem_post(rpl_sem_t * sem)
+{
+ pthread_mutex_lock(&sem->mutex);
+ sem->count++;
+ pthread_cond_broadcast(&sem->cond);
+ pthread_mutex_unlock(&sem->mutex);
+ return 0;
+}
+
+int
+rpl_sem_getvalue(rpl_sem_t * sem, int *sval)
+{
+ *sval = sem->count;
+ return 0;
+}
+
+int
+rpl_sem_destroy(rpl_sem_t * sem)
+{
+ return pthread_mutex_destroy(&sem->mutex) |
+ pthread_cond_destroy(&sem->cond);
+}
diff --git a/lib/rpl_sem.h b/lib/rpl_sem.h
new file mode 100644
index 0000000..23724e4
--- /dev/null
+++ b/lib/rpl_sem.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2007 Pingtel Corp., certain elements licensed under a Contributor
Agreement.
+ * Contributors retain copyright to elements licensed under a Contributor Agreement.
+ * Licensed to the User under the LGPL license.
+ *
+ * Modified by: Angus Salkeld <asalkeld(a)redhat.com>
+ * Copyright (C) 2012 Red Hat, Inc.
+ * To conform to official implementation and support process shared semaphores.
+ *
+ * The bsd posix semaphore implementation does not have support for timing
+ * out while waiting for a synchronization object. This uses the
+ * pthread_cond_timedwait function and a mutex to build all the other
+ * synchronization objecs with timeout capabilities.
+ */
+
+#ifndef _RPL_SEM_H
+#define _RPL_SEM_H
+
+#include "os_base.h"
+#include <pthread.h>
+#include <semaphore.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_SEM_TIMEDWAIT
+#define rpl_sem_t sem_t
+#define rpl_sem_init sem_init
+#define rpl_sem_wait sem_wait
+#define rpl_sem_timedwait sem_timedwait
+#define rpl_sem_post sem_post
+#define rpl_sem_getvalue sem_getvalue
+#define rpl_sem_destroy sem_destroy
+#define rpl_sem_trywait sem_trywait
+#else
+
+typedef struct rpl_sem {
+ unsigned int count;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+} rpl_sem_t;
+
+int rpl_sem_init(rpl_sem_t * sem, int pshared, unsigned int count);
+
+int rpl_sem_wait(rpl_sem_t *sem);
+
+int rpl_sem_timedwait(rpl_sem_t *sem,const struct timespec *timeout);
+
+int rpl_sem_trywait(rpl_sem_t *sem);
+
+int rpl_sem_post(rpl_sem_t *sem);
+
+int rpl_sem_getvalue(rpl_sem_t * sem, int *sval);
+
+int rpl_sem_destroy(rpl_sem_t *sem);
+
+#endif /* HAVE_SEM_TIMEDWAIT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RPL_SEM_H */
diff --git a/tests/check_ipc.c b/tests/check_ipc.c
index 87c5a48..8e0d3a3 100644
--- a/tests/check_ipc.c
+++ b/tests/check_ipc.c
@@ -21,12 +21,8 @@
* along with libqb. If not, see <
http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
+#include "os_base.h"
#include <sys/wait.h>
-#include <errno.h>
#include <signal.h>
#include <check.h>
@@ -312,9 +308,12 @@ test_ipc_txrx(void)
static void
test_ipc_exit(void)
{
+ struct qb_ipc_request_header req_header;
+ struct qb_ipc_response_header res_header;
+ struct iovec iov[1];
+ int32_t res;
int32_t c = 0;
int32_t j = 0;
- int32_t rc = 0;
pid_t pid;
pid = run_function_in_new_process(run_ipc_server);
@@ -332,9 +331,16 @@ test_ipc_exit(void)
} while (conn == NULL && c < 5);
fail_if(conn == NULL);
- /* confirm we can send one message */
- rc = send_and_check(100, recv_timeout, QB_TRUE);
- _ck_assert_int(rc, >=, 0);
+ req_header.id = IPC_MSG_REQ_TX_RX;
+ req_header.size = sizeof(struct qb_ipc_request_header);
+
+ iov[0].iov_len = req_header.size;
+ iov[0].iov_base = &req_header;
+
+ res = qb_ipcc_sendv_recv(conn, iov, 1,
+ &res_header,
+ sizeof(struct qb_ipc_response_header), -1);
+ ck_assert_int_eq(res, sizeof(struct qb_ipc_response_header));
/* kill the server */
stop_process(pid);
@@ -350,7 +356,16 @@ test_ipc_exit(void)
qb_ipcc_disconnect(conn);
}
+START_TEST(test_ipc_exit_us)
+{
+ ipc_type = QB_IPC_SOCKET;
+ ipc_name = __func__;
+ recv_timeout = 5000;
+ test_ipc_exit();
+}
+END_TEST
+#ifdef HAVE_SEM_TIMEDWAIT
START_TEST(test_ipc_exit_shm)
{
ipc_type = QB_IPC_SHM;
@@ -380,32 +395,33 @@ START_TEST(test_ipc_txrx_shm_block)
}
END_TEST
-START_TEST(test_ipc_txrx_us_block)
+START_TEST(test_ipc_fc_shm)
{
- turn_on_fc = QB_FALSE;
- ipc_type = QB_IPC_SOCKET;
+ turn_on_fc = QB_TRUE;
+ ipc_type = QB_IPC_SHM;
+ recv_timeout = 500;
ipc_name = __func__;
- recv_timeout = -1;
test_ipc_txrx();
}
END_TEST
+#endif /* HAVE_SEM_TIMEDWAIT */
-START_TEST(test_ipc_txrx_us_tmo)
+START_TEST(test_ipc_txrx_us_block)
{
turn_on_fc = QB_FALSE;
ipc_type = QB_IPC_SOCKET;
ipc_name = __func__;
- recv_timeout = 1000;
+ recv_timeout = -1;
test_ipc_txrx();
}
END_TEST
-START_TEST(test_ipc_fc_shm)
+START_TEST(test_ipc_txrx_us_tmo)
{
- turn_on_fc = QB_TRUE;
- ipc_type = QB_IPC_SHM;
- recv_timeout = 500;
+ turn_on_fc = QB_FALSE;
+ ipc_type = QB_IPC_SOCKET;
ipc_name = __func__;
+ recv_timeout = 1000;
test_ipc_txrx();
}
END_TEST
@@ -503,14 +519,6 @@ test_ipc_dispatch(void)
stop_process(pid);
}
-START_TEST(test_ipc_disp_shm)
-{
- ipc_type = QB_IPC_SHM;
- ipc_name = __func__;
- test_ipc_dispatch();
-}
-END_TEST
-
START_TEST(test_ipc_disp_us)
{
ipc_type = QB_IPC_SOCKET;
@@ -574,6 +582,15 @@ START_TEST(test_ipc_server_fail_soc)
}
END_TEST
+#ifdef HAVE_SEM_TIMEDWAIT
+START_TEST(test_ipc_disp_shm)
+{
+ ipc_type = QB_IPC_SHM;
+ ipc_name = __func__;
+ test_ipc_dispatch();
+}
+END_TEST
+
START_TEST(test_ipc_server_fail_shm)
{
ipc_type = QB_IPC_SHM;
@@ -581,6 +598,7 @@ START_TEST(test_ipc_server_fail_shm)
test_ipc_server_fail();
}
END_TEST
+#endif /* HAVE_SEM_TIMEDWAIT */
static Suite *
ipc_suite(void)
@@ -589,16 +607,12 @@ ipc_suite(void)
uid_t uid;
Suite *s = suite_create("ipc");
+#ifdef HAVE_SEM_TIMEDWAIT
tc = tcase_create("ipc_server_fail_shm");
tcase_add_test(tc, test_ipc_server_fail_shm);
tcase_set_timeout(tc, 6);
suite_add_tcase(s, tc);
- tc = tcase_create("ipc_server_fail_soc");
- tcase_add_test(tc, test_ipc_server_fail_soc);
- tcase_set_timeout(tc, 6);
- suite_add_tcase(s, tc);
-
tc = tcase_create("ipc_txrx_shm_block");
tcase_add_test(tc, test_ipc_txrx_shm_block);
tcase_set_timeout(tc, 6);
@@ -609,6 +623,27 @@ ipc_suite(void)
tcase_set_timeout(tc, 6);
suite_add_tcase(s, tc);
+ tc = tcase_create("ipc_fc_shm");
+ tcase_add_test(tc, test_ipc_fc_shm);
+ tcase_set_timeout(tc, 6);
+ suite_add_tcase(s, tc);
+
+ tc = tcase_create("ipc_dispatch_shm");
+ tcase_add_test(tc, test_ipc_disp_shm);
+ tcase_set_timeout(tc, 16);
+ suite_add_tcase(s, tc);
+
+ tc = tcase_create("ipc_exit_shm");
+ tcase_add_test(tc, test_ipc_exit_shm);
+ tcase_set_timeout(tc, 3);
+ suite_add_tcase(s, tc);
+#endif /* HAVE_SEM_TIMEDWAIT */
+
+ tc = tcase_create("ipc_server_fail_soc");
+ tcase_add_test(tc, test_ipc_server_fail_soc);
+ tcase_set_timeout(tc, 6);
+ suite_add_tcase(s, tc);
+
tc = tcase_create("ipc_txrx_us_block");
tcase_add_test(tc, test_ipc_txrx_us_block);
tcase_set_timeout(tc, 6);
@@ -619,16 +654,16 @@ ipc_suite(void)
tcase_set_timeout(tc, 6);
suite_add_tcase(s, tc);
- tc = tcase_create("ipc_fc_shm");
- tcase_add_test(tc, test_ipc_fc_shm);
- tcase_set_timeout(tc, 6);
- suite_add_tcase(s, tc);
-
tc = tcase_create("ipc_fc_us");
tcase_add_test(tc, test_ipc_fc_us);
tcase_set_timeout(tc, 6);
suite_add_tcase(s, tc);
+ tc = tcase_create("ipc_exit_us");
+ tcase_add_test(tc, test_ipc_exit_us);
+ tcase_set_timeout(tc, 3);
+ suite_add_tcase(s, tc);
+
uid = geteuid();
if (uid == 0) {
tc = tcase_create("ipc_txrx_posix_mq");
@@ -641,21 +676,11 @@ ipc_suite(void)
tcase_set_timeout(tc, 10);
suite_add_tcase(s, tc);
}
- tc = tcase_create("ipc_dispatch_shm");
- tcase_add_test(tc, test_ipc_disp_shm);
- tcase_set_timeout(tc, 16);
- suite_add_tcase(s, tc);
-
tc = tcase_create("ipc_dispatch_us");
tcase_add_test(tc, test_ipc_disp_us);
tcase_set_timeout(tc, 16);
suite_add_tcase(s, tc);
- tc = tcase_create("ipc_exit_shm");
- tcase_add_test(tc, test_ipc_exit_shm);
- tcase_set_timeout(tc, 3);
- suite_add_tcase(s, tc);
-
return s;
}
@@ -670,7 +695,7 @@ main(void)
qb_log_init("check", LOG_USER, LOG_EMERG);
qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE);
qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
- QB_LOG_FILTER_FILE, "*", LOG_INFO);
+ QB_LOG_FILTER_FILE, "*", LOG_TRACE);
qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE);
srunner_run_all(sr, CK_VERBOSE);
--
1.7.9.3