File: make_test

package info (click to toggle)
stunnel4 3:5.50-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,492 kB
  • sloc: ansic: 15,914; sh: 5,645; pascal: 2,719; perl: 988; cpp: 650; makefile: 216
file content (98 lines) | stat: -rwxr-xr-x 2,648 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh

result=0
count=0
fail=0
skip=0

result_path=$(pwd)
cd $(dirname "$0")
script_path=$(pwd)
cd "${result_path}"
result_path="${result_path}/logs"

autodetection() {

  result=0
  if [ -n "$(command -v ncat)" ]
    then # ncat
      mynetcat="ncat"
    elif [ -n "$(command -v nc)" ]
      then # nc
        mynetcat="nc"
    else # netcat is required
      printf "%s\n" "ncat / nc not found in \$PATH"
      result=1
  fi

  if [ -n "$(command -v netstat)" ] && ! netstat -a -n 2>&1 | grep -q -e "usage" -e "invalid" -e "illegal" -e "command not found"
    then
      mynetstat="netstat"
    elif [ -n "$(command -v ss)" ] && ! ss -a -n -l 2>&1 | grep -q -e "usage" -e "invalid" -e "illegal" -e "command not found"
      then
        mynetstat="ss"
    elif [ -n "$(command -v lsof)" ] && ! lsof -i -n -P 2>&1 | grep -q -e "usage" -e "invalid" -e "illegal" -e "command not found"
      then
        mynetstat="lsof"
    else # netstat / ss / lsof is required
      printf "%s\n" "netstat / ss / lsof not found in \$PATH or some option error"
      result=1
   fi

  if [ -n "$(command -v stdbuf)" ]
    then
      mybuffer="stdbuf"
    elif [ -n "$(command -v unbuffer)" ]
      then
        mybuffer="unbuffer"
    else
      mybuffer=""
    fi

  return $result
}

if autodetection
  then
    rm -rf "${result_path}"
    mkdir "${result_path}"
    cd "${result_path}"
    date > "results.log"
    ../../src/stunnel -version 2>> "results.log"
    printf "\n%s\n" "Testing..." >> "results.log"
    head -n5 "results.log"
    if ! grep -q "solaris" "results.log"
      then
        for plik in ${script_path}/recipes/*
          do
            /bin/sh $plik "$mynetcat" "$mynetstat" "$mybuffer"
            state=$?
            if [ "$state" -eq 0 ]
              then # $state=0
                count=$((count + 1))
              elif [ "$state" -eq 125 ]
                then # $state=125
                  skip=$((skip + 1))
              else # $state=1
                fail=$((fail + 1))
                result=1
              fi
          done
        if [ $count -eq 0 ]
          then # no test was done
            result=1
          fi
        printf "%s\n" "summary: success $count, skip $skip, fail $fail"
        printf "%s\n" "summary: success $count, skip $skip, fail $fail" >> "results.log"
        printf "%s\n" "./make_test finished"
        cd ..
      else # skip make test for solaris
        printf "%s\n" "./make_test skipped"
        printf "%s\n" "./make_test skipped" >> "results.log"
        #result=125
      fi
  else # netcat not found
    printf "%s\n" "./make_test skipped"
    #result=125
  fi
exit $result