Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 5a1cc4e

Browse files
hadusamiizukak
authored andcommitted
fix to wait ssh daemon enabled (#327)
1 parent 07bf571 commit 5a1cc4e

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

dlk/tests/tstutils.py

+25-10
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,39 @@ def run_and_check(command, cwd, file_stdout=None, file_stderr=None, testcase=Non
101101
def wait_for_device(host: str, tries: int, seconds: int, log_path: str, testcase=None) -> bool:
102102

103103
board_found = False
104+
board_ssh_enabled = False
104105
for i in range(tries):
105106
try:
106107
print(f'Waiting for device {host}: try {i+1} of {tries}')
107-
time.sleep(seconds)
108-
109-
run_and_check(
110-
["ping", "-c5", host],
111-
log_path, join(log_path, "ping.out"), join(log_path, "ping.err"), testcase)
112108

113-
board_found = True
114-
break
109+
if not board_found:
110+
run_and_check(
111+
["ping", "-c5", host],
112+
log_path, join(log_path, "ping.out"), join(log_path, "ping.err"), testcase)
113+
114+
board_found = True
115+
else:
116+
run_and_check(
117+
[ "ssh",
118+
"-o",
119+
"StrictHostKeyChecking no",
120+
f"root@{host}",
121+
f"uname -a"
122+
],
123+
log_path,
124+
join(log_path, "ssh_uname-a.out"),
125+
join(log_path, "ssh_uname-a.err"),
126+
testcase
127+
)
128+
129+
board_ssh_enabled = True
130+
break
115131
except Exception as e:
116132
print(str(e))
133+
time.sleep(seconds)
117134
continue
118135

119-
return board_found
136+
return board_ssh_enabled
120137

121138
def setup_de10nano(hw_path: str, output_path: str, testcase=None):
122139

@@ -128,8 +145,6 @@ def setup_de10nano(hw_path: str, output_path: str, testcase=None):
128145
try:
129146
run_and_check(
130147
[ "ssh",
131-
"-o",
132-
"StrictHostKeyChecking no",
133148
f"root@{host}",
134149
f"mkdir -p ~/automated_testing; mkdir -p ~/boot; if grep -qs '/root/boot' /proc/mounts ;" \
135150
+ "then echo 0 ; else mount /dev/mmcblk0p1 /root/boot ; fi"

0 commit comments

Comments
 (0)