From b65f2c8093f82b223420d821ea4ae180fe81e3f0 Mon Sep 17 00:00:00 2001 From: Aleksander Mistewicz Date: Tue, 26 Jul 2016 12:31:17 +0200 Subject: [PATCH] Check for ssh errors in common_prep_flash_conf.sh Change-Id: I3850233b5459d5d4bf075cdad37f94020ca7641c Signed-off-by: Aleksander Mistewicz --- tsp/jobs/common_prep_flash_conf.sh | 49 +++++++++++++++++++++++------------ tsp/scripts/common_prep_flash_conf.sh | 10 ++++++- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/tsp/jobs/common_prep_flash_conf.sh b/tsp/jobs/common_prep_flash_conf.sh index 92720d5..aeb06d3 100755 --- a/tsp/jobs/common_prep_flash_conf.sh +++ b/tsp/jobs/common_prep_flash_conf.sh @@ -20,16 +20,17 @@ export TSP_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)/.." . "${TSP_DIR}/common.sh" -test -n "$1" || die "Missing argument: build nr" - -WORKDIR="${WS_TEST}/$1" -WORKDIR_REMOTE="${WS_TEST_REMOTE}/$1" -DWN_WORKDIR="${WS_DOWNLOAD}/$1" - +BUILD_NR="$1" TARGET="$2" +test -n "${BUILD_NR}" || die "Missing argument: build nr" test -n "$TARGET" || die "Missing argument: target" +WORKDIR="${WS_TEST}/${BUILD_NR}" +WORKDIR_REMOTE="${WS_TEST_REMOTE}/${BUILD_NR}" +DWN_WORKDIR="${WS_DOWNLOAD}/${BUILD_NR}" + + case "$TARGET" in *odroid*) BOOT_IMG="`ls ${DWN_WORKDIR}/tizen-common_*-boot-*.tar.gz`" @@ -44,38 +45,52 @@ esac FAIL_CNT="$3" test -n "${FAIL_CNT}" || FAIL_CNT=0 +retrigger() { + # Add job back to the queue + echo "Retrigger... ($1)" + echo "FAILED 1" > sysctl.result + tsrun_target "${TARGET}" -L "RETRIGGERED_$(echo "$TARGET" | tr 'a-z' 'A-Z')_PREPARE_FLASH_CONF" \ + sh "${TSP_DIR}/jobs/common_prep_flash_conf.sh" "$BUILD_NR" "${TARGET}" "$(($FAIL_CNT + 1))" + exit 0 +} + if [ "$FAIL_CNT" -ge 2 ]; then # Trigger publish job - tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$1" "$TARGET" - exit 0 + tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$BUILD_NR" "$TARGET" + exit 1 fi # Create and clean required directories on remote machine (tl-runner) -ssh tl-runner "rm -rf \"${WORKDIR_REMOTE}\"; mkdir -p \"${WORKDIR_REMOTE}\"" +ssh tl-runner "rm -rf \"${WORKDIR_REMOTE}\"; mkdir -p \"${WORKDIR_REMOTE}\"" || retrigger "ssh: remote ws cleanup failed" # Copy required files -scp "${BOOT_IMG}" "${USERSPACE_IMG}" "${USERSPACE_IMG_BMAP}" tl-runner:"${WORKDIR_REMOTE}/" +case "$TARGET" in + *odroid*) + scp "${USERSPACE_IMG}" "${BOOT_IMG}" tl-runner:"${WORKDIR_REMOTE}/" || retrigger "ssh: copy failed" + ;; + *minnow*) + scp "${USERSPACE_IMG}" "${USERSPACE_IMG_BMAP}" tl-runner:"${WORKDIR_REMOTE}/" || retrigger "ssh: copy failed" + ;; +esac + echo "start remote script" ssh tl-runner "TARGET=${TARGET} FAIL_CNT=${FAIL_CNT} WORKDIR_REMOTE=${WORKDIR_REMOTE} timeout 10m sh -s --" \ - < "${TSP_DIR}/scripts/common_prep_flash_conf.sh" + < "${TSP_DIR}/scripts/common_prep_flash_conf.sh" || retrigger "ssh: remote script execution failed" echo "finish remote script" # Copy the results scp tl-runner:"${WORKDIR_REMOTE}/sysctl.result" . echo "RETRIGGER_CNT ${FAIL_CNT}" >> sysctl.result -echo "Build nr: $1" >> sysctl.result +echo "Build nr: $BUILD_NR" >> sysctl.result echo "Date: `date`" >> sysctl.result # Check if they have run successfully, otherwise reschedule the job if grep -q "Testing failed." sysctl.result then - echo "Retrigger..." - tsrun_target ${TARGET} -L "RETRIGGERED_$(echo "$TARGET" | tr 'a-z' 'A-Z')_PREPARE_FLASH_CONF" \ - sh "${TSP_DIR}/jobs/common_prep_flash_conf.sh" "$1" "${TARGET}" "$(($FAIL_CNT + 1))" - exit 0 + retrigger "Testing failed." fi # Trigger publish job -tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$1" "$TARGET" +tspwb -L PUBLISH sh ${TSP_DIR}/jobs/publish.sh "$BUILD_NR" "$TARGET" diff --git a/tsp/scripts/common_prep_flash_conf.sh b/tsp/scripts/common_prep_flash_conf.sh index 412406e..07e3d46 100755 --- a/tsp/scripts/common_prep_flash_conf.sh +++ b/tsp/scripts/common_prep_flash_conf.sh @@ -30,6 +30,7 @@ case "$TARGET" in ;; *minnow*) USR_IMG="`pwd`/`ls tizen-common_*_common-*-sda.raw.bz2`" + USR_IMG_BMAP="`pwd`/`ls tizen-common_*_common-*-sda.bmap`" ;; esac @@ -70,4 +71,11 @@ fi echo "sdmux used: ${SDMUX}" >> sysctl.result -rm -v "$USR_IMG" "$BOOT_IMG" +case "$TARGET" in + *odroid*) + rm -v "$USR_IMG" "$BOOT_IMG" + ;; + *minnow*) + rm -v "$USR_IMG" "$USR_IMG_BMAP" + ;; +esac -- 2.7.4