Repository navigation
Expand file tree
/
Copy pathrun_test.sh
More file actions
65 lines (55 loc) · 1.65 KB
/
Copy pathrun_test.sh
File metadata and controls
65 lines (55 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Run test script for drone routing solution
echo "🚁 Multi-Drone Routing Optimization Test"
echo "=========================================="
echo ""
# Check if Python is available
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is not installed"
exit 1
fi
echo "✅ Python 3 found: $(python3 --version)"
echo ""
# Run small test case
echo "📦 Running small test case..."
echo "Input: test_cases/sample_small.json"
echo ""
start_time=$(date +%s%N)
python3 solution_current.py < test_cases/sample_small.json > output_small.json 2>&1
exit_code=$?
end_time=$(date +%s%N)
elapsed_ms=$(( (end_time - start_time) / 1000000 ))
if [ $exit_code -eq 0 ]; then
echo "✅ Solution completed successfully"
echo "⏱️ Runtime: ${elapsed_ms}ms"
echo ""
# Validate output
if [ -f output_small.json ]; then
deliveries=$(python3 -c "
import json
try:
data = json.load(open('output_small.json'))
manifest = data.get('flight_manifest', [])
delivered = set()
for drone in manifest:
for step in drone.get('path', []):
if step.get('action') == 'DELIVER':
delivered.add(step.get('delivery_id'))
print(f'Deliveries: {len(delivered)}/5')
print(f'Drones used: {len(manifest)}')
except Exception as e:
print(f'Error parsing output: {e}')
" 2>&1)
echo "$deliveries"
echo ""
echo "📄 Output saved to: output_small.json"
else
echo "⚠️ No output file generated"
fi
else
echo "❌ Solution failed with exit code: $exit_code"
exit 1
fi
echo ""
echo "=========================================="
echo "✨ Test completed!"