|
| 1 | +#!/bin/sh -ex |
| 2 | + |
| 3 | +TEST_DIR=$(dirname "$(realpath "$0")") |
| 4 | +OUTPUT="${TEST_DIR}/output" |
| 5 | +RESULT_FILE="${OUTPUT}/result.txt" |
| 6 | +export RESULT_FILE |
| 7 | +BOARD="generic-armhf" |
| 8 | +TOOLCHAIN="armhf" |
| 9 | +TEST="Functional.hello_world" |
| 10 | +SPEC="default" |
| 11 | +SKIP_INSTALL="false" |
| 12 | + |
| 13 | +usage() { |
| 14 | + echo "Usage: $0 [-b BOARD] [-c TOOLCHAIN] [-t TEST] [-s SPEC] [-S SKIP_INSTALL]" 1>&2 |
| 15 | + exit 1 |
| 16 | +} |
| 17 | + |
| 18 | +while getopts "b:c:t:s:S:h" o; do |
| 19 | + case "$o" in |
| 20 | + b) BOARD="${OPTARG}" ;; |
| 21 | + c) TOOLCHAIN="${OPTARG}" ;; |
| 22 | + t) TEST="${OPTARG}" ;; |
| 23 | + s) SPEC="${OPTARG}" ;; |
| 24 | + S) SKIP_INSTALL="${OPTARG}" ;; |
| 25 | + h|*) usage ;; |
| 26 | + esac |
| 27 | +done |
| 28 | + |
| 29 | +# shellcheck disable=SC1090 |
| 30 | +. "${TEST_DIR}/../../lib/sh-test-lib" |
| 31 | +create_out_dir "${OUTPUT}" |
| 32 | + |
| 33 | +# Install toolchain. |
| 34 | +# Refer to http://fuegotest.org/wiki/Adding_a_toolchain for supported |
| 35 | +# toolchains by the following installer. |
| 36 | +if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then |
| 37 | + info_msg "Toolchain ${TOOLCHAIN} installation skipped." |
| 38 | +else |
| 39 | + /fuego-ro/toolchains/install_cross_toolchain.sh "${TOOLCHAIN}" |
| 40 | +fi |
| 41 | + |
| 42 | +# Add board configuration. |
| 43 | +# FIXME: changes in LAVA are required to support additional docker run params. |
| 44 | +# fuego uses '--net="host"' to make fuego host accessible for DUT. The feature |
| 45 | +# is required by networking tests like NetPIPE, iperf, netperf |
| 46 | +dut_ipaddr=$(grep "ipaddr" /tmp/lava_multi_node_cache.txt | awk -F"=" '{print $NF}') |
| 47 | +board_config="/fuego-ro/boards/${BOARD}.board" |
| 48 | +if [ -f "${board_config}" ] && grep "${dut_ipaddr}" "${board_config}"; then |
| 49 | + info_msg "Board configuration already added." |
| 50 | +else |
| 51 | + sed -i "s/dut_ipaddr/${dut_ipaddr}/" "boards/${BOARD}.board" |
| 52 | + cp "boards/${BOARD}.board" /fuego-ro/boards/ |
| 53 | + cat "/fuego-ro/boards/${BOARD}.board" |
| 54 | +fi |
| 55 | + |
| 56 | +# Set proper permissions. |
| 57 | +chown -R jenkins.jenkins /fuego-rw/ |
| 58 | +chown -R jenkins.jenkins /fuego-ro/ |
| 59 | + |
| 60 | +# Add Jenkins node. |
| 61 | +# Give Jenkins time to start. |
| 62 | +sleep 30 |
| 63 | +if ftc list-nodes | grep "${BOARD}"; then |
| 64 | + info_msg "Node ${BOARD} already added." |
| 65 | +else |
| 66 | + ftc add-nodes -b "${BOARD}" -f |
| 67 | +fi |
| 68 | + |
| 69 | +# Add test job. |
| 70 | +if ftc list-jobs | grep "${BOARD}.${SPEC}.${TEST}"; then |
| 71 | + info_msg "Test job ${BOARD}.${SPEC}.${TEST} already added." |
| 72 | +else |
| 73 | + ftc add-job -b "${BOARD}" -t "${TEST}" -s "${SPEC}" |
| 74 | +fi |
| 75 | + |
| 76 | +# Run test as user jenkins. |
| 77 | +# timeout will be handled by LAVA. Set a super long time here. |
| 78 | +# TODO: support dynamic-vars |
| 79 | +ret_val=0 |
| 80 | +sudo -u jenkins ftc run-test -b "${BOARD}" -t "${TEST}" -s "${SPEC}" \ |
| 81 | + --precleanup true \ |
| 82 | + --postcleanup false \ |
| 83 | + --rebuild false \ |
| 84 | + --reboot false \ |
| 85 | + --timeout 1d || ret_val=$? |
| 86 | + |
| 87 | +# Parse result file run.json. |
| 88 | +log_dir=$(find "/fuego-rw/logs/${TEST}/${BOARD}.${SPEC}"* -maxdepth 0 -type d | sort | tail -n 1) |
| 89 | +python "${TEST_DIR}/parser.py" -s "${log_dir}/run.json" -d "${RESULT_FILE}" |
| 90 | + |
| 91 | +if [ "${ret_val}" -ne 0 ]; then |
| 92 | + exit 1 |
| 93 | +else |
| 94 | + exit 0 |
| 95 | +fi |
0 commit comments