mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-15 18:38:00 +08:00
Merge pull request #89 from ewen-naos-nz/zos
z/OS UNIX System Services port
This commit is contained in:
commit
37203c4964
426
builds/zos/README.md
Normal file
426
builds/zos/README.md
Normal file
@ -0,0 +1,426 @@
|
||||
# ZeroMQ on z/OS UNIX System Services
|
||||
|
||||
ZeroMQ has been successfully built on z/OS, using [z/OS UNIX System
|
||||
Services](http://www-03.ibm.com/systems/z/os/zos/features/unix/),
|
||||
a certified UNIX environment for the [IBM
|
||||
z-series](http://www-03.ibm.com/systems/z/). The build is possible
|
||||
with the shell scripts in this directory, as described below.
|
||||
|
||||
Tested build combinations:
|
||||
|
||||
* ZeroMQ 4.0.4, using IBM XL C/C++ compiler, as XPLINK in ILP32 mode
|
||||
|
||||
* ZeroMQ 4.0.4, using IBM XL C/C++ compiler, as XPLINK in LP64 mode
|
||||
|
||||
Other combinations are likely to work, possibly with minor changes,
|
||||
but have not been tested. Both static library and DLL modes have been
|
||||
tested.
|
||||
|
||||
There are some minor limitations (detailed below), but all core
|
||||
functionality tests run successfully.
|
||||
|
||||
|
||||
## Quickstart: building ZeroMQ on z/OS UNIX System Services
|
||||
|
||||
Assuming [z/OS UNIX System
|
||||
Services](http://www-03.ibm.com/systems/z/os/zos/features/unix/) is
|
||||
installed, and the [z/OS XL C/C++
|
||||
compiler suite](http://www-03.ibm.com/software/products/en/czos) is
|
||||
installed, ZeroMQ can be built as follows:
|
||||
|
||||
* Download and extract ZeroMQ tar file
|
||||
|
||||
* Ensure contents of this directory are present at `builds/zos`
|
||||
within that extracted diretory (eg, `zeromq-VERSION/builds/zos/`;
|
||||
copy these files in, if not already present, and make sure the
|
||||
shell scripts are executable)
|
||||
|
||||
* (Optional) set ZCXXFLAGS for additional compile flags (see below)
|
||||
|
||||
* Build `libzmq.a` static library and `libzmq.so` dynamic
|
||||
library, with:
|
||||
|
||||
cd zeromq-VERSION
|
||||
builds/zos/makelibzmq
|
||||
|
||||
or to skip the `libzmq.so` dynamic library (only building `libzmq.a`):
|
||||
|
||||
cd zeromq-VERSION
|
||||
BUILD_DLL=false
|
||||
export BUILD_DLL
|
||||
builds/zos/makelibzmq
|
||||
|
||||
* (Optional, but recommended) build and run the core tests with:
|
||||
|
||||
cd zeromq-VERSION
|
||||
builds/zos/maketests
|
||||
builds/zos/runtests
|
||||
|
||||
* To remove built files, to start again (eg, rebuild with different
|
||||
compile/link flags):
|
||||
|
||||
cd zeromq-VERSION
|
||||
builds/zos/makeclean
|
||||
|
||||
There are details on specifying alternative compilation flags below.
|
||||
|
||||
|
||||
## Quickstart: using ZeroMQ on z/OS UNIX System Services
|
||||
|
||||
### Static linking
|
||||
|
||||
Install `include/*.h` somewhere on your compiler include path.
|
||||
|
||||
Install `src/libzmq.a` somewhere on your library search path.
|
||||
|
||||
Compile and link application with:
|
||||
|
||||
c++ -Wc,xplink -Wl,xplink ... -+ -o myprog myprog.cpp -lzmq
|
||||
|
||||
Run with:
|
||||
|
||||
./myprog
|
||||
|
||||
|
||||
### Dynamic linking
|
||||
|
||||
Install `include/*.h` somewhere on your compiler include path.
|
||||
|
||||
Install `src/libzmq.so` somewhere on your LIBPATH.
|
||||
|
||||
Install `src/libzmq.x` somewhere you can reference for import linking.
|
||||
|
||||
Compile and link application:
|
||||
|
||||
c++ -Wc,xplink -Wc,dll ... -+ -c -o myprog.o myprog.cpp
|
||||
c++ -Wl,xplink -o myprog myprog.o /PATH/TO/libzmq.x
|
||||
|
||||
Run with:
|
||||
|
||||
LIBPATH=/DIR/OF/LIBZMQ.SO:/lib:/usr/lib:... # if not in default path
|
||||
export LIBPATH
|
||||
./myprog
|
||||
|
||||
|
||||
## ZeroMQ on z/OS UNIX System Services: Application considerations
|
||||
|
||||
z/0S UNIX System Services does not provide a way to block the
|
||||
[`SIGPIPE` signal being generated when a thread writes to a closed socket](http://pic.dhe.ibm.com/infocenter/zvm/v6r2/index.jsp?topic=%2Fcom.ibm.zos.r12.cbcpx01%2Fcbcpg1b0287.htm)
|
||||
(compare with other platforms that support the `SO_NOSIGPIPE` socket
|
||||
option, and/or the `MSG_NOSIGNAL` flag on `send()`; z/OS UNIX System
|
||||
Services supports neither).
|
||||
|
||||
As a result, applications using ZeroMQ on z/OS UNIX System Services
|
||||
have to expect to encounter `SIGPIPE` at various times during the use
|
||||
of the library, if sockets are unexpectedly disconnected. Normally
|
||||
`SIGPIPE` will terminate the application.
|
||||
|
||||
A simple solution, if `SIGPIPE` is not required for normal operation
|
||||
of the application (eg, it is not part of a unix pipeline, the
|
||||
traditional use of `SIGPIPE`), is to set `SIGPIPE` to be ignored
|
||||
with code like:
|
||||
|
||||
#include <signal.h>
|
||||
...
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
near the start of the application (eg, before initialising the ZeroMQ
|
||||
library).
|
||||
|
||||
If `SIGPIPE` is required for normal operation it is recommended that
|
||||
the application install a signal handler that flags the signal was
|
||||
received, and allows the application main loop to determine if it
|
||||
was received for one of its own file descriptors -- and ignores it if it
|
||||
none of the applications own file descriptors seems to have changed.
|
||||
|
||||
Linking to the `libzmq.a` static library will pull in substantially
|
||||
all of the library code, which will add about 4MB to the application
|
||||
size (per executable statically linked with ZeroMQ). If this is a
|
||||
significant consideration, use of the DLL version is recommended.
|
||||
|
||||
See also ZeroMQ test status on z/OS UNIX System Services below
|
||||
for other caveats.
|
||||
|
||||
|
||||
## Setting other compilation flags
|
||||
|
||||
### Optimisation
|
||||
|
||||
To build with optimisation:
|
||||
|
||||
* set `ZCXXFLAGS` to "`-O2`" before starting build process above
|
||||
|
||||
|
||||
### Full debugging symbols
|
||||
|
||||
To build with debugging symbols:
|
||||
|
||||
* set `ZCXXFLAGS` to "`-g`" before starting build process above
|
||||
|
||||
### 64-bit mode (LP64/amode=64)
|
||||
|
||||
To build in 64-bit mode:
|
||||
|
||||
The default build is
|
||||
[ILP32](http://publib.boulder.ibm.com/infocenter/zvm/v6r1/index.jsp?topic=/com.ibm.zos.r9.cbcux01/lp64cop.htm),
|
||||
the default for the IBM XL C/C++ compiler. To build in LP64 mode
|
||||
(64-bit):
|
||||
|
||||
* set `ZCXXFLAGS` to "`-Wc,lp64 -Wl,lp64`" before starting build
|
||||
|
||||
(64-bit mode can be combined with optimisation or debug symbols.)
|
||||
|
||||
### Combining compilation flags
|
||||
|
||||
Other build flags can be used in `ZXCCFLAGS` if desired. Beware that
|
||||
they are passed through (Bourne) shell expansion, and passed to both
|
||||
the compile and link stages; some experimentation of argument quoting
|
||||
may be required (and arguments requiring parenthesis are particularly
|
||||
complicated).
|
||||
|
||||
|
||||
## ZeroMQ test status on z/OS UNIX System Services
|
||||
|
||||
As of 2014-07-22, 41 of the 43 tests in the core ZeroMQ test suite
|
||||
pass. There are two tests that are expected to fail:
|
||||
|
||||
0. `test_abstract_ipc`: tests Linux-specific IPC functions, and is
|
||||
expected to fail on non-Linux platforms.
|
||||
|
||||
0. `test_fork`: tests ability to use ZeroMQ both before *and* after
|
||||
fork (and before exec()); this relies on the ability to use
|
||||
pthreads both before *and* after fork. On z/OS (and some other
|
||||
UNIX compliant platforms) functions like `pthreads_create` (used
|
||||
by ZeroMQ) cannot be used after fork and before exec; on z/OS the
|
||||
call after fork fails with `ELEMULTITHREADFORK` (errno=257) if
|
||||
ZeroMQ was also used before fork. (On z/OS it appears possible
|
||||
to use z/OS *after* fork, *providing* it has not been used before
|
||||
fork -- the problem is the two separate initialisations of the
|
||||
threading library, before and after fork, attempting to mix
|
||||
together.) In practice this is unlikely to affect many real-world
|
||||
programs -- most programs use threads or fork without exec, but
|
||||
not both.
|
||||
|
||||
These two "expected to fail" tests are listed as XFAIL_TESTS, and
|
||||
`runtests` will still consider the test run successful when they fail
|
||||
as expected.
|
||||
|
||||
In addition `test_security_curve` does not do any meaningful testing,
|
||||
as a result of the CURVE support not being compiled in; it requires
|
||||
[`libsodium`](http://doc.libsodium.org/), which has not been
|
||||
ported to z/OS UNIX System Services yet.
|
||||
|
||||
Multicast (via `libpgm`) is also not ported or compiled in.
|
||||
|
||||
|
||||
## ZeroMQ on z/OS UNIX System Services: Library portability notes
|
||||
|
||||
### *.cpp
|
||||
|
||||
The source code in ZeroMQ is a combination of a C++ core library
|
||||
(in `*.cpp` and `*.hpp` files), and a C wrapper (also in `*.cpp`
|
||||
files). It is all compiled with the C++ compiler. The IBM XL C/C++
|
||||
complier (at least the version used for initial porting) insists
|
||||
that C++ source be in `*.C` files (note capital C). To work around
|
||||
this issue the compile flag `-+` is used (specified in the `zc++`
|
||||
compiler wrapper), which tells the compiler the file should be
|
||||
considered C++ despite the file extension.
|
||||
|
||||
### XPLINK
|
||||
|
||||
The library (and tests) are built in
|
||||
[XPLINK](http://www.redbooks.ibm.com/abstracts/sg245991.html) mode
|
||||
with the flags `-Wc,xplink -Wl,xplink` (specified in the `zc++`
|
||||
compiler wrapper). This is [recommended by IBM for C++
|
||||
code](http://publib.boulder.ibm.com/infocenter/zvm/v5r4/index.jsp?topic=/com.ibm.zos.r9.ceea200/xplrunt.htm)
|
||||
due to the small functions. (Amongst other things, using XPLINK
|
||||
enables function calls with some arguments passed in registers.)
|
||||
|
||||
### long long
|
||||
|
||||
ZeroMQ makes use of `uint64_t` (which is `unsigned long long` in ILP32
|
||||
mode). To enable this the compile flag `-Wc,lang(longlong)` is passed
|
||||
to enable `long long`. This is passed from the `zc++` compiler wrapper
|
||||
in order to be able to specifically quote the argument to protect the
|
||||
parentheses from shell expansion.
|
||||
|
||||
### BSD-style sockets, with IPv6 support
|
||||
|
||||
ZeroMQ uses BSD-style socket handling, with extensions to support IPv6.
|
||||
BSD-style sockets were merged into SysV-derived UNIX at least a decade
|
||||
ago, and are required as part of the X/Open Portability Guide at least
|
||||
as of XPG 4.2. To access this functionality two feature macros are
|
||||
defined:
|
||||
|
||||
_XOPEN_SOURCE_EXTENDED=1
|
||||
|
||||
_OPEN_SYS_SOCK_IPV6
|
||||
|
||||
The first enables the XPG 4.2 features (including functionality like
|
||||
`getsockname()`), and the latter exposes IPv6 specific functionality
|
||||
like `sa_family_t`. These flags are defined in the `cxxall` script.
|
||||
|
||||
(The traditional BSD-sockets API, exposed with `_OE_SOCKETS` cannot
|
||||
be used because it does not support functions like `getsockname()`,
|
||||
nor does it support IPv6 -- and the API definitions prevent compiling
|
||||
in LP64 mode due to assumptions about long being 32 bits. Using
|
||||
`_XOPEN_SOURCE_EXTENDED=1` avoids all these problems.)
|
||||
|
||||
### pthreads
|
||||
|
||||
ZeroMQ uses the pthreads library to create additional threads to handle
|
||||
background communication without blocking the main application. This
|
||||
functionaity is enabled on z/OS UNIX System Services by defining:
|
||||
|
||||
_OPEN_THREADS=3
|
||||
|
||||
which is done in the `cxxall` script. (The "3" value exposes later
|
||||
pthreads functionality like `pthread_atfork`, although ZeroMQ does not
|
||||
currently use all these features.)
|
||||
|
||||
|
||||
## `platform.hpp` on z/OS UNIX System Services
|
||||
|
||||
The build (described above) on z/OS UNIX System Services uses a static
|
||||
pre-built `platform.hpp` file. (By default `src/platform.hpp` is
|
||||
dynamically generated as a result of running the `./configure` script.)
|
||||
The master version of this is in `builds/zos/platform.hpp`.
|
||||
|
||||
The pre-built file is used because z/OS does not have the GNU auto tools
|
||||
(`automake`, `autoconf`, `libtool`, etc) installed, and particularly the
|
||||
libtool replacement does not work properly with the IBM XL C/C++
|
||||
compiler.
|
||||
|
||||
The `./configure` script (only supplied in the tarballs); built with
|
||||
`automake` and `autoconf` on another platform), with one small edit,
|
||||
was used to generate the z/OS `platform.hpp` and then two small changes
|
||||
(described below) were made by hand to the generated `platform.hpp`.
|
||||
|
||||
To be able to run the ./configure script to completion (in tcsh
|
||||
syntax):
|
||||
|
||||
* Edit `./configure` and add:
|
||||
|
||||
openedition)
|
||||
;;
|
||||
|
||||
immediately before the line:
|
||||
|
||||
as_fn_error $? "unsupported system: ${host_os}." "$LINENO" 5
|
||||
|
||||
(somewhere around 17637). This avoids the configure script giving
|
||||
up early because `openedition` is not recognised.
|
||||
|
||||
* set `CXX` to point that the full path to the `builds/zos/zc++` wrapper, eg
|
||||
|
||||
setenv CXX "/u/0mq/zeromq-4.0.4/builds/zos/zc++"
|
||||
|
||||
* set `CPPFLAGS` to for the feature macros required, eg:
|
||||
|
||||
setenv CPPFLAGS "-D_XOPEN_SOURCE_EXTENDED=1 -D_OPEN_THREADS=3 -D_OPEN_SYS_SOCK_IPV6"
|
||||
|
||||
* set `CXXFLAGS` to enable XPLINK:
|
||||
|
||||
setenv CXXFLAGS "-Wc,xplink -Wl,xplink -+"
|
||||
|
||||
* run configure script with `--disable-eventfd` (`sys/eventfd.h` does
|
||||
not exist, but the test for its existance has a false positive on
|
||||
z/OS UNIX System Services, apparently due to the way the `c++`
|
||||
compiler wrapper passes errors back from the IBM XL C/C++ compiler), viz:
|
||||
|
||||
./configure --disable-eventfd
|
||||
|
||||
All going well several Makefiles, and `src/platform.hpp` should be
|
||||
produced. Two additional changes are required to `src/platform.hpp`
|
||||
which can be appended to the end:
|
||||
|
||||
/* ---- Special case for z/OS Unix Services: openedition ---- */
|
||||
#include <pthread.h>
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 1025
|
||||
#endif
|
||||
|
||||
(many includes require pthreads-related methods or data structures to
|
||||
be defined, but not all of them include `pthread.h`, and the value
|
||||
`NI_MAXHOST` is not defined on z/OS UNIX System Services -- the 1025
|
||||
value is the conventional value on other platforms).
|
||||
|
||||
Having done this the Makefiles can be used to compile individual files
|
||||
if desired, eg:
|
||||
|
||||
cd src
|
||||
make zmq.o
|
||||
|
||||
but note:
|
||||
|
||||
* IBM Make will warn of duplicate prerequisites on *every* run of
|
||||
`make`, and both the generated `src/Makefile` and `tests/Makefile`
|
||||
have several duplicates. (For `src/Makefile` edit
|
||||
`libzmq_la_SOURCES` to remove the duplicates.)
|
||||
|
||||
* IBM Make does not understand the `@` prefix (eg, `@echo`) as a way
|
||||
to avoid echoing the command, resulting in an error and the command
|
||||
being echoed anyway.
|
||||
|
||||
* Many of the make targets result in GNU auto tools (`aclocal`, etc)
|
||||
being invoked, which are likely to fail, and most of the
|
||||
library-related targets will invoke `libtool` which will cause
|
||||
compile failures (due to differences in expected arguments).
|
||||
|
||||
However running `./configure` to regenerate `src/platform.hpp` may
|
||||
be useful for later versions of ZeroMQ which add more feature tests.
|
||||
|
||||
|
||||
## Transferring from GitHub to z/OS UNIX System Services
|
||||
|
||||
The process of transferring files from GitHub to z/OS UNIX System
|
||||
Services is somewhat convoluted because:
|
||||
|
||||
* There is not a port of git for z/OS UNIX System Services; and
|
||||
|
||||
* z/OS uses the EBCDIC (IBM-1047) character set rather than the
|
||||
ASCII/ISO-8859-1 character set used by the ZeroMQ source code
|
||||
on GitHub
|
||||
|
||||
A workable transfer process is:
|
||||
|
||||
* On an ASCII/ISO-8859-1/UTF-8 system with `git` (eg, a Linux system):
|
||||
|
||||
git clone https://github.com/zeromq/libzmq.git
|
||||
git archive --prefix=libzmq-git/ -o /var/tmp/libzmq-git.tar master
|
||||
|
||||
* On a ASCII/ISO-8859-1/UTF-8 system with `tar`, and `pax`, and
|
||||
optionally the GNU auto tools (eg, the same Linux system):
|
||||
|
||||
mkdir /var/tmp/zos
|
||||
cd /var/tmp/zos
|
||||
tar -xpf /var/tmp/libzmq-git.tar
|
||||
cd libzmq-git
|
||||
./autogen.sh # Optional: to be able to run ./configure
|
||||
cd ..
|
||||
pax -wf /var/tmp/libzmq-git.pax libzmq-git
|
||||
compress libzmq-git.pax # If available, reduce transfer size
|
||||
|
||||
* Transfer the resulting file (`libzmq-git.pax` or `libzmq-git.pax.Z`)
|
||||
to the z/OS UNIX System Services system. If using FTP be sure to
|
||||
transfer the file in `bin` (binary/Image) mode to avoid corruption.
|
||||
|
||||
* On the z/OS UNIX System Services system, unpack the `pax` file and
|
||||
convert all the files to EBCDIC with:
|
||||
|
||||
pax -o from=iso8859-1 -pp -rvf libzmq-git-2014-07-23.pax
|
||||
|
||||
or if the file was compressed:
|
||||
|
||||
pax -o from=iso8859-1 -pp -rvzf libzmq-git-2014-07-23.pax.Z
|
||||
|
||||
The result should be a `libzmq-git` directory with the source in
|
||||
EBCDIC format, on the z/OS UNIX System Services system ready to start
|
||||
building.
|
||||
|
||||
See also the [`pax` man
|
||||
page](http://pic.dhe.ibm.com/infocenter/zos/v1r13/index.jsp?topic=%2Fcom.ibm.zos.r13.bpxa500%2Fr4paxsh.htm),
|
||||
some [`pax` conversion
|
||||
examples](http://pic.dhe.ibm.com/infocenter/zos/v1r13/index.jsp?topic=%2Fcom.ibm.zos.r13.bpxa400%2Fbpxza4c0291.htm),
|
||||
and [IBM's advice on ASCII to EBCDIC conversion
|
||||
options](http://www-03.ibm.com/systems/z/os/zos/features/unix/bpxa1p03.html)
|
62
builds/zos/cxxall
Executable file
62
builds/zos/cxxall
Executable file
@ -0,0 +1,62 @@
|
||||
#! /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
|
36
builds/zos/makeclean
Executable file
36
builds/zos/makeclean
Executable file
@ -0,0 +1,36 @@
|
||||
#! /bin/sh
|
||||
# Remove built object files and test executables
|
||||
#
|
||||
# Written by Ewen McNeill <ewen@imatix.com>, 2014-07-22
|
||||
# Updated by Ewen McNeill <ewen@imatix.com>, 2014-07-24
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
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 *.so libzmq)
|
||||
|
||||
# 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
|
||||
)
|
54
builds/zos/makelibzmq
Executable file
54
builds/zos/makelibzmq
Executable file
@ -0,0 +1,54 @@
|
||||
#! /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
|
102
builds/zos/maketests
Executable file
102
builds/zos/maketests
Executable file
@ -0,0 +1,102 @@
|
||||
#! /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
|
277
builds/zos/platform.hpp
Normal file
277
builds/zos/platform.hpp
Normal file
@ -0,0 +1,277 @@
|
||||
/* 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
|
216
builds/zos/runtests
Executable file
216
builds/zos/runtests
Executable file
@ -0,0 +1,216 @@
|
||||
#! /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
|
85
builds/zos/test_fork.cpp
Normal file
85
builds/zos/test_fork.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
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;
|
||||
}
|
42
builds/zos/zc++
Executable file
42
builds/zos/zc++
Executable file
@ -0,0 +1,42 @@
|
||||
#! /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
|
@ -77,6 +77,55 @@
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#if !defined (ZMQ_HAVE_WINDOWS)
|
||||
// Helper to sleep for specific number of milliseconds (or until signal)
|
||||
//
|
||||
static int sleep_ms (unsigned int ms_)
|
||||
{
|
||||
if (ms_ == 0)
|
||||
return 0;
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
Sleep (ms_ > 0 ? ms_ : INFINITE);
|
||||
return 0;
|
||||
#elif defined ZMQ_HAVE_ANDROID
|
||||
usleep (ms_ * 1000);
|
||||
return 0;
|
||||
#else
|
||||
return usleep (ms_ * 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper to wait on close(), for non-blocking sockets, until it completes
|
||||
// If EAGAIN is received, will sleep briefly (1-100ms) then try again, until
|
||||
// the overall timeout is reached.
|
||||
//
|
||||
static int close_wait_ms (int fd_, unsigned int max_ms_ = 2000)
|
||||
{
|
||||
unsigned int ms_so_far = 0;
|
||||
unsigned int step_ms = max_ms_ / 10;
|
||||
if (step_ms < 1)
|
||||
step_ms = 1;
|
||||
|
||||
if (step_ms > 100)
|
||||
step_ms = 100;
|
||||
|
||||
int rc = 0; // do not sleep on first attempt
|
||||
|
||||
do
|
||||
{
|
||||
if (rc == -1 && errno == EAGAIN)
|
||||
{
|
||||
sleep_ms (step_ms);
|
||||
ms_so_far += step_ms;
|
||||
}
|
||||
|
||||
rc = close (fd_);
|
||||
} while (ms_so_far < max_ms_ && rc == -1 && errno == EAGAIN);
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
zmq::signaler_t::signaler_t ()
|
||||
{
|
||||
// Create the socketpair for signaling.
|
||||
@ -92,7 +141,7 @@ zmq::signaler_t::signaler_t ()
|
||||
zmq::signaler_t::~signaler_t ()
|
||||
{
|
||||
#if defined ZMQ_HAVE_EVENTFD
|
||||
int rc = close (r);
|
||||
int rc = close_wait_ms (r);
|
||||
errno_assert (rc == 0);
|
||||
#elif defined ZMQ_HAVE_WINDOWS
|
||||
struct linger so_linger = { 1, 0 };
|
||||
@ -104,9 +153,9 @@ zmq::signaler_t::~signaler_t ()
|
||||
rc = closesocket (r);
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
#else
|
||||
int rc = close (w);
|
||||
int rc = close_wait_ms (w);
|
||||
errno_assert (rc == 0);
|
||||
rc = close (r);
|
||||
rc = close_wait_ms (r);
|
||||
errno_assert (rc == 0);
|
||||
#endif
|
||||
}
|
||||
|
@ -262,6 +262,11 @@ void setup_test_environment()
|
||||
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
|
||||
# endif
|
||||
#endif
|
||||
#if defined __MVS__
|
||||
// z/OS UNIX System Services: Ignore SIGPIPE during test runs, as a
|
||||
// workaround for no SO_NOGSIGPIPE socket option.
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Provide portable millisecond sleep
|
||||
|
Loading…
x
Reference in New Issue
Block a user