public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH 1/8] cibuilder.py: Support custom arguments passing to CI scripts
Date: Fri, 18 Aug 2023 09:06:59 +0200	[thread overview]
Message-ID: <20230818070706.27913-2-ubely@ilbers.de> (raw)
In-Reply-To: <20230818070706.27913-1-ubely@ilbers.de>

With this change, it becomes possible to add custom arguments
to the scripts we want to run remotely on the target.

This means that remote script execution process is now consist
of two parts: delivering the script on board and running it
with custom arguments.

An interface of the call doesn't change just allowing to add
space-separated arguments:

```
self.vm_start(script='test_script arg1 arg2 .. argN')
```

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 testsuite/cibuilder.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index a03ff050..80b3aa88 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -246,13 +246,25 @@ class CIBuilder(Test):
     def run_script(self, script, cmd_prefix):
         script_dir = self.params.get('test_script_dir',
                                      default=os.path.abspath(os.path.dirname(__file__))) + '/scripts/'
-        script_path = script_dir + script
+        script_path = script_dir + script.split()[0]
+        script_args = ' '.join(script.split()[1:])
+
+        self.log.debug("script_path: '%s'" % (script_path))
+        self.log.debug("script args: '%s'" % (script_args))
+
         if not os.path.exists(script_path):
             self.log.error('Script not found: ' + script_path)
             return 2
 
-        rc = subprocess.call('cat ' + script_path + ' | ' + str(cmd_prefix), shell=True,
+        # Copy the script to the target
+        rc = subprocess.call('cat %s | %s install -m 755 /dev/stdin ./ci.sh' % (script_path, cmd_prefix), shell=True,
                              stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        time.sleep(1)
+
+        # Run the script remotely with the arguments
+        if rc == 0:
+            rc = subprocess.call('%s ./ci.sh %s' % (cmd_prefix, script_args), shell=True,
+                                 stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         return rc
 
 
-- 
2.20.1


  reply	other threads:[~2023-08-18  7:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  7:06 [PATCH 0/8] Testsuite improvements for SSH-based tests Uladzimir Bely
2023-08-18  7:06 ` Uladzimir Bely [this message]
2023-08-18  7:07 ` [PATCH 2/8] meta-isar: Add more extra space to qemu ext4 images Uladzimir Bely
2023-08-18  7:07 ` [PATCH 3/8] cibuilder.py: Split vm_start function to smaller subfunctions Uladzimir Bely
2023-08-18  7:07 ` [PATCH 4/8] cibuilder.py: Simplify remote_run command Uladzimir Bely
2023-08-18  7:07 ` [PATCH 5/8] cibuilder.py: Reuse the same qemu machine in ssh-based tests Uladzimir Bely
2023-08-18  7:07 ` [PATCH 6/8] citest.py: Adapt tests to qemu reuse Uladzimir Bely
2023-08-18  7:07 ` [PATCH 7/8] cibuilder.py: enable output from remote scripts Uladzimir Bely
2023-08-18  7:07 ` [PATCH 8/8] testsuite: Switch to remote scripts with arguments Uladzimir Bely
2023-08-24 15:34 ` [PATCH 0/8] Testsuite improvements for SSH-based tests 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=20230818070706.27913-2-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