Files

41 lines
930 B
Bash
Executable File

#!/bin/bash
# A self-verifying test script for the troupe
# Outputs test data to stdout and verifies expected values
set -e
# Test data: generate a simple counter and checksum
counter=42
checksum=$(echo -n "spark-verification" | md5sum | cut -d' ' -f1)
# Output structured data
echo "COUNTER: $counter"
echo "CHECKSUM: $checksum"
echo "STATUS: SUCCESS"
# Verification function
verify() {
local expected_counter=42
local expected_checksum="d5b5e2d4855b7d7e1b8c3f1a2d4e5c6b"
# Verify counter
if [ "$counter" -eq "$expected_counter" ]; then
echo "COUNTER_VERIFIED: PASS"
else
echo "COUNTER_VERIFIED: FAIL"
return 1
fi
# Verify checksum format (MD5 is 32 hex chars)
if [[ "$checksum" =~ ^[0-9a-f]{32}$ ]]; then
echo "CHECKSUM_FORMAT: PASS"
else
echo "CHECKSUM_FORMAT: FAIL"
return 1
fi
return 0
}
# Run verification
verify