[gst-cvs] CVS: gstreamer/testsuite/bytestream testfile1,NONE,1.1.2.1 gstbstest.c,1.1.2.2,1.1.2.3 test1.c,1.1.2.3,1.1.2.4
Wim Taymans
wtay at users.sourceforge.net
Sun Oct 14 08:56:03 PDT 2001
Update of /cvsroot/gstreamer/gstreamer/testsuite/bytestream
In directory usw-pr-cvs1:/tmp/cvs-serv16163
Modified Files:
Tag: BRANCH-EVENTS1
gstbstest.c test1.c
Added Files:
Tag: BRANCH-EVENTS1
testfile1
Log Message:
More cleanups, added a pattern argument to bstest. The testsuite is now
driven by a config file.
--- NEW FILE: testfile1 ---
# lots of parameters here. values for the columns are like:
#
# - data property in fakesrc: 1 = allocate, 2 = subbuffer
# - sizetype property in fakesrc: 2 = fixed, 3 = random
#
# - accesspattern for bstest
# <action><size>[:<action><size>...]
#
# <action> can be:
# r = read
# p = peek
# pb = peek bytes
# f = flush
# <size> can be:
# <empty> = fixed size
# r = random size
# < = previous size
# <int> = this size
#
# - integrity check: 0 = no, 1 = yes
#
1 2 r 1
1 2 rr 1
1 3 r 1
1 3 rr 1
2 2 r 1
2 2 rr 1
2 3 r 1
2 3 rr 1
1 2 p:r< 1
1 2 pr:r< 1
1 3 p:r< 1
1 3 pr:r< 1
2 2 p:r< 1
2 2 pr:r< 1
2 3 p:r< 1
2 3 pr:r< 1
1 2 p:rr 1
1 2 pr:rr 1
1 3 p:rr 1
1 3 pr:rr 1
2 2 p:rr 1
2 2 pr:rr 1
2 3 p:rr 1
2 3 pr:rr 1
Index: gstbstest.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/testsuite/bytestream/Attic/gstbstest.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- gstbstest.c 2001/10/14 02:52:27 1.1.2.2
+++ gstbstest.c 2001/10/14 15:55:49 1.1.2.3
@@ -21,6 +21,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include <gst/gst.h>
#include <libs/bytestream/gstbytestream.h>
@@ -34,21 +35,6 @@
typedef struct _GstBsTest GstBsTest;
typedef struct _GstBsTestClass GstBsTestClass;
-typedef enum
-{
- BSTEST_SIZETYPE_FIXED = 1,
- BSTEST_SIZETYPE_RANDOM
-}
-GstBsTestSizeType;
-
-typedef enum
-{
- BSTEST_ACCESSTYPE_READ = 1,
- BSTEST_ACCESSTYPE_PEEK_READ,
- BSTEST_ACCESSTYPE_PEEK_READRAND,
-}
-GstBsTestAccessType;
-
struct _GstBsTest
{
GstElement element;
@@ -57,12 +43,13 @@
GstPad *srcpad;
GstByteStream *bs;
- GstBsTestSizeType sizetype;
- GstBsTestAccessType accesstype;
- guint sizemin;
- guint sizemax;
- gint count;
- gboolean silent;
+
+ gchar *accesspattern;
+ gchar **patterns;
+ guint sizemin;
+ guint sizemax;
+ gint count;
+ gboolean silent;
};
struct _GstBsTestClass
@@ -93,12 +80,11 @@
enum
{
ARG_0,
- ARG_SIZETYPE,
ARG_SIZEMIN,
ARG_SIZEMAX,
- ARG_ACCESSTYPE,
ARG_COUNT,
ARG_SILENT,
+ ARG_ACCESSPATTERN,
};
@@ -117,40 +103,6 @@
// static guint gst_bstest_signals[LAST_SIGNAL] = { 0 };
-#define GST_TYPE_BSTEST_SIZETYPE (gst_bstest_sizetype_get_type())
-static GType
-gst_bstest_sizetype_get_type (void)
-{
- static GType bstest_sizetype_type = 0;
- static GEnumValue bstest_sizetype[] = {
- {BSTEST_SIZETYPE_FIXED, "1", "Fixed size buffers (sizemax sized)"},
- {BSTEST_SIZETYPE_RANDOM, "2", "Random sized buffers (sizemin <= size <= sizemax)"},
- {0, NULL, NULL},
- };
-
- if (!bstest_sizetype_type) {
- bstest_sizetype_type = g_enum_register_static ("GstBsTestSizeType", bstest_sizetype);
- }
- return bstest_sizetype_type;
-}
-
-#define GST_TYPE_BSTEST_ACCESSTYPE (gst_bstest_accesstype_get_type())
-static GType
-gst_bstest_accesstype_get_type (void)
-{
- static GType bstest_accesstype_type = 0;
- static GEnumValue bstest_accesstype[] = {
- {BSTEST_ACCESSTYPE_READ, "1", "Read data"},
- {BSTEST_ACCESSTYPE_PEEK_READ, "2", "Peek data, read data (same size)"},
- {BSTEST_ACCESSTYPE_PEEK_READRAND, "3", "Peek data, read data (different size)"},
- {0, NULL, NULL},
- };
-
- if (!bstest_accesstype_type) {
- bstest_accesstype_type = g_enum_register_static ("GstBsTestAccessType", bstest_accesstype);
- }
- return bstest_accesstype_type;
-}
GType
gst_bstest_get_type (void)
{
@@ -184,20 +136,15 @@
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE,
- g_param_spec_enum ("sizetype", "sizetype", "sizetype",
- GST_TYPE_BSTEST_SIZETYPE,
- BSTEST_SIZETYPE_FIXED, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT,
0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT,
384, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACCESSTYPE,
- g_param_spec_enum ("accesstype", "accesstype", "accesstype",
- GST_TYPE_BSTEST_ACCESSTYPE,
- BSTEST_ACCESSTYPE_READ, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACCESSPATTERN,
+ g_param_spec_string ("accesspattern", "accesspattern", "accesspattern",
+ "r", G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COUNT,
g_param_spec_uint ("count", "count", "count",
0, G_MAXUINT, 0, G_PARAM_READWRITE));
@@ -245,26 +192,36 @@
gst_element_set_loop_function (GST_ELEMENT (bstest), gst_bstest_loop);
- bstest->sizetype = BSTEST_SIZETYPE_FIXED;
bstest->sizemin = 0;
bstest->sizemax = 384;
- bstest->accesstype = BSTEST_ACCESSTYPE_READ;
+ bstest->accesspattern = g_strdup ("r");
+ bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0);
bstest->count = 5;
bstest->silent = FALSE;
bstest->bs = NULL;
}
static guint
-gst_bstest_get_size (GstBsTest *bstest)
+gst_bstest_get_size (GstBsTest *bstest, gchar *sizestring, guint prevsize)
{
- switch (bstest->sizetype) {
- case BSTEST_SIZETYPE_FIXED:
- return bstest->sizemax;
- break;
- case BSTEST_SIZETYPE_RANDOM:
- return bstest->sizemin + (guint8)(((gfloat)bstest->sizemax)*rand()/(RAND_MAX + (gfloat)bstest->sizemin));
- break;
+ guint size;
+
+ if (sizestring[0] == 0) {
+ size = bstest->sizemax;
+ }
+ else if (sizestring[0] == 'r') {
+ size = bstest->sizemin + (guint8)(((gfloat)bstest->sizemax)*rand()/(RAND_MAX + (gfloat)bstest->sizemin));
}
+ else if (sizestring[0] == '<') {
+ size = prevsize;
+ }
+ else {
+ size = atoi (sizestring);
+ }
+
+ if (size == 0) size++;
+
+ return size;
}
static void
@@ -272,7 +229,6 @@
{
GstBsTest *bstest;
GstBuffer *buf = NULL;
- gint i;
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_BSTEST (element));
@@ -281,43 +237,41 @@
/* THIS IS THE BUFFER BASED ONE */
do {
- for (i = 0; i < bstest->count; i++) {
- guint size;
+ guint size = 0;
+ guint i = 0;
- size = gst_bstest_get_size (bstest);
- if (size == 0) {
- buf = gst_buffer_new ();
- }
- else {
+ while (bstest->patterns[i]) {
+ buf = NULL;
- switch (bstest->accesstype) {
- case BSTEST_ACCESSTYPE_PEEK_READ:
- if (!bstest->silent) g_print ("bstest: ***** peek %d bytes\n", size);
- gst_bytestream_peek_bytes (bstest->bs, size);
- // fall though
- case BSTEST_ACCESSTYPE_READ:
- if (!bstest->silent) g_print ("bstest: ***** read %d bytes\n", size);
- buf = gst_bytestream_read (bstest->bs, size);
- break;
- case BSTEST_ACCESSTYPE_PEEK_READRAND:
- if (!bstest->silent) g_print ("bstest: ***** peek %d bytes\n", size);
- gst_bytestream_peek_bytes (bstest->bs, size);
- size = gst_bstest_get_size (bstest);
- if (!bstest->silent) g_print ("bstest: ***** read %d bytes\n", size);
- if (size == 0) {
- buf = gst_buffer_new ();
- }
- else {
- buf = gst_bytestream_read (bstest->bs, size);
- }
- break;
- }
+ if (bstest->patterns[i][0] == 'r') {
+ size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
+ if (!bstest->silent) g_print ("bstest: ***** read %d bytes\n", size);
+ buf = gst_bytestream_read (bstest->bs, size);
}
- if (!buf)
- g_print ("BUFFER IS BOGUS\n");
- else
+ else if (bstest->patterns[i][0] == 'f') {
+ size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
+ if (!bstest->silent) g_print ("bstest: ***** flush %d bytes\n", size);
+ gst_bytestream_flush (bstest->bs, size);
+ }
+ else if (!strncmp (bstest->patterns[i], "pb", 2)) {
+ size = gst_bstest_get_size (bstest, &bstest->patterns[i][2], size);
+ if (!bstest->silent) g_print ("bstest: ***** peek bytes %d bytes\n", size);
+ gst_bytestream_peek_bytes (bstest->bs, size);
+ }
+ else if (bstest->patterns[i][0] == 'p') {
+ size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size);
+ if (!bstest->silent) g_print ("bstest: ***** peek %d bytes\n", size);
+ buf = gst_bytestream_peek (bstest->bs, size);
+ gst_buffer_unref (buf);
+ buf = NULL;
+ }
+
+ if (buf)
gst_pad_push (bstest->srcpad, buf);
+
+ i++;
}
+
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
}
@@ -332,17 +286,25 @@
bstest = GST_BSTEST (object);
switch (prop_id) {
- case ARG_SIZETYPE:
- bstest->sizetype = g_value_get_int (value);
- break;
case ARG_SIZEMIN:
bstest->sizemin = g_value_get_int (value);
break;
case ARG_SIZEMAX:
bstest->sizemax = g_value_get_int (value);
break;
- case ARG_ACCESSTYPE:
- bstest->accesstype = g_value_get_int (value);
+ case ARG_ACCESSPATTERN:
+ if (bstest->accesspattern) {
+ g_free (bstest->accesspattern);
+ g_strfreev (bstest->patterns);
+ }
+ if (g_value_get_string (value) == NULL) {
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
+ bstest->accesspattern = NULL;
+ /* otherwise set the new filename */
+ } else {
+ bstest->accesspattern = g_strdup (g_value_get_string (value));
+ bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0);
+ }
break;
case ARG_COUNT:
bstest->count = g_value_get_uint (value);
@@ -367,17 +329,14 @@
bstest = GST_BSTEST (object);
switch (prop_id) {
- case ARG_SIZETYPE:
- g_value_set_int (value, bstest->sizetype);
- break;
case ARG_SIZEMIN:
g_value_set_int (value, bstest->sizemin);
break;
case ARG_SIZEMAX:
g_value_set_int (value, bstest->sizemax);
break;
- case ARG_ACCESSTYPE:
- g_value_set_int (value, bstest->accesstype);
+ case ARG_ACCESSPATTERN:
+ g_value_set_string (value, bstest->accesspattern);
break;
case ARG_COUNT:
g_value_set_uint (value, bstest->count);
Index: test1.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/testsuite/bytestream/Attic/test1.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- test1.c 2001/10/14 02:52:27 1.1.2.3
+++ test1.c 2001/10/14 15:55:49 1.1.2.4
@@ -1,65 +1,44 @@
+#include <string.h>
+#include <stdlib.h>
+
#include <gst/gst.h>
#include "mem.h"
#define VM_THRES 1000
+#define MAX_CONFIG_LINE 255
+#define MAX_CONFIG_PATTERN 64
typedef struct
{
- gchar *desc;
gint src_data;
gint src_sizetype;
- gint src_filltype;
- gboolean src_silent;
- gint bs_sizetype;
- gint bs_accesstype;
- gboolean bs_silent;
+ gchar *bs_accesspattern;
- gboolean sink_dump;
- gboolean sink_silent;
+ gboolean integrity_check;
} TestParam;
-static TestParam params[] = {
- {"fixed size src, fixed size _read", 1, 2, 5, TRUE, 1, 1, TRUE, FALSE, TRUE },
- {"fixed size src, random size _read", 1, 2, 5, TRUE, 2, 1, TRUE, FALSE, TRUE },
- {"random size src, fixed size _read", 1, 3, 5, TRUE, 1, 1, TRUE, FALSE, TRUE },
- {"random size src, random size _read", 1, 3, 5, TRUE, 2, 1, TRUE, FALSE, TRUE },
- {"fixed size subbuffer, fixed size _read", 2, 2, 5, TRUE, 1, 1, TRUE, FALSE, TRUE },
- {"fixed size subbuffer, random size _read", 2, 2, 5, TRUE, 2, 1, TRUE, FALSE, TRUE },
- {"random size subbuffer, fixed size _read", 2, 3, 5, TRUE, 1, 1, TRUE, FALSE, TRUE },
- {"random size subbuffer, random size _read", 2, 3, 5, TRUE, 2, 1, TRUE, FALSE, TRUE },
- {"fixed size src, fixed size _peek_read", 1, 2, 5, TRUE, 1, 2, TRUE, FALSE, TRUE },
- {"fixed size src, random size _peek_read", 1, 2, 5, TRUE, 2, 2, TRUE, FALSE, TRUE },
- {"random size src, fixed size _peek_read", 1, 3, 5, TRUE, 1, 2, TRUE, FALSE, TRUE },
- {"random size src, random size _peek_read", 1, 3, 5, TRUE, 2, 2, TRUE, FALSE, TRUE },
- {"fixed size subbuffer, fixed size _peek_read", 2, 2, 5, TRUE, 1, 2, TRUE, FALSE, TRUE },
- {"fixed size subbuffer, random size _peek_read", 2, 2, 5, TRUE, 2, 2, TRUE, FALSE, TRUE },
- {"random size subbuffer, fixed size _peek_read", 2, 3, 5, TRUE, 1, 2, TRUE, FALSE, TRUE },
- {"random size subbuffer, random size _peek_read", 2, 3, 5, TRUE, 2, 2, TRUE, FALSE, TRUE },
- {"fixed size src, fixed size _peek_readrand", 1, 2, 5, TRUE, 1, 3, TRUE, FALSE, TRUE },
- {"fixed size src, random size _peek_readrand", 1, 2, 5, TRUE, 2, 3, TRUE, FALSE, TRUE },
- {"random size src, fixed size _peek_readrand", 1, 3, 5, TRUE, 1, 3, TRUE, FALSE, TRUE },
- {"random size src, random size _peek_readrand", 1, 3, 5, TRUE, 2, 3, TRUE, FALSE, TRUE },
- {"fixed size subbuffer, fixed size _peek_readrand", 2, 2, 5, TRUE, 1, 3, TRUE, FALSE, TRUE },
- {"fixed size subbuffer, random size _peek_readrand", 2, 2, 5, TRUE, 2, 3, TRUE, FALSE, TRUE },
- {"random size subbuffer, fixed size _peek_readrand", 2, 3, 5, TRUE, 1, 3, TRUE, FALSE, TRUE },
- {"random size subbuffer, random size _peek_readrand", 2, 3, 5, TRUE, 2, 3, TRUE, FALSE, TRUE },
- {NULL, 2, 3, 5, TRUE, 2, 2, TRUE, FALSE, TRUE }
-};
+static GSList *params = NULL;
static guint8 count;
+static guint8 iters;
+static gboolean integrity_check = TRUE;
+static gboolean verbose = FALSE;
+static gboolean dump = FALSE;
static void
handoff (GstElement *element, GstBuffer *buf, GstPad *pad, gpointer data)
{
if (GST_IS_BUFFER (buf)) {
- gint i;
- guint8 *ptr = GST_BUFFER_DATA (buf);
+ if (integrity_check) {
+ gint i;
+ guint8 *ptr = GST_BUFFER_DATA (buf);
- for (i=0; i<GST_BUFFER_SIZE (buf); i++) {
- if (*ptr++ != count++) {
- g_print ("data error!\n");
- return;
+ for (i=0; i<GST_BUFFER_SIZE (buf); i++) {
+ if (*ptr++ != count++) {
+ g_print ("data error!\n");
+ return;
+ }
}
}
}
@@ -67,6 +46,60 @@
g_print ("not a buffer ! %p\n", buf);
}
}
+static gchar*
+create_desc (TestParam *param)
+{
+ gchar *desc;
+
+ desc = g_strdup_printf ("%s %s, pattern %s", (param->src_sizetype == 2 ? "fixed" : "random"),
+ (param->src_data == 1 ? "src" : "subbuffer"),
+ param->bs_accesspattern);
+ return desc;
+}
+
+static gboolean
+read_param_file (gchar *filename)
+{
+ FILE *fp;
+ gchar line[MAX_CONFIG_LINE+1];
+ guint linenr = 0;
+ gchar pattern[MAX_CONFIG_PATTERN];
+ gint data, sizetype, integrity_check;
+ gchar *scan_str;
+ gboolean res = TRUE;
+
+ fp = fopen (filename, "r");
+ if (fp == NULL)
+ return FALSE;
+
+ scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN-1);
+
+ while (fgets (line, MAX_CONFIG_LINE, fp)) {
+ linenr++;
+
+ if (line[0] == '\n' || line[0] == '#')
+ continue;
+
+ if (sscanf (line, scan_str, &data, &sizetype, pattern, &integrity_check) != 4) {
+ g_print ("error on line: %d\n", linenr);
+ res = FALSE;
+ break;
+ }
+ else {
+ TestParam *param = g_malloc (sizeof (TestParam));
+
+ param->src_data = data;
+ param->src_sizetype = sizetype;
+ param->bs_accesspattern = g_strdup (pattern);
+ param->integrity_check = (integrity_check == 0 ? FALSE : TRUE);
+
+ params = g_slist_append (params, param);
+ }
+ }
+ g_free (scan_str);
+
+ return res;
+}
static void
run_test (GstBin *pipeline, gint iters)
@@ -96,6 +129,12 @@
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
}
+static void
+usage (char *argv[])
+{
+ g_print ("usage: %s [--verbose] [--dump] <paramfile> <iterations>\n", argv[0]);
+}
+
int
main (int argc, char *argv[])
{
@@ -104,9 +143,34 @@
GstElement *bs;
GstElement *pipeline;
gint testnum = 0;
+ GSList *walk;
+ gint arg_walk;
gst_init (&argc, &argv);
+ arg_walk = 1;
+ while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) {
+ if (!strncmp (argv[arg_walk], "--verbose", 9))
+ verbose = TRUE;
+ else if (!strncmp (argv[arg_walk], "--dump", 6))
+ dump = TRUE;
+ else {
+ g_print ("unknown option %s (ignored)\n", argv[arg_walk]);
+ }
+
+ arg_walk++;
+ }
+ if (argc - arg_walk < 2) {
+ usage(argv);
+ return -1;
+ }
+ if (!read_param_file (argv[arg_walk])) {
+ g_print ("error reading file %s\n", argv[arg_walk]);
+ usage (argv);
+ return -1;
+ }
+ iters = atoi (argv[++arg_walk]);
+
pipeline = gst_elementfactory_make ("pipeline", "pipeline");
g_assert (pipeline);
@@ -127,25 +191,35 @@
gst_bin_add (GST_BIN (pipeline), bs);
gst_bin_add (GST_BIN (pipeline), sink);
- while (params[testnum].desc) {
+ walk = params;
+
+ while (walk) {
+ gchar *desc;
+ TestParam *param = (TestParam *) (walk->data);
+
+ integrity_check = param->integrity_check;
+
g_print ("\n\nrunning test %d:\n", testnum+1);
- g_print ("%s\n", params[testnum].desc);
+ desc = create_desc (param);
+ g_print ("%s\n", desc);
+ g_free (desc);
- g_object_set (G_OBJECT (src), "data", params[testnum].src_data,
- "sizetype", params[testnum].src_sizetype,
- "filltype", params[testnum].src_filltype,
- "silent", params[testnum].src_silent, NULL);
+ g_object_set (G_OBJECT (src), "data", param->src_data,
+ "sizetype", param->src_sizetype,
+ "filltype", (integrity_check?5:0),
+ "silent", !verbose, NULL);
- g_object_set (G_OBJECT (bs), "sizetype", params[testnum].bs_sizetype,
- "accesstype", params[testnum].bs_accesstype,
- "silent", TRUE, NULL);
+ g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern,
+ "silent", !verbose, NULL);
- g_object_set (G_OBJECT (sink), "dump", params[testnum].sink_dump,
- "silent", params[testnum].sink_silent, NULL);
+ g_object_set (G_OBJECT (sink), "dump", dump,
+ "silent", !verbose, NULL);
- run_test (GST_BIN (pipeline), 50000);
+ run_test (GST_BIN (pipeline), iters);
testnum++;
+
+ walk = g_slist_next (walk);
}
g_print ("\n\ndone\n");
More information about the Gstreamer-commits
mailing list