Changeset 746 for vendor/current/lib/talloc/testsuite.c
- Timestamp:
- Nov 27, 2012, 4:56:06 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/talloc/testsuite.c
r740 r746 1318 1318 talloc_report_full(root, stdout); 1319 1319 talloc_free(root); 1320 CHECK_BLOCKS("null_context", NULL, 2); 1321 return true; 1322 } 1323 1324 static bool test_free_children(void) 1325 { 1326 void *root; 1327 const char *p1, *p2, *name, *name2; 1328 1329 talloc_enable_null_tracking(); 1330 root = talloc_new(NULL); 1331 p1 = talloc_strdup(root, "foo1"); 1332 p2 = talloc_strdup(p1, "foo2"); 1333 1334 talloc_set_name(p1, "%s", "testname"); 1335 talloc_free_children(p1); 1336 /* check its still a valid talloc ptr */ 1337 talloc_get_size(talloc_get_name(p1)); 1338 if (strcmp(talloc_get_name(p1), "testname") != 0) { 1339 return false; 1340 } 1341 1342 talloc_set_name(p1, "%s", "testname"); 1343 name = talloc_get_name(p1); 1344 talloc_free_children(p1); 1345 /* check its still a valid talloc ptr */ 1346 talloc_get_size(talloc_get_name(p1)); 1347 torture_assert("name", name == talloc_get_name(p1), "name ptr changed"); 1348 torture_assert("namecheck", strcmp(talloc_get_name(p1), "testname") == 0, 1349 "wrong name"); 1350 CHECK_BLOCKS("name1", p1, 2); 1351 1352 /* note that this does not free the old child name */ 1353 talloc_set_name_const(p1, "testname2"); 1354 name2 = talloc_get_name(p1); 1355 /* but this does */ 1356 talloc_free_children(p1); 1357 torture_assert("namecheck", strcmp(talloc_get_name(p1), "testname2") == 0, 1358 "wrong name"); 1359 CHECK_BLOCKS("name1", p1, 1); 1360 1361 talloc_report_full(root, stdout); 1362 talloc_free(root); 1320 1363 return true; 1321 1364 } … … 1380 1423 test_reset(); 1381 1424 ret &= test_rusty(); 1425 test_reset(); 1426 ret &= test_free_children(); 1382 1427 1383 1428 if (ret) {
Note:
See TracChangeset
for help on using the changeset viewer.