From: Marc Dionne Date: Wed, 3 Apr 2013 20:09:53 +0000 (-0400) Subject: tests: Improve afstest_UnlinkTestConfig cleanup X-Git-Tag: openafs-stable-1_8_0pre1~1136 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=12e2d47a1c318d13e43c19d0afd1cd3401e03a8d tests: Improve afstest_UnlinkTestConfig cleanup Make afstest_UnlinkTestConfig clean up and remove the specified directory regardless of which files are present. This means the function no longer has to track the current state of which files may be present as tests are added and modified. A sanity check is added to prevent damage in case the function is called for an inappropriate directory. As before, no cleaning is done if the test is run outside of a "make check". Change-Id: Idd092040496aaa2566c8693496fefd7d6f247565 Reviewed-on: http://gerrit.openafs.org/9703 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- diff --git a/tests/common/config.c b/tests/common/config.c index faefc00..6a0e3e1 100644 --- a/tests/common/config.c +++ b/tests/common/config.c @@ -121,14 +121,18 @@ fail: void afstest_UnlinkTestConfig(char *dir) { + DIR *dirp; + struct dirent *de; + + /* Sanity check, only zap directories that look like ours */ + if (!strstr(dir, "afs_")) + return; if (getenv("MAKECHECK") != NULL) { - unlinkConfigFile(dir, "KeyFile"); - unlinkConfigFile(dir, "KeyFileExt"); - unlinkConfigFile(dir, "CellServDB"); - unlinkConfigFile(dir, "ThisCell"); - unlinkConfigFile(dir, "UserList"); - unlinkConfigFile(dir, "krb.conf"); - unlinkConfigFile(dir, "krb.excl"); + dirp = opendir(dir); + if (!dirp) + return; + while ((de = readdir(dirp))) + unlinkConfigFile(dir, de->d_name); rmdir(dir); } }