aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2019-10-19 23:41:06 +0200
committerAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2020-08-13 17:35:09 +0200
commita7c0ccd35e83797351459b4abdfd45f57f7fa337 (patch)
tree95dc9b969dcde8252f2d028cc583fa9fd411b07e
parent9ec692347983907df174f09fe27f4f9dd664fd94 (diff)
downloadlibssh-a7c0ccd35e83797351459b4abdfd45f57f7fa337.tar.gz
libssh-a7c0ccd35e83797351459b4abdfd45f57f7fa337.tar.xz
libssh-a7c0ccd35e83797351459b4abdfd45f57f7fa337.zip
tests: search for netcat binary
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 177e76f7539aa9ba1769c2d46fd91fc776883dbe)
-rw-r--r--tests/client/torture_proxycommand.c17
-rw-r--r--tests/tests_config.h.cmake4
-rw-r--r--tests/torture.h1
3 files changed, 19 insertions, 3 deletions
diff --git a/tests/client/torture_proxycommand.c b/tests/client/torture_proxycommand.c
index 77dd8ade..c04ff2ab 100644
--- a/tests/client/torture_proxycommand.c
+++ b/tests/client/torture_proxycommand.c
@@ -59,6 +59,7 @@ static int session_teardown(void **state)
return 0;
}
+#ifdef NC_EXECUTABLE
static void torture_options_set_proxycommand(void **state)
{
struct torture_state *s = *state;
@@ -70,13 +71,13 @@ static void torture_options_set_proxycommand(void **state)
int rc;
socket_t fd;
- rc = stat("/bin/nc", &sb);
+ rc = stat(NC_EXECUTABLE, &sb);
if (rc != 0 || (sb.st_mode & S_IXOTH) == 0) {
- SSH_LOG(SSH_LOG_WARNING, "Could not find /bin/nc: Skipping the test");
+ SSH_LOG(SSH_LOG_WARNING, "Could not find " NC_EXECUTABLE ": Skipping the test");
skip();
}
- rc = snprintf(command, sizeof(command), "/bin/nc %s %d", address, port);
+ rc = snprintf(command, sizeof(command), NC_EXECUTABLE " %s %d", address, port);
assert_true((size_t)rc < sizeof(command));
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, command);
@@ -89,6 +90,16 @@ static void torture_options_set_proxycommand(void **state)
assert_int_equal(rc & O_RDWR, O_RDWR);
}
+#else /* NC_EXECUTABLE */
+
+static void torture_options_set_proxycommand(void **state)
+{
+ (void) state;
+ skip();
+}
+
+#endif /* NC_EXECUTABLE */
+
static void torture_options_set_proxycommand_notexist(void **state) {
struct torture_state *s = *state;
ssh_session session = s->ssh.session;
diff --git a/tests/tests_config.h.cmake b/tests/tests_config.h.cmake
index 5c727759..ffaff946 100644
--- a/tests/tests_config.h.cmake
+++ b/tests/tests_config.h.cmake
@@ -61,3 +61,7 @@
#cmakedefine OPENSSH_ECDSA_SHA2_NISTP256_CERT_V01_OPENSSH_COM 1
#cmakedefine OPENSSH_ECDSA_SHA2_NISTP384_CERT_V01_OPENSSH_COM 1
#cmakedefine OPENSSH_ECDSA_SHA2_NISTP521_CERT_V01_OPENSSH_COM 1
+
+/* Available programs */
+
+#cmakedefine NC_EXECUTABLE "${NC_EXECUTABLE}"
diff --git a/tests/torture.h b/tests/torture.h
index 1cd52b20..a1dc6208 100644
--- a/tests/torture.h
+++ b/tests/torture.h
@@ -41,6 +41,7 @@
#include <cmocka.h>
#include "torture_cmocka.h"
+#include "tests_config.h"
#ifndef assert_return_code
/* hack for older versions of cmocka */