Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use diff to compare sysfs output #796

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

calebsander
Copy link
Contributor

The sysfs tests are currently hand-rolling file comparison. Use diff -u instead to get a rich comparison if the comparison fails. This also simplifies the test code significantly.

@igaw
Copy link
Collaborator

igaw commented Mar 20, 2024

When I added this code I decided against using an external tool, so that we don't have a build dependency on the tool. Maybe add a check to meson an if available use it?

@tbzatek
Copy link
Contributor

tbzatek commented Mar 20, 2024

When I added this code I decided against using an external tool, so that we don't have a build dependency on the tool. Maybe add a check to meson an if available use it?

FYI, I have already wired diff in nbft tests this way:

diffcmd = find_program(
'diff',
required: false
)
if diffcmd.found()

@igaw
Copy link
Collaborator

igaw commented Mar 20, 2024

Yes, and this case this the nbft test will not be executed when diff is missing. So this should handled in the same way.

@calebsander calebsander force-pushed the feature/test-sysfs-diff branch from 29f1f07 to 3e4ef43 Compare April 4, 2024 17:54
The sysfs tests are currently hand-rolling file comparison.
Use diff -u instead to get a rich comparison if the comparison fails.

Create a single shell script that combines extracting the sysfs files,
invoking the test program to generate the tree output,
and diffing the result against the expected output.
This reduces the C and Meson code needed for the test.

Signed-off-by: Caleb Sander Mateos <[email protected]>
@calebsander calebsander force-pushed the feature/test-sysfs-diff branch from 3e4ef43 to dd4a057 Compare April 4, 2024 17:57
@igaw igaw merged commit 86e6d82 into linux-nvme:master Apr 5, 2024
14 checks passed
@igaw
Copy link
Collaborator

igaw commented Apr 5, 2024

Thanks!

@calebsander calebsander deleted the feature/test-sysfs-diff branch April 5, 2024 17:16
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.

3 participants