mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-26 18:06:28 -05:00
Sort the dir alphabetically if explicitely requested.
This ensures that the test is independent of the directory order of the files.
This commit is contained in:
parent
6c88c44970
commit
71ff0620ce
2 changed files with 37 additions and 4 deletions
23
Makefile.am
23
Makefile.am
|
|
@ -121,11 +121,30 @@ maintainer-clean-local:
|
||||||
|
|
||||||
# Automatic testing
|
# Automatic testing
|
||||||
|
|
||||||
|
# Base options
|
||||||
|
# --test-skip-device
|
||||||
|
# Is required to allow testing in the same disk
|
||||||
|
#
|
||||||
|
# --test-skip-self
|
||||||
|
# It just makes the test a little faster
|
||||||
|
#
|
||||||
|
# --test-force-order-alpha
|
||||||
|
# Ensures to process files always in the same order despites
|
||||||
|
# the inode, physical location, and dir order assigned by the OS.
|
||||||
CHECKFLAGS_BASE = --test-skip-device --test-skip-self --test-force-order-alpha
|
CHECKFLAGS_BASE = --test-skip-device --test-skip-self --test-force-order-alpha
|
||||||
|
|
||||||
|
# Verbose options
|
||||||
CHECKFLAGS_VERBOSE = $(CHECKFLAGS_BASE) -v -G
|
CHECKFLAGS_VERBOSE = $(CHECKFLAGS_BASE) -v -G
|
||||||
|
|
||||||
|
# Quiet options
|
||||||
CHECKFLAGS = $(CHECKFLAGS_BASE) -q
|
CHECKFLAGS = $(CHECKFLAGS_BASE) -q
|
||||||
|
|
||||||
|
# Number of files to create
|
||||||
CHECKCOUNT = 1000
|
CHECKCOUNT = 1000
|
||||||
|
|
||||||
|
# Size of files to create
|
||||||
CHECKSIZE = 4000
|
CHECKSIZE = 4000
|
||||||
|
|
||||||
CONF = $(srcdir)/test/test-par6.conf
|
CONF = $(srcdir)/test/test-par6.conf
|
||||||
HOLE = $(srcdir)/test/test-par6-hole.conf
|
HOLE = $(srcdir)/test/test-par6-hole.conf
|
||||||
PAR1 = $(srcdir)/test/test-par1.conf
|
PAR1 = $(srcdir)/test/test-par1.conf
|
||||||
|
|
@ -174,7 +193,7 @@ endif
|
||||||
echo DUP > bench/disk1/DUP1
|
echo DUP > bench/disk1/DUP1
|
||||||
echo DUP > bench/disk1/DUP2
|
echo DUP > bench/disk1/DUP2
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) diff > output.log
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) diff > output.log
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-force-order-physical sync
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
|
||||||
echo --- Some commands with a not empty array
|
echo --- Some commands with a not empty array
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) dup -l test.log
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) dup -l test.log
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) list -l test.log > output.log
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) list -l test.log > output.log
|
||||||
|
|
@ -241,7 +260,7 @@ endif
|
||||||
ln bench/disk3/file_hardlink1 bench/disk3/file_hardlink2
|
ln bench/disk3/file_hardlink1 bench/disk3/file_hardlink2
|
||||||
ln bench/disk3/file_hardlink1 bench/disk3/file_hardlink3
|
ln bench/disk3/file_hardlink1 bench/disk3/file_hardlink3
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(PAR1) diff > output.log
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(PAR1) diff > output.log
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-fallocate -c $(PAR1) --test-force-order-inode sync
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-fallocate -c $(PAR1) sync
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
|
||||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-sequential -c $(PAR1) check
|
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-sequential -c $(PAR1) check
|
||||||
echo --- Some commands with a not empty array
|
echo --- Some commands with a not empty array
|
||||||
|
|
|
||||||
|
|
@ -894,6 +894,14 @@ static int dd_ino_compare(const void* void_a, const void* void_b)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int dd_name_compare(const void* void_a, const void* void_b)
|
||||||
|
{
|
||||||
|
const struct dirent_sorted* a = void_a;
|
||||||
|
const struct dirent_sorted* b = void_b;
|
||||||
|
|
||||||
|
return strcmp(a->d_name, b->d_name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the stat info of a dir entry.
|
* Returns the stat info of a dir entry.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1024,11 +1032,17 @@ static int scan_dir(struct snapraid_scan* scan, int output, const char* dir, con
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_STRUCT_DIRENT_D_INO
|
#if HAVE_STRUCT_DIRENT_D_INO
|
||||||
/* if inodes are persistent */
|
if (state->opt.force_order == SORT_ALPHA) {
|
||||||
if (!disk->has_volatile_inodes) {
|
/* if requested sort alphabetically */
|
||||||
|
/* this is mainly done for testing to ensure to always */
|
||||||
|
/* process in the same way in different platforms */
|
||||||
|
tommy_list_sort(&list, dd_name_compare);
|
||||||
|
} else if (!disk->has_volatile_inodes) {
|
||||||
|
/* if inodes are persistent */
|
||||||
/* sort the list of dir entries by inodes */
|
/* sort the list of dir entries by inodes */
|
||||||
tommy_list_sort(&list, dd_ino_compare);
|
tommy_list_sort(&list, dd_ino_compare);
|
||||||
}
|
}
|
||||||
|
/* otherwise just keep the insertion order */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* process the sorted dir entries */
|
/* process the sorted dir entries */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue