philosophers_prep/setup_testers.sh

88 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Quick setup script for the test suite
# Makes all scripts executable and checks dependencies
echo "🔧 Setting up Philosophers Prep Test Suite..."
echo ""
# Make all test scripts executable
echo "Making test scripts executable..."
chmod +x testers/*.sh
if [ $? -eq 0 ]; then
echo "✓ Scripts are now executable"
else
echo "✗ Failed to make scripts executable"
exit 1
fi
echo ""
echo "Checking dependencies..."
echo ""
# Check for gcc
if command -v gcc &> /dev/null; then
GCC_VERSION=$(gcc --version | head -1)
echo "✓ gcc found: $GCC_VERSION"
else
echo "✗ gcc not found - REQUIRED"
echo " Install: sudo apt-get install gcc"
fi
# Check for valgrind
if command -v valgrind &> /dev/null; then
VALGRIND_VERSION=$(valgrind --version)
echo "✓ valgrind found: $VALGRIND_VERSION"
else
echo "⚠ valgrind not found - RECOMMENDED"
echo " Install: sudo apt-get install valgrind"
fi
# Check for pthread
echo -n "Checking pthread support... "
cat > /tmp/pthread_test.c << 'EOF'
#include <pthread.h>
int main() { return 0; }
EOF
gcc -pthread /tmp/pthread_test.c -o /tmp/pthread_test 2>/dev/null
if [ $? -eq 0 ]; then
echo "✓ pthread available"
rm -f /tmp/pthread_test /tmp/pthread_test.c
else
echo "✗ pthread not available"
fi
# Check thread sanitizer support
echo -n "Checking thread sanitizer... "
cat > /tmp/tsan_test.c << 'EOF'
int main() { return 0; }
EOF
gcc -fsanitize=thread /tmp/tsan_test.c -o /tmp/tsan_test 2>/dev/null
if [ $? -eq 0 ]; then
echo "✓ thread sanitizer available"
rm -f /tmp/tsan_test /tmp/tsan_test.c
else
echo "⚠ thread sanitizer not available"
fi
echo ""
echo "=========================================="
echo "Setup complete!"
echo "=========================================="
echo ""
echo "To run all tests:"
echo " bash testers/run_all_tests.sh"
echo ""
echo "To run a specific test:"
echo " bash testers/run_all_tests.sh [1-12]"
echo " Example: bash testers/run_all_tests.sh 1"
echo ""
echo "To run individual test directly:"
echo " bash testers/test_1_thread_basics.sh"
echo ""
echo "Read testers/README.md for more information."
echo ""