|
| 1 | +#!/bin/sh |
| 2 | +#******************************************************************************* |
| 3 | +# Copyright 2019-2022 FUJITSU LIMITED |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +#******************************************************************************/ |
| 17 | +#******************************************************************************* |
| 18 | +# Default compiler is g++ |
| 19 | +#******************************************************************************* |
| 20 | +TEST_FILE=${1} |
| 21 | +AARCH64_TYPE="armv8.4-a" |
| 22 | +if [ ${ARCH} = arm64 ] ; then |
| 23 | + AARCH64_TYPE="all" |
| 24 | +fi |
| 25 | +CXX_FLAGS1="-std=c++11 -fomit-frame-pointer -Wall -fno-operator-names -I../xbyak_aarch64 -I./ -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -Wno-ignored-qualifiers" |
| 26 | +CXX_FLAGS2="-std=c++11 -Wall -I../xbyak_aarch64 -DXBYAK_TEST -DXBYAK_USE_MMAP_ALLOCATOR" |
| 27 | + |
| 28 | +#******************************************************************************* |
| 29 | +# Function definition |
| 30 | +#******************************************************************************* |
| 31 | +usage_exit() { |
| 32 | + echo "Usage: $0 [-f|-q] TEST_FILE" |
| 33 | + echo " [-f] Fujitsu Compiler" |
| 34 | + echo " [-q] GCC + QEMU" |
| 35 | + exit 1 |
| 36 | +} |
| 37 | + |
| 38 | +dumpOK () { |
| 39 | + echo "##########################################" |
| 40 | + echo "# Test OK :-)" |
| 41 | + echo "##########################################" |
| 42 | +} |
| 43 | + |
| 44 | +dumpNG () { |
| 45 | + echo "##########################################" |
| 46 | + echo "# $1" |
| 47 | + echo "# Test NG :-p" |
| 48 | + echo "##########################################" |
| 49 | +} |
| 50 | + |
| 51 | +set_variables() { |
| 52 | + |
| 53 | + case $ENV_SELECT in |
| 54 | + f) CXX=FCC; |
| 55 | + CXX_FLAGS1="-std=c++11 -fomit-frame-pointer -Wall -fno-operator-names -I../xbyak_aarch64 -I./ -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -Nclang -Knolargepage -Wno-ignored-qualifiers"; |
| 56 | + CXX_FLAGS2="-Wall -I../xbyak_aarch64 -DXBYAK_TEST -DXBYAK_USE_MMAP_ALLOCATOR -Nclang -Knolargepage"; |
| 57 | + echo "compiler is FCC" |
| 58 | + ;; |
| 59 | + |
| 60 | + q) source setenv-qemu |
| 61 | + ;; |
| 62 | + g) source setenv-gcc |
| 63 | + ;; |
| 64 | + *) |
| 65 | + ;; |
| 66 | + esac |
| 67 | +} |
| 68 | + |
| 69 | +#******************************************************************************* |
| 70 | +# Main routine |
| 71 | +#******************************************************************************* |
| 72 | +while getopts f: OPT |
| 73 | +do |
| 74 | + case $OPT in |
| 75 | + f) ENV_SELECT=f; TEST_FILE=$OPTARG |
| 76 | + ;; |
| 77 | + q) ENV_SELECT=q; TEST_FILE=$OPTARG |
| 78 | + ;; |
| 79 | + \?) usage_exit |
| 80 | + ;; |
| 81 | + esac |
| 82 | +done |
| 83 | +#shift $((OPTIND - 1)) |
| 84 | + |
| 85 | +set_variables |
| 86 | + |
| 87 | +# Make object files |
| 88 | +${CXX} -c ${TEST_FILE}.cpp -o ${TEST_FILE}.o ${CXX_FLAGS1} -MMD -MP -MF ${TEST_FILE}.d |
| 89 | + |
| 90 | +if [ $? != 0 ] ; then |
| 91 | + dumpNG "Making object files" |
| 92 | + exit 1 |
| 93 | +fi |
| 94 | + |
| 95 | +# Make binary |
| 96 | +${CXX} ${TEST_FILE}.o -o ${TEST_FILE} -L ../lib -lxbyak_aarch64 |
| 97 | + |
| 98 | +if [ $? != 0 ] ; then |
| 99 | + dumpNG "Compiling binary." |
| 100 | + exit 1 |
| 101 | +fi |
| 102 | + |
| 103 | + |
| 104 | +# Output |
| 105 | +${EMULATOR} ./${TEST_FILE} > ${TEST_FILE}.log 2>&1 |
| 106 | +if [ $? != 0 ] ;then |
| 107 | + dumpNG "Running binary test." |
| 108 | + exit 1 |
| 109 | +fi |
0 commit comments