From 15dbc33be847c9b4d137e6311bb8ba68a51a3c27 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sat, 9 Nov 2024 18:55:09 +0100 Subject: [PATCH] support/testing: new proj runtime test Tested-by: Zoltan Gyarmati Reviewed-by: Zoltan Gyarmati Signed-off-by: Julien Olivain --- DEVELOPERS | 1 + support/testing/tests/package/test_proj.py | 59 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 support/testing/tests/package/test_proj.py diff --git a/DEVELOPERS b/DEVELOPERS index 492eb765e0..f2abab2ef3 100644 --- a/DEVELOPERS +++ b/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 diff --git a/support/testing/tests/package/test_proj.py b/support/testing/tests/package/test_proj.py new file mode 100644 index 0000000000..ed23c229fd --- /dev/null +++ b/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])