Skip to contentSkip to conversation

runtime/systemd: Fix for boot time string parse error

PATCH In review Benjamin Esquivel 2 participants 4 messages Feb 1, 2016 – Feb 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 runtime/systemd: Fix for boot time string parse error

boot time string can change its format of the output of the amount of time it took to boot. It is required to handle graceful fail of the parsing errors that it provokes

[YOCTO #8889]

---
 meta/lib/oeqa/runtime/systemd.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
meta/lib/oeqa/runtime/systemd.py +12 -10
index 03c56ef..2b2f10d 100644
@@ -145,8 +145,7 @@ class SystemdJournalTests(SystemdTest):
         except AssertionError:
             self.fail("Error occurred while calling journalctl")
         if not len(output):
-            self.fail("Error: unable to obtain the startup time from\
-                    systemd journal")
+            self.fail("Error, unable to get startup time from systemd journal")
 
         # check for the regular expression items that match the startup time
         for line in output.split('\n'):
@@ -156,20 +155,23 @@ class SystemdJournalTests(SystemdTest):
         if check_match:
             print "%s" % check_match
         else:
-            self.fail("Error while obtaining the boot time from journalctl")
+            self.skipTest("Error at obtaining the boot time from journalctl")
         boot_time_sec = 0
 
         # get the numeric values from the string and convert them to seconds
         # same data will be placed in list and string for manipulation
         l_boot_time = check_match.split(" ")[-2:]
         s_boot_time = " ".join(l_boot_time)
-        # Obtain the minutes it took to boot
-        if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit():
-            boot_time_min = s_boot_time.split("min")[0]
-            # convert to seconds and accumulate it
-            boot_time_sec += int(boot_time_min) * 60
-        # Obtain the seconds it took to boot and accumulate
-        boot_time_sec += float(l_boot_time[1].split("s")[0])
+        try:
+            # Obtain the minutes it took to boot
+            if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit():
+                boot_time_min = s_boot_time.split("min")[0]
+                # convert to seconds and accumulate it
+                boot_time_sec += int(boot_time_min) * 60
+            # Obtain the seconds it took to boot and accumulate
+            boot_time_sec += float(l_boot_time[1].split("s")[0])
+        except ValueError:
+            self.skipTest("Error when parsing time from boot string")
         #Assert the target boot time against systemd's unit start timeout
         if boot_time_sec > systemd_TimeoutStartSec:
             print "Target boot time %s exceeds systemd's TimeoutStartSec %s"\
Signature · 1 line
2.5.1
#1 lore raw
Quoted 42 lines · Benjamin Esquivel

boot time string can change its format of the output of the amount of time it took to boot. It is required to handle graceful fail of the parsing errors that it provokes

[YOCTO #8889]

---
 meta/lib/oeqa/runtime/systemd.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
meta/lib/oeqa/runtime/systemd.py +2 -8
index 03c56ef..2b2f10d 100644
@@ -145,8 +145,7 @@ class SystemdJournalTests(SystemdTest):
         except AssertionError:
             self.fail("Error occurred while calling journalctl")
         if not len(output):
-            self.fail("Error: unable to obtain the startup time from\
-                    systemd journal")
+            self.fail("Error, unable to get startup time from systemd journal")
 
         # check for the regular expression items that match the startup time
         for line in output.split('\n'):
@@ -156,20 +155,23 @@ class SystemdJournalTests(SystemdTest):
         if check_match:
             print "%s" % check_match
         else:
-            self.fail("Error while obtaining the boot time from journalctl")
+            self.skipTest("Error at obtaining the boot time from journalctl")
         boot_time_sec = 0
 
         # get the numeric values from the string and convert them to seconds
         # same data will be placed in list and string for manipulation
         l_boot_time = check_match.split(" ")[-2:]
         s_boot_time = " ".join(l_boot_time)
-        # Obtain the minutes it took to boot
-        if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit():
-            boot_time_min = s_boot_time.split("min")[0]
-            # convert to seconds and accumulate it
-            boot_time_sec += int(boot_time_min) * 60

meta/lib/oeqa/runtime/systemd.py class SystemdJournalTests(SystemdTest): · line 172

Quoted 10 lines
meta/lib/oeqa/runtime/systemd.py +8 -2
-        # Obtain the seconds it took to boot and accumulate
-        boot_time_sec += float(l_boot_time[1].split("s")[0])
+        try:
+            # Obtain the minutes it took to boot
+            if l_boot_time[0].endswith('min') and l_boot_time[0][0].isdigit():
+                boot_time_min = s_boot_time.split("min")[0]
+                # convert to seconds and accumulate it
+                boot_time_sec += int(boot_time_min) * 60
+            # Obtain the seconds it took to boot and accumulate
+            boot_time_sec += float(l_boot_time[1].split("s")[0])

is float right to use here I wonder,

Quoted 13 lines
meta/lib/oeqa/runtime/systemd.py +2 -1
+        except ValueError:
+            self.skipTest("Error when parsing time from boot string")
         #Assert the target boot time against systemd's unit start timeout
         if boot_time_sec > systemd_TimeoutStartSec:
             print "Target boot time %s exceeds systemd's TimeoutStartSec %s"\
--

2.5.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#2 lore raw
Quoted 61 lines · Khem Raj
Quoted 59 lines · Benjamin Esquivel

boot time string can change its format of the output of the amount of time
it took to boot. It is required to handle graceful fail of the parsing
errors that it provokes

[YOCTO #8889]

Quoted 1 line
---
 meta/lib/oeqa/runtime/systemd.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
meta/lib/oeqa/runtime/systemd.py +1 -2
index 03c56ef..2b2f10d 100644
@@ -145,8 +145,7 @@ class SystemdJournalTests(SystemdTest):
         except AssertionError:
             self.fail("Error occurred while calling journalctl")
         if not len(output):
-            self.fail("Error: unable to obtain the startup time
 from\
-                    systemd journal")
+            self.fail("Error, unable to get startup time from
 systemd journal")
 
         # check for the regular expression items that match the
startup time
         for line in output.split('\n'):
meta/lib/oeqa/runtime/systemd.py +1 -1
@@ -156,20 +155,23 @@ class SystemdJournalTests(SystemdTest):
         if check_match:
             print "%s" % check_match
         else:
-            self.fail("Error while obtaining the boot time from
 journalctl")
+            self.skipTest("Error at obtaining the boot time from
 journalctl")
         boot_time_sec = 0
 
         # get the numeric values from the string and convert them

to seconds

         # same data will be placed in list and string for
manipulation
         l_boot_time = check_match.split(" ")[-2:]
         s_boot_time = " ".join(l_boot_time)
meta/lib/oeqa/runtime/systemd.py +0 -2
-        # Obtain the minutes it took to boot
-        if l_boot_time[0].endswith('min') and

l_boot_time[0][0].isdigit():

meta/lib/oeqa/runtime/systemd.py +3 -5
-            boot_time_min = s_boot_time.split("min")[0]
-            # convert to seconds and accumulate it
-            boot_time_sec += int(boot_time_min) * 60
-        # Obtain the seconds it took to boot and accumulate
-        boot_time_sec += float(l_boot_time[1].split("s")[0])
+        try:
+            # Obtain the minutes it took to boot
+            if l_boot_time[0].endswith('min') and
Quoted 8 lines

meta/lib/oeqa/runtime/systemd.py class SystemdJournalTests(SystemdTest): · line 172

Quoted 6 lines

l_boot_time[0][0].isdigit():

meta/lib/oeqa/runtime/systemd.py +5 -0
+                boot_time_min = s_boot_time.split("min")[0]
+                # convert to seconds and accumulate it
+                boot_time_sec += int(boot_time_min) * 60
+            # Obtain the seconds it took to boot and accumulate
+            boot_time_sec += float(l_boot_time[1].split("s")[0])

is float right to use here I wonder,

float is what the seconds are expressed in at the journal, like in:

systemd[1]: Startup finished in 1.616s (kernel) + 13.561s (initrd) + 3.195s (userspace) = 26.632s

Quoted 16 lines
Quoted 16 lines
meta/lib/oeqa/runtime/systemd.py +2 -0
+        except ValueError:
+            self.skipTest("Error when parsing time from boot

string")
#Assert the target boot time against systemd's unit start
timeout
if boot_time_sec > systemd_TimeoutStartSec:
print "Target boot time %s exceeds systemd's
TimeoutStartSec %s"\
--
2.5.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#3 lore raw
Quoted 70 lines · Benjamin Esquivel
Quoted 61 lines · Khem Raj
Quoted 59 lines · Benjamin Esquivel

boot time string can change its format of the output of the amount of time
it took to boot. It is required to handle graceful fail of the parsing
errors that it provokes

[YOCTO #8889]

Quoted 1 line
---
 meta/lib/oeqa/runtime/systemd.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
meta/lib/oeqa/runtime/systemd.py +1 -2
index 03c56ef..2b2f10d 100644
@@ -145,8 +145,7 @@ class SystemdJournalTests(SystemdTest):
         except AssertionError:
             self.fail("Error occurred while calling journalctl")
         if not len(output):
-            self.fail("Error: unable to obtain the startup time
 from\
-                    systemd journal")
+            self.fail("Error, unable to get startup time from
 systemd journal")
 
         # check for the regular expression items that match the
startup time
         for line in output.split('\n'):
meta/lib/oeqa/runtime/systemd.py +1 -1
@@ -156,20 +155,23 @@ class SystemdJournalTests(SystemdTest):
         if check_match:
             print "%s" % check_match
         else:
-            self.fail("Error while obtaining the boot time from
 journalctl")
+            self.skipTest("Error at obtaining the boot time from
 journalctl")
         boot_time_sec = 0
 
         # get the numeric values from the string and convert them

to seconds

         # same data will be placed in list and string for
manipulation
         l_boot_time = check_match.split(" ")[-2:]
         s_boot_time = " ".join(l_boot_time)
meta/lib/oeqa/runtime/systemd.py +0 -2
-        # Obtain the minutes it took to boot
-        if l_boot_time[0].endswith('min') and

l_boot_time[0][0].isdigit():

meta/lib/oeqa/runtime/systemd.py +3 -5
-            boot_time_min = s_boot_time.split("min")[0]
-            # convert to seconds and accumulate it
-            boot_time_sec += int(boot_time_min) * 60
-        # Obtain the seconds it took to boot and accumulate
-        boot_time_sec += float(l_boot_time[1].split("s")[0])
+        try:
+            # Obtain the minutes it took to boot
+            if l_boot_time[0].endswith('min') and
Quoted 8 lines

meta/lib/oeqa/runtime/systemd.py class SystemdJournalTests(SystemdTest): · line 172

Quoted 6 lines

l_boot_time[0][0].isdigit():

meta/lib/oeqa/runtime/systemd.py +5 -0
+                boot_time_min = s_boot_time.split("min")[0]
+                # convert to seconds and accumulate it
+                boot_time_sec += int(boot_time_min) * 60
+            # Obtain the seconds it took to boot and accumulate
+            boot_time_sec += float(l_boot_time[1].split("s")[0])

is float right to use here I wonder,

Quoted 5 lines

float is what the seconds are expressed in at the journal, like in:

systemd[1]: Startup finished in 1.616s (kernel) + 13.561s (initrd) + 3.195s (userspace) = 26.632s

so its in 100th thats ok,.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
meta/lib/oeqa/runtime/systemd.py +2 -0
+        except ValueError:
+            self.skipTest("Error when parsing time from boot

string")
#Assert the target boot time against systemd's unit start
timeout
if boot_time_sec > systemd_TimeoutStartSec:
print "Target boot time %s exceeds systemd's
TimeoutStartSec %s"\
--
2.5.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core