blob: 8482f2fc7ffb2383507aadd8aba7d96b837b5cc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/bin/sh
# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Script used to flash, prepare and configure Minnowboard MAX.
# Compatibile with both (32-bit and 64-bit) versions.
# Configuration file in $TL_IP_CONF is required; format is:
# <IP address> <SDMUX>
#
# Synatx is: minnow_prepare_conf_flash.sh $SDMUX $IMAGE
#
# Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
export TESTLAB_SCRIPTS="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
. "${TESTLAB_SCRIPTS}/common.sh"
. "${TESTLAB_SCRIPTS}/flash/flash.sh"
. "${TESTLAB_SCRIPTS}/conf/conf.sh"
. "${TESTLAB_SCRIPTS}/run/run.sh"
SDMUX="$1"
IMAGE="$2"
TL_IP_CONF="/etc/opt/testlab-major/ip_addr"
test -n "${SDMUX}" || die "Missing argument: sdmux!"
test -n "${IMAGE}" || die "Missing argument: image!"
test -f "${IMAGE}" || die "Image file does not exist or is not a regular file: ${IMAGE}!"
test -f "${TL_IP_CONF}" ||
die "Required conf file does not exist or is not accessible: ${TL_IP_CONF}"
IP="$(awk -v SDMUX="${SDMUX}" '$2 == SDMUX {print $1}' "${TL_IP_CONF}")"
test -n "${IP}" || die "Missing entry in: ${TL_IP_CONF}"
echo "### prepare ###"
switch2testserver "${SDMUX}"
echo "### flash ###"
UUID_FILE="/var/tmp/uuid-${SDMUX}"
DEV_SDCARD=$(uuid2dev "${UUID_FILE}" "${SDMUX}")
echo "Bmaptool: start"
test -b "${DEV_SDCARD}" || die "File does not exist or is not block special"
sudo bmaptool -q copy "${IMAGE}" "${DEV_SDCARD}"
RET=$?
echo "Bmaptool: finish"
change_uuid "${UUID_FILE}" "${DEV_SDCARD}"
if [ $RET -ne 0 ]; then
die "Bmaptool exited with an error" "$RET"
fi
switch2device "${SDMUX}"
restart_device "${SDMUX}"
echo "### conf ###"
CONNECT_CNT=0
SLEEP=${INIT_SLEEP}
sleep "${SLEEP}"
while ! ping -c 1 "${IP}" -W 1 | grep -q icmp_seq
do
printf ","
if [ ${SLEEP} -ge ${MAX_SLEEP} ]
then
die "Timeout: host not found in the network!"
fi
if [ ${SLEEP} -ge ${RESTART_SLEEP} ]
then
echo "Restarting MINNOW" >&2
restart_device "${SDMUX}"
fi
sleep "${SLEEP}"
SLEEP=$((SLEEP+INC_SLEEP))
CONNECT_CNT=$((CONNECT_CNT+1))
done
printf "\n"
SLEEP=10
while ! nc -q 1 "${IP}" 22 </dev/null
do
printf "."
if [ ${SLEEP} -ge 60 ]
then
die "Timeout: ssh port not open!"
fi
SLEEP=$((SLEEP+10))
CONNECT_CNT=$((CONNECT_CNT+1))
done
printf "\n"
copy_ssh "${IP}" "${TESTLAB_SCRIPTS}/run/smoke_tests.sh"
run_smoke_ssh "${IP}"
echo "CONNECT_CNT $CONNECT_CNT" >> sysctl.result
cat sysctl.result
echo "### run ###"
if [ -f "common_test.yaml" ]
then
run_avocado_ssh "${IP}" "avocado-results" "common_test.yaml"
else
echo "Missing file: common_test.yaml; skipping avocado tests"
fi
echo "### cleanup ###"
switch2testserver "${SDMUX}"
|