Source: golang-github-go-debos-fakemachine Version: 0.0~git20180126.e307c2f-1 Severity: normal Tags: patch
The tests for this package appear to pass, but if you look more closely, there is very little actual testing going on: autopkgtest [02:05:31]: test command1: /usr/bin/dh_golang_autopkgtest autopkgtest [02:05:31]: test command1: [----------------------- [info] Testing github.com/go-debos/fakemachine... [info] Source code installed by binary package, overriding dh_auto_configure... dh build --buildsystem=golang --with=golang ... debian/rules override_dh_auto_test make[1]: Entering directory '/tmp/autopkgtest-lxc.6okl3mgq/downtmp/autopkgtest_tmp' # Disable auto tests at build time # fakemachine need to be able to use /dev/kvm : make[1]: Leaving directory '/tmp/autopkgtest-lxc.6okl3mgq/downtmp/autopkgtest_tmp' create-stamp debian/debhelper-build-stamp autopkgtest [02:05:33]: test command1: -----------------------] autopkgtest [02:05:33]: test command1: - - - - - - - - - - results - - - - - - - - - - command1 PASS I suspect autopkgtest-pkg-go is not appropriate for this particular package. I attach a simple smoke-test which tries to detect whether fakemachine should be expected to be able to operate or not. This would hopefully have detected the missing runtime dependencies. Regards, smcv
>From 17bec09d74237f3961a423e416de72c6be30afd6 Mon Sep 17 00:00:00 2001 From: Simon McVittie <s...@collabora.com> Date: Mon, 14 May 2018 18:21:50 +0100 Subject: [PATCH 1/3] Add an autopkgtest smoke test Unlike the (disabled) build-time tests, this checks for access to /dev/kvm and is skipped if that isn't possible. Signed-off-by: Simon McVittie <s...@collabora.com> --- debian/control | 1 - debian/tests/control | 3 ++ debian/tests/hello | 72 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 debian/tests/control create mode 100755 debian/tests/hello diff --git a/debian/control b/debian/control index 9d746bf..bd58272 100644 --- a/debian/control +++ b/debian/control @@ -18,7 +18,6 @@ Homepage: https://github.com/go-debos/fakemachine Vcs-Browser: https://salsa.debian.org/go-team/packages/golang-github-go-debos-fakemachine Vcs-Git: https://salsa.debian.org/go-team/packages/golang-github-go-debos-fakemachine.git XS-Go-Import-Path: github.com/go-debos/fakemachine -Testsuite: autopkgtest-pkg-go Package: fakemachine Architecture: any diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..a7d8062 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: hello +Depends: fakemachine, hello +Restrictions: allow-stderr needs-recommends diff --git a/debian/tests/hello b/debian/tests/hello new file mode 100755 index 0000000..d99aef6 --- /dev/null +++ b/debian/tests/hello @@ -0,0 +1,72 @@ +#!/bin/bash + +# Copyright © 2018 Collabora Ltd. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +set -u +set -o pipefail + +cd "${AUTOPKGTEST_TMP:-"${ADTTMP}"}" + +if ! [ -w /dev/kvm ]; then + echo "1..0 # SKIP no write access to /dev/kvm" + exit 0 +fi + +if ! grep -E '^flags[[:space:]]*:.*[[:space:]](vmx|svm)( |$)' /proc/cpuinfo >&2; then + echo "1..0 # SKIP could not find AMD-V (svm) or Intel VT-x (vmx) in /proc/cpuinfo" + exit 0 +fi + +echo "1..3" +fail=0 + +# Filter out Esc and Tab for a cleaner log and easier grepping +if timeout -k 5s -s ABRT 60s \ + fakemachine env LC_ALL=C hello </dev/null 2>&1 | \ + stdbuf -oL tr -d '\033\015' | \ + tee fakemachine.log >&2; then + e=0 +else + e=$? +fi + +if [ "$e" -eq 0 ]; then + echo "ok 1 - fakemachine hello exited successfully" +elif [ "$e" -eq 124 ]; then + echo "not ok 1 - fakemachine hello timed out" + fail=1 +else + echo "not ok 1 - fakemachine hello exited $e" + fail=1 +fi + +if grep -E '^Running env LC_ALL=C hello$' fakemachine.log >&2; then + echo "ok 2 - fakemachine tried to run hello" +else + echo "not ok 2 - fakemachine didn't get as far as running hello" + fail=1 +fi + +if grep -E '^Hello, world!$' fakemachine.log >&2; then + echo "ok 3 - received a friendly greeting" +else + echo "not ok 3 - did not receive a friendly greeting" + fail=1 +fi + +exit "$fail" -- 2.17.0