From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH 8/8] testsuite: Switch to remote scripts with arguments
Date: Fri, 18 Aug 2023 09:07:06 +0200 [thread overview]
Message-ID: <20230818070706.27913-9-ubely@ilbers.de> (raw)
In-Reply-To: <20230818070706.27913-1-ubely@ilbers.de>
Scripts `test_getty_target.sh` and `test_example_module.sh` are limited
to the only function.
Rename and refactor (add custom arguments support) them in order
to support any systemd unit / kernel module to check.
Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
testsuite/README.md | 2 +-
testsuite/citest.py | 14 +++++++-------
testsuite/scripts/test_example_module.sh | 5 -----
testsuite/scripts/test_getty_target.sh | 7 -------
testsuite/scripts/test_kernel_module.sh | 5 +++++
testsuite/scripts/test_systemd_unit.sh | 23 +++++++++++++++++++++++
6 files changed, 36 insertions(+), 20 deletions(-)
delete mode 100755 testsuite/scripts/test_example_module.sh
delete mode 100755 testsuite/scripts/test_getty_target.sh
create mode 100755 testsuite/scripts/test_kernel_module.sh
create mode 100755 testsuite/scripts/test_systemd_unit.sh
diff --git a/testsuite/README.md b/testsuite/README.md
index b58a1013..913767fc 100644
--- a/testsuite/README.md
+++ b/testsuite/README.md
@@ -87,7 +87,7 @@ can be executed instead of command:
self.init()
self.vm_start('amd64','bookworm', \
image='isar-image-ci',
- script='test_getty_target.sh')
+ script='test_systemd_unit.sh getty.target 10')
```
The default location of custom scripts is `isar/testsuite/`. It can be changed
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 0cfb46ff..90b8955f 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -326,7 +326,7 @@ class VmBootTestFast(CIBaseTest):
def test_arm_bullseye_getty_target(self):
self.init()
self.vm_start('arm','bullseye', image='isar-image-ci',
- script='test_getty_target.sh',
+ script='test_systemd_unit.sh getty.target 10',
stop_vm=True)
@@ -342,7 +342,7 @@ class VmBootTestFast(CIBaseTest):
def test_arm_buster_example_module(self):
self.init()
self.vm_start('arm','buster', image='isar-image-ci',
- script='test_example_module.sh',
+ script='test_kernel_module.sh example_module',
stop_vm=True)
@@ -358,7 +358,7 @@ class VmBootTestFast(CIBaseTest):
def test_arm_bookworm_getty_target(self):
self.init()
self.vm_start('arm','bookworm', image='isar-image-ci',
- script='test_getty_target.sh',
+ script='test_systemd_unit.sh getty.target 10',
stop_vm=True)
@@ -388,7 +388,7 @@ class VmBootTestFull(CIBaseTest):
def test_arm_buster_getty_target(self):
self.init()
self.vm_start('arm','buster', image='isar-image-ci',
- script='test_getty_target.sh',
+ script='test_systemd_unit.sh getty.target 10',
stop_vm=True)
@@ -404,7 +404,7 @@ class VmBootTestFull(CIBaseTest):
def test_arm64_bullseye_example_module(self):
self.init()
self.vm_start('arm64','bullseye', image='isar-image-ci',
- script='test_example_module.sh',
+ script='test_kernel_module.sh example_module',
stop_vm=True)
@@ -436,7 +436,7 @@ class VmBootTestFull(CIBaseTest):
def test_amd64_focal_getty_target(self):
self.init()
self.vm_start('amd64','focal', image='isar-image-ci',
- script='test_getty_target.sh',
+ script='test_systemd_unit.sh getty.target 10',
stop_vm=True)
@@ -470,5 +470,5 @@ class VmBootTestFull(CIBaseTest):
def test_mipsel_bookworm_example_module(self):
self.init()
self.vm_start('mipsel','bookworm', image='isar-image-ci',
- script='test_example_module.sh',
+ script='test_kernel_module.sh example_module',
stop_vm=True)
diff --git a/testsuite/scripts/test_example_module.sh b/testsuite/scripts/test_example_module.sh
deleted file mode 100755
index 175030d1..00000000
--- a/testsuite/scripts/test_example_module.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-set -e
-
-lsmod | grep '^example_module '
diff --git a/testsuite/scripts/test_getty_target.sh b/testsuite/scripts/test_getty_target.sh
deleted file mode 100755
index 38c0fc1e..00000000
--- a/testsuite/scripts/test_getty_target.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-set -e
-
-sleep 10
-
-systemctl is-active getty.target
diff --git a/testsuite/scripts/test_kernel_module.sh b/testsuite/scripts/test_kernel_module.sh
new file mode 100755
index 00000000..1e43e5cb
--- /dev/null
+++ b/testsuite/scripts/test_kernel_module.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+lsmod | grep "^${1} "
diff --git a/testsuite/scripts/test_systemd_unit.sh b/testsuite/scripts/test_systemd_unit.sh
new file mode 100755
index 00000000..c97d7a7c
--- /dev/null
+++ b/testsuite/scripts/test_systemd_unit.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Checks system unit until it gets active or retry count reaches the limit
+
+set -e
+
+unit=$1
+cnt=$2
+
+ret=1
+
+while [ "$cnt" -gt 0 ]; do
+ if systemctl is-active "${unit}"; then
+ exit 0
+ else
+ ret=$?
+ fi
+
+ cnt=$((cnt - 1))
+ sleep 1
+done
+
+exit $ret
--
2.20.1
next prev parent 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 ` [PATCH 1/8] cibuilder.py: Support custom arguments passing to CI scripts Uladzimir Bely
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 ` Uladzimir Bely [this message]
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-9-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