Skip to content

Conversation

ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Feb 3, 2022

Reenable some broken tests as discussed #20744 (comment) and #20744 (comment)

Fix windows test cases broken in #20744, by passing normalized path arguments to fs::equivalent, fs::exists, and fs::is_directory, instead of non-normalized arguments. Also re-enable the tests.

It is possible these changes also fix real init behavior on windows when -datadir or -walletdir paths with trailing dots or dashes are used, but it's not clear because I only tested on wine.

@ryanofsky ryanofsky marked this pull request as draft February 3, 2022 15:46
@DrahtBot DrahtBot added the Wallet label Feb 3, 2022
This should also fix an assert error if a -datadir with a trailing slash
is used on windows. This appears to be a real error and regression
introduced with bitcoin#20744.

On windows (or at least wine), fs calls that actuallly access the
filesystem like fs::equivalent or fs::exists seem to treat directory
paths with trailing slashes as not existing, so it's necessary to
normalize these paths before using them. This fix adds a
path::lexically_normal() call to the failing assert so it passes.
…itcoin#20744

This should also fix an init error if a -walletdir with a trailing slash
is used on windows. This appears to be a real error and regression
introduced with bitcoin#20744.

On windows (or at least wine), fs calls that actuallly access the
filesystem like fs::equivalent or fs::exists seem to treat directory
paths with trailing slashes as not existing, so it's necessary to
normalize these paths before using them. This change passes canonical
paths to fs calls validating the -walletdir path to fix this.
@ryanofsky
Copy link
Contributor Author

Updated 8287489 -> d216bc8 (pr/wp.1 -> pr/wp.2, compare) hopefully fixing CI errors.

I think #20744 might have actually caused real regressions on windows. If -datadir or -walletdir values with trailing slashes are passed, it triggers assert errors or init errors in these two test cases, and it seems like the same problems would happen outside of the test environment.

Not good to disable tests like this!

@hebasto
Copy link
Member

hebasto commented Feb 4, 2022

@ryanofsky

If -datadir or -walletdir values with trailing slashes are passed, it triggers assert errors or init errors...

You're talking about Windows builds only, right?

@ryanofsky
Copy link
Contributor Author

@ryanofsky

If -datadir or -walletdir values with trailing slashes are passed, it triggers assert errors or init errors...

You're talking about Windows builds only, right?

You left off the important part where I said "... in these two test cases." And I actually only know about wine, not real windows. With wine, I saw fs::exists and similar functions treat directory paths with trailing dots and slashes as if they did not exist. Normalizing or canonicalizing the arguments made these functions work again and let me re-enable these windows tests. I think adding back test coverage here, and making minor changes to make code more reliable are already good things to do, and would have improved #20744. But it also hints that #20744 could also break some real windows configurations. I don't know for sure.

@ryanofsky ryanofsky marked this pull request as ready for review February 4, 2022 22:07
@maflcko
Copy link
Member

maflcko commented Feb 5, 2022

Shouldn't this be named "wallet: Use canonical path in VerifyWallets"?

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK d216bc8, I have reviewed the code and it looks OK, I agree it can be merged.

Also note that #24265 makes all paths (-datadir, -blocksdir or -walletdir) normalized at the earliest available stage that effectively makes changes in src/util/system.cpp and src/wallet/load.cpp redundant.

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 5, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24265 (Drop StripRedundantLastElementsOfPath() function and re-enable Windows tests by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@fanquake fanquake merged commit 1e7564e into bitcoin:master Feb 5, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 6, 2022
…#20744

d216bc8 Re-enable walletinit_verify_walletdir_no_trailing2 test disabled in bitcoin#20744 (Ryan Ofsky)
80cd64e Re-enable util_datadir check disabled in bitcoin#20744 (Ryan Ofsky)

Pull request description:

  Reenable some broken tests as discussed bitcoin#20744 (comment) and bitcoin#20744 (comment)

  Fix windows test cases broken in bitcoin#20744, by passing normalized path arguments to fs::equivalent, fs::exists, and fs::is_directory, instead of non-normalized arguments. Also re-enable the tests.

  It is possible these changes also fix real init behavior on windows when -datadir or -walletdir paths with trailing dots or dashes are used, but it's not clear because I only tested on wine.

ACKs for top commit:
  hebasto:
    ACK d216bc8, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 2099ddfa1a3ad70f7ac2ff413929414a1851d257b280da25c0f5cefb46fd1372b580a1f1ee5280681a1c16e6031f119185cadd4f7a6121298562cf001f711068
@bitcoin bitcoin locked and limited conversation to collaborators Feb 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants