]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/runtime/systemd: remove race in settle()
authorRoss Burton <ross.burton@intel.com>
Tue, 4 Feb 2014 12:41:15 +0000 (12:41 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 4 Feb 2014 12:43:03 +0000 (12:43 +0000)
The settle() function had a race where services could still be activating at two
minutes but then when the final log is output, they've activated.

Remove this race and generally clean up the code.

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/runtime/systemd.py

index 6414dd6e0ea222def229428e6ba3f44f141588c4..6de84f891bbb34cba5d34001b9f24af34e73a001 100644 (file)
@@ -37,25 +37,19 @@ class SystemdBasicTests(SystemdTest):
         Block until systemd has finished activating any units being activated,
         or until two minutes has elapsed.
 
-        Returns a tuple, either (True, None) if all units have finished
-        acitvating, or (False, message string) if there are still units
+        Returns a tuple, either (True, '') if all units have finished
+        activating, or (False, message string) if there are still units
         activating (generally, failing units that restart).
         """
         import time
-        settled = False
         endtime = time.time() + (60 * 2)
-        while time.time() < endtime:
-            status = self.target.run('systemctl --state=activating | grep -q "0 loaded units listed"')
-            if status == 0:
-                settled = True
-                break
-            time.sleep(10)
-
-        if settled:
-            return (True, None)
-        else:
+        while True:
             status, output = self.target.run('systemctl --state=activating')
-        return (settled, output)
+            if "0 loaded units listed" in output:
+                return (True, '')
+            if time.time() >= endtime:
+                return (False, output)
+            time.sleep(10)
 
     @skipUnlessPassed('test_systemd_basic')
     def test_systemd_failed(self):