#!/bin/bash # Set defaults if test x"${debug}" = x"true"; then export CONFIG_SHELL="/bin/bash -x" else export CONFIG_SHELL="/bin/bash" fi user_workspace="$PWD" OPTS="`getopt -o w:t:h -l tarball:,workspace:,help`" while test $# -gt 0; do echo 1 = "$1" case $1 in -w|--workspace) user_workspace=$2 ;; -t|--tarball) tarball=$2 ;; -h|--help) usage ;; --) break ;; esac shift done if test -e ${user_workspace}; then cat << EOF > ${user_workspace}/BUILD-INFO.txt Format-Version: 0.5 Files-Pattern: * License-Type: open EOF fi testdir=${user_workspace}/_test # Create a test directory if test ! -d ${testdir}; then mkdir -p ${testdir} fi # Use the newly created build directory cd ${testdir} file=`basename ${tarball}` tarball_name="${testdir}/${file}" protocol="`echo ${tarball} | cut -d ':' -f 1`" if test x${protocol} = x"file"; then tarball_name="`echo ${tarball} | sed -e 's:file./::'`" else # Download the toolchain binary tarball if test ! -e ${testdir}/${file}; then wget ${tarball} --directory=${testdir} --progress=dot:giga if test $? -gt 0; then echo "ERROR: ${tarball} doesn't exist on remote machine!" exit 1 fi fi fi # Extract the tarball dir="`echo ${file} | sed -e 's:.tar.xz::'`" tar Jxf ${tarball_name} --directory=${testdir} if test $? -gt 0; then echo "ERROR: ${tarball} is corrupted!" exit 1 fi # Create a simple test case if test ! -e ${testdir}/hello.cpp; then # Create the usual Hello World! test case cat < ${testdir}/hello.cpp #include int main(int argc, char *argv[]) { std::cout << "Hello World!" << std::endl; } EOF fi target="`echo ${dir} | egrep -o '(arm|aarch64)[_0-9a-z-]*' | sed -e 's:-\$::'`" win32="`echo {$file} | grep -c mingw`" # For Windows releases, check for symlinks in the release tarball. Some # extractors for Windows do not handle symlinks well, so Abe should # generate tarballs without symlinks. if test ${win32} -ne 0; then find "${testdir}" -type l > ${testdir}/symlinks.txt 2>&1 SYMLINKS="$(grep -c ^ ${testdir}/symlinks.txt)" if [ "$SYMLINKS" -eq 0 ]; then echo "No symlinks found in release" else cat ${testdir}/symlinks.txt echo "Found symlinks in release: FAILURE" exit 1 fi fi # Bare metal builds need special care baremetal="`echo ${target} | egrep -c "\-eabi|\-elf"`" if test ${baremetal} -gt 0; then case ${target} in aarch64*) # AArch64 needs specs rdimon="`find ${testdir} -name rdimon.specs | head -1`" specs="${rdimon:+--specs=${rdimon}}" ;; arm*) # ARM does not need specs, but the default cpu implies # undefined references to __sync_synchronize specs="-mcpu=cortex-a9" ;; esac fi # Compile the test case rm -f ${testdir}/hi params="-o ${testdir}/hi ${testdir}/hello.cpp ${specs:-} -static" if test ${win32} -eq 0; then ${testdir}/${dir}/bin/${target}-c++ ${params} else # Compilation may fail if the paths are too long. # Create a G: drive, as a shortcut makes wine automagically use # it. # Make sure WINEPREFIX exists by running a dummy command export WINEPREFIX="$(pwd)/dotwine" echo "ECHO Hello" | wine cmd rm -f ${WINEPREFIX}/dosdevices/g: ln -s ${testdir}/${dir} ${WINEPREFIX}/dosdevices/g: wine ${testdir}/${dir}/bin/${target}-c++ ${params} fi # See if the compilation worked if test -e ${testdir}/hi; then echo Compilation of hello.cpp: SUCCESS else echo Compilation of hello.cpp: FAILED exit 1 fi git clone --depth 1 https://git-us.linaro.org/toolchain/tcwg-regression make -C tcwg-regression check TOOLCHAIN=${testdir}/${dir} TARGET=${target} if [ $? -ne 0 ]; then echo "TCWG regression tests FAILED" exit 1 fi exit 0