From c9140bbcbd386626c7d166c5789b826675c35daa Mon Sep 17 00:00:00 2001 From: leelee Date: Tue, 24 Mar 2026 17:41:07 +0800 Subject: [PATCH 1/2] unittest: add gtest_parallel to speed up unit test execution --- .github/build-linux/test.sh | 9 +++++++-- .gitmodules | 3 +++ gtest-parallel | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 gtest-parallel diff --git a/.github/build-linux/test.sh b/.github/build-linux/test.sh index b7e49cb9b..f3ce80ee3 100755 --- a/.github/build-linux/test.sh +++ b/.github/build-linux/test.sh @@ -22,6 +22,11 @@ export CODON_PYTHON=$(python ${WORKSPACE}/test/python/find-python-library.py) export PYTHONPATH=${WORKSPACE}/test/python export CODON_DIR=$(pwd)/codon-deploy-${ARCH} +GTEST_PARALLEL="${WORKSPACE}/gtest-parallel/gtest-parallel" +if [ ! -f "${GTEST_PARALLEL}" ]; then + git submodule update --init --recursive +fi + echo "=> Unit tests..." mkdir -p build # needed for some tests that write into this directory if [ "${ARCH}" = "darwin-x86_64" ]; then @@ -29,10 +34,10 @@ if [ "${ARCH}" = "darwin-x86_64" ]; then # (macOS 14 Intel runners are not free). # arithmetic.codon fails in debug mode on x86 due to float16 (TODO: why?) export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES - time build-${ARCH}/codon_test --gtest_filter="-*numpy*:*core_arithmetic_codon_debug*" + time "${GTEST_PARALLEL}" build-${ARCH}/codon_test --gtest_filter="-*numpy*:*core_arithmetic_codon_debug*" # :*python*:*core_arithmetic*:*stdlib_random_test*" else - time build-${ARCH}/codon_test + time "${GTEST_PARALLEL}" build-${ARCH}/codon_test fi echo "=> Standalone test..." diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..0d1abcffd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "gtest-parallel"] + path = gtest-parallel + url = https://github.com/google/gtest-parallel.git diff --git a/gtest-parallel b/gtest-parallel new file mode 160000 index 000000000..cd488bded --- /dev/null +++ b/gtest-parallel @@ -0,0 +1 @@ +Subproject commit cd488bdedc1d2cffb98201a17afc1b298b0b90f1 From 801a10a0cd67cb0f87a0e6141121cdf985b5e50d Mon Sep 17 00:00:00 2001 From: leelee Date: Tue, 31 Mar 2026 11:12:57 +0800 Subject: [PATCH 2/2] fix: resolve pipe deadlock --- test/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/main.cpp b/test/main.cpp index 463490ad8..11276d9c0 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -314,8 +314,16 @@ class SeqTest GC_atfork_parent(); int status = -1; close(out_pipe[1]); + + buf.clear(); + char temp_buf[4096]; + ssize_t n; + while ((n = read(out_pipe[0], temp_buf, sizeof(temp_buf))) > 0) { + buf.insert(buf.end(), temp_buf, temp_buf + n); + } + buf.push_back('\0'); + assert(waitpid(pid, &status, 0) == pid); - read(out_pipe[0], buf.data(), buf.size() - 1); close(out_pipe[0]); return status; }