Commit b0103de6 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #1136 from ewen-naos-nz/zos

z/OS UNIX System Services port
parents 81b9f21b f72f4b25
This diff is collapsed.
#! /bin/sh
# Attempt to compile all *.cpp files in the current directory, that are
# not already compiled. Uses zc++ wrapper around C++ compiler, to add
# additional compile arguments.
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-19
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-22
#---------------------------------------------------------------------------
VERBOSE="${VERBOSE:-}" # Set to non-empty for already done status
export VERBOSE
# Locate compiler wrapper
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
ZCXX="${BIN_DIR}/zc++"
# Determine compile flags
CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED=1 -D_OPEN_THREADS=3 -D_OPEN_SYS_SOCK_IPV6"
CXXFLAGS="-DHAVE_CONFIG_H -D_REENTRANT -D_THREAD_SAFE -DZMQ_FORCE_POLL"
case $(pwd) in
*src) CXXFLAGS="${CXXFLAGS} -I."
;;
*tests) CXXFLAGS="${CXXFLAGS} -I. -I../src -I../include"
;;
*) echo "Currently only builds in src/ and tests/" >&2
exit 1
;;
esac
skip() {
SRC="$1"
OBJ="$2"
if [ -n "${VERBOSE}" ]; then
echo " ${SRC} compiled already"
fi
}
compile() {
SRC="$1"
OBJ="$2"
echo "CXX ${SRC}"
"${ZCXX}" ${CXXFLAGS} ${CPPFLAGS} -+ -c -o "${OBJ}" "${SRC}"
}
for SRC in *.cpp; do
OBJ=$(echo $SRC | sed 's/\.cpp/.o/;')
if [ -f "${OBJ}" ]; then
if [ "${OBJ}" -nt "${SRC}" ]; then
skip "${SRC}" "${OBJ}"
else
compile "${SRC}" "${OBJ}"
fi
else
compile "${SRC}" "${OBJ}"
fi
done
#! /bin/sh
# Remove built object files and test executables
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-22
#---------------------------------------------------------------------------
set -e # Stop on errors
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRC="${TOP}/src"
TESTS="${TOP}/tests"
# Remove object/library files
echo "Removing libzmq built files"
(cd "${SRC}" && rm -f *.o *.a *.dbg *.x libzmq* *.so)
# Remove test object files
echo "Removing libzmq tests"
(cd "${TESTS}" && rm -f *.o *.dbg)
(cd "${TESTS}";
EXES=$(ls test_* | grep -v "\.")
if [ -n "${EXES}" ]; then
rm ${EXES}
fi
)
#! /bin/sh
# Build libzmq.a static library and libzmq.so dynamic library
#
# Usage: makelibzmq
# BUILD_DLL=false makelibzmq # Skip building DLL
#
# NOTE: We do a single compile run for both static and dynamic libraries
# which results in the static library having -Wc,exportall compiled objects;
# in practice this doesn't seem to cause a problem beyond using some extra
# space (around 10%).
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-21
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-22
#---------------------------------------------------------------------------
set -e # Stop on errors
BUILD_DLL="${BUILD_DLL:-true}" # Build DLL by default
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
ZCXX="${BIN_DIR}/zc++"
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRC="${TOP}/src"
# Install pre-generated platform.hpp
cp -p "${BIN_DIR}/platform.hpp" "${SRC}/platform.hpp"
# Compile all the source (optionally ready for a DLL)
if [ "${BUILD_DLL}" = "true" ]; then
ZCXXFLAGS="${ZCXXFLAGS} -Wc,exportall"
export ZCXXFLAGS
#echo "Building DLL with ${ZCXXFLAGS}"
fi
cd "${SRC}"
"${BIN_DIR}/cxxall"
# Make static library
ar r libzmq.a *.o
# Optionally Make dynamic library
if [ "${BUILD_DLL}" = "true" ]; then
#echo "Building libzmq.so DLL"
"${ZCXX}" -Wl,DLL -o libzmq.so *.o
fi
#! /bin/sh
# Build tests/* executables; assumes that libzmq.a or libzmq.so/libzmq.x
# is already built
#
# If libzmq.so and libzmq.x exist, then dynamic linking is used, otherwise
# static linking is used.
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-21
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-22
#---------------------------------------------------------------------------
set -e # Stop on errors
VERBOSE="${VERBOSE:-}" # Set to non-empty for already done status
export VERBOSE
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
# Locate compiler wrapper
ZCXX="${BIN_DIR}/zc++"
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRC="${TOP}/src"
TESTS="${TOP}/tests"
# Figure out how we are going to link to ZMQ
LINK_TYPE=unknown
if [ -f "${SRC}/platform.hpp" -a -f "${SRC}/libzmq.so" -a -f "${SRC}/libzmq.x" ]; then
LINK_TYPE=dynamic
elif [ -f "${SRC}/platform.hpp" -a -f "${SRC}/libzmq.a" ]; then
LINK_TYPE=static
else
echo "Error: run makezmqlib to build libzmq.a and/or libzmq.so/libzmq.x first" >&2
exit 1
fi
# Copy in replacement test with timeout, if main version is not already
# up to date
#
if [ -f "${TESTS}/test_fork.cpp" ] &&
grep "TIMEOUT" "${TESTS}/test_fork.cpp" >/dev/null 2>&1; then
: # Already copied in
else
echo "Updating test_fork.cpp to version with master timeout"
cp -p "${BIN_DIR}/test_fork.cpp" "${TESTS}/test_fork.cpp"
fi
# Compile all the source
if [ "${LINK_TYPE}" = "dynamic" ]; then
ZCXXFLAGS="${ZCXXFLAGS} -Wc,DLL"
export ZXCCFLAGS
echo "Building tests to use DLL: ${ZCXXFLAGS}"
fi
cd "${TESTS}"
"${BIN_DIR}/cxxall"
# Link all the executables that are not already linked
skip() {
OBJ="$1"
EXE="$2"
if [ -n "${VERBOSE}" ]; then
echo "${OBJ} linked to ${EXE}"
fi
}
link() {
OBJ="$1"
EXE="$2"
echo " LD ${EXE}"
case "${LINK_TYPE}" in
static) "${ZCXX}" -L ../src -o "${EXE}" "${OBJ}" -lzmq
;;
dynamic) "${ZCXX}" -o "${EXE}" "${OBJ}" ../src/libzmq.x
;;
*) echo "Do not know how to do ${LINK_TYPE} linking!" 2>&1
exit 1
;;
esac
}
for OBJ in *.o; do
EXE=$(echo "${OBJ}" | sed 's/\.o//;')
if [ -f "${EXE}" ]; then
if [ "${EXE}" -nt "${OBJ}" ]; then
skip "${OBJ}" "${EXE}"
else
link "${OBJ}" "${EXE}"
fi
else
link "${OBJ}" "${EXE}"
fi
done
/* src/platform.hpp. Generated from platform.hpp.in by configure. */
/* src/platform.hpp.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <alloca.h> header file. */
/* #undef HAVE_ALLOCA_H */
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define to 1 if you have the `clock_gettime' function. */
/* #undef HAVE_CLOCK_GETTIME */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
/* Define to 1 if you have the `freeifaddrs' function. */
#define HAVE_FREEIFADDRS 1
/* Define to 1 if you have the `gethrtime' function. */
/* #undef HAVE_GETHRTIME */
/* Define to 1 if you have the `getifaddrs' function. */
#define HAVE_GETIFADDRS 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <ifaddrs.h> header file. */
#define HAVE_IFADDRS_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `iphlpapi' library (-liphlpapi). */
/* #undef HAVE_LIBIPHLPAPI */
/* Define to 1 if you have the `nsl' library (-lnsl). */
/* #undef HAVE_LIBNSL */
/* Define to 1 if you have the `pthread' library (-lpthread). */
/* #undef HAVE_LIBPTHREAD */
/* Define to 1 if you have the `rpcrt4' library (-lrpcrt4). */
/* #undef HAVE_LIBRPCRT4 */
/* Define to 1 if you have the `rt' library (-lrt). */
/* #undef HAVE_LIBRT */
/* Define to 1 if you have the `socket' library (-lsocket). */
/* #undef HAVE_LIBSOCKET */
/* Define to 1 if you have the `sodium' library (-lsodium). */
/* #undef HAVE_LIBSODIUM */
/* Define to 1 if you have the `ws2_32' library (-lws2_32). */
/* #undef HAVE_LIBWS2_32 */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#define HAVE_NETINET_TCP_H 1
/* Define to 1 if you have the `perror' function. */
#define HAVE_PERROR 1
/* Define to 1 if you have the `socket' function. */
#define HAVE_SOCKET 1
/* Define to 1 if stdbool.h conforms to C99. */
/* #undef HAVE_STDBOOL_H */
/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/eventfd.h> header file. */
/* #undef HAVE_SYS_EVENTFD_H */
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define HAVE_SYS_UIO_H 1
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
/* Define to 1 if the system has the type `_Bool'. */
/* #undef HAVE__BOOL */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#define NO_MINUS_C_MINUS_O 1
/* Name of package */
#define PACKAGE "zeromq"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "zeromq-dev@lists.zeromq.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "zeromq"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "zeromq 4.0.4"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "zeromq"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "4.0.4"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
#define VERSION "4.0.4"
/* Force to use mutexes */
/* #undef ZMQ_FORCE_MUTEXES */
/* Have AIX OS */
/* #undef ZMQ_HAVE_AIX */
/* Have Android OS */
/* #undef ZMQ_HAVE_ANDROID */
/* Have Cygwin */
/* #undef ZMQ_HAVE_CYGWIN */
/* Have eventfd extension. */
/* #undef ZMQ_HAVE_EVENTFD */
/* Have FreeBSD OS */
/* #undef ZMQ_HAVE_FREEBSD */
/* Have HPUX OS */
/* #undef ZMQ_HAVE_HPUX */
/* Have ifaddrs.h header. */
#define ZMQ_HAVE_IFADDRS 1
/* Have Linux OS */
/* #undef ZMQ_HAVE_LINUX */
/* Have MinGW32 */
/* #undef ZMQ_HAVE_MINGW32 */
/* Have NetBSD OS */
/* #undef ZMQ_HAVE_NETBSD */
/* Have OpenBSD OS */
/* #undef ZMQ_HAVE_OPENBSD */
/* Have OpenPGM extension */
/* #undef ZMQ_HAVE_OPENPGM */
/* Have DarwinOSX OS */
/* #undef ZMQ_HAVE_OSX */
/* Have QNX Neutrino OS */
/* #undef ZMQ_HAVE_QNXNTO */
/* Whether SOCK_CLOEXEC is defined and functioning. */
/* #undef ZMQ_HAVE_SOCK_CLOEXEC */
/* Have Solaris OS */
/* #undef ZMQ_HAVE_SOLARIS */
/* Whether SO_KEEPALIVE is supported. */
/* #undef ZMQ_HAVE_SO_KEEPALIVE */
/* Whether TCP_KEEPALIVE is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPALIVE */
/* Whether TCP_KEEPCNT is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPCNT */
/* Whether TCP_KEEPIDLE is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPIDLE */
/* Whether TCP_KEEPINTVL is supported. */
/* #undef ZMQ_HAVE_TCP_KEEPINTVL */
/* Have uio.h header. */
#define ZMQ_HAVE_UIO 1
/* Have Windows OS */
/* #undef ZMQ_HAVE_WINDOWS */
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
/* #undef _UINT32_T */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef ssize_t */
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
/* #undef uint32_t */
/* Define to empty if the keyword `volatile' does not work. Warning: valid
code using `volatile' can become incorrect without. Disable with care. */
/* #undef volatile */
/* ---- Special case for z/OS Unix Services: openedition ---- */
#include <pthread.h>
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
#! /bin/sh
# Run ZeroMQ tests, in order. This is extracted from the tests/Makefile
# which won't run as-is because it relies on libtool building things, and
# thus creating various libtool files, which don't work well on z/OS
#
# noinst_PROGRAMS needs to be kept in sync with tests/Makefile.am, as it
# defines the order in which tests are run.
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-19
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-22
#---------------------------------------------------------------------------
set -e # Stop if a test fails
# Test order taken from tests/Makefile.am
noinst_PROGRAMS="test_system
test_pair_inproc
test_pair_tcp
test_reqrep_inproc
test_reqrep_tcp
test_hwm
test_reqrep_device
test_sub_forward
test_invalid_rep
test_msg_flags
test_connect_resolve
test_immediate
test_last_endpoint
test_term_endpoint
test_monitor
test_router_mandatory
test_router_raw_empty
test_probe_router
test_stream
test_disconnect_inproc
test_ctx_options
test_ctx_destroy
test_security_null
test_security_plain
test_security_curve
test_iov
test_spec_req
test_spec_rep
test_spec_dealer
test_spec_router
test_spec_pushpull
test_req_correlate
test_req_relaxed
test_conflate
test_inproc_connect
test_issue_566
test_abstract_ipc
test_many_sockets
test_shutdown_stress
test_pair_ipc
test_reqrep_ipc
test_timeo
test_fork"
if [ -n "${1}" ]; then
TESTS="$*" # Run tests on command line
else
TESTS="${noinst_PROGRAMS}"
fi
# Explanation of tests expected to fail:
# test_abstract_ipc: Relies on Linux-specific IPC functionality
# test_fork: Relies on using pthreads _after_ fork, _before_ exec
#
# (Note: there _must_ be spaces either side of the tests names to match)
XFAIL_TESTS="
test_abstract_ipc
test_fork
"
verbose() {
echo "Starting: $@" >&2
"$@"
}
# Uncomment TESTS_ENVIRONMENT=verbose to see "Starting: TEST" messages
#TESTS_ENVIRONMENT=verbose
TESTS_ENVIRONMENT=
#---------------------------------------------------------------------------
# Change to tests directory if necessary
# Figure out where we are
BIN_DIR=$(dirname $0)
if [ -z "${BIN_DIR}" ]; then BIN_DIR="."; fi
case "${BIN_DIR}" in
.) BIN_DIR="$(pwd)"; ;;
/*) ;;
*) BIN_DIR="$(pwd)/${BIN_DIR}"; ;;
esac
# Locate top of source tree, assuming we're in builds/zos
TOP="${BIN_DIR}/../.."
SRCDIR="${TOP}/src"
TESTDIR="${TOP}/tests"
case "$(pwd)" in
*tests) ;;
*) echo "Changing to ${TESTDIR}"
cd "${TESTDIR}"
;;
esac
if [ -x "test_system" ]; then
:
else
echo "Run makelibzmq and maketests before runtests" >&2
exit 1
fi
# Explicitly add SRCDIR into library serach path, to make sure we
# use our just-built version
LIBPATH="${SRCDIR}:/lib:/usr/lib"
export LIBPATH
#---------------------------------------------------------------------------
# check-TESTS: target from tests/Makefile, converted from Make syntax to
# shell syntax
failed=0; all=0; xfail=0; xpass=0; skip=0;
srcdir=.; export srcdir;
list="${TESTS}";
red=""; grn=""; lgn=""; blu=""; std="";
if test -n "$list"; then
for tst in $list; do
if test -f ./$tst; then dir=./;
elif test -f $tst; then dir=;
else dir="${srcdir}/"; fi;
if ${TESTS_ENVIRONMENT} ${dir}$tst; then
all=`expr $all + 1`;
case " ${XFAIL_TESTS} " in
*"$tst"*)
xpass=`expr $xpass + 1`;
failed=`expr $failed + 1`;
col=$red; res=XPASS;
;;
*)
col=$grn; res=PASS;
;;
esac;
elif test $? -ne 77; then
all=`expr $all + 1`;
case " ${XFAIL_TESTS} " in
*"$tst"*)
xfail=`expr $xfail + 1`;
col=$lgn; res=XFAIL;
;;
*)
failed=`expr $failed + 1`;
col=$red; res=FAIL;
;;
esac;
else
skip=`expr $skip + 1`;
col=$blu; res=SKIP;
fi;
echo "${col}$res${std}: $tst";
done;
if test "$all" -eq 1; then
tests="test";
All="";
else
tests="tests";
All="All ";
fi;
if test "$failed" -eq 0; then
if test "$xfail" -eq 0; then
banner="$All$all $tests passed";
else
if test "$xfail" -eq 1; then failures=failure; else failures=failures; fi;
banner="$All$all $tests behaved as expected ($xfail expected $failures)";
fi;
else
if test "$xpass" -eq 0; then
banner="$failed of $all $tests failed";
else
if test "$xpass" -eq 1; then passes=pass; else passes=passes; fi;
banner="$failed of $all $tests did not behave as expected ($xpass unexpected $passes)";
fi;
fi;
dashes="$banner";
skipped="";
if test "$skip" -ne 0; then
if test "$skip" -eq 1; then
skipped="($skip test was not run)";
else
skipped="($skip tests were not run)";
fi;
test `echo "$skipped" | wc -c` -le `echo "$banner" | wc -c` ||
dashes="$skipped"; \
fi;
report="";
if test "$failed" -ne 0 && test -n "${PACKAGE_BUGREPORT}"; then
report="Please report to ${PACKAGE_BUGREPORT}";
test `echo "$report" | wc -c` -le `echo "$banner" | wc -c` ||
dashes="$report";
fi;
dashes=`echo "$dashes" | sed s/./=/g`;
if test "$failed" -eq 0; then
col="$grn";
else
col="$red";
fi;
echo "${col}$dashes${std}";
echo "${col}$banner${std}";
test -z "$skipped" || echo "${col}$skipped${std}";
test -z "$report" || echo "${col}$report${std}";
echo "${col}$dashes${std}";
test "$failed" -eq 0;
else :; fi
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "testutil.hpp"
#include <unistd.h> // For alarm()
const char *address = "tcp://127.0.0.1:6571";
#define NUM_MESSAGES 5
#define TIMEOUT_SECS 5 // Global timeout
int main (void)
{
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
// Create and bind pull socket to receive messages
void *pull = zmq_socket (ctx, ZMQ_PULL);
assert (pull);
int rc = zmq_bind (pull, address);
assert (rc == 0);
int pid = fork ();
if (pid == 0) {
// Child process
// Immediately close parent sockets and context
zmq_close (pull);
zmq_term (ctx);
// Create new context, socket, connect and send some messages
void *child_ctx = zmq_ctx_new ();
assert (child_ctx);
void *push = zmq_socket (child_ctx, ZMQ_PUSH);
assert (push);
rc = zmq_connect (push, address);
assert (rc == 0);
int count;
for (count = 0; count < NUM_MESSAGES; count++)
zmq_send (push, "Hello", 5, 0);
zmq_close (push);
zmq_ctx_destroy (child_ctx);
exit (0);
}
else {
// Parent process
alarm(TIMEOUT_SECS); // Set upper limit on runtime
int count;
for (count = 0; count < NUM_MESSAGES; count++) {
char buffer [5];
int num_bytes = zmq_recv (pull, buffer, 5, 0);
assert (num_bytes == 5);
}
int child_status;
while (true) {
rc = waitpid (pid, &child_status, 0);
if (rc == -1 && errno == EINTR)
continue;
assert (rc > 0);
// Verify the status code of the child was zero
assert (WEXITSTATUS (child_status) == 0);
break;
}
exit (0);
}
return 0;
}
#! /bin/sh
# Wrapper around IBM C++ compiler to add "-+" to preprocessor calls
# and thus work with C++ in files other than *.C. Also add -Wc,lang(longlong)
# with appropriate quoting to avoid shell confusion -- this is difficult
# to get through both ./configure arguments _and_ Makefile/shell expansion
# safely so more easily added in this wrapper.
#
# Finally, by default will enable xplink for C++ compatibilty and performance
# (c++ standard library requires xplink enabled).
#
# Additional compile/link flags can be passed in as ZCXXFLAGS, eg:
#
# For debug: ZXCCFLAGS=-g ...
#
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-18
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-21
#---------------------------------------------------------------------------
CPPFLAGS="-+"
LONGLONG="-Wc,lang(longlong)"
XPLINK="${XPLINK:--Wc,xplink -Wl,xplink}"
CXX="/bin/c++"
ZCXXFLAGS="${ZCXXFLAGS:-}" # Extra compile/link arguments, eg "-g"
# For debugging calling conventions issues
#echo "Called with: $0 $@" >>/tmp/zc++.log 2>&1
#exec >>/tmp/zc++.log 2>&1
#set -x
case "$1" in
-E) exec "${CXX}" "${CPPFLAGS}" "$@"
;;
-o) exec "${CXX}" ${ZCXXFLAGS} "${LONGLONG}" "${CPPFLAGS}" ${XPLINK} "$@"
;;
-c) exec "${CXX}" ${ZCXXFLAGS} "${LONGLONG}" "${CPPFLAGS}" ${XPLINK} "$@"
;;
-L) # Special case for linking via C++, called from linkall
exec "${CXX}" ${ZCXXFLAGS} ${XPLINK} "$@"
;;
*) exec "${CXX}" ${ZCXXFLAGS} "${LONGLONG}" ${XPLINK} "$@"
;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment