summaryrefslogtreecommitdiff
path: root/v4l2-apps/test
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-03-12 11:10:42 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-12 11:10:42 -0300
commit7787613f5c5a3a00ebd6aca9893ef2c4ad679bc1 (patch)
tree4ffb8dbda509405c10b484edacb44807b16c5466 /v4l2-apps/test
parent84c19b03d182a3ad1a04fa4be0772ef587225fe6 (diff)
parentd32bcc1401cca5f2ea369ce78ab70947034b5c8f (diff)
downloadmediapointer-dvb-s2-7787613f5c5a3a00ebd6aca9893ef2c4ad679bc1.tar.gz
mediapointer-dvb-s2-7787613f5c5a3a00ebd6aca9893ef2c4ad679bc1.tar.bz2
merge: http://jusst.de/hg/v4l-dvb
From: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'v4l2-apps/test')
-rw-r--r--v4l2-apps/test/Makefile9
-rw-r--r--v4l2-apps/test/capture-example.c (renamed from v4l2-apps/test/capture_example.c)10
-rw-r--r--v4l2-apps/test/driver-test.c2
-rw-r--r--v4l2-apps/test/ioctl-test.c2
-rw-r--r--v4l2-apps/test/stress-buffer.c140
5 files changed, 150 insertions, 13 deletions
diff --git a/v4l2-apps/test/Makefile b/v4l2-apps/test/Makefile
index faafed14d..d118b9210 100644
--- a/v4l2-apps/test/Makefile
+++ b/v4l2-apps/test/Makefile
@@ -9,7 +9,8 @@ binaries = ioctl-test \
v4lgrab \
driver-test \
pixfmt-test \
- capture_example
+ stress-buffer \
+ capture-example
.PHONY: all clean install
@@ -20,10 +21,10 @@ clean::
install:
-../lib/libv4l2.a: ../lib/v4l2_driver.c ../lib/frequencies.c
- make -C ../lib libv4l2.a
+../libv4l2util/libv4l2util.a: ../libv4l2util/v4l2_driver.c ../libv4l2util/frequencies.c
+ make -C ../libv4l2util libv4l2util.a
-driver-test: driver-test.o ../lib/libv4l2.a
+driver-test: driver-test.o ../libv4l2util/libv4l2util.a
pixfmt-test: pixfmt-test.o
$(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ -lX11
diff --git a/v4l2-apps/test/capture_example.c b/v4l2-apps/test/capture-example.c
index 0cd129885..9d5b0d6ce 100644
--- a/v4l2-apps/test/capture_example.c
+++ b/v4l2-apps/test/capture-example.c
@@ -23,17 +23,15 @@
#include <sys/mman.h>
#include <sys/ioctl.h>
-#include <asm/types.h> /* for videodev2.h */
-
#include <linux/videodev2.h>
#define CLEAR(x) memset(&(x), 0, sizeof(x))
-typedef enum {
+enum io_method {
IO_METHOD_READ,
IO_METHOD_MMAP,
IO_METHOD_USERPTR,
-} io_method;
+};
struct buffer {
void *start;
@@ -41,7 +39,7 @@ struct buffer {
};
static char *dev_name;
-static io_method io = IO_METHOD_MMAP;
+static enum io_method io = IO_METHOD_MMAP;
static int fd = -1;
struct buffer *buffers;
static unsigned int n_buffers;
@@ -570,7 +568,7 @@ static void usage(FILE *fp, int argc, char **argv)
"-f | --format Force format to 640x480 YUYV\n"
"-c | --count Number of frames to grab [%i]\n"
"",
- argv[0],dev_name,frame_count );
+ argv[0], dev_name, frame_count);
}
static const char short_options[] = "d:hmruofc:";
diff --git a/v4l2-apps/test/driver-test.c b/v4l2-apps/test/driver-test.c
index e4c16ed54..1f722e198 100644
--- a/v4l2-apps/test/driver-test.c
+++ b/v4l2-apps/test/driver-test.c
@@ -14,7 +14,7 @@
GNU General Public License for more details.
*/
-#include "../lib/v4l2_driver.h"
+#include "../libv4l2util/v4l2_driver.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
diff --git a/v4l2-apps/test/ioctl-test.c b/v4l2-apps/test/ioctl-test.c
index f9ac1cad5..883282106 100644
--- a/v4l2-apps/test/ioctl-test.c
+++ b/v4l2-apps/test/ioctl-test.c
@@ -90,7 +90,6 @@ union v4l_parms {
struct v4l2_encoder_cmd p_v4l2_encoder_cmd;
struct v4l2_dbg_register p_v4l2_dbg_register;
struct v4l2_dbg_chip_ident p_v4l2_dbg_chip_ident;
- struct v4l2_chip_ident_old p_v4l2_chip_ident_old;
struct v4l2_hw_freq_seek p_v4l2_hw_freq_seek;
};
@@ -197,7 +196,6 @@ static const struct {
ioc(VIDIOC_DBG_S_REGISTER), /* struct v4l2_register */
ioc(VIDIOC_DBG_G_REGISTER), /* struct v4l2_register */
ioc(VIDIOC_DBG_G_CHIP_IDENT), /* struct v4l2_dbg_chip_ident */
- ioc(VIDIOC_G_CHIP_IDENT_OLD), /* struct v4l2_chip_ident_old */
ioc(VIDIOC_S_HW_FREQ_SEEK), /* struct v4l2_hw_freq_seek */
#ifdef __OLD_VIDIOC_
ioc(VIDIOC_OVERLAY_OLD), /* int */
diff --git a/v4l2-apps/test/stress-buffer.c b/v4l2-apps/test/stress-buffer.c
new file mode 100644
index 000000000..60410c70c
--- /dev/null
+++ b/v4l2-apps/test/stress-buffer.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2009 Douglas Schilling Landgraf <dougsland@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * stress-buffer tool makes infinite calls using read() for
+ * any device specified by the command argument.
+ *
+ * The size of buffer shall be a random number from 0 up to 1000.
+ *
+ * Also is automatically created a file called: stats-M-D-Y-h-m-s.txt
+ * in current directory with data executed.
+ *
+ * The stress test is performed by several read() calls,
+ * and it helped to identify real issues like:
+ *
+ * - memory leaks
+ * - specific crashs that are rare and hard to reproduce
+ *
+ * To compile:
+ * gcc -o stress-buffer stress-buffer.c -Wall
+ *
+ * To execute:
+ * ./stress-buffer /dev/device_for_test
+ *
+ * Example:
+ * ./stress-buffer /dev/video0
+ */
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+ char buffer[1000];
+ char fname[30];
+ int fd, ret, magic_buffer_size, cnt = 0;
+ time_t t1, t2;
+ double dif;
+ time_t current;
+ struct tm *timep;
+
+ FILE *fd_file;
+
+ if (argc != 2) {
+ printf("Usage: %s /dev/device_to_test\n", argv[0]);
+ return -1;
+ }
+
+ current = time(NULL);
+ timep = localtime(&current);
+
+ memset(fname, 0, sizeof(fname));
+
+ snprintf(fname, sizeof(fname), "stats-%.2d-%.2d-%.2d-%.2d-%.2d-%.2d.txt",
+ timep->tm_mon+1, timep->tm_mday, timep->tm_year + 1900,
+ timep->tm_hour, timep->tm_min, timep->tm_sec);
+
+ fd_file = fopen(fname, "a+");
+ if (!fd_file) {
+ perror("error opening file");
+ return -1;
+ }
+
+ srand(time(NULL));
+
+ while (1) {
+
+ if (time(&t1) < 0) {
+ perror("time_t t1");
+ fclose(fd_file);
+ return -1;
+ }
+
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ perror("error opening device");
+ fclose(fd_file);
+ return -1;
+ }
+
+ /* Random number 0 - 1000 */
+ magic_buffer_size = rand() % sizeof(buffer);
+
+ memset(buffer, 0, sizeof(buffer));
+
+ ret = access(fname, W_OK);
+ if (ret < 0) {
+ close(fd);
+ perror("Error");
+ return -1;
+ }
+
+ ret = read(fd, buffer, magic_buffer_size);
+ if (ret < 0) {
+ fprintf(fd_file, "[%s] error reading buffer - [%s]\n",
+ argv[1], strerror(errno));
+ fflush(fd_file);
+ perror("error reading buffer from device");
+ return -1;
+ }
+
+ if (time(&t2) < 0) {
+ perror("time_t t2");
+ fclose(fd_file);
+ return -1;
+ }
+
+ dif = difftime(t2, t1);
+
+ printf("Seconds: [%d] - Test Number: [%d] - Read [%d] bytes\n",
+ (int)dif, cnt, ret);
+
+ fprintf(fd_file, "Seconds: [%.2f] - Test number: [%d] - Read [%d] bytes\n",
+ dif, cnt, ret);
+
+ fflush(fd_file);
+
+ cnt++;
+
+ close(fd);
+
+ }
+ return 0;
+}