Recursively remove a tmp dir created by cgroup_test_setup. Best-effort. * Uses opendir/unlink/rmdir rather than system("rm -rf ...") to avoid * spawning a shell from the test binary. */
| 552 | * Uses opendir/unlink/rmdir rather than system("rm -rf ...") to avoid |
| 553 | * spawning a shell from the test binary. */ |
| 554 | static void cgroup_test_teardown(const char *root) { |
| 555 | DIR *d = opendir(root); |
| 556 | if (d != NULL) { |
| 557 | struct dirent *ent; |
| 558 | while ((ent = readdir(d)) != NULL) { |
| 559 | if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { |
| 560 | continue; |
| 561 | } |
| 562 | char child[1024]; |
| 563 | snprintf(child, sizeof(child), "%s/%s", root, ent->d_name); |
| 564 | struct stat st; |
| 565 | if (stat(child, &st) == 0 && S_ISDIR(st.st_mode)) { |
| 566 | cgroup_test_teardown(child); /* recurse into subdir */ |
| 567 | } else { |
| 568 | (void)unlink(child); |
| 569 | } |
| 570 | } |
| 571 | closedir(d); |
| 572 | } |
| 573 | (void)rmdir(root); |
| 574 | } |
| 575 | |
| 576 | TEST(cgroup_v2_cpu_quota) { |
| 577 | char root[64]; |