From 05128a1f5f17c55a8d8da42c6c52c4235adf36d4 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Thu, 27 Jun 2024 15:05:03 +1200 Subject: [PATCH] cmdline:tests: extend cmdline_burn tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=15674 Signed-off-by: Douglas Bagnall Reviewed-by: Jo Sutton --- lib/cmdline/tests/test_cmdline.c | 32 +++++++++++++++++++++++++------- selftest/knownfail.d/cmdline | 1 + 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 selftest/knownfail.d/cmdline diff --git a/lib/cmdline/tests/test_cmdline.c b/lib/cmdline/tests/test_cmdline.c index 16dd09c63fa..89d93996479 100644 --- a/lib/cmdline/tests/test_cmdline.c +++ b/lib/cmdline/tests/test_cmdline.c @@ -24,6 +24,7 @@ #include #include #include +#include "replace.h" #include "lib/cmdline/cmdline.h" @@ -62,19 +63,36 @@ static void torture_cmdline_sanity_check_bad(void **state) static void torture_cmdline_burn(void **state) { char arg1[] = "-U Administrator%secret"; - char arg2[] = "--user=Administrator%secret"; - char arg3[] = "--user=Administrator%super%secret"; - char arg4[] = "--password=super%secret"; + char arg2[] = "--no-no-no-not-secret=not%secret"; + char arg3[] = "--user=Administrator%secret"; + char arg4[] = "--user=Administrator%super%secret"; + char arg5[] = "--password=super%secret"; + char arg6[] = "--no-no-no-not-secret=not%secret"; + char arg7[] = "-U"; + char arg8[] = "fish%chips"; + char arg9[] = "--password"; + char arg10[] = "fish%chips"; + char arg11[] = "--password2"; + char arg12[] = "fish%chips"; - char *argv[] = { arg1, arg2, arg3, arg4, NULL }; - int argc = 4; + char *argv[] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, + arg9, arg10, arg11, arg12, NULL }; + int argc = ARRAY_SIZE(argv) - 1; samba_cmdline_burn(argc, argv); assert_string_equal(arg1, "-U Administrator"); - assert_string_equal(arg2, "--user=Administrator"); + assert_string_equal(arg2, "--no-no-no-not-secret=not%secret"); assert_string_equal(arg3, "--user=Administrator"); - assert_string_equal(arg4, "--password"); + assert_string_equal(arg4, "--user=Administrator"); + assert_string_equal(arg5, "--password"); + assert_string_equal(arg6, "--no-no-no-not-secret=not%secret"); + assert_string_equal(arg7, "-U"); + assert_string_equal(arg8, "fish"); + assert_string_equal(arg9, "--password"); + assert_string_equal(arg10, ""); + assert_string_equal(arg11, "--password2"); + assert_string_equal(arg12, ""); } int main(int argc, char *argv[]) diff --git a/selftest/knownfail.d/cmdline b/selftest/knownfail.d/cmdline new file mode 100644 index 00000000000..c9e4a86609c --- /dev/null +++ b/selftest/knownfail.d/cmdline @@ -0,0 +1 @@ +^samba.unittests.cmdline.torture_cmdline_burn.none.$