140 lines
4.1 KiB
Bash
140 lines
4.1 KiB
Bash
#!/bin/bash
|
|
|
|
# WAV-Only Comprehensive Test Script for 2gopus
|
|
# Tests all versions with WAV files only
|
|
|
|
set -e
|
|
|
|
echo "=== WAV-ONLY COMPREHENSIVE TEST ==="
|
|
echo "Testing all 2gopus versions with WAV files only"
|
|
echo
|
|
|
|
# Test configuration
|
|
TIMEOUT=60
|
|
TEST_DIR="/home/user/Public/2gopus/test_audio"
|
|
OUTPUT_BASE="/tmp/wav_test_results"
|
|
|
|
# Create output directories
|
|
mkdir -p "$OUTPUT_BASE"/{go,rust,cpp,bash,original}
|
|
|
|
# Find WAV files
|
|
WAV_FILES=$(find "$TEST_DIR" -name "*.wav" -type f | sort)
|
|
WAV_COUNT=$(echo "$WAV_FILES" | wc -l)
|
|
|
|
echo "📁 Found $WAV_COUNT WAV files:"
|
|
echo "$WAV_FILES"
|
|
echo
|
|
|
|
# Function to test a version
|
|
test_version() {
|
|
local version_name="$1"
|
|
local binary_path="$2"
|
|
local output_dir="$3"
|
|
local extra_args="$4"
|
|
|
|
echo "🧪 Testing $version_name..."
|
|
echo " Binary: $binary_path"
|
|
echo " Output: $output_dir"
|
|
echo " Extra args: $extra_args"
|
|
|
|
# Clear output directory
|
|
rm -rf "$output_dir"/*
|
|
|
|
# Run with timeout
|
|
if timeout "$TIMEOUT" "$binary_path" $extra_args; then
|
|
echo " ✅ $version_name completed successfully"
|
|
|
|
# Count output files
|
|
local output_count=$(find "$output_dir" -name "*.opus" -o -name "*.ogg" | wc -l)
|
|
echo " 📊 Generated $output_count output files"
|
|
|
|
# Show file sizes
|
|
echo " 📏 Output file sizes:"
|
|
find "$output_dir" -name "*.opus" -o -name "*.ogg" | head -3 | while read file; do
|
|
size=$(stat -c%s "$file" 2>/dev/null || echo "0")
|
|
echo " $(basename "$file"): ${size} bytes"
|
|
done
|
|
|
|
return 0
|
|
else
|
|
local exit_code=$?
|
|
if [ $exit_code -eq 124 ]; then
|
|
echo " ⏰ $version_name timed out after ${TIMEOUT}s"
|
|
else
|
|
echo " ❌ $version_name failed with exit code $exit_code"
|
|
fi
|
|
return $exit_code
|
|
fi
|
|
}
|
|
|
|
# Test all versions
|
|
echo "🚀 Starting WAV-only tests..."
|
|
echo
|
|
|
|
# Test Go Version
|
|
test_version "Go Version" "./go-version/2gopus-go" "$OUTPUT_BASE/go" "-input $TEST_DIR -output $OUTPUT_BASE/go -verbose"
|
|
|
|
# Test Rust Version
|
|
test_version "Rust Version" "./rust-version/target/release/2gopus" "$OUTPUT_BASE/rust" "-i $TEST_DIR -o $OUTPUT_BASE/rust -v"
|
|
|
|
# Test C++ Version
|
|
test_version "C++ Version" "./cpp-version/2gopus" "$OUTPUT_BASE/cpp" "-i $TEST_DIR -o $OUTPUT_BASE/cpp -v"
|
|
|
|
# Test Bash Version
|
|
test_version "Bash Version" "./bash-version/2gopus.sh" "$OUTPUT_BASE/bash" "-i $TEST_DIR -o $OUTPUT_BASE/bash -v"
|
|
|
|
# Test Original (with N input to avoid Y/N prompt)
|
|
echo "🧪 Testing Original Version..."
|
|
echo " Binary: ./original/2gopus"
|
|
echo " Output: $OUTPUT_BASE/original"
|
|
|
|
rm -rf "$OUTPUT_BASE/original"/*
|
|
if timeout "$TIMEOUT" bash -c 'echo "N" | ./original/2gopus -i "$TEST_DIR" -o "$OUTPUT_BASE/original" -v'; then
|
|
echo " ✅ Original Version completed successfully"
|
|
output_count=$(find "$OUTPUT_BASE/original" -name "*.opus" -o -name "*.ogg" | wc -l)
|
|
echo " 📊 Generated $output_count output files"
|
|
else
|
|
exit_code=$?
|
|
if [ $exit_code -eq 124 ]; then
|
|
echo " ⏰ Original Version timed out after ${TIMEOUT}s"
|
|
else
|
|
echo " ❌ Original Version failed with exit code $exit_code"
|
|
fi
|
|
fi
|
|
|
|
echo
|
|
echo "=== WAV-ONLY TEST RESULTS ==="
|
|
echo
|
|
|
|
# Summary of results
|
|
echo "📊 RESULTS SUMMARY:"
|
|
echo "==================="
|
|
|
|
for version in go rust cpp bash original; do
|
|
output_dir="$OUTPUT_BASE/$version"
|
|
if [ -d "$output_dir" ]; then
|
|
file_count=$(find "$output_dir" -name "*.opus" -o -name "*.ogg" 2>/dev/null | wc -l)
|
|
if [ $file_count -gt 0 ]; then
|
|
echo "✅ $version: $file_count files generated"
|
|
else
|
|
echo "❌ $version: No files generated"
|
|
fi
|
|
else
|
|
echo "❌ $version: No output directory"
|
|
fi
|
|
done
|
|
|
|
echo
|
|
echo "📁 Output directories:"
|
|
for version in go rust cpp bash original; do
|
|
output_dir="$OUTPUT_BASE/$version"
|
|
if [ -d "$output_dir" ]; then
|
|
echo " $version: $output_dir"
|
|
ls -la "$output_dir" | head -3
|
|
fi
|
|
done
|
|
|
|
echo
|
|
echo "🎯 WAV-only testing complete!"
|
|
echo "All versions tested with WAV files only."
|