Skip to content

Commit bbcc79d

Browse files
committed
Problem: tests don't build on Windows
There were numerous small issues with test cases: - some lacked the right source file header - some were not portable at all - some were using internal libzmq APIs (headers) Solution: fixed and cleaned up.
1 parent 06acd76 commit bbcc79d

17 files changed

+125
-78
lines changed

builds/gyp/project.gyp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
'conditions': [
2222
[ 'OS=="win"', {
2323
'defines': [
24-
'ZMQ_HAVE_WINDOWS=1'
24+
'ZMQ_HAVE_WINDOWS=1',
25+
'ZMQ_STATIC'
26+
],
27+
'libraries': [
28+
'ws2_32',
29+
'advapi32',
30+
'iphlpapi'
2531
]
2632
}],
2733
[ 'OS=="mac"', {

tests/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ If you must write non-portable code, wrap it in #ifdefs to ensure it will compil
88

99
Note that testutil.hpp includes platform.h. Do not include it yourself as it changes location depending on the build system and OS.
1010

11+
All sources must contain the correct header. Please copy from test_system.cpp if you're not certain.
12+
1113

tests/test_connect_delay_tipc.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@
2727
along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
*/
2929

30-
#include "../include/zmq.h"
31-
#include <errno.h>
32-
#include <stdlib.h>
33-
#include <string.h>
34-
#include <unistd.h>
35-
#include <string>
36-
37-
#undef NDEBUG
38-
#include <assert.h>
39-
4030
#include "testutil.hpp"
4131

4232
int main (void)

tests/test_pair_tipc.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Copyright (c) 2010-2011 250bpm s.r.o.
3-
Copyright (c) 2011 iMatix Corporation
4-
Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
2+
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
53
64
This file is part of libzmq, the ZeroMQ core engine in C++.
75

tests/test_reqrep_device_tipc.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Copyright (c) 2010-2011 250bpm s.r.o.
3-
Copyright (c) 2011 VMware, Inc.
4-
Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
2+
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
53
64
This file is part of libzmq, the ZeroMQ core engine in C++.
75
@@ -29,12 +27,7 @@
2927
along with this program. If not, see <http://www.gnu.org/licenses/>.
3028
*/
3129

32-
#include "../include/zmq.h"
33-
#include <stdio.h>
34-
#include <string.h>
35-
36-
#undef NDEBUG
37-
#include <assert.h>
30+
#include "testutil.hpp"
3831

3932
int main (void)
4033
{

tests/test_reqrep_tipc.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Copyright (c) 2010-2011 250bpm s.r.o.
3-
Copyright (c) 2011 iMatix Corporation
4-
Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
2+
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
53
64
This file is part of libzmq, the ZeroMQ core engine in C++.
75
@@ -29,7 +27,6 @@
2927
along with this program. If not, see <http://www.gnu.org/licenses/>.
3028
*/
3129

32-
#include <stdio.h>
3330
#include "testutil.hpp"
3431

3532
int main (void)

tests/test_router_mandatory_hwm.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
*/
2929

30-
#include <stdio.h>
3130
#include "testutil.hpp"
32-
#include <unistd.h>
3331

3432
// DEBUG shouldn't be defined in sources as it will cause a redefined symbol
3533
// error when it is defined in the build configuration. It appears that the

tests/test_router_mandatory_tipc.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Copyright (c) 2010-2011 250bpm s.r.o.
3-
Copyright (c) 2011 iMatix Corporation
4-
Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
2+
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
53
64
This file is part of libzmq, the ZeroMQ core engine in C++.
75

tests/test_setsockopt.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
/*
2+
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
3+
4+
This file is part of libzmq, the ZeroMQ core engine in C++.
5+
6+
libzmq is free software; you can redistribute it and/or modify it under
7+
the terms of the GNU Lesser General Public License (LGPL) as published
8+
by the Free Software Foundation; either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
As a special exception, the Contributors give you permission to link
12+
this library with independent modules to produce an executable,
13+
regardless of the license terms of these independent modules, and to
14+
copy and distribute the resulting executable under terms of your choice,
15+
provided that you also meet, for each linked independent module, the
16+
terms and conditions of the license of that module. An independent
17+
module is a module which is not derived from or based on this library.
18+
If you modify this library, you must extend this exception to your
19+
version of the library.
20+
21+
libzmq is distributed in the hope that it will be useful, but WITHOUT
22+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24+
License for more details.
25+
26+
You should have received a copy of the GNU Lesser General Public License
27+
along with this program. If not, see <http://www.gnu.org/licenses/>.
28+
*/
29+
130
#include "testutil.hpp"
231

332
void test_setsockopt_tcp_recv_buffer (void)

tests/test_shutdown_stress_tipc.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/*
2-
Copyright (c) 2010-2011 250bpm s.r.o.
3-
Copyright (c) 2011 iMatix Corporation
4-
Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
2+
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
53
64
This file is part of libzmq, the ZeroMQ core engine in C++.
75
@@ -29,13 +27,7 @@
2927
along with this program. If not, see <http://www.gnu.org/licenses/>.
3028
*/
3129

32-
#include "../include/zmq.h"
33-
#include <pthread.h>
34-
#include <stddef.h>
35-
#include <stdio.h>
36-
37-
#undef NDEBUG
38-
#include <assert.h>
30+
#include "testutil.hpp"
3931

4032
#define THREAD_COUNT 100
4133

0 commit comments

Comments
 (0)