mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 18:28:10 +09:00
config: glob support for include with test
Signed-off-by: NoName115 <robert.kolcun@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
110da49504
commit
99c5160cb5
@@ -10,6 +10,9 @@
|
||||
#define LIBSSH_TESTCONFIG2 "libssh_testconfig2.tmp"
|
||||
#define LIBSSH_TESTCONFIG3 "libssh_testconfig3.tmp"
|
||||
#define LIBSSH_TESTCONFIG4 "libssh_testconfig4.tmp"
|
||||
#define LIBSSH_TESTCONFIG5 "libssh_testconfig5.tmp"
|
||||
#define LIBSSH_TESTCONFIG6 "libssh_testconfig6.tmp"
|
||||
#define LIBSSH_TESTCONFIGGLOB "libssh_testc*[36].tmp"
|
||||
|
||||
#define USERNAME "testuser"
|
||||
#define PROXYCMD "ssh -q -W %h:%p gateway.example.com"
|
||||
@@ -25,6 +28,8 @@ static int setup_config_files(void **state)
|
||||
unlink(LIBSSH_TESTCONFIG2);
|
||||
unlink(LIBSSH_TESTCONFIG3);
|
||||
unlink(LIBSSH_TESTCONFIG4);
|
||||
unlink(LIBSSH_TESTCONFIG5);
|
||||
unlink(LIBSSH_TESTCONFIG6);
|
||||
|
||||
torture_write_file(LIBSSH_TESTCONFIG1,
|
||||
"User "USERNAME"\nInclude "LIBSSH_TESTCONFIG2"\n\n");
|
||||
@@ -40,6 +45,13 @@ static int setup_config_files(void **state)
|
||||
torture_write_file(LIBSSH_TESTCONFIG4,
|
||||
"Port 123\nPort 456\n");
|
||||
|
||||
/* Testing glob include */
|
||||
torture_write_file(LIBSSH_TESTCONFIG5,
|
||||
"User "USERNAME"\nInclude "LIBSSH_TESTCONFIGGLOB"\n\n");
|
||||
|
||||
torture_write_file(LIBSSH_TESTCONFIG6,
|
||||
"ProxyCommand "PROXYCMD"\n\n");
|
||||
|
||||
session = ssh_new();
|
||||
*state = session;
|
||||
|
||||
@@ -52,6 +64,8 @@ static int teardown(void **state)
|
||||
unlink(LIBSSH_TESTCONFIG2);
|
||||
unlink(LIBSSH_TESTCONFIG3);
|
||||
unlink(LIBSSH_TESTCONFIG4);
|
||||
unlink(LIBSSH_TESTCONFIG5);
|
||||
unlink(LIBSSH_TESTCONFIG6);
|
||||
|
||||
ssh_free(*state);
|
||||
|
||||
@@ -105,6 +119,29 @@ static void torture_config_double_ports(void **state) {
|
||||
assert_true(ret == 0);
|
||||
}
|
||||
|
||||
static void torture_config_glob(void **state) {
|
||||
ssh_session session = *state;
|
||||
int ret;
|
||||
char *v;
|
||||
|
||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG5);
|
||||
assert_true(ret == 0);
|
||||
|
||||
/* Test the variable presence */
|
||||
|
||||
ret = ssh_options_get(session, SSH_OPTIONS_PROXYCOMMAND, &v);
|
||||
assert_true(ret == 0);
|
||||
|
||||
assert_string_equal(v, PROXYCMD);
|
||||
ssh_string_free_char(v);
|
||||
|
||||
ret = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &v);
|
||||
assert_true(ret == 0);
|
||||
|
||||
assert_string_equal(v, ID_FILE);
|
||||
ssh_string_free_char(v);
|
||||
}
|
||||
|
||||
int torture_run_tests(void) {
|
||||
int rc;
|
||||
struct CMUnitTest tests[] = {
|
||||
@@ -114,6 +151,9 @@ int torture_run_tests(void) {
|
||||
cmocka_unit_test_setup_teardown(torture_config_double_ports,
|
||||
setup_config_files,
|
||||
teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_config_glob,
|
||||
setup_config_files,
|
||||
teardown),
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user