Skip to content

Conversation

@q5sys
Copy link

@q5sys q5sys commented Jan 30, 2026

Motivation and Context

Currently the export tests will always pass, you can add a log_fail and it will still pass.
log_fail calls endlog (tests/test-runner/include/logapi.shlib:366-369) with exit code of 1.
endlog (tests/test-runner/include/logapi.shlib:428-460) runs the cleanup function log_onexit zpool_export_cleanup.
zpool_export_cleanup (tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.kshlib:29-33) calls default_cleanup. However default_cleanup (tests/zfs-tests/include/libtest.shlib:531-536) ends with log_pass which calls _endlog with an exit code of 0. This overwrites the original exit code of 1 and results in the test passing.

default_cleanup_noexit (tests/zfs-tests/include/libtest.shlib:549-623) should be used in the zpool_export_cleanup function so the exit code is not overwritten.

After fixing zpool_export.kshlib, the failure of zpool_export_002_pos.ksh became visible. I then fixed this test by ensuring the pool gets created, since it was destroyed in the prior test.

How Has This Been Tested?

Tested on Linux and FreeBSD

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

Copilot AI review requested due to automatic review settings January 30, 2026 17:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the ZFS test suite where zpool_export tests would always pass even when failures occurred. The root cause was that the cleanup function used default_cleanup which calls log_pass, overwriting the test's exit code. Additionally, it fixes zpool_export_002_pos.ksh which was failing after the cleanup bug was fixed.

Changes:

  • Changed zpool_export_cleanup to use default_cleanup_noexit instead of default_cleanup to preserve test exit codes
  • Added explicit pool and filesystem setup in zpool_export_002_pos.ksh since the pool gets destroyed in the prior test

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.kshlib Fixed cleanup function to use default_cleanup_noexit to avoid overwriting test exit codes with log_pass
tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh Added manual pool/filesystem setup since pool is destroyed by previous test, and updated test documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@q5sys
Copy link
Author

q5sys commented Jan 30, 2026

just rebased on the master branch

@behlendorf
Copy link
Contributor

Rebasing this one more time on the master branch should sort out the CI infrastructure issue.

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Jan 31, 2026
JT Pennington added 2 commits February 2, 2026 11:28
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: JT Pennington <[email protected]>
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: JT Pennington <[email protected]>
Copilot AI review requested due to automatic review settings February 2, 2026 16:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

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

It looks to me like the cleanup in d7265b3 introduced this bug by destroying the pool after each test. Our usual convention for a test group is if a pool is created in setup.sh it is expected to persistent until cleanup.sh which destroys it. Individual tests that destroy a pool are also responsible for create it.

So it seems to me the bug here is zpool_export_cleanup shouldn't be destroying the pool at all on failure (or success). It simply needs to make sure the existing pool is ready for the test case. Alternately, I think it'd be fine if you updated all of the tests in this group to create/destroy a pool for use in their individual test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Code Review Needed Ready for review and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants