]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c
88a3f96305c3775e02a652680502eb17c49e5d06
[mirror_edk2.git] / CryptoPkg / Test / UnitTest / Library / BaseCryptLib / UnitTestMain.c
1 /** @file
2 This is a sample to demostrate the usage of the Unit Test Library that
3 supports the PEI, DXE, SMM, UEFI SHell, and host execution environments.
4
5 Copyright (c) Microsoft Corporation.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9 #include "TestBaseCryptLib.h"
10
11
12 /**
13 Initialize the unit test framework, suite, and unit tests for the
14 sample unit tests and run the unit tests.
15
16 @retval EFI_SUCCESS All test cases were dispatched.
17 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
18 initialize the unit tests.
19 **/
20 EFI_STATUS
21 EFIAPI
22 UefiTestMain (
23 VOID
24 )
25 {
26 EFI_STATUS Status;
27 UNIT_TEST_FRAMEWORK_HANDLE Framework;
28
29 DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION ));
30 CreateUnitTest(UNIT_TEST_NAME, UNIT_TEST_VERSION, &Framework);
31
32 //
33 // Execute the tests.
34 //
35 Status = RunAllTestSuites (Framework);
36
37 if (Framework) {
38 FreeUnitTestFramework (Framework);
39 }
40
41 return Status;
42 }
43
44 /**
45 Standard PEIM entry point for target based unit test execution from PEI.
46 **/
47 EFI_STATUS
48 EFIAPI
49 PeiEntryPoint (
50 IN EFI_PEI_FILE_HANDLE FileHandle,
51 IN CONST EFI_PEI_SERVICES **PeiServices
52 )
53 {
54 return UefiTestMain ();
55 }
56
57 /**
58 Standard UEFI entry point for target based unit test execution from DXE, SMM,
59 UEFI Shell.
60 **/
61 EFI_STATUS
62 EFIAPI
63 DxeEntryPoint (
64 IN EFI_HANDLE ImageHandle,
65 IN EFI_SYSTEM_TABLE *SystemTable
66 )
67 {
68 return UefiTestMain ();
69 }
70
71 /**
72 Standard POSIX C entry point for host based unit test execution.
73 **/
74 int
75 main (
76 int argc,
77 char *argv[]
78 )
79 {
80 return UefiTestMain ();
81 }