]> granicus.if.org Git - sysstat/commitdiff
simtest: Start tests on current root directory
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 21 Jul 2019 14:04:20 +0000 (16:04 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 21 Jul 2019 14:04:20 +0000 (16:04 +0200)
Don't assume that tests always start on tests/root1 directory.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
systest.c

index 13e6a17801bb59883c568f6b1f61f4f1c1a2cac4..1058be9782a7d709a0be44313397512e38f528ac 100644 (file)
--- a/systest.c
+++ b/systest.c
@@ -114,11 +114,18 @@ char *get_env_value(char *c)
  */
 void next_time_step(void)
 {
-       static int root_nr = 1;
+       int root_nr = 1;
        char rootf[64], testf[64];
+       char *resolved_name;
 
        __unix_time += interval;
 
+       if ((resolved_name = realpath(ROOTDIR, NULL)) != NULL) {
+               if (strlen(resolved_name) > 4) {
+                       root_nr = atoi(resolved_name + strlen(resolved_name) - 1);
+               }
+               free(resolved_name);
+       }
        if ((unlink(ROOTDIR) < 0) && (errno != ENOENT)) {
                perror("unlink");
                exit(1);