34 lines
787 B
Bash
Executable File
34 lines
787 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [ "$#" -lt 1 ] || [ "$#" -gt 4 ]; then
|
|
echo "usage: scripts/tui/smoke-tty.sh <binary-path> [rows] [cols] [log-path]" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! command -v script >/dev/null 2>&1; then
|
|
echo "error: \`script\` command is required for TTY smoke." >&2
|
|
exit 3
|
|
fi
|
|
|
|
binary_path="$1"
|
|
rows="${2:-40}"
|
|
cols="${3:-120}"
|
|
log_path="${4:-/tmp/dbtool-tui-smoke.log}"
|
|
|
|
if [ ! -x "$binary_path" ]; then
|
|
echo "error: binary is not executable: $binary_path" >&2
|
|
exit 4
|
|
fi
|
|
|
|
command_string="$(printf 'stty rows %s cols %s; "%s"' "$rows" "$cols" "$binary_path")"
|
|
|
|
rm -f "$log_path"
|
|
printf 'q' | script -qec "$command_string" "$log_path" >/dev/null
|
|
|
|
echo "TTY smoke passed."
|
|
echo "binary: $binary_path"
|
|
echo "rows: $rows"
|
|
echo "cols: $cols"
|
|
echo "log: $log_path"
|