xref: /xnu-10002.1.13/tests/nvram_tests/nvram_sys_hidden.c (revision 1031c584a5e37aff177559b9f69dbd3c8c3fd30a)
1 #include <darwintest.h>
2 #include "nvram_helper.h"
3 
4 T_GLOBAL_META(T_META_NAMESPACE("xnu.nvram"),
5     T_META_RADAR_COMPONENT_NAME("xnu"),
6     T_META_RADAR_COMPONENT_VERSION("nvram"));
7 
8 static io_registry_entry_t optionsRef = IO_OBJECT_NULL;
9 
10 // xcrun -sdk macosx.internal make -C tests nvram_sys_hidden && sudo ./tests/build/sym/nvram_sys_hidden
11 
12 // Test that reading of variables with SystemReadHidden bit set using entitlement should succeed
13 T_DECL(TestSysReadHidEntitled, "Test SystemReadHidden bit set variable with entitlement")
14 {
15 #if ((TARGET_OS_OSX) && !(__x86_64__))
16 	const char * varToTest = SystemNVRAMGuidString ":" "testSysReadHidden";
17 
18 	optionsRef = CreateOptionsRef();
19 
20 	TestVarOp(OP_SET, varToTest, DefaultSetVal, KERN_SUCCESS, optionsRef);
21 	TestVarOp(OP_GET, varToTest, NULL, KERN_SUCCESS, optionsRef);
22 	TestVarOp(OP_DEL, varToTest, NULL, KERN_SUCCESS, optionsRef);
23 
24 	ReleaseOptionsRef(optionsRef);
25 #else
26 	T_PASS("Test not supported");
27 #endif /* ((TARGET_OS_OSX) && !(__x86_64__)) */
28 }
29