Forráskód Böngészése

support/testing: add oath-toolkit runtime test

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Julien Olivain 10 hónapja
szülő
commit
8851a2583e
2 módosított fájl, 39 hozzáadás és 0 törlés
  1. 1 0
      DEVELOPERS
  2. 38 0
      support/testing/tests/package/test_oath_toolkit.py

+ 1 - 0
DEVELOPERS

@@ -1944,6 +1944,7 @@ F:	support/testing/tests/package/test_ntp.py
 F:	support/testing/tests/package/test_ntp/
 F:	support/testing/tests/package/test_numactl.py
 F:	support/testing/tests/package/test_numactl/
+F:	support/testing/tests/package/test_oath_toolkit.py
 F:	support/testing/tests/package/test_octave.py
 F:	support/testing/tests/package/test_ola.py
 F:	support/testing/tests/package/test_ola/

+ 38 - 0
support/testing/tests/package/test_oath_toolkit.py

@@ -0,0 +1,38 @@
+import os
+
+import infra.basetest
+
+
+class TestOathToolKit(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_OATH_TOOLKIT=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()
+
+        self.assertRunOk("oathtool --version")
+
+        # Test commands and expected results are coming from examples
+        # producing stable/reproducible outputs given in the oathtool
+        # manual page. See:
+        # https://www.nongnu.org/oath-toolkit/oathtool.1.html
+
+        tests = [
+            ("echo 00 | oathtool -", "328482"),
+            ("oathtool -c 5 3132333435363738393031323334353637383930", "254676"),
+            ("oathtool -w 10 3132333435363738393031323334353637383930 969429", "3"),
+            ("oathtool --totp --now \"2008-04-23 17:42:17 UTC\" 00", "974945")
+        ]
+
+        for cmd, expected_out in tests:
+            out, ret = self.emulator.run(cmd)
+            self.assertEqual(ret, 0, f"Failed to run '{cmd}'")
+            self.assertEqual(expected_out, out[0])