Debian Codegraph @

tests/test_no_simd_include.sh

raw
1 #!/bin/bash
2 # Test that include/abpoa.h does not leak SIMD types into the public API.
3 # After making abpoa_simd_matrix_t opaque, the public header should:
4 # 1. NOT include simd_instruction.h
5 # 2. NOT reference SIMDi type
6 # 3. Compile without any -m SIMD flags
7 set -e
8
9 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
10 PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
11 cd "$PROJECT_DIR"
12
13 ERRORS=0
14
15 if grep -q '#include.*simd_instruction' include/abpoa.h; then
16 echo "FAIL: include/abpoa.h still includes simd_instruction.h"
17 ERRORS=$((ERRORS + 1))
18 fi
19
20 if grep -q 'SIMDi' include/abpoa.h; then
21 echo "FAIL: include/abpoa.h still references SIMDi type"
22 ERRORS=$((ERRORS + 1))
23 fi
24
25 # Compile a consumer file with only -I include and NO SIMD flags.
26 # This must succeed if the public header is clean.
27 if [ -f tests/test_opaque_header.c ]; then
28 if ! gcc -c -Wall -Werror -I include tests/test_opaque_header.c \
29 -o /tmp/test_opaque_header.o 2>/tmp/test_opaque_header.err; then
30 echo "FAIL: test_opaque_header.c does not compile without SIMD flags"
31 cat /tmp/test_opaque_header.err
32 ERRORS=$((ERRORS + 1))
33 fi
34 rm -f /tmp/test_opaque_header.o /tmp/test_opaque_header.err
35 fi
36
37 if [ $ERRORS -gt 0 ]; then
38 echo "$ERRORS opaque header errors"
39 exit 1
40 fi
41
42 echo "Public header is SIMD-clean"
43 exit 0