From 34317698b8c024de5c948b6f6058730b1fdbc328 Mon Sep 17 00:00:00 2001 From: Kirill Isakov Date: Mon, 28 Mar 2022 00:08:35 +0600 Subject: [PATCH] Fix building tinc and running tests on Solaris --- meson.build | 4 ++++ src/fd_device.c | 2 -- src/meson.build | 29 ++++++++++++++++++----------- src/solaris/meson.build | 2 ++ test/integration/meson.build | 5 ++++- test/integration/testlib.sh | 17 ++++++++++++++++- 6 files changed, 44 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index 9f55c9e6..f96fb323 100644 --- a/meson.build +++ b/meson.build @@ -34,6 +34,10 @@ os_name = host_machine.system() cc_name = cc.get_id() cc_defs = ['-D_GNU_SOURCE'] +if os_name == 'sunos' + cc_defs += '-D__EXTENSIONS__' +endif + cc_flags = [cc_defs] ld_flags = [] diff --git a/src/fd_device.c b/src/fd_device.c index 6e85be0d..381c7841 100644 --- a/src/fd_device.c +++ b/src/fd_device.c @@ -22,7 +22,6 @@ #include "system.h" -#ifdef HAVE_SYS_UN_H #include #include "conf.h" @@ -240,4 +239,3 @@ const devops_t fd_devops = { .read = read_packet, .write = write_packet, }; -#endif diff --git a/src/meson.build b/src/meson.build index 3eb4bc45..43f70bfa 100644 --- a/src/meson.build +++ b/src/meson.build @@ -46,17 +46,20 @@ check_headers = [ 'sys/stat.h', 'sys/time.h', 'sys/types.h', - 'sys/un.h', 'sys/wait.h', 'syslog.h', 'termios.h', ] +# 'struct msghdr' misses some required fields +if os_name != 'sunos' + check_headers += 'sys/un.h' +endif + check_functions = [ 'asprintf', 'daemon', 'fchmod', - 'fork', 'gettimeofday', 'mlockall', 'putenv', @@ -64,6 +67,11 @@ check_functions = [ 'unsetenv', ] +# Broken definition, fails to link +if os_name != 'windows' + check_functions += 'fork' +endif + check_types = [ 'struct arphdr', 'struct ether_arp', @@ -115,7 +123,6 @@ src_tincd = [ 'dummy_device.c', 'edge.c', 'event.c', - 'fd_device.c', 'graph.c', 'meta.c', 'multicast_device.c', @@ -160,6 +167,10 @@ foreach h : check_headers endif endforeach +if cdata.has('HAVE_SYS_UN_H') + src_tincd += 'fd_device.c' +endif + confdata = configuration_data() confdata.merge_from(cdata) configure_file(output: 'meson_config.h', configuration: confdata) @@ -170,14 +181,10 @@ have_prefix = ''' '''.format(build_root, meson.current_source_dir()) foreach f : check_functions - if f == 'fork' and os_name == 'windows' - message('MinGW does not have correct definition for fork()') - else - if cc.has_function(f, prefix: have_prefix, args: cc_defs) - cdata.set('HAVE_' + f.to_upper(), - 1, - description: 'function ' + f) - endif + if cc.has_function(f, prefix: have_prefix, args: cc_defs) + cdata.set('HAVE_' + f.to_upper(), + 1, + description: 'function ' + f) endif endforeach diff --git a/src/solaris/meson.build b/src/solaris/meson.build index f657428b..5d071ff7 100644 --- a/src/solaris/meson.build +++ b/src/solaris/meson.build @@ -1,2 +1,4 @@ src_tincd += files('device.c') +deps_common += cc.find_library('libsocket') + diff --git a/test/integration/meson.build b/test/integration/meson.build index 1c3b9ea1..ef33b085 100644 --- a/test/integration/meson.build +++ b/test/integration/meson.build @@ -6,7 +6,6 @@ tests = [ 'invite-join.test', 'invite-offline.test', 'invite-tinc-up.test', - 'scripts.test', 'security.test', 'variables.test', ] @@ -24,6 +23,10 @@ if os_name == 'linux' tests += 'ns-ping.test' endif +if os_name != 'sunos' + tests += 'scripts.test' +endif + exe_splice = executable( 'splice', sources: 'splice.c', diff --git a/test/integration/testlib.sh b/test/integration/testlib.sh index 3d0f990b..4c99f3be 100644 --- a/test/integration/testlib.sh +++ b/test/integration/testlib.sh @@ -45,6 +45,21 @@ DIR_BAZ=$(realdir "$PWD/$net3") # Register helper functions +if [ "$(uname -s)" = SunOS ]; then + gnu=/usr/gnu/bin + grep="$gnu/grep" + + grep() { $gnu/grep "$@"; } + tail() { $gnu/tail "$@"; } + + if ! tail /dev/null || ! echo '' | grep ''; then + echo >&2 'Sorry, native Solaris tools are not supported. Please install GNU Coreutils.' + exit $EXIT_SKIP_TEST + fi +else + grep='grep' +fi + # Alias gtimeout to timeout if it exists. if type gtimeout >/dev/null; then timeout() { gtimeout "$@"; } @@ -361,7 +376,7 @@ wait_script() { new_line=$( sh -c " - grep -n -m $count '^$script,' <'$fifo' + $grep -n -m $count '^$script,' <'$fifo' " | awk -F: 'END { print $1 }' ) -- 2.20.1