From 6043fb55362a899e25ded908543c81d661c6e5d5 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Tue, 25 May 2021 10:35:41 -0400 Subject: [PATCH] feat: image resize framework --- .../applications/ekf/one_iteration/debug.sh | 19 ---- .../applications/imageresize/test/.gitignore | 2 +- .../applications/imageresize/test/debug.sh | 19 ---- .../imageresize/test/edf_nopreemption.env | 2 + .../imageresize/test/edf_preemption.env | 3 + .../imageresize/test/fifo_nopreemption.env | 2 + .../imageresize/test/fifo_preemption.env | 2 + .../applications/imageresize/test/run.sh | 101 ++++++++++-------- 8 files changed, 69 insertions(+), 81 deletions(-) delete mode 100755 runtime/experiments/applications/ekf/one_iteration/debug.sh delete mode 100755 runtime/experiments/applications/imageresize/test/debug.sh create mode 100644 runtime/experiments/applications/imageresize/test/edf_nopreemption.env create mode 100644 runtime/experiments/applications/imageresize/test/edf_preemption.env create mode 100644 runtime/experiments/applications/imageresize/test/fifo_nopreemption.env create mode 100644 runtime/experiments/applications/imageresize/test/fifo_preemption.env diff --git a/runtime/experiments/applications/ekf/one_iteration/debug.sh b/runtime/experiments/applications/ekf/one_iteration/debug.sh deleted file mode 100755 index 879d485..0000000 --- a/runtime/experiments/applications/ekf/one_iteration/debug.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Executes the runtime in GDB -# Substitutes the absolute path from the container with a path relatively derived from the location of this script -# This allows debugging outside of the Docker container -# Also disables pagination and stopping on SIGUSR1 - -experiment_directory=$(pwd) -project_directory=$(cd ../../../.. && pwd) -binary_directory=$(cd "$project_directory"/bin && pwd) - -export LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" -export PATH="$binary_directory:$PATH" - -gdb --eval-command="handle SIGUSR1 nostop" \ - --eval-command="handle SIGPIPE nostop" \ - --eval-command="set pagination off" \ - --eval-command="set substitute-path /sledge/runtime $project_directory" \ - --eval-command="run $experiment_directory/spec.json" \ - sledgert diff --git a/runtime/experiments/applications/imageresize/test/.gitignore b/runtime/experiments/applications/imageresize/test/.gitignore index 978a56e..aaf36ac 100644 --- a/runtime/experiments/applications/imageresize/test/.gitignore +++ b/runtime/experiments/applications/imageresize/test/.gitignore @@ -1 +1 @@ -result_*.png +res/* diff --git a/runtime/experiments/applications/imageresize/test/debug.sh b/runtime/experiments/applications/imageresize/test/debug.sh deleted file mode 100755 index 879d485..0000000 --- a/runtime/experiments/applications/imageresize/test/debug.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Executes the runtime in GDB -# Substitutes the absolute path from the container with a path relatively derived from the location of this script -# This allows debugging outside of the Docker container -# Also disables pagination and stopping on SIGUSR1 - -experiment_directory=$(pwd) -project_directory=$(cd ../../../.. && pwd) -binary_directory=$(cd "$project_directory"/bin && pwd) - -export LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" -export PATH="$binary_directory:$PATH" - -gdb --eval-command="handle SIGUSR1 nostop" \ - --eval-command="handle SIGPIPE nostop" \ - --eval-command="set pagination off" \ - --eval-command="set substitute-path /sledge/runtime $project_directory" \ - --eval-command="run $experiment_directory/spec.json" \ - sledgert diff --git a/runtime/experiments/applications/imageresize/test/edf_nopreemption.env b/runtime/experiments/applications/imageresize/test/edf_nopreemption.env new file mode 100644 index 0000000..eeba531 --- /dev/null +++ b/runtime/experiments/applications/imageresize/test/edf_nopreemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=true diff --git a/runtime/experiments/applications/imageresize/test/edf_preemption.env b/runtime/experiments/applications/imageresize/test/edf_preemption.env new file mode 100644 index 0000000..302a324 --- /dev/null +++ b/runtime/experiments/applications/imageresize/test/edf_preemption.env @@ -0,0 +1,3 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=false +SLEDGE_SIGALRM_HANDLER=TRIAGED diff --git a/runtime/experiments/applications/imageresize/test/fifo_nopreemption.env b/runtime/experiments/applications/imageresize/test/fifo_nopreemption.env new file mode 100644 index 0000000..a572a70 --- /dev/null +++ b/runtime/experiments/applications/imageresize/test/fifo_nopreemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=true diff --git a/runtime/experiments/applications/imageresize/test/fifo_preemption.env b/runtime/experiments/applications/imageresize/test/fifo_preemption.env new file mode 100644 index 0000000..eb1298f --- /dev/null +++ b/runtime/experiments/applications/imageresize/test/fifo_preemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=false diff --git a/runtime/experiments/applications/imageresize/test/run.sh b/runtime/experiments/applications/imageresize/test/run.sh index 4fab433..7d354be 100755 --- a/runtime/experiments/applications/imageresize/test/run.sh +++ b/runtime/experiments/applications/imageresize/test/run.sh @@ -1,57 +1,74 @@ #!/bin/bash -# Executes the runtime in GDB -# Substitutes the absolute path from the container with a path relatively derived from the location of this script -# This allows debugging outside of the Docker container -# Also disables pagination and stopping on SIGUSR1 -experiment_directory=$(pwd) -echo "$experiment_directory" -project_directory=$(cd ../../../.. && pwd) -binary_directory=$(cd "$project_directory"/bin && pwd) +__run_sh__base_path="$(dirname "$(realpath --logical "${BASH_SOURCE[0]}")")" +__run_sh__bash_libraries_relative_path="../../../bash_libraries" +__run_sh__bash_libraries_absolute_path=$(cd "$__run_sh__base_path" && cd "$__run_sh__bash_libraries_relative_path" && pwd) +export PATH="$__run_sh__bash_libraries_absolute_path:$PATH" + +__run_sh__project_base_relative_path="../../../../.." +__run_sh__project_base_absolute_path=$(cd "$__run_sh__base_path" && cd "$__run_sh__project_base_relative_path" && pwd) + +source csv_to_dat.sh || exit 1 +source framework.sh || exit 1 +source get_result_count.sh || exit 1 +source panic.sh || exit 1 +source path_join.sh || exit 1 # Copy Flower Image if not here if [[ ! -f "./flower.jpg" ]]; then - cp ../../../../tests/sod/bin/flower.jpg ./flower.jpg + cp "$__run_sh__project_base_absolute_path/runtime/tests/sod/bin/flower.jpg" ./flower.jpg fi -if [ "$1" != "-d" ]; then - PATH="$binary_directory:$PATH" LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" sledgert "$experiment_directory/spec.json" & - sleep 3 -else - echo "Running under gdb" -fi +# Validate that required tools are in path +declare -a required_binaries=(curl compare) +validate_dependencies() { + for required_binary in "${required_binaries[@]}"; do + if ! command -v "$required_binary" > /dev/null; then + echo "$required_binary is not present." + exit 1 + fi + done +} + +experiment_main() { + local -r hostname="$1" + local -r results_directory="$2" -success_count=0 -total_count=10 + local -i success_count=0 + local -ri total_count=10 -for ((i = 0; i < total_count; i++)); do - echo "$i" - ext="$RANDOM" + local tmpfs_dir=/tmp/sledge_imageresize_test/ + [[ -d "$tmpfs_dir" ]] && { + panic "tmpfs directory exists. Aborting" + return 1 + } + mkdir $tmpfs_dir - if curl -H 'Expect:' -H "Content-Type: image/jpg" --data-binary "@flower.jpg" --output "result_$ext.png" localhost:10000 2> /dev/null 1> /dev/null; then + for ((i = 0; i < total_count; i++)); do + ext="$RANDOM" - pixel_differences="$(compare -identify -metric AE "result_$ext.png" expected_result.png null: 2>&1 > /dev/null)" + if curl -H 'Expect:' -H "Content-Type: image/jpg" --data-binary "@flower.jpg" --output "$tmpfs_dir/result_$ext.png" "$hostname:10000" 2> /dev/null 1> /dev/null; then - if [[ "$pixel_differences" == "0" ]]; then - success_count=$((success_count + 1)) + pixel_differences="$(compare -identify -metric AE "$tmpfs_dir/result_$ext.png" expected_result.png null: 2>&1 > /dev/null)" + + if [[ "$pixel_differences" == "0" ]]; then + success_count=$((success_count + 1)) + else + { + echo "FAIL" + echo "$pixel_differences pixel differences detected" + } | tee -a "$results_directory/result.txt" + return 1 + fi else - echo "FAIL" - echo "$pixel_differences pixel differences detected" - exit 1 + echo "curl failed with ${?}. See man curl for meaning." | tee -a "$results_directory/result.txt" fi - else - echo "curl failed with ${?}. See man curl for meaning." - fi -done - -echo "$success_count / $total_count" -rm result_*.png - -if [ "$1" != "-d" ]; then - sleep 5 - echo -n "Running Cleanup: " - pkill sledgert > /dev/null 2> /dev/null - echo "[DONE]" -fi + done + + echo "$success_count / $total_count" | tee -a "$results_directory/result.txt" + rm -r "$tmpfs_dir" + + return 0 +} -exit 0 +main "$@"