[openssh-commits] [openssh] 06/07: upstream: unit test for stringlist_append() and stringlist_free()

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Nov 7 15:14:20 AEDT 2025


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit a1c526f29b47147046f77a0f74097008256396f6
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Thu Nov 6 01:33:26 2025 +0000

    upstream: unit test for stringlist_append() and stringlist_free()
    
    OpenBSD-Regress-ID: a3a4dae538c831b3810f69abc34ad8504dc3c460
---
 regress/unittests/misc/test_misc.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/regress/unittests/misc/test_misc.c b/regress/unittests/misc/test_misc.c
index d175196b7..db0b5bb66 100644
--- a/regress/unittests/misc/test_misc.c
+++ b/regress/unittests/misc/test_misc.c
@@ -373,6 +373,44 @@ test_path_absolute(void)
 	TEST_DONE();
 }
 
+static void
+test_stringlist(void)
+{
+	char **list = NULL;
+
+	TEST_START("stringlist_append initial");
+	stringlist_append(&list, "one");
+	ASSERT_PTR_NE(list, NULL);
+	ASSERT_STRING_EQ(list[0], "one");
+	ASSERT_PTR_EQ(list[1], NULL);
+	TEST_DONE();
+
+	TEST_START("stringlist_append second");
+	stringlist_append(&list, "two");
+	ASSERT_PTR_NE(list, NULL);
+	ASSERT_STRING_EQ(list[0], "one");
+	ASSERT_STRING_EQ(list[1], "two");
+	ASSERT_PTR_EQ(list[2], NULL);
+	TEST_DONE();
+
+	TEST_START("stringlist_append third");
+	stringlist_append(&list, "three");
+	ASSERT_PTR_NE(list, NULL);
+	ASSERT_STRING_EQ(list[0], "one");
+	ASSERT_STRING_EQ(list[1], "two");
+	ASSERT_STRING_EQ(list[2], "three");
+	ASSERT_PTR_EQ(list[3], NULL);
+	TEST_DONE();
+
+	TEST_START("stringlist_free");
+	stringlist_free(list);
+	TEST_DONE();
+
+	TEST_START("stringlist_free NULL");
+	stringlist_free(NULL);
+	TEST_DONE();
+}
+
 static void
 test_skip_space(void)
 {
@@ -432,5 +470,6 @@ test_misc(void)
 	test_tohex();
 	test_lowercase();
 	test_path_absolute();
+	test_stringlist();
 	test_skip_space();
 }

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list