summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-11-27 15:22:29 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2020-11-27 15:22:29 -0800
commitf2e551a5ff03325505bf90796887d4fc0093a99b (patch)
treef066080798a294e177c7b9063971c54e83f75675 /tests
parent9d23ed25b44ae351eaf839805722d6796f9b018a (diff)
downloadlibusb-f2e551a5ff03325505bf90796887d4fc0093a99b.tar.gz
build: Prepare config.h for inclusion in examples/tests
There are certain games played in the examples and tests source to account for differences in build environments and target platforms. This can be simplified by including config.h and using the definitions there. To that end, move the printf function attribute definition from libusbi.h to config.h and leverage it where it is used in the examples and tests. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/libusb_testlib.h4
-rw-r--r--tests/stress.c2
-rw-r--r--tests/testlib.c10
3 files changed, 11 insertions, 5 deletions
diff --git a/tests/libusb_testlib.h b/tests/libusb_testlib.h
index b3dbaae..145f4e6 100644
--- a/tests/libusb_testlib.h
+++ b/tests/libusb_testlib.h
@@ -20,6 +20,8 @@
#ifndef LIBUSB_TESTLIB_H
#define LIBUSB_TESTLIB_H
+#include <config.h>
+
/** Values returned from a test function to indicate test result */
typedef enum {
/** Indicates that the test ran successfully. */
@@ -36,7 +38,7 @@ typedef enum {
/**
* Logs some test information or state
*/
-void libusb_testlib_logf(const char *fmt, ...);
+void libusb_testlib_logf(const char *fmt, ...) PRINTF_FORMAT(1, 2);
/**
* Structure holding a test description.
diff --git a/tests/stress.c b/tests/stress.c
index 5c8c315..6dcb8f3 100644
--- a/tests/stress.c
+++ b/tests/stress.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <config.h>
+
#include <string.h>
#include "libusb.h"
diff --git a/tests/testlib.c b/tests/testlib.c
index fb4fee6..3825341 100644
--- a/tests/testlib.c
+++ b/tests/testlib.c
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libusb_testlib.h"
+#include <config.h>
#include <errno.h>
#include <stdarg.h>
@@ -25,10 +25,12 @@
#include <stdio.h>
#include <string.h>
-#if defined(_WIN32)
-#define NULL_PATH "nul"
-#else
+#include "libusb_testlib.h"
+
+#if defined(PLATFORM_POSIX)
#define NULL_PATH "/dev/null"
+#elif defined(PLATFORM_WINDOWS)
+#define NULL_PATH "nul"
#endif
/**