poky/meta/lib/oeqa/buildtools/cases/gcc.py
Thune Tran 041ba867db oeqa/sdk: Simplify test specification and discovery
Simplify how tests are specified and discovered for different SDK configurations
to allow per-layer customization.

* Introduce `TESTSDK_CASE_DIRS` variable to specify test directory types,
  replacing the need to modify the default_cases class member

* Discover tests from configured layers using a common discovery pattern
  (`<LAYER_DIR>/lib/oeqa/<dirname>/cases`) where `<dirname>` is specified in `TESTSDK_CASE_DIRS`

* The buildtools directories were renamed to follow the common discovery pattern
(`<LAYER_DIR>/lib/oeqa/<dirname>/cases`) for consistency across all SDK configurations.

  meta/lib/oeqa/
  ├── sdk/cases/              # Standard SDK: dirname="sdk"
  ├── buildtools/cases/       # Buildtools: dirname="buildtools"
  └── buildtools-docs/cases/  # Buildtools-docs: dirname="buildtools-docs"

  meta-mingw/lib/oeqa/
  └── sdkmingw/cases/         # MinGW: dirname="sdkmingw"

  meta-foo/lib/oeqa/
  └── sdk/cases/              # Standard SDK: dirname="sdk"

Tested by:

1. Adding new tests using the default discovery pattern `<LAYER_DIR>/lib/oeqa/sdk/cases` and
   verifying they are discovered and executed.

2. Verifying existing SDK configuration tests work (requires -c populate_sdk first):
   * Standard SDK: `bitbake core-image-minimal -c testsdk`
   * Buildtools tarball: `bitbake buildtools-tarball -c testsdk`
   * Buildtools docs tarball: `bitbake buildtools-docs-tarball -c testsdk`
   * Mingw SDK: (SDKMACHINE = "x86_64-mingw32") `bitbake core-image-minimal -c testsdk`

(From OE-Core rev: bde94c128c0b4e7e1ebea40f582b4dd6dcc965ff)

Signed-off-by: Thune Tran <thune.a.tran@boeing.com>
Signed-off-by: Chuck Wolber <chuck.wolber@boeing.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2025-07-01 08:49:37 +01:00

32 lines
1.1 KiB
Python

#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#
import os.path
from oeqa.sdk.case import OESDKTestCase
class GccTests(OESDKTestCase):
def test_verify_specs(self):
"""
Verify that the compiler has been relocated successfully and isn't
looking in the hard-coded prefix.
"""
# Canonicalise the SDK root
sdk_base = os.path.realpath(self.tc.sdk_dir)
# Canonicalise the location of GCC
gcc_path = os.path.realpath(self._run("command -v gcc").strip())
# Skip the test if the GCC didn't come from the buildtools, as it only
# comes with buildtools-extended-tarball.
if os.path.commonprefix((sdk_base, gcc_path)) != sdk_base:
self.skipTest("Buildtools does not provide GCC")
# This is the prefix that GCC is build with, and should be replaced at
# installation time.
sdkpath = self.td.get("SDKPATH")
self.assertTrue(sdkpath)
for line in self._run('gcc -dumpspecs').splitlines():
self.assertNotIn(sdkpath, line)