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

fix(test/drivers): fix ENOSYS check and test skipping. #1737

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Mar 8, 2024

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area tests

Does this PR require a change in the driver versions?

What this PR does / why we need it:

We cannot call GTEST_SKIP() in a sub-routine of a test, but only in the test body.
I kept the changes at the bare minumum to avoid touching all of the test cases...i had to introduce a simple macro though.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Andreagit97
Andreagit97 previously approved these changes Mar 8, 2024
Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

* dealing with ENOSYS syscalls, ie: syscalls that are defined but unimplemented,
* skipping the test.
*/
#define assert_syscall_state(syscall_state, syscall_name, ...) \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

First 3 parameters are mandatory, thus we are sure that this macro always expands to the correct _assert_syscall_state call, even if it is called with just 3 parameters, since the ... will then expand to third(, fourth, fifth) parameter.

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 8, 2024

/hold
Weird behavior on a ppc64le node.

We cannot call GTEST_SKIP() in a sub-routine of a test, but only in the test body.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
… tests.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@poiana poiana added size/M and removed size/S labels Mar 11, 2024
int64_t errno_value = -errno;
assert_syscall_state(SYSCALL_FAILURE, "dup3", res);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since assert_syscall_state now resets errno to 0, we must take errno value before calling the macro.
Same below.

{
bool match = false;

if (errno == ENOSYS)
{
GTEST_SKIP() << "Syscall " << syscall_name << " not implemented" << std::endl;
// it is managed upward by assert_syscall_state macro.
Copy link
Contributor Author

@FedeDP FedeDP Mar 11, 2024

Choose a reason for hiding this comment

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

We need to short-circuit it here, because otherwise we would FAIL the test below.

@FedeDP
Copy link
Contributor Author

FedeDP commented Mar 11, 2024

/unhold
Fixed issues.

m_fd = syscall(__NR_openat, dirfd, filename, flags, 0);
assert_syscall_state(SYSCALL_SUCCESS, "openat", m_fd, NOT_EQUAL, -1);
// Using the macro that deals with ENOSYS produces a build issue since GTEST_SKIP returns value in a ctor.
_assert_syscall_state(SYSCALL_SUCCESS, "openat", m_fd, NOT_EQUAL, -1);
Copy link
Member

Choose a reason for hiding this comment

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

not clear who calls GTEST_SKIP() here if we use the internal method and not the macro

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nobody :/ this is just a ctor unfortunately
AFAIK openat should be implemented everywhere...hopefully.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway, we will notice immediately since it would break the tests.

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Mar 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, LucaGuerra

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Andreagit97,FedeDP,LucaGuerra]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit 5dc692e into master Mar 11, 2024
41 checks passed
@poiana poiana deleted the fix/enosys_drivers_test branch March 11, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants