/** @file UEFI based application for unit testing the DxeReportStatusCodeLib. Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include #include #include extern "C" { #include #include #include } using namespace testing; class DxeReportStatusCodeLibGeneralTest : public Test { protected: StrictMock BsMock; }; // Verify that ReportStatusCode does not attempt to locate the ReportStatusCode protocol // on demand if not cached. It should only be updated via events outside of a call to // ReportStatusCode to prevent possible TPL inversion. TEST_F (DxeReportStatusCodeLibGeneralTest, DoNotCallLocateProtocol) { EFI_STATUS Status; // LocateProtocol should never be called EXPECT_CALL (BsMock, gBS_LocateProtocol (_, _, _)) .Times (0); Status = ReportStatusCode (EFI_PROGRESS_CODE, 0x0); ASSERT_EQ (Status, EFI_UNSUPPORTED); // We have not located the protocol, so this is expected. } int main ( int argc, char *argv[] ) { testing::InitGoogleTest (&argc, argv); return RUN_ALL_TESTS (); }