All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Korsgaard <peter@korsgaard.com>
To: Julien Olivain <ju.o@free.fr>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] support/testing: new acl runtime test
Date: Tue, 06 Feb 2024 22:48:51 +0100	[thread overview]
Message-ID: <87h6il462k.fsf@48ers.dk> (raw)
In-Reply-To: <20240206195237.55252-1-ju.o@free.fr> (Julien Olivain's message of "Tue, 6 Feb 2024 20:52:37 +0100")

>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:

 > Signed-off-by: Julien Olivain <ju.o@free.fr>
 > ---
 >  DEVELOPERS                                |  1 +
 >  support/testing/tests/package/test_acl.py | 87 +++++++++++++++++++++++
 >  2 files changed, 88 insertions(+)
 >  create mode 100644 support/testing/tests/package/test_acl.py

 > diff --git a/DEVELOPERS b/DEVELOPERS
 > index 4b8d195f9f..ce248e8706 100644
 > --- a/DEVELOPERS
 > +++ b/DEVELOPERS
 > @@ -1762,6 +1762,7 @@ F:	support/testing/tests/package/sample_python_midiutil.py
 >  F:	support/testing/tests/package/sample_python_ml_dtypes.py
 >  F:	support/testing/tests/package/sample_python_pyalsa.py
 >  F:	support/testing/tests/package/sample_python_spake2.py
 > +F:	support/testing/tests/package/test_acl.py
 >  F:	support/testing/tests/package/test_acpica.py
 >  F:	support/testing/tests/package/test_acpica/
 >  F:	support/testing/tests/package/test_apache.py
 > diff --git a/support/testing/tests/package/test_acl.py b/support/testing/tests/package/test_acl.py
 > new file mode 100644
 > index 0000000000..e4827c7bec
 > --- /dev/null
 > +++ b/support/testing/tests/package/test_acl.py
 > @@ -0,0 +1,87 @@
 > +import os
 > +
 > +import infra.basetest
 > +
 > +
 > +class TestAcl(infra.basetest.BRTest):
 > +    # Note: this test requires a Kernel with a filesystem on /tmp
 > +    # supporting ACLs. This is the case for the basetest reference
 > +    # config. Kernel has CONFIG_TMPFS_POSIX_ACL=y, and /tmp is tmpfs
 > +    # in the default Buildroot config.
 > +    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
 > +        """
 > +        BR2_PACKAGE_ACL=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()
 > +
 > +        # Check the programs can execute.
 > +        self.assertRunOk("getfacl --version")
 > +        self.assertRunOk("setfacl --version")
 > +
 > +        # Constants used in this test.
 > +        test_user = "acltest"
 > +        test_data = "Hello Buildroot!"
 > +        test_file = "/tmp/file.txt"
 > +
 > +        # Create a test user:
 > +        # -D    don't set a password
 > +        # -h    set home directory
 > +        # -H    don't create home directory
 > +        # -s    set shell to /bin/sh
 > +        self.assertRunOk(f"adduser -D -h /tmp -H -s /bin/sh {test_user}")
 > +
 > +        # Create a test file, and make sure the owner is "root" with
 > +        # standard Unix permissions to read/write only for the owner.
 > +        self.assertRunOk(f"echo '{test_data}' > {test_file}")
 > +        self.assertRunOk(f"chown root:root {test_file}")
 > +        self.assertRunOk(f"chmod 0600 {test_file}")
 > +
 > +        # Check we have no ACL for the test user.
 > +        getacl_cmd = f"getfacl -c -p {test_file}"
 > +        out, ret = self.emulator.run(getacl_cmd)
 > +        self.assertEqual(ret, 0)

NIT: Maybe we should consider making assertRunOk() return the stdout
output so we don't need to open code the exit code check every time that
we also need stdout?

Committed, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2024-02-06 21:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 19:52 [Buildroot] [PATCH 1/1] support/testing: new acl runtime test Julien Olivain
2024-02-06 21:48 ` Peter Korsgaard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6il462k.fsf@48ers.dk \
    --to=peter@korsgaard.com \
    --cc=buildroot@buildroot.org \
    --cc=ju.o@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.