facebookexperimental / facebookexperimental/edencommon

Some tests fail when building as another user

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
13
Forks
19
PR merge metrics
No merged PRs in 30d

Description

The following two tests fail because they rely on getting the real username, which fails in build systems like Portage that run the tests as a sandboxed user:

https://github.com/facebookexperimental/edencommon/blob/e905ac762585238d91b0479f8b88d8393d6a97fc/eden/common/utils/test/ProcessInfoTest.cpp#L47-L52

https://github.com/facebookexperimental/edencommon/blob/e905ac762585238d91b0479f8b88d8393d6a97fc/eden/common/utils/test/ProcessInfoTest.cpp#L20-L34

Test output:

```
134/168 Testing: ProcessInfoTest.readUserInfoForCurrentProcess
134/168 Test: ProcessInfoTest.readUserInfoForCurrentProcess
Command: "/var/tmp/portage/dev-cpp/edencommon-2025.04.14.00/work/edencommon-2025.04.14.00_build/eden/common/utils/test/utils_test" "--gtest_filter=ProcessInfoTest.readUserInfoForCurrentProcess" "--gtest_also_run_disabled_tests"
Directory: /var/tmp/portage/dev-cpp/edencommon-2025.04.14.00/work/edencommon-2025.04.14.00_build/eden/common/utils/test
"ProcessInfoTest.readUserInfoForCurrentProcess" start time: Apr 21 20:29 CEST
Output:
----------------------------------------------------------
Running main() from gmock_main.cc
Note: Google Test filter = ProcessInfoTest.readUserInfoForCurrentProcess
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ProcessInfoTest
[ RUN ] ProcessInfoTest.readUserInfoForCurrentProcess
/var/tmp/portage/dev-cpp/edencommon-2025.04.14.00/work/edencommon-2025.04.14.00/eden/common/utils/test/ProcessInfoTest.cpp:33: Failure
Expected equality of these values:
userInfo->getRealUsername()
Which is: "portage"
username
Which is: "agni"

[ FAILED ] ProcessInfoTest.readUserInfoForCurrentProcess (0 ms)
[----------] 1 test from ProcessInfoTest (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] ProcessInfoTest.readUserInfoForCurrentProcess

1 FAILED TEST

Test time = 0.03 sec
----------------------------------------------------------
Test Failed.
"ProcessInfoTest.readUserInfoForCurrentProcess" end time: Apr 21 20:29 CEST
"ProcessInfoTest.readUserInfoForCurrentProcess" time elapsed: 00:00:00
----------------------------------------------------------

136/168 Testing: ProcessInfoTest.testUidToUsername
136/168 Test: ProcessInfoTest.testUidToUsername
Command: "/var/tmp/portage/dev-cpp/edencommon-2025.04.14.00/work/edencommon-2025.04.14.00_build/eden/common/utils/test/utils_test" "--gtest_filter=ProcessInfoTest.testUidToUsername" "--gtest_also_run_disabled_tests"
Directory: /var/tmp/portage/dev-cpp/edencommon-2025.04.14.00/work/edencommon-2025.04.14.00_build/eden/common/utils/test
"ProcessInfoTest.testUidToUsername" start time: Apr 21 20:29 CEST
Output:
----------------------------------------------------------
Running main() from gmock_main.cc
Note: Google Test filter = ProcessInfoTest.testUidToUsername
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ProcessInfoTest
[ RUN ] ProcessInfoTest.testUidToUsername
/var/tmp/portage/dev-cpp/edencommon-2025.04.14.00/work/edencommon-2025.04.14.00/eden/common/utils/test/ProcessInfoTest.cpp:56: Failure
Expected equality of these values:
ProcessUserInfo::uidToUsername(getuid())
Which is: "portage"
username
Which is: "agni"

[ FAILED ] ProcessInfoTest.testUidToUsername (0 ms)
[----------] 1 test from ProcessInfoTest (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] ProcessInfoTest.testUidToUsername

1 FAILED TEST

Test time = 0.02 sec
----------------------------------------------------------
Test Failed.
"ProcessInfoTest.testUidToUsername" end time: Apr 21 20:29 CEST
"ProcessInfoTest.testUidToUsername" time elapsed: 00:00:00
----------------------------------------------------------
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.