2018-07-07 17:34:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2019-11-07 19:10:37 +00:00
|
|
|
TEST_RUN=ALL
|
|
|
|
PAUSE=no
|
|
|
|
MICRO_OSD_PATH="/micro-osd.sh"
|
|
|
|
|
2019-12-20 15:59:57 +00:00
|
|
|
CLI="$(getopt -o h --long test-run:,test-pkg:,pause,micro-osd:,help -n "$0" -- "$@")"
|
2019-11-07 19:10:37 +00:00
|
|
|
eval set -- "${CLI}"
|
|
|
|
while true ; do
|
|
|
|
case "$1" in
|
2019-12-20 15:59:57 +00:00
|
|
|
--test-pkg)
|
|
|
|
TEST_PKG="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
2019-11-07 19:10:37 +00:00
|
|
|
--test-run)
|
|
|
|
TEST_RUN="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--pause)
|
|
|
|
PAUSE=yes
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--micro-osd)
|
|
|
|
MICRO_OSD_PATH="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-h|--help)
|
|
|
|
echo "Options:"
|
|
|
|
echo " --test-run=VALUE Run selected test or ALL, NONE"
|
|
|
|
echo " ALL is the default"
|
2019-12-20 15:59:57 +00:00
|
|
|
echo " --test-pkg=PKG Run only tests from PKG"
|
2019-11-07 19:10:37 +00:00
|
|
|
echo " --pause Sleep forever after tests execute"
|
|
|
|
echo " --micro-osd Specify path to micro-osd script"
|
|
|
|
echo " -h|--help Display help text"
|
|
|
|
echo ""
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unknown option" >&2
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p /tmp/ceph
|
|
|
|
"${MICRO_OSD_PATH}" /tmp/ceph
|
2018-07-07 17:34:56 +00:00
|
|
|
export CEPH_CONF=/tmp/ceph/ceph.conf
|
|
|
|
|
2018-08-05 17:46:55 +00:00
|
|
|
export PATH=/usr/lib/go-1.10/bin:$PATH
|
|
|
|
|
2019-11-07 19:10:37 +00:00
|
|
|
if [[ ${TEST_RUN} == NONE ]]; then
|
|
|
|
echo "skipping test execution"
|
|
|
|
else
|
|
|
|
go get -t -v ./...
|
|
|
|
diff -u <(echo -n) <(gofmt -d -s .)
|
|
|
|
#go vet ./...
|
|
|
|
#go list ./...
|
2019-12-20 15:59:57 +00:00
|
|
|
echo "mode: count" > "cover.out"
|
2019-11-07 19:10:37 +00:00
|
|
|
P=github.com/ceph/go-ceph
|
2019-12-20 15:59:57 +00:00
|
|
|
pkgs=(\
|
|
|
|
"cephfs" \
|
|
|
|
"errutil" \
|
|
|
|
"rados" \
|
|
|
|
"rbd" \
|
|
|
|
)
|
|
|
|
for pkg in "${pkgs[@]}"; do
|
|
|
|
if [[ "$TEST_PKG" && "$TEST_PKG" != "$pkg" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
testargs=(\
|
|
|
|
"-covermode=count" \
|
|
|
|
"-coverprofile=$pkg.cover.out" \
|
|
|
|
"-coverpkg=$P/$pkg")
|
|
|
|
# disable caching of tests results
|
|
|
|
testargs+=("-count=1")
|
|
|
|
if [[ ${TEST_RUN} != ALL ]]; then
|
|
|
|
testargs+=("-run" "${TEST_RUN}")
|
|
|
|
fi
|
2019-11-07 19:10:37 +00:00
|
|
|
|
2019-12-20 15:59:57 +00:00
|
|
|
go test -v "${testargs[@]}" "./$pkg"
|
|
|
|
grep -v "^mode: count" "$pkg.cover.out" >> "cover.out"
|
|
|
|
done
|
2019-11-07 19:10:37 +00:00
|
|
|
mkdir -p /results/coverage
|
|
|
|
go tool cover -html=cover.out -o /results/coverage/go-ceph.html
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${PAUSE} = yes ]]; then
|
|
|
|
sleep infinity
|
|
|
|
fi
|