summaryrefslogtreecommitdiffstats
path: root/rtems-release-test
blob: 2b971b85e5ce53d4e79849fb7c06184b8b8f7ef3 (plain) (blame)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#! /bin/sh
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2020 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

set -e

#
# Test a release
#

#
# Global release top path.
#
#
# Work in the release sandbox
#
export release_top=$(realpath $(dirname $0))

#
# Top
#
top=$PWD

#
# Defaults.
#
. ${release_top}/rtems-release-defaults

release_url="${rtems_release_url}"
build_email="no"
build_from="none"
build_to="${email_build_to}"
smtphost=

#
# Usage for this tool.
#
usage() {
 echo "Usage: $0 [-u RELEASE-URL] version revision" 1>&2
 echo " where:" 1>&2
 echo "  version          : The version of RTEMS, eg 5" 1>&2
 echo "  revision         : The revision, eg 0.0 or 0.0-myrev" 1>&2
 echo "  -u [RELEASE-URL] : The path to download the RSB (default: ${rtems_release_url})." 1>&2
 echo "  -e               : Email the build results." 1>&2
 echo "  -F [FROM]        : The FROM email address." 1>&2
 echo "  -T [TO]          : The TO email address (default: ${email_build_to}." 1>&2
 echo "  -s [SMTP-HOST]   : The STMP host to send the mail via." 1>&2
 exit 1
}

#
# Option defaults
#
release_url=${rtems_release_url}

#
# Manage the command line.
#
while getopts ":u:eF:T:s:" opt; do
 case "${opt}" in
  u)
   release_url=${OPTARG}
   ;;
  e)
   build_email="yes"
   ;;
  F)
   build_from=${OPTARG}
   ;;
  T)
   build_to=${OPTARG}
   ;;
  s)
   smtphost=${OPTARG}
   ;;
  *)
   usage
   ;;
 esac
done
shift $((OPTIND-1))

if [ $# -ne 2 ]; then
 echo "error: 2 arguments must be supplied, version and revision. See -h for help" 1>&2
 exit 1
fi

if [ ${build_email} = yes ]; then
 if [ ${build_from} = "none" ]; then
  echo "error: no FROM email address provided. See -h for help" 1>&2
  exit 1
 fi
fi

version=$1
revision=$2

. ${release_top}/rtems-release-version

bsets=
bsets="${bsets} ${version}/rtems-sparc"
bsets="${bsets} ${version}/rtems-arm"
bsets="${bsets} ${version}/rtems-powerpc"
bsets="${bsets} ${version}/rtems-i386"
bsets="${bsets} ${version}/rtems-riscv"

#
# The BSP were moved after 5.
#
if [ ${version} -eq 5 ]; then
 bsp_ver="5/"
fi
bsets="${bsets} ${bsp_ver}bsps/beagleboneblack"
bsets="${bsets} ${bsp_ver}bsps/xilinx_zynq_zedboard"
bsets="${bsets} ${bsp_ver}bsps/pc"
bsets="${bsets} ${bsp_ver}bsps/erc32"
bsets="${bsets} ${bsp_ver}bsps/imx7"

#
# Is this an RC or snapshot build in the default RTEMS release path?
#
if [ ${release_url} = ${rtems_release_url} -a \
     $(echo ${revision} | sed 's/.*-.*/yes/') = yes ]; then
 release_url=${release_url}/${version}
 if [ $(echo ${revision} | sed 's/.*-rc.*/yes/') = yes ]; then
  release_url=${release_url}/rc/${release}
 else
  revision_number=$(echo ${revision} | sed 's/-.*//')
  release_url=${release_url}/${revision_number}/${release}
 fi
fi

echo "RTEMS Release Testing, v${release}"
echo
echo "URL: ${release_url}"

email_body="${top}/email-body.txt"
rm -f ${email_body}
touch ${email_body}

email()
{
 echo "$*" >> ${email_body}
}
email_attach()
{
 cat $1 >> ${email_body}
}

email  "RTEMS Release Testing, v${release}"
email
email "URL:  ${release_url}"
email "Host: $(uname -a)"
email "Date: $(date)"
email

#
# Clean the build directory.
#
if [ -e ${release} ]; then
 echo "] Removing existing ${release} build" 1>&2
 rm -rf ${release}
fi
mkdir ${release}

cd ${release}
 rsb="rtems-source-builder-${release}"
 rsb_tar="${rsb}.tar.xz"
 if [ ! -z $(command -v wget) ]; then
  echo "wget ${release_url}/sources/${rsb_tar}"
  wget ${release_url}/sources/${rsb_tar}
 else
  if [ ! -z $(command -v curl) ]; then
    echo "curl ${release_ur}/sources/${rsb_tar} > ${rsb_tar}"
    curl ${release_url}/sources/${rsb_tar} > ${rsb_tar}
  else
   echo "error: cannot find wget or curl; please install" 1>&2
   exit 1
  fi
 fi
 echo "tar Jxf ${rsb_tar}"
 tar Jxf ${rsb_tar}
 cd ${rsb}/rtems
 email "Build Sets"
 email "=========="
 result="PASSED"
 touch ${top}/rsb_out.txt
 for bset in ${bsets}
 do
  email
  echo "../source-builder/sb-set-builder --prefix=${top}/build --log=$(basename ${bset}).txt ${bset}"
  rm -f rsb-report-*
  set +e
  ../source-builder/sb-set-builder --prefix=${top}/build --log=$(basename ${bset}) ${bset} > rsb_out.txt 2>&1
  ec=$?
  set -e
  cat rsb_out.txt >> ${top}/rsb_out.txt
  if [ ${ec} -eq 0 ]; then
   email "${bset}: PASS"
  else
   result="FAIL"
   email "${bset}: FAIL"
   email "RSB Output:"
   email_attach rsb_out.txt
   if [ -e rsb-report-* ]; then
    email "RSB Error Report:"
    email_attach rsb-report-*
   else
    email "RSB Error Report: not-found"
   fi
  fi
 done
 if [ ${build_email} = yes ]; then
  subject="RTEMS Release Test: ${release} - ${result}"
  ${release_top}/rtems-mailer --to=${build_to} \
                              --from=${build_from} \
                              --subject="${subject}" \
                              ${smtphost} \
                              ${email_body}
 fi
 cd ..
 echo "Build Finished"

exit 0