Skip to content

added more tests for socketpair syscall and fixed an issue with prior socketpair test #256

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

Merged
merged 12 commits into from
Jul 2, 2024

Conversation

qianxichen233
Copy link
Contributor

Description

Fixes # (issue)

This PR added more tests for the socketpair syscall, and fixed an issue for prior socketpair test that could stuck the entire test in some cases, especially, when a test inside a non-main thread failed, the thread will panic and the main thread will never be able to return from recv_syscall as it is waiting message from an already dead thread. Fix involves creating dedicated thread for each peer and using non-blocking thread join method. Besides the fix of the old test, below is the new tests cased being added:

  1. socketpair_syscall called with SOCK_NONBLOCK flag set
  2. socketpair_syscall called with SOCK_CLOEXEC flag set
  3. socketpair_syscall called with bad inputs to test for error code

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

This PR is a test itself, and currently all the tests were passed.

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been added to a pull request and/or merged in other modules (native-client, lind-glibc, lind-project)

@qianxichen233 qianxichen233 changed the title Socketpair improve added more tests for socketpair syscall and fixed an issue with prior socketpair test Jun 3, 2024
Copy link
Member

@Yaxuan-w Yaxuan-w left a comment

Choose a reason for hiding this comment

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

Great job! Tests are comprehensive. LGTM with a minor question

Copy link
Member

@JustinCappos JustinCappos left a comment

Choose a reason for hiding this comment

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

Looks good overall! A few minor comments / request for changes...

@yashaswi2000
Copy link
Contributor

Good work on the tests! , Needs more documentation on what is intended and how we are testing. Missing comments on the original Socketpair syscall in net_calls.rs, and potential error checking improvements there.

@qianxichen233 qianxichen233 requested review from davidge20 and removed request for rennergade and yashaswi2000 June 25, 2024 02:19
@qianxichen233
Copy link
Contributor Author

@davidge20 Could you review my socketpair PR?

Copy link
Contributor

@davidge20 davidge20 left a comment

Choose a reason for hiding this comment

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

I learned a lot from reading through your tests! Great work overall!

Just a note, I would appreciate more comments especially at the top of blocks of code that perform something. This would help me out a lot.

Copy link
Contributor

@yashaswi2000 yashaswi2000 left a comment

Choose a reason for hiding this comment

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

LGTM

/// On success, zero is returned. Otherwise, errors or panics are returned for
/// different scenarios.
///
/// ### Errors
Copy link
Contributor

Choose a reason for hiding this comment

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

add a panic section after this, mentioning when can this function panic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not find any place that might cause panic currently. But I just wonder is the panic something that should occur inside the syscalls? I just feel like whenever something goes wrong, we should always return a syscall error instead of letting it panic directly. A panic inside the syscall would look like a bug to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm that's something to think about. ideally I agree with your line of thought, but the purpose of panic is kind of to say something went wrong when it shouldn't. And it might not be related to the logic of the Syscall. @rennergade your thoughts on this?

Copy link
Contributor

@rennergade rennergade left a comment

Choose a reason for hiding this comment

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

Some minor changes requested from Yash and I. Once those are addressed I think this is good to go!

@qianxichen233 qianxichen233 requested a review from rennergade July 2, 2024 05:18
Copy link
Contributor

@rennergade rennergade left a comment

Choose a reason for hiding this comment

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

Great! Approved.

@rennergade rennergade merged commit 3ecae1d into develop Jul 2, 2024
1 of 2 checks passed
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.

6 participants