veyron/shell/lib/shell_test.sh: mechanism to enable running shell tests under security agent
veyron/services/mgmt/binary/binaryd/test.sh: exemplify the mechanism on the binary service shell test.
To avoid boilerplate in every test that needs credentials managed by the
security agent, we introduce the enable_agent function, which under the covers
(when called in the parent invocation of the script) runs the script itself
under the agent; and (when called in the child invocation) sets up the vrun
command and lets the rest of the script run.
The only thing a test.sh needs to do is embed this line after sourcing
shell_test.sh:
enable_agent "$@"
This should make it easy to transition existing test.sh scripts to using agent.
Change-Id: Ia0ee11fd8023cb0f8864231cf87c1e380d756302
diff --git a/services/mgmt/binary/binaryd/test.sh b/services/mgmt/binary/binaryd/test.sh
index 602a643..8bc4402 100755
--- a/services/mgmt/binary/binaryd/test.sh
+++ b/services/mgmt/binary/binaryd/test.sh
@@ -8,6 +8,9 @@
source "$(go list -f {{.Dir}} veyron.io/veyron/shell/lib)/shell_test.sh"
+# Run the test under the security agent.
+shell_test::enable_agent "$@"
+
readonly WORKDIR="${shell_test_WORK_DIR}"
build() {
@@ -23,7 +26,7 @@
# Start the binary repository daemon.
local -r REPO="binaryd-test-repo"
- shell_test::start_server "${BINARYD_BIN}" --name="${REPO}" --veyron.tcp.address=127.0.0.1:0 --http=127.0.0.1:0 \
+ shell_test::start_server "${VRUN}" "${BINARYD_BIN}" --name="${REPO}" --veyron.tcp.address=127.0.0.1:0 --http=127.0.0.1:0 \
|| shell_test::fail "line ${LINENO} failed to start binaryd"
local -r HTTP_ADDR=$(grep 'HTTP server at: "' "${START_SERVER_LOG_FILE}" | sed -e 's/^.*HTTP server at: "//' | sed -e 's/"$//')