[edk2-devel] [PATCH v3 2/3] CryptoPkg: BaseCryptLib: Add unit tests (Host and Shell based)

Michael D Kinney michael.d.kinney at intel.com
Wed Jul 15 19:03:02 UTC 2020


Matt,

For (4) and (5) I think I see the issue.  Host based unit tests always link against the standard C lib for the host OS env and
those are in conflict with some if the wrappers that are provided to make OpenSSL work in an EDK II FW build env.

So the approach to unit testing BaseCryptLib is not to test the actually lib instances used in FW, but to instead test the
source code of the BaseCryptLib that is used by the FW specific instances.  There is a small chance of some differences
that may not be caught, but we can get really good unit test coverage for the source code that is identical in both host
and FW instances.  If this is a correct assessment, you may want to add some of this information to the INF file header of
and source file headers for the unit tests.

Thanks,

Mike

From: Matthew Carlson <matthewfcarlson at gmail.com>
Sent: Wednesday, July 15, 2020 11:16 AM
To: Kinney, Michael D <michael.d.kinney at intel.com>
Cc: devel at edk2.groups.io; Wang, Jian J <jian.j.wang at intel.com>; Lu, XiaoyuX <xiaoyux.lu at intel.com>
Subject: Re: [edk2-devel] [PATCH v3 2/3] CryptoPkg: BaseCryptLib: Add unit tests (Host and Shell based)

Hey Mike,

1. I'll move it for v4.
2. I'll remove that, thanks!
3. I'll fix that as well, good spot.
4. It's mostly the same except for the different CrtWrappers
5. We need a host-specific CrtWrapper since the regular one has a bunch of conflicts with regular C98, but there are a few functions that since we're building no std mode of OpenSSL we still need to provide.
6. That would be my guess- this is largely based on the edk2-staging HBFA branch and I've had to reverse engineer some of the steps for generating the test data. I fixed the instructions.

-Matthew Carlson


On Tue, Jul 14, 2020 at 7:53 PM Kinney, Michael D <michael.d.kinney at intel.com<mailto:michael.d.kinney at intel.com>> wrote:
Hi Matt,

I think the BaseCryptLib unit tests may need some more work.

1) The DSC file for host based tests is in the wrong directory.
   It should be in CryptoPkg/Test to match the MdePkg, MdeModulePkg
   and UnitTestFrameworkPkg location.

2) CryptoPkg/CryptoPkg.dsc includes a reference to the host based
   library UnitTestHostBaseCryptLib.inf.  This should only be
   listed in the host based DSC file.

3) CryptoPkg\Library\BaseCryptLib\UnitTestHostBaseCryptLib.inf
   This file appears to only be for host based tests, but it
   lists compatibility with DXE_DRIVER DXE_CORE UEFI_APPLICATION UEFI_DRIVER
   and does not list HOST_APPLICATION as expected.

4) Why do we need a new lib instance of the BaseCryptLib for
   host based unit testing.  I would think we would want to perform
   unit tests on the BaseCryptLib instances that would actually be
   used in FW components.  Can we update the unit tests to test
   the services provided in the Base, Pei, Runtime, and Smm
   instances of the BaseCryptLib?

5) Why do we need a host based specific version of the CrtWrapper,
   UnitTestHostCrtWrapper.c?

6) The file CryptoPkg/Test/UnitTest/Librray/BaseCryptLib/TestEKUCerts/
   ChainCreationInstructions.txt makes reference to a bintohex tool
   and putting the results in a file called AllTestSignatures.h.
   But I do not see this file in the patch.  Are these instructions
   out of date?

Thanks,

Mike

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62638): https://edk2.groups.io/g/devel/message/62638
Mute This Topic: https://groups.io/mt/75505002/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20200715/561a1d9d/attachment.htm>


More information about the edk2-devel-archive mailing list