diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-21 21:27:31 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-21 21:27:31 +0300 |
| commit | 0841f0f9a1e3f3708d8c511a6290344e73607aab (patch) | |
| tree | 4ae7fe60878b693d6975093acb491d977d247acd /scripts/test-verbose.sh | |
| parent | ce82046a11521b0537ac2150a07a4de54aec883a (diff) | |
Move test scripts to scripts/ directory and fix simulation completion
- Moved test-protocols.sh, test-quick.sh, test-verbose.sh to scripts/
- Updated references in README.md and docs/testing-guide.md
- Fixed HeadlessSimulationRunner to properly run simulations to completion
- Fixed message delivery timing (now respects 500-2000ms delays)
- Added proper process time synchronization
- Fixed HeadlessProtocolRunner to exit cleanly
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'scripts/test-verbose.sh')
| -rwxr-xr-x | scripts/test-verbose.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/test-verbose.sh b/scripts/test-verbose.sh new file mode 100755 index 0000000..e3362b3 --- /dev/null +++ b/scripts/test-verbose.sh @@ -0,0 +1,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
\ No newline at end of file |
