[aravis] tests: http loading test program



commit adcdfea4284108475df0d3a3d4f479eaff0451ce
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Thu Nov 19 10:26:04 2015 +0100

    tests: http loading test program

 src/arvgvdevice.c    |    2 +-
 tests/.gitignore     |    1 +
 tests/Makefile.am    |    6 ++++-
 tests/loadhttptest.c |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+), 2 deletions(-)
---
diff --git a/src/arvgvdevice.c b/src/arvgvdevice.c
index 204cb84..77c35e4 100644
--- a/src/arvgvdevice.c
+++ b/src/arvgvdevice.c
@@ -619,7 +619,7 @@ _load_genicam (ArvGvDevice *gv_device, guint32 address, size_t  *size)
                                        *size = 0;
                                }
                        }
-        } else if (g_ascii_strcasecmp (tokens[1], "http:") == 0) {
+               } else if (g_ascii_strcasecmp (tokens[1], "http:") == 0) {
                        GFile *file;
                        GFileInputStream *stream;
 
diff --git a/tests/.gitignore b/tests/.gitignore
index b9a1e6c..e90eedd 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -14,3 +14,4 @@ arv-heartbeat-test
 arv-example
 time-test
 realtime-test
+load-http-test
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ea440a3..b633436 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,7 +18,8 @@ noinst_PROGRAMS =                     \
                arv-heartbeat-test              \
                arv-example                     \
        time-test                       \
-       realtime-test
+       realtime-test                   \
+       load-http-test
 
 arv_test_SOURCES = arvtest.c
 arv_test_LDADD = $(test_progs_ldadd)
@@ -50,6 +51,9 @@ time_test_LDADD = $(test_progs_ldadd)
 realtime_test_SOURCES = realtimetest.c
 realtime_test_LDADD = $(test_progs_ldadd)
 
+load_http_test_SOURCES = loadhttptest.c
+load_http_test_LDADD = $(test_progs_ldadd)
+
 TEST_PROGS += evaluator buffer misc fake genicam
 if ARAVIS_BUILD_CPP_TEST
 TEST_PROGS += cpp
diff --git a/tests/loadhttptest.c b/tests/loadhttptest.c
new file mode 100644
index 0000000..c80cdb5
--- /dev/null
+++ b/tests/loadhttptest.c
@@ -0,0 +1,51 @@
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <arv.h>
+
+int
+main (int argc, char **argv)
+{
+       GFile *file;
+       GFileInputStream *stream;
+       const char *filename;
+       char *genicam = NULL;
+       char **tokens;
+       gsize len = 0;
+
+       if (argc != 2) {
+               printf ("Usage: load-http-test <URL>\n");
+               return EXIT_FAILURE;
+       }
+
+       filename = argv[1];
+
+       tokens = g_regex_split (arv_gv_device_get_url_regex (), filename, 0);
+
+       if (tokens[0] != NULL && tokens[1] != NULL) {
+               if (g_ascii_strcasecmp (tokens[1], "http:") == 0) {
+                       file = g_file_new_for_uri (filename);
+                       stream = g_file_read (file, NULL, NULL);
+                       if(stream) {
+                               GDataInputStream *data_stream;
+
+                               data_stream = g_data_input_stream_new (G_INPUT_STREAM (stream));
+                               genicam = g_data_input_stream_read_upto (data_stream, "", 0, &len, NULL, 
NULL);
+
+                               g_object_unref (data_stream);
+                               g_object_unref (stream);
+                       }
+                       g_object_unref (file);
+               }
+       }
+
+       g_strfreev (tokens);
+
+       printf ("size = %lu\n", len);
+       printf ("%s\n", genicam != NULL ? genicam : "NULL");
+
+       g_free (genicam);
+
+       return EXIT_SUCCESS;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]