]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Introduce xtf_exit()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 17 May 2017 13:41:28 +0000 (14:41 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 19 May 2017 18:56:13 +0000 (19:56 +0100)
This is more convenient for tests which want to terminate cleanly from the
middle of their logic, rather than needing to arrange for execution to return
from test_main().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
common/report.c
common/setup.c
include/xtf/report.h

index 8a6ddfa6d836a7a699497480b18d1075a82859c0..ffdf09871eb1652b454627d4c4eaa72800732140 100644 (file)
@@ -1,6 +1,6 @@
-#include <xtf/types.h>
+#include <xtf/lib.h>
 #include <xtf/report.h>
-#include <xtf/console.h>
+#include <xtf/hypercall.h>
 
 enum test_status {
     STATUS_RUNNING, /**< Test not yet completed.       */
@@ -121,6 +121,13 @@ bool xtf_status_reported(void)
     return status != STATUS_RUNNING;
 }
 
+void xtf_exit(void)
+{
+    xtf_report_status();
+    hypercall_shutdown(SHUTDOWN_poweroff);
+    panic("xtf_exit(): hypercall_shutdown(SHUTDOWN_poweroff) returned\n");
+}
+
 /*
  * Local variables:
  * mode: C
index 9d70435c59026e79ba60e4d74dc1afef3bd9aafd..932fc09168da981773d6aa4e38004a2e6d93846a 100644 (file)
@@ -32,10 +32,8 @@ void __noreturn xtf_main(void)
         test_main();
     }
 
-    xtf_report_status();
-
-    hypercall_shutdown(SHUTDOWN_poweroff);
-    unreachable();
+    /* Report status and exit. */
+    xtf_exit();
 }
 
 /*
index 9a59d6f486521e5d72dea1ddc93784badd2b8ab2..36517bdea9755be60e03789613e94e3caeb11734 100644 (file)
@@ -73,6 +73,13 @@ void xtf_report_status(void);
  */
 bool xtf_status_reported(void);
 
+/**
+ * Exit the test early.
+ *
+ * Reports the current status.  Does not return.
+ */
+void __noreturn xtf_exit(void);
+
 #endif /* XTF_REPORT_H */
 
 /*