Skip to content

Commit

Permalink
HostUnitTestCompilerPlugin: enable single module build test execution (
Browse files Browse the repository at this point in the history
…#219)

Updates the HostUnitTestCompilerPlugin to skip post build
scripts in all scenarios, then find and execute only plugins with the
host-based-test scope. This enables the HostUnitTestCompilerPlugin
to successfully execute and log host-based unit tests for single
module builds and for normal builds.
  • Loading branch information
Javagedes authored and kenlautner committed May 9, 2023
1 parent 85ad5d3 commit 7ba3a80
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

import logging
import os
import re
import sys
from edk2toollib.uefi.edk2.parsers.dsc_parser import DscParser
from edk2toolext.environment.plugintypes.ci_build_plugin import ICiBuildPlugin
from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin
from edk2toolext.environment.plugin_manager import PluginDescriptor
from edk2toolext.environment.uefi_build import UefiBuilder
from edk2toolext import edk2_logging
from edk2toolext.environment.var_dict import VarDict
from edk2toollib.utility_functions import GetHostInfo

Expand Down Expand Up @@ -132,18 +133,32 @@ def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, environment, PLM,
# Skip if there is no intersection between SUPPORTED_ARCHITECTURES and TARGET_ARCHITECTURES
if len(set(SUPPORTED_ARCHITECTURES) & set(TARGET_ARCHITECTURES)) == 0:
tc.SetSkipped()
tc.LogStdError("No supported architecutres to build for host unit tests")
tc.LogStdError("No supported architectures to build for host unit tests")
return -1

uefiBuilder = UefiBuilder()

# do all the steps
# WorkSpace, PackagesPath, PInHelper, PInManager
# Skip post build plugins and run only host-based-tests manually
uefiBuilder.SkipPostBuild = True
ret = uefiBuilder.Go(Edk2pathObj.WorkspacePath, os.pathsep.join(Edk2pathObj.PackagePathList), PLMHelper, PLM)
if ret != 0: # failure:
tc.SetFailed("Compile failed for {0}".format(packagename), "Compile_FAILED")
tc.LogStdError("{0} Compile failed with error code {1} ".format(AP_Path, ret))
return 1

else:
tc.SetSuccess()
return 0
def host_test_filter(plugin: PluginDescriptor) -> bool:
return plugin.descriptor['scope'] == 'host-based-test'

build_plugins = PLM.GetPluginsOfClass(IUefiBuildPlugin)
host_test_plugins = filter(host_test_filter, build_plugins)

for plugin in host_test_plugins:
if plugin.Obj.do_post_build(uefiBuilder) != 0:
tc.SetFailed("Host Based Unit Test failed for {0}".format(packagename), "HostUnitTest_FAILED")
tc.LogStdError("Host Based Unit Test failed for {0} ".format(packagename))
return 1

tc.SetSuccess()
return 0
5 changes: 4 additions & 1 deletion .pytool/Plugin/HostUnitTestCompilerPlugin/Readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Host UnitTest Compiler Plugin

A CiBuildPlugin that compiles the dsc for host based unit test apps.
An IUefiBuildPlugin may be attached to this plugin that will run the unit tests and collect the results after successful compilation.

To run the unit tests and collect the results after successful compilation, The
host UnitTest Compliler Plugin will execute any IUefiBuildPlugin that has the
scope 'host-based-test'.

## Configuration

Expand Down

0 comments on commit 7ba3a80

Please sign in to comment.