Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Mar 4, 2021

This updates the test to only skip the mountedByOpenat2() part, instead
of skipping the whole test, if openat2 is not supported.

@thaJeztah
Copy link
Member Author

@kolyshkin PTAL; noticed this when running tests in a container on Docker Desktop (kernel 4.19)

@thaJeztah
Copy link
Member Author

ehm. probably don't need this as #65 also fixes this 🤦‍♂️thought we already merged that one

@AkihiroSuda
Copy link
Member

Merged #65

@kolyshkin
Copy link
Collaborator

As I said in #65, I definitely had openat2 way in mind when writing this, mostly added mountinfo to test the test itself. As we already test this functionality on an openat2-capable system that should be sufficient, i.e. this check does not bring much by itself.

Feel free to either enable part of GetMountedBy test, or close this PR.

@thaJeztah
Copy link
Member Author

I updated the PR, but would be fine either way (closing / merging). ptal

func TestMountedBy(t *testing.T) {
requireOpenat2(t)
func tryOpenat2(t *testing.T) error {
t.Helper()
Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIK it does not have to be a helper (so also no need to pass t).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, probably not strictly needed; I usually add it by default, so that issues get reported with the line of the Test, not the line in the helper. I'll remove

} else if mounted != exp {
t.Errorf("mountedByOpenat2(%q): expected %v, got %v", m, exp, mounted)

err = tryOpenat2(t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't matter much really, but calling it in a loop seems unclean -- e.g. it could make a reviewer think that something we do here might affect the value returned from tryOpenat2.

So I would move it out of the loop, doing something like

openat2Supported = tryOpenat2(t) == nil

and below

if openat2Supported {
   mounted, err = mountedByOpenat2(m)
   ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

@thaJeztah PTAL ^^^

@kolyshkin
Copy link
Collaborator

I updated the PR, but would be fine either way (closing / merging). ptal

Left some notes, also the commit description needs an update.

@thaJeztah
Copy link
Member Author

@kolyshkin updated; ptal

@kolyshkin
Copy link
Collaborator

LGTM except the commit message seems to be not up-to-date (it was before #65).

@kolyshkin
Copy link
Collaborator

LGTM except the commit message seems to be not up-to-date (it was before #65).

@thaJeztah PTAL ^^^ 🙏🏻

This updates the test to only skip the mountedByOpenat2() part, instead
of skipping the whole test, if openat2 is not supported.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

@kolyshkin updated, PTAL

Copy link
Collaborator

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@AkihiroSuda AkihiroSuda merged commit daaedda into moby:master Sep 21, 2021
@thaJeztah thaJeztah deleted the skip_no_openat2 branch September 21, 2021 05:43
@kolyshkin kolyshkin mentioned this pull request Oct 25, 2021
@thaJeztah thaJeztah changed the title TestMountedBy: skip mountedByOpenat2() check if not supported mountinfo: TestMountedBy: skip mountedByOpenat2() check if not supported Nov 5, 2021
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