diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/yoctotestresultsquerytests.py')
-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") | ||