summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorAlexis Lothoré <alexis.lothore@bootlin.com>2023-02-24 17:45:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-26 11:59:52 +0000
commitffaee6bd482d2bbf32e78306e3884985e3078184 (patch)
tree6909c6ce085d0772682abd4b707cb237b3f5000b /meta
parent7a70dcfea7cde7b28ae3e606b338ff0a6eca0bd6 (diff)
downloadpoky-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.py39
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
7import os
8import sys
9import subprocess
10import shutil
11from oeqa.selftest.case import OESelftestTestCase
12from yocto_testresults_query import get_sha1, create_workdir
13basepath = os.path.abspath(os.path.dirname(__file__) + '/../../../../../')
14lib_path = basepath + '/scripts/lib'
15sys.path = sys.path + [lib_path]
16
17
18class 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")