From 5854aaf680e3c04629a62f36a2ea27dccd82fcae Mon Sep 17 00:00:00 2001
From: Marijan Petricevic <marijan.petricevic94@gmail.com>
Date: Fri, 8 Nov 2019 10:46:37 +0100
Subject: [PATCH] nixos/tests: improve get_unit_info expressiveness on failure

---
 nixos/lib/test-driver/test-driver.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index 93b8eebd2e12..978441dbce8f 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -319,7 +319,11 @@ class Machine:
     def get_unit_info(self, unit, user=None):
         status, lines = self.systemctl('--no-pager show "{}"'.format(unit), user)
         if status != 0:
-            return None
+            raise Exception(
+                'retrieving systemctl info for unit "{}" {} failed with exit code {}'.format(
+                    unit, "" if user is None else 'under user "{}"'.format(user), status
+                )
+            )
 
         line_pattern = re.compile(r"^([^=]+)=(.*)$")