diff --git a/makefile b/makefile index 4ced58b9c439ac9d34b46893b988ac36984f0f7c..bd2568aed1d28e23f307dd7dcf88390348d675ee 100644 --- a/makefile +++ b/makefile @@ -36,6 +36,7 @@ help: @echo "" @echo "Available Commands:" @echo " all - Executes \"run\", then \"clean\"." - @echo " run - Compile program to \"a.out\". Then run." - @echo " valgrind - Compile program to \"a.out\". Then run with memory error checking." + @echo " compile - Compiles program to \"a.out\"." + @echo " run - Compiles program to \"a.out\". Then run." + @echo " valgrind - Compiles program to \"a.out\". Then run with memory error checking." @echo " clean - Remove temporary/compiled files from directory." diff --git a/run.sh b/run.sh index c1ebe80dd988bd16c03539150c8a2ef37d329073..2439b652ccf6172dfd82386f7f66abdd71a02046 100755 --- a/run.sh +++ b/run.sh @@ -20,7 +20,6 @@ color_cyan='\033[1;36m' # Change location to script's directory. # Makes logic consistent, regardless of what directory script is ran from. cd "$(dirname "$0")" -cd ../ function main () { @@ -43,9 +42,53 @@ function main () { ## function execute_single_file () { # Get passed filename. - echo $@ - for i in $@; do :; done - echo $i + for file in $@; do :; done + + # Check if valid file. + if [[ -f "$file" ]] + then + # Check if file ends with ".trace" for trace file. + file_extension="${file##*.}" + if [[ $file_extension == "trace" ]] + then + # Get absolute path for file. + get_absolute_path $file + if [[ return_value != "" ]] + then + file=$return_value + + echo -e "${color_blue}Found input file \"$file\". Attempting to compile C code.${color_reset}" + + # Attempt to compile C code. + make compile + + # Run input file on example cache simulator file. + echo "" + echo -e "${color_blue}Running input file on \"wmucachelab/csim-ref\". Runtime args:${color_reset}" + echo -e "${color_blue} -v -s 4 -E 1 -b 4 -t $file${color_reset}" + ./wmucachelab/csim-ref -v -s 4 -E 1 -b 4 -t $file + + # Run input file on compiled C code. + echo "" + echo -e "${color_blue}Running input file on compiled C code. Runtime args:${color_reset}" + echo -e "${color_blue} -v -s 4 -E 1 -b 4 -t $file${color_reset}" + ./a.out -v -s 4 -E 1 -b 4 -t $file + + # Clean up directory. + make clean + + else + echo -e "${color_red}Failed to determine absolute path for input file.${color_reset}" + echo "Terminating script." + exit 1 + fi + else + echo -e "${color_red}Found file \"$file\" but extension is not \".trace\". Not a trace file.${color_reset}" + echo "Terminating script." + exit 1 + fi + fi + exit 0 }