From 034fdb4bc2dd380a3c77c0b82c03c99c222ddef4 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 1 Jun 2018 13:44:12 +0200 Subject: cec-compliance: add --exit-on-fail/warn options These options simplify debugging: when the first fail or warning occurs, the application will call exit(1) instead of continuing. Signed-off-by: Hans Verkuil --- utils/cec-compliance/cec-compliance.1.in | 7 +++++++ utils/cec-compliance/cec-compliance.cpp | 14 ++++++++++++++ utils/cec-compliance/cec-compliance.h | 8 ++++++++ 3 files changed, 29 insertions(+) diff --git a/utils/cec-compliance/cec-compliance.1.in b/utils/cec-compliance/cec-compliance.1.in index ba4aa88b..57ef2083 100644 --- a/utils/cec-compliance/cec-compliance.1.in +++ b/utils/cec-compliance/cec-compliance.1.in @@ -74,6 +74,10 @@ tests they depend on failed, and they will not be shown in the test listing. \fB\-d\fR, \fB\-\-device\fR \fI\fR Use device as the CEC device. If is a number, then /dev/cec is used. .TP +\fB\-E\fR, \fB\-\-exit\-on\-fail\fR +Exit this application when the first failure occurs instead of continuing +with a possible inconsistent state. +.TP \fB\-v\fR, \fB\-\-verbose\fR Turn on verbose reporting. .TP @@ -86,6 +90,9 @@ Prints the help message. \fB\-w\fR, \fB\-\-wall\-clock\fR Show timestamps as wall-clock time. .TP +\fB\-W\fR, \fB\-\-exit\-on\-warn\fR +Exit this application when the first warning occurs instead of continuing. +.TP \fB\-n\fR, \fB\-\-no\-warnings\fR Turn off warning messages. .TP diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp index 790f7dfc..1781a6ca 100644 --- a/utils/cec-compliance/cec-compliance.cpp +++ b/utils/cec-compliance/cec-compliance.cpp @@ -36,6 +36,7 @@ enum Option { OptTestAdapter = 'A', OptSetDevice = 'd', + OptExitOnFail = 'E', OptHelp = 'h', OptInteractive = 'i', OptNoWarnings = 'n', @@ -46,6 +47,7 @@ enum Option { OptTrace = 'T', OptVerbose = 'v', OptWallClock = 'w', + OptExitOnWarn = 'W', OptTestCore = 128, OptTestAudioRateControl, @@ -98,6 +100,8 @@ static int tests_total, tests_ok; bool show_info; bool show_warnings = true; +bool exit_on_fail; +bool exit_on_warn; unsigned warnings; unsigned reply_threshold = 1000; time_t long_timeout = 60; @@ -106,6 +110,8 @@ static struct option long_options[] = { {"device", required_argument, 0, OptSetDevice}, {"help", no_argument, 0, OptHelp}, {"no-warnings", no_argument, 0, OptNoWarnings}, + {"exit-on-fail", no_argument, 0, OptExitOnFail}, + {"exit-on-warn", no_argument, 0, OptExitOnWarn}, {"remote", optional_argument, 0, OptRemote}, {"timeout", required_argument, 0, OptTimeout}, {"trace", no_argument, 0, OptTrace}, @@ -197,12 +203,14 @@ static void usage(void) " --test-standby-resume Test standby and resume functionality. This will activate\n" " testing of Standby, Give Device Power Status and One Touch Play.\n" "\n" + " -E, --exit-on-fail Exit on the first fail.\n" " -h, --help Display this help message\n" " -n, --no-warnings Turn off warning messages\n" " -s, --skip-info Skip Driver Info output\n" " -T, --trace Trace all called ioctls\n" " -v, --verbose Turn on verbose reporting\n" " -w, --wall-clock Show timestamps as wall-clock time\n" + " -W, --exit-on-warn Exit on the first warning.\n" ); } @@ -1129,6 +1137,12 @@ int main(int argc, char **argv) case OptNoWarnings: show_warnings = false; break; + case OptExitOnFail: + exit_on_fail = true; + break; + case OptExitOnWarn: + exit_on_warn = true; + break; case OptRemote: if (optarg) { remote_la = strtoul(optarg, NULL, 0); diff --git a/utils/cec-compliance/cec-compliance.h b/utils/cec-compliance/cec-compliance.h index 3c4bf78c..eed21d77 100644 --- a/utils/cec-compliance/cec-compliance.h +++ b/utils/cec-compliance/cec-compliance.h @@ -112,6 +112,8 @@ struct short_audio_desc { extern bool show_info; extern bool show_warnings; +extern bool exit_on_fail; +extern bool exit_on_warn; extern unsigned warnings; extern unsigned reply_threshold; extern time_t long_timeout; @@ -211,6 +213,8 @@ struct remote_subtest { warnings++; \ if (show_warnings) \ printf("\t\twarn: %s(%d): " fmt, __FILE__, __LINE__, ##args); \ + if (exit_on_warn) \ + exit(1); \ } while (0) #define warn_once(fmt, args...) \ @@ -223,12 +227,16 @@ struct remote_subtest { if (show_warnings) \ printf("\t\twarn: %s(%d): " fmt, \ __FILE__, __LINE__, ##args); \ + if (exit_on_warn) \ + exit(1); \ } \ } while (0) #define fail(fmt, args...) \ ({ \ printf("\t\tfail: %s(%d): " fmt, __FILE__, __LINE__, ##args); \ + if (exit_on_fail) \ + exit(1); \ FAIL; \ }) -- cgit v1.2.1