Source: mosh
Version: 1.4.0-1
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu lunar ubuntu-patch

Hi,

In Ubuntu, we added a couple of dep8 tests to the mosh package. These
should help detect any regressions caused by changes in dependencies
before they land. I think these should apply and be equally useful for
Debian. Please consider applying the attached patch. Thanks!

diff --git a/debian/changelog b/debian/changelog
index af36f16..2f1ba64 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+mosh (1.4.0-1ubuntu1) lunar; urgency=medium
+
+  [ Sergio Durigan Junior ]
+  * d/t/upstream-tests: New dep8 test which runs the upstream test
+    suite against a system mosh.
+
+  [ Robie Basak ]
+  * d/t/smoke: smoke test for mosh using pexpect.
+
+ -- Robie Basak <robie.ba...@ubuntu.com>  Wed, 22 Mar 2023 13:36:00 +0000
+
 mosh (1.4.0-1build1) lunar; urgency=medium
 
   * Rebuild against new libprotobuf32.
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..7623e07
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,7 @@
+Tests: upstream-tests
+Depends: @, @builddeps@
+Restrictions: allow-stderr
+
+Tests: smoke
+Depends: mosh, openssh-server, python3-pexpect
+Restrictions: allow-stderr, isolation-container, needs-root, superficial, 
breaks-testbed
diff --git a/debian/tests/smoke b/debian/tests/smoke
new file mode 100755
index 0000000..7ff856d
--- /dev/null
+++ b/debian/tests/smoke
@@ -0,0 +1,28 @@
+#!/bin/sh
+set -ex
+
+# HOME may not be set in an autopkgtest environment, but we want to be on the
+# same page as ssh on where ~/.ssh is. See LP: #2012514.
+if [ "$HOME" = "" ]; then
+       export HOME=$(getent passwd `whoami`|cut -d: -f6)
+fi
+
+echo 'mosh motd test' > /etc/motd
+mkdir -pm700 "$HOME"/.ssh
+if [ ! -f "$HOME"/.ssh/id_rsa ]; then
+       ssh-keygen -N '' -C mosh-smoke -f "$HOME"/.ssh/id_rsa
+fi
+if [ ! -f "$HOME"/.ssh/authorized_keys ] || ! grep -q mosh-smoke\$ 
"$HOME"/.ssh/authorized_keys; then
+       cat "$HOME"/.ssh/id_rsa.pub >> "$HOME"/.ssh/authorized_keys
+fi
+python3 <<EOT
+import os
+import pexpect
+# Set TERM=dumb so the bash prompt doesn't embed escape sequences to make it
+# easier to match
+env = os.environ.copy()
+env["TERM"] = "dumb"
+child = pexpect.spawn('mosh --ssh="ssh -o StrictHostKeyChecking=no" 
localhost', env=env)
+child.expect('mosh motd test')
+child.expect(r'(\w+)@([-\w]+):~#')
+EOT
diff --git a/debian/tests/upstream-tests b/debian/tests/upstream-tests
new file mode 100755
index 0000000..63be333
--- /dev/null
+++ b/debian/tests/upstream-tests
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+set -e
+
+# Build mosh.  We need to do this because some of the test programs
+# expect to link against libraries built here.
+#
+# We could use "Restrictions: build-needed" on d/t/control, but that'd
+# also invoke dh_auto_test which only wastes our time.
+
+echo "I: Copying source tree so that we can modify it"
+mkdir "$AUTOPKGTEST_TMP/build"
+shopt -s nullglob
+cp -a * "$AUTOPKGTEST_TMP/build"
+cd "$AUTOPKGTEST_TMP/build"
+
+echo "I: Building mosh"
+./debian/rules override_dh_auto_configure
+make -j$(nproc)
+
+# Remove all possible local mosh binaries that could confuse the test
+# suite.
+echo "I: Removing all locally-built mosh binaries"
+rm -fv \
+   scripts/mosh \
+   src/frontend/mosh-client \
+   src/frontend/mosh-server \
+   src/tests/mosh-client \
+   src/tests/mosh-server
+
+# Adjust mosh's test scripts to use mosh-{client,server} from the
+# system.
+echo "I: Adjusting mosh's test suite to use the system-installed mosh binaries"
+find src/tests/ -type f -print0 | xargs -0 sed -i \
+    -e 's@ --client=.\?[^ ]*\/mosh-client.\? @ --client=/usr/bin/mosh-client 
@' \
+    -e 's@ --server=.\?[^ ]*\/mosh-server.\? @ --server=/usr/bin/mosh-server 
@' \
+    -e 's@\.\.\/\.\.\/scripts\/mosh@/usr/bin/mosh@' \
+    -e 's@export MOSH_CLIENT=.*@export MOSH_CLIENT="/usr/bin/mosh-client"@' \
+    -e 's@export MOSH_SERVER=.*@export MOSH_SERVER="/usr/bin/mosh-server"@'
+
+echo "I: Running tests"
+if ! make check; then
+    echo "E: Testsuite failed to run:"
+    if [ -f src/tests/test-suite.log ]; then
+       echo
+       cat src/tests/test-suite.log
+    fi
+    exit 1
+fi
+
+exit 0

Reply via email to