From 12e2d47a1c318d13e43c19d0afd1cd3401e03a8d Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Wed, 3 Apr 2013 16:09:53 -0400 Subject: [PATCH] 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 --- tests/common/config.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/common/config.c b/tests/common/config.c index faefc0058..6a0e3e1ef 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); } } -- 2.39.5