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. */
| 1028 | * Uses opendir/unlink/rmdir rather than system("rm -rf ...") to avoid |
| 1029 | * spawning a shell from the test binary. */ |
| 1030 | static void cgroup_test_teardown(const char *root) { |
| 1031 | DIR *d = opendir(root); |
| 1032 | if (d != NULL) { |
| 1033 | struct dirent *ent; |
| 1034 | while ((ent = readdir(d)) != NULL) { |
| 1035 | if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { |
| 1036 | continue; |
| 1037 | } |
| 1038 | char child[1024]; |
| 1039 | snprintf(child, sizeof(child), "%s/%s", root, ent->d_name); |
| 1040 | struct stat st; |
| 1041 | if (stat(child, &st) == 0 && S_ISDIR(st.st_mode)) { |
| 1042 | cgroup_test_teardown(child); /* recurse into subdir */ |
| 1043 | } else { |
| 1044 | (void)unlink(child); |
| 1045 | } |
| 1046 | } |
| 1047 | closedir(d); |
| 1048 | } |
| 1049 | (void)rmdir(root); |
| 1050 | } |
| 1051 | |
| 1052 | TEST(cgroup_v2_cpu_quota) { |
| 1053 | char root[64]; |
no test coverage detected