MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cgroup_test_teardown

Function cgroup_test_teardown

tests/test_platform.c:1030–1050  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

1028 * Uses opendir/unlink/rmdir rather than system("rm -rf ...") to avoid
1029 * spawning a shell from the test binary. */
1030static 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
1052TEST(cgroup_v2_cpu_quota) {
1053 char root[64];

Callers 1

test_platform.cFile · 0.85

Calls 3

opendirFunction · 0.85
readdirFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected