upstream: memory leaks in unit tests
OpenBSD-Regress-ID: af11ac7b8034b99ca324af4dae1ef5cd7700b273
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: test_expand.c,v 1.3 2021/12/14 21:25:27 deraadt Exp $ */
|
||||
/* $OpenBSD: test_expand.c,v 1.4 2025/09/15 03:00:22 djm Exp $ */
|
||||
/*
|
||||
* Regress test for misc string expansion functions.
|
||||
*
|
||||
@@ -71,17 +71,26 @@ test_expand(void)
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("percent_expand");
|
||||
ASSERT_STRING_EQ(percent_expand("%%", "%h", "foo", NULL), "%");
|
||||
ASSERT_STRING_EQ(percent_expand("%h", "h", "foo", NULL), "foo");
|
||||
ASSERT_STRING_EQ(percent_expand("%h ", "h", "foo", NULL), "foo ");
|
||||
ASSERT_STRING_EQ(percent_expand(" %h", "h", "foo", NULL), " foo");
|
||||
ASSERT_STRING_EQ(percent_expand(" %h ", "h", "foo", NULL), " foo ");
|
||||
ASSERT_STRING_EQ(percent_expand(" %a%b ", "a", "foo", "b", "bar", NULL),
|
||||
" foobar ");
|
||||
#define CHECK_ONE(val, expect) \
|
||||
ASSERT_STRING_EQ(val, expect); \
|
||||
free(val);
|
||||
ret = percent_expand("%%", "%h", "foo", NULL);
|
||||
CHECK_ONE(ret, "%");
|
||||
ret = percent_expand("%h", "h", "foo", NULL);
|
||||
CHECK_ONE(ret, "foo");
|
||||
ret = percent_expand("%h ", "h", "foo", NULL);
|
||||
CHECK_ONE(ret, "foo ");
|
||||
ret = percent_expand(" %h", "h", "foo", NULL);
|
||||
CHECK_ONE(ret, " foo");
|
||||
ret = percent_expand(" %h ", "h", "foo", NULL);
|
||||
CHECK_ONE(ret, " foo ");
|
||||
ret = percent_expand(" %a%b ", "a", "foo", "b", "bar", NULL);
|
||||
CHECK_ONE(ret, " foobar ");
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("percent_dollar_expand");
|
||||
ASSERT_STRING_EQ(percent_dollar_expand("%h${FOO}", "h", "foo", NULL),
|
||||
"foobar");
|
||||
ret = percent_dollar_expand("%h${FOO}", "h", "foo", NULL);
|
||||
CHECK_ONE(ret, "foobar");
|
||||
#undef CHECK_ONE
|
||||
TEST_DONE();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: test_sshbuf_getput_basic.c,v 1.4 2025/06/13 07:35:14 dtucker Exp $ */
|
||||
/* $OpenBSD: test_sshbuf_getput_basic.c,v 1.5 2025/09/15 03:00:22 djm Exp $ */
|
||||
/*
|
||||
* Regress test for sshbuf.h buffer API
|
||||
*
|
||||
@@ -609,6 +609,7 @@ sshbuf_getput_basic_tests(void)
|
||||
ASSERT_PTR_NE(s2, NULL);
|
||||
ASSERT_STRING_EQ(s2, "00000000000000000000");
|
||||
sshbuf_free(p1);
|
||||
free(s2);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("sshbuf_poke_u16");
|
||||
@@ -643,6 +644,7 @@ sshbuf_getput_basic_tests(void)
|
||||
ASSERT_PTR_NE(s2, NULL);
|
||||
ASSERT_STRING_EQ(s2, "00000000000000000000");
|
||||
sshbuf_free(p1);
|
||||
free(s2);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("sshbuf_poke_u8");
|
||||
@@ -673,6 +675,7 @@ sshbuf_getput_basic_tests(void)
|
||||
ASSERT_PTR_NE(s2, NULL);
|
||||
ASSERT_STRING_EQ(s2, "00000000000000000000");
|
||||
sshbuf_free(p1);
|
||||
free(s2);
|
||||
TEST_DONE();
|
||||
|
||||
TEST_START("sshbuf_poke");
|
||||
@@ -707,5 +710,6 @@ sshbuf_getput_basic_tests(void)
|
||||
ASSERT_PTR_NE(s2, NULL);
|
||||
ASSERT_STRING_EQ(s2, "00000000000000000000");
|
||||
sshbuf_free(p1);
|
||||
free(s2);
|
||||
TEST_DONE();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: test_sshbuf_misc.c,v 1.6 2025/09/04 00:37:10 djm Exp $ */
|
||||
/* $OpenBSD: test_sshbuf_misc.c,v 1.7 2025/09/15 03:00:22 djm Exp $ */
|
||||
/*
|
||||
* Regress test for sshbuf.h buffer API
|
||||
*
|
||||
@@ -214,6 +214,7 @@ test_sshbuf_cmp(void)
|
||||
ASSERT_INT_EQ(sshbuf_cmp(p1, 1000, "silence", 7),
|
||||
SSH_ERR_MESSAGE_INCOMPLETE);
|
||||
ASSERT_INT_EQ(sshbuf_cmp(p1, 0, msg, sizeof(msg) - 1), 0);
|
||||
sshbuf_free(p1);
|
||||
TEST_DONE();
|
||||
}
|
||||
|
||||
@@ -252,6 +253,7 @@ test_sshbuf_find(void)
|
||||
SSH_ERR_MESSAGE_INCOMPLETE);
|
||||
ASSERT_INT_EQ(sshbuf_find(p1, 0, msg + 1, sizeof(msg) - 2, &sz), 0);
|
||||
ASSERT_SIZE_T_EQ(sz, 1);
|
||||
sshbuf_free(p1);
|
||||
TEST_DONE();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user