diff mbox series

selinux-testsuite: fix the cgroups_label test

Message ID 156683229042.27016.12674072161480134335.stgit@chester (mailing list archive)
State Accepted
Headers show
Series selinux-testsuite: fix the cgroups_label test | expand

Commit Message

Paul Moore Aug. 26, 2019, 3:11 p.m. UTC
From: Paul Moore <paul@paul-moore.com>

We can't rely on /sys/fs/cgroups/unified anymore, use our own directory.

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/cgroupfs_label/test |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Paul Moore Aug. 26, 2019, 3:19 p.m. UTC | #1
On Mon, Aug 26, 2019 at 11:11 AM Paul Moore <paul@paul-moore.com> wrote:
> From: Paul Moore <paul@paul-moore.com>
>
> We can't rely on /sys/fs/cgroups/unified anymore, use our own directory.
>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
>  tests/cgroupfs_label/test |   19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)

This seemed like a trivial fix, and broken tests are a Very Bad Thing,
so I merged this without the usual day-or-two delay.  However, if
you've got comments on the patch please feel free to send mail.
diff mbox series

Patch

diff --git a/tests/cgroupfs_label/test b/tests/cgroupfs_label/test
index 127e802..385b953 100755
--- a/tests/cgroupfs_label/test
+++ b/tests/cgroupfs_label/test
@@ -5,24 +5,23 @@  BEGIN { plan tests => 2 }
 
 my $ret;
 
+my $dir = "/sys/fs/cgroup/selinuxtest";
+
 # Create a new cgroupfs directory and relabel it.
-mkdir("/sys/fs/cgroup/unified/test");
-system("chcon -R -t test_cgroup_t /sys/fs/cgroup/unified/test");
+mkdir("$dir");
+system("chcon -R -t test_cgroup_t $dir");
 
 # Create a subdirectory in it.
-mkdir("/sys/fs/cgroup/unified/test/subdir");
+mkdir("$dir/subdir");
 
-$ret =
-  system("test `secon -tf /sys/fs/cgroup/unified/test/subdir` = test_cgroup_t");
+$ret = system("secon -tf $dir/subdir | grep -q '^test_cgroup_t\$'");
 ok( $ret, 0 );    # Did the subdirectory inherit the parent's label?
 
-$ret = system(
-"test `secon -tf /sys/fs/cgroup/unified/test/subdir/cgroup.type` = test_cgroup_t"
-);
+$ret = system("secon -tf $dir/subdir/cgroup.type | grep -q '^test_cgroup_t\$'");
 ok( $ret, 0 );    # Did also files in the subdirectory inherit the label?
 
 # Cleanup.
-rmdir("/sys/fs/cgroup/unified/test/subdir");
-rmdir("/sys/fs/cgroup/unified/test");
+rmdir("$dir/subdir");
+rmdir("$dir");
 
 exit;