| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # fs_suite.py against the rooted SFTP server of third_party/sshocker, through |
| 4 | # real sshfs, as the Lima hostagent serves agent-vm's shares. |
| 5 | # |
| 6 | # tests/sftp/run [case-substring...] the server agent-vm ships |
| 7 | # tests/sftp/run --openssh [case-substring...] OpenSSH's sftp-server, the control |
| 8 | # |
| 9 | # Needs Go, sshfs, fusermount (user_allow_other in /etc/fuse.conf), python3, |
| 10 | # git, tar and patch. WORK (default /tmp/sftp-work) must be on this machine's |
| 11 | # own disk, never on a share served by the code under test. |
| 12 | |
| 13 | set -euo pipefail |
| 14 | |
| 15 | HERE="$(CDPATH= cd -P -- "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" |
| 16 | ROOT="$(CDPATH= cd -P -- "$HERE/../.." >/dev/null && pwd)" |
| 17 | WORK="${WORK:-/tmp/sftp-work}" |
| 18 | |
| 19 | if [ "${1:-}" = --openssh ]; then |
| 20 | shift |
| 21 | harness="$HERE/openssh_harness.sh" |
| 22 | run="$WORK/run-openssh" |
| 23 | else |
| 24 | # A copy of third_party/sshocker with the harness added, built against |
| 25 | # third_party/sftp as agent-vm's module builds it. |
| 26 | src="$WORK/src" |
| 27 | rm -rf "$src" |
| 28 | mkdir -p "$WORK" |
| 29 | cp -R "$ROOT/third_party/sshocker" "$src" |
| 30 | cp "$HERE/testdata/harness/harness_export.go" "$src/pkg/reversesshfs/" |
| 31 | mkdir -p "$src/cmd/harness" |
| 32 | cp "$HERE/testdata/harness/main.go" "$src/cmd/harness/" |
| 33 | ( cd "$src" \ |
| 34 | && go mod edit -replace "github.com/pkg/sftp=$ROOT/third_party/sftp" \ |
| 35 | && GOFLAGS=-mod=mod go build -o "$WORK/harness" ./cmd/harness ) |
| 36 | harness="$WORK/harness" |
| 37 | run="$WORK/run" |
| 38 | fi |
| 39 | exec python3 "$HERE/fs_suite.py" "$harness" "$run" "$@" |