diff --git a/configure/E3/CONFIG_TEST b/configure/E3/CONFIG_TEST
index e8494bcff4ab7409463e1c9671c97934b73e3cd4..1836a92d02b51dabb0004f57a7e230a1c8c14859 100644
--- a/configure/E3/CONFIG_TEST
+++ b/configure/E3/CONFIG_TEST
@@ -12,5 +12,7 @@ VARS_EXCLUDES+=TEMP_CELL_PATH
 
 ifneq (,$(findstring test,$(MAKECMDGOALS)))
   TEST_DEBUG_ARCH:=$(if $(and $(findstring debug,$(EPICS_HOST_ARCH)),$(wildcard $(EPICS_BASE)/bin/$(EPICS_HOST_ARCH)/softIocPVA)),$(EPICS_HOST_ARCH))
+  EXPORT_VARS+=TEST_DEBUG_ARCH
+
   E3_MODULES_PATH=$(TEMP_CELL_PATH)/$(notdir $(EPICS_BASE))/require-$(E3_REQUIRE_VERSION)
 endif
diff --git a/tests/test_e3.py b/tests/test_e3.py
index 54e1e079488ecb5d658dfb84387c5f8780bc5650..b79327fd6921423deb1327fb8d710b7317e40ef2 100644
--- a/tests/test_e3.py
+++ b/tests/test_e3.py
@@ -1,3 +1,5 @@
+import pytest
+
 from .utils import Wrapper
 
 
@@ -49,3 +51,24 @@ def test_warning_if_building_from_sitemods(wrapper: Wrapper):
     assert (
         "It is ill-advised to build a module from the module install location." in errs
     )
+
+
+def test_debug_arch_is_not_used_when_unspecified(wrapper: Wrapper):
+    rc, _, errs = wrapper.run_make("test")
+    assert rc == 0
+
+    # Note that output from run-iocsh goes to stderr
+    assert f'EPICS_HOST_ARCH = "{wrapper.host_arch}"' in errs
+
+
+def test_debug_arch_is_used_when_specified(wrapper: Wrapper):
+    debug_arch = f"{wrapper.host_arch}-debug"
+    softioc_exec = wrapper.epics_base / "bin" / debug_arch / "softIocPVA"
+    if not softioc_exec.exists():
+        pytest.skip("No debug arch installed")
+
+    rc, _, errs = wrapper.run_make("test", EPICS_HOST_ARCH=debug_arch)
+    assert rc == 0
+
+    # Note that output from run-iocsh goes to stderr
+    assert f'EPICS_HOST_ARCH = "{debug_arch}"' in errs
diff --git a/tests/utils.py b/tests/utils.py
index b837ab55ce5e1c06586e80104b1eae00bdca0759..7223776e3374142be837fd24748dbb923a6957db 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -78,8 +78,6 @@ include $(REQUIRE_CONFIG)/RULES_SITEMODS
             module_makefile_contents = """
 where_am_I := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
 include $(E3_REQUIRE_TOOLS)/driver.makefile
-
-EXCLUDE_ARCHS+=debug
 """
             self.module_makefile.write_text(module_makefile_contents)
 
@@ -138,6 +136,9 @@ EXCLUDE_ARCHS+=debug
         args = list(args)
         if module_version:
             args.append(f"E3_MODULE_VERSION={module_version}")
+        if not ("TEST_DEBUG_ARCH" in env and not env["TEST_DEBUG_ARCH"]):
+            args.append("EXCLUDE_ARCHS=debug")
+
         if cell_path:
             self.write_dot_local_data("CONFIG_CELL", {"E3_CELL_PATH": cell_path})
         make_cmd = ["make", "-C", self.path, target] + args