support/testing: add runtime test for Crudini (py2 and py3)
authorTitouan Christophe <titouan.christophe@railnova.eu>
Wed, 5 Feb 2020 14:11:49 +0000 (15:11 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 5 Feb 2020 15:23:42 +0000 (16:23 +0100)
This also adds the new tests to the gitlab CI configuration.

Signed-off-by: Titouan Christophe <titouan.christophe@railnova.eu>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
.gitlab-ci.yml
DEVELOPERS
support/testing/tests/package/test_crudini.py [new file with mode: 0644]

index c0140527db28f48145886ec07a8500d8adb87f62..a6436a84172dd346b0c5f6269c30ebb68bd2fba1 100644 (file)
@@ -375,6 +375,8 @@ tests.init.test_systemd.TestInitSystemSystemdRwFull: { extends: .runtime_test }
 tests.init.test_systemd.TestInitSystemSystemdRwIfupdown: { extends: .runtime_test }
 tests.init.test_systemd.TestInitSystemSystemdRwNetworkd: { extends: .runtime_test }
 tests.package.test_atop.TestAtop: { extends: .runtime_test }
+tests.package.test_crudini.TestCrudiniPy2: { extends: .runtime_test }
+tests.package.test_crudini.TestCrudiniPy3: { extends: .runtime_test }
 tests.package.test_docker_compose.TestDockerCompose: { extends: .runtime_test }
 tests.package.test_dropbear.TestDropbear: { extends: .runtime_test }
 tests.package.test_glxinfo.TestGlxinfo: { extends: .runtime_test }
index 67cce2f8e47906741975ac73c9b512c31c8b83d8..32b49f17366a96fc6ea4d45522e57d4d0834f3cb 100644 (file)
@@ -2460,6 +2460,7 @@ F:        package/mosquitto/
 F:     package/python-avro/
 F:     package/redis/
 F:     package/waf/
+F:     support/testing/tests/package/test_crudini.py
 
 N:     Trent Piepho <tpiepho@impinj.com>
 F:     package/libp11/
diff --git a/support/testing/tests/package/test_crudini.py b/support/testing/tests/package/test_crudini.py
new file mode 100644 (file)
index 0000000..e320d32
--- /dev/null
@@ -0,0 +1,49 @@
+import os
+from tests.package.test_python import TestPythonPackageBase
+
+
+INI_FILE_CONTENT = """
+[section]
+param = this-is-the-magic-value
+other = dont care
+"""
+
+
+class TestCrudiniBase(TestPythonPackageBase):
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_CRUDINI=y
+        """
+
+    def test_run(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5", kernel="builtin",
+                           options=["-initrd", img])
+
+        self.emulator.login()
+
+        # 1. Create some sample .ini file
+        cmd = "echo -e '%s' > config.ini" % INI_FILE_CONTENT
+        _, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+
+        # 2. Attempt to get the value
+        out, ret = self.emulator.run("crudini --get config.ini section param")
+        self.assertEqual(ret, 0)
+        self.assertEqual(out, ['this-is-the-magic-value'])
+
+
+class TestCrudiniPy2(TestCrudiniBase):
+    __test__ = True
+    config = TestCrudiniBase.config + \
+        """
+        BR2_PACKAGE_PYTHON=y
+        """
+
+
+class TestCrudiniPy3(TestCrudiniBase):
+    __test__ = True
+    config = TestCrudiniBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        """