testexport.bbclass oe-test: capture all tests and data from all layers

testexport.bbclass only copied files from core layer to
the testexport.tar.gz to run tests. Then it filtered
out tests and files which were not specified in
TEST_SUITES variable.

Remove filtering of files to include parselogs.py
test data files which are machine and/or layer specific.
TEST_SUITES variable is now read from build time exported
data store when running tests so there is no need to remove
files from exported tests in testexport.bbclass.

Adapt oe-test script to find "lib" directories from
the new structure with layer specific paths which are
used to find tests and test data files.

(From OE-Core rev: 260db92c35fbabcd54fe543256eee836ffeb73f0)

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mikko Rapeli 2025-07-02 10:25:14 +03:00 committed by Richard Purdie
parent 6d20f8ad65
commit 1052fff52e
2 changed files with 30 additions and 25 deletions

View File

@ -85,6 +85,7 @@ def copy_needed_files(d, tc):
export_path = d.getVar('TEST_EXPORT_DIR')
corebase_path = d.getVar('COREBASE')
bblayers = d.getVar('BBLAYERS').split()
# Clean everything before starting
oe.path.remove(export_path)
@ -92,17 +93,11 @@ def copy_needed_files(d, tc):
# The source of files to copy are relative to 'COREBASE' directory
# The destination is relative to 'TEST_EXPORT_DIR'
# Because we are squashing the libraries, we need to remove
# the layer/script directory
files_to_copy = [ os.path.join('meta', 'lib', 'oeqa', 'core'),
os.path.join('meta', 'lib', 'oeqa', 'runtime'),
os.path.join('meta', 'lib', 'oeqa', 'files'),
os.path.join('meta', 'lib', 'oeqa', 'utils'),
os.path.join('scripts', 'oe-test'),
# core files/dirs first
core_files_to_copy = [ os.path.join('scripts', 'oe-test'),
os.path.join('scripts', 'lib', 'argparse_oe.py'),
os.path.join('scripts', 'lib', 'scriptutils.py'), ]
for f in files_to_copy:
for f in core_files_to_copy:
src = os.path.join(corebase_path, f)
dst = os.path.join(export_path, f.split('/', 1)[-1])
if os.path.isdir(src):
@ -110,18 +105,21 @@ def copy_needed_files(d, tc):
else:
shutil.copy2(src, dst)
# Remove cases and just copy the ones specified
cases_path = os.path.join(export_path, 'lib', 'oeqa', 'runtime', 'cases')
oe.path.remove(cases_path)
bb.utils.mkdirhier(cases_path)
test_paths = get_runtime_paths(d)
test_modules = d.getVar('TEST_SUITES').split()
tc.loadTests(test_paths, modules=test_modules)
for f in getSuiteCasesFiles(tc.suites):
shutil.copy2(f, cases_path)
json_file = _get_json_file(f)
if json_file:
shutil.copy2(json_file, cases_path)
# layer specific files/dirs
layer_files_to_copy = [ os.path.join('lib', 'oeqa', 'core'),
os.path.join('lib', 'oeqa', 'runtime'),
os.path.join('lib', 'oeqa', 'files'),
os.path.join('lib', 'oeqa', 'utils'),]
for layer in bblayers:
meta = os.path.basename(layer)
for f in layer_files_to_copy:
src = os.path.join(layer, f)
dst = os.path.join(export_path, meta, f)
if os.path.exists(src):
if os.path.isdir(src):
oe.path.copytree(src, dst)
else:
shutil.copy2(src, dst)
# Copy test data
image_name = ("%s/%s" % (d.getVar('DEPLOY_DIR_IMAGE'),
@ -142,6 +140,9 @@ def copy_needed_files(d, tc):
testexport_create_tarball(d, "testexport.tar.gz", d.getVar("TEST_EXPORT_DIR"))
# Copy packages needed for runtime testing
test_paths = get_runtime_paths(d)
test_modules = d.getVar('TEST_SUITES').split()
tc.loadTests(test_paths, modules=test_modules)
package_extraction(d, tc.suites)
test_pkg_dir = d.getVar("TEST_NEEDED_PACKAGES_DIR")
if os.path.isdir(test_pkg_dir) and os.listdir(test_pkg_dir):

View File

@ -7,14 +7,18 @@
# SPDX-License-Identifier: MIT
#
import argparse
import glob
import logging
import os
import sys
import argparse
import logging
scripts_path = os.path.dirname(os.path.realpath(__file__))
lib_path = scripts_path + '/lib'
sys.path = sys.path + [lib_path]
lib_path = os.path.join(scripts_path, 'lib')
sys.path.append(lib_path)
meta_lib_paths = glob.glob(scripts_path + '/*/lib', root_dir=scripts_path, recursive=True)
for p in meta_lib_paths:
sys.path.append(p)
import argparse_oe
import scriptutils