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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Aug 13 11:32:00 2014 +0200

lib/smokey: introduce smokey_note() routine

---

 include/smokey/smokey.h |    2 ++
 lib/smokey/helpers.c    |   14 +++++++++++++-
 lib/smokey/init.c       |    8 +++++++-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/include/smokey/smokey.h b/include/smokey/smokey.h
index 95120e9..9c267ef 100644
--- a/include/smokey/smokey.h
+++ b/include/smokey/smokey.h
@@ -115,6 +115,8 @@ struct smokey_arg *smokey_lookup_arg(struct smokey_test *t,
 int smokey_parse_args(struct smokey_test *t,
                      int argc, char *const argv[]);
 
+void smokey_note(const char *fmt, ...);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/smokey/helpers.c b/lib/smokey/helpers.c
index 9dccea9..332ffae 100644
--- a/lib/smokey/helpers.c
+++ b/lib/smokey/helpers.c
@@ -16,9 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 #include <stdio.h>
+#include <stdarg.h>
 #include <ctype.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <string.h>
 #include <errno.h>
 #include <boilerplate/ancillaries.h>
@@ -117,3 +117,15 @@ struct smokey_arg *smokey_lookup_arg(struct smokey_test *t,
        panic("test %s has no argument \"%s\"",
              t->name, name);
 }
+
+void smokey_note(const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+
+       if (!smokey_quiet_mode)
+               vprintf(fmt, ap);
+
+       va_end(ap);
+}
diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index eb1dfbc..967f57f 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -198,6 +198,12 @@
  * including the test detection and the active test selection have
  * been performed by the Smokey API already.
  *
+ * @par Issuing progress messages
+ *
+ * The printf-like @a smokey_note() routine is available for issuing
+ * progress messages to the output device (currently stdout), unless
+ * --quiet was detected on the command line.
+ *
  * Therefore, a possible implementation of a test driver could be as
  * basic as:
  *
@@ -221,7 +227,7 @@
  *                             continue;
  *                     error(1, -ret, "test %s failed", t->name);
  *             }
- *             printf("%s OK\n", t->name);
+ *             smokey_note("%s OK\n", t->name);
  *     }
  *
  *     return 0;


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

Reply via email to