-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# Check if correct number of arguments is provided | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 <program-filepath> <srs-filepath>" | ||
echo "Example: $0 path/to/my_program.bin /path/to/srs" | ||
exit 1 | ||
fi | ||
|
||
# Store arguments in descriptive variables | ||
PROGRAM_FILEPATH="$1" | ||
SRS_FILEPATH="$2" | ||
|
||
# Extract just the program name from the filepath | ||
PROGRAM_NAME=$(basename "$PROGRAM_FILEPATH") | ||
STATE_JSON="${PROGRAM_NAME}-state.json" | ||
|
||
# Set up cleanup trap | ||
cleanup() { | ||
rm -f "$STATE_JSON" | ||
} | ||
trap cleanup EXIT | ||
|
||
# Generate state JSON | ||
echo "Generating state JSON for $PROGRAM_NAME..." | ||
cargo run --bin pickles_o1vm -- cannon gen-state-json \ | ||
-i "$PROGRAM_FILEPATH" \ | ||
-o "$STATE_JSON" | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to generate state JSON" | ||
exit 1 | ||
fi | ||
|
||
# Run the program with the generated state | ||
echo "Running program with generated state..." | ||
cargo run --release --bin pickles_o1vm -- cannon run \ | ||
--input "$STATE_JSON" \ | ||
--srs-filepath "$SRS_FILEPATH" \ | ||
--halt-address 0 | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to run program" | ||
exit 1 | ||
fi | ||
|
||
echo "Execution completed successfully" |