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. */
| 997 | * Uses opendir/unlink/rmdir rather than system("rm -rf ...") to avoid |
| 998 | * spawning a shell from the test binary. */ |
| 999 | static void cgroup_test_teardown(const char *root) { |
| 1000 | DIR *d = opendir(root); |
| 1001 | if (d != NULL) { |
| 1002 | struct dirent *ent; |
| 1003 | while ((ent = readdir(d)) != NULL) { |
| 1004 | if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { |
| 1005 | continue; |
| 1006 | } |
| 1007 | char child[1024]; |
| 1008 | snprintf(child, sizeof(child), "%s/%s", root, ent->d_name); |
| 1009 | struct stat st; |
| 1010 | if (stat(child, &st) == 0 && S_ISDIR(st.st_mode)) { |
| 1011 | cgroup_test_teardown(child); /* recurse into subdir */ |
| 1012 | } else { |
| 1013 | (void)unlink(child); |
| 1014 | } |
| 1015 | } |
| 1016 | closedir(d); |
| 1017 | } |
| 1018 | (void)rmdir(root); |
| 1019 | } |
| 1020 | |
| 1021 | TEST(cgroup_v2_cpu_quota) { |
| 1022 | char root[64]; |