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

[qtest-parallel testing] C++ exception with description "cannot open file test-file: No such file or directory" thrown in the test body. #3878

Closed
vgorrX opened this issue Mar 3, 2024 · 2 comments

Comments

@vgorrX
Copy link
Contributor

vgorrX commented Mar 3, 2024

Probably, there are some problems with test sources for FMT project.
When I start the testing with qtest-parallel the following exception is thrown sometimes:
C++ exception with description "cannot open file test-file: No such file or directory" thrown in the test body.

Possible, I've found out a root cause of this issue and I'm going to share my concerns with you.
Lets to consider two tests, namely:

TEST(file_test, read_error) {
file f("test-file", file::WRONLY);
char buf; // We intentionally read from a file opened in the write-only mode to
// cause error.
EXPECT_SYSTEM_ERROR(f.read(&buf, 1), EBADF, "cannot read from file");
}

TEST(file_test, write_error) {
file f("test-file", file::RDONLY);
// We intentionally write to a file opened in the read-only mode to
// cause error.
EXPECT_SYSTEM_ERROR(f.write(" ", 1), EBADF, "cannot write to file");
}

These tests work w/ the file that has a similar name, namely, test-file .
I suppose, this file can be removed when one test closes it whereas another uses this file a while.
Certainly, I mean the testing in the parallel mode. In my opinion here the exception mentioned above can be thrown rarely.

Could you please confirm or deny my guesses?

Thanks in advance,
Vladimir.

PS. I've prepared a patch that we're using for our CI stand to suppress the problem described there.
You can look at it if you're wondering.

fmt.patch.txt

@vitaut
Copy link
Contributor

vitaut commented Mar 3, 2024

In general we don't support parallel tests but if it's the only issue, a PR to change file name(s) to avoid conflict would be welcome.

vgorrX added a commit to vgorrX/fmt that referenced this issue Mar 5, 2024
uniq test file names for the os-test suite (fmtlib#3878 issue).
@vgorrX
Copy link
Contributor Author

vgorrX commented Mar 6, 2024

Indeed the problem described here can be resolved as the following:

TEST(file_test, read_error) {
file f("test-file", file::WRONLY | file::CREATE);
char buf; // We intentionally read from a file opened in the write-only mode to
// cause error.
EXPECT_SYSTEM_ERROR(f.read(&buf, 1), EBADF, "cannot read from file");
}

I've detected this bug when moved this test case on the top of file.
In other word this test case worked only because it used the test-file as an artefact of another test cases.

vitaut pushed a commit that referenced this issue Mar 6, 2024
uniq test file names for the os-test suite (#3878 issue).
@vitaut vitaut closed this as completed Mar 6, 2024
happymonkey1 pushed a commit to happymonkey1/fmt that referenced this issue Apr 7, 2024
uniq test file names for the os-test suite (fmtlib#3878 issue).
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

No branches or pull requests

2 participants