diff options
| author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-08-07 06:37:30 +0200 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2014-09-16 05:18:33 -0700 | 
| commit | 68e062ea6e3e6957cc6212f778950cce54078a90 (patch) | |
| tree | c1133a5c57105b9a2190c977a1717a77884d9a18 /tests/utils | |
| parent | b30f9e56cd92906ccb97e046b8928d7de76b4b50 (diff) | |
Regression test portability: arequal-checksum
Emulate GNU libc extension FTW_SKIP_SUBTREE for system that lack it.
FTW_ACTIONRETVAL is another GNU libc extension we just ignore now.
BUG: 764655
Change-Id: I25d9641055a30fe72b4e248f51b53b2a3ba637e9
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8427
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests/utils')
| -rw-r--r-- | tests/utils/arequal-checksum.c | 37 | 
1 files changed, 31 insertions, 6 deletions
diff --git a/tests/utils/arequal-checksum.c b/tests/utils/arequal-checksum.c index d97c6d4f656..9fdd60c6d2b 100644 --- a/tests/utils/arequal-checksum.c +++ b/tests/utils/arequal-checksum.c @@ -45,7 +45,6 @@   */  #ifndef FTW_ACTIONRETVAL  #define FTW_ACTIONRETVAL 0 -#define FTW_SKIP_SUBTREE 0  #endif  int debug = 0; @@ -457,6 +456,20 @@ process_other (const char *path, const struct stat *sb)          return 0;  } +static int +ignore_entry(const char *bname, const char *dname) +{ +        int i; + +	for (i  = 0; i < arequal_config.directories_ignored; i++) { +		if (strcmp(bname, arequal_config.ignored_directory[i]) == 0 && +                    strncmp(arequal_config.test_directory, dname, +                            strlen(arequal_config.test_directory)) == 0) +                        return 1; +        } + +        return 0; +}  int  process_entry (const char *path, const struct stat *sb, @@ -485,6 +498,21 @@ process_entry (const char *path, const struct stat *sb,          */          if (arequal_config.ignored_directory) { +#ifndef FTW_SKIP_SUBTREE +                char *cp; + +                name = strdup (path); +                dname = dirname (name); + +                for (cp = strtok(name, "/"); cp; cp = strtok(NULL, "/")) { +                        if (ignore_entry(cp, dname)) { +                                DBG ("ignoring %s\n", path); +                                if (name) +                                        free (name); +                                return 0; +                        } +                } +#else /* FTW_SKIP_SUBTREE */                  name = strdup (path);                  name[strlen(name)] = '\0'; @@ -494,17 +522,14 @@ process_entry (const char *path, const struct stat *sb,                          bname++;                  dname = dirname (name); -                for ( i = 0; i < arequal_config.directories_ignored; i++) { -                        if ((strcmp (bname, arequal_config.ignored_directory[i]) -                             == 0) && (strcmp (arequal_config.test_directory, -                                               dname) == 0)) { +                if (ignore_entry(bname, dname)) {                                  DBG ("ignoring %s\n", bname);                                  ret = FTW_SKIP_SUBTREE;                                  if (name)                                          free (name);                                  return ret; -                        }                  } +#endif /* FTW_SKIP_SUBTREE */          }          DBG ("processing entry %s\n", path);  | 
