All of lore.kernel.org
 help / color / mirror / Atom feed
From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: buildroot@buildroot.org
Cc: Angelo Compagnucci <angelo.compagnucci@gmail.com>,
	Julien Olivain <ju.o@free.fr>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	James Hilliard <james.hilliard1@gmail.com>,
	Fiona Klute <fiona.klute@gmx.de>
Subject: [Buildroot] [PATCH v3 6/6] support/testing: add python-web2py runtime test
Date: Thu, 19 Nov 2026 10:56:29 +0100	[thread overview]
Message-ID: <20261119095629.1990220-6-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <20261119095629.1990220-1-angelo.compagnucci@gmail.com>

The test boots a system where S51web2py starts web2py, then logs in to
the admin application:

- with a wrong password, which must fail;
- with the password set in the configuration, which must succeed: the
  admin application then redirects to its site page.

This checks the admin password generated at build time.

Then it checks the init script: a second start must find the running
server, and nothing must answer once the service is stopped.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v2 -> v3:
  - new patch

 DEVELOPERS                                    |  1 +
 .../tests/package/test_python_web2py.py       | 61 +++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 support/testing/tests/package/test_python_web2py.py

diff --git a/DEVELOPERS b/DEVELOPERS
index e4c7e494cd..4e267125b1 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -266,6 +266,7 @@ F:	package/sshguard/
 F:	package/sunwait/
 F:	package/sysdig/
 F:	package/uthash/
+F:	support/testing/tests/package/test_python_web2py.py
 
 N:	Andy Shevchenko <andy.shevchenko@gmail.com>
 F:	package/fb-test-app/
diff --git a/support/testing/tests/package/test_python_web2py.py b/support/testing/tests/package/test_python_web2py.py
new file mode 100644
index 0000000000..f6f65c8cf7
--- /dev/null
+++ b/support/testing/tests/package/test_python_web2py.py
@@ -0,0 +1,61 @@
+import os
+import time
+
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Web2py(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_WEB2PY=y
+        BR2_PACKAGE_PYTHON_WEB2PY_PASSWORD="buildroot"
+        BR2_TARGET_ROOTFS_EXT2=y
+        BR2_TARGET_ROOTFS_EXT2_SIZE="200M"
+        """
+    timeout = 120
+
+    # The root filesystem is too big for an initramfs
+    def login(self):
+        ext2_file = os.path.join(self.builddir, "images", "rootfs.ext2")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-drive", "file=%s,if=scsi,format=raw" % ext2_file],
+                           kernel_cmdline=["rootwait", "root=/dev/sda"])
+        self.emulator.login()
+
+    # The admin application redirects to its site page once logged in.
+    def login_admin(self, password):
+        cmd = "wget -S -O /dev/null --post-data 'password=%s' " % password
+        cmd += "http://127.0.0.1:8000/admin/default/index 2>&1"
+        output, _ = self.emulator.run(cmd, timeout=self.timeout)
+        return any("Location: /admin/default/site" in line for line in output)
+
+    def test_run(self):
+        self.login()
+
+        # S51web2py starts web2py at boot: wait for it to answer.
+        for attempt in range(60):
+            cmd = "wget -q -O /dev/null http://127.0.0.1:8000/admin/default/index"
+            _, exit_code = self.emulator.run(cmd, timeout=self.timeout)
+            if exit_code == 0:
+                break
+            time.sleep(2)
+        else:
+            self.fail("Timeout while waiting for web2py")
+
+        self.assertFalse(self.login_admin("wrong"))
+        self.assertTrue(self.login_admin("buildroot"))
+
+        # A second start must find the running server.
+        _, exit_code = self.emulator.run("/etc/init.d/S51web2py start")
+        self.assertNotEqual(exit_code, 0)
+
+        # Stop the service: nothing answers anymore.
+        _, exit_code = self.emulator.run("/etc/init.d/S51web2py stop",
+                                         timeout=self.timeout)
+        self.assertEqual(exit_code, 0)
+        cmd = "wget -q -O /dev/null http://127.0.0.1:8000/admin/default/index"
+        _, exit_code = self.emulator.run(cmd, timeout=self.timeout)
+        self.assertNotEqual(exit_code, 0)
-- 
2.53.0

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

      parent reply	other threads:[~2026-11-19  9:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 11:53 [Buildroot] [PATCH] package/python-web2py: bump to version 3.3.3 Angelo Compagnucci
2026-10-30 20:26 ` Julien Olivain via buildroot
2026-10-31 14:36 ` [Buildroot] [PATCH v2 0/2] " Angelo Compagnucci
2026-10-31 14:36   ` [Buildroot] [PATCH v2 1/2] package/python-rocket3: new package Angelo Compagnucci
2026-10-31 14:36   ` [Buildroot] [PATCH v2 2/2] package/python-web2py: bump to version 3.3.3 Angelo Compagnucci
2026-11-19  9:56   ` [Buildroot] [PATCH v3 1/6] package/python-web2py: keep the admin password at boot Angelo Compagnucci
2026-11-19  9:56     ` [Buildroot] [PATCH v3 2/6] package/python-rocket3: new package Angelo Compagnucci
2026-11-19  9:56     ` [Buildroot] [PATCH v3 3/6] package/python-pydal: bump to version 20261107.0 Angelo Compagnucci
2026-11-19  9:56     ` [Buildroot] [PATCH v3 4/6] package/python-web2py: security bump to version 3.4.1 Angelo Compagnucci
2026-11-19  9:56     ` [Buildroot] [PATCH v3 5/6] package/python-web2py: rework the init script Angelo Compagnucci
2026-11-19  9:56     ` Angelo Compagnucci [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119095629.1990220-6-angelo.compagnucci@gmail.com \
    --to=angelo.compagnucci@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=fiona.klute@gmx.de \
    --cc=james.hilliard1@gmail.com \
    --cc=ju.o@free.fr \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.