This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new bf0d1022d8c [test](be) Fix internal_rpc_tls_test compilation on macOS
(#71117)
bf0d1022d8c is described below
commit bf0d1022d8c77b358032a5efa9aeddb93380f116
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Mon Nov 30 11:16:11 2026 +0800
[test](be) Fix internal_rpc_tls_test compilation on macOS (#71117)
### Background
`be/test/util/internal_rpc_tls_test.cpp` (added by #70697) generates its
TLS fixture by spawning a shell with `posix_spawnp(..., environ)`, so
the child inherits the test's environment. POSIX leaves the declaration
of `environ` to the program; glibc's `<unistd.h>` declares it when
`_GNU_SOURCE` is defined, which the Linux build always has, and macOS's
`<unistd.h>` does not declare it.
### What problem does this PR solve?
Issue Number: None
Related PR: #70697 (added the test)
PR Type: Test
Problem Summary: On macOS the BE unit tests no longer build:
`internal_rpc_tls_test.cpp:95` fails with `use of undeclared identifier
'environ'`, and since every test is linked into one `doris_be_test`
binary, no BE unit test can run locally on a Mac. This PR declares
`extern char** environ;` at global scope in that test, the form POSIX
documents. Linux builds see a second, identical declaration of what
`<unistd.h>` already declares, and nothing else changes.
### Details
- **Failure:** macOS arm64, `run-be-ut.sh` at master `d97993b7256`:
`../test/util/internal_rpc_tls_test.cpp:95:85: error: use of undeclared
identifier 'environ'`, the build stops and `doris_be_test` is not
linked.
- **Cause:** the test uses `environ` without declaring it and relies on
glibc's `<unistd.h>` to do so; macOS's headers don't.
- **Stability evidence:** a compile error, not a flaky test; with the
declaration the file compiles and the suite passes on macOS (see
Testing).
### Testing
- macOS arm64, ASAN, `run-be-ut.sh` with
`--gtest_filter=InternalRpcTlsTest.*`: before the change the build fails
with the error above; after it `doris_be_test` links and all 21
`InternalRpcTlsTest` tests pass.
- Linux: not built locally; the declaration is identical to the one
glibc provides, and the BE UT pipelines cover it.
- `clang-format` 16 reports no change.
---
be/test/util/internal_rpc_tls_test.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/be/test/util/internal_rpc_tls_test.cpp
b/be/test/util/internal_rpc_tls_test.cpp
index 8366acf7914..d2a63268287 100644
--- a/be/test/util/internal_rpc_tls_test.cpp
+++ b/be/test/util/internal_rpc_tls_test.cpp
@@ -66,6 +66,10 @@
#include "util/thrift_rpc_helper.h"
#include "util/thrift_server.h"
+// POSIX leaves declaring environ to the program: glibc's <unistd.h> declares
it under
+// _GNU_SOURCE, macOS's does not.
+extern char** environ;
+
namespace doris {
namespace {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]