mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
torture_options: Add tests for incorrect number parsing options
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
4e1b0e269f
commit
543f3cba7d
@@ -316,6 +316,7 @@ static void torture_options_set_port(void **state) {
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PORT_STR, "five");
|
||||
assert_true(rc == -1);
|
||||
assert_int_not_equal(session->opts.port, 0);
|
||||
|
||||
rc = ssh_options_set(session, SSH_OPTIONS_PORT, NULL);
|
||||
assert_true(rc == -1);
|
||||
@@ -1480,6 +1481,26 @@ static void torture_options_apply (void **state) {
|
||||
ssh_list_free(awaited_list);
|
||||
}
|
||||
|
||||
static void torture_options_set_verbosity (void **state)
|
||||
{
|
||||
ssh_session session = *state;
|
||||
int rc, new_level;
|
||||
|
||||
rc = ssh_options_set(session,
|
||||
SSH_OPTIONS_LOG_VERBOSITY_STR,
|
||||
"3");
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
new_level = ssh_get_log_level();
|
||||
assert_int_equal(new_level, SSH_LOG_PACKET);
|
||||
|
||||
rc = ssh_options_set(session,
|
||||
SSH_OPTIONS_LOG_VERBOSITY_STR,
|
||||
"datsun");
|
||||
assert_int_equal(rc, -1);
|
||||
new_level = ssh_get_log_level();
|
||||
assert_int_not_equal(new_level, 0);
|
||||
}
|
||||
|
||||
#ifdef WITH_SERVER
|
||||
const char template[] = "temp_dir_XXXXXX";
|
||||
|
||||
@@ -1711,6 +1732,10 @@ static void torture_bind_options_bindport_str(void **state)
|
||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDPORT_STR, "23");
|
||||
assert_int_equal(rc, 0);
|
||||
assert_int_equal(bind->bindport, 23);
|
||||
|
||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDPORT_STR, "twentythree");
|
||||
assert_int_equal(rc, -1);
|
||||
assert_int_not_equal(bind->bindport, 0);
|
||||
}
|
||||
|
||||
static void torture_bind_options_log_verbosity(void **state)
|
||||
@@ -1760,6 +1785,11 @@ static void torture_bind_options_log_verbosity_str(void **state)
|
||||
new_level = ssh_get_log_level();
|
||||
assert_int_equal(new_level, SSH_LOG_PACKET);
|
||||
|
||||
rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "verbosity");
|
||||
assert_int_equal(rc, -1);
|
||||
new_level = ssh_get_log_level();
|
||||
assert_int_not_equal(new_level, 0);
|
||||
|
||||
rc = ssh_set_log_level(previous_level);
|
||||
assert_int_equal(rc, SSH_OK);
|
||||
}
|
||||
@@ -2236,6 +2266,7 @@ int torture_run_tests(void) {
|
||||
cmocka_unit_test_setup_teardown(torture_options_caret_sign,
|
||||
setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_options_apply, setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_options_set_verbosity, setup, teardown),
|
||||
};
|
||||
|
||||
#ifdef WITH_SERVER
|
||||
|
||||
Reference in New Issue
Block a user