support/testing: add unbound runtime test
Signed-off-by: Julien Olivain <ju.o@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> (cherry picked from commit 04c91340ffefbfd7d4293e6e0b5e40a0e10c48b8) Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
parent
fa022fc4df
commit
f93225071a
@ -1879,6 +1879,8 @@ F: support/testing/tests/package/test_tesseract_ocr.py
|
||||
F: support/testing/tests/package/test_thttpd.py
|
||||
F: support/testing/tests/package/test_trace_cmd.py
|
||||
F: support/testing/tests/package/test_trace_cmd/
|
||||
F: support/testing/tests/package/test_unbound.py
|
||||
F: support/testing/tests/package/test_unbound/
|
||||
F: support/testing/tests/package/test_usbutils.py
|
||||
F: support/testing/tests/package/test_usbutils/
|
||||
F: support/testing/tests/package/test_weston.py
|
||||
|
79
support/testing/tests/package/test_unbound.py
Normal file
79
support/testing/tests/package/test_unbound.py
Normal file
@ -0,0 +1,79 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestUnbound(infra.basetest.BRTest):
|
||||
rootfs_overlay = \
|
||||
infra.filepath("tests/package/test_unbound/rootfs-overlay")
|
||||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
|
||||
f"""
|
||||
BR2_PACKAGE_UNBOUND=y
|
||||
BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
|
||||
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()
|
||||
|
||||
# Check the program can execute.
|
||||
self.assertRunOk("unbound -V")
|
||||
|
||||
# Verify that the configuration checker validates our file.
|
||||
self.assertRunOk("unbound-checkconf")
|
||||
|
||||
# Our test configuration enabled the unbound remote
|
||||
# control. The unbound server is supposed to be started by the
|
||||
# sysv initscript. We should see the already running server.
|
||||
out, ret = self.emulator.run("unbound-control status")
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertRegex("\n".join(out), r"unbound \(pid \d+\) is running")
|
||||
|
||||
# We check the "unbound-host" program is working with a simple
|
||||
# query. Note: this local query succeed even if the unbound
|
||||
# server is not running. We are only testing this program
|
||||
# here. The server side will be tested with the BusyBox
|
||||
# "nslookup" applet.
|
||||
out, ret = self.emulator.run("unbound-host -t A localhost.")
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertEqual(out[0], "localhost. has address 127.0.0.1")
|
||||
|
||||
# We test few other "unbound-control" commands.
|
||||
self.assertRunOk("unbound-control stats")
|
||||
self.assertRunOk("unbound-control list_local_zones")
|
||||
|
||||
# We check we see our test IPv4 address record.
|
||||
cmd = "nslookup -type=A somehost.buildroot.test."
|
||||
out, ret = self.emulator.run(cmd)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertIn("Address: 10.20.30.40", out)
|
||||
|
||||
# We also check we see our reverse record.
|
||||
cmd = "nslookup 10.20.30.40"
|
||||
out, ret = self.emulator.run(cmd)
|
||||
self.assertEqual(ret, 0)
|
||||
expected = "40.30.20.10.in-addr.arpa\tname = somehost.buildroot.test"
|
||||
self.assertIn(expected, out)
|
||||
|
||||
# We check we see our test text record.
|
||||
cmd = "nslookup -type=TXT sometext.buildroot.test."
|
||||
out, ret = self.emulator.run(cmd)
|
||||
self.assertEqual(ret, 0)
|
||||
expected = "sometext.buildroot.test\ttext = \"Hello Buildroot TXT\""
|
||||
self.assertIn(expected, out)
|
||||
|
||||
# We add a new record with unbound-control.
|
||||
record_data = "someotherhost.buildroot.test. IN A 10.99.99.99"
|
||||
cmd = f"unbound-control local_data \"{record_data}\""
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
# We check we see our new IPv4 address record.
|
||||
cmd = "nslookup -type=A someotherhost.buildroot.test."
|
||||
out, ret = self.emulator.run(cmd)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertIn("Address: 10.99.99.99", out)
|
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Unbound configuration file for Buildroot runtime test.
|
||||
#
|
||||
|
||||
server:
|
||||
do-ip6: no
|
||||
local-zone: "test." nodefault
|
||||
local-zone: "10.in-addr.arpa." nodefault
|
||||
private-domain: "buildroot.test"
|
||||
local-zone: "buildroot.test" static
|
||||
local-data: "somehost.buildroot.test. IN A 10.20.30.40"
|
||||
local-data: 'sometext.buildroot.test. TXT "Hello Buildroot TXT"'
|
||||
local-data-ptr: "10.20.30.40 somehost.buildroot.test"
|
||||
|
||||
remote-control:
|
||||
control-enable: yes
|
||||
control-use-cert: no
|
Loading…
Reference in New Issue
Block a user