Skip to content

Instantly share code, notes, and snippets.

@p-offtermatt
Created April 3, 2024 06:58
Show Gist options
  • Save p-offtermatt/6e107a8685ae2384c6f02e41297079d4 to your computer and use it in GitHub Desktop.
Save p-offtermatt/6e107a8685ae2384c6f02e41297079d4 to your computer and use it in GitHub Desktop.
Useful files for working with Quint MBT traces
#!/bin/bash
# Replace 'your_command_here' with your actual command, ensuring it's properly quoted if it contains spaces or special characters
COMMAND='go test -v'
EXPECTED_OUT="Running traces from the traces folder done"
# Loop 1000 times
for i in {1..100}
do
output=$($COMMAND)
# Compare the output with the initial output
if ! echo "$output" | grep -q "$EXPECTED_OUT"; then
echo $output
echo "Error: Output at iteration $i does not contain the expected line."
exit 1
fi
done
echo "All outputs were consistent across 1000 runs."
#!/bin/bash
# Assign the command line arguments to variables
filename=$1
start_index=$2
end_index=$3
# Loop from start_index to end_index
for ((index=$start_index; index<=$end_index; index++))
do
# Use jq to extract the state with the current index and save it to a file named "<index>.json"
jq --argjson idx $index '.states[] | select(."#meta".index == $idx)' $filename > "${index}.json"
done
#!/bin/bash
# Assign the command line arguments to variables
filename=$1
start_index=$2
end_index=$3
# Loop from start_index to end_index
for ((index=$start_index; index<=$end_index; index++))
do
# Use jq to extract the index and the consumersWithPowerChangesInThisEpoch value and print them
jq --argjson idx $index '.states[] | select(."#meta".index == $idx) | .currentState.providerState.consumersWithAddrAssignmentChangesInThisEpoch | "Index: \($idx) Value: \(.)"' $filename
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment