Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Test running an application using the agent. |
| 4 | |
Jiri Simsa | f8727f2 | 2014-09-24 19:08:49 -0700 | [diff] [blame] | 5 | source "${VEYRON_ROOT}/scripts/lib/shell_test.sh" |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 6 | |
Jing Jin | 89312ff | 2014-10-24 10:42:08 -0700 | [diff] [blame] | 7 | readonly WORKDIR="${shell_test_WORK_DIR}" |
Jiri Simsa | 85aea7b | 2014-10-15 15:48:36 -0700 | [diff] [blame] | 8 | |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 9 | build() { |
Jing Jin | 89312ff | 2014-10-24 10:42:08 -0700 | [diff] [blame] | 10 | AGENTD_BIN="$(shell_test::build_go_binary 'veyron.io/veyron/veyron/security/agent/agentd')" |
Jing Jin | 84a1152 | 2014-10-28 14:16:28 -0700 | [diff] [blame] | 11 | PINGPONG_BIN="$(shell_test::build_go_binary 'veyron.io/veyron/veyron/security/agent/pingpong')" |
Jiri Simsa | 85aea7b | 2014-10-15 15:48:36 -0700 | [diff] [blame] | 12 | } |
| 13 | |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 14 | main() { |
Jiri Simsa | 85aea7b | 2014-10-15 15:48:36 -0700 | [diff] [blame] | 15 | local RESULT |
| 16 | |
| 17 | cd "${WORKDIR}" |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 18 | build |
| 19 | |
Suharsh Sivakumar | aca1c32 | 2014-10-21 11:27:32 -0700 | [diff] [blame] | 20 | |
Suharsh Sivakumar | 8a7fba4 | 2014-10-27 12:40:48 -0700 | [diff] [blame] | 21 | shell_test::setup_server_test || shell_test::fail "line ${LINENO} failed to setup server test" |
| 22 | export VEYRON_CREDENTIALS="$(shell::tmp_dir)" |
Ryan Brown | 50b473a | 2014-09-23 14:23:00 -0700 | [diff] [blame] | 23 | |
| 24 | # Test running a single app. |
Jing Jin | 89312ff | 2014-10-24 10:42:08 -0700 | [diff] [blame] | 25 | shell_test::start_server "${PINGPONG_BIN}" --server |
| 26 | "${AGENTD_BIN}" --v=4 "${PINGPONG_BIN}" || shell_test::fail "line ${LINENO}: failed to run pingpong" |
Asim Shankar | b3a82ba | 2014-10-29 11:41:27 -0700 | [diff] [blame] | 27 | 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 Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 30 | fi |
| 31 | |
Ryan Brown | 50b473a | 2014-09-23 14:23:00 -0700 | [diff] [blame] | 32 | # Test running multiple apps connecting to the same agent. |
Jing Jin | 89312ff | 2014-10-24 10:42:08 -0700 | [diff] [blame] | 33 | # 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 Simsa | 85aea7b | 2014-10-15 15:48:36 -0700 | [diff] [blame] | 36 | shell_test::assert_eq "${RESULT}" "0" "${LINENO}" |
| 37 | |
| 38 | shell_test::pass |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | main "$@" |