github.com/iDigitalFlame/xmt@v0.5.4/tools/run_tests.sh (about)

     1  #!/usr/bin/bash -e
     2  # Copyright (C) 2020 - 2023 iDigitalFlame
     3  #
     4  # This program is free software: you can redistribute it and/or modify
     5  # it under the terms of the GNU General Public License as published by
     6  # the Free Software Foundation, either version 3 of the License, or
     7  # any later version.
     8  #
     9  # This program is distributed in the hope that it will be useful,
    10  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  # GNU General Public License for more details.
    13  #
    14  # You should have received a copy of the GNU General Public License
    15  # along with this program.  If not, see <https://www.gnu.org/licenses/>.
    16  #
    17  
    18  build_tags=(
    19                bugs implant crypt stdrand nojson nosweep tiny small medium large nofrag regexp nopanic noservice ews noproxy nokeyset scripts
    20                bugs,implant
    21                bugs,implant,crypt
    22                bugs,implant,crypt,stdrand
    23                bugs,implant,crypt,stdrand,nojson
    24                bugs,implant,crypt,stdrand,nojson,nosweep
    25                bugs,implant,crypt,stdrand,nojson,nosweep,tiny
    26                bugs,implant,crypt,stdrand,nojson,nosweep,small
    27                bugs,implant,crypt,stdrand,nojson,nosweep,medium
    28                bugs,implant,crypt,stdrand,nojson,nosweep,nofrag
    29                bugs,implant,crypt,stdrand,nojson,nosweep,nofrag,regexp
    30                bugs,implant,crypt,stdrand,nojson,nosweep,nofrag,regexp,ews
    31                bugs,implant,crypt,stdrand,nojson,nosweep,nofrag,regexp,ews,noproxy
    32                implant,crypt,stdrand,nojson,nosweep,nofrag,regexp,ews,noproxy
    33                crypt,stdrand,nojson,nosweep,nofrag,regexp,ews,noproxy
    34                crypt,stdrand,nojson,nosweep,nofrag,regexp,noproxy
    35                stdrand,nojson,nosweep,nofrag,regexp,ews,noproxy
    36                nojson,nosweep,nofrag,regexp,ews,noproxy
    37                nosweep,nofrag,regexp,ews,noproxy
    38                nosweep,nofrag,ews,noproxy
    39                nosweep,nofrag,noproxy
    40                nosweep,nofrag,ews
    41                nofrag,regexp,ews
    42                nofrag,regexp
    43                nofrag,ews
    44                nofrag
    45                funcmap
    46             )
    47  
    48  if ! go mod tidy; then
    49      printf "\x1b[1m\x1b[31m[!] Tidying modules failed!\x1b[0m\n"
    50      exit 1
    51  fi
    52  
    53  if ! go mod verify; then
    54      printf "\x1b[1m\x1b[31m[!] Verifying modules failed!\x1b[0m\n"
    55      exit 1
    56  fi
    57  
    58  run_vet() {
    59      printf "\x1b[1m\x1b[36m[+] Vetting GOARCH=$1 GOOS=$2..\x1b[0m\n"
    60      env GOARCH=$1 GOOS=$2 go vet ./c2 2>&1 | grep -vE '^# github.com'
    61      env GOARCH=$1 GOOS=$2 go vet ./cmd 2>&1 | grep -vE '^# github.com|: possible misuse of unsafe.Pointer$'
    62      env GOARCH=$1 GOOS=$2 go vet ./com 2>&1 | grep -vE '^# github.com'
    63      env GOARCH=$1 GOOS=$2 go vet ./data 2>&1 | grep -vE '^# github.com'
    64      env GOARCH=$1 GOOS=$2 go vet ./device 2>&1 | grep -vE '^# github.com|: possible misuse of unsafe.Pointer$|\.s:'
    65      env GOARCH=$1 GOOS=$2 go vet ./man 2>&1 | grep -vE '^# github.com'
    66      env GOARCH=$1 GOOS=$2 go vet ./util 2>&1 | grep -vE '^# github.com'
    67  }
    68  run_vet_all() {
    69      for entry in $(go tool dist list); do
    70          run_vet "$(echo $entry | cut -d '/' -f 2)" "$(echo $entry | cut -d '/' -f 1)"
    71      done
    72  }
    73  run_staticcheck() {
    74      printf "\x1b[1m\x1b[33m[+] Static Check GOARCH=$1 GOOS=$2..\x1b[0m\n"
    75      env GOARCH=$1 GOOS=$2 staticcheck -checks all -f text ./... | grep -vE '^-: # github.com/iDigitalFlame/xmt/examples$|^examples/|^unit_tests/|^c2/session.go:288|^c2/session.go:1155'
    76      for tags in ${build_tags[@]}; do
    77          printf "\x1b[1m\x1b[34m[+] Static Check GOARCH=$1 GOOS=$2 with tags \"${tags}\"..\x1b[0m\n"
    78          env GOARCH=$1 GOOS=$2 staticcheck -checks all -f text -tags $tags ./... | grep -vE '^-: # github.com/iDigitalFlame/xmt/examples$|^examples/|^unit_tests/|^c2/session.go:288|^c2/session.go:1155'
    79      done
    80  }
    81  run_staticcheck_all() {
    82      for entry in $(go tool dist list); do
    83          run_staticcheck "$(echo $entry | cut -d '/' -f 2)" "$(echo $entry | cut -d '/' -f 1)"
    84      done
    85  }
    86  
    87  run_vet_all
    88  run_staticcheck_all