Changed TEST_PLS to track number of powerlosses seen by the current test
This turned out to have limited use for the tests themselves. I was hoping to avoid the mount->format->mount fallback when powerloss testing, but we still need it in case format was interrupted. Still, TEST_PLS is very useful for debugging. Previouly it was difficult to set a breakpoint at a specific location, and after a specific powerloss event. Now all you need is this in gdb: b <line> if test_pls == <pls>
This commit is contained in:
+37
-11
@@ -469,7 +469,7 @@ extern size_t test_geometry_count;
|
|||||||
|
|
||||||
extern const test_powerloss_t *test_powerlosses;
|
extern const test_powerloss_t *test_powerlosses;
|
||||||
extern size_t test_powerloss_count;
|
extern size_t test_powerloss_count;
|
||||||
bool test_pl = false;
|
size_t test_pls = 0;
|
||||||
|
|
||||||
const test_id_t *test_ids = (const test_id_t[]) {
|
const test_id_t *test_ids = (const test_id_t[]) {
|
||||||
{NULL, NULL, 0, NULL, 0},
|
{NULL, NULL, 0, NULL, 0},
|
||||||
@@ -762,7 +762,6 @@ static void case_forperm(
|
|||||||
|
|
||||||
// explicit powerloss cycles?
|
// explicit powerloss cycles?
|
||||||
if (cycles) {
|
if (cycles) {
|
||||||
test_pl = true;
|
|
||||||
cb(data, suite, case_, &(test_powerloss_t){
|
cb(data, suite, case_, &(test_powerloss_t){
|
||||||
.run=run_powerloss_cycles,
|
.run=run_powerloss_cycles,
|
||||||
.cycles=cycles,
|
.cycles=cycles,
|
||||||
@@ -770,8 +769,8 @@ static void case_forperm(
|
|||||||
} else {
|
} else {
|
||||||
for (size_t p = 0; p < test_powerloss_count; p++) {
|
for (size_t p = 0; p < test_powerloss_count; p++) {
|
||||||
// skip non-reentrant tests when powerloss testing
|
// skip non-reentrant tests when powerloss testing
|
||||||
test_pl = test_powerlosses[p].run != run_powerloss_none;
|
if (test_powerlosses[p].run != run_powerloss_none
|
||||||
if (test_pl && !(case_->flags & TEST_REENTRANT)) {
|
&& !(case_->flags & TEST_REENTRANT)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,7 +811,6 @@ static void case_forperm(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cycles) {
|
if (cycles) {
|
||||||
test_pl = true;
|
|
||||||
cb(data, suite, case_, &(test_powerloss_t){
|
cb(data, suite, case_, &(test_powerloss_t){
|
||||||
.run=run_powerloss_cycles,
|
.run=run_powerloss_cycles,
|
||||||
.cycles=cycles,
|
.cycles=cycles,
|
||||||
@@ -820,8 +818,8 @@ static void case_forperm(
|
|||||||
} else {
|
} else {
|
||||||
for (size_t p = 0; p < test_powerloss_count; p++) {
|
for (size_t p = 0; p < test_powerloss_count; p++) {
|
||||||
// skip non-reentrant tests when powerloss testing
|
// skip non-reentrant tests when powerloss testing
|
||||||
test_pl = test_powerlosses[p].run != run_powerloss_none;
|
if (test_powerlosses[p].run != run_powerloss_none
|
||||||
if (test_pl && !(case_->flags & TEST_REENTRANT)) {
|
&& !(case_->flags & TEST_REENTRANT)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -854,6 +852,8 @@ void perm_count(
|
|||||||
|
|
||||||
state->total += 1;
|
state->total += 1;
|
||||||
|
|
||||||
|
// set pls to 1 if running under powerloss so it useful for if predicates
|
||||||
|
test_pls = (powerloss->run != run_powerloss_none);
|
||||||
if (case_->if_ && !case_->if_()) {
|
if (case_->if_ && !case_->if_()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1434,6 +1434,9 @@ static void run_powerloss_none(
|
|||||||
perm_printid(suite, case_, NULL, 0);
|
perm_printid(suite, case_, NULL, 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
// zero pls
|
||||||
|
test_pls = 0;
|
||||||
|
|
||||||
case_->run(&cfg);
|
case_->run(&cfg);
|
||||||
|
|
||||||
printf("finished ");
|
printf("finished ");
|
||||||
@@ -1499,6 +1502,9 @@ static void run_powerloss_linear(
|
|||||||
perm_printid(suite, case_, NULL, 0);
|
perm_printid(suite, case_, NULL, 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
// zero pls before first run
|
||||||
|
test_pls = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!setjmp(powerloss_jmp)) {
|
if (!setjmp(powerloss_jmp)) {
|
||||||
// run the test
|
// run the test
|
||||||
@@ -1515,6 +1521,8 @@ static void run_powerloss_linear(
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
// increment pls
|
||||||
|
test_pls += 1;
|
||||||
i += 1;
|
i += 1;
|
||||||
lfs_emubd_setpowercycles(&cfg, i);
|
lfs_emubd_setpowercycles(&cfg, i);
|
||||||
}
|
}
|
||||||
@@ -1577,6 +1585,9 @@ static void run_powerloss_log(
|
|||||||
perm_printid(suite, case_, NULL, 0);
|
perm_printid(suite, case_, NULL, 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
// zero pls before first run
|
||||||
|
test_pls = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!setjmp(powerloss_jmp)) {
|
if (!setjmp(powerloss_jmp)) {
|
||||||
// run the test
|
// run the test
|
||||||
@@ -1593,6 +1604,8 @@ static void run_powerloss_log(
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
// increment pls
|
||||||
|
test_pls += 1;
|
||||||
i *= 2;
|
i *= 2;
|
||||||
lfs_emubd_setpowercycles(&cfg, i);
|
lfs_emubd_setpowercycles(&cfg, i);
|
||||||
}
|
}
|
||||||
@@ -1653,6 +1666,9 @@ static void run_powerloss_cycles(
|
|||||||
perm_printid(suite, case_, NULL, 0);
|
perm_printid(suite, case_, NULL, 0);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
// zero pls before first run
|
||||||
|
test_pls = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!setjmp(powerloss_jmp)) {
|
if (!setjmp(powerloss_jmp)) {
|
||||||
// run the test
|
// run the test
|
||||||
@@ -1666,6 +1682,8 @@ static void run_powerloss_cycles(
|
|||||||
perm_printid(suite, case_, cycles, i+1);
|
perm_printid(suite, case_, cycles, i+1);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
// increment pls
|
||||||
|
test_pls += 1;
|
||||||
i += 1;
|
i += 1;
|
||||||
lfs_emubd_setpowercycles(&cfg,
|
lfs_emubd_setpowercycles(&cfg,
|
||||||
(i < cycle_count) ? cycles[i] : 0);
|
(i < cycle_count) ? cycles[i] : 0);
|
||||||
@@ -1727,7 +1745,8 @@ static void run_powerloss_exhaustive_layer(
|
|||||||
const struct test_case *case_,
|
const struct test_case *case_,
|
||||||
struct lfs_config *cfg,
|
struct lfs_config *cfg,
|
||||||
struct lfs_emubd_config *bdcfg,
|
struct lfs_emubd_config *bdcfg,
|
||||||
size_t depth) {
|
size_t depth,
|
||||||
|
size_t pls) {
|
||||||
(void)suite;
|
(void)suite;
|
||||||
|
|
||||||
struct powerloss_exhaustive_state state = {
|
struct powerloss_exhaustive_state state = {
|
||||||
@@ -1742,6 +1761,9 @@ static void run_powerloss_exhaustive_layer(
|
|||||||
lfs_emubd_setpowercycles(state.cfg, depth > 0 ? 1 : 0);
|
lfs_emubd_setpowercycles(state.cfg, depth > 0 ? 1 : 0);
|
||||||
bdcfg->powerloss_data = &state;
|
bdcfg->powerloss_data = &state;
|
||||||
|
|
||||||
|
// make the number of pls currently seen available to tests/debugging
|
||||||
|
test_pls = pls;
|
||||||
|
|
||||||
// run the tests
|
// run the tests
|
||||||
case_->run(cfg);
|
case_->run(cfg);
|
||||||
|
|
||||||
@@ -1774,7 +1796,7 @@ static void run_powerloss_exhaustive_layer(
|
|||||||
cfg->context = &state.branches[i];
|
cfg->context = &state.branches[i];
|
||||||
run_powerloss_exhaustive_layer(cycles,
|
run_powerloss_exhaustive_layer(cycles,
|
||||||
suite, case_,
|
suite, case_,
|
||||||
cfg, bdcfg, depth-1);
|
cfg, bdcfg, depth-1, pls+1);
|
||||||
|
|
||||||
// pop the cycle
|
// pop the cycle
|
||||||
cycles->cycle_count -= 1;
|
cycles->cycle_count -= 1;
|
||||||
@@ -1830,7 +1852,7 @@ static void run_powerloss_exhaustive(
|
|||||||
run_powerloss_exhaustive_layer(
|
run_powerloss_exhaustive_layer(
|
||||||
&(struct powerloss_exhaustive_cycles){NULL, 0, 0},
|
&(struct powerloss_exhaustive_cycles){NULL, 0, 0},
|
||||||
suite, case_,
|
suite, case_,
|
||||||
&cfg, &bdcfg, cycle_count);
|
&cfg, &bdcfg, cycle_count, 0);
|
||||||
|
|
||||||
printf("finished ");
|
printf("finished ");
|
||||||
perm_printid(suite, case_, NULL, 0);
|
perm_printid(suite, case_, NULL, 0);
|
||||||
@@ -1910,6 +1932,8 @@ void perm_run(
|
|||||||
}
|
}
|
||||||
test_step += 1;
|
test_step += 1;
|
||||||
|
|
||||||
|
// set pls to 1 if running under powerloss so it useful for if predicates
|
||||||
|
test_pls = (powerloss->run != run_powerloss_none);
|
||||||
// filter?
|
// filter?
|
||||||
if (case_->if_ && !case_->if_()) {
|
if (case_->if_ && !case_->if_()) {
|
||||||
printf("skipped ");
|
printf("skipped ");
|
||||||
@@ -1918,6 +1942,7 @@ void perm_run(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// run the test, possibly under powerloss
|
||||||
powerloss->run(
|
powerloss->run(
|
||||||
powerloss->cycles, powerloss->cycle_count,
|
powerloss->cycles, powerloss->cycle_count,
|
||||||
suite, case_);
|
suite, case_);
|
||||||
@@ -2628,7 +2653,8 @@ step_unknown:
|
|||||||
char *parsed = NULL;
|
char *parsed = NULL;
|
||||||
test_trace_period = strtoumax(optarg, &parsed, 0);
|
test_trace_period = strtoumax(optarg, &parsed, 0);
|
||||||
if (parsed == optarg) {
|
if (parsed == optarg) {
|
||||||
fprintf(stderr, "error: invalid trace-period: %s\n", optarg);
|
fprintf(stderr, "error: invalid trace-period: %s\n",
|
||||||
|
optarg);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -72,10 +72,11 @@ extern const struct test_suite *const test_suites[];
|
|||||||
extern const size_t test_suite_count;
|
extern const size_t test_suite_count;
|
||||||
|
|
||||||
|
|
||||||
// this is defined as true when powerloss-testing
|
// this variable tracks the number of powerlosses triggered during the
|
||||||
extern bool test_pl;
|
// current test permutation, this is useful for both tests and debugging
|
||||||
|
extern size_t test_pls;
|
||||||
|
|
||||||
#define TEST_PL test_pl
|
#define TEST_PLS test_pls
|
||||||
|
|
||||||
// deterministic prng for pseudo-randomness in testes
|
// deterministic prng for pseudo-randomness in testes
|
||||||
uint32_t test_prng(uint32_t *state);
|
uint32_t test_prng(uint32_t *state);
|
||||||
|
|||||||
@@ -1432,7 +1432,7 @@ defines.PARENT = [false, true]
|
|||||||
# 2 => rewind then seek
|
# 2 => rewind then seek
|
||||||
defines.SEEK = [0, 1, 2]
|
defines.SEEK = [0, 1, 2]
|
||||||
# limit powerloss testing due to time
|
# limit powerloss testing due to time
|
||||||
if = '!TEST_PL || N <= 32'
|
if = '!TEST_PLS || N <= 32'
|
||||||
reentrant = true
|
reentrant = true
|
||||||
code = '''
|
code = '''
|
||||||
// format once per test
|
// format once per test
|
||||||
@@ -1445,7 +1445,7 @@ code = '''
|
|||||||
|
|
||||||
if (PARENT) {
|
if (PARENT) {
|
||||||
err = lfsr_mkdir(&lfs, "pricklypear");
|
err = lfsr_mkdir(&lfs, "pricklypear");
|
||||||
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
|
assert(!err || (TEST_PLS && err == LFS_ERR_EXIST));
|
||||||
}
|
}
|
||||||
|
|
||||||
// make this many directories
|
// make this many directories
|
||||||
@@ -1453,7 +1453,7 @@ code = '''
|
|||||||
char name[256];
|
char name[256];
|
||||||
sprintf(name, "%s/dir%04d", (PARENT ? "pricklypear" : ""), i);
|
sprintf(name, "%s/dir%04d", (PARENT ? "pricklypear" : ""), i);
|
||||||
err = lfsr_mkdir(&lfs, name);
|
err = lfsr_mkdir(&lfs, name);
|
||||||
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
|
assert(!err || (TEST_PLS && err == LFS_ERR_EXIST));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that our mkdir worked
|
// check that our mkdir worked
|
||||||
@@ -1558,7 +1558,7 @@ defines.PARENT = [0, 1, 2]
|
|||||||
# 2 => rewind then seek
|
# 2 => rewind then seek
|
||||||
defines.SEEK = [0, 1, 2]
|
defines.SEEK = [0, 1, 2]
|
||||||
# limit powerloss testing due to time
|
# limit powerloss testing due to time
|
||||||
if = '!TEST_PL || N <= 32'
|
if = '!TEST_PLS || N <= 32'
|
||||||
reentrant = true
|
reentrant = true
|
||||||
code = '''
|
code = '''
|
||||||
// format once per test
|
// format once per test
|
||||||
@@ -1571,10 +1571,10 @@ code = '''
|
|||||||
|
|
||||||
if (PARENT) {
|
if (PARENT) {
|
||||||
err = lfsr_mkdir(&lfs, "pricklypear");
|
err = lfsr_mkdir(&lfs, "pricklypear");
|
||||||
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
|
assert(!err || (TEST_PLS && err == LFS_ERR_EXIST));
|
||||||
if (PARENT >= 2) {
|
if (PARENT >= 2) {
|
||||||
err = lfsr_mkdir(&lfs, "quiabentia");
|
err = lfsr_mkdir(&lfs, "quiabentia");
|
||||||
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
|
assert(!err || (TEST_PLS && err == LFS_ERR_EXIST));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1596,7 +1596,7 @@ code = '''
|
|||||||
char name[256];
|
char name[256];
|
||||||
sprintf(name, "%s/dir%04d", (PARENT ? "pricklypear" : ""), i);
|
sprintf(name, "%s/dir%04d", (PARENT ? "pricklypear" : ""), i);
|
||||||
err = lfsr_mkdir(&lfs, name);
|
err = lfsr_mkdir(&lfs, name);
|
||||||
assert(!err || (TEST_PL && err == LFS_ERR_EXIST));
|
assert(!err || (TEST_PLS && err == LFS_ERR_EXIST));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that our mkdir worked
|
// check that our mkdir worked
|
||||||
@@ -1664,7 +1664,7 @@ code = '''
|
|||||||
(BEFORE ? "0" : ""),
|
(BEFORE ? "0" : ""),
|
||||||
&info.name[strlen("dir")]);
|
&info.name[strlen("dir")]);
|
||||||
err = lfsr_rename(&lfs, old_path, new_path);
|
err = lfsr_rename(&lfs, old_path, new_path);
|
||||||
assert(!err || (TEST_PL && err == LFS_ERR_NOENT));
|
assert(!err || (TEST_PLS && err == LFS_ERR_NOENT));
|
||||||
|
|
||||||
// seek between renames? this tests that the internal position is
|
// seek between renames? this tests that the internal position is
|
||||||
// updated correctly
|
// updated correctly
|
||||||
|
|||||||
+185
-185
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user