[rygel] tests: Skip the test if network is not available



commit 2574f662e4a47e3c6945e82d6dff0a1e1a6af2bb
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Mar 10 17:54:17 2010 +0200

    tests: Skip the test if network is not available

 tests/rygel-http-item-uri-test.vala |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/tests/rygel-http-item-uri-test.vala b/tests/rygel-http-item-uri-test.vala
index ef6cd04..118ba82 100644
--- a/tests/rygel-http-item-uri-test.vala
+++ b/tests/rygel-http-item-uri-test.vala
@@ -4,6 +4,10 @@ public errordomain Rygel.HTTPRequestError {
     NOT_FOUND = Soup.KnownStatusCode.NOT_FOUND
 }
 
+public errordomain Rygel.TestError {
+    SKIP
+}
+
 public class Rygel.HTTPServer : GLib.Object {
     private const string SERVER_PATH = "/RygelHTTPServer/Rygel/Test";
 
@@ -11,9 +15,14 @@ public class Rygel.HTTPServer : GLib.Object {
 
     public GUPnP.Context context;
 
-    public HTTPServer () throws Error {
+    public HTTPServer () throws TestError {
         this.path_root = SERVER_PATH;
-        this.context = new GUPnP.Context (null, "lo", 0);
+
+        try {
+            this.context = new GUPnP.Context (null, "lo", 0);
+        } catch (Error error) {
+            throw new TestError.SKIP ("Network context not available");
+        }
 
         assert (this.context != null);
         assert (this.context.host_ip != null);
@@ -33,6 +42,10 @@ public class Rygel.HTTPItemURITest : GLib.Object {
             var test = new HTTPItemURITest ();
 
             test.run ();
+        } catch (TestError error) {
+            // FIXME: We should catch the exact error but currently valac issues
+            // unreachable warning if we do so.
+            return 77;
         } catch (Error error) {
             critical ("%s", error.message);
 
@@ -54,7 +67,7 @@ public class Rygel.HTTPItemURITest : GLib.Object {
         }
     }
 
-    private HTTPItemURITest () throws Error {
+    private HTTPItemURITest () throws TestError {
         this.server = new HTTPServer ();
     }
 



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