* [PATCH v2 2/4] testsuite: fix deterministic password test in image account extension
2026-10-26 14:31 [PATCH v2 1/4] testsuite: fix run_privileged_cmd in image account extension unit test 'Clara Kowalsky' via isar-users
@ 2026-10-26 14:31 ` 'Clara Kowalsky' via isar-users
2026-10-26 14:31 ` [PATCH v2 3/4] testsuite: run Python unittests in fast suite 'Clara Kowalsky' via isar-users
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: 'Clara Kowalsky' via isar-users @ 2026-10-26 14:31 UTC (permalink / raw)
To: isar-users; +Cc: Clara Kowalsky
The test expected two process.run calls which worked for the original
crypt-based implementation. Commit 6144daf9 replaced crypt with an
openssl passwd subprocess, adding a third call, but did not update the
test.
Also mock the openssl output and verify the expected salt and password
input.
Fixes: 6144daf9 ("image-account-extension: Avoid deprecated crypt module")
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
testsuite/unittests/test_image_account_extension.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testsuite/unittests/test_image_account_extension.py b/testsuite/unittests/test_image_account_extension.py
index 8bf5f82b..266883c1 100644
--- a/testsuite/unittests/test_image_account_extension.py
+++ b/testsuite/unittests/test_image_account_extension.py
@@ -118,11 +118,16 @@ class TestImageAccountExtensionImageCreateUsers(
)
with patch.object(process, 'run') as run_mock:
+ run_mock.return_value = (encrypted_password, '')
image_create_users(d)
password_data = f"{test_user}:{encrypted_password}".encode()
- assert run_mock.call_count == 2
+ assert run_mock.call_count == 3
+ run_mock.assert_any_call([
+ 'openssl', 'passwd', '-6', '--salt', 'eb2e2a12cccc88a',
+ cleartext_password,
+ ])
assert run_mock.call_args[0][1] == password_data
--
2.55.0
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20261026143132.1067398-2-clara.kowalsky%40siemens.com.
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 3/4] testsuite: run Python unittests in fast suite
2026-10-26 14:31 [PATCH v2 1/4] testsuite: fix run_privileged_cmd in image account extension unit test 'Clara Kowalsky' via isar-users
2026-10-26 14:31 ` [PATCH v2 2/4] testsuite: fix deterministic password test in image account extension 'Clara Kowalsky' via isar-users
@ 2026-10-26 14:31 ` 'Clara Kowalsky' via isar-users
2026-10-26 14:31 ` [PATCH v2 4/4] testsuite: improve documentation for running Python unittests 'Clara Kowalsky' via isar-users
2026-10-29 14:23 ` [PATCH v2 1/4] testsuite: fix run_privileged_cmd in image account extension unit test Zhihang Wei
3 siblings, 0 replies; 5+ messages in thread
From: 'Clara Kowalsky' via isar-users @ 2026-10-26 14:31 UTC (permalink / raw)
To: isar-users; +Cc: Clara Kowalsky
Add an Avocado test with tag fast to run the Python unittests.
By default, all unittests located in testsuite/unittests/test* are run.
It is also possible to run a specific test or test file.
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
testsuite/citest.py | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 245a4305..dd151c1c 100644
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -8,7 +8,7 @@
from avocado import skipUnless
from avocado.core import exceptions
-from avocado.utils import path
+from avocado.utils import path, process
from cibase import CIBaseTest
from utils import CIUtils
@@ -56,6 +56,23 @@ class EnvTest(CIBaseTest):
self.perform_build_test(targets)
+class UnittestTest(CIBaseTest):
+ """Run the Python unit tests.
+
+ :avocado: tags=unittest,fast
+ """
+
+ def test_unittest(self):
+ test = self.params.get('test', default='')
+ if test:
+ process.run(
+ f'python3 -m unittest {test}',
+ env={'PYTHONPATH': 'testsuite/unittests'},
+ )
+ else:
+ process.run('python3 -m unittest discover -s testsuite/unittests')
+
+
class DevTest(CIBaseTest):
"""
--
2.55.0
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20261026143132.1067398-3-clara.kowalsky%40siemens.com.
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 4/4] testsuite: improve documentation for running Python unittests
2026-10-26 14:31 [PATCH v2 1/4] testsuite: fix run_privileged_cmd in image account extension unit test 'Clara Kowalsky' via isar-users
2026-10-26 14:31 ` [PATCH v2 2/4] testsuite: fix deterministic password test in image account extension 'Clara Kowalsky' via isar-users
2026-10-26 14:31 ` [PATCH v2 3/4] testsuite: run Python unittests in fast suite 'Clara Kowalsky' via isar-users
@ 2026-10-26 14:31 ` 'Clara Kowalsky' via isar-users
2026-10-29 14:23 ` [PATCH v2 1/4] testsuite: fix run_privileged_cmd in image account extension unit test Zhihang Wei
3 siblings, 0 replies; 5+ messages in thread
From: 'Clara Kowalsky' via isar-users @ 2026-10-26 14:31 UTC (permalink / raw)
To: isar-users; +Cc: Clara Kowalsky
Update the command for running unittests and fix some typos.
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
testsuite/unittests/README.md | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/testsuite/unittests/README.md b/testsuite/unittests/README.md
index 75a3bb01..22e6b6d1 100644
--- a/testsuite/unittests/README.md
+++ b/testsuite/unittests/README.md
@@ -1,20 +1,31 @@
# Isar Unittests
-The unittest python module adds some simple infrastructure that allows to
-unittest python functions defined in bitbake files.
+The unittest Python module adds some simple infrastructure that allows to
+unittest Python functions defined in BitBake files.
## Running the tests
-You can run the tests using avocado with `avocado --show=app,test run testsuite/unittests/`
-or by using the buildin module with `python3 -m unittest discover testsuite/unittests/`
+Run all Python unit tests with:
+
+```sh
+scripts/run-tests.sh -t unittest
+```
+
+Or by using the built-in module: `python3 -m unittest discover testsuite/unittests/`.
+
+Run a specific test by its unittest name:
+
+```sh
+scripts/run-tests.sh -t unittest -p test=test_image_account_extension.TestImageAccountExtensionImageCreateUsers.test_new_user
+```
## Creating new tests
See the [unittest documentation](https://docs.python.org/3/library/unittest.html)
on how to create a test module and name it test_*bitbake_module_name*.py
-Use the function `load_function(file_name: str, function_name: str) -> Callable`
-in the bitbake module to load the function.
+Use `load_function(file_name, function_name)` from `bitbake.py` to load regular
+Python functions from BitBake files.
Example:
```python
--
2.55.0
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20261026143132.1067398-4-clara.kowalsky%40siemens.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/4] testsuite: fix run_privileged_cmd in image account extension unit test
2026-10-26 14:31 [PATCH v2 1/4] testsuite: fix run_privileged_cmd in image account extension unit test 'Clara Kowalsky' via isar-users
` (2 preceding siblings ...)
2026-10-26 14:31 ` [PATCH v2 4/4] testsuite: improve documentation for running Python unittests 'Clara Kowalsky' via isar-users
@ 2026-10-29 14:23 ` Zhihang Wei
3 siblings, 0 replies; 5+ messages in thread
From: Zhihang Wei @ 2026-10-29 14:23 UTC (permalink / raw)
To: Clara Kowalsky, isar-users
Applied to next, thanks.
Zhihang
On 10/26/26 15:31, 'Clara Kowalsky' via isar-users wrote:
> The account functions use run_privileged_cmd which BitBake provides
> through base.bbclass. The tests load the functions in isolation, so the
> helper is undefined and the tests fail with:
>
> NameError: name 'run_privileged_cmd' is not defined
>
> Fix this by providing a stub for the helper in the test namespace.
>
> Fixes: 14acf490 ("introduce wrappers for privileged execution")
> Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
> ---
> testsuite/unittests/test_image_account_extension.py | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/testsuite/unittests/test_image_account_extension.py b/testsuite/unittests/test_image_account_extension.py
> index ff0e47e0..8bf5f82b 100644
> --- a/testsuite/unittests/test_image_account_extension.py
> +++ b/testsuite/unittests/test_image_account_extension.py
> @@ -18,8 +18,16 @@ from bb import process
> from bb.data_smart import DataSmart
>
> file_name = 'meta/classes-recipe/image-account-extension.bbclass'
> +
> +
> +def run_privileged_cmd(d):
> + return 'sudo -E'
> +
> +
> image_create_users = load_function(file_name, 'image_create_users')
> +image_create_users.__globals__['run_privileged_cmd'] = run_privileged_cmd
> image_create_groups = load_function(file_name, 'image_create_groups')
> +image_create_groups.__globals__['run_privileged_cmd'] = run_privileged_cmd
>
>
> class TestImageAccountExtensionCommon(unittest.TestCase):
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/73fed67d-acf3-4c2f-8eb3-85ece2241c44%40ilbers.de.
^ permalink raw reply [flat|nested] 5+ messages in thread