github.com/openebs/node-disk-manager@v1.9.1-0.20230225014141-4531f06ffa1e/build/test.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2018-2020 The OpenEBS Authors. All rights reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # 16 # This script runs tests and generates a report file. 17 18 set -e 19 20 # architecute on which tests need to be run 21 ARCH=$1 22 23 if [ -z "$ARCH" ]; then 24 echo "platform not specified for running tests. Exiting." 25 exit 1 26 fi 27 28 # currently tests are run only for amd64 29 if [ "$ARCH" != "amd64" ]; then 30 exit 0 31 fi 32 33 exit_val=0 34 echo "" > coverage.txt 35 PACKAGES=$(go list ./... | grep -v '/vendor/\|/pkg/apis/\|/pkg/client/\|integration_test') 36 for d in $PACKAGES; do 37 if ! go test -coverprofile=profile.out -covermode=atomic "$d"; then 38 exit_val=1 39 fi 40 if [ -f profile.out ]; then 41 cat profile.out >> coverage.txt 42 rm profile.out 43 fi 44 done 45 46 exit ${exit_val}