From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2 7/9] testsuite: Support running custom scripts in VM
Date: Wed, 8 Feb 2023 16:45:09 +0100 [thread overview]
Message-ID: <20230208154511.1884-8-ubely@ilbers.de> (raw)
In-Reply-To: <20230208154511.1884-1-ubely@ilbers.de>
By specifying `script='<file.sh>'` it's now possible to run VM and
execute local script over SSH connection.
Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
testsuite/cibuilder.py | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index 9b64af90..5eebd5aa 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -228,6 +228,15 @@ class CIBuilder(Test):
return rc
+ def run_script(self, script, cmd_prefix):
+ script_dir = self.params.get('test_script_dir',
+ default=os.path.abspath(os.path.dirname(__file__))) + '/'
+ script_path = script_dir + script
+ rc = subprocess.call('cat ' + script_path + ' | ' + str(cmd_prefix), shell=True,
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ return rc
+
+
def wait_connection(self, proc, cmd_prefix, timeout):
self.log.debug('Waiting for SSH server ready...')
@@ -252,12 +261,13 @@ class CIBuilder(Test):
def vm_start(self, arch='amd64', distro='buster',
enforce_pcbios=False, skip_modulecheck=False,
- image='isar-image-base', cmd=None):
+ image='isar-image-base', cmd=None, script=None):
time_to_wait = self.params.get('time_to_wait', default=60)
self.log.info('===================================================')
self.log.info('Running Isar VM boot test for (' + distro + '-' + arch + ')')
self.log.info('Remote command is ' + str(cmd))
+ self.log.info('Remote script is ' + str(script))
self.log.info('Isar build folder is: ' + self.build_dir)
self.log.info('===================================================')
@@ -309,7 +319,7 @@ class CIBuilder(Test):
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True)
- if cmd is not None:
+ if cmd is not None or script is not None:
rc = None
try:
port = None
@@ -330,8 +340,13 @@ class CIBuilder(Test):
rc = self.wait_connection(p1, cmd_prefix, timeout)
if rc == 0:
- rc = self.exec_cmd(cmd, cmd_prefix)
- self.log.debug('`' + cmd + '` returned ' + str(rc))
+ if cmd is not None:
+ rc = self.exec_cmd(cmd, cmd_prefix)
+ self.log.debug('`' + cmd + '` returned ' + str(rc))
+ elif script is not None:
+ rc = self.run_script(script, cmd_prefix)
+ self.log.debug('`' + script + '` returned ' + str(rc))
+
finally:
if p1.poll() is None:
self.log.debug('Killing qemu...')
--
2.20.1
next prev parent reply other threads:[~2023-02-08 15:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 15:45 [PATCH v2 0/9] Support running custom commands " Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 1/9] testsuite: Fix failing hostname service in qemu guest Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 2/9] testsuite: Add SSH key pair for using in CI Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 3/9] meta-isar: Add a recipe that configures ci user Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 4/9] meta-isar: Use a separate image recipe in CI Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 5/9] testsuite: Allow custom image names in start_vm.py Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 6/9] testsuite: Support running custom commands in VM Uladzimir Bely
2023-02-08 15:45 ` Uladzimir Bely [this message]
2023-02-08 15:45 ` [PATCH v2 8/9] testsuite: Run custom commands and scripts on some qemu targets Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 9/9] testsuite: Update testsuite qemu-related documentation Uladzimir Bely
2023-02-21 10:56 ` [PATCH v2 0/9] Support running custom commands in VM Uladzimir Bely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230208154511.1884-8-ubely@ilbers.de \
--to=ubely@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox