int main(void) { int i; /* Test preconditions. There should be no active sandbox. */ ASSERT_EQ(NULL, MinsfiGetActiveSandbox()); ASSERT_EQ(0, __sfi_memory_base); /* * First, try invoking the sandbox without having initialized it. * It should fail but not crash. */ helper_invoke_error(); /* Initialize, invoke, destroy a couple of times. This should succeed. */ for (i = 0; i < 3; i++) { helper_initialize(); helper_invoke_success(); helper_destroy(); } /* * Multiple initializations and invokes without destroying. This will leave * the sandbox initialized. */ for (i = 0; i < 3; i++) { helper_initialize(); helper_invoke_success(); } /* Now try destroying it multiple times. */ for (i = 0; i < 3; i++) helper_destroy(); /* Finally, invoking the sandbox after it's been destroyed should fail. */ helper_invoke_error(); }
int xa_destroy (xa_instance_t *instance) { int ret1, ret2; #ifdef ENABLE_XEN instance->m.xen.domain_id = 0; #endif /* ENABLE_XEN */ ret1 = helper_destroy(instance); #ifdef ENABLE_XEN ret2 = xc_interface_close(instance->m.xen.xc_handle); #endif /* ENABLE_XEN */ if (XA_FAILURE == ret1 || XA_FAILURE == ret2){ return XA_FAILURE; } return XA_SUCCESS; }