From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.92.41.26]) by mx.groups.io with SMTP id smtpd.web11.23828.1586982682012809444 for ; Wed, 15 Apr 2020 13:31:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=ptt4bYvg; spf=pass (domain: outlook.com, ip: 40.92.41.26, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jnEGG98wXVQ+rGTXpnnli3e3hE0yi/83xYF6WMt9k4WJoVxY1xSd+TLDXAe4czfjMVpQyAmw1wA8BllbnVkOge65w8LZPaKEoLSztqChKo5VI4k/wsCV4x3v9qprdSWkYRR5OhCKKhzJesQXspEEOq03Ofnni0agXl3fyYQN6zB5Xx0/knUzUCN0InWLUCbJKH2WJprp/0VH4v7UvZBbiFAKZL0q9N6JMqsUc8tvmsqtIiX1OnNiYiyxopRE/5rbWKijic6Rs+BiMkfpG9qoAa4dxgX9xxn+2Pw3YA1Y3LsfqD/Z4gC7S6MlI4oivqaN0zC+SCbJhx5s73DGsvT+Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GkF+U9kSonVMugVO/FxiFHDG0s+orzjvsOn5CTDKCz0=; b=AnyNlA/D70ewrdcVhZfGfbi/RYX3c7ERmvAxM9PmGIaa2NEwfKR7glE4ErjmoaOjEHMuzwWebtByFJ5ZuIA7/2CBByDRb6nDpTKawQtVumU7MaI1ZBC+1YJ8etlZKHIYogJLIpnhlm+uTetAyIq7PQhSrclgth9Uwote2ProRzTw6twarH+IqcQJkLnWBxlIr0cRpb5ELB7PG9/ZKaNZbFC/+sm0/S/pUI1IqHNQdvt1fscn/Zdb503LZ0zDh1mz2uv2Bo/1UUSt9/iHpfckBV+mseUCclBgLqAgigl+krLgEXioFrYQQWIXZCLwUXIlvoKvQM4n7Gym5r430N8iMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GkF+U9kSonVMugVO/FxiFHDG0s+orzjvsOn5CTDKCz0=; b=ptt4bYvg7Dn3b8BHgVKm1OBt1bEFIfTqZ7SkNKWvX7fufUH8keAF6vK4qrcnCw3LAIfuCtUCWHwRBD8ICbI6+NVDdP8qMk71DmYJHSvzQKRxLqFqv5i8PlHUeqm4VsWlFI9VVydizpNpiL1KvUHchPzcQTRf6uWJTVCktZhciOJ2VOU3B8FVwmnu/fqLUyv3UfTXsVgqvWdsxRb0MW6IuyBO+f4A9eTSDveBV614PF/JdmokQGmu16r/z3BZDPxvnJhK0HiHayDqFXfvgP3+vFdSXjfYHtLpnQxfqKS5GhEcqZMF5+AziWUUWs1pYRDFORA/thOlqtN/QJ47/ePWVg== Received: from DM6NAM10FT048.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::4f) by DM6NAM10HT159.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15; Wed, 15 Apr 2020 20:31:20 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:7e86::45) by DM6NAM10FT048.mail.protection.outlook.com (2a01:111:e400:7e86::204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Wed, 15 Apr 2020 20:31:19 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:ACA2E58BA9AF2BF685E654CF99B2AF4B9CF7D7267D6DB4538F415118DE30F56B;UpperCasedChecksum:5D9BEB2E1A081994F66285C2B8106CA1FE34DA7FD6C3ECFDAC417C4C6D3C3354;SizeAsReceived:7854;Count:49 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3%6]) with mapi id 15.20.2900.028; Wed, 15 Apr 2020 20:31:19 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Bret Barkelew , Michael D Kinney Subject: [PATCH v1 2/2] BaseTools/Plugin: Update HostBasedUnitTestRunner to support Linux Date: Wed, 15 Apr 2020 13:30:39 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 In-Reply-To: <20200415203039.23196-1-michael.kubacki@outlook.com> References: <20200415203039.23196-1-michael.kubacki@outlook.com> X-ClientProxiedBy: MWHPR13CA0013.namprd13.prod.outlook.com (2603:10b6:300:16::23) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200415203039.23196-3-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:3:152b:bb64:f441:78a8) by MWHPR13CA0013.namprd13.prod.outlook.com (2603:10b6:300:16::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.20 via Frontend Transport; Wed, 15 Apr 2020 20:31:17 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200415203039.23196-3-michael.kubacki@outlook.com> X-TMN: [ZTtG6SVthd0eCHXUo597l4q1tY1SRhQb9WTGzoWvzF4T1H6F88iAZFJ4IKQKtyMw] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 2147c817-c0b7-4fcc-6372-08d7e17bf374 X-MS-TrafficTypeDiagnostic: DM6NAM10HT159: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QfqK5FODn8LykP43OPz2QByw/a8epOIM5c1wvDn1AAjWCfJ7L54uMNr0SHzcJFd89qPmPzczgaJKLpFv6uN7F9E7LRf2dJfJiCH0wqLZgYMleMZzGpIvEjvY5IA9frpPPd6YWaWqZSca5O5jdMdPqaY1KYu5oR5YQ5feYeHDq9GRU9WY+zojAQ4EJTlSuMYoxYtQtuAvP1UJBGCZKoY0dsW0YAh1sIVq1/VP9JVHXAo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR07MB3440.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: hstlsfNp0Q3mtHBb9UjscHewh7lgxHu1AZNKlZF6Shj9zM0gmNOZTliiRIXv1sfi3BP4QX3ZicOQqHiiY0oDQUGlE+SWbEmjsbNYeiHg11mBtsUk4ez17Ir0YkRHcFkx/PRMExlUILjRfhFQDZE2MKT1CInuvdlAKIKdaap4VCxUd9YfsQVFDsJdIJJFXcr2XJSSfzz0st9DHn53LEKTkw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2147c817-c0b7-4fcc-6372-08d7e17bf374 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2020 20:31:19.5202 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM10HT159 Content-Type: text/plain From: Sean Brogan 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 Cc: Liming Gao Cc: Bret Barkelew Cc: Michael D Kinney Signed-off-by: Sean Brogan Signed-off-by: Michael Kubacki --- 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