Path: blob/main/crypto/libecc/scripts/crossrun.sh
102415 views
#/*1# * Copyright (C) 2017 - This file is part of libecc project2# *3# * Authors:4# * Ryad BENADJILA <[email protected]>5# * Arnaud EBALARD <[email protected]>6# * Jean-Pierre FLORI <[email protected]>7# *8# * Contributors:9# * Nicolas VIVET <[email protected]>10# * Karim KHALFALLAH <[email protected]>11# *12# * This software is licensed under a dual BSD and GPL v2 license.13# * See LICENSE file at the root folder of the project.14# */15#!/bin/sh1617run_triplet_wordsize(){18triplet=$119wordsize=$220echo "======== RUNNING RELEASE FOR $triplet / $wordsize"21if [ "$triplet" != "i386-apple-darwin" ] && [ "$triplet" != "x86_64-apple-darwin" ] && [ "$triplet" != "x86_64h-apple-darwin" ] && [ "$triplet" != "i686-w64-mingw32" ] && [ "$triplet" != "x86_64-w64-mingw32" ]; then22echo " [X] Using QEMU static"23$CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static vectors24$CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_debug_static vectors25#$CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static rand26fi27if [ "$triplet" = "i386-apple-darwin" ] || [ "$triplet" = "x86_64-apple-darwin" ] || [ "$triplet" = "x86_64h-apple-darwin" ]; then28echo " [X] Testing MAC-OS binaries is futur work!"29fi30if [ "$triplet" = "i686-w64-mingw32" ] || [ "$triplet" = "x86_64-w64-mingw32" ]; then31echo " [X] Using WINE"32wine $CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static vectors33wine $CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_debug_static vectors34#wine $CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static rand35fi36}373839print_help(){40echo "$0 uses qemu-static and wine to run self tests"41echo "with multiple word sizes (16, 32 and 64)."42echo "The produced binaries are expected to be in the 'crossbuild_out' folder."43echo "Supported platform triplets are:"44echo "arm-linux-gnueabi / arm-linux-gnueabihf / powerpc64le-linux-gnu / aarch64-linux-gnu /"45echo "mipsel-linux-gnu / i386-apple-darwin / x86_64-apple-darwin / i686-w64-mingw32 / x86_64-w64-mingw32."46}474849######### Script main50SRC_DIR=`dirname "$(readlink -f "$0")"`/..51CROSSBUILD_OUTPUT=$SRC_DIR/scripts/crossbuild_out/5253# Check for the qemu-static command line54for arch in i386 x86_64 arm ppc64 aarch64 mipsel;55do56QEMU_CHECK=$(qemu-$arch-static -h)57if [ $? -ne 0 ]; then58echo "qemu-$arch-static is not installed ... Please install it! (usually in qemu-user-static)"59exit60fi61done6263WINE_CHECK=$(wine --help)64if [ $? -ne 0 ]; then65echo "wine is not installed ... Please install it!"66exit67fi6869WINE64_CHECK=$(wine64 --help)70if [ $? -ne 0 ]; then71echo "wine64 is not installed ... Please install it!"72exit73fi7475# Print help if asked76if [ "$1" = "-h" ]77then78print_help $079exit80fi8182# If we have arguments, just execute subcommand83if [ "$1" = "-triplet" ]84then85# If no specific word size has been given, do all the sizes86if [ "$3" = "" ]87then88for wordsize in 16 32 64;89do90run_triplet_wordsize $2 $wordsize91done92else93run_triplet_wordsize $2 $394fi95exit96fi9798ALL_CHECKS=""99for wordsize in 16 32 64;100do101for triplet in arm-linux-gnueabi arm-linux-gnueabihf powerpc64le-linux-gnu aarch64-linux-gnu mipsel-linux-gnu i386-apple-darwin x86_64-apple-darwin x86_64h-apple-darwin i686-w64-mingw32 x86_64-w64-mingw32;102do103ALL_CHECKS="$ALL_CHECKS\n-triplet $triplet $wordsize"104done105done106107if [ "$1" = "-cpu" ]108then109if [ "$3" = "-triplet" ]110then111echo "-cpu and -triplet are not compatible ..."112exit113else114# User defined number of CPUs115NCPU=$2116fi117else118# Get number of CPUs for parallel processing119NCPU=`getconf _NPROCESSORS_ONLN`120fi121echo "Parallelizing on $NCPU processors"122# Unleash the kraken123echo $ALL_CHECKS | xargs -n 4 -P $NCPU sh `readlink -f "$0"`124125126