Files
rpi-buildroot/support/testing/tests/package/test_gumbo_parser.py
Raphaël Mélotte f980395994 support/testing: new runtime test for gumbo-parser
The new test requires a br2-external directory because we compile a
small test program on the host and install it on the target, but it's
not useful to have it in the main Buildroot package tree.

The test program loads and parses a sample HTML document. Taking
inspiration from 'examples/get_title.c' in gumbo-parser, it also
searches for the title of the document just to check that we can do
more than the parsing.

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit da23be6338)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
2025-07-03 09:58:54 +02:00

28 lines
934 B
Python

import os
import infra.basetest
class TestGumboParser(infra.basetest.BRTest):
br2_external = [infra.filepath("tests/package/br2-external/gumbo-parser")]
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_PACKAGE_GUMBO_PARSER=y
BR2_PACKAGE_GUMBO_PARSER_TEST=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()
# Run the test program and check output
out, ret = self.emulator.run("/usr/bin/gumbo_test")
self.assertEqual(ret, 0)
self.assertIn("HTML parsing successful", "\n".join(out))
self.assertIn("Found title: Test HTML", "\n".join(out))