* [PATCH v1 1/2] .pytool/CISettings: Remove Windows only scope for host based unit tests
[not found] <20200415203039.23196-1-michael.kubacki@outlook.com>
@ 2020-04-15 20:30 ` Michael Kubacki
2020-04-15 20:30 ` [PATCH v1 2/2] BaseTools/Plugin: Update HostBasedUnitTestRunner to support Linux Michael Kubacki
1 sibling, 0 replies; 2+ messages in thread
From: Michael Kubacki @ 2020-04-15 20:30 UTC (permalink / raw)
To: devel; +Cc: Sean Brogan, Bret Barkelew, Michael D Kinney, Liming Gao
From: Sean Brogan <sean.brogan@microsoft.com>
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2513
Remove Windows only scopes in the CISettngs file
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
.pytool/CISettings.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py
index 120fa1dcb433..0826fb16a34e 100644
--- a/.pytool/CISettings.py
+++ b/.pytool/CISettings.py
@@ -122,9 +122,6 @@ class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManag
self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
- if GetHostInfo().os.upper() == "WINDOWS":
- scopes += ('host-test-win',)
-
if GetHostInfo().os.upper() == "LINUX" and self.ActualToolChainTag.upper().startswith("GCC"):
if "AARCH64" in self.ActualArchitectures:
scopes += ("gcc_aarch64_linux",)
--
2.16.3.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v1 2/2] BaseTools/Plugin: Update HostBasedUnitTestRunner to support Linux
[not found] <20200415203039.23196-1-michael.kubacki@outlook.com>
2020-04-15 20:30 ` [PATCH v1 1/2] .pytool/CISettings: Remove Windows only scope for host based unit tests Michael Kubacki
@ 2020-04-15 20:30 ` Michael Kubacki
1 sibling, 0 replies; 2+ messages in thread
From: Michael Kubacki @ 2020-04-15 20:30 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao, Bret Barkelew, Michael D Kinney
From: Sean Brogan <sean.brogan@microsoft.com>
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2513
Update HostBasedUnitTestRunner plugin to support the Linux environment
and remove any Windows only logic.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py | 58 ++++++++++----------
BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner_plug_in.yaml | 4 +-
2 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
index 92426760ae0f..c1eeaf26251e 100644
--- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
+++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
@@ -8,47 +8,23 @@
import os
import logging
import glob
+import stat
import xml.etree.ElementTree
from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin
from edk2toolext import edk2_logging
import edk2toollib.windows.locate_tools as locate_tools
from edk2toolext.environment import shell_environment
from edk2toollib.utility_functions import RunCmd
+from edk2toollib.utility_functions import GetHostInfo
class HostBasedUnitTestRunner(IUefiBuildPlugin):
def do_pre_build(self, thebuilder):
'''
- Works with the compiler (either the HostBasedCompilerPlugin or an other Builder) to set
- up the environment that will be needed to build host-based unit tests.
-
- EXPECTS:
- - Build Var 'CI_BUILD_TYPE' - If not set to 'host_unit_test', will not do anything.
-
- UPDATES:
- - Shell Var (Several) - Updates the shell with all vars listed in interesting_keys.
- - Shell Path - Updated from QueryVcVariables()
- - Shell Var 'CMOCKA_MESSAGE_OUTPUT'
+ Run Prebuild
'''
- ci_type = thebuilder.env.GetValue('CI_BUILD_TYPE')
- if ci_type != 'host_unit_test':
- return 0
- shell_env = shell_environment.GetEnvironment()
- # Use the tools lib to determine the correct values for the vars that interest us.
- interesting_keys = ["ExtensionSdkDir", "INCLUDE", "LIB", "LIBPATH", "UniversalCRTSdkDir",
- "UCRTVersion", "WindowsLibPath", "WindowsSdkBinPath", "WindowsSdkDir", "WindowsSdkVerBinPath",
- "WindowsSDKVersion", "VCToolsInstallDir"]
- vs_vars = locate_tools.QueryVcVariables(interesting_keys, "amd64")
- for (k, v) in vs_vars.items():
- if k.upper() == "PATH":
- shell_env.append_path(v)
- else:
- shell_env.set_shell_var(k, v)
-
- # Set up the reporting type for Cmocka.
- shell_env.set_shell_var('CMOCKA_MESSAGE_OUTPUT', 'xml')
return 0
def do_post_build(self, thebuilder):
@@ -73,6 +49,9 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin):
failure_count = 0
+ # Set up the reporting type for Cmocka.
+ shell_env.set_shell_var('CMOCKA_MESSAGE_OUTPUT', 'xml')
+
for arch in thebuilder.env.GetValue("TARGET_ARCH").split():
logging.log(edk2_logging.get_subsection_level(),
"Testing for architecture: " + arch)
@@ -82,8 +61,29 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin):
for old_result in glob.iglob(os.path.join(cp, "*.result.xml")):
os.remove(old_result)
- # Determine whether any tests exist.
- testList = glob.glob(os.path.join(cp, "*Test*.exe"))
+ # Find and Run any Host Tests
+ if GetHostInfo().os.upper() == "LINUX":
+ testList = glob.glob(os.path.join(cp, "*Test*"))
+ for a in testList[:]:
+ p = os.path.join(cp, a)
+ # It must be a file
+ if not os.path.isfile(p):
+ testList.remove(a)
+ logging.debug(f"Remove directory file: {p}")
+ continue
+ # It must be executable
+ if os.stat(p).st_mode & (stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) == 0:
+ testList.remove(a)
+ logging.debug(f"Remove non-executable file: {p}")
+ continue
+
+ logging.info(f"Test file found: {p}")
+
+ elif GetHostInfo().os.upper() == "WINDOWS":
+ testList = glob.glob(os.path.join(cp, "*Test*.exe"))
+ else:
+ raise NotImplementedError("Unsupported Operating System")
+
for test in testList:
# Configure output name.
shell_env.set_shell_var(
diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner_plug_in.yaml b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner_plug_in.yaml
index d9eb852e97d9..a0fbf3d2fe16 100644
--- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner_plug_in.yaml
+++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner_plug_in.yaml
@@ -6,7 +6,7 @@
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
{
- "scope": "host-test-win",
- "name": "Windows Host-Based Unit Test Runner",
+ "scope": "host-based-test",
+ "name": "Host-Based Unit Test Runner",
"module": "HostBasedUnitTestRunner"
}
--
2.16.3.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread