Add regression test for UUID change

This commit is contained in:
Andrea Mazzoleni 2015-12-04 22:38:43 +01:00
parent cab1b43d3b
commit fcc3894667
4 changed files with 16 additions and 0 deletions

View file

@ -305,6 +305,9 @@ endif
rm bench/disk1/EXTRA1
touch bench/disk1/EXTRA2
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -E sync
# Change UUID
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-fake-uuid sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
#### NOT EMPTY ####
echo --- Create some files
$(TESTENV) ./mktest$(EXEEXT) generate 1 6 $(CHECKCOUNT) $(CHECKSIZE)

View file

@ -246,6 +246,7 @@ void config(char* conf, size_t conf_size, const char* argv0)
#define OPT_TEST_FAKE_DEVICE 284
#define OPT_TEST_EXPECT_NEED_SYNC 285
#define OPT_NO_WARNINGS 286
#define OPT_TEST_FAKE_UUID 287
#if HAVE_GETOPT_LONG
struct option long_options[] = {
@ -364,6 +365,9 @@ struct option long_options[] = {
/* Disable annoying warnings */
{ "test-no-warnings", 0, 0, OPT_NO_WARNINGS },
/* Fake UUID */
{ "test-fake-uuid", 0, 0, OPT_TEST_FAKE_UUID },
{ 0, 0, 0, 0 }
};
#endif
@ -733,6 +737,9 @@ int main(int argc, char* argv[])
case OPT_NO_WARNINGS :
opt.no_warnings = 1;
break;
case OPT_TEST_FAKE_UUID :
opt.fake_uuid = 2;
break;
default :
/* LCOV_EXCL_START */
log_fatal("Unknown option '%c'\n", (char)c);

View file

@ -1271,6 +1271,11 @@ static void state_map(struct snapraid_state* state)
continue;
}
if (state->opt.fake_uuid) {
snprintf(uuid, sizeof(uuid), "fake-uuid-%d", state->opt.fake_uuid);
--state->opt.fake_uuid;
}
/* if the uuid is changed */
if (strcmp(uuid, map->uuid) != 0) {
/* mark the disk as with an UUID change */

View file

@ -105,6 +105,7 @@ struct snapraid_option {
int fake_device; /**< Fake device data. */
int no_warnings; /**< Remove some warning messages. */
int expected_missing; /**< If missing files are expected and should not be reported. */
int fake_uuid; /**< Set fakes UUID for testing. */
};
/**