diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-05-25 18:22:51 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-05-27 15:55:07 +0300 |
commit | 80a3b730e9b1044d689997e8d68e3b6acb71c7a3 (patch) | |
tree | 8132f474f7c12b76df9f0360efdcb70eff328359 /tests | |
parent | acd00a418ef8203fe34809fdd8891dbc5271512c (diff) |
fs-tests: integck: make directory checking work
This patch makes the directory checking in case of power cut emulation
actually work. There were many bugs. Basically, we cannot rely on anything
unless the directory is marked as clean.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fs-tests/integrity/integck.c | 101 |
1 files changed, 45 insertions, 56 deletions
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 437922e..748b6cb 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -1702,65 +1702,54 @@ static void dir_check(struct dir_info *dir) int link_count = 2; /* Parent and dot */ struct stat st; - /* Create an array of entries */ - sz = sizeof(struct dir_entry_info *); - n = dir->number_of_entries; - entry_array = malloc(sz * n); - CHECK(entry_array != NULL); - - entry = dir->first; - p = entry_array; - while (entry) { - *p++ = entry; - entry->checked = 0; - entry = entry->next; - } + path = dir_path(dir->parent, dir->entry->name); - /* Sort it by name */ - qsort(entry_array, n, sz, sort_comp); + if (!args.power_cut_mode || dir->clean) { + v("checking dir %s", path); - /* Go through directory on file system checking entries match */ - path = dir_path(dir->parent, dir->entry->name); + /* Create an array of entries */ + sz = sizeof(struct dir_entry_info *); + n = dir->number_of_entries; + entry_array = malloc(sz * n); + CHECK(entry_array != NULL); - v("checking dir %s", path); + entry = dir->first; + p = entry_array; + while (entry) { + *p++ = entry; + entry->checked = 0; + entry = entry->next; + } - d = opendir(path); - if (!d) { - if (args.power_cut_mode && !dir->clean) - /* - * We are doing power cut testing and the directory - * was not synchronized, which means it might not - * exist. - */ - return; + /* Sort it by name */ + qsort(entry_array, n, sz, sort_comp); - errmsg("cannot open directory %s", path); - CHECK(0); - } + /* Go through directory on file system checking entries match */ + d = opendir(path); + if (!d) { + errmsg("cannot open directory %s", path); + CHECK(0); + } - for (;;) { - errno = 0; - ent = readdir(d); - if (ent) { - if (strcmp(".",ent->d_name) != 0 && - strcmp("..",ent->d_name) != 0) { - dir_entry_check(entry_array, n, ent); - checked += 1; + for (;;) { + errno = 0; + ent = readdir(d); + if (ent) { + if (strcmp(".",ent->d_name) != 0 && + strcmp("..",ent->d_name) != 0) { + dir_entry_check(entry_array, n, ent); + checked += 1; + } + } else { + CHECK(errno == 0); + break; } - } else { - CHECK(errno == 0); - break; } - } - CHECK(closedir(d) == 0); + free(entry_array); + CHECK(closedir(d) == 0); - /* - * In power cut mode the file-system may miss some directory entries - * because it is possible that they have not reached the media by the - * time of the emulated power cut. - */ - if (!args.power_cut_mode || dir->clean) CHECK(checked == dir->number_of_entries); + } /* Now check each entry */ entry = dir->first; @@ -1777,15 +1766,15 @@ static void dir_check(struct dir_info *dir) entry = entry->next; } - CHECK(stat(path, &st) == 0); - - if (link_count != st.st_nlink) { - errmsg("calculated link count %d, FS reports %d for dir %s", - link_count, (int)st.st_nlink, path); - CHECK(0); + if (!args.power_cut_mode || dir->clean) { + CHECK(stat(path, &st) == 0); + if (link_count != st.st_nlink) { + errmsg("calculated link count %d, FS reports %d for dir %s", + link_count, (int)st.st_nlink, path); + CHECK(0); + } } - free(entry_array); free(path); } |