mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-27 12:30:34 -09:00
support/testing: add runtime tests for python-scp
Add a basic test involving a local SSH connection (based on dropbear server). The test validates that we are able, through python-scp, to fetch the /etc/hostname file. The test needs some basic key initialization to allow connecting to the dropbear server, hence the custom run_sample_scripts method. Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com> [Julien: - remove unneeded os import in test script - execute setup commands with assertRunOk() - create /root/.ssh with 0700 mode - run sample scripts using super() - check in the sample file that copied files are the same ] Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
committed by
Julien Olivain
parent
3963c3c06e
commit
7470587cfa
15
support/testing/tests/package/sample_python_scp.py
Normal file
15
support/testing/tests/package/sample_python_scp.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import filecmp
|
||||
|
||||
from paramiko import SSHClient
|
||||
from paramiko.client import AutoAddPolicy
|
||||
|
||||
from scp import SCPClient
|
||||
|
||||
ssh_client = SSHClient()
|
||||
ssh_client.load_system_host_keys()
|
||||
ssh_client.set_missing_host_key_policy(AutoAddPolicy)
|
||||
ssh_client.connect('127.0.0.1', username='root')
|
||||
scp_client = SCPClient(ssh_client.get_transport())
|
||||
scp_client.get("/etc/hostname", "/tmp/hostname")
|
||||
|
||||
assert filecmp("/etc/hostname", "/tmp/hostname")
|
||||
Reference in New Issue
Block a user