From c0c063f94c3952ded5b84d532dc97e233a6dd968 Mon Sep 17 00:00:00 2001 From: Norbert Pocs Date: Wed, 16 Nov 2022 17:17:14 +0100 Subject: [PATCH] torture_options.c: Add identity test for ssh_options_copy Test if the ssh_options_apply is called on session before ssh_options_copy, then `opts.identity` ssh_list will be copied Signed-off-by: Norbert Pocs Reviewed-by: Jakub Jelen --- tests/unittests/torture_options.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c index 7208ebf9..d86959e0 100644 --- a/tests/unittests/torture_options.c +++ b/tests/unittests/torture_options.c @@ -918,6 +918,34 @@ static void torture_options_copy(void **state) sizeof(session->opts.options_seen)); ssh_free(new); + + /* test if ssh_options_apply was called before ssh_options_copy + * the opts.identity list gets copied (percent expanded list) */ + rv = ssh_options_apply(session); + assert_ssh_return_code(session, rv); + + rv = ssh_options_copy(session, &new); + assert_ssh_return_code(session, rv); + assert_non_null(new); + + it = ssh_list_get_iterator(session->opts.identity_non_exp); + assert_null(it); + it2 = ssh_list_get_iterator(new->opts.identity_non_exp); + assert_null(it2); + + it = ssh_list_get_iterator(session->opts.identity); + assert_non_null(it); + it2 = ssh_list_get_iterator(new->opts.identity); + assert_non_null(it2); + while (it != NULL && it2 != NULL) { + assert_string_equal(it->data, it2->data); + it = it->next; + it2 = it2->next; + } + assert_null(it); + assert_null(it2); + + ssh_free(new); } #define EXECUTABLE_NAME "test-exec"