VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTSystemQueryFirmware.cpp@ 80878

Last change on this file since 80878 was 80860, checked in by vboxsync, 5 years ago

IPRT: Renamed RTSystemFirmwareValueGet() -> RTSystemFirmwareValueQuery().

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: tstRTSystemQueryFirmware.cpp 80860 2019-09-17 13:13:26Z vboxsync $ */
2/** @file
3 * IPRT Testcase - RTSystemQuerFirmware*.
4 */
5
6/*
7 * Copyright (C) 2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include <iprt/system.h>
32
33#include <iprt/assert.h>
34#include <iprt/errcore.h>
35#include <iprt/string.h>
36#include <iprt/test.h>
37
38
39int main()
40{
41 RTTEST hTest;
42 int rc = RTTestInitAndCreate("tstRTSystemQueryFirmware", &hTest);
43 if (rc)
44 return rc;
45 RTTestBanner(hTest);
46
47 RTSYSFWTYPE fwType;
48 rc = RTSystemFirmwareQueryType(&fwType);
49 if (RT_FAILURE(rc))
50 RTTestIFailed("Querying firmware type failed, rc=%Rrc\n", rc);
51
52 switch (fwType)
53 {
54 case RTSYSFWTYPE_BIOS:
55 RTTestPrintf(hTest, RTTESTLVL_INFO, "Firmware type: BIOS (Legacy)\n");
56 break;
57 case RTSYSFWTYPE_UEFI:
58 RTTestPrintf(hTest, RTTESTLVL_INFO, "Firmware type: UEFI\n");
59 break;
60 case RTSYSFWTYPE_UNKNOWN: /* Do not fail on not-implemented platforms. */
61 RT_FALL_THROUGH();
62 default:
63 RTTestPrintf(hTest, RTTESTLVL_INFO, "Unknown firmware type\n");
64 break;
65 }
66
67 PRTSYSFWVALUE pValue;
68 rc = RTSystemFirmwareValueQuery(RTSYSFWPROP_SECURE_BOOT, &pValue);
69 if (RT_SUCCESS(rc))
70 {
71 RTTestPrintf(hTest, RTTESTLVL_INFO, "Secure Boot enabled: %RTbool\n", pValue->u.fVal);
72
73 RTSystemFirmwareValueFree(pValue);
74 }
75 else if (rc != VERR_NOT_SUPPORTED)
76 RTTestIFailed("Querying secure boot failed, rc=%Rrc\n", rc);
77
78 return RTTestSummaryAndDestroy(hTest);
79}
80
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette