Skip to content

[MOKOSH] RHEL-1843 - Test for improved capsh --print output - #8

Open
Koncpa wants to merge 12 commits into
mainfrom
auto/RHEL-1843_test
Open

[MOKOSH] RHEL-1843 - Test for improved capsh --print output#8
Koncpa wants to merge 12 commits into
mainfrom
auto/RHEL-1843_test

Conversation

@Koncpa

@Koncpa Koncpa commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

This PR was generated by the QE automation pipeline and requires human review.

Summary

This PR introduces a new regression test for RHEL-1843, which addresses an RFE to improve the output of the capsh --print command.

Test Description

The test verifies the following:

  • When a process has a full set of capabilities, capsh --print now displays "all" instead of a long, difficult-to-read list of every individual capability.
  • When a capability set (like the ambient set) is empty, capsh --print now displays "none" for clarity.

How to Run

The test can be run using TMT:

tmt run -avv plans --name /plans/default /tests/Regression/RHEL-1843-capsh-print-all

Reference Tests

The following existing tests were used as a reference for framework, metadata, and structure:

  • Sanity/capsh-basic-functionality
  • Regression/bz722694-capsh-does-not-chdir-after-chroot

Summary by Sourcery

Add a new regression test validating the improved capsh --print output for capability sets.

Tests:

  • Introduce a BeakerLib-based regression test covering capsh --print behavior for full, empty, and non-root capability sets.
  • Add test metadata and purpose files for the new RHEL-1843 capsh --print regression test.

@sourcery-ai

sourcery-ai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a new beakerlib-based regression test for RHEL-1843 to validate improved capsh --print output, including handling of full capability sets, empty ambient sets, and non-root users, along with associated TMT metadata files.

File-Level Changes

Change Details Files
Introduce a new beakerlib regression test to validate capsh --print output for different capability scenarios.
  • Add setup phase asserting libcap package presence
  • Add test phase checking that a root process with full capabilities reports all in Current and Bounding sets
  • Add test phase checking that an empty ambient set is reported as none
  • Add test phase creating a non-root user, running capsh --print, and asserting capabilities are empty, then deleting the user
  • Retain standard beakerlib journal start/end and text printing
Regression/RHEL-1843-capsh-print-all/runtest.sh
Add test metadata and purpose documentation for the new regression test to integrate with TMT and existing test suites.
  • Document the RHEL-1843 regression test purpose and the behavior being validated
  • Define TMT/fmf metadata (e.g., summary, contact, components, enabled status, and plan linkage) for the new test directory
Regression/RHEL-1843-capsh-print-all/PURPOSE
Regression/RHEL-1843-capsh-print-all/main.fmf

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The temporary capsh_test_user account is created and deleted inside the test phase; consider moving creation to Setup and deletion to Cleanup (and making both idempotent) so that failures in the middle of the test don't leave stray users behind.
  • You call capsh --print multiple times and only grep for a subset of fields each time; to reduce runtime and potential flakiness, you could capture the output once per scenario and assert all expected lines from that single invocation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The temporary `capsh_test_user` account is created and deleted inside the test phase; consider moving creation to Setup and deletion to Cleanup (and making both idempotent) so that failures in the middle of the test don't leave stray users behind.
- You call `capsh --print` multiple times and only grep for a subset of fields each time; to reduce runtime and potential flakiness, you could capture the output once per scenario and assert all expected lines from that single invocation.

## Individual Comments

### Comment 1
<location path="Regression/RHEL-1843-capsh-print-all/runtest.sh" line_range="24-28" />
<code_context>
+        rlAssertGrep "Ambient set: none" "$rlRun_LOG" "Check for 'none' in Ambient set"
+    rlPhaseEnd
+
+    rlPhaseStartTest "Verify capsh --print output for a non-root user (no capabilities)"
+        rlRun "useradd capsh_test_user"
+        rlRun "su - capsh_test_user -c 'capsh --print'"
+        rlAssertGrep "Current: =" "$rlRun_LOG" "Current capabilities should be empty for non-root user"
+        rlRun "userdel -r capsh_test_user"
+    rlPhaseEnd
+
</code_context>
<issue_to_address>
**issue (testing):** Make user lifecycle handling more robust to pre-existing users or failures during useradd/userdel.

This test relies on `useradd capsh_test_user` and `userdel -r capsh_test_user` succeeding unconditionally. If the user already exists or deletion fails, the phase may misbehave or become flaky. Please make the setup/teardown more resilient, e.g. by using a more unique username, checking for existence before create/delete, or relaxing `rlRun` expectations with explicit handling of non-zero return codes.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread Regression/RHEL-1843-capsh-print-all/runtest.sh Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant