-
Notifications
You must be signed in to change notification settings - Fork 10
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
Testing cleanup: Unify use of EXPECT/ASSERT in Landlock kselftests #31
Comments
Another point, we are also using ASSERT in a bunch of places in fs_test.c where we should have used EXPECT. The earlier we clean this up, the less we are going to cargo cult the wrong patterns in the future. For reference, the same macros exist in the C++ Googletest framework, where they are documented at https://google.github.io/googletest/primer.html#same-data-multiple-tests:
In C++, people tend to use |
Shouldn't we try to un-setup as much as possible e.g., to avoid other tests to fail because of a half-run teardown? All current Landlock FS tests use the same "tmp" directory, but we could use a dedicated directory per test suite to avoid potential cascading failures. FYI, my latest kselftest commits (introducing
Agree! We should probably also add a README in the selftests/landlock/ too, highlighting common issues (e.g. "Only use ASSERT when a prerequisite is not meet and if it doesn't make sense to run the following tests"), and point to the GoogleTest doc. I see a set of (sequential) tasks to improve tests:
|
We've been inconsistently using EXPECT and ASSERT in Landlock's selftests, especially for teardown. (fs_test.c uses
ASSERT_EQ(0, close(fd))
whereas net_test.c usesEXPECT_EQ(0, close(fd))
everywhere).I personally prefer to use ASSERT in these places, because ASSERT is also used for test setup, and the test teardown is largely symmetric to the corresponding setup code, it touches the same underlying objects and should thus use ASSERT as well. (I don't feel strongly about it though.)
The text was updated successfully, but these errors were encountered: