Module: xenomai-3
Branch: next
Commit: b4fffa079d7ee02d751f0f82701ceccd4be1a126
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b4fffa079d7ee02d751f0f82701ceccd4be1a126

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Aug 26 17:08:58 2015 +0200

lib/smokey: add --vm switch

This switch gives a hint about smokey currently running in a virtual
environment. smokey_on_vm can be checked by test code to figure out
whether this might have an impact on their results (such as being
affected by a significant slowdown).

---

 include/smokey/smokey.h |    2 ++
 lib/smokey/init.c       |   20 ++++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h
index 7dcc06b..b48d796 100644
--- a/include/smokey/smokey.h
+++ b/include/smokey/smokey.h
@@ -166,4 +166,6 @@ extern int smokey_keep_going;
 
 extern int smokey_verbose_mode;
 
+extern int smokey_on_vm;
+
 #endif /* _XENOMAI_SMOKEY_SMOKEY_H */
diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index 2c16cde..e98f9a0 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -188,6 +188,12 @@
  *   non-zero value, which should be interpreted by all parties as the
  *   desired verbosity level (defaults to 1).
  *
+ * - --vm gives a hint to the test code, about running in a virtual
+ * environment, such as KVM. When passed, the boolean @a smokey_on_vm
+ * is set. Each test may act upon this setting, such as skipping
+ * time-dependent checks that may fail due to any slowdown induced by
+ * the virtualization.
+ *
  * @par Writing a test driver based on the Smokey API
  *
  * A test driver provides the main() entry point, which should iterate
@@ -250,14 +256,16 @@ DEFINE_PRIVATE_LIST(smokey_test_list);
 
 int smokey_keep_going;
 
+int smokey_verbose_mode = 1;
+
+int smokey_on_vm = 0;
+
 static DEFINE_PRIVATE_LIST(register_list);
 
 static int test_count;
 
 static int do_list;
 
-int smokey_verbose_mode = 1;
-
 static const struct option smokey_options[] = {
        {
 #define keep_going_opt 0
@@ -277,6 +285,12 @@ static const struct option smokey_options[] = {
                .val = 1,
        },
        {
+#define vm_opt         3
+               .name = "vm",
+               .flag = &smokey_on_vm,
+               .val = 1,
+       },
+       {
                /* sentinel */
        }
 };
@@ -286,6 +300,7 @@ static void smokey_help(void)
         fprintf(stderr, "--keep-going                  don't stop upon test 
error\n");
        fprintf(stderr, "--list                         list all tests\n");
        fprintf(stderr, "--run[=<id[,id...]>]]          run [portion of] the 
test list\n");
+       fprintf(stderr, "--vm                           hint about running in a 
virtual environment\n");
 }
 
 static inline void pick_test_range(int start, int end)
@@ -431,6 +446,7 @@ static int smokey_parse_option(int optnum, const char 
*optarg)
 
        switch (optnum) {
        case keep_going_opt:
+       case vm_opt:
                break;
        case run_opt:
                if (pvlist_empty(&register_list)) {


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to