[Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-08 Thread marcandre . lureau
From: Marc-André Lureau 

For some reason, the URIs test didn't include spice+unix:// checks,
probably because they came about the same time.

Signed-off-by: Marc-André Lureau 
---
 tests/session.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/tests/session.c b/tests/session.c
index 7ed4a41..413d812 100644
--- a/tests/session.c
+++ b/tests/session.c
@@ -9,6 +9,7 @@ typedef struct {
 const gchar *uri_input;
 const gchar *uri_output;
 const gchar *message;
+const gchar *unix_path;
 } TestCase;
 
 static void test_session_uri_bad(void)
@@ -139,7 +140,7 @@ static void test_session_uri_good(const TestCase *tests, 
const guint cases)
 
 /* Set URI and check URI, port and tls_port */
 for (i = 0; i < cases; i++) {
-gchar *uri, *port, *tls_port, *host, *username, *password;
+gchar *uri, *port, *tls_port, *host, *username, *password, *unix_path;
 
 s = spice_session_new();
 if (tests[i].message != NULL)
@@ -152,20 +153,23 @@ static void test_session_uri_good(const TestCase *tests, 
const guint cases)
  "host", &host,
  "username", &username,
  "password", &password,
+ "unix-path", &unix_path,
   NULL);
-g_assert_cmpstr(tests[i].uri_output, ==, uri);
+g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==, uri);
 g_assert_cmpstr(tests[i].port, ==, port);
 g_assert_cmpstr(tests[i].tls_port, ==, tls_port);
 g_assert_cmpstr(tests[i].host, ==, host);
 g_assert_cmpstr(tests[i].username, ==, username);
 g_assert_cmpstr(tests[i].password, ==, password);
 g_test_assert_expected_messages();
+g_assert_cmpstr(tests[i].unix_path, ==, unix_path);
 g_clear_pointer(&uri, g_free);
 g_clear_pointer(&port, g_free);
 g_clear_pointer(&tls_port, g_free);
 g_clear_pointer(&host, g_free);
 g_clear_pointer(&username, g_free);
 g_clear_pointer(&password, g_free);
+g_clear_pointer(&unix_path, g_free);
 g_object_unref(s);
 }
 
@@ -180,9 +184,10 @@ static void test_session_uri_good(const TestCase *tests, 
const guint cases)
  "host", tests[i].host,
  "username", tests[i].username,
  "password", tests[i].password,
+ "unix-path", tests[i].unix_path,
   NULL);
 g_object_get(s, "uri", &uri, NULL);
-g_assert_cmpstr(tests[i].uri_output, ==, uri);
+g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==, uri);
 g_clear_pointer(&uri, g_free);
 g_object_unref(s);
 }
@@ -278,6 +283,22 @@ static void test_session_uri_ipv6_good(void)
 test_session_uri_good(tests, G_N_ELEMENTS(tests));
 }
 
+static void test_session_uri_unix_good(void)
+{
+const TestCase tests[] = {
+{ .uri_input = "spice+unix:///tmp/foo.sock",
+  .unix_path = "/tmp/foo.sock" },
+/* perhaps not very clever, but this doesn't raise an error/warning */
+{ .uri_input = "spice+unix://",
+  .unix_path = "" },
+/* unix uri don't support passing password or other kind of options */
+{ .uri_input = "spice+unix:///tmp/foo.sock?password=frobnicate",
+  .unix_path = "/tmp/foo.sock?password=frobnicate" },
+};
+
+test_session_uri_good(tests, G_N_ELEMENTS(tests));
+}
+
 int main(int argc, char* argv[])
 {
 g_test_init(&argc, &argv, NULL);
@@ -285,6 +306,7 @@ int main(int argc, char* argv[])
 g_test_add_func("/session/bad-uri", test_session_uri_bad);
 g_test_add_func("/session/good-ipv4-uri", test_session_uri_ipv4_good);
 g_test_add_func("/session/good-ipv6-uri", test_session_uri_ipv6_good);
+g_test_add_func("/session/good-unix", test_session_uri_unix_good);
 
 return g_test_run();
 }
-- 
2.16.1.73.g5832b7e9f2

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-08 Thread Frediano Ziglio
> 
> From: Marc-André Lureau 
> 
> For some reason, the URIs test didn't include spice+unix:// checks,
> probably because they came about the same time.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  tests/session.c | 28 +---
>  1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/session.c b/tests/session.c
> index 7ed4a41..413d812 100644
> --- a/tests/session.c
> +++ b/tests/session.c
> @@ -9,6 +9,7 @@ typedef struct {
>  const gchar *uri_input;
>  const gchar *uri_output;
>  const gchar *message;
> +const gchar *unix_path;
>  } TestCase;
>  
>  static void test_session_uri_bad(void)
> @@ -139,7 +140,7 @@ static void test_session_uri_good(const TestCase *tests,
> const guint cases)
>  
>  /* Set URI and check URI, port and tls_port */
>  for (i = 0; i < cases; i++) {
> -gchar *uri, *port, *tls_port, *host, *username, *password;
> +gchar *uri, *port, *tls_port, *host, *username, *password,
> *unix_path;
>  
>  s = spice_session_new();
>  if (tests[i].message != NULL)
> @@ -152,20 +153,23 @@ static void test_session_uri_good(const TestCase
> *tests, const guint cases)
>   "host", &host,
>   "username", &username,
>   "password", &password,
> + "unix-path", &unix_path,
>NULL);
> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==, uri);
>  g_assert_cmpstr(tests[i].port, ==, port);
>  g_assert_cmpstr(tests[i].tls_port, ==, tls_port);
>  g_assert_cmpstr(tests[i].host, ==, host);
>  g_assert_cmpstr(tests[i].username, ==, username);
>  g_assert_cmpstr(tests[i].password, ==, password);
>  g_test_assert_expected_messages();
> +g_assert_cmpstr(tests[i].unix_path, ==, unix_path);
>  g_clear_pointer(&uri, g_free);
>  g_clear_pointer(&port, g_free);
>  g_clear_pointer(&tls_port, g_free);
>  g_clear_pointer(&host, g_free);
>  g_clear_pointer(&username, g_free);
>  g_clear_pointer(&password, g_free);
> +g_clear_pointer(&unix_path, g_free);
>  g_object_unref(s);
>  }
>  
> @@ -180,9 +184,10 @@ static void test_session_uri_good(const TestCase *tests,
> const guint cases)
>   "host", tests[i].host,
>   "username", tests[i].username,
>   "password", tests[i].password,
> + "unix-path", tests[i].unix_path,
>NULL);
>  g_object_get(s, "uri", &uri, NULL);
> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==, uri);
>  g_clear_pointer(&uri, g_free);
>  g_object_unref(s);
>  }
> @@ -278,6 +283,22 @@ static void test_session_uri_ipv6_good(void)
>  test_session_uri_good(tests, G_N_ELEMENTS(tests));
>  }
>  
> +static void test_session_uri_unix_good(void)
> +{
> +const TestCase tests[] = {
> +{ .uri_input = "spice+unix:///tmp/foo.sock",
> +  .unix_path = "/tmp/foo.sock" },
> +/* perhaps not very clever, but this doesn't raise an error/warning
> */
> +{ .uri_input = "spice+unix://",
> +  .unix_path = "" },
> +/* unix uri don't support passing password or other kind of options
> */
> +{ .uri_input = "spice+unix:///tmp/foo.sock?password=frobnicate",
> +  .unix_path = "/tmp/foo.sock?password=frobnicate" },
> +};
> +
> +test_session_uri_good(tests, G_N_ELEMENTS(tests));
> +}
> +
>  int main(int argc, char* argv[])
>  {
>  g_test_init(&argc, &argv, NULL);
> @@ -285,6 +306,7 @@ int main(int argc, char* argv[])
>  g_test_add_func("/session/bad-uri", test_session_uri_bad);
>  g_test_add_func("/session/good-ipv4-uri", test_session_uri_ipv4_good);
>  g_test_add_func("/session/good-ipv6-uri", test_session_uri_ipv6_good);
> +g_test_add_func("/session/good-unix", test_session_uri_unix_good);
>  
>  return g_test_run();
>  }

Looks good (still to review better).
Can we consider this patch separate from the rest of the series
(that is merge even separately) ?

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-12 Thread Marc-André Lureau
Hi

On Thu, Feb 8, 2018 at 2:18 PM, Frediano Ziglio  wrote:
>>
>> From: Marc-André Lureau 
>>
>> For some reason, the URIs test didn't include spice+unix:// checks,
>> probably because they came about the same time.
>>
>> Signed-off-by: Marc-André Lureau 
>> ---
>>  tests/session.c | 28 +---
>>  1 file changed, 25 insertions(+), 3 deletions(-)
>>
>> diff --git a/tests/session.c b/tests/session.c
>> index 7ed4a41..413d812 100644
>> --- a/tests/session.c
>> +++ b/tests/session.c
>> @@ -9,6 +9,7 @@ typedef struct {
>>  const gchar *uri_input;
>>  const gchar *uri_output;
>>  const gchar *message;
>> +const gchar *unix_path;
>>  } TestCase;
>>
>>  static void test_session_uri_bad(void)
>> @@ -139,7 +140,7 @@ static void test_session_uri_good(const TestCase *tests,
>> const guint cases)
>>
>>  /* Set URI and check URI, port and tls_port */
>>  for (i = 0; i < cases; i++) {
>> -gchar *uri, *port, *tls_port, *host, *username, *password;
>> +gchar *uri, *port, *tls_port, *host, *username, *password,
>> *unix_path;
>>
>>  s = spice_session_new();
>>  if (tests[i].message != NULL)
>> @@ -152,20 +153,23 @@ static void test_session_uri_good(const TestCase
>> *tests, const guint cases)
>>   "host", &host,
>>   "username", &username,
>>   "password", &password,
>> + "unix-path", &unix_path,
>>NULL);
>> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
>> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==, uri);
>>  g_assert_cmpstr(tests[i].port, ==, port);
>>  g_assert_cmpstr(tests[i].tls_port, ==, tls_port);
>>  g_assert_cmpstr(tests[i].host, ==, host);
>>  g_assert_cmpstr(tests[i].username, ==, username);
>>  g_assert_cmpstr(tests[i].password, ==, password);
>>  g_test_assert_expected_messages();
>> +g_assert_cmpstr(tests[i].unix_path, ==, unix_path);
>>  g_clear_pointer(&uri, g_free);
>>  g_clear_pointer(&port, g_free);
>>  g_clear_pointer(&tls_port, g_free);
>>  g_clear_pointer(&host, g_free);
>>  g_clear_pointer(&username, g_free);
>>  g_clear_pointer(&password, g_free);
>> +g_clear_pointer(&unix_path, g_free);
>>  g_object_unref(s);
>>  }
>>
>> @@ -180,9 +184,10 @@ static void test_session_uri_good(const TestCase *tests,
>> const guint cases)
>>   "host", tests[i].host,
>>   "username", tests[i].username,
>>   "password", tests[i].password,
>> + "unix-path", tests[i].unix_path,
>>NULL);
>>  g_object_get(s, "uri", &uri, NULL);
>> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
>> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==, uri);
>>  g_clear_pointer(&uri, g_free);
>>  g_object_unref(s);
>>  }
>> @@ -278,6 +283,22 @@ static void test_session_uri_ipv6_good(void)
>>  test_session_uri_good(tests, G_N_ELEMENTS(tests));
>>  }
>>
>> +static void test_session_uri_unix_good(void)
>> +{
>> +const TestCase tests[] = {
>> +{ .uri_input = "spice+unix:///tmp/foo.sock",
>> +  .unix_path = "/tmp/foo.sock" },
>> +/* perhaps not very clever, but this doesn't raise an error/warning
>> */
>> +{ .uri_input = "spice+unix://",
>> +  .unix_path = "" },
>> +/* unix uri don't support passing password or other kind of options
>> */
>> +{ .uri_input = "spice+unix:///tmp/foo.sock?password=frobnicate",
>> +  .unix_path = "/tmp/foo.sock?password=frobnicate" },
>> +};
>> +
>> +test_session_uri_good(tests, G_N_ELEMENTS(tests));
>> +}
>> +
>>  int main(int argc, char* argv[])
>>  {
>>  g_test_init(&argc, &argv, NULL);
>> @@ -285,6 +306,7 @@ int main(int argc, char* argv[])
>>  g_test_add_func("/session/bad-uri", test_session_uri_bad);
>>  g_test_add_func("/session/good-ipv4-uri", test_session_uri_ipv4_good);
>>  g_test_add_func("/session/good-ipv6-uri", test_session_uri_ipv6_good);
>> +g_test_add_func("/session/good-unix", test_session_uri_unix_good);
>>
>>  return g_test_run();
>>  }
>
> Looks good (still to review better).
> Can we consider this patch separate from the rest of the series
> (that is merge even separately) ?

Sure, it was just in the same area of code, and thus added dependency,
but we can review & merge this one right away I think.
thanks


-- 
Marc-André Lureau
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-13 Thread Frediano Ziglio
> 
> Hi
> 
> On Thu, Feb 8, 2018 at 2:18 PM, Frediano Ziglio  wrote:
> >>
> >> From: Marc-André Lureau 
> >>
> >> For some reason, the URIs test didn't include spice+unix:// checks,
> >> probably because they came about the same time.
> >>
> >> Signed-off-by: Marc-André Lureau 
> >> ---
> >>  tests/session.c | 28 +---
> >>  1 file changed, 25 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/tests/session.c b/tests/session.c
> >> index 7ed4a41..413d812 100644
> >> --- a/tests/session.c
> >> +++ b/tests/session.c
> >> @@ -9,6 +9,7 @@ typedef struct {
> >>  const gchar *uri_input;
> >>  const gchar *uri_output;
> >>  const gchar *message;
> >> +const gchar *unix_path;
> >>  } TestCase;
> >>
> >>  static void test_session_uri_bad(void)
> >> @@ -139,7 +140,7 @@ static void test_session_uri_good(const TestCase
> >> *tests,
> >> const guint cases)
> >>
> >>  /* Set URI and check URI, port and tls_port */
> >>  for (i = 0; i < cases; i++) {
> >> -gchar *uri, *port, *tls_port, *host, *username, *password;
> >> +gchar *uri, *port, *tls_port, *host, *username, *password,
> >> *unix_path;
> >>
> >>  s = spice_session_new();
> >>  if (tests[i].message != NULL)
> >> @@ -152,20 +153,23 @@ static void test_session_uri_good(const TestCase
> >> *tests, const guint cases)
> >>   "host", &host,
> >>   "username", &username,
> >>   "password", &password,
> >> + "unix-path", &unix_path,
> >>NULL);
> >> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
> >> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==,
> >> uri);
> >>  g_assert_cmpstr(tests[i].port, ==, port);
> >>  g_assert_cmpstr(tests[i].tls_port, ==, tls_port);
> >>  g_assert_cmpstr(tests[i].host, ==, host);
> >>  g_assert_cmpstr(tests[i].username, ==, username);
> >>  g_assert_cmpstr(tests[i].password, ==, password);
> >>  g_test_assert_expected_messages();
> >> +g_assert_cmpstr(tests[i].unix_path, ==, unix_path);
> >>  g_clear_pointer(&uri, g_free);
> >>  g_clear_pointer(&port, g_free);
> >>  g_clear_pointer(&tls_port, g_free);
> >>  g_clear_pointer(&host, g_free);
> >>  g_clear_pointer(&username, g_free);
> >>  g_clear_pointer(&password, g_free);
> >> +g_clear_pointer(&unix_path, g_free);
> >>  g_object_unref(s);
> >>  }
> >>
> >> @@ -180,9 +184,10 @@ static void test_session_uri_good(const TestCase
> >> *tests,
> >> const guint cases)
> >>   "host", tests[i].host,
> >>   "username", tests[i].username,
> >>   "password", tests[i].password,
> >> + "unix-path", tests[i].unix_path,
> >>NULL);
> >>  g_object_get(s, "uri", &uri, NULL);
> >> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
> >> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==,
> >> uri);
> >>  g_clear_pointer(&uri, g_free);
> >>  g_object_unref(s);
> >>  }
> >> @@ -278,6 +283,22 @@ static void test_session_uri_ipv6_good(void)
> >>  test_session_uri_good(tests, G_N_ELEMENTS(tests));
> >>  }
> >>
> >> +static void test_session_uri_unix_good(void)
> >> +{
> >> +const TestCase tests[] = {
> >> +{ .uri_input = "spice+unix:///tmp/foo.sock",
> >> +  .unix_path = "/tmp/foo.sock" },
> >> +/* perhaps not very clever, but this doesn't raise an
> >> error/warning
> >> */
> >> +{ .uri_input = "spice+unix://",
> >> +  .unix_path = "" },
> >> +/* unix uri don't support passing password or other kind of
> >> options
> >> */
> >> +{ .uri_input = "spice+unix:///tmp/foo.sock?password=frobnicate",
> >> +  .unix_path = "/tmp/foo.sock?password=frobnicate" },
> >> +};
> >> +
> >> +test_session_uri_good(tests, G_N_ELEMENTS(tests));
> >> +}
> >> +
> >>  int main(int argc, char* argv[])
> >>  {
> >>  g_test_init(&argc, &argv, NULL);
> >> @@ -285,6 +306,7 @@ int main(int argc, char* argv[])
> >>  g_test_add_func("/session/bad-uri", test_session_uri_bad);
> >>  g_test_add_func("/session/good-ipv4-uri",
> >>  test_session_uri_ipv4_good);
> >>  g_test_add_func("/session/good-ipv6-uri",
> >>  test_session_uri_ipv6_good);
> >> +g_test_add_func("/session/good-unix", test_session_uri_unix_good);
> >>
> >>  return g_test_run();
> >>  }
> >
> > Looks good (still to review better).
> > Can we consider this patch separate from the rest of the series
> > (that is merge even separately) ?
> 
> Sure, it was just in the same area of code, and thus added dependency,
> but we can review & merge this one right away I think.
> thanks
> 

Acked-by: Frediano Ziglio 

Follow ups:

The "spice://" syntax is weird, maybe we should refuse it.
Running remote-

Re: [Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-13 Thread Marc-Andre Lureau
Hi

On Tue, Feb 13, 2018 at 10:08 AM, Frediano Ziglio  wrote:
>>
>> Hi
>>
>> On Thu, Feb 8, 2018 at 2:18 PM, Frediano Ziglio  wrote:
>> >>
>> >> From: Marc-André Lureau 
>> >>
>> >> For some reason, the URIs test didn't include spice+unix:// checks,
>> >> probably because they came about the same time.
>> >>
>> >> Signed-off-by: Marc-André Lureau 
>> >> ---
>> >>  tests/session.c | 28 +---
>> >>  1 file changed, 25 insertions(+), 3 deletions(-)
>> >>
>> >> diff --git a/tests/session.c b/tests/session.c
>> >> index 7ed4a41..413d812 100644
>> >> --- a/tests/session.c
>> >> +++ b/tests/session.c
>> >> @@ -9,6 +9,7 @@ typedef struct {
>> >>  const gchar *uri_input;
>> >>  const gchar *uri_output;
>> >>  const gchar *message;
>> >> +const gchar *unix_path;
>> >>  } TestCase;
>> >>
>> >>  static void test_session_uri_bad(void)
>> >> @@ -139,7 +140,7 @@ static void test_session_uri_good(const TestCase
>> >> *tests,
>> >> const guint cases)
>> >>
>> >>  /* Set URI and check URI, port and tls_port */
>> >>  for (i = 0; i < cases; i++) {
>> >> -gchar *uri, *port, *tls_port, *host, *username, *password;
>> >> +gchar *uri, *port, *tls_port, *host, *username, *password,
>> >> *unix_path;
>> >>
>> >>  s = spice_session_new();
>> >>  if (tests[i].message != NULL)
>> >> @@ -152,20 +153,23 @@ static void test_session_uri_good(const TestCase
>> >> *tests, const guint cases)
>> >>   "host", &host,
>> >>   "username", &username,
>> >>   "password", &password,
>> >> + "unix-path", &unix_path,
>> >>NULL);
>> >> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
>> >> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==,
>> >> uri);
>> >>  g_assert_cmpstr(tests[i].port, ==, port);
>> >>  g_assert_cmpstr(tests[i].tls_port, ==, tls_port);
>> >>  g_assert_cmpstr(tests[i].host, ==, host);
>> >>  g_assert_cmpstr(tests[i].username, ==, username);
>> >>  g_assert_cmpstr(tests[i].password, ==, password);
>> >>  g_test_assert_expected_messages();
>> >> +g_assert_cmpstr(tests[i].unix_path, ==, unix_path);
>> >>  g_clear_pointer(&uri, g_free);
>> >>  g_clear_pointer(&port, g_free);
>> >>  g_clear_pointer(&tls_port, g_free);
>> >>  g_clear_pointer(&host, g_free);
>> >>  g_clear_pointer(&username, g_free);
>> >>  g_clear_pointer(&password, g_free);
>> >> +g_clear_pointer(&unix_path, g_free);
>> >>  g_object_unref(s);
>> >>  }
>> >>
>> >> @@ -180,9 +184,10 @@ static void test_session_uri_good(const TestCase
>> >> *tests,
>> >> const guint cases)
>> >>   "host", tests[i].host,
>> >>   "username", tests[i].username,
>> >>   "password", tests[i].password,
>> >> + "unix-path", tests[i].unix_path,
>> >>NULL);
>> >>  g_object_get(s, "uri", &uri, NULL);
>> >> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
>> >> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==,
>> >> uri);
>> >>  g_clear_pointer(&uri, g_free);
>> >>  g_object_unref(s);
>> >>  }
>> >> @@ -278,6 +283,22 @@ static void test_session_uri_ipv6_good(void)
>> >>  test_session_uri_good(tests, G_N_ELEMENTS(tests));
>> >>  }
>> >>
>> >> +static void test_session_uri_unix_good(void)
>> >> +{
>> >> +const TestCase tests[] = {
>> >> +{ .uri_input = "spice+unix:///tmp/foo.sock",
>> >> +  .unix_path = "/tmp/foo.sock" },
>> >> +/* perhaps not very clever, but this doesn't raise an
>> >> error/warning
>> >> */
>> >> +{ .uri_input = "spice+unix://",
>> >> +  .unix_path = "" },
>> >> +/* unix uri don't support passing password or other kind of
>> >> options
>> >> */
>> >> +{ .uri_input = "spice+unix:///tmp/foo.sock?password=frobnicate",
>> >> +  .unix_path = "/tmp/foo.sock?password=frobnicate" },
>> >> +};
>> >> +
>> >> +test_session_uri_good(tests, G_N_ELEMENTS(tests));
>> >> +}
>> >> +
>> >>  int main(int argc, char* argv[])
>> >>  {
>> >>  g_test_init(&argc, &argv, NULL);
>> >> @@ -285,6 +306,7 @@ int main(int argc, char* argv[])
>> >>  g_test_add_func("/session/bad-uri", test_session_uri_bad);
>> >>  g_test_add_func("/session/good-ipv4-uri",
>> >>  test_session_uri_ipv4_good);
>> >>  g_test_add_func("/session/good-ipv6-uri",
>> >>  test_session_uri_ipv6_good);
>> >> +g_test_add_func("/session/good-unix", test_session_uri_unix_good);
>> >>
>> >>  return g_test_run();
>> >>  }
>> >
>> > Looks good (still to review better).
>> > Can we consider this patch separate from the rest of the series
>> > (that is merge even separately) ?
>>
>> Sure, it was just in the same area of code, and thus added dependency,
>>

Re: [Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-13 Thread Frediano Ziglio
> 
> Hi
> 
> On Tue, Feb 13, 2018 at 10:08 AM, Frediano Ziglio  wrote:
> >>
> >> Hi
> >>
> >> On Thu, Feb 8, 2018 at 2:18 PM, Frediano Ziglio 
> >> wrote:
> >> >>
> >> >> From: Marc-André Lureau 
> >> >>
> >> >> For some reason, the URIs test didn't include spice+unix:// checks,
> >> >> probably because they came about the same time.
> >> >>
> >> >> Signed-off-by: Marc-André Lureau 
> >> >> ---
> >> >>  tests/session.c | 28 +---
> >> >>  1 file changed, 25 insertions(+), 3 deletions(-)
> >> >>
> >> >> diff --git a/tests/session.c b/tests/session.c
> >> >> index 7ed4a41..413d812 100644
> >> >> --- a/tests/session.c
> >> >> +++ b/tests/session.c
> >> >> @@ -9,6 +9,7 @@ typedef struct {
> >> >>  const gchar *uri_input;
> >> >>  const gchar *uri_output;
> >> >>  const gchar *message;
> >> >> +const gchar *unix_path;
> >> >>  } TestCase;
> >> >>
> >> >>  static void test_session_uri_bad(void)
> >> >> @@ -139,7 +140,7 @@ static void test_session_uri_good(const TestCase
> >> >> *tests,
> >> >> const guint cases)
> >> >>
> >> >>  /* Set URI and check URI, port and tls_port */
> >> >>  for (i = 0; i < cases; i++) {
> >> >> -gchar *uri, *port, *tls_port, *host, *username, *password;
> >> >> +gchar *uri, *port, *tls_port, *host, *username, *password,
> >> >> *unix_path;
> >> >>
> >> >>  s = spice_session_new();
> >> >>  if (tests[i].message != NULL)
> >> >> @@ -152,20 +153,23 @@ static void test_session_uri_good(const TestCase
> >> >> *tests, const guint cases)
> >> >>   "host", &host,
> >> >>   "username", &username,
> >> >>   "password", &password,
> >> >> + "unix-path", &unix_path,
> >> >>NULL);
> >> >> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
> >> >> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==,
> >> >> uri);
> >> >>  g_assert_cmpstr(tests[i].port, ==, port);
> >> >>  g_assert_cmpstr(tests[i].tls_port, ==, tls_port);
> >> >>  g_assert_cmpstr(tests[i].host, ==, host);
> >> >>  g_assert_cmpstr(tests[i].username, ==, username);
> >> >>  g_assert_cmpstr(tests[i].password, ==, password);
> >> >>  g_test_assert_expected_messages();
> >> >> +g_assert_cmpstr(tests[i].unix_path, ==, unix_path);
> >> >>  g_clear_pointer(&uri, g_free);
> >> >>  g_clear_pointer(&port, g_free);
> >> >>  g_clear_pointer(&tls_port, g_free);
> >> >>  g_clear_pointer(&host, g_free);
> >> >>  g_clear_pointer(&username, g_free);
> >> >>  g_clear_pointer(&password, g_free);
> >> >> +g_clear_pointer(&unix_path, g_free);
> >> >>  g_object_unref(s);
> >> >>  }
> >> >>
> >> >> @@ -180,9 +184,10 @@ static void test_session_uri_good(const TestCase
> >> >> *tests,
> >> >> const guint cases)
> >> >>   "host", tests[i].host,
> >> >>   "username", tests[i].username,
> >> >>   "password", tests[i].password,
> >> >> + "unix-path", tests[i].unix_path,
> >> >>NULL);
> >> >>  g_object_get(s, "uri", &uri, NULL);
> >> >> -g_assert_cmpstr(tests[i].uri_output, ==, uri);
> >> >> +g_assert_cmpstr(tests[i].uri_output ?: tests[i].uri_input, ==,
> >> >> uri);
> >> >>  g_clear_pointer(&uri, g_free);
> >> >>  g_object_unref(s);
> >> >>  }
> >> >> @@ -278,6 +283,22 @@ static void test_session_uri_ipv6_good(void)
> >> >>  test_session_uri_good(tests, G_N_ELEMENTS(tests));
> >> >>  }
> >> >>
> >> >> +static void test_session_uri_unix_good(void)
> >> >> +{
> >> >> +const TestCase tests[] = {
> >> >> +{ .uri_input = "spice+unix:///tmp/foo.sock",
> >> >> +  .unix_path = "/tmp/foo.sock" },
> >> >> +/* perhaps not very clever, but this doesn't raise an
> >> >> error/warning
> >> >> */
> >> >> +{ .uri_input = "spice+unix://",
> >> >> +  .unix_path = "" },
> >> >> +/* unix uri don't support passing password or other kind of
> >> >> options
> >> >> */
> >> >> +{ .uri_input =
> >> >> "spice+unix:///tmp/foo.sock?password=frobnicate",
> >> >> +  .unix_path = "/tmp/foo.sock?password=frobnicate" },
> >> >> +};
> >> >> +
> >> >> +test_session_uri_good(tests, G_N_ELEMENTS(tests));
> >> >> +}
> >> >> +
> >> >>  int main(int argc, char* argv[])
> >> >>  {
> >> >>  g_test_init(&argc, &argv, NULL);
> >> >> @@ -285,6 +306,7 @@ int main(int argc, char* argv[])
> >> >>  g_test_add_func("/session/bad-uri", test_session_uri_bad);
> >> >>  g_test_add_func("/session/good-ipv4-uri",
> >> >>  test_session_uri_ipv4_good);
> >> >>  g_test_add_func("/session/good-ipv6-uri",
> >> >>  test_session_uri_ipv6_good);
> >> >> +g_test_add_func("/session/good-unix", test_session_uri_unix_good);
> >> >>
> >> >>  return g

Re: [Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-14 Thread Christophe de Dinechin


> On 13 Feb 2018, at 17:36, Marc-Andre Lureau  wrote:
> 
> I was not really fond of passing options via URI, but apparently this
> is a standard practice. 

So is passing port number after a colon.

Christophe
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 1/4] tests: add spice+unix:// URI checks

2018-02-15 Thread i iordanov
If one can infer the usage of unix sockets from other parameters passed
anyway, then there may be no point having it in the first place. For the
VNC URI, we could have gone with vnc+ssh://, or vnc+ssl:// (for stunnel),
but there were ssh-related and stunnel parameters we could infer from so it
became unnecessary.

I already use the VNC RFC spec to provide Red Hat's own movirt a means to
start bVNC via a vnc:// URI intent and aSPICE via an implementation of a
spice:// URI based on the VNC one. I added several parameters like TlsPort,
and renamed the username and password from VncUsername and VncPassword to
SpiceUsername and SpicePassword.

So if you guys want to start from something already in use and seeing
whether extending it works for you, please take a look at parseFomUri()
here:

https://github.com/iiordanov/remote-desktop-clients/blob/master/bVNC/src2/main/java/com/iiordanov/bVNC/ConnectionBean.java

And at the way movirt constructs the URI to start aSPICE and bVNC.

Thanks!
Iordan

On Feb 14, 2018 5:09 AM, "Christophe de Dinechin" <
christophe.de.dinec...@gmail.com> wrote:



> On 13 Feb 2018, at 17:36, Marc-Andre Lureau  wrote:
>
> I was not really fond of passing options via URI, but apparently this
> is a standard practice.

So is passing port number after a colon.

Christophe
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel