[6/7] CI: fix random testimage failures

Message ID 20220325134853.3068169-6-ross.burton@arm.com
State New
Headers show
Series [1/7] arm/fvp: generalise FVP_ARCH | expand

Commit Message

Ross Burton March 25, 2022, 1:48 p.m. UTC
Backport a patch from Poky to fix random failures in testimage where
sys.path contains meta-arm twice, causing testimage to complain that
there are duplicate class names.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 ...text-remove-duplicate-sys.path-entri.patch | 38 +++++++++++++++++++
 ci/base.yml                                   |  4 ++
 2 files changed, 42 insertions(+)
 create mode 100644 ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch

Comments

Ross Burton March 28, 2022, 11:12 a.m. UTC | #1
This commit is now in poky, so shouldn't be pulled in.

Ross

On Fri, 25 Mar 2022 at 13:49, Ross Burton via lists.yoctoproject.org
<ross=burtonini.com@lists.yoctoproject.org> wrote:
>
> Backport a patch from Poky to fix random failures in testimage where
> sys.path contains meta-arm twice, causing testimage to complain that
> there are duplicate class names.
>
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  ...text-remove-duplicate-sys.path-entri.patch | 38 +++++++++++++++++++
>  ci/base.yml                                   |  4 ++
>  2 files changed, 42 insertions(+)
>  create mode 100644 ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch
>
> diff --git a/ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch b/ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch
> new file mode 100644
> index 00000000..6fcefd25
> --- /dev/null
> +++ b/ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch
> @@ -0,0 +1,38 @@
> +From 366316dca4ad6a0485b68fbf3271651d90395573 Mon Sep 17 00:00:00 2001
> +From: Ross Burton <ross.burton@arm.com>
> +Date: Thu, 24 Mar 2022 18:11:27 +0000
> +Subject: [PATCH] oeqa/runtime/context: remove duplicate sys.path entries when
> + looking for modules
> +
> +sys.path can contain duplicate entries for each layer, which means that
> +the search in add_controller_list() will find the same name twice and
> +abort.
> +
> +As duplicate directories should be harmless, remove any duplicates before
> +iterating through the entries.
> +
> +Signed-off-by: Ross Burton <ross.burton@arm.com>
> +---
> + meta/lib/oeqa/runtime/context.py | 6 +++++-
> + 1 file changed, 5 insertions(+), 1 deletion(-)
> +
> +diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
> +index d707ab263a8..8092dd0baee 100644
> +--- a/meta/lib/oeqa/runtime/context.py
> ++++ b/meta/lib/oeqa/runtime/context.py
> +@@ -153,7 +153,11 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
> +                 else:
> +                     raise RuntimeError("Duplicate controller module found for %s. Layers should create unique controller module names" % module)
> +
> +-        for p in sys.path:
> ++        # sys.path can contain duplicate paths, but because of the login in
> ++        # add_controller_list this doesn't work and causes testimage to abort.
> ++        # Remove duplicates using an intermediate dictionary to ensure this
> ++        # doesn't happen.
> ++        for p in list(dict.fromkeys(sys.path)):
> +             controllerpath = os.path.join(p, 'oeqa', 'controllers')
> +             if os.path.exists(controllerpath):
> +                 add_controller_list(controllerpath)
> +--
> +2.25.1
> +
> diff --git a/ci/base.yml b/ci/base.yml
> index 9a59de79..d19901dd 100644
> --- a/ci/base.yml
> +++ b/ci/base.yml
> @@ -19,6 +19,10 @@ repos:
>      layers:
>        meta:
>        meta-poky:
> +    patches:
> +      oeqa-duplicates:
> +        repo: meta-arm
> +        path: ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch
>
>  env:
>    BB_LOGCONFIG: ""
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#3210): https://lists.yoctoproject.org/g/meta-arm/message/3210
> Mute This Topic: https://lists.yoctoproject.org/mt/90022499/1676615
> Group Owner: meta-arm+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [ross@burtonini.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>

Patch

diff --git a/ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch b/ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch
new file mode 100644
index 00000000..6fcefd25
--- /dev/null
+++ b/ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch
@@ -0,0 +1,38 @@ 
+From 366316dca4ad6a0485b68fbf3271651d90395573 Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton@arm.com>
+Date: Thu, 24 Mar 2022 18:11:27 +0000
+Subject: [PATCH] oeqa/runtime/context: remove duplicate sys.path entries when
+ looking for modules
+
+sys.path can contain duplicate entries for each layer, which means that
+the search in add_controller_list() will find the same name twice and
+abort.
+
+As duplicate directories should be harmless, remove any duplicates before
+iterating through the entries.
+
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ meta/lib/oeqa/runtime/context.py | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
+index d707ab263a8..8092dd0baee 100644
+--- a/meta/lib/oeqa/runtime/context.py
++++ b/meta/lib/oeqa/runtime/context.py
+@@ -153,7 +153,11 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
+                 else:
+                     raise RuntimeError("Duplicate controller module found for %s. Layers should create unique controller module names" % module)
+ 
+-        for p in sys.path:
++        # sys.path can contain duplicate paths, but because of the login in
++        # add_controller_list this doesn't work and causes testimage to abort.
++        # Remove duplicates using an intermediate dictionary to ensure this
++        # doesn't happen.
++        for p in list(dict.fromkeys(sys.path)):
+             controllerpath = os.path.join(p, 'oeqa', 'controllers')
+             if os.path.exists(controllerpath):
+                 add_controller_list(controllerpath)
+-- 
+2.25.1
+
diff --git a/ci/base.yml b/ci/base.yml
index 9a59de79..d19901dd 100644
--- a/ci/base.yml
+++ b/ci/base.yml
@@ -19,6 +19,10 @@  repos:
     layers:
       meta:
       meta-poky:
+    patches:
+      oeqa-duplicates:
+        repo: meta-arm
+        path: ci/0001-oeqa-runtime-context-remove-duplicate-sys.path-entri.patch
 
 env:
   BB_LOGCONFIG: ""