[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] tests: Add port option to torture_ssh_session


Signed-off-by: Alan Dunn <amdunn@xxxxxxxxx>
---
 tests/client/torture_forward.c     |    2 +-
 tests/client/torture_request_env.c |    2 +-
 tests/client/torture_sftp_dir.c    |    2 +-
 tests/client/torture_sftp_read.c   |    2 +-
 tests/torture.c                    |    7 +++++++
 tests/torture.h                    |    1 +
 6 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/client/torture_forward.c b/tests/client/torture_forward.c
index 5754386..0ffeae0 100644
--- a/tests/client/torture_forward.c
+++ b/tests/client/torture_forward.c
@@ -39,7 +39,7 @@ static void setup(void **state)
     user = getenv("TORTURE_USER");
     password = getenv("TORTURE_PASSWORD");
 
-    session = torture_ssh_session(host, user, password);
+    session = torture_ssh_session(host, NULL, user, password);
 
     assert_non_null(session);
     *state = session;
diff --git a/tests/client/torture_request_env.c b/tests/client/torture_request_env.c
index 7c7338e..fc3843d 100644
--- a/tests/client/torture_request_env.c
+++ b/tests/client/torture_request_env.c
@@ -39,7 +39,7 @@ static void setup(void **state)
     user = getenv("TORTURE_USER");
     password = getenv("TORTURE_PASSWORD");
 
-    session = torture_ssh_session(host, user, password);
+    session = torture_ssh_session(host, NULL, user, password);
 
     assert_false(session == NULL);
     *state = session;
diff --git a/tests/client/torture_sftp_dir.c b/tests/client/torture_sftp_dir.c
index 8d2bcda..b2e3fa3 100644
--- a/tests/client/torture_sftp_dir.c
+++ b/tests/client/torture_sftp_dir.c
@@ -18,7 +18,7 @@ static void setup(void **state) {
     user = getenv("TORTURE_USER");
     password = getenv("TORTURE_PASSWORD");
 
-    session = torture_ssh_session(host, user, password);
+    session = torture_ssh_session(host, NULL, user, password);
     assert_false(session == NULL);
     t = torture_sftp_session(session);
     assert_false(t == NULL);
diff --git a/tests/client/torture_sftp_read.c b/tests/client/torture_sftp_read.c
index 1e40e2c..dac5ef7 100644
--- a/tests/client/torture_sftp_read.c
+++ b/tests/client/torture_sftp_read.c
@@ -20,7 +20,7 @@ static void setup(void **state) {
     user = getenv("TORTURE_USER");
     password = getenv("TORTURE_PASSWORD");
 
-    session = torture_ssh_session(host, user, password);
+    session = torture_ssh_session(host, NULL, user, password);
     assert_false(session == NULL);
     t = torture_sftp_session(session);
     assert_false(t == NULL);
diff --git a/tests/torture.c b/tests/torture.c
index 38e4e56..fb4707a 100644
--- a/tests/torture.c
+++ b/tests/torture.c
@@ -157,6 +157,7 @@ int torture_isdir(const char *path) {
 }
 
 ssh_session torture_ssh_session(const char *host,
+                                const unsigned int *port,
                                 const char *user,
                                 const char *password) {
     ssh_session session;
@@ -176,6 +177,12 @@ ssh_session torture_ssh_session(const char *host,
         goto failed;
     }
 
+    if (port != NULL) {
+      if (ssh_options_set(session, SSH_OPTIONS_PORT, port) < 0) {
+        goto failed;
+      }
+    }
+
     if (user != NULL) {
         if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) {
             goto failed;
diff --git a/tests/torture.h b/tests/torture.h
index 7571306..fb7ac5a 100644
--- a/tests/torture.h
+++ b/tests/torture.h
@@ -62,6 +62,7 @@ int torture_isdir(const char *path);
 int torture_libssh_verbosity(void);
 
 ssh_session torture_ssh_session(const char *host,
+                                const unsigned int *port,
                                 const char *user,
                                 const char *password);
 
-- 
1.7.9.5


References:
[PATCH 0/4] Fix incorrectly passed X11 request screen numberAlan Dunn <amdunn@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org