#!/bin/bash # simple_surnames_validation.sh - Robust and simple DBLP_FILE="${1:-dblp.xml.gz}" TEMP_DIR="/tmp/surnames_val_$$" echo "=== Simple Surname Validation ===" echo "Input: $DBLP_FILE" mkdir -p "$TEMP_DIR" # Sequential execution to avoid pipe issues echo "Running C program..." gunzip -c "$DBLP_FILE" | ./surnames > "$TEMP_DIR/c_results.txt" c_count=$(wc -l < "$TEMP_DIR/c_results.txt") c_wang=$(head -1 "$TEMP_DIR/c_results.txt") echo "Running Python validation..." gunzip -c "$DBLP_FILE" | python3 surnames.py > "$TEMP_DIR/python_results.txt" python_count=$(wc -l < "$TEMP_DIR/python_results.txt") python_wang=$(head -1 "$TEMP_DIR/python_results.txt") echo "Results:" echo " C program: $c_count surnames" echo " Python script: $python_count surnames" echo " C top result: $c_wang" echo " Python top result: $python_wang" if diff -q "$TEMP_DIR/c_results.txt" "$TEMP_DIR/python_results.txt" > /dev/null; then echo "✓ Results are identical!" else echo "⚠ Results differ - checking details..." diff "$TEMP_DIR/c_results.txt" "$TEMP_DIR/python_results.txt" | head -10 fi echo "Memory check..." echo "test" | valgrind --leak-check=yes ./surnames > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "✓ No memory leaks detected" fi # Cleanup rm -rf "$TEMP_DIR" echo "Validation complete!"