Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetr0v committed May 14, 2020
1 parent cc9d8a2 commit 03486cb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 60 deletions.
8 changes: 1 addition & 7 deletions scripts/build_example
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ case "${language}" in
# `aggregator` example has an additional Backend Docker image
cargo build --release --package=aggregator_backend
fi
bazel --output_base="${CACHE_DIR}/client" build "${bazel_build_flags[@]}" "//examples/${EXAMPLE}/config:config"

# Compile examples that are supported by the Rust Oak Loader.
if [[ " ${RUST_LOADER_EXAMPLES[@]} " =~ " ${EXAMPLE} " ]]; then
bazel --output_base="${CACHE_DIR}/client" build "${bazel_build_flags[@]}" "//examples/${EXAMPLE}/config:config_rust"
fi
;;
bazel --output_base="${CACHE_DIR}/client" build "${bazel_build_flags[@]}" "//examples/${EXAMPLE}/config:config";;
cpp)
# `config_cpp` depends on a Wasm module, so it should be built with `wasm32` or `emscripten`.
readonly BUILD_RULES=(
Expand Down
11 changes: 0 additions & 11 deletions scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,6 @@ else
)
fi

# Examples that are supported by the Rust Oak Loader.
readonly RUST_LOADER_EXAMPLES=(
'abitest'
'chat'
'machine_learning'
'private_set_intersection'
'running_average'
'rustfmt'
'translator'
)

# kill_pid tries to kill the given pid(s), first softly then more aggressively.
kill_pid() {
local pids=( "$@" )
Expand Down
6 changes: 3 additions & 3 deletions scripts/run_example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ readonly SCRIPTS_DIR="$(dirname "$0")"
source "${SCRIPTS_DIR}/common"

language="rust"
server="base"
server="rust"
buildargs=""
serverargs=""
while getopts "s:l:de:vh" opt; do
Expand All @@ -18,9 +18,9 @@ Build and run the given example Oak Application and client.
Options:
-e Example application name (required)
-s Server type used to run examples:
- base: base version of the server (default)
- base: base version of the server
- logless: base version of the server with debug logging compiled out
- rust: Rust version of the server
- rust: Rust version of the server (default)
- asan: server with address sanitizer
- tsan: server with thread sanitizer
- none: run an application client without a server
Expand Down
37 changes: 12 additions & 25 deletions scripts/run_examples
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ readonly SCRIPTS_DIR="$(dirname "$0")"
# shellcheck source=scripts/common
source "${SCRIPTS_DIR}/common"

server="base"
server="rust"
languages="rust cpp"
while getopts "s:l:h" opt; do
case "${opt}" in
h)
echo -e "Usage: ${0} [-s base|logless|asan|tsan] [-l rust|cpp]
-s Server type used to run examples:
- base: base version of the server (default)
- base: base version of the server
- logless: base version of the server with debug logging compiled out
- rust: Rust version of the server
- rust: Rust version of the server (default)
- asan: server with address sanitizer
- tsan: server with thread santizer
-l Run examples implemented in which language (default: both):
Expand All @@ -37,28 +37,15 @@ while getopts "s:l:h" opt; do
esac
done

if [[ "${server}" == "rust" ]]; then
# Run examples that are supported by the Rust Oak Loader.
for example in ${RUST_LOADER_EXAMPLES}; do
if [[ "${example}" == "abitest" ]]; then
# Run only currently supported tests.
"${SCRIPTS_DIR}/run_example" -s rust -l rust -e abitest -- \
--test_include UnaryMethodOK UnaryMethodErr
# Run all examples.
for language in ${languages}; do
# TODO(#594): Re-enable rustfmt when upstream rustc internal error is fixed.
examples="$(find examples -mindepth 2 -maxdepth 4 -type d -regex '.*/module.*/'"${language}"'$' | cut -d'/' -f2 | uniq | grep -v rustfmt)"
for example in ${examples}; do
if [[ "${example}" == "chat" ]]; then
"${SCRIPTS_DIR}/run_example" -s "${server}" -l "${language}" -e chat -- --test
else
"${SCRIPTS_DIR}/run_example" -s rust -l rust -e "${example}"
"${SCRIPTS_DIR}/run_example" -s "${server}" -l "${language}" -e "${example}"
fi
done
else
# Run all examples.
for language in ${languages}; do
# TODO(#594): Re-enable rustfmt when upstream rustc internal error is fixed.
examples="$(find examples -mindepth 2 -maxdepth 4 -type d -regex '.*/module.*/'"${language}"'$' | cut -d'/' -f2 | uniq | grep -v rustfmt)"
for example in ${examples}; do
if [[ "${example}" == "chat" ]]; then
"${SCRIPTS_DIR}/run_example" -s "${server}" -l "${language}" -e chat -- --test
else
"${SCRIPTS_DIR}/run_example" -s "${server}" -l "${language}" -e "${example}"
fi
done
done
fi
done
18 changes: 4 additions & 14 deletions scripts/run_server
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ readonly SCRIPTS_DIR="$(dirname "$0")"
source "${SCRIPTS_DIR}/common"

language="rust"
server="base"
server="rust"
while getopts "s:a:l:e:vh" opt; do
case "${opt}" in
h)
Expand All @@ -17,9 +17,9 @@ Either the -a APPLICATION or the -e EXAMPLE option is required.
-a Path to a serialized application configuration file
-e Example application name
-s Server type:
- base: base version of the server (default)
- base: base version of the server
- logless: base version of the server with debug logging compiled out
- rust: Rust version of the server
- rust: Rust version of the server (default)
- arm: server for ARM architecture
- asan: server with address sanitizer
- tsan: server with thread santizer
Expand Down Expand Up @@ -55,17 +55,7 @@ if [[ -n ${EXAMPLE+x} ]]; then
# Determine expected configuration file from example name and language variant.
case "${language}" in
rust)
# Compile examples that are supported by the Rust Oak Loader.
if [[ "${server}" == "rust" ]]; then
if [[ " ${RUST_LOADER_EXAMPLES[@]} " =~ " ${EXAMPLE} " ]]; then
readonly APPLICATION="${PWD}/bazel-client-bin/examples/${EXAMPLE}/config/config_rust.bin"
else
echo "Example ${EXAMPLE} is not supported by the rust server"
exit 1
fi
else
readonly APPLICATION="${PWD}/bazel-client-bin/examples/${EXAMPLE}/config/config.bin"
fi;;
readonly APPLICATION="${PWD}/bazel-client-bin/examples/${EXAMPLE}/config/config.bin";;
cpp)
# TensorFlow example is compiled with Emscripten and other examples with Clang.
if [[ "${EXAMPLE}" == "tensorflow" ]]; then
Expand Down

0 comments on commit 03486cb

Please sign in to comment.