blob: a6961c1e51efde8406d9dde4d24d11ebbfd9fd79 [file] [log] [blame]
Ryan Brownfed691e2014-09-15 13:09:40 -07001#!/bin/bash
2
3# Test running an application using the agent.
4
Jiri Simsaf8727f22014-09-24 19:08:49 -07005source "${VEYRON_ROOT}/scripts/lib/shell_test.sh"
Ryan Brownfed691e2014-09-15 13:09:40 -07006
Jing Jin89312ff2014-10-24 10:42:08 -07007readonly WORKDIR="${shell_test_WORK_DIR}"
Jiri Simsa85aea7b2014-10-15 15:48:36 -07008
Ryan Brownfed691e2014-09-15 13:09:40 -07009build() {
Jing Jin89312ff2014-10-24 10:42:08 -070010 AGENTD_BIN="$(shell_test::build_go_binary 'veyron.io/veyron/veyron/security/agent/agentd')"
Jing Jin84a11522014-10-28 14:16:28 -070011 PINGPONG_BIN="$(shell_test::build_go_binary 'veyron.io/veyron/veyron/security/agent/pingpong')"
Jiri Simsa85aea7b2014-10-15 15:48:36 -070012}
13
Ryan Brownfed691e2014-09-15 13:09:40 -070014main() {
Jiri Simsa85aea7b2014-10-15 15:48:36 -070015 local RESULT
16
17 cd "${WORKDIR}"
Ryan Brownfed691e2014-09-15 13:09:40 -070018 build
19
Suharsh Sivakumaraca1c322014-10-21 11:27:32 -070020
Suharsh Sivakumar8a7fba42014-10-27 12:40:48 -070021 shell_test::setup_server_test || shell_test::fail "line ${LINENO} failed to setup server test"
22 export VEYRON_CREDENTIALS="$(shell::tmp_dir)"
Ryan Brown50b473a2014-09-23 14:23:00 -070023
24 # Test running a single app.
Jing Jin89312ff2014-10-24 10:42:08 -070025 shell_test::start_server "${PINGPONG_BIN}" --server
26 "${AGENTD_BIN}" --v=4 "${PINGPONG_BIN}" || shell_test::fail "line ${LINENO}: failed to run pingpong"
Asim Shankarb3a82ba2014-10-29 11:41:27 -070027 local -r CREDENTIALS_UNDER_AGENT=$("${AGENTD_BIN}" bash -c 'echo ${VEYRON_CREDENTIALS}')
28 if [[ "${CREDENTIALS_UNDER_AGENT}" != "" ]]; then
29 shell_test::fail "line ${LINENO}: VEYRON_CREDENTIALS should not be set when running under the agent(${CREDENTIALS_UNDER_AGENT})"
Ryan Brownfed691e2014-09-15 13:09:40 -070030 fi
31
Ryan Brown50b473a2014-09-23 14:23:00 -070032 # Test running multiple apps connecting to the same agent.
Jing Jin89312ff2014-10-24 10:42:08 -070033 # Make sure the testchild.sh script get the same shell_test_BIN_DIR as the main script.
34 export shell_test_BIN_DIR="${shell_test_BIN_DIR}"
35 RESULT=$(shell::check_result "${AGENTD_BIN}" bash "${VEYRON_ROOT}/veyron/go/src/veyron.io/veyron/veyron/security/agent/testchild.sh")
Jiri Simsa85aea7b2014-10-15 15:48:36 -070036 shell_test::assert_eq "${RESULT}" "0" "${LINENO}"
37
38 shell_test::pass
Ryan Brownfed691e2014-09-15 13:09:40 -070039}
40
41main "$@"