[PATCH 1/2] Toaster: tests: add passthroughs for relevant build environment variables

Alexander Lussier-Cullen <[email protected]> Thu, 23 Nov 2023 10:12:14 -0500
Newsgroups org.yoctoproject.lists.toaster
Message-ID <20231123151215.4390-2-alexander.lussier-cullen@savoirfairelinux.com>
Toaster build tests create new build environments which do not utlize
any existing build environment variables.
In particular, DL_DIR and SSTATE_DIR from an existing environment can
be passed in to allow for faster builds.

Adding these as passthroughs specifically resolves slow builds
related to the autobuilder integrations of the toaster test suite.

Signed-off-by: Alexander Lussier-Cullen <[email protected]>
---
 bitbake/lib/toaster/tests/builds/buildtest.py | 9 +++++++++
 bitbake/lib/toaster/tox.ini                   | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/bitbake/lib/toaster/tests/builds/buildtest.py b/bitbake/lib/toaster/tests/builds/buildtest.py
index 13b51fb0d8..53cd7a9ffa 100644
--- a/bitbake/lib/toaster/tests/builds/buildtest.py
+++ b/bitbake/lib/toaster/tests/builds/buildtest.py
@@ -116,6 +116,15 @@ class BuildTest(unittest.TestCase):
         project = Project.objects.create_project(name=BuildTest.PROJECT_NAME,
                                                  release=release)
 
+        passthrough_variable_names = ["SSTATE_DIR", "DL_DIR"]
+        for variable_name in passthrough_variable_names:
+            current_variable = os.environ.get(variable_name)
+            if current_variable:
+                ProjectVariable.objects.get_or_create(
+                    name=variable_name,
+                    value=current_variable,
+                    project=project)
+
         if os.environ.get("TOASTER_TEST_USE_SSTATE_MIRROR"):
             ProjectVariable.objects.get_or_create(
                 name="SSTATE_MIRRORS",
diff --git a/bitbake/lib/toaster/tox.ini b/bitbake/lib/toaster/tox.ini
index d058558b05..9928657106 100644
--- a/bitbake/lib/toaster/tox.ini
+++ b/bitbake/lib/toaster/tox.ini
@@ -5,6 +5,9 @@ toxworkdir = {env:TOX_WORKDIR:.tox}
 passenv = *
 
 [testenv]
+passenv =
+    SSTATE_DIR
+    DL_DIR
 setenv =
     DJANGO_SETTINGS_MODULE=toastermain.settings_test
     TOASTER_BUILDSERVER=1
-- 
2.34.1