blob: e3362b3a4f1aa5b3a0f95e29c1587c70085b661f (
plain)
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
|
#!/bin/bash
#
# Test verbose logging for DS-Sim protocols
#
echo "DS-Sim Verbose Logging Test"
echo "=========================="
echo
echo "This demonstrates real-time logging during protocol simulation."
echo
# Compile if needed
if [ ! -d "target/classes" ]; then
echo "Building project..."
mvn compile -q || { echo "Build failed!"; exit 1; }
fi
# Run ping-pong for just 2 seconds with verbose output
echo "Running ping-pong protocol for 2 seconds with verbose output..."
echo
# Create a simple test that runs for a limited time
cat > /tmp/TestVerbose.java << 'EOF'
import testing.*;
public class TestVerbose {
public static void main(String[] args) throws Exception {
String simFile = args.length > 0 ? args[0] : "saved-simulations/ping-pong.dat";
int duration = args.length > 1 ? Integer.parseInt(args[1]) : 2000;
System.out.println("Loading: " + simFile);
System.out.println("Duration: " + duration + "ms");
System.out.println("\n--- Real-Time Log Output ---\n");
HeadlessSimulationRunner runner = new HeadlessSimulationRunner();
runner.setPrintLogs(true);
try {
SimulationResult result = runner.runSimulation(simFile, duration);
System.out.println("\n--- Simulation Complete ---");
System.out.println("Total events: " + result.getAllLogs().size());
} finally {
runner.shutdown();
}
}
}
EOF
# Compile and run the test
javac -cp target/classes /tmp/TestVerbose.java -d /tmp
java -cp /tmp:target/classes:target/test-classes -Djava.awt.headless=true TestVerbose "$@"
# Clean up
rm -f /tmp/TestVerbose.java /tmp/TestVerbose.class
# Exit cleanly
exit 0
|