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. */
| 479 | * Uses opendir/unlink/rmdir rather than system("rm -rf ...") to avoid |
| 480 | * spawning a shell from the test binary. */ |
| 481 | static void cgroup_test_teardown(const char *root) { |
| 482 | DIR *d = opendir(root); |
| 483 | if (d != NULL) { |
| 484 | struct dirent *ent; |
| 485 | while ((ent = readdir(d)) != NULL) { |
| 486 | if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { |
| 487 | continue; |
| 488 | } |
| 489 | char child[1024]; |
| 490 | snprintf(child, sizeof(child), "%s/%s", root, ent->d_name); |
| 491 | struct stat st; |
| 492 | if (stat(child, &st) == 0 && S_ISDIR(st.st_mode)) { |
| 493 | cgroup_test_teardown(child); /* recurse into subdir */ |
| 494 | } else { |
| 495 | (void)unlink(child); |
| 496 | } |
| 497 | } |
| 498 | closedir(d); |
| 499 | } |
| 500 | (void)rmdir(root); |
| 501 | } |
| 502 | |
| 503 | TEST(cgroup_v2_cpu_quota) { |
| 504 | char root[64]; |