Several tweaks to script flags

- Changed multi-field flags to action=append instead of comma-separated.
- Dropped short-names for geometries/powerlosses
- Renamed -Pexponential -> -Plog
- Allowed omitting the 0 for -W0/-H0/-n0 and made -j0 consistent
- Better handling of --xlim/--ylim
This commit is contained in:
Christopher Haster
2022-09-26 19:19:40 -05:00
parent 42d889e141
commit 9507e6243c
9 changed files with 146 additions and 137 deletions
+19 -25
View File
@@ -90,9 +90,7 @@ static uintmax_t leb16_parse(const char *s, char **tail) {
// bench_runner types
typedef struct bench_geometry {
char short_name;
const char *long_name;
const char *name;
bench_define_t defines[BENCH_GEOMETRY_DEFINE_COUNT];
} bench_geometry_t;
@@ -1057,7 +1055,7 @@ static void list_implicit_defines(void) {
// make sure to include builtin geometries here
extern const bench_geometry_t builtin_geometries[];
for (size_t g = 0; builtin_geometries[g].long_name; g++) {
for (size_t g = 0; builtin_geometries[g].name; g++) {
bench_define_geometry(&builtin_geometries[g]);
bench_define_flush();
@@ -1089,12 +1087,12 @@ static void list_implicit_defines(void) {
// geometries to bench
const bench_geometry_t builtin_geometries[] = {
{'d', "default", {{NULL}, BENCH_CONST(16), BENCH_CONST(512), {NULL}}},
{'e', "eeprom", {{NULL}, BENCH_CONST(1), BENCH_CONST(512), {NULL}}},
{'E', "emmc", {{NULL}, {NULL}, BENCH_CONST(512), {NULL}}},
{'n', "nor", {{NULL}, BENCH_CONST(1), BENCH_CONST(4096), {NULL}}},
{'N', "nand", {{NULL}, BENCH_CONST(4096), BENCH_CONST(32768), {NULL}}},
{0, NULL, {{NULL}, {NULL}, {NULL}, {NULL}}},
{"default", {{NULL}, BENCH_CONST(16), BENCH_CONST(512), {NULL}}},
{"eeprom", {{NULL}, BENCH_CONST(1), BENCH_CONST(512), {NULL}}},
{"emmc", {{NULL}, {NULL}, BENCH_CONST(512), {NULL}}},
{"nor", {{NULL}, BENCH_CONST(1), BENCH_CONST(4096), {NULL}}},
{"nand", {{NULL}, BENCH_CONST(4096), BENCH_CONST(32768), {NULL}}},
{NULL, {{NULL}, {NULL}, {NULL}, {NULL}}},
};
const bench_geometry_t *bench_geometries = builtin_geometries;
@@ -1107,12 +1105,11 @@ static void list_geometries(void) {
printf("%-24s %7s %7s %7s %7s %11s\n",
"geometry", "read", "prog", "erase", "count", "size");
for (size_t g = 0; builtin_geometries[g].long_name; g++) {
for (size_t g = 0; builtin_geometries[g].name; g++) {
bench_define_geometry(&builtin_geometries[g]);
bench_define_flush();
printf("%c,%-22s %7ju %7ju %7ju %7ju %11ju\n",
builtin_geometries[g].short_name,
builtin_geometries[g].long_name,
printf("%-24s %7ju %7ju %7ju %7ju %11ju\n",
builtin_geometries[g].name,
READ_SIZE,
PROG_SIZE,
BLOCK_SIZE,
@@ -1253,7 +1250,7 @@ enum opt_flags {
OPT_LIST_IMPLICIT_DEFINES = 5,
OPT_LIST_GEOMETRIES = 6,
OPT_DEFINE = 'D',
OPT_GEOMETRY = 'g',
OPT_GEOMETRY = 'G',
OPT_STEP = 's',
OPT_DISK = 'd',
OPT_TRACE = 't',
@@ -1262,7 +1259,7 @@ enum opt_flags {
OPT_ERASE_SLEEP = 9,
};
const char *short_opts = "hYlLD:g:s:d:t:";
const char *short_opts = "hYlLD:G:s:d:t:";
const struct option long_opts[] = {
{"help", no_argument, NULL, OPT_HELP},
@@ -1300,7 +1297,7 @@ const char *const help_text[] = {
"List implicit defines in this bench-runner.",
"List the available disk geometries.",
"Override a bench define.",
"Comma-separated list of disk geometries to bench. Defaults to d,e,E,n,N.",
"Comma-separated list of disk geometries to bench.",
"Comma-separated range of bench permutations to run (start,stop,step).",
"Redirect block device operations to this file.",
"Redirect trace output to this file.",
@@ -1555,14 +1552,11 @@ invalid_define:
// named disk geometry
size_t len = strcspn(optarg, " ,");
for (size_t i = 0; builtin_geometries[i].long_name; i++) {
if ((len == 1
&& *optarg == builtin_geometries[i].short_name)
|| (len == strlen(
builtin_geometries[i].long_name)
&& memcmp(optarg,
builtin_geometries[i].long_name,
len) == 0)) {
for (size_t i = 0; builtin_geometries[i].name; i++) {
if (len == strlen(builtin_geometries[i].name)
&& memcmp(optarg,
builtin_geometries[i].name,
len) == 0) {
*geometry = builtin_geometries[i];
optarg += len;
goto geometry_next;
+44 -51
View File
@@ -90,16 +90,12 @@ static uintmax_t leb16_parse(const char *s, char **tail) {
// test_runner types
typedef struct test_geometry {
char short_name;
const char *long_name;
const char *name;
test_define_t defines[TEST_GEOMETRY_DEFINE_COUNT];
} test_geometry_t;
typedef struct test_powerloss {
char short_name;
const char *long_name;
const char *name;
void (*run)(
const lfs_emubd_powercycles_t *cycles,
size_t cycle_count,
@@ -574,6 +570,11 @@ void test_seen_cleanup(test_seen_t *seen) {
free(seen->branches);
}
static void run_powerloss_none(
const lfs_emubd_powercycles_t *cycles,
size_t cycle_count,
const struct test_suite *suite,
const struct test_case *case_);
static void run_powerloss_cycles(
const lfs_emubd_powercycles_t *cycles,
size_t cycle_count,
@@ -606,7 +607,7 @@ static void case_forperm(
} else {
for (size_t p = 0; p < test_powerloss_count; p++) {
// skip non-reentrant tests when powerloss testing
if (test_powerlosses[p].short_name != '0'
if (test_powerlosses[p].run != run_powerloss_none
&& !(case_->flags & TEST_REENTRANT)) {
continue;
}
@@ -646,7 +647,7 @@ static void case_forperm(
} else {
for (size_t p = 0; p < test_powerloss_count; p++) {
// skip non-reentrant tests when powerloss testing
if (test_powerlosses[p].short_name != '0'
if (test_powerlosses[p].run != run_powerloss_none
&& !(case_->flags & TEST_REENTRANT)) {
continue;
}
@@ -1094,7 +1095,7 @@ static void list_implicit_defines(void) {
// make sure to include builtin geometries here
extern const test_geometry_t builtin_geometries[];
for (size_t g = 0; builtin_geometries[g].long_name; g++) {
for (size_t g = 0; builtin_geometries[g].name; g++) {
test_define_geometry(&builtin_geometries[g]);
test_define_flush();
@@ -1126,12 +1127,12 @@ static void list_implicit_defines(void) {
// geometries to test
const test_geometry_t builtin_geometries[] = {
{'d', "default", {{NULL}, TEST_CONST(16), TEST_CONST(512), {NULL}}},
{'e', "eeprom", {{NULL}, TEST_CONST(1), TEST_CONST(512), {NULL}}},
{'E', "emmc", {{NULL}, {NULL}, TEST_CONST(512), {NULL}}},
{'n', "nor", {{NULL}, TEST_CONST(1), TEST_CONST(4096), {NULL}}},
{'N', "nand", {{NULL}, TEST_CONST(4096), TEST_CONST(32768), {NULL}}},
{0, NULL, {{NULL}, {NULL}, {NULL}, {NULL}}},
{"default", {{NULL}, TEST_CONST(16), TEST_CONST(512), {NULL}}},
{"eeprom", {{NULL}, TEST_CONST(1), TEST_CONST(512), {NULL}}},
{"emmc", {{NULL}, {NULL}, TEST_CONST(512), {NULL}}},
{"nor", {{NULL}, TEST_CONST(1), TEST_CONST(4096), {NULL}}},
{"nand", {{NULL}, TEST_CONST(4096), TEST_CONST(32768), {NULL}}},
{NULL, {{NULL}, {NULL}, {NULL}, {NULL}}},
};
const test_geometry_t *test_geometries = builtin_geometries;
@@ -1144,12 +1145,11 @@ static void list_geometries(void) {
printf("%-24s %7s %7s %7s %7s %11s\n",
"geometry", "read", "prog", "erase", "count", "size");
for (size_t g = 0; builtin_geometries[g].long_name; g++) {
for (size_t g = 0; builtin_geometries[g].name; g++) {
test_define_geometry(&builtin_geometries[g]);
test_define_flush();
printf("%c,%-22s %7ju %7ju %7ju %7ju %11ju\n",
builtin_geometries[g].short_name,
builtin_geometries[g].long_name,
printf("%-24s %7ju %7ju %7ju %7ju %11ju\n",
builtin_geometries[g].name,
READ_SIZE,
PROG_SIZE,
BLOCK_SIZE,
@@ -1314,7 +1314,7 @@ static void run_powerloss_linear(
}
}
static void run_powerloss_exponential(
static void run_powerloss_log(
const lfs_emubd_powercycles_t *cycles,
size_t cycle_count,
const struct test_suite *suite,
@@ -1646,11 +1646,11 @@ static void run_powerloss_exhaustive(
const test_powerloss_t builtin_powerlosses[] = {
{'0', "none", run_powerloss_none, NULL, 0},
{'e', "exponential", run_powerloss_exponential, NULL, 0},
{'l', "linear", run_powerloss_linear, NULL, 0},
{'x', "exhaustive", run_powerloss_exhaustive, NULL, SIZE_MAX},
{0, NULL, NULL, NULL, 0},
{"none", run_powerloss_none, NULL, 0},
{"log", run_powerloss_log, NULL, 0},
{"linear", run_powerloss_linear, NULL, 0},
{"exhaustive", run_powerloss_exhaustive, NULL, SIZE_MAX},
{NULL, NULL, NULL, 0},
};
const char *const builtin_powerlosses_help[] = {
@@ -1664,17 +1664,16 @@ const char *const builtin_powerlosses_help[] = {
};
const test_powerloss_t *test_powerlosses = (const test_powerloss_t[]){
{'0', "none", run_powerloss_none, NULL, 0},
{"none", run_powerloss_none, NULL, 0},
};
size_t test_powerloss_count = 1;
static void list_powerlosses(void) {
printf("%-24s %s\n", "scenario", "description");
size_t i = 0;
for (; builtin_powerlosses[i].long_name; i++) {
printf("%c,%-22s %s\n",
builtin_powerlosses[i].short_name,
builtin_powerlosses[i].long_name,
for (; builtin_powerlosses[i].name; i++) {
printf("%-24s %s\n",
builtin_powerlosses[i].name,
builtin_powerlosses_help[i]);
}
@@ -1765,8 +1764,8 @@ enum opt_flags {
OPT_LIST_GEOMETRIES = 6,
OPT_LIST_POWERLOSSES = 7,
OPT_DEFINE = 'D',
OPT_GEOMETRY = 'g',
OPT_POWERLOSS = 'p',
OPT_GEOMETRY = 'G',
OPT_POWERLOSS = 'P',
OPT_STEP = 's',
OPT_DISK = 'd',
OPT_TRACE = 't',
@@ -1775,7 +1774,7 @@ enum opt_flags {
OPT_ERASE_SLEEP = 10,
};
const char *short_opts = "hYlLD:g:p:s:d:t:";
const char *short_opts = "hYlLD:G:P:s:d:t:";
const struct option long_opts[] = {
{"help", no_argument, NULL, OPT_HELP},
@@ -1816,8 +1815,8 @@ const char *const help_text[] = {
"List the available disk geometries.",
"List the available power-loss scenarios.",
"Override a test define.",
"Comma-separated list of disk geometries to test. Defaults to d,e,E,n,N.",
"Comma-separated list of power-loss scenarios to test. Defaults to 0,l.",
"Comma-separated list of disk geometries to test.",
"Comma-separated list of power-loss scenarios to test.",
"Comma-separated range of test permutations to run (start,stop,step).",
"Redirect block device operations to this file.",
"Redirect trace output to this file.",
@@ -2076,14 +2075,11 @@ invalid_define:
// named disk geometry
size_t len = strcspn(optarg, " ,");
for (size_t i = 0; builtin_geometries[i].long_name; i++) {
if ((len == 1
&& *optarg == builtin_geometries[i].short_name)
|| (len == strlen(
builtin_geometries[i].long_name)
&& memcmp(optarg,
builtin_geometries[i].long_name,
len) == 0)) {
for (size_t i = 0; builtin_geometries[i].name; i++) {
if (len == strlen(builtin_geometries[i].name)
&& memcmp(optarg,
builtin_geometries[i].name,
len) == 0) {
*geometry = builtin_geometries[i];
optarg += len;
goto geometry_next;
@@ -2224,14 +2220,11 @@ geometry_next:
// named power-loss scenario
size_t len = strcspn(optarg, " ,");
for (size_t i = 0; builtin_powerlosses[i].long_name; i++) {
if ((len == 1
&& *optarg == builtin_powerlosses[i].short_name)
|| (len == strlen(
builtin_powerlosses[i].long_name)
&& memcmp(optarg,
builtin_powerlosses[i].long_name,
len) == 0)) {
for (size_t i = 0; builtin_powerlosses[i].name; i++) {
if (len == strlen(builtin_powerlosses[i].name)
&& memcmp(optarg,
builtin_powerlosses[i].name,
len) == 0) {
*powerloss = builtin_powerlosses[i];
optarg += len;
goto powerloss_next;