More coverage support

This commit is contained in:
Andrea Mazzoleni 2026-04-29 14:51:40 +02:00
parent 8a727975ab
commit c724b47189
3 changed files with 178 additions and 56 deletions

View file

@ -936,6 +936,7 @@ void signal_init(void)
#define OPERATION_SMART 17
#define OPERATION_PROBE 18
#define OPERATION_LOCATE 19
#define OPERATION_SPINDOWNIFUP 20
int snapraid_main(int argc, char* argv[])
{
@ -1497,6 +1498,8 @@ int snapraid_main(int argc, char* argv[])
operation = OPERATION_SPINUP;
} else if (strcmp(argv[optind], "down") == 0) {
operation = OPERATION_SPINDOWN;
} else if (strcmp(argv[optind], "test-downifup") == 0) {
operation = OPERATION_SPINDOWNIFUP;
} else if (strcmp(argv[optind], "devices") == 0) {
operation = OPERATION_DEVICES;
} else if (strcmp(argv[optind], "smart") == 0) {
@ -1533,6 +1536,7 @@ int snapraid_main(int argc, char* argv[])
case OPERATION_DEVICES :
case OPERATION_SPINUP :
case OPERATION_SPINDOWN :
case OPERATION_SPINDOWNIFUP :
break;
default :
if (opt.force_device) {
@ -1626,6 +1630,7 @@ int snapraid_main(int argc, char* argv[])
/* fallthrough */
case OPERATION_SPINUP :
case OPERATION_SPINDOWN :
case OPERATION_SPINDOWNIFUP :
if (!tommy_list_empty(&filterlist_file)) {
/* LCOV_EXCL_START */
log_fatal(EUSER, "You cannot use -f, --filter with the '%s' command\n", command);
@ -1713,6 +1718,7 @@ int snapraid_main(int argc, char* argv[])
case OPERATION_TOUCH :
case OPERATION_SPINUP :
case OPERATION_SPINDOWN :
case OPERATION_SPINDOWNIFUP :
case OPERATION_DEVICES :
case OPERATION_SMART :
case OPERATION_PROBE :
@ -1979,6 +1985,12 @@ int snapraid_main(int argc, char* argv[])
#if HAVE_CHECKER
if (ret < 0)
ret = 0; /* ignore errors in test environment */
#endif
} else if (operation == OPERATION_SPINDOWNIFUP) {
ret = state_device(&state, DEVICE_DOWNIFUP, &filterlist_disk);
#if HAVE_TEST_RUN
if (ret < 0)
ret = 0; /* ignore errors in test environment */
#endif
} else if (operation == OPERATION_DEVICES) {
ret = state_device(&state, DEVICE_LIST, 0);