All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing: test_squid: new runtime test
@ 2026-09-06 21:52 Julien Olivain via buildroot
  2026-09-18 21:52 ` Thomas Petazzoni via buildroot
  2026-09-25 14:43 ` Raphaël Mélotte via buildroot
  0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain via buildroot @ 2026-09-06 21:52 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested in:
https://gitlab.com/jolivain/buildroot/-/jobs/16334532501
---
 DEVELOPERS                                  |  1 +
 support/testing/tests/package/test_squid.py | 66 +++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 support/testing/tests/package/test_squid.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 1fd93b1de5..5b88bb445a 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2042,6 +2042,7 @@ F:	support/testing/tests/package/test_sed.py
 F:	support/testing/tests/package/test_socat.py
 F:	support/testing/tests/package/test_sox.py
 F:	support/testing/tests/package/test_sqlite.py
+F:	support/testing/tests/package/test_squid.py
 F:	support/testing/tests/package/test_strace.py
 F:	support/testing/tests/package/test_stress_ng.py
 F:	support/testing/tests/package/test_swipl.py
diff --git a/support/testing/tests/package/test_squid.py b/support/testing/tests/package/test_squid.py
new file mode 100644
index 0000000000..02593b13e9
--- /dev/null
+++ b/support/testing/tests/package/test_squid.py
@@ -0,0 +1,66 @@
+import os
+import time
+
+import infra.basetest
+
+
+class TestSquid(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+        BR2_PACKAGE_LIGHTTPD=y
+        BR2_PACKAGE_SQUID=y
+        BR2_PACKAGE_WGET=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        msg = "Hello Buildroot!"
+        fname = "file.txt"
+
+        # We check the program can run.
+        self.assertRunOk("squid --version")
+
+        # We create a file to serve over http.
+        self.assertRunOk(f"echo '{msg}' > /var/www/{fname}")
+
+        # We download the test file through the proxy.
+        proxy = "http://127.0.0.1:3128"
+        url = f"http://localhost/{fname}"
+        cmd = f"wget --progress=dot -e http_proxy={proxy} {url}"
+        # The squid server can take some time to start. Depending the
+        # load of the test controller, this can take a variable amount
+        # of time. We attempt several time before failing.
+        for attempt in range(15):
+            time.sleep(5)
+
+            _, ret = self.emulator.run(cmd)
+            if ret == 0:
+                break
+            # wget exit with status code 4 in case of a network error.
+            # Since we are waiting for the proxy server to be ready,
+            # we only expect this kind of error. We fail for other
+            # types of error.
+            self.assertEqual(ret, 4)
+        else:
+            self.fail("Timeout while waiting for squid to be ready.")
+
+        # We check the downloaded file has the expected content.
+        cmd = f"cat {fname}"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], msg)
+
+        # We also check the squid proxy logged the access.
+        cmd = "cat /var/log/squid/access.log"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        log_str = f"GET {url}"
+        self.assertIn(log_str, "\n".join(out))
-- 
2.55.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-25 14:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-06 21:52 [Buildroot] [PATCH 1/1] support/testing: test_squid: new runtime test Julien Olivain via buildroot
2026-09-18 21:52 ` Thomas Petazzoni via buildroot
2026-09-25 14:43 ` Raphaël Mélotte via buildroot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.