From d678f6a9eaf02d8e4a527fe396097739c4ae814a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 27 Jun 2018 09:44:39 +0200 Subject: torture: Fix building on Windows Signed-off-by: Andreas Schneider (cherry-picked from commit b74a1841) --- tests/torture.c | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/tests/torture.c b/tests/torture.c index 4755cb23..bc43f04e 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -229,6 +229,7 @@ static int verbosity = 0; static const char *pattern = NULL; #ifndef _WIN32 + static int _torture_auth_kbdint(ssh_session session, const char *password) { const char *prompt; @@ -537,7 +538,7 @@ ssh_bind torture_ssh_bind(const char *addr, return sshbind; } -#endif +#endif /* WITH_SERVER */ #ifdef WITH_SFTP @@ -604,25 +605,6 @@ void torture_sftp_close(struct torture_sftp *t) { } #endif /* WITH_SFTP */ -#endif /* _WIN32 */ - -void torture_write_file(const char *filename, const char *data){ - int fd; - int rc; - - assert_non_null(filename); - assert_true(filename[0] != '\0'); - assert_non_null(data); - - fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0600); - assert_true(fd >= 0); - - rc = write(fd, data, strlen(data)); - assert_int_equal(rc, strlen(data)); - - close(fd); -} - static const char *torture_get_testkey_internal(enum ssh_keytypes_e type, int bits, int with_passphrase, @@ -765,7 +747,7 @@ static void torture_setup_create_sshd_config(void **state) #ifndef OPENSSH_VERSION_MAJOR #define OPENSSH_VERSION_MAJOR 7U #define OPENSSH_VERSION_MINOR 0U -#endif +#endif /* OPENSSH_VERSION_MAJOR */ const char config_string[]= "Port 22\n" "ListenAddress 127.0.0.10\n" @@ -788,11 +770,11 @@ static void torture_setup_create_sshd_config(void **state) "HostKeyAlgorithms +ssh-dss\n" # if (OPENSSH_VERSION_MAJOR == 7 && OPENSSH_VERSION_MINOR < 6) "Ciphers +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc\n" -# else +# else /* OPENSSH_VERSION 7.0 - 7.5 */ "Ciphers +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc\n" -# endif +# endif /* OPENSSH_VERSION 7.0 - 7.6 */ "KexAlgorithms +diffie-hellman-group1-sha1" -#else +#else /* OPENSSH_VERSION >= 6.7 */ "Ciphers 3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr," "aes192-ctr,aes256-ctr,aes128-gcm@openssh.com," "aes256-gcm@openssh.com,arcfour128,arcfour256,arcfour," @@ -803,7 +785,7 @@ static void torture_setup_create_sshd_config(void **state) "diffie-hellman-group-exchange-sha1," "diffie-hellman-group14-sha1," "diffie-hellman-group1-sha1\n" -#endif +#endif /* OPENSSH_VERSION >= 6.7 */ "\n" "AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES\n" "AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT\n" @@ -971,6 +953,26 @@ void _torture_filter_tests(UnitTest *tests, size_t ntests){ } } +#endif /* _WIN32 */ + +void torture_write_file(const char *filename, const char *data){ + int fd; + int rc; + + assert_non_null(filename); + assert_true(filename[0] != '\0'); + assert_non_null(data); + + fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0600); + assert_true(fd >= 0); + + rc = write(fd, data, strlen(data)); + assert_int_equal(rc, strlen(data)); + + close(fd); +} + + int main(int argc, char **argv) { struct argument_s arguments; char *env = getenv("LIBSSH_VERBOSITY"); -- cgit v1.2.3