try to get travis building with multiple macOS versions
[platform/upstream/libusb.git] / tests / stress.c
index 26860a0..0f50003 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * libusbx stress test program to perform simple stress tests
+ * libusb stress test program to perform simple stress tests
  * Copyright © 2012 Toby Gray <toby.gray@realvnc.com>
  *
  * This library is free software; you can redistribute it and/or
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <memory.h>
-#if !defined(_WIN32_WCE)
-#include <sys/types.h>
-#endif
 
 #include "libusb.h"
-
-#include "libusbx_testlib.h"
+#include "libusb_testlib.h"
 
 /** Test that creates and destroys a single concurrent context
  * 10000 times. */
-static libusbx_testlib_result test_init_and_exit(libusbx_testlib_ctx * tctx)
+static libusb_testlib_result test_init_and_exit(libusb_testlib_ctx * tctx)
 {
        libusb_context * ctx = NULL;
        int i;
        for (i = 0; i < 10000; ++i) {
                int r = libusb_init(&ctx);
                if (r != LIBUSB_SUCCESS) {
-                       libusbx_testlib_logf(tctx,
+                       libusb_testlib_logf(tctx,
                                "Failed to init libusb on iteration %d: %d",
                                i, r);
                        return TEST_STATUS_FAILURE;
@@ -49,20 +46,20 @@ static libusbx_testlib_result test_init_and_exit(libusbx_testlib_ctx * tctx)
 }
 
 /** Tests that devices can be listed 1000 times. */
-static libusbx_testlib_result test_get_device_list(libusbx_testlib_ctx * tctx)
+static libusb_testlib_result test_get_device_list(libusb_testlib_ctx * tctx)
 {
        libusb_context * ctx = NULL;
        int r, i;
        r = libusb_init(&ctx);
        if (r != LIBUSB_SUCCESS) {
-               libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
+               libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
                return TEST_STATUS_FAILURE;
        }
        for (i = 0; i < 1000; ++i) {
                libusb_device ** device_list;
                ssize_t list_size = libusb_get_device_list(ctx, &device_list);
                if (list_size < 0 || device_list == NULL) {
-                       libusbx_testlib_logf(tctx,
+                       libusb_testlib_logf(tctx,
                                "Failed to get device list on iteration %d: %d (%p)",
                                i, -list_size, device_list);
                        return TEST_STATUS_FAILURE;
@@ -74,7 +71,7 @@ static libusbx_testlib_result test_get_device_list(libusbx_testlib_ctx * tctx)
 }
 
 /** Tests that 100 concurrent device lists can be open at a time. */
-static libusbx_testlib_result test_many_device_lists(libusbx_testlib_ctx * tctx)
+static libusb_testlib_result test_many_device_lists(libusb_testlib_ctx * tctx)
 {
 #define LIST_COUNT 100
        libusb_context * ctx = NULL;
@@ -84,7 +81,7 @@ static libusbx_testlib_result test_many_device_lists(libusbx_testlib_ctx * tctx)
 
        r = libusb_init(&ctx);
        if (r != LIBUSB_SUCCESS) {
-               libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
+               libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
                return TEST_STATUS_FAILURE;
        }
 
@@ -92,7 +89,7 @@ static libusbx_testlib_result test_many_device_lists(libusbx_testlib_ctx * tctx)
        for (i = 0; i < LIST_COUNT; ++i) {
                ssize_t list_size = libusb_get_device_list(ctx, &(device_lists[i]));
                if (list_size < 0 || device_lists[i] == NULL) {
-                       libusbx_testlib_logf(tctx,
+                       libusb_testlib_logf(tctx,
                                "Failed to get device list on iteration %d: %d (%p)",
                                i, -list_size, device_lists[i]);
                        return TEST_STATUS_FAILURE;
@@ -115,7 +112,7 @@ static libusbx_testlib_result test_many_device_lists(libusbx_testlib_ctx * tctx)
 /** Tests that the default context (used for various things including
  * logging) works correctly when the first context created in a
  * process is destroyed. */
-static libusbx_testlib_result test_default_context_change(libusbx_testlib_ctx * tctx)
+static libusb_testlib_result test_default_context_change(libusb_testlib_ctx * tctx)
 {
        libusb_context * ctx = NULL;
        int r, i;
@@ -124,7 +121,7 @@ static libusbx_testlib_result test_default_context_change(libusbx_testlib_ctx *
                /* First create a new context */
                r = libusb_init(&ctx);
                if (r != LIBUSB_SUCCESS) {
-                       libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
+                       libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
                        return TEST_STATUS_FAILURE;
                }
 
@@ -135,7 +132,7 @@ static libusbx_testlib_result test_default_context_change(libusbx_testlib_ctx *
                /* Now create a reference to the default context */
                r = libusb_init(NULL);
                if (r != LIBUSB_SUCCESS) {
-                       libusbx_testlib_logf(tctx, "Failed to init libusb: %d", r);
+                       libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
                        return TEST_STATUS_FAILURE;
                }
 
@@ -149,15 +146,15 @@ static libusbx_testlib_result test_default_context_change(libusbx_testlib_ctx *
 }
 
 /* Fill in the list of tests. */
-static const libusbx_testlib_test tests[] = {
+static const libusb_testlib_test tests[] = {
        {"init_and_exit", &test_init_and_exit},
        {"get_device_list", &test_get_device_list},
        {"many_device_lists", &test_many_device_lists},
        {"default_context_change", &test_default_context_change},
-       LIBUSBX_NULL_TEST
+       LIBUSB_NULL_TEST
 };
 
 int main (int argc, char ** argv)
 {
-       return libusbx_testlib_run_tests(argc, argv, tests);
+       return libusb_testlib_run_tests(argc, argv, tests);
 }