diff mbox series

oeqa/selftest/buildoptions: Fix test_yocto_source_mirror MIRRORS & PREMIRRORS definitions

Message ID 20251010231110.326806-1-yoann.congal@smile.fr
State New
Headers show
Series oeqa/selftest/buildoptions: Fix test_yocto_source_mirror MIRRORS & PREMIRRORS definitions | expand

Commit Message

Yoann Congal Oct. 10, 2025, 11:11 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

Currently, the definitions of MIRRORS and PREMIRRORS made by
test_yocto_source_mirror() are overwritten when run on the autobuilder:
* MIRRORS = "" is extended by mirrors.bbclass to its usual value.
* PREMIRRORS = "* dl.yp.org" is overwritten by the autobuilder.conf
  config fragment to ""

Simplified variable history:
  # $MIRRORS [4 operations]
  #   set .../contribution-yocto/builds/build-qemux86-64-st/conf/selftest.inc:3
  #     ""
  #   append .../contribution-yocto/builds/build-qemux86-64-st/../../layers/poky/meta/classes-global/mirrors.bbclass:57
  #     "${DEBIAN_MIRROR}	..."
  MIRRORS=" http://deb.debian.org/debian/pool ..."

  # $PREMIRRORS [4 operations]
  #   set .../contribution-yocto/builds/build-qemux86-64-st/conf/selftest.inc:18
  #     "    bzr://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \n ..."
  #   set .../contribution-yocto/builds/build-qemux86-64-st/../../layers/poky/meta/conf/fragments/yocto-autobuilder/autobuilder.conf:6
  #     ""
  #   append .../contribution-yocto/builds/build-qemux86-64-st/../../layers/poky/meta/classes-global/mirrors.bbclass:84
  #     "git://sourceware.org/git/glibc.git https://downloads.yoctoproject.org/mirror/sources/  ..."
  PREMIRRORS=" git://sourceware.org/git/glibc.git https://downloads.yoctoproject.org/mirror/sources/  ..."

Despite this unexpected configuration, the test passes because after
failing to find a PREMIRROR (empty), failing to download the normal
SRC_URI (because of BB_ALLOWED_NETWORKS), the fetcher tries the MIRRORS
which have by default download.yoctoproject.org. For example, on a
failed meta-oe-mirror test[0], we can see a lot of warnings:
"stdio: WARNING: ... do_fetch: Failed to fetch URL https://... attempting MIRRORS if available"

By using the ":forcevariable" override, test_yocto_source_mirror() makes
sure the correct value is set for MIRRORS and PREMIRRORS (whatever is
the configuration).

Simplified variable history (after the fix):
  # $MIRRORS [4 operations]
  #   append .../contribution-yocto/builds/build-qemux86-64-st/../../layers/poky/meta/classes-global/mirrors.bbclass:57
  #     "${DEBIAN_MIRROR}	..."
  #   append .../contribution-yocto/builds/build-qemux86-64-st/../../layers/poky/meta/classes-global/mirrors.bbclass:68
  #     "git://salsa.debian.org/.* ..."
  #   override[forcevariable]:set .../contribution-yocto/builds/build-qemux86-64-st/conf/selftest.inc:3
  #     ""
  MIRRORS=""

  # $PREMIRRORS [4 operations]
  #   set .../contribution-yocto/builds/build-qemux86-64-st/../../layers/poky/meta/conf/fragments/yocto-autobuilder/autobuilder.conf:6
  #     ""
  #   append .../contribution-yocto/builds/build-qemux86-64-st/../../layers/poky/meta/classes-global/mirrors.bbclass:84
  #     "git://sourceware.org/git/glibc.git ..."
  #   override[forcevariable]:set .../contribution-yocto/builds/build-qemux86-64-st/conf/selftest.inc:18
  #     "    bzr://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ ..."
  # pre-expansion value:
  #   "    bzr://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ ..."
  PREMIRRORS="    bzr://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ ..."

[0]: https://autobuilder.yoctoproject.org/valkyrie/#/builders/82/builds/470/steps/17/logs/warnings

Fixes [YOCTO #15993]

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 meta/lib/oeqa/selftest/cases/buildoptions.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/buildoptions.py b/meta/lib/oeqa/selftest/cases/buildoptions.py
index 767e19bd88..b46f55e256 100644
--- a/meta/lib/oeqa/selftest/cases/buildoptions.py
+++ b/meta/lib/oeqa/selftest/cases/buildoptions.py
@@ -173,11 +173,11 @@  class SourceMirroring(OESelftestTestCase):
     def test_yocto_source_mirror(self):
         self.write_config("""
 BB_ALLOWED_NETWORKS = "downloads.yoctoproject.org"
-MIRRORS = ""
+MIRRORS:forcevariable = ""
 DL_DIR = "${TMPDIR}/test_downloads"
 STAMPS_DIR = "${TMPDIR}/test_stamps"
 SSTATE_DIR = "${TMPDIR}/test_sstate-cache"
-PREMIRRORS = "\\
+PREMIRRORS:forcevariable = "\\
     bzr://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \\n \\
     cvs://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \\n \\
     git://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \\n \\