Skip to content

Tests: allow verifying how arguments, return values, and mutable pointer arguments are translated #303

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

Open
kamalmarhubi opened this issue Mar 9, 2016 · 1 comment

Comments

@kamalmarhubi
Copy link
Member

I've been thinking about what the functionality of nix is, and how we're testing it. Right now, most of our tests are actually making system calls, and so we're reliant on the test environment behaving how we'd like.

One place I found this problematic is in testing mount on Linux: you ordinarily need root privileges to mount. You can get around it with mount namespaces, but then you are limited to certain filesystem types and operations. Also you're limited to having unprivileged namespaces available. See #248 and the test runner I wrote.

But what nix is actually providing is a "translation" from Rust to system APIs and back, and that's what we should be testing. This is particularly obvious in places where we're not just accepting and returning primitives. Some examples:

  • fork, where we force the user to confront the fact that fork can fail by returning a Result, and allow you to pattern match to determine if whether you're in child or parent
  • mount accepts an Option for its various arguments
  • chown accepts an Option for the uid and gid arguments
@kamalmarhubi
Copy link
Member Author

@posborne opened a thread on reddit about mocking external functions.

Additionally, I've been itching to put together a ptrace-based test suite, where we can test what arguments our wrappers send through to system calls, and also control the return values and make sure the wrappers handle them properly.

@kamalmarhubi kamalmarhubi changed the title Find a new testing strategy that allows verifying arguments and simulating failures Tests: allow verifying how arguments, return values, and mutable pointer arguments are translated Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants