1
1
libssh/tests/client/torture_proxycommand.c
Aris Adamantiadis d42a1a35b0 tests: allow conditionnal execution on pattern
Option can be used to filter out irrelevant tests
usage: ./torture_pki '*ed25519'

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 17:34:15 +01:00

59 строки
1.4 KiB
C

#define LIBSSH_STATIC
#include "torture.h"
#include <libssh/libssh.h>
#include "libssh/priv.h"
static void setup(void **state) {
ssh_session session = ssh_new();
*state = session;
}
static void teardown(void **state) {
ssh_free(*state);
}
static void torture_options_set_proxycommand(void **state) {
ssh_session session = *state;
int rc;
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
assert_true(rc == 0);
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "nc localhost 22");
assert_true(rc == 0);
rc = ssh_connect(session);
assert_true(rc == SSH_OK);
}
static void torture_options_set_proxycommand_notexist(void **state) {
ssh_session session = *state;
int rc;
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
assert_true(rc == 0);
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "this_command_does_not_exist");
assert_true(rc == SSH_OK);
rc = ssh_connect(session);
assert_true(rc == SSH_ERROR);
}
int torture_run_tests(void) {
int rc;
UnitTest tests[] = {
unit_test_setup_teardown(torture_options_set_proxycommand, setup, teardown),
unit_test_setup_teardown(torture_options_set_proxycommand_notexist, setup, teardown),
};
ssh_init();
torture_filter_tests(tests);
rc = run_tests(tests);
ssh_finalize();
return rc;
}