]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: wget: add a test case for validating URI
authorSughosh Ganu <sughosh.ganu@linaro.org>
Thu, 3 Jul 2025 06:43:08 +0000 (12:13 +0530)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Thu, 3 Jul 2025 08:34:20 +0000 (11:34 +0300)
The wget module has a function wget_validate_uri() which is used for
validating the URI to be used by wget. Add a basic test case for this
function.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
test/cmd/wget.c

index 445750660c28550e888954693147461c42b062c2..1005392b952ec4248824aa3124c5a3ac659a809d 100644 (file)
@@ -241,3 +241,23 @@ static int net_test_wget(struct unit_test_state *uts)
        return 0;
 }
 CMD_TEST(net_test_wget, UTF_CONSOLE);
+
+static int net_test_wget_uri_validate(struct unit_test_state *uts)
+{
+       ut_asserteq(true, wget_validate_uri("http://foo.com/bar.html"));
+       ut_asserteq(true, wget_validate_uri("http://1.1.2.3/bar.html"));
+       ut_asserteq(false, wget_validate_uri("http://foo/ba r.html"));
+       ut_asserteq(false, wget_validate_uri("http://"));
+
+       if (CONFIG_IS_ENABLED(WGET_HTTPS)) {
+               ut_asserteq(true,
+                           wget_validate_uri("https://foo.com/bar.html"));
+               ut_asserteq(true,
+                           wget_validate_uri("https://1.1.2.3/bar.html"));
+               ut_asserteq(false, wget_validate_uri("https://foo/ba r.html"));
+               ut_asserteq(false, wget_validate_uri("https://"));
+       }
+
+       return 0;
+}
+CMD_TEST(net_test_wget_uri_validate, UTF_CONSOLE);