#!/bin/bash # Clean: shellcheck -e 2001 ./tcwg-benchmark.sh set -ex # Make shellcheck happy and workaround Jenkins not defining variables # for empty arguments. toolchain_url="$toolchain_url" bench_list="$bench_list" cflags="$cflags" extension="$extension" testmode="$testmode" iterations="$iterations" run_profile="$run_profile" sysroot="$sysroot" fileserver="$fileserver" forceinstall="$forceinstall" builder="$builder" BUILD_NUMBER="$BUILD_NUMBER" NODE_NAME="$NODE_NAME" WORKSPACE="$WORKSPACE" # Jenkins doesn't define variables when parameter value is empty (like cflags), # so enable "set -u" only after above binding of variables. set -u if echo "$builder" | grep -q ".*-[0-9]\+"; then docker_host_opt="--arch amd64 --node $builder" else docker_host_opt="--label $builder" fi # Make sure to cleanup build container if something goes # wrong when preparing the test environment trap "cleanup_all_containers" EXIT ./start-container-docker.sh $docker_host_opt --distro trusty --task build --prefix build_ > build-container.sh build_container_host= build_container_port= . ./build-container.sh . jenkins-helpers.sh case "$toolchain_url" in "ssh://"*) ccprefix="${toolchain_url##ssh://}" if [ x"$sysroot" = x"tarball" ]; then echo "ERROR: Unsupported sysroot $sysroot for toolchain_url $toolchain_url" exit 1 fi ;; "http://"*".tar.xz"|"https://"*".tar.xz") wget_wildcard_url "$toolchain_url" # shellcheck disable=SC2046 tarball="$(ls $(basename "$toolchain_url"))" tar xf "${tarball}" toolchaindir="$WORKSPACE/$(echo "${tarball}" | sed 's/.tar.xz//')" ccpath=$(find "$toolchaindir" -name "*-gcc") ccprefix=$(echo "$ccpath" | sed -e 's/-gcc$/-/') # Copy toolchain to the build container. rsync -a --delete -e "ssh -p$build_container_port" "$toolchaindir/" "$build_container_host:$toolchaindir/" ccprefix="$build_container_host:$build_container_port:$ccprefix" if [ x"$sysroot" = x"tarball" ]; then sysroot="$build_container_host:$(find "$toolchaindir" -name "libc")" fi ;; *) echo "ERROR: Cannot handle toolchain_url: $toolchain_url" exit 1 ;; esac # Slaves for this job are virtual slaves on dev-01, # convert the slave name into the target board name boardname=$(echo "${NODE_NAME}" | sed 's/-bmk//').tcwglab rsync -az --delete bmk-scripts/ "$boardname:bmk-scripts/" case "$testmode" in build|verify) input_size="test" ;; benchmark) input_size="ref" ;; esac build_container_exec ssh -t "$boardname" bmk-scripts/run.sh \ --bench "$(printf '%q' "$bench_list")" \ --config "${BUILD_NUMBER}-$run_profile" \ --cflags "$(printf '%q' "$cflags")" \ --ccprefix "$ccprefix" \ --extension "$extension" \ --input_size "$input_size" \ --iterations "$iterations" \ --run_profile "$run_profile" \ "${sysroot:+--sysroot "$sysroot"}" \ --toolchain gnu \ --resultsdest "$resultsdest/${NODE_NAME}" \ --nodename "${NODE_NAME}" \ --forceinstall "${forceinstall}" \ --verbose true exit 0