From 748185788e221da15e57b105ea325218edce2bd4 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 13 Apr 2011 17:21:05 +0300 Subject: fs-tests: integck: do not expect max name length to be 256 The 'make_name()' function assumes that the maxumum file name length is 256 bytes, which is wrong. This patch fixes this. Signed-off-by: Artem Bityutskiy --- tests/fs-tests/integrity/integck.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'tests/fs-tests') diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 387874c..61fb12c 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -202,6 +202,11 @@ static uint64_t operation_count = 0; /* Number of operations used to fill up the file system */ static unsigned int check_run_no; +/* + * A buffer which is used by 'make_name()' to return the generated random name. + */ +static char *random_name_buf; + /* * Is this 'struct write_info' actually holds information about a truncation? */ @@ -1451,7 +1456,6 @@ static void close_open_files(void) static char *make_name(struct dir_info *dir) { - static char name[256]; struct dir_entry_info *entry; int found; @@ -1460,20 +1464,20 @@ static char *make_name(struct dir_info *dir) if (random_no(5) == 1) { int i, n = random_no(fsinfo.max_name_len) + 1; - CHECK(n > 0 && n < 256); for (i = 0; i < n; i++) - name[i] = 'a' + random_no(26); - name[i] = '\0'; + random_name_buf[i] = 'a' + random_no(26); + random_name_buf[i] = '\0'; } else - sprintf(name, "%u", random_no(1000000)); + sprintf(random_name_buf, "%u", random_no(1000000)); for (entry = dir->first; entry; entry = entry->next) { - if (strcmp(entry->name, name) == 0) { + if (strcmp(entry->name, random_name_buf) == 0) { found = 1; break; } } } while (found); - return name; + + return random_name_buf; } static struct file_info *pick_file(void) @@ -2417,6 +2421,9 @@ int main(int argc, char *argv[]) /* Seed the random generator with out PID */ srand(getpid()); + random_name_buf = malloc(fsinfo.max_name_len + 1); + CHECK(random_name_buf != NULL); + /* Do the actual test */ ret = integck(); if (ret) -- cgit v1.2.3