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

[Bug]: No details about why GetTempFileName fails #4566

Open
BenSluis opened this issue Jun 25, 2024 · 0 comments · May be fixed by #4578
Open

[Bug]: No details about why GetTempFileName fails #4566

BenSluis opened this issue Jun 25, 2024 · 0 comments · May be fixed by #4578

Comments

@BenSluis
Copy link

BenSluis commented Jun 25, 2024

Describe the issue

When using gtest on Windows, I'm seeing sporadic messages saying "Unable to create a temporary file in " and the path to the temp folder. These messages are coming from third_party/gtest/src/gtest-port.cc, L1045. I would like this line to include a call to GetLastError so that I can get more information from the operating system about what exactly is going wrong so I can fix my sporadic error.

Requested addition:

    GTEST_CHECK_(success != 0)
        << "Unable to create a temporary file in " << temp_dir_path << ". Error code: " << ::GetLastError();

Steps to reproduce the problem

Download the git repo at https://github.com/BenSluis/googletest, checkout the error_code_temp_file branch.

Build samples:

cd googletest
mkdir build
cd build
cmake.exe .. -Dgtest_build_samples=ON
cmake.exe --build . --config Debug

Run sample1 with the custom changes from https://github.com/BenSluis/googletest/tree/error_code_temp_file .

set TMP=E:\badtemppath
cd googletest\Debug
sample1_unittest.exe

It should show the last error message and exits with 3.

Running main() from E:\googletest\googletest\src\gtest_main.cc
[==========] Running 6 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN ] FactorialTest.Negative

[ FATAL ] E:\googletest\googletest\src/gtest-port.cc(1044):: Condition success != 0 failed. Unable to create a temporary file in E:\badtemppath. Error code: 267

Without the GetLastError change, it shows the following and exits with 3.

Running main() from E:\googletest\googletest\src\gtest_main.cc
[==========] Running 6 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN ] FactorialTest.Negative

[ FATAL ] E:\googletest\googletest\src/gtest-port.cc(1044):: Condition success != 0 failed. Unable to create a temporary file in E:\badtemppath\

What version of GoogleTest are you using?

v1.14.0

What operating system and version are you using?

  • Windows Server 2022, 10.0.20348
  • Windows 11, 10.0.22631

What compiler and version are you using?

MSVC 19.40.33811.0

What build system are you using?

cmake version 3.27.1

Additional context

No response

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 a pull request may close this issue.

1 participant