75 lines
2 KiB
Shell
75 lines
2 KiB
Shell
#!/usr/bin/env bash
|
|
set -u
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
. "$SCRIPT_DIR/common.sh"
|
|
|
|
ALLOW_RESET=0
|
|
ALLOW_START=0
|
|
STOP_AFTER_START=0
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
case "$1" in
|
|
--serial)
|
|
shift
|
|
[ "$#" -gt 0 ] || die "--serial requires a value"
|
|
ADB_SERIAL="$1"
|
|
;;
|
|
--out-root)
|
|
shift
|
|
[ "$#" -gt 0 ] || die "--out-root requires a value"
|
|
OUT_ROOT="$1"
|
|
;;
|
|
--allow-reset)
|
|
ALLOW_RESET=1
|
|
;;
|
|
--allow-start)
|
|
ALLOW_START=1
|
|
;;
|
|
--stop-after-start)
|
|
STOP_AFTER_START=1
|
|
;;
|
|
-h|--help)
|
|
sed -n '1,160p' "$SCRIPT_DIR/README.md"
|
|
exit 0
|
|
;;
|
|
*)
|
|
die "unknown argument: $1"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
ensure_single_device
|
|
ensure_root_shell
|
|
ensure_runtime_cli
|
|
RUN_DIR="$(make_run_dir)"
|
|
FAILED=0
|
|
|
|
note "running safe RKNnoVPN smoke checks into $RUN_DIR"
|
|
|
|
capture_su runtime_version "'$RUNTIME_CLI_PATH' version" || FAILED=1
|
|
capture_su runtime_status_before "'$RUNTIME_CLI_PATH' status" || FAILED=1
|
|
capture_su runtime_logs_before "'$RUNTIME_CLI_PATH' logs --lines 160" || FAILED=1
|
|
|
|
if [ "$ALLOW_RESET" = "1" ]; then
|
|
note "running explicit reset smoke step"
|
|
capture_su network_reset "'$RUNTIME_CLI_PATH' reset" || FAILED=1
|
|
capture_su runtime_status_after_reset "'$RUNTIME_CLI_PATH' status" || FAILED=1
|
|
fi
|
|
|
|
if [ "$ALLOW_START" = "1" ]; then
|
|
note "running explicit start smoke step"
|
|
capture_su start "'$RUNTIME_CLI_PATH' start" || FAILED=1
|
|
capture_su runtime_status_after_start "'$RUNTIME_CLI_PATH' status" || FAILED=1
|
|
if [ "$STOP_AFTER_START" = "1" ]; then
|
|
note "stopping after explicit start smoke step"
|
|
capture_su stop_after_start "'$RUNTIME_CLI_PATH' stop" || FAILED=1
|
|
capture_su runtime_status_after_stop "'$RUNTIME_CLI_PATH' status" || FAILED=1
|
|
fi
|
|
fi
|
|
|
|
note "done: $RUN_DIR"
|
|
if [ "$FAILED" != "0" ]; then
|
|
die "one or more smoke checks failed; inspect $RUN_DIR"
|
|
fi
|