| 1 |
#!/bin/bash |
| 2 |
# Test that abPOA's klib symbols are properly namespaced by compiling |
| 3 |
# a program that defines its own bare kmalloc/kfree and linking against |
| 4 |
# libabpoa.a. If abPOA still exports bare symbols, the linker will |
| 5 |
# either error or our test's assertion will catch the collision. |
| 6 |
set -e |
| 7 |
|
| 8 |
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 9 |
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 10 |
cd "$PROJECT_DIR" |
| 11 |
|
| 12 |
LIB="lib/libabpoa.a" |
| 13 |
if [ ! -f "$LIB" ]; then |
| 14 |
echo "SKIP: $LIB not found (run make first)" |
| 15 |
exit 1 |
| 16 |
fi |
| 17 |
|
| 18 |
BUILD_DIR="/tmp/abpoa_dual_link_$$" |
| 19 |
trap "rm -rf $BUILD_DIR" EXIT |
| 20 |
mkdir -p "$BUILD_DIR" |
| 21 |
|
| 22 |
if ! gcc tests/test_dual_link.c -Iinclude -Llib -labpoa -lz -lm -lpthread \ |
| 23 |
-o "$BUILD_DIR/test_dual_link" 2>"$BUILD_DIR/compile.log"; then |
| 24 |
echo "FAIL: test_dual_link.c failed to compile" |
| 25 |
cat "$BUILD_DIR/compile.log" |
| 26 |
exit 1 |
| 27 |
fi |
| 28 |
|
| 29 |
if ! "$BUILD_DIR/test_dual_link" 2>"$BUILD_DIR/run.log"; then |
| 30 |
echo "FAIL: test_dual_link assertion failed" |
| 31 |
cat "$BUILD_DIR/run.log" |
| 32 |
exit 1 |
| 33 |
fi |
| 34 |
|
| 35 |
echo "Dual-link symbol collision test passed" |
| 36 |
exit 0 |