Package: autopkgtest
Version: 4.1
Severity: normal
Tags: patch

It isn't completely clear what a test author should do if they want to
reboot the machine: isolation-machine doesn't necessarily seem to
guarantee the ability to reboot, although perhaps in practice it always
does. In the virtualization abstraction, 'reboot' is a separate capability.

The attached patch is one way to resolve this, by adding a 'needs-reboot'
Restriction which maps directly to the 'reboot' capability.

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (500, 'testing'), 
(500, 'stable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages autopkgtest depends on:
ii  apt-utils       1.3.1
ii  libdpkg-perl    1.18.10
ii  procps          2:3.3.12-2
ii  python3         3.5.1-4
ii  python3-debian  0.1.29

Versions of packages autopkgtest recommends:
ii  autodep8  0.8

Versions of packages autopkgtest suggests:
pn  lxc          <none>
pn  lxd-client   <none>
ii  qemu-system  1:2.7+dfsg-1
ii  qemu-utils   1:2.7+dfsg-1
ii  schroot      1.6.10-2+b1

-- no debconf information
>From 85de34c9bc44a38104a32a10b7aa615fbe147664 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvit...@collabora.co.uk>
Date: Thu, 27 Oct 2016 15:06:01 +0100
Subject: [PATCH 3/5] Add 'needs-reboot' restriction

This allows tests to be explicit about needing to reboot the machine,
rather than assuming that 'isolation-machine' is enough. It is plumbed
into the existing 'reboot' capability, which is distinct from
'isolation-machine'.

Signed-off-by: Simon McVittie <simon.mcvit...@collabora.co.uk>
---
 doc/README.package-tests.rst | 4 ++++
 lib/testdesc.py              | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/README.package-tests.rst b/doc/README.package-tests.rst
index 3eb1230..4775a07 100644
--- a/doc/README.package-tests.rst
+++ b/doc/README.package-tests.rst
@@ -202,6 +202,10 @@ isolation-machine
     test in a virtualization server which does not provide this it will
     be skipped.
 
+needs-reboot
+    The test wants to reboot the machine using
+    ``/tmp/autopkgtest-reboot`` (see below).
+
 needs-recommends
     Enable installation of recommended packages in apt for the test
     dependencies. This does not affect build dependencies.
diff --git a/lib/testdesc.py b/lib/testdesc.py
index a8eca66..914e00c 100644
--- a/lib/testdesc.py
+++ b/lib/testdesc.py
@@ -42,7 +42,7 @@ import adtlog
 
 known_restrictions = ['rw-build-tree', 'breaks-testbed', 'needs-root',
                       'build-needed', 'allow-stderr', 'isolation-container',
-                      'isolation-machine', 'needs-recommends']
+                      'isolation-machine', 'needs-recommends', 'needs-reboot']
 
 
 class Unsupported(Exception):
@@ -161,6 +161,12 @@ class Test:
                               'Test needs root on testbed which is not '
                               'available')
 
+        if 'needs-reboot' in self.restrictions and \
+           'reboot' not in caps:
+            raise Unsupported(self.name,
+                              'Test needs to reboot testbed but testbed does '
+                              'not provide reboot capability')
+
 #
 # Parsing for Debian source packages
 #
-- 
2.10.1

Reply via email to