-/* $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.
*
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();
}
-/* $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
*
ASSERT_PTR_NE(s2, NULL);
ASSERT_STRING_EQ(s2, "00000000000000000000");
sshbuf_free(p1);
+ free(s2);
TEST_DONE();
TEST_START("sshbuf_poke_u16");
ASSERT_PTR_NE(s2, NULL);
ASSERT_STRING_EQ(s2, "00000000000000000000");
sshbuf_free(p1);
+ free(s2);
TEST_DONE();
TEST_START("sshbuf_poke_u8");
ASSERT_PTR_NE(s2, NULL);
ASSERT_STRING_EQ(s2, "00000000000000000000");
sshbuf_free(p1);
+ free(s2);
TEST_DONE();
TEST_START("sshbuf_poke");
ASSERT_PTR_NE(s2, NULL);
ASSERT_STRING_EQ(s2, "00000000000000000000");
sshbuf_free(p1);
+ free(s2);
TEST_DONE();
}
-/* $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
*
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();
}
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();
}