Skip to content

Commit 4015426

Browse files
committed
shelldriver: Silence kernel earlier
Moves up the call to silence the kernel to the console expect loop. This ensures that the kernel has been silenced before the prompt is checked, as dmesg output can interrupt it and cause failures. Signed-off-by: Joshua Watt <[email protected]>
1 parent f4a8962 commit 4015426

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

labgrid/driver/shelldriver.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ def on_activate(self):
7979

8080
self._put_ssh_key(keyfile_path)
8181

82-
# Turn off Kernel Messages to the console
83-
self._run("dmesg -n 1")
84-
8582
def on_deactivate(self):
8683
self._status = 0
8784

@@ -133,6 +130,7 @@ def _await_login(self):
133130
# occours, we can't lose any data this way.
134131
last_before = b''
135132
did_login = False
133+
did_silence_kernel = False
136134

137135
while True:
138136
index, before, _, _ = self.console.expect(
@@ -141,10 +139,15 @@ def _await_login(self):
141139
)
142140

143141
if index == 0:
144-
# we got a promt. no need for any further action to activate
145-
# this driver.
146-
self.status = 1
147-
break
142+
if did_login and not did_silence_kernel:
143+
# Silence the kernel and wait for another prompt
144+
self.console.sendline("dmesg -n 1")
145+
did_silence_kernel = True
146+
else:
147+
# we got a prompt. no need for any further action to
148+
# activate this driver.
149+
self.status = 1
150+
break
148151

149152
elif index == 1:
150153
# we need to login

0 commit comments

Comments
 (0)