Changeset 46781 in vbox
- Timestamp:
- Jun 25, 2013 2:04:17 PM (11 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/CFGM.cpp
r45189 r46781 66 66 #include <VBox/log.h> 67 67 #include <iprt/assert.h> 68 #include <iprt/mem.h> 68 69 #include <iprt/param.h> 69 70 #include <iprt/string.h> … … 81 82 static int cfgmR3InsertLeaf(PCFGMNODE pNode, const char *pszName, PCFGMLEAF *ppLeaf); 82 83 static void cfgmR3RemoveLeaf(PCFGMNODE pNode, PCFGMLEAF pLeaf); 83 static void cfgmR3FreeValue(PCFGMLEAF pLeaf); 84 static void cfgmR3FreeValue(PVM pVM, PCFGMLEAF pLeaf); 85 86 87 /** 88 * Allocator wrapper. 89 * 90 * @returns Pointer to the allocated memory, NULL on failure. 91 * @param pVM The VM handle, if tree associated with one. 92 * @param enmTag The allocation tag. 93 * @param cb The size of the allocation. 94 */ 95 static void *cfgmR3MemAlloc(PVM pVM, MMTAG enmTag, size_t cb) 96 { 97 if (pVM) 98 return MMR3HeapAlloc(pVM, enmTag, cb); 99 return RTMemAlloc(cb); 100 } 101 102 103 /** 104 * Free wrapper. 105 * 106 * @returns Pointer to the allocated memory, NULL on failure. 107 * @param pVM The VM handle, if tree associated with one. 108 * @param pv The memory block to free. 109 */ 110 static void cfgmR3MemFree(PVM pVM, void *pv) 111 { 112 if (pVM) 113 MMR3HeapFree(pv); 114 else 115 RTMemFree(pv); 116 } 117 118 119 /** 120 * String allocator wrapper. 121 * 122 * @returns Pointer to the allocated memory, NULL on failure. 123 * @param pVM The VM handle, if tree associated with one. 124 * @param enmTag The allocation tag. 125 * @param cbString The size of the allocation, terminator included. 126 */ 127 static char *cfgmR3StrAlloc(PVM pVM, MMTAG enmTag, size_t cbString) 128 { 129 if (pVM) 130 return (char *)MMR3HeapAlloc(pVM, enmTag, cbString); 131 return (char *)RTStrAlloc(cbString); 132 } 133 134 135 /** 136 * String free wrapper. 137 * 138 * @returns Pointer to the allocated memory, NULL on failure. 139 * @param pVM The VM handle, if tree associated with one. 140 * @param pszString The memory block to free. 141 */ 142 static void cfgmR3StrFree(PVM pVM, char *pszString) 143 { 144 if (pVM) 145 MMR3HeapFree(pszString); 146 else 147 RTStrFree(pszString); 148 } 149 150 151 /** 152 * Frees one node, leaving any children or leaves to the caller. 153 * 154 * @param pNode The node structure to free. 155 */ 156 static void cfgmR3FreeNodeOnly(PCFGMNODE pNode) 157 { 158 pNode->pFirstLeaf = NULL; 159 pNode->pFirstChild = NULL; 160 pNode->pNext = NULL; 161 pNode->pPrev = NULL; 162 if (!pNode->pVM) 163 RTMemFree(pNode); 164 else 165 { 166 pNode->pVM = NULL; 167 MMR3HeapFree(pNode); 168 } 169 } 170 84 171 85 172 … … 1203 1290 * @returns Pointer to the root node, NULL on error (out of memory or invalid 1204 1291 * VM handle). 1205 * @param pUVM The user mode VM handle. 1292 * @param pUVM The user mode VM handle. For testcase (and other 1293 * purposes, NULL can be used. However, the resulting 1294 * tree cannot be inserted into a tree that has a 1295 * non-NULL value. Using NULL can be usedful for 1296 * testcases and similar, non VMM uses. 1206 1297 */ 1207 1298 VMMR3DECL(PCFGMNODE) CFGMR3CreateTree(PUVM pUVM) 1208 1299 { 1209 UVM_ASSERT_VALID_EXT_RETURN(pUVM, NULL); 1210 VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, NULL); 1211 1212 PCFGMNODE pNew = (PCFGMNODE)MMR3HeapAllocU(pUVM, MM_TAG_CFGM, sizeof(*pNew)); 1300 if (pUVM) 1301 { 1302 UVM_ASSERT_VALID_EXT_RETURN(pUVM, NULL); 1303 VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, NULL); 1304 } 1305 1306 PCFGMNODE pNew; 1307 if (pUVM) 1308 pNew = (PCFGMNODE)MMR3HeapAllocU(pUVM, MM_TAG_CFGM, sizeof(*pNew)); 1309 else 1310 pNew = (PCFGMNODE)RTMemAlloc(sizeof(*pNew)); 1213 1311 if (pNew) 1214 1312 { … … 1218 1316 pNew->pFirstChild = NULL; 1219 1317 pNew->pFirstLeaf = NULL; 1220 pNew->pVM = pUVM ->pVM;1318 pNew->pVM = pUVM ? pUVM->pVM : NULL; 1221 1319 pNew->fRestrictedRoot = false; 1222 1320 pNew->cchName = 0; … … 1242 1340 * Create a new tree. 1243 1341 */ 1244 PCFGMNODE pNewRoot = CFGMR3CreateTree(pRoot->pVM ->pUVM);1342 PCFGMNODE pNewRoot = CFGMR3CreateTree(pRoot->pVM ? pRoot->pVM->pUVM : NULL); 1245 1343 if (!pNewRoot) 1246 1344 return VERR_NO_MEMORY; … … 1352 1450 AssertReturn(pNode != pSubTree, VERR_INVALID_PARAMETER); 1353 1451 AssertReturn(!pSubTree->pParent, VERR_INVALID_PARAMETER); 1354 AssertReturn(p SubTree->pVM, VERR_INVALID_PARAMETER);1452 AssertReturn(pNode->pVM == pSubTree->pVM, VERR_INVALID_PARAMETER); 1355 1453 Assert(!pSubTree->pNext); 1356 1454 Assert(!pSubTree->pPrev); … … 1376 1474 1377 1475 /* free the old subtree root */ 1378 pSubTree->pVM = NULL; 1379 pSubTree->pFirstLeaf = NULL; 1380 pSubTree->pFirstChild = NULL; 1381 MMR3HeapFree(pSubTree); 1476 cfgmR3FreeNodeOnly(pSubTree); 1382 1477 } 1383 1478 return rc; … … 1407 1502 AssertReturn(pRoot != pNewRoot, VERR_INVALID_PARAMETER); 1408 1503 AssertReturn(!pNewRoot->pParent, VERR_INVALID_PARAMETER); 1409 AssertReturn(pNewRoot->pVM, VERR_INVALID_PARAMETER);1410 1504 AssertReturn(pNewRoot->pVM == pRoot->pVM, VERR_INVALID_PARAMETER); 1411 1505 AssertReturn(!pNewRoot->pNext, VERR_INVALID_PARAMETER); … … 1429 1523 pChild->pParent = pRoot; 1430 1524 1431 pNewRoot->pFirstLeaf = NULL; 1432 pNewRoot->pFirstChild = NULL; 1433 pNewRoot->pVM = NULL; 1434 MMR3HeapFree(pNewRoot); 1525 cfgmR3FreeNodeOnly(pNewRoot); 1435 1526 1436 1527 return VINF_SUCCESS; … … 1644 1735 * Allocate and init node. 1645 1736 */ 1646 PCFGMNODE pNew = (PCFGMNODE) MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM, sizeof(*pNew) + cchName);1737 PCFGMNODE pNew = (PCFGMNODE)cfgmR3MemAlloc(pNode->pVM, MM_TAG_CFGM, sizeof(*pNew) + cchName); 1647 1738 if (pNew) 1648 1739 { … … 1786 1877 * Allocate and init node. 1787 1878 */ 1788 PCFGMLEAF pNew = (PCFGMLEAF) MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM, sizeof(*pNew) + cchName);1879 PCFGMLEAF pNew = (PCFGMLEAF)cfgmR3MemAlloc(pNode->pVM, MM_TAG_CFGM, sizeof(*pNew) + cchName); 1789 1880 if (pNew) 1790 1881 { … … 1856 1947 1857 1948 /* 1858 * Free ourselves. (bit of paranoia first)1949 * Free ourselves. 1859 1950 */ 1860 pNode->pVM = NULL; 1861 pNode->pNext = NULL; 1862 pNode->pPrev = NULL; 1863 pNode->pParent = NULL; 1864 MMR3HeapFree(pNode); 1951 cfgmR3FreeNodeOnly(pNode); 1865 1952 } 1866 1953 } … … 1890 1977 * Free value and node. 1891 1978 */ 1892 cfgmR3FreeValue(p Leaf);1979 cfgmR3FreeValue(pNode->pVM, pLeaf); 1893 1980 pLeaf->pNext = NULL; 1894 1981 pLeaf->pPrev = NULL; 1895 MMR3HeapFree(pLeaf);1982 cfgmR3MemFree(pNode->pVM, pLeaf); 1896 1983 } 1897 1984 } … … 1904 1991 * The caller must either free the leaf or assign a new value to it. 1905 1992 * 1993 * @param pVM Used to select the heap. 1906 1994 * @param pLeaf Pointer to the leaf which value should be free. 1907 1995 */ 1908 static void cfgmR3FreeValue(P CFGMLEAF pLeaf)1996 static void cfgmR3FreeValue(PVM pVM, PCFGMLEAF pLeaf) 1909 1997 { 1910 1998 if (pLeaf) … … 1913 2001 { 1914 2002 case CFGMVALUETYPE_BYTES: 1915 MMR3HeapFree(pLeaf->Value.Bytes.pau8);2003 cfgmR3MemFree(pVM, pLeaf->Value.Bytes.pau8); 1916 2004 pLeaf->Value.Bytes.pau8 = NULL; 1917 2005 pLeaf->Value.Bytes.cb = 0; … … 1919 2007 1920 2008 case CFGMVALUETYPE_STRING: 1921 MMR3HeapFree(pLeaf->Value.String.psz);2009 cfgmR3StrFree(pVM, pLeaf->Value.String.psz); 1922 2010 pLeaf->Value.String.psz = NULL; 1923 2011 pLeaf->Value.String.cb = 0; … … 1974 2062 * Allocate string object first. 1975 2063 */ 1976 char *pszStringCopy = (char *) MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_STRING, cchString + 1);2064 char *pszStringCopy = (char *)cfgmR3StrAlloc(pNode->pVM, MM_TAG_CFGM_STRING, cchString + 1); 1977 2065 if (pszStringCopy) 1978 2066 { … … 1992 2080 } 1993 2081 else 1994 MMR3HeapFree(pszStringCopy);2082 cfgmR3StrFree(pNode->pVM, pszStringCopy); 1995 2083 } 1996 2084 else … … 2037 2125 * Allocate string object first. 2038 2126 */ 2039 char *pszString = MMR3HeapAPrintfVU(pNode->pVM->pUVM, MM_TAG_CFGM_STRING, pszFormat, va); 2127 char *pszString; 2128 if (!pNode->pVM) 2129 pszString = RTStrAPrintf2(pszFormat, va); 2130 else 2131 pszString = MMR3HeapAPrintfVU(pNode->pVM->pUVM, MM_TAG_CFGM_STRING, pszFormat, va); 2040 2132 if (pszString) 2041 2133 { … … 2052 2144 } 2053 2145 else 2054 MMR3HeapFree(pszString);2146 cfgmR3StrFree(pNode->pVM, pszString); 2055 2147 } 2056 2148 else … … 2124 2216 * Allocate string object first. 2125 2217 */ 2126 void *pvCopy = MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_STRING, cbBytes);2218 void *pvCopy = cfgmR3MemAlloc(pNode->pVM, MM_TAG_CFGM_STRING, cbBytes); 2127 2219 if (pvCopy || !cbBytes) 2128 2220 { … … 2140 2232 pLeaf->Value.Bytes.pau8 = (uint8_t *)pvCopy; 2141 2233 } 2234 else 2235 cfgmR3MemFree(pNode->pVM, pvCopy); 2142 2236 } 2143 2237 else … … 2918 3012 * @param pszName Value name. This value must be of zero terminated character string type. 2919 3013 * @param ppszString Where to store the string pointer. 2920 * Free this using MMR3HeapFree(). 3014 * Free this using MMR3HeapFree() (or RTStrFree if not 3015 * associated with a pUVM - see CFGMR3CreateTree). 2921 3016 */ 2922 3017 VMMR3DECL(int) CFGMR3QueryStringAlloc(PCFGMNODE pNode, const char *pszName, char **ppszString) … … 2926 3021 if (RT_SUCCESS(rc)) 2927 3022 { 2928 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbString);3023 char *pszString = cfgmR3StrAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbString); 2929 3024 if (pszString) 2930 3025 { … … 2933 3028 *ppszString = pszString; 2934 3029 else 2935 MMR3HeapFree(pszString);3030 cfgmR3StrFree(pNode->pVM, pszString); 2936 3031 } 2937 3032 else … … 2953 3048 * @param pszName Value name. This value must be of zero terminated character string type. 2954 3049 * @param ppszString Where to store the string pointer. Not set on failure. 2955 * Free this using MMR3HeapFree(). 3050 * Free this using MMR3HeapFree() (or RTStrFree if not 3051 * associated with a pUVM - see CFGMR3CreateTree). 2956 3052 * @param pszDef The default return value. This can be NULL. 2957 3053 */ … … 2971 3067 { 2972 3068 size_t const cbSrc = pLeaf->Value.String.cb; 2973 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbSrc);3069 char *pszString = cfgmR3StrAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbSrc); 2974 3070 if (pszString) 2975 3071 { … … 2988 3084 *ppszString = NULL; 2989 3085 else 2990 *ppszString = MMR3HeapStrDup(pNode->pVM, MM_TAG_CFGM_USER, pszDef); 3086 { 3087 size_t const cbDef = strlen(pszDef) + 1; 3088 *ppszString = cfgmR3StrAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbDef); 3089 memcpy(*ppszString, pszDef, cbDef); 3090 } 2991 3091 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT) 2992 3092 rc = VINF_SUCCESS; -
trunk/src/VBox/VMM/testcase/tstCFGM.cpp
r44528 r46781 31 31 #include <iprt/initterm.h> 32 32 #include <iprt/stream.h> 33 #include <iprt/mem.h> 33 34 #include <iprt/string.h> 34 35 36 #include <iprt/test.h> 37 38 39 static void doGeneralTests(PCFGMNODE pRoot) 40 { 41 /* test multilevel node creation */ 42 PCFGMNODE pChild = NULL; 43 RTTESTI_CHECK_RC_RETV(CFGMR3InsertNode(pRoot, "First/Second/Third//Final", &pChild), VINF_SUCCESS); 44 RTTESTI_CHECK_RETV(RT_VALID_PTR(pChild)); 45 RTTESTI_CHECK(CFGMR3GetChild(pRoot, "First/Second/Third/Final") == pChild); 46 47 /* 48 * Boolean queries. 49 */ 50 RTTESTI_CHECK_RC(CFGMR3InsertInteger(pChild, "BoolValue", 1), VINF_SUCCESS); 51 bool f = false; 52 RTTESTI_CHECK_RC(CFGMR3QueryBool(pChild, "BoolValue", &f), VINF_SUCCESS); 53 RTTESTI_CHECK(f == true); 54 55 RTTESTI_CHECK_RC(CFGMR3QueryBool(pRoot, "BoolValue", &f), VERR_CFGM_VALUE_NOT_FOUND); 56 RTTESTI_CHECK_RC(CFGMR3QueryBool(NULL, "BoolValue", &f), VERR_CFGM_NO_PARENT); 57 58 RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(pChild, "ValueNotFound", &f, true), VINF_SUCCESS); 59 RTTESTI_CHECK(f == true); 60 RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(pChild, "ValueNotFound", &f, false), VINF_SUCCESS); 61 RTTESTI_CHECK(f == false); 62 63 RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(NULL, "BoolValue", &f, true), VINF_SUCCESS); 64 RTTESTI_CHECK(f == true); 65 RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(NULL, "BoolValue", &f, false), VINF_SUCCESS); 66 RTTESTI_CHECK(f == false); 67 68 } 69 70 71 72 static void doTestsOnDefaultValues(PCFGMNODE pRoot) 73 { 74 /* integer */ 75 uint64_t u64; 76 RTTESTI_CHECK_RC(CFGMR3QueryU64(pRoot, "RamSize", &u64), VINF_SUCCESS); 77 78 size_t cb = 0; 79 RTTESTI_CHECK_RC(CFGMR3QuerySize(pRoot, "RamSize", &cb), VINF_SUCCESS); 80 RTTESTI_CHECK(cb == sizeof(uint64_t)); 81 82 /* string */ 83 char *pszName = NULL; 84 RTTESTI_CHECK_RC(CFGMR3QueryStringAlloc(pRoot, "Name", &pszName), VINF_SUCCESS); 85 RTTESTI_CHECK_RC(CFGMR3QuerySize(pRoot, "Name", &cb), VINF_SUCCESS); 86 RTTESTI_CHECK(cb == strlen(pszName) + 1); 87 MMR3HeapFree(pszName); 88 } 89 90 91 static void doInVmmTests(RTTEST hTest) 92 { 93 /* 94 * Create empty VM structure and init SSM. 95 */ 96 int rc = SUPR3Init(NULL); 97 if (RT_FAILURE(rc)) 98 { 99 RTTestSkipped(hTest, "SUPR3Init failed with rc=%Rrc", rc); 100 return; 101 } 102 103 PVM pVM; 104 RTTESTI_CHECK_RC_RETV(SUPR3PageAlloc(RT_ALIGN_Z(sizeof(*pVM), PAGE_SIZE) >> PAGE_SHIFT, (void **)&pVM), VINF_SUCCESS); 105 106 107 PUVM pUVM = (PUVM)RTMemPageAlloc(sizeof(*pUVM)); 108 pUVM->u32Magic = UVM_MAGIC; 109 pUVM->pVM = pVM; 110 pVM->pUVM = pUVM; 111 112 /* 113 * Do the testing. 114 */ 115 RTTESTI_CHECK_RC_RETV(STAMR3InitUVM(pUVM), VINF_SUCCESS); 116 RTTESTI_CHECK_RC_RETV(MMR3InitUVM(pUVM), VINF_SUCCESS); 117 RTTESTI_CHECK_RC_RETV(CFGMR3Init(pVM, NULL, NULL), VINF_SUCCESS); 118 RTTESTI_CHECK_RETV(CFGMR3GetRoot(pVM) != NULL); 119 120 doTestsOnDefaultValues(CFGMR3GetRoot(pVM)); 121 doGeneralTests(CFGMR3GetRoot(pVM)); 122 123 124 /* done */ 125 RTTESTI_CHECK_RC_RETV(CFGMR3Term(pVM), VINF_SUCCESS); 126 } 127 128 129 static void doStandaloneTests(void) 130 { 131 RTTestISub("Standalone"); 132 PCFGMNODE pRoot;; 133 RTTESTI_CHECK_RETV((pRoot = CFGMR3CreateTree(NULL)) != NULL); 134 doGeneralTests(pRoot); 135 } 35 136 36 137 int main() … … 39 140 * Init runtime. 40 141 */ 142 RTTEST hTest; 41 143 RTR3InitExeNoArguments(RTR3INIT_FLAGS_SUPLIB); 144 RTEXITCODE rcExit = RTTestInitAndCreate("tstCFGM", &hTest); 145 if (rcExit != RTEXITCODE_SUCCESS) 146 return rcExit; 42 147 43 /* 44 * Create empty VM structure and init SSM. 45 */ 46 PVM pVM; 47 int rc = SUPR3Init(NULL); 48 if (RT_SUCCESS(rc)) 49 rc = SUPR3PageAlloc(RT_ALIGN_Z(sizeof(*pVM), PAGE_SIZE) >> PAGE_SHIFT, (void **)&pVM); 50 if (RT_FAILURE(rc)) 51 { 52 RTPrintf("Fatal error: SUP Failure! rc=%Rrc\n", rc); 53 return 1; 54 } 148 doInVmmTests(hTest); 149 doStandaloneTests(); 55 150 56 static UVM s_UVM; 57 PUVM pUVM = &s_UVM; 58 pUVM->pVM = pVM; 59 pVM->pUVM = pUVM; 151 return RTTestSummaryAndDestroy(hTest); 152 } 60 153 61 rc = STAMR3InitUVM(pUVM);62 if (RT_FAILURE(rc))63 {64 RTPrintf("FAILURE: STAMR3Init failed. rc=%Rrc\n", rc);65 return 1;66 }67 68 rc = MMR3InitUVM(pUVM);69 if (RT_FAILURE(rc))70 {71 RTPrintf("FAILURE: STAMR3Init failed. rc=%Rrc\n", rc);72 return 1;73 }74 75 rc = CFGMR3Init(pVM, NULL, NULL);76 if (RT_FAILURE(rc))77 {78 RTPrintf("FAILURE: CFGMR3Init failed. rc=%Rrc\n", rc);79 return 1;80 }81 82 if (!CFGMR3GetRoot(pVM))83 {84 RTPrintf("FAILURE: CFGMR3GetRoot failed\n");85 return 1;86 }87 88 /* integer */89 uint64_t u64;90 rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &u64);91 if (RT_FAILURE(rc))92 {93 RTPrintf("FAILURE: CFGMR3QueryU64(,\"RamSize\",) failed. rc=%Rrc\n", rc);94 return 1;95 }96 97 size_t cb;98 rc = CFGMR3QuerySize(CFGMR3GetRoot(pVM), "RamSize", &cb);99 if (RT_FAILURE(rc))100 {101 RTPrintf("FAILURE: CFGMR3QuerySize(,\"RamSize\",) failed. rc=%Rrc\n", rc);102 return 1;103 }104 if (cb != sizeof(uint64_t))105 {106 RTPrintf("FAILURE: Incorrect valuesize %d for \"RamSize\" value.\n", cb);107 return 1;108 }109 110 /* string */111 char *pszName = NULL;112 rc = CFGMR3QueryStringAlloc(CFGMR3GetRoot(pVM), "Name", &pszName);113 if (RT_FAILURE(rc))114 {115 RTPrintf("FAILURE: CFGMR3QueryStringAlloc(,\"Name\" failed. rc=%Rrc\n", rc);116 return 1;117 }118 119 rc = CFGMR3QuerySize(CFGMR3GetRoot(pVM), "Name", &cb);120 if (RT_FAILURE(rc))121 {122 RTPrintf("FAILURE: CFGMR3QuerySize(,\"RamSize\",) failed. rc=%Rrc\n", rc);123 return 1;124 }125 if (cb != strlen(pszName) + 1)126 {127 RTPrintf("FAILURE: Incorrect valuesize %d for \"Name\" value '%s'.\n", cb, pszName);128 return 1;129 }130 MMR3HeapFree(pszName);131 132 133 /* test multilevel node creation */134 PCFGMNODE pChild = NULL;135 rc = CFGMR3InsertNode(CFGMR3GetRoot(pVM), "First/Second/Third//Final", &pChild);136 if (RT_FAILURE(rc))137 {138 RTPrintf("FAILURE: CFGMR3InsertNode(,\"First/Second/Third//Final\" failed. rc=%Rrc\n", rc);139 return 1;140 }141 rc = CFGMR3InsertInteger(pChild, "BoolValue", 1);142 if (RT_FAILURE(rc))143 {144 RTPrintf("FAILURE: CFGMR3InsertInteger(,\"BoolValue\", 1) failed. rc=%Rrc\n", rc);145 return 1;146 }147 PCFGMNODE pNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "First/Second/Third/Final");148 if (pNode != pChild)149 {150 RTPrintf("FAILURE: CFGMR3GetChild(,\"First/Second/Third/Final/BoolValue\") failed. pNode=%p expected %p\n", pNode, pChild);151 return 1;152 }153 bool f = false;154 rc = CFGMR3QueryBool(pNode, "BoolValue", &f);155 if (RT_FAILURE(rc) || !f)156 {157 RTPrintf("FAILURE: CFGMR3QueryBool(,\"BoolValue\",) failed. rc=%Rrc f=%d\n", rc, f);158 return 1;159 }160 161 162 /* done */163 rc = CFGMR3Term(pVM);164 if (RT_FAILURE(rc))165 {166 RTPrintf("FAILURE: CFGMR3QueryU64(,\"RamSize\" failed. rc=%Rrc\n", rc);167 return 1;168 }169 170 RTPrintf("tstCFGM: SUCCESS\n");171 return rc;172 }
Note:
See TracChangeset
for help on using the changeset viewer.