]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
tests: cleanup temporary files
authorMarc Dionne <marc.c.dionne@gmail.com>
Wed, 19 Sep 2012 23:14:31 +0000 (19:14 -0400)
committerDerrick Brashear <shadow@your-file-system.com>
Tue, 30 Oct 2012 10:27:16 +0000 (03:27 -0700)
Call the configuration directory cleanup function before exiting
so there are no files left behind, even in case of error.

Add KeyFileExt to the list of files that are removed.

Change-Id: Ie795bef0d44609b36950970244c02a6c6da1a843
Reviewed-on: http://gerrit.openafs.org/8142
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
tests/Makefile.in
tests/auth/authcon-t.c
tests/auth/superuser-t.c
tests/common/config.c
tests/volser/vos-t.c

index d6d221d5a625314ad74a3ebeafa9b1214240d972..d0708514853a5cac051ae921fdfe7458467e4d0b 100644 (file)
@@ -23,7 +23,7 @@ runtests.o: $(srcdir)/runtests.c
 check test tests: runtests
        @for A in $(SUBDIRS); do cd $$A && $(MAKE) $@ && cd .. || exit 1; done
        ./libwrap @TOP_OBJDIR@/lib \
-           ./runtests $(abs_top_srcdir)/tests/TESTS
+           MAKECHECK=1 ./runtests $(abs_top_srcdir)/tests/TESTS
 
 install:
 
index 359b3a3f065879c408b5ce1b4e5d26c2502e4f99..46cf3c949c9090b912adbbab002cf64d6b90fde2 100644 (file)
@@ -49,6 +49,7 @@ main(int argc, char **argv)
     int secIndex;
     int numClasses;
     struct afsconf_typedKey *key;
+    int code = 0;
 
     plan(9);
     dirname = afstest_BuildTestConfig();
@@ -56,7 +57,8 @@ main(int argc, char **argv)
     dir = afsconf_Open(dirname);
     if (dir == NULL) {
        fprintf(stderr, "Unable to configure directory.\n");
-        exit(1);
+       code = 1;
+       goto out;
     }
 
     rx_Init(0);
@@ -87,5 +89,7 @@ main(int argc, char **argv)
     afsconf_GetLatestKeyByTypes(dir, afsconf_rxkad, 0, &key);
     ok(afsconf_UpToDate(dir), "afsconf_GetLatestKeyByTypes resest UpToDate");
 
-    return 0;
+out:
+    afstest_UnlinkTestConfig(dirname);
+    return code;
 }
index 095abf1945a480a40278ff183150717f417fbff8..03f67d918a17549497dc560a89e570497560a4a6 100644 (file)
@@ -371,6 +371,7 @@ int main(int argc, char **argv)
     char *dirname;
     int serverPid, clientPid, waited, stat;
     int code;
+    int ret = 0;
 
     /* Start the client and the server if requested */
 
@@ -397,13 +398,15 @@ int main(int argc, char **argv)
     dir = afsconf_Open(dirname);
     if (dir == NULL) {
        fprintf(stderr, "Unable to configure directory.\n");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     code = afstest_AddDESKeyFile(dir);
     if (code) {
        afs_com_err("superuser-t", code, "while adding new key\n");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     printf("Config directory is %s\n", dirname);
@@ -412,13 +415,15 @@ int main(int argc, char **argv)
         /* Bang */
     } else if (serverPid == 0) {
         execl(argv[0], argv[0], "-server", dirname, NULL);
-        exit(1);
+       ret = 1;
+       goto out;
     }
     clientPid = fork();
     if (clientPid == -1) {
         kill(serverPid, SIGTERM);
         waitpid(serverPid, &stat, 0);
-        exit(1);
+       ret = 1;
+       goto out;
     } else if (clientPid == 0) {
         execl(argv[0], argv[0], "-client", dirname, NULL);
     }
@@ -434,9 +439,9 @@ int main(int argc, char **argv)
     }
     waitpid(0, &stat, 0);
 
+out:
     /* Client and server are both done, so cleanup after everything */
+    afstest_UnlinkTestConfig(dirname);
 
-    /* unlinkTestConfig(dirname); */
-
-    return 0;
+    return ret;
 }
index aced66b432cfc712c55a4b1ea79648c83468b1b0..4783753ddf69362d49361a93e5f33e9bf7141fa7 100644 (file)
@@ -120,13 +120,16 @@ fail:
 void
 afstest_UnlinkTestConfig(char *dir)
 {
-    unlinkConfigFile(dir, "KeyFile");
-    unlinkConfigFile(dir, "CellServDB");
-    unlinkConfigFile(dir, "ThisCell");
-    unlinkConfigFile(dir, "UserList");
-    unlinkConfigFile(dir, "krb.conf");
-    unlinkConfigFile(dir, "krb.excl");
-    rmdir(dir);
+    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");
+       rmdir(dir);
+    }
 }
 
 int
index daecfbfa947a9b1c5216892bc663bae7ee9f6f68..e3c499cca26efd940fb40021f61665452a1b8df0 100644 (file)
@@ -93,6 +93,7 @@ main(int argc, char **argv)
     pid_t serverPid;
     struct rx_securityClass *secClass;
     struct ubik_client *ubikClient = NULL;
+    int ret = 0;
 
     plan(6);
 
@@ -108,13 +109,15 @@ main(int argc, char **argv)
     code = afstest_AddDESKeyFile(dir);
     if (code) {
        afs_com_err("vos-t", code, "while adding test DES keyfile");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     code = afstest_StartVLServer(dirname, &serverPid);
     if (code) {
        afs_com_err("vos-t", code, "while starting the vlserver");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     /* Let it figure itself out ... */
@@ -123,7 +126,8 @@ main(int argc, char **argv)
     is_int(code, 0, "Successfully got security class");
     if (code) {
        afs_com_err("authname-t", code, "while getting anonymous secClass");
-        exit(1);
+       ret = 1;
+       goto out;
     }
 
     code = afstest_GetUbikClient(dir, AFSCONF_VLDBSERVICE, USER_SERVICE_ID,
@@ -131,7 +135,8 @@ main(int argc, char **argv)
     is_int(code, 0, "Successfully built ubik client structure");
     if (code) {
        afs_com_err("vos-t", code, "while building ubik client");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     TestListAddrs(ubikClient, dirname);
@@ -139,5 +144,7 @@ main(int argc, char **argv)
     code = afstest_StopServer(serverPid);
     is_int(0, code, "Server exited cleanly");
 
-    return 0;
+out:
+    afstest_UnlinkTestConfig(dirname);
+    return ret;
 }