package/rwmem: add python module.
PATCH 1/2 package/rwmem: add python module.
Signed-off-by Vincent Cruz <[email protected]>
--- package/rwmem/Config.in | 4 ++++ package/rwmem/rwmem-python/Config.in | 8 ++++++++ package/rwmem/rwmem-python/rwmem-python.hash | 3 +++ package/rwmem/rwmem-python/rwmem-python.mk | 21 ++++++++++++++++++++ package/rwmem/rwmem.mk | 2 ++ 5 files changed, 38 insertions(+) create mode 100644 package/rwmem/rwmem-python/Config.in create mode 100644 package/rwmem/rwmem-python/rwmem-python.hash create mode 100644 package/rwmem/rwmem-python/rwmem-python.mk
package/rwmem/Config.in +4 -0
@@ -10,6 +10,10 @@ config BR2_PACKAGE_RWMEM https://github.com/tomba/rwmem +if BR2_PACKAGE_RWMEM +source "package/rwmem/rwmem-python/Config.in" +endif + comment "rwmem needs a toolchain w/ C++, wchar, gcc >= 10" depends on !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR || \ !BR2_TOOLCHAIN_GCC_AT_LEAST_10
package/rwmem/rwmem-python/Config.in new file +8 -0
@@ -0,0 +1,8 @@ +config BR2_PACKAGE_RWMEM_PYTHON + bool "python tools" + depends on BR2_PACKAGE_RWMEM + depends on BR2_PACKAGE_PYTHON3 + help + Python bindings for rwmem + + https://github.com/tomba/rwmem
package/rwmem/rwmem-python/rwmem-python.hash new file +3 -0
@@ -0,0 +1,3 @@ +# Locally calculated +sha256 d10639f563100c819202337c4d4df57db11c2fcd59a19b0c68e34b8eb9aa1d01 rwmem-2.0.tar.gz +sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 LICENSE
package/rwmem/rwmem-python/rwmem-python.mk new file +21 -0
@@ -0,0 +1,21 @@ +################################################################################ +# +# pyrwmem +# +################################################################################ + +RWMEM_PYTHON_VERSION = $(RWMEM_VERSION) +RWMEM_PYTHON_SOURCE = $(RWMEM_SOURCE) +RWMEM_PYTHON_SITE = $(RWMEM_SITE) +RWMEM_PYTHON_DL_SUBDIR = rwmem + +RWMEM_PYTHON_LICENSE = $(RWMEM_LICENSE) +RWMEM_PYTHON_LICENSE_FILES = $(RWMEM_LICENSE_FILES) + +RWMEM_PYTHON_DEPENDENCIES = rwmem + +RWMEM_PYTHON_INSTALL_STAGING = YES + +RWMEM_PYTHON_SETUP_TYPE = setuptools + +$(eval $(python-package))
package/rwmem/rwmem.mk +2 -0
@@ -11,3 +11,5 @@ RWMEM_LICENSE_FILES = LICENSE RWMEM_DEPENDENCIES = host-pkgconf fmt inih $(eval $(meson-package)) + +include package/rwmem/rwmem-python/rwmem-python.mk
Signature · 6 lines
2.51.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 support/testing: add rwmem tests
Add a basic runtime test for rwmem package.
This test verifies that rwmem package can read register values from an I2C device and a memory mapped file.
Signed-off-by Vincent Cruz <[email protected]>
--- support/testing/tests/package/test_rwmem.py | 72 +++++++++++++++++++ .../package/test_rwmem/linux-rwmem.fragment | 3 + .../test_rwmem/rootfs-overlay/root/tests.py | 22 ++++++ 3 files changed, 97 insertions(+) create mode 100644 support/testing/tests/package/test_rwmem.py create mode 100644 support/testing/tests/package/test_rwmem/linux-rwmem.fragment create mode 100644 support/testing/tests/package/test_rwmem/rootfs-overlay/root/tests.py
support/testing/tests/package/test_rwmem.py new file +72 -0
@@ -0,0 +1,72 @@ +import os + +import infra.basetest + + +class TestRwmem(infra.basetest.BRTest): + kernel_fragment = infra.filepath("tests/package/test_rwmem/linux-rwmem.fragment") + rootfs_overlay = infra.filepath("tests/package/test_rwmem/rootfs-overlay") + + config = \ + f""" + BR2_arm=y + BR2_cortex_a9=y + BR2_ARM_ENABLE_NEON=y + BR2_ARM_ENABLE_VFP=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y + BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV7_EABIHF_GLIBC_STABLE=y + BR2_LINUX_KERNEL=y + BR2_LINUX_KERNEL_DEFCONFIG="vexpress" + BR2_LINUX_KERNEL_DTS_SUPPORT=y + BR2_LINUX_KERNEL_INTREE_DTS_NAME="arm/vexpress-v2p-ca9" + BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" + BR2_TARGET_ROOTFS_CPIO=y + BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kernel_fragment}" + BR2_ROOTFS_OVERLAY="{rootfs_overlay}" + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_RWMEM=y + BR2_PACKAGE_RWMEM_PYTHON=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + img = os.path.join(self.builddir, "images", "rootfs.cpio") + kern = os.path.join(self.builddir, "images", "zImage") + dtb = os.path.join(self.builddir, "images", "vexpress-v2p-ca9.dtb") + self.emulator.boot(arch="armv7", + kernel=kern, + kernel_cmdline=["console=ttyAMA0"], + options=["-M", "vexpress-a9", + "-dtb", dtb, + "-device", "virtio-rng-device", + "-device", "tmp105,address=0x49,id=sensor", + "-initrd", img]) + self.emulator.login() + + self.assertRunOk("i2cset -y 0 0x49 0x02 0x5a 0x80 i") + + out, ret = self.emulator.run("rwmem -S 8 -s 16be --i2c=0:0x49 0x02") + self.assertEqual(ret, 0) + self.assertIn("0x02 (+0x0) = 0x5a80", out) + + out, ret = self.emulator.run("rwmem -S 8 -s 8 --mmap /etc/os-release 0x6-0xe") + self.assertEqual(ret, 0) + self.assertEqual(out, [ + "0x06 (+0x0) = 0x75", + "0x07 (+0x1) = 0x69", + "0x08 (+0x2) = 0x6c", + "0x09 (+0x3) = 0x64", + "0x0a (+0x4) = 0x72", + "0x0b (+0x5) = 0x6f", + "0x0c (+0x6) = 0x6f", + "0x0d (+0x7) = 0x74" + ]) + + self.assertRunOk("i2cset -y 0 0x49 0x02 0x7c 0xa0 i") + out, ret = self.emulator.run("python3 /root/tests.py") + self.assertEqual(ret, 0) + self.assertEqual(out, [ + "0x7ca0", + "0x75696c64726f6f74" + ])
support/testing/tests/package/test_rwmem/linux-rwmem.fragment new file +3 -0
@@ -0,0 +1,3 @@ +CONFIG_I2C=y +CONFIG_I2C_CHARDEV=y +CONFIG_SENSORS_LM75=y
support/testing/tests/package/test_rwmem/rootfs-overlay/root/tests.py new file +22 -0
@@ -0,0 +1,22 @@ +#! /usr/bin/env python3 +# This is the python version of the rwmem cli tests. +import sys + +import rwmem as rw + +# rwmem -S 8 -s 16be --i2c=0:0x49 0x02 +map = rw.I2CTarget(i2c_adapter_nr=0, i2c_dev_addr=0x49, + offset=0x0, length=16, + addr_endianness=rw.Endianness.Big, addr_size=1, + data_endianness=rw.Endianness.Big, data_size=2, + mode=rw.MapMode.ReadWrite) + +out = map.read(0x02) +print(hex(out)) + +# rwmem -S 8 -s 8 --mmap /etc/os-release 0x6-0xe +map = rw.MMapTarget('/etc/os-release', 0, 32, rw.Endianness.Big, 1, rw.MapMode.Read) +out = map.read(0x6, 8) +print(hex(out)) + +sys.exit(0)
Signature · 6 lines
2.51.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot