aboutsummaryrefslogtreecommitdiffstats
path: root/utils/cec-compliance
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2018-06-01 13:44:12 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2018-06-01 13:44:12 +0200
commit034fdb4bc2dd380a3c77c0b82c03c99c222ddef4 (patch)
tree078f5c1d4cb3645d244d79bc60249291f61292ae /utils/cec-compliance
parent5851919b5bcb8d656c410be7d17534ff88f6b234 (diff)
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 <hans.verkuil@cisco.com>
Diffstat (limited to 'utils/cec-compliance')
-rw-r--r--utils/cec-compliance/cec-compliance.1.in7
-rw-r--r--utils/cec-compliance/cec-compliance.cpp14
-rw-r--r--utils/cec-compliance/cec-compliance.h8
3 files changed, 29 insertions, 0 deletions
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<dev>\fR
Use device <dev> as the CEC device. If <dev> is a number, then /dev/cec<dev> 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; \
})

Privacy Policy