]> xenbits.xensource.com Git - people/iwj/ring3-xl-test.git/commitdiff
Add more assertions to test_domain_create_new.c
authorEuan Harris <euan.harris@citrix.com>
Tue, 16 Jun 2015 16:34:55 +0000 (16:34 +0000)
committerEuan Harris <euan.harris@citrix.com>
Tue, 16 Jun 2015 16:43:01 +0000 (16:43 +0000)
Signed-off-by: Euan Harris <euan.harris@citrix.com>
test_domain_create_new.c
test_domain_suspend.c

index ea7de20ae5df132420ebc14dc557e10567ac04fb..43e14a3efd497b0c4d7fd963f4e0ed24faba2290 100644 (file)
@@ -25,7 +25,6 @@
  *   cancellation point.
  */
 
-
 void teardown(struct test *tc, libxl_domain_config * dc, int domid)
 {
     libxl_domain_config_dispose(dc);
@@ -41,25 +40,52 @@ void *testcase(struct test *tc)
         uint32_t domid;
         libxl_domain_config dc;
         struct event ev;
+        int rc;
 
         printf("\n****** Will cancel after %d events ******\n", count);
 
         init_domain_config(&dc, "test_domain_create_new",
                            "/root/vmlinuz-4.0.4-301.fc22.x86_64",
-                           "/root/foobar.img",
+                           "/root/initrd.xen-4.0.4-301.fc22.x86_64",
                            "/root/Fedora-Cloud-Base-22-20150521.x86_64.qcow2",
                            "/root/init.iso");
 
         do_domain_create(tc, &dc, &domid);
 
         if (wait_until_n(tc, EV_LIBXL_CALLBACK, count, &ev)) {
+            /* The API call returned before we could cancel it.
+               It should have returned successfully.
+             */
+            printf("libxl_domain_create_new returned %d\n",
+                   ev.u.callback_event.rc);
+            assert(ev.u.callback_event.rc == 0);
+
+            /* No operation in progress - cancelling should return an error */
+            rc = libxl_ao_cancel(tc->ctx, &tc->ao_how);
+            printf("libxl_ao_cancel returned %d\n", rc);
+            assert(rc == ERROR_NOTFOUND);
+
             teardown(tc, &dc, domid);
             break;
         }
 
-        libxl_ao_cancel(tc->ctx, &tc->ao_how);
+        rc = libxl_ao_cancel(tc->ctx, &tc->ao_how);
+
+        /* Calling cancel on a cancellable operation should not return an
+           error, unless the operation happened to complete in the meantime.
+         */
+        printf("libxl_ao_cancel returned %d\n", rc);
+        assert(rc == ERROR_NOTFOUND || rc == 0);
+
+        /* The API call's return code should indicate that it was cancelled */
         wait_for(tc, EV_LIBXL_CALLBACK, &ev);
+        printf("libxl_domain_create_new returned %d\n",
+               ev.u.callback_event.rc);
+        assert(ev.u.callback_event.rc == ERROR_CANCELLED
+               || ev.u.callback_event.rc == 0);
 
+        /* Although we cancelled, some domain configuration will have 
+           been created. */
         printf("domid: %d\n", domid);
         assert(!libxl_domain_info(tc->ctx, NULL, domid));
 
index a988861f3ddd51fb8993bb16b1c448ed6a06cb50..3d74436a21679c84723e20050f4c70840971f097 100644 (file)
@@ -15,7 +15,7 @@ void *testcase(struct test *tc)
 
     init_domain_config(&dc, "test_domain_suspend",
                        "/root/vmlinuz-4.0.4-301.fc22.x86_64",
-                       "/root/foobar.img",
+                       "/root/initrd.xen-4.0.4-301.fc22.x86_64",
                        "/root/Fedora-Cloud-Base-22-20150521.x86_64.qcow2",
                        "/root/init.iso");
     do_domain_create(tc, &dc, &domid);