diff options
author | Alexis Lothoré <alexis.lothore@bootlin.com> | 2023-02-24 17:45:55 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-02-26 11:59:52 +0000 |
commit | ffaee6bd482d2bbf32e78306e3884985e3078184 (patch) | |
tree | 6909c6ce085d0772682abd4b707cb237b3f5000b /meta | |
parent | 7a70dcfea7cde7b28ae3e606b338ff0a6eca0bd6 (diff) | |
download | poky-ffaee6bd482d2bbf32e78306e3884985e3078184.tar.gz |
oeqa/selftest: add test for yocto_testresults_query.py
Add some tests for new yocto_testresults_query.py helper. First test is taken
from yocto-autobuilder-helper feature which has moved in yocto_testresults_query
(From OE-Core rev: 9ce28f685e4282d81f179877cbafd0a52fa887bd)
Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/yoctotestresultsquerytests.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/yoctotestresultsquerytests.py b/meta/lib/oeqa/selftest/cases/yoctotestresultsquerytests.py new file mode 100644 index 0000000000..312edb6431 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/yoctotestresultsquerytests.py | |||
@@ -0,0 +1,39 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | import os | ||
8 | import sys | ||
9 | import subprocess | ||
10 | import shutil | ||
11 | from oeqa.selftest.case import OESelftestTestCase | ||
12 | from yocto_testresults_query import get_sha1, create_workdir | ||
13 | basepath = os.path.abspath(os.path.dirname(__file__) + '/../../../../../') | ||
14 | lib_path = basepath + '/scripts/lib' | ||
15 | sys.path = sys.path + [lib_path] | ||
16 | |||
17 | |||
18 | class TestResultsQueryTests(OESelftestTestCase): | ||
19 | def test_get_sha1(self): | ||
20 | test_data_get_sha1 = [ | ||
21 | {"input": "yocto-4.0", "expected": "00cfdde791a0176c134f31e5a09eff725e75b905"}, | ||
22 | {"input": "4.1_M1", "expected": "95066dde6861ee08fdb505ab3e0422156cc24fae"}, | ||
23 | ] | ||
24 | for data in test_data_get_sha1: | ||
25 | test_name = data["input"] | ||
26 | with self.subTest(f"Test SHA1 from {test_name}"): | ||
27 | self.assertEqual( | ||
28 | get_sha1(basepath, data["input"]), data["expected"]) | ||
29 | |||
30 | def test_create_workdir(self): | ||
31 | workdir = create_workdir() | ||
32 | try: | ||
33 | url = subprocess.check_output( | ||
34 | ["git", "-C", workdir, "remote", "get-url", "origin"]).strip().decode("utf-8") | ||
35 | except: | ||
36 | shutil.rmtree(workdir, ignore_errors=True) | ||
37 | self.fail(f"Can not execute git commands in {workdir}") | ||
38 | shutil.rmtree(workdir) | ||
39 | self.assertEqual(url, "git://git.yoctoproject.org/yocto-testresults") | ||