From 56f61e50ab38d6f81903ac9fae08700c134f9ea7 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 26 Apr 2021 17:24:32 -0400 Subject: [PATCH] chore: Enhance experimental framework with dotenv --- .../experiments/bash_libraries/framework.sh | 51 ++++++++++--------- runtime/experiments/bash_libraries/panic.sh | 5 +- .../experiments/bimodal/edf_nopreemption.env | 2 + .../experiments/bimodal/edf_preemption.env | 2 + .../experiments/bimodal/fifo_nopreemption.env | 2 + .../experiments/bimodal/fifo_preemption.env | 2 + runtime/experiments/concurrency/edf.env | 1 + runtime/experiments/concurrency/fifo.env | 1 + runtime/experiments/payload/edf.env | 1 + runtime/experiments/payload/fifo.env | 1 + 10 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 runtime/experiments/bimodal/edf_nopreemption.env create mode 100644 runtime/experiments/bimodal/edf_preemption.env create mode 100644 runtime/experiments/bimodal/fifo_nopreemption.env create mode 100644 runtime/experiments/bimodal/fifo_preemption.env create mode 100644 runtime/experiments/concurrency/edf.env create mode 100644 runtime/experiments/concurrency/fifo.env create mode 100644 runtime/experiments/payload/edf.env create mode 100644 runtime/experiments/payload/fifo.env diff --git a/runtime/experiments/bash_libraries/framework.sh b/runtime/experiments/bash_libraries/framework.sh index 8675d7a..b521ec8 100644 --- a/runtime/experiments/bash_libraries/framework.sh +++ b/runtime/experiments/bash_libraries/framework.sh @@ -22,6 +22,7 @@ __framework_sh__usage() { echo "" echo "Options:" echo " -t,--target= Execute as client against remote URL" + echo " -e,--envfile= Load an Env File. No path and pass filename with *.env extension" echo " -s,--serve Serve but do not run client" echo " -d,--debug Debug under GDB but do not run client" echo " -v,--valgrind Debug under Valgrind but do not run client" @@ -39,6 +40,7 @@ __framework_sh__initialize_globals() { # Globals used by parse_arguments declare -g __framework_sh__target="" declare -g __framework_sh__role="" + declare -g __framework_sh__envfile="" # Configure environment variables # shellcheck disable=SC2155 @@ -98,6 +100,15 @@ __framework_sh__parse_arguments() { __framework_sh__role=valgrind shift ;; + -e=* | --envfile=*) + if [[ "$__framework_sh__role" == "client" ]]; then + echo "Expected to be used with run by the server" + __framework_sh__usage + return 1 + fi + __framework_sh__envfile="${i#*=}" + echo "Set envfile to $__framework_sh__envfile" + ;; -h | --help) __framework_sh__usage exit 0 @@ -225,12 +236,6 @@ __framework_sh__run_server() { } __framework_sh__run_perf() { - if (($# != 0)); then - printf "[ERR]\n" - panic "Invalid number of arguments. Saw $#. Expected 0." - return 1 - fi - if ! command -v perf; then echo "perf is not present." exit 1 @@ -240,12 +245,6 @@ __framework_sh__run_perf() { } __framework_sh__run_valgrind() { - if (($# != 0)); then - printf "[ERR]\n" - panic "Invalid number of arguments. Saw $#. Expected 0." - return 1 - fi - if ! command -v valgrind; then echo "valgrind is not present." exit 1 @@ -256,12 +255,6 @@ __framework_sh__run_valgrind() { # Starts the Sledge Runtime under GDB __framework_sh__run_debug() { - if (($# != 0)); then - printf "[ERR]\n" - panic "Invalid number of arguments. Saw $#. Expected 0." - return 1 - fi - # shellcheck disable=SC2155 local project_directory=$(cd ../.. && pwd) @@ -294,12 +287,23 @@ __framework_sh__run_client() { return 0 } +__framework_sh__load_env_file() { + local envfile="$1" + if [[ -f "$envfile" ]]; then + while read -r line; do + echo export "${line?}" + export "${line?}" + done < "$envfile" + fi +} + __framework_sh__run_both() { - local -ar schedulers=(EDF FIFO) - for scheduler in "${schedulers[@]}"; do - printf "Running %s\n" "$scheduler" - export SLEDGE_SCHEDULER="$scheduler" - __framework_sh__create_and_export_results_directory "$scheduler" + local short_name + for envfile in "$__framework_sh__application_directory"/*.env; do + short_name="$(basename "${envfile/.env/}")" + printf "Running %s\n" "$short_name" + __framework_sh__load_env_file "$envfile" + __framework_sh__create_and_export_results_directory "$short_name" __framework_sh__run_server background || { panic "Error calling __framework_sh__run_server" @@ -370,6 +374,7 @@ main() { __framework_sh__initialize_globals || exit 1 __framework_sh__parse_arguments "$@" || exit 1 __framework_sh__create_and_export_results_directory || exit 1 + [[ -n "$__framework_sh__envfile" ]] && __framework_sh__load_env_file "$__framework_sh__application_directory/$__framework_sh__envfile" case $__framework_sh__role in both) diff --git a/runtime/experiments/bash_libraries/panic.sh b/runtime/experiments/bash_libraries/panic.sh index a204315..0f6d1f3 100644 --- a/runtime/experiments/bash_libraries/panic.sh +++ b/runtime/experiments/bash_libraries/panic.sh @@ -8,9 +8,8 @@ declare __common_did_dump_callstack=false __common_dump_callstack() { echo "Call Stack:" - # Skip the dump_bash_stack and error_msg_frames - for ((i = 2; i < ${#FUNCNAME[@]}; i++)); do - printf "\t%d - %s\n" "$((i - 2))" "${FUNCNAME[i]} (${BASH_SOURCE[i + 1]}:${BASH_LINENO[i + 1]})" + for ((i = 1; i < ${#FUNCNAME[@]}; i++)); do + printf "\t%d - %s\n" "$((i - 1))" "${FUNCNAME[i]} (${BASH_SOURCE[i + 1]}:${BASH_LINENO[i]})" done } diff --git a/runtime/experiments/bimodal/edf_nopreemption.env b/runtime/experiments/bimodal/edf_nopreemption.env new file mode 100644 index 0000000..eeba531 --- /dev/null +++ b/runtime/experiments/bimodal/edf_nopreemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=true diff --git a/runtime/experiments/bimodal/edf_preemption.env b/runtime/experiments/bimodal/edf_preemption.env new file mode 100644 index 0000000..0cd4ebf --- /dev/null +++ b/runtime/experiments/bimodal/edf_preemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=EDF +SLEDGE_DISABLE_PREEMPTION=false diff --git a/runtime/experiments/bimodal/fifo_nopreemption.env b/runtime/experiments/bimodal/fifo_nopreemption.env new file mode 100644 index 0000000..a572a70 --- /dev/null +++ b/runtime/experiments/bimodal/fifo_nopreemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=true diff --git a/runtime/experiments/bimodal/fifo_preemption.env b/runtime/experiments/bimodal/fifo_preemption.env new file mode 100644 index 0000000..eb1298f --- /dev/null +++ b/runtime/experiments/bimodal/fifo_preemption.env @@ -0,0 +1,2 @@ +SLEDGE_SCHEDULER=FIFO +SLEDGE_DISABLE_PREEMPTION=false diff --git a/runtime/experiments/concurrency/edf.env b/runtime/experiments/concurrency/edf.env new file mode 100644 index 0000000..43ea217 --- /dev/null +++ b/runtime/experiments/concurrency/edf.env @@ -0,0 +1 @@ +SLEDGE_SCHEDULER=EDF diff --git a/runtime/experiments/concurrency/fifo.env b/runtime/experiments/concurrency/fifo.env new file mode 100644 index 0000000..db4c96a --- /dev/null +++ b/runtime/experiments/concurrency/fifo.env @@ -0,0 +1 @@ +SLEDGE_SCHEDULER=FIFO diff --git a/runtime/experiments/payload/edf.env b/runtime/experiments/payload/edf.env new file mode 100644 index 0000000..43ea217 --- /dev/null +++ b/runtime/experiments/payload/edf.env @@ -0,0 +1 @@ +SLEDGE_SCHEDULER=EDF diff --git a/runtime/experiments/payload/fifo.env b/runtime/experiments/payload/fifo.env new file mode 100644 index 0000000..db4c96a --- /dev/null +++ b/runtime/experiments/payload/fifo.env @@ -0,0 +1 @@ +SLEDGE_SCHEDULER=FIFO