Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 2833bc072f
Fetching contributors…

Cannot retrieve contributors at this time

executable file 76 lines (58 sloc) 1.817 kB
#!/bin/bash
# All tests must pass!
set -o errexit
if [[ ! -f "/lib/sdc/.sdc-test-no-production-data" ]]; then
cat <<EOF
To run this test you must create the file:
/lib/sdc/.sdc-test-no-production-data
after ensuring you have no production data on this machine.
EOF
exit 2
fi
start_time=$(date +%s)
if [[ $(uname -s) != 'SunOS' ]]; then
echo "FATAL: this can only run on SmartOS"
exit 1
fi
if [[ $(zonename) != 'global' ]]; then
echo "FATAL: this can only run in the GZ"
exit 1
fi
if [[ $(id -u) != 0 ]]; then
echo "FATAL: this can only run as root"
exit 1
fi
if [[ -z "$1" ]]; then
echo "FATAL: no test file specified"
exit 1
fi
export TAP=1
NODE_PATH="/usr/vm/test/node-tap/node_modules:${NODE_PATH}" \
/usr/node/bin/node $1 | tee -a /tmp/test.output.$$
end_time=$(date +%s)
elapsed=$((${end_time} - ${start_time}))
tests=$(grep "^# tests [0-9]" /tmp/test.output.$$ | cut -d ' ' -f3 | xargs | tr ' ' '+' | bc)
passed=$(grep "^# pass [0-9]" /tmp/test.output.$$ | tr -s ' ' | cut -d ' ' -f3 | xargs | tr ' ' '+' | bc)
skipped=$(grep "^# skip [0-9]" /tmp/test.output.$$ | tr -s ' ' | cut -d ' ' -f3 | xargs | tr ' ' '+' | bc)
[[ -z ${tests} ]] && tests=0
[[ -z ${passed} ]] && passed=0
[[ -z ${skipped} ]] && skipped=0
fail=$((${tests} - ${passed} - ${skipped}))
if [[ -t 0 ]]; then
# We're on a terminal so output the summary
echo "#"
echo "# $1 TEST COMPLETE IN ${elapsed} SECONDS, SUMMARY:"
echo "#"
echo -e "# \033[32mPASS: ${passed} / ${tests}\033[39m"
if [[ ${skipped} -gt 0 ]]; then
echo -e "# \033[31mSKIP: ${skipped} / ${tests}\033[39m"
fi
if [[ ${fail} -gt 0 ]]; then
echo -e "# \033[31mFAIL: ${fail} / ${tests}\033[39m"
fi
echo "#"
fi
if [[ ${fail} -gt 0 ]]; then
exit 1
fi
exit 0
Jump to Line
Something went wrong with that request. Please try again.