aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2018-06-01 13:32:00 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2018-06-01 13:35:58 +0200
commit5851919b5bcb8d656c410be7d17534ff88f6b234 (patch)
tree25871c7e83dee08d34d936133b2a8ad3f438958c
parentd7b940a06ed01725a9d79cb2feda13769ff42ac2 (diff)
v4l2-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>
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.1.in7
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.cpp14
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.h8
3 files changed, 29 insertions, 0 deletions
diff --git a/utils/v4l2-compliance/v4l2-compliance.1.in b/utils/v4l2-compliance/v4l2-compliance.1.in
index e9511abb..591a5fb5 100644
--- a/utils/v4l2-compliance/v4l2-compliance.1.in
+++ b/utils/v4l2-compliance/v4l2-compliance.1.in
@@ -128,6 +128,10 @@ Do the \fB\-s\fR, \fB\-c\fR and \fB\-f\fR streaming tests for all inputs or outp
instead of just the current input or output. This requires that a valid video
signal is present on all inputs or that all outputs are hooked up.
.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\-n\fR, \fB\-\-no\-warnings\fR
Turn off warning messages. They are still counted in the summary, but you won't see them.
.TP
@@ -142,6 +146,9 @@ Use the libv4l2 wrapper library for all V4L2 device accesses. Note that doing th
cause some tests to fail because the libv4l2 library isn't fully V4L2 compliant. By
default v4l2-compliance will bypass libv4l2 and access the V4L2 devices directly.
.TP
+\fB\-W\fR, \fB\-\-exit\-on\-warn\fR
+Exit this application when the first warning occurs instead of continuing.
+.TP
\fB\-h\fR, \fB\-\-help\fR
Prints the help message.
.SH EXIT STATUS
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 36c4c0a6..2bd7b2e2 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -56,6 +56,7 @@ enum Option {
OptStreamAllColorTest = 'c',
OptSetDevice = 'd',
OptSetExpBufDevice = 'e',
+ OptExitOnFail = 'E',
OptStreamAllFormats = 'f',
OptHelp = 'h',
OptSetMediaDevice = 'm',
@@ -70,6 +71,7 @@ enum Option {
OptVerbose = 'v',
OptSetVbiDevice = 'V',
OptUseWrapper = 'w',
+ OptExitOnWarn = 'W',
OptLast = 256
};
@@ -81,6 +83,8 @@ static int tests_total, tests_ok;
// Globals
bool show_info;
bool show_warnings = true;
+bool exit_on_fail;
+bool exit_on_warn;
int kernel_version;
int media_fd = -1;
unsigned warnings;
@@ -124,6 +128,8 @@ static struct option long_options[] = {
{"help", no_argument, 0, OptHelp},
{"verbose", no_argument, 0, OptVerbose},
{"no-warnings", no_argument, 0, OptNoWarnings},
+ {"exit-on-fail", no_argument, 0, OptExitOnFail},
+ {"exit-on-warn", no_argument, 0, OptExitOnWarn},
{"trace", no_argument, 0, OptTrace},
#ifndef NO_LIBV4L2
{"wrapper", no_argument, 0, OptUseWrapper},
@@ -190,6 +196,7 @@ static void usage(void)
printf(" signal is present on the input(s). If <skip> is not specified,\n");
printf(" then just capture the first frame. If <perc> is not specified,\n");
printf(" then this defaults to 90%%.\n");
+ printf(" -E, --exit-on-fail Exit on the first fail.\n");
printf(" -h, --help Display this help message.\n");
printf(" -n, --no-warnings Turn off warning messages.\n");
printf(" -T, --trace Trace all called ioctls.\n");
@@ -197,6 +204,7 @@ static void usage(void)
#ifndef NO_LIBV4L2
printf(" -w, --wrapper Use the libv4l2 wrapper library.\n");
#endif
+ printf(" -W, --exit-on-warn Exit on the first warning.\n");
exit(0);
}
@@ -1216,6 +1224,12 @@ int main(int argc, char **argv)
case OptNoWarnings:
show_warnings = false;
break;
+ case OptExitOnWarn:
+ exit_on_warn = true;
+ break;
+ case OptExitOnFail:
+ exit_on_fail = true;
+ break;
case OptVerbose:
show_info = true;
break;
diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
index 3c791155..d07ed9d1 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -51,6 +51,8 @@
extern bool show_info;
extern bool show_warnings;
+extern bool exit_on_fail;
+extern bool exit_on_warn;
extern int kernel_version;
extern int media_fd;
extern unsigned warnings;
@@ -136,6 +138,8 @@ struct node : public base_node, public cv4l_fd {
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...) \
@@ -148,12 +152,16 @@ struct node : public base_node, public cv4l_fd {
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); \
1; \
})

Privacy Policy