Workaround for parallel writing of LLVM profiler data

Skip failing tests on cygwin: we'll just have to mark the unix socket feature as "experimental", but shouldn't block merging it due to cygwin being weird
This commit is contained in:
Alexey Sokolov
2025-05-01 22:24:10 +01:00
parent 5184d662d3
commit 5974d0ff3b
4 changed files with 48 additions and 2 deletions

2
.github/build.sh vendored
View File

@@ -47,7 +47,7 @@ case "${CC:-gcc}" in
export PATH=$PATH:/Library/Developer/CommandLineTools/usr/bin
fi
llvm-profdata merge unittest.profraw -o unittest.profdata
llvm-profdata merge inttest.profraw -o inttest.profdata
llvm-profdata merge inttest.profraw* -o inttest.profdata
llvm-cov show -show-line-counts-or-regions -instr-profile=unittest.profdata test/unittest_bin > unittest-cmake-coverage.txt
llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata /usr/local/bin/znc > inttest-znc-coverage.txt
find /usr/local/lib/znc -name '*.so' -or -name '*.bundle' | while read f; do llvm-cov show -show-line-counts-or-regions -instr-profile=inttest.profdata $f > inttest-$(basename $f)-coverage.txt; done

View File

@@ -102,6 +102,7 @@ add_custom_target(inttest COMMAND
# znc-buildmod should use the correct compiler.
# https://bugs.gentoo.org/699258 is an example of how it can go wrong.
${CMAKE_COMMAND} -E env MAKEFLAGS= CXX=${CMAKE_CXX_COMPILER}
"INTTEST_BIN=${CMAKE_CURRENT_BINARY_DIR}/integration/inttest"
"${PROJECT_SOURCE_DIR}/third_party/gtest-parallel/gtest-parallel"
"${CMAKE_CURRENT_BINARY_DIR}/integration/inttest")
"${CMAKE_CURRENT_SOURCE_DIR}/integration/wrapper.py")
add_dependencies(inttest inttest_bin)

View File

@@ -159,6 +159,9 @@ TEST_F(ZNCTest, ModperlSocket) {
TEST_F(ZNCTest, ModpythonUnixSocket) {
#ifndef WANT_PYTHON
GTEST_SKIP() << "Modpython is disabled";
#endif
#ifdef __CYGWIN__
GTEST_SKIP() << "Bug to fix: https://github.com/znc/znc/issues/1947";
#endif
auto znc = Run();
znc->CanLeak();
@@ -207,6 +210,9 @@ TEST_F(ZNCTest, ModpythonUnixSocket) {
TEST_F(ZNCTest, ModperlUnixSocket) {
#ifndef WANT_PERL
GTEST_SKIP() << "Modperl is disabled";
#endif
#ifdef __CYGWIN__
GTEST_SKIP() << "Bug to fix: https://github.com/znc/znc/issues/1947";
#endif
auto znc = Run();
znc->CanLeak();

39
test/integration/wrapper.py Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python3
#
# Copyright (C) 2004-2025 ZNC, see the NOTICE file for details.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# The purpose of this file is to fix LLVM profiler data in the parallel
# execution of the test - all of them write to the same file, so it races and
# produces invalid data
import os
import sys
import re
test = ''
for arg in sys.argv:
m = re.match(r'--gtest_filter=(.*)', arg)
if m:
test = m[1]
break
if test != '' and 'LLVM_PROFILE_FILE' in os.environ:
os.environ['LLVM_PROFILE_FILE'] += '.' + test
binary = os.environ['INTTEST_BIN']
sys.argv[0] = binary
os.execv(binary, sys.argv)