diff --git a/server/tcp_server.c b/server/tcp_server.c index a4532f93..7ba55bf1 100644 --- a/server/tcp_server.c +++ b/server/tcp_server.c @@ -146,6 +146,11 @@ run_tcp_server(fko_srv_options_t *opts) log_msg(LOG_ERR, "run_tcp_server: bind() failed: %s", strerror(errno)); close(s_sock); + + /* In the case of code coverage, don't die on bind() fail, as netcat may be running */ +#if CODE_COVERAGE + return 0; +#endif return -1; } diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index 71d09164..5ef8d9bc 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -2882,6 +2882,25 @@ sub spa_cycle() { return $rv; } +sub tcp_spa_cycle() { + my $test_hr = shift; + + my ($rv, $server_was_stopped, $fw_rule_created, $fw_rule_removed) + = &client_server_interaction($test_hr, [], $USE_CLIENT); + if (!$rv) { + $rv = 1; + #start netcat listening on tcp/62201 + system("nc -k -l 62201 > /dev/null 2>&1 &"); + my ($rv, $server_was_stopped, $fw_rule_created, $fw_rule_removed) + = &client_server_interaction($test_hr, [], $USE_CLIENT); + + #stop netcat + system("killall nc"); +} + $rv = 0 unless &process_output_matches($test_hr); + + return $rv; +} sub iptables_no_flush_init_exit() { my $test_hr = shift; diff --git a/test/tests/rijndael.pl b/test/tests/rijndael.pl index a7d780e8..e2bed6a0 100644 --- a/test/tests/rijndael.pl +++ b/test/tests/rijndael.pl @@ -599,7 +599,7 @@ 'category' => 'Rijndael', 'subcategory' => 'client+server', 'detail' => "SPA over TCP connection", - 'function' => \&spa_cycle, + 'function' => \&tcp_spa_cycle, 'cmdline' => "$default_client_args -P tcp", 'fwknopd_cmdline' => "$fwknopdCmd -c $cf{'tcp_server'} -a $cf{'def_access'} " . "-d $default_digest_file -p $default_pid_file $intf_str",