Skip to content

test: use mtime for -ot and fix direction of comparison#5441

Merged
sylvestre merged 1 commit intouutils:mainfrom
n1000:test_ot_fix
Oct 23, 2023
Merged

test: use mtime for -ot and fix direction of comparison#5441
sylvestre merged 1 commit intouutils:mainfrom
n1000:test_ot_fix

Conversation

@n1000
Copy link
Contributor

@n1000 n1000 commented Oct 23, 2023

  • Use the file modification time instead of the creation time (matches GNU coreutils documentation)

  • Fix direction of comparison (a < b instead of a > b)

  • Extend test case to cover both the 0 and 1 exit code cases

- Use the file modification time instead of the creation time (matches
  GNU coreutils documentation)

- Fix direction of comparison (a < b instead of a > b)

- Extend test case to cover both the 0 and 1 exit code cases
@n1000
Copy link
Contributor Author

n1000 commented Oct 23, 2023

Here is the specific coreutils documentation page I was referring to.

I wasn't sure how to test on android, so left the #cfg check in place for that target environment. For musl testing I used cargo test --target=x86_64-unknown-linux-musl test_test.

@sylvestre
Copy link
Contributor

Looks good :)
I am curious how you found this issue :)

@n1000
Copy link
Contributor Author

n1000 commented Oct 23, 2023

I am curious how you found this issue :)

I ended up finding this issue while running the tests on OpenBSD and digging into why this test case was failing. Eventually I found out OpenBSD was providing creation times of "0".. This led me to checking the OpenBSD "test" implementation and finding out that there both -nt and -ot used mtime.

Once I changed the uutils/coreutils "-ot" implementation to use the modified time, it was easier to spot that the -nt implementation on the line above was identical to "-ot" which raised a red flag.. 😃

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.

2 participants