Skip to content

Commit 70b81ea

Browse files
committed
fix tests on macos
1 parent 950d55b commit 70b81ea

4 files changed

Lines changed: 39 additions & 21 deletions

File tree

tests/test_cmake_dispatch.sh

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if ! cmake -B "$BUILD_DIR" -S . -DCMAKE_BUILD_TYPE=Release >/dev/null 2>&1; then
1919
fi
2020

2121
if [ $ERRORS -eq 0 ]; then
22-
if ! cmake --build "$BUILD_DIR" -j$(nproc) >/dev/null 2>&1; then
22+
if ! cmake --build "$BUILD_DIR" -j$(sysctl -n hw.logicalcpu 2>/dev/null || nproc 2>/dev/null || echo 4) >/dev/null 2>&1; then
2323
echo "FAIL: cmake build failed"
2424
ERRORS=$((ERRORS + 1))
2525
fi
@@ -37,23 +37,35 @@ if [ -z "$CMAKE_LIB" ]; then
3737
exit 1
3838
fi
3939

40-
SYMBOLS=$(nm -g "$CMAKE_LIB" 2>/dev/null | grep " T " | awk '{print $3}')
40+
SYMBOLS=$(nm -g "$CMAKE_LIB" 2>/dev/null | grep " T " | awk '{print $3}' | sed 's/^_//')
4141

42-
# Check for per-ISA dispatch symbols
43-
for sym in simd_sse2_abpoa_align_sequence_to_subgraph \
44-
simd_sse41_abpoa_align_sequence_to_subgraph \
45-
simd_avx2_abpoa_align_sequence_to_subgraph \
46-
simd_avx512_abpoa_align_sequence_to_subgraph \
47-
simd_abpoa_align_sequence_to_subgraph \
48-
simd_abpoa_align_sequence_to_graph; do
49-
if ! echo "$SYMBOLS" | grep -qx "$sym"; then
50-
echo "FAIL: dispatch symbol '$sym' not found in CMake-built library"
51-
ERRORS=$((ERRORS + 1))
52-
fi
53-
done
42+
ARCH=$(uname -m)
43+
if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then
44+
# Check for per-ISA dispatch symbols (x86 only)
45+
for sym in simd_sse2_abpoa_align_sequence_to_subgraph \
46+
simd_sse41_abpoa_align_sequence_to_subgraph \
47+
simd_avx2_abpoa_align_sequence_to_subgraph \
48+
simd_avx512_abpoa_align_sequence_to_subgraph \
49+
simd_abpoa_align_sequence_to_subgraph \
50+
simd_abpoa_align_sequence_to_graph; do
51+
if ! echo "$SYMBOLS" | grep -qx "$sym"; then
52+
echo "FAIL: dispatch symbol '$sym' not found in CMake-built library"
53+
ERRORS=$((ERRORS + 1))
54+
fi
55+
done
56+
else
57+
# Non-x86: just verify the generic align symbols are present
58+
for sym in simd_abpoa_align_sequence_to_subgraph \
59+
simd_abpoa_align_sequence_to_graph; do
60+
if ! echo "$SYMBOLS" | grep -qx "$sym"; then
61+
echo "FAIL: dispatch symbol '$sym' not found in CMake-built library"
62+
ERRORS=$((ERRORS + 1))
63+
fi
64+
done
65+
fi
5466

5567
# Compare output with Makefile reference
56-
CMAKE_BIN=$(find "$BUILD_DIR" -name 'abpoa' -type f -executable | head -1)
68+
CMAKE_BIN=$(find "$BUILD_DIR" -name 'abpoa' -type f -perm +111 | head -1)
5769
if [ -z "$CMAKE_BIN" ]; then
5870
echo "FAIL: abpoa binary not found in CMake build"
5971
ERRORS=$((ERRORS + 1))

tests/test_cmake_lib_only.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if ! cmake -B "$BUILD_DIR" -S . -DABPOA_BUILD_EXE=OFF \
1818
echo "FAIL: cmake configure failed (ABPOA_BUILD_EXE=OFF)"
1919
exit 1
2020
fi
21-
if ! cmake --build "$BUILD_DIR" -j$(nproc) >/dev/null 2>&1; then
21+
if ! cmake --build "$BUILD_DIR" -j$(sysctl -n hw.logicalcpu 2>/dev/null || nproc 2>/dev/null || echo 4) >/dev/null 2>&1; then
2222
echo "FAIL: cmake build failed (ABPOA_BUILD_EXE=OFF)"
2323
exit 1
2424
fi
@@ -32,7 +32,7 @@ else
3232
fi
3333

3434
# Binary must NOT exist
35-
if find "$BUILD_DIR" -name 'abpoa' -type f -executable | grep -q .; then
35+
if find "$BUILD_DIR" -name 'abpoa' -type f -perm +111 | grep -q .; then
3636
echo "FAIL: abpoa binary found in lib-only build (should be disabled)"
3737
ERRORS=$((ERRORS + 1))
3838
fi
@@ -45,12 +45,12 @@ if ! cmake -B "$BUILD_DIR2" -S . -DCMAKE_BUILD_TYPE=Release >/dev/null 2>&1; the
4545
echo "FAIL: cmake configure failed (default build)"
4646
exit 1
4747
fi
48-
if ! cmake --build "$BUILD_DIR2" -j$(nproc) >/dev/null 2>&1; then
48+
if ! cmake --build "$BUILD_DIR2" -j$(sysctl -n hw.logicalcpu 2>/dev/null || nproc 2>/dev/null || echo 4) >/dev/null 2>&1; then
4949
echo "FAIL: cmake build failed (default build)"
5050
exit 1
5151
fi
5252

53-
if ! find "$BUILD_DIR2" -name 'abpoa' -type f -executable | grep -q .; then
53+
if ! find "$BUILD_DIR2" -name 'abpoa' -type f -perm +111 | grep -q .; then
5454
echo "FAIL: abpoa binary not found in default build (should be built)"
5555
ERRORS=$((ERRORS + 1))
5656
fi

tests/test_portable_alloc.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ fi
3535

3636
# Compile and run the alignment verification test
3737
if [ -f tests/test_aligned_alloc.c ]; then
38-
if gcc -march=native tests/test_aligned_alloc.c -I src -I include \
38+
ARCH=$(uname -m)
39+
if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then
40+
EXTRA_DEFS=""
41+
else
42+
EXTRA_DEFS="-DUSE_SIMDE -DSIMDE_ENABLE_NATIVE_ALIASES"
43+
fi
44+
if gcc -march=native $EXTRA_DEFS tests/test_aligned_alloc.c -I src -I include \
3945
-o /tmp/test_aligned_alloc 2>/tmp/test_aligned_alloc.err; then
4046
if ! /tmp/test_aligned_alloc; then
4147
echo "FAIL: aligned allocation test failed at runtime"

tests/test_symbol_namespacing.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ ! -f "$LIB" ]; then
1414
exit 1
1515
fi
1616

17-
SYMBOLS=$(nm -g "$LIB" 2>/dev/null | grep " T " | awk '{print $3}')
17+
SYMBOLS=$(nm -g "$LIB" 2>/dev/null | grep " T " | awk '{print $3}' | sed 's/^_//')
1818
ERRORS=0
1919

2020
# These bare symbols must NOT appear

0 commit comments

Comments
 (0)