All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/testing: add test for lzop
@ 2022-07-17 14:44 Vincent Stehlé via buildroot
  2022-07-17 20:05 ` Yann E. MORIN
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Stehlé via buildroot @ 2022-07-17 14:44 UTC (permalink / raw)
  To: buildroot; +Cc: Vincent Stehlé

Add a simple compress-uncompress test to verify that lzop is working.

Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
Cc: Peter Korsgaard <peter@korsgaard.com>
---


Hi,

I have verified that this test works fine locally and on gitlab.

Peter, please do not hesitate to let me know about any feedback, and if this
test should be assigned to you in DEVELOPERS instead. I am adding myself by
default to make sure the test is not orphaned.

Best regards,
Vincent.


 DEVELOPERS                                 |  1 +
 support/testing/tests/package/test_lzop.py | 38 ++++++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 support/testing/tests/package/test_lzop.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 5c3c24ff7a..644711c5f4 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2919,6 +2919,7 @@ F:	package/i7z/
 F:	package/msr-tools/
 F:	package/pixz/
 F:	package/zerofree/
+F:	support/testing/tests/package/test_lzop.py
 F:	support/testing/tests/package/test_msr_tools*
 F:	support/testing/tests/package/test_pixz.py
 F:	support/testing/tests/package/test_zerofree.py
diff --git a/support/testing/tests/package/test_lzop.py b/support/testing/tests/package/test_lzop.py
new file mode 100644
index 0000000000..b5479a25d5
--- /dev/null
+++ b/support/testing/tests/package/test_lzop.py
@@ -0,0 +1,38 @@
+import os
+
+import infra.basetest
+
+
+class TestLzop(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_LZOP=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()
+
+        # Prepare input file with random data and zeroes.
+        # We keep the size small (4 MB) for the sake of test time.
+        cmd = "dd if=/dev/urandom of=orig bs=1M count=2 && " \
+              "dd if=/dev/zero of=orig bs=1M count=2 seek=2"
+        self.assertRunOk(cmd)
+
+        # Compress.
+        self.assertRunOk("lzop -v -o compressed.lzo orig", timeout=60)
+
+        # Test.
+        self.assertRunOk("lzop -tv compressed.lzo")
+
+        # Uncompress.
+        self.assertRunOk("lzop -dv -o uncompressed compressed.lzo")
+
+        # Verify.
+        # The ls is there for debugging.
+        self.assertRunOk("ls -l && cmp orig uncompressed")
-- 
2.35.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH] support/testing: add test for lzop
  2022-07-17 14:44 [Buildroot] [PATCH] support/testing: add test for lzop Vincent Stehlé via buildroot
@ 2022-07-17 20:05 ` Yann E. MORIN
  0 siblings, 0 replies; 2+ messages in thread
From: Yann E. MORIN @ 2022-07-17 20:05 UTC (permalink / raw)
  To: Vincent Stehlé; +Cc: buildroot

Vncent, All,

On 2022-07-17 16:44 +0200, Vincent Stehlé via buildroot spake thusly:
> Add a simple compress-uncompress test to verify that lzop is working.
> 
> Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net>
> Cc: Peter Korsgaard <peter@korsgaard.com>
> ---
[--SNIP--]
> diff --git a/support/testing/tests/package/test_lzop.py b/support/testing/tests/package/test_lzop.py
> new file mode 100644
> index 0000000000..b5479a25d5
> --- /dev/null
> +++ b/support/testing/tests/package/test_lzop.py
> @@ -0,0 +1,38 @@
> +import os
> +
> +import infra.basetest
> +
> +
> +class TestLzop(infra.basetest.BRTest):
> +    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
> +        """
> +        BR2_PACKAGE_LZOP=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()
> +
> +        # Prepare input file with random data and zeroes.
> +        # We keep the size small (4 MB) for the sake of test time.
> +        cmd = "dd if=/dev/urandom of=orig bs=1M count=2 && " \
> +              "dd if=/dev/zero of=orig bs=1M count=2 seek=2"
> +        self.assertRunOk(cmd)
> +
> +        # Compress.
> +        self.assertRunOk("lzop -v -o compressed.lzo orig", timeout=60)
> +
> +        # Test.
> +        self.assertRunOk("lzop -tv compressed.lzo")
> +
> +        # Uncompress.
> +        self.assertRunOk("lzop -dv -o uncompressed compressed.lzo")
> +
> +        # Verify.
> +        # The ls is there for debugging.
> +        self.assertRunOk("ls -l && cmp orig uncompressed")

I think I am starting to see a trend there... ;-)

Do you think you could generalise this test as a common, no-test class,
and have the various test inherit from it?

For example:

    class TestCompress(infra.basetest.BRTest):
        config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
            """
            BR2_TARGET_ROOTFS_CPIO=y
            # BR2_TARGET_ROOTFS_TAR is not set
            """

        def __init__(self, *args, **kwargs):
            self.config += "{}=y\n".format(kwargs['symbol'])
            self.comp = kwargs['comp']
            self.uncomp = kwargs['uncomp']
            del kwargs['symbol'] kwargs['comp'] kwargs['uncomp']
            super(self).__init(*args, **kwargs)

        def test_run(self):
            # blablabla...

            # Compress
            self.assertRunOk("{} <orig >compressed".format(self.comp), timeout=60)

            # blablabla

            # Uncompress
            self.assertRunOk("{} <compressed >uncompressed".format(self.uncomp))


    class TestCompressPixz(TestCompress):
        def __init__(self):
            super(self).__init__(sympol='BR2_PACKAGE_LZOP', comp='lzo -v', uncomp='lzop -dv')


Notice how I changed to use stdin/stdout so that we do not care about
the option for input/ouput...

Of course, this is just a draft, you will need a bit more magic to make
it work. ;-)

Regards,
Yann E. MORIN.

> -- 
> 2.35.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-17 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-17 14:44 [Buildroot] [PATCH] support/testing: add test for lzop Vincent Stehlé via buildroot
2022-07-17 20:05 ` Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.