File: quick_test.sh

package info (click to toggle)
android-platform-system-extras 10.0.0%2Br36%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,588 kB
  • sloc: cpp: 45,171; python: 10,047; ansic: 8,169; sh: 4,029; java: 2,239; javascript: 1,752; xml: 991; asm: 169; makefile: 13
file content (48 lines) | stat: -rwxr-xr-x 1,005 bytes parent folder | download | duplicates (6)
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
#!/bin/bash

nethandle=0

readonly TEST_HOST="connectivitycheck.gstatic.com"
readonly TEST_PATH="/generate_204"
readonly PREFIX=">>>"

function getUrls() {
    if [ ! -z $(echo "$1" | sed -e 's/[^:]//g') ]; then
        echo "http://[$1]$TEST_PATH"
        echo "http://[$1]:80$TEST_PATH"
    else
        echo "http://$1$TEST_PATH"
        echo "http://$1:80$TEST_PATH"
    fi
}

function toHex() {
    readonly local hexValue=$(bc -q 2>/dev/null << EOT
obase=16
$1
EOT
)
    if [ ! -z "$hexValue" ]; then
        echo "0x$hexValue"
    fi
}


if [ ! -z "$1" ]; then
    nethandle="$1"
fi
echo "$PREFIX Using nethandle $nethandle ($(toHex $nethandle))"
echo ""

readonly IPADDRESSES=$(
    adb shell /system/bin/dnschk --nethandle $nethandle $TEST_HOST |
    sed -e 's/#.*//' -e '/^$/d')


for host in $TEST_HOST $IPADDRESSES; do
    urls=$(getUrls $host)
    for url in $urls; do
        echo "$PREFIX Checking $url" >&2
        adb shell /system/bin/httpurl --nethandle $nethandle "$url"
    done
done