浏览代码

support/testing: new proj runtime test

Tested-by: Zoltan Gyarmati <zgyarmati@zgyarmati.de>
Reviewed-by: Zoltan Gyarmati <zgyarmati@zgyarmati.de>
Signed-off-by: Julien Olivain <ju.o@free.fr>
Julien Olivain 8 月之前
父节点
当前提交
15dbc33be8
共有 2 个文件被更改,包括 60 次插入0 次删除
  1. 1 0
      DEVELOPERS
  2. 59 0
      support/testing/tests/package/test_proj.py

+ 1 - 0
DEVELOPERS

@@ -1956,6 +1956,7 @@ F:	support/testing/tests/package/test_pigz.py
 F:	support/testing/tests/package/test_postgresql.py
 F:	support/testing/tests/package/test_pppd.py
 F:	support/testing/tests/package/test_pppd/
+F:	support/testing/tests/package/test_proj.py
 F:	support/testing/tests/package/test_pv.py
 F:	support/testing/tests/package/test_python_distro.py
 F:	support/testing/tests/package/test_python_gnupg.py

+ 59 - 0
support/testing/tests/package/test_proj.py

@@ -0,0 +1,59 @@
+import os
+
+import infra.basetest
+
+
+class TestProj(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_PROJ=y
+        BR2_PACKAGE_PROJ_APPS=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()
+
+        # We check the program can run. The "proj" command does not
+        # have a "--version" option. It will just show its version
+        # when invoked without any argument.
+        self.assertRunOk("proj")
+
+        # The commands in this tests are taken from the Proj
+        # documentation quickstart page, at:
+        # https://proj.org/en/9.5/usage/quickstart.html
+
+        proj_str = "+proj=merc +lat_ts=56.5 +ellps=GRS80"
+        cmd = "echo 55.2 12.2"
+        cmd += f" | proj {proj_str}"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        expected_values = [3399483.80, 752085.60]
+        values = list(map(lambda x: float(x), out[0].split()))
+        for i in range(len(expected_values)):
+            self.assertAlmostEqual(values[i], expected_values[i])
+
+        proj_str = "+proj=merc +lat_ts=56.5 +ellps=GRS80 +to +proj=utm +zone=32"
+        cmd = "echo 3399483.80 752085.60"
+        cmd += f" | cs2cs {proj_str}"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        expected_values = [6103992.36, 1924052.47, 0.00]
+        values = list(map(lambda x: float(x), out[0].split()))
+        for i in range(len(expected_values)):
+            self.assertAlmostEqual(values[i], expected_values[i])
+
+        proj_str = "+init=epsg:4326 +to +init=epsg:25832"
+        cmd = "echo 56 12"
+        cmd += f" | cs2cs {proj_str}"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        expected_values = [6231950.54, 1920310.71, 0.00]
+        values = list(map(lambda x: float(x), out[0].split()))
+        for i in range(len(expected_values)):
+            self.assertAlmostEqual(values[i], expected_values[i])