-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·39 lines (32 loc) · 884 Bytes
/
test
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
#!/usr/bin/env bash
TESTS=(
'BIND: \d+\.\d+\.\d+\b[^ ]*'
'Composer: \d+\.\d+\.\d+(-\w+)?'
'Docker: \d+\.\d+\.\d+'
'ExifTool: \d+\.\d+'
'ImageMagick: \d\.\d\.\d-\d\d?'
'MongoDB: \d+\.\d+\.\d+'
'NGINX: \d+\.\d+\.\d+'
'OpenDKIM: \d+\.\d+\.\d+'
'Perl: \d+\.\d+\.\d+'
'PHP: \d+\.\d+\.\d+\b[^ ]*'
'Postfix: \d+\.\d+\.\d+'
'Python: \d+\.\d+\.\d+'
'Squid: \d+\.\d+\.\d+'
'Varnish: \d+\.\d+\.\d+'
'ZNC: \d+\.\d+\.\d+\b[^ ]*'
)
pass=${fail=0}
printf '%s\n\n' "${INPUT=$(cat)}"
time for test in "${TESTS[@]}"; do
printf '"%s" ' "$test"
if match=$(grep -Pxm1 "$test" <<<"$INPUT"); then
echo $(tput setaf 2)"✔ Matches \"$match\"."$(tput sgr0)
((++pass))
else
echo $(tput setaf 1)'✘ No match.'$(tput sgr0)
((++fail))
fi
done
echo -e "\nPassed: $pass Failed: $fail"
((fail == 0))