public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jan Zarsky <jzarsky@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: fix hidden failure in check_contexts
Date: Fri, 11 Sep 2026 13:17:25 GMT	[thread overview]
Message-ID: <178913264583.1.6858177446812822541.tests-selinux-4d8e2de3cda9@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 4d8e2de3cda97685e0188b6ee9c93a8c2f139748
            Author : Jan Zarsky <jzarsky@redhat.com>
            Date   : 2018-10-15T10:46:49+02:00
            Stats  : +7/-4 in 1 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/4d8e2de3cda97685e0188b6ee9c93a8c2f139748?branch=pr775-checkpolicy-revdeps

            Log:
            fix hidden failure in check_contexts

check_contexts was checking contexts in a loop and there was no warning
when there were no files to check (because of invalid parameter). Fix
this by counting the files to be checked.

Fix also one invalid call to check_contexts.

---
diff --git a/policycoreutils/restorecon/runtest.sh b/policycoreutils/restorecon/runtest.sh
index b16d4c0..aa7570c 100755
--- a/policycoreutils/restorecon/runtest.sh
+++ b/policycoreutils/restorecon/runtest.sh
@@ -111,10 +111,13 @@ rlJournalStart
 
         # Check that files matching with $2 in dir $1 have context $3
         function check_contexts {
-            COMMAND="find $1 -name '$2'"
-            for ITEM in `eval $COMMAND`; do
-                rlRun "ls -ladZ $ITEM | grep :$3";
+            rlRun "find $1 -name '$2' >files"
+            rlRun "[ $(cat files | wc -l) -gt 0 ]"
+
+            for f in $files; do
+                rlRun "ls -ladZ $f | grep :$3"
             done
+            rlRun "rm files"
         }
 
         # Create the testing dirs and files
@@ -184,7 +187,7 @@ EOF"
         check_initial_contexts 'incorrect1.dir'
         check_initial_contexts 'correct.dir'
         check_initial_contexts 'customizable.dir'
-        check_contexts 'incorrect2' '*' 'correct_t'
+        check_contexts 'incorrect2.dir' '*' 'correct_t'
         rlRun "ls -ladZ customizable.file | grep customizable_t"
         rlRun "ls -ladZ incorrect.file | grep :correct_t"
 

                 reply	other threads:[~2026-09-11 13:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=178913264583.1.6858177446812822541.tests-selinux-4d8e2de3cda9@fedoraproject.org \
    --to=jzarsky@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox