Debian Codegraph @

test

raw
1 #!/bin/bash -e
2 #
3
4 # source ./build
5
6 TESTABLE=""
7 FORMATTABLE="$TESTABLE attestation tpmd tspi verification tpmclient tpmown tspiconst"
8
9 # user has not provided PKG override
10 if [ -z "$PKG" ]; then
11 TEST=$TESTABLE
12 FMT=$FORMATTABLE
13
14 # user has provided PKG override
15 else
16 # strip out slashes and dots from PKG=./foo/
17 TEST=${PKG//\//}
18 TEST=${TEST//./}
19
20 # only run gofmt on packages provided by user
21 FMT="$TEST"
22 fi
23
24 # split TEST into an array and prepend REPO_PATH to each local package
25 split=(${TEST// / })
26 TEST=${split[@]/#/${REPO_PATH}/}
27
28 # TODO: add tests..
29 # echo "Running tests..."
30 # go test ${COVER} $@ ${TEST}
31
32 echo "Checking gofmt..."
33 fmtRes=$(gofmt -l $FMT)
34 if [ -n "${fmtRes}" ]; then
35 echo -e "gofmt checking failed:\n${fmtRes}"
36 exit 255
37 fi
38
39 echo "Checking golint..."
40 # tpmclient and tspiconst declare C style constants and don't pass golint. For
41 # now ignore them.
42 golint -set_exit_status \
43 ./attestation \
44 ./tpmd \
45 ./tpmown \
46 ./verification
47
48 echo "Success"