]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Introduce test_needs_fep to help uniform handling of fep being unavailable
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 3 Aug 2016 11:33:52 +0000 (12:33 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 3 Aug 2016 11:38:25 +0000 (12:38 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/setup.c
common/report.c
common/setup.c
include/xtf/report.h
include/xtf/test.h
tests/xsa-123/main.c

index 85600014909bc7d60e7921c38a48ff7f20e96f52..b07481480c9aea8dfdb7e19b5189991e5b738930 100644 (file)
@@ -1,6 +1,7 @@
 #include <xtf/lib.h>
 #include <xtf/hypercall.h>
 #include <xtf/extable.h>
+#include <xtf/report.h>
 
 #include <arch/x86/cpuid.h>
 #include <arch/x86/desc.h>
@@ -197,6 +198,18 @@ void arch_setup(void)
  */
 bool xtf_has_fep = false;
 
+/*
+ * Default weak settings.
+ *
+ * test_wants_* indicates default settings for the framework, which may be
+ * overridden by individual tests by providing non-weak variables.
+ *
+ * test_needs_* indicates options required by the test, without which the test
+ * isn't worth running.
+ */
+bool __weak test_wants_user_mappings = false;
+bool __weak test_needs_fep = false;
+
 void test_setup(void)
 {
     /*
@@ -204,21 +217,15 @@ void test_setup(void)
      * xtf_has_fep to the value of 1.  Use the exception table to compensate
      * for the #UD exception if FEP is not available.
      */
-    asm volatile ("xor %0, %0;"
-                  "1:" _ASM_XEN_FEP
-                  "mov $1, %0;"
+    asm volatile ("1:" _ASM_XEN_FEP "mov $1, %[fep];"
                   "2:"
                   _ASM_EXTABLE(1b, 2b)
-                  : "=q" (xtf_has_fep));
-}
+                  : [fep] "=q" (xtf_has_fep)
+                  : "0" (false));
 
-/*
- * Default weak settings.
- *
- * test_wants_* indicates default settings for the framework, which may be
- * overridden by individual tests by providing non-weak variables.
- */
-bool __weak test_wants_user_mappings = false;
+    if ( test_needs_fep && !xtf_has_fep )
+        return xtf_skip("FEP unavailable, but needed by test\n");
+}
 
 /*
  * Local variables:
index 685542c6b1861add5fa54f70ecedcb442a1b37cc..8a6ddfa6d836a7a699497480b18d1075a82859c0 100644 (file)
@@ -116,6 +116,11 @@ void xtf_report_status(void)
            " with warnings" : "");
 }
 
+bool xtf_status_reported(void)
+{
+    return status != STATUS_RUNNING;
+}
+
 /*
  * Local variables:
  * mode: C
index 16d4b7f243cae851ff9e6989574cdb9627c83ea0..3c2f848cf64d942f40c67b35c6f7efd2b7dba1c7 100644 (file)
@@ -26,7 +26,10 @@ void __noreturn xtf_main(void)
 
     test_setup();
 
-    test_main();
+    if ( !xtf_status_reported() )
+    {
+        test_main();
+    }
 
     xtf_report_status();
 
index 6ec5047b7b24f897141c01d00dc114b302e9af00..3d08fb0c0bbed22997c84888c46f022403c890f6 100644 (file)
@@ -67,6 +67,11 @@ void xtf_failure(const char *fmt, ...) __printf(1, 2);
  */
 void xtf_report_status(void);
 
+/**
+ * Query whether a status has already been reported.
+ */
+bool xtf_status_reported(void);
+
 #endif /* XTF_REPORT_H */
 
 /*
index e7639984c5f3456c7dec2326edde70a1c3157bd5..778090cfecb0fe3158388ed96df8da1601101f96 100644 (file)
@@ -33,6 +33,12 @@ extern bool xtf_has_fep;
  */
 extern bool test_wants_user_mappings;
 
+/**
+ * Boolean indicating whether the test is entirely predicated on the available
+ * of the Force Emulation Prefix.
+ */
+extern bool test_needs_fep;
+
 #endif /* XTF_TEST_H */
 
 /*
index 92c80f2ef4dfe0615a3ee85a916039185774095c..7ed387626a8c69f23b3a845dfe0654ea5189eae4 100644 (file)
  */
 #include <xtf.h>
 
+bool test_needs_fep = true;
+
 void test_main(void)
 {
     unsigned long src = 0x1234, dest = 0;
 
     printk("XSA-123 PoC\n");
 
-    if ( !xtf_has_fep )
-        return xtf_error("Error: FEP not available\n");
-
     asm volatile(_ASM_XEN_FEP
                  /* Explicit %cs segment override. */
                  ".byte 0x2e;"