summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhjelmn@cs.unm.edu <hjelmn@cs.unm.edu>2014-01-08 23:50:34 +0000
committerPete Batard <pete@akeo.ie>2014-01-08 23:51:01 +0000
commit1eff220474f63d7ea7f8f99bef2a3da9da5324eb (patch)
treeeba538bb278e18c9a8c70fb244f22dd9e971773e /tests
parent85e118aca6425108a408c3ce8b55a8d44fcef73c (diff)
downloadlibusb-1eff220474f63d7ea7f8f99bef2a3da9da5324eb.tar.gz
Misc: Revert all references to libusb/libusb.info
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/libusb_testlib.h (renamed from tests/libusbx_testlib.h)30
-rw-r--r--tests/stress.c32
-rw-r--r--tests/testlib.c40
4 files changed, 52 insertions, 52 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bf53f3f..12c5105 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,4 +3,4 @@ LDADD = ../libusb/libusb-1.0.la
noinst_PROGRAMS = stress
-stress_SOURCES = stress.c libusbx_testlib.h testlib.c
+stress_SOURCES = stress.c libusb_testlib.h testlib.c
diff --git a/tests/libusbx_testlib.h b/tests/libusb_testlib.h
index 06dbc8e..6c987d3 100644
--- a/tests/libusbx_testlib.h
+++ b/tests/libusb_testlib.h
@@ -1,5 +1,5 @@
/*
- * libusbx test library helper functions
+ * libusb test library helper functions
* Copyright © 2012 Toby Gray <toby.gray@realvnc.com>
*
* This library is free software; you can redistribute it and/or
@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef LIBUSBX_TESTLIB_H
-#define LIBUSBX_TESTLIB_H
+#ifndef LIBUSB_TESTLIB_H
+#define LIBUSB_TESTLIB_H
#include <stdio.h>
@@ -43,7 +43,7 @@ typedef enum {
/** Indicates that the test can't be run. For example this may be
* due to no suitable device being connected to perform the tests.*/
TEST_STATUS_SKIP
-} libusbx_testlib_result;
+} libusb_testlib_result;
/**
* Context for test library functions
@@ -57,21 +57,21 @@ typedef struct {
int old_stderr;
FILE* output_file;
int null_fd;
-} libusbx_testlib_ctx;
+} libusb_testlib_ctx;
/**
* Logs some test information or state
*/
-void libusbx_testlib_logf(libusbx_testlib_ctx * ctx,
+void libusb_testlib_logf(libusb_testlib_ctx * ctx,
const char* fmt, ...);
/**
- * Function pointer for a libusbx test function.
+ * Function pointer for a libusb test function.
*
* Should return TEST_STATUS_SUCCESS on success or another TEST_STATUS value.
*/
-typedef libusbx_testlib_result
-(*libusbx_testlib_test_function)(libusbx_testlib_ctx * ctx);
+typedef libusb_testlib_result
+(*libusb_testlib_test_function)(libusb_testlib_ctx * ctx);
/**
* Structure holding a test description.
@@ -80,14 +80,14 @@ typedef struct {
/** Human readable name of the test. */
const char * name;
/** The test library will call this function to run the test. */
- libusbx_testlib_test_function function;
-} libusbx_testlib_test;
+ libusb_testlib_test_function function;
+} libusb_testlib_test;
/**
* Value to use at the end of a test array to indicate the last
* element.
*/
-#define LIBUSBX_NULL_TEST {NULL, NULL}
+#define LIBUSB_NULL_TEST {NULL, NULL}
/**
* Runs the tests provided.
@@ -100,8 +100,8 @@ typedef struct {
* \param tests A NULL_TEST terminated array of tests
* \return 0 on success, non-zero on failure
*/
-int libusbx_testlib_run_tests(int argc,
+int libusb_testlib_run_tests(int argc,
char ** argv,
- const libusbx_testlib_test * tests);
+ const libusb_testlib_test * tests);
-#endif //LIBUSBX_TESTLIB_H
+#endif //LIBUSB_TESTLIB_H
diff --git a/tests/stress.c b/tests/stress.c
index db8d233..0f50003 100644
--- a/tests/stress.c
+++ b/tests/stress.c
@@ -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
@@ -22,18 +22,18 @@
#include <memory.h>
#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;
@@ -46,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;
@@ -71,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;
@@ -81,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;
}
@@ -89,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;
@@ -112,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;
@@ -121,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;
}
@@ -132,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;
}
@@ -146,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);
}
diff --git a/tests/testlib.c b/tests/testlib.c
index 7cab0b9..aa38cf1 100644
--- a/tests/testlib.c
+++ b/tests/testlib.c
@@ -1,5 +1,5 @@
/*
- * libusbx test library helper functions
+ * libusb test library helper functions
* Copyright © 2012 Toby Gray <toby.gray@realvnc.com>
*
* This library is free software; you can redistribute it and/or
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libusbx_testlib.h"
+#include "libusb_testlib.h"
#include <stdio.h>
#include <stdarg.h>
@@ -53,7 +53,7 @@
/**
* Converts a test result code into a human readable string.
*/
-static const char* test_result_to_str(libusbx_testlib_result result)
+static const char* test_result_to_str(libusb_testlib_result result)
{
switch (result) {
case TEST_STATUS_SUCCESS:
@@ -77,7 +77,7 @@ static void print_usage(int argc, char ** argv)
printf(" -v Don't redirect STDERR/STDOUT during tests\n");
}
-static void cleanup_test_output(libusbx_testlib_ctx * ctx)
+static void cleanup_test_output(libusb_testlib_ctx * ctx)
{
#ifndef DISABLE_STDOUT_REDIRECTION
if (!ctx->verbose) {
@@ -105,7 +105,7 @@ static void cleanup_test_output(libusbx_testlib_ctx * ctx)
* Setup test output handles
* \return zero on success, non-zero on failure
*/
-static int setup_test_output(libusbx_testlib_ctx * ctx)
+static int setup_test_output(libusb_testlib_ctx * ctx)
{
#ifndef DISABLE_STDOUT_REDIRECTION
/* Stop output to stdout and stderr from being displayed if using non-verbose output */
@@ -149,7 +149,7 @@ static int setup_test_output(libusbx_testlib_ctx * ctx)
return 0;
}
-void libusbx_testlib_logf(libusbx_testlib_ctx * ctx,
+void libusb_testlib_logf(libusb_testlib_ctx * ctx,
const char* fmt, ...)
{
va_list va;
@@ -160,9 +160,9 @@ void libusbx_testlib_logf(libusbx_testlib_ctx * ctx,
fflush(ctx->output_file);
}
-int libusbx_testlib_run_tests(int argc,
+int libusb_testlib_run_tests(int argc,
char ** argv,
- const libusbx_testlib_test * tests)
+ const libusb_testlib_test * tests)
{
int run_count = 0;
int idx = 0;
@@ -172,8 +172,8 @@ int libusbx_testlib_run_tests(int argc,
int skip_count = 0;
int r, j;
size_t arglen;
- libusbx_testlib_result test_result;
- libusbx_testlib_ctx ctx;
+ libusb_testlib_result test_result;
+ libusb_testlib_ctx ctx;
/* Setup default mode of operation */
ctx.test_names = NULL;
@@ -227,7 +227,7 @@ int libusbx_testlib_run_tests(int argc,
/* Act on any options not related to running tests */
if (ctx.list_tests) {
while (tests[idx].function != NULL) {
- libusbx_testlib_logf(&ctx, tests[idx].name);
+ libusb_testlib_logf(&ctx, tests[idx].name);
++idx;
}
cleanup_test_output(&ctx);
@@ -236,7 +236,7 @@ int libusbx_testlib_run_tests(int argc,
/* Run any requested tests */
while (tests[idx].function != NULL) {
- const libusbx_testlib_test * test = &tests[idx];
+ const libusb_testlib_test * test = &tests[idx];
++idx;
if (ctx.test_count > 0) {
/* Filtering tests to run, check if this is one of them */
@@ -251,10 +251,10 @@ int libusbx_testlib_run_tests(int argc,
continue;
}
}
- libusbx_testlib_logf(&ctx,
+ libusb_testlib_logf(&ctx,
"Starting test run: %s...", test->name);
test_result = test->function(&ctx);
- libusbx_testlib_logf(&ctx,
+ libusb_testlib_logf(&ctx,
"%s (%d)",
test_result_to_str(test_result), test_result);
switch (test_result) {
@@ -265,12 +265,12 @@ int libusbx_testlib_run_tests(int argc,
}
++run_count;
}
- libusbx_testlib_logf(&ctx, "---");
- libusbx_testlib_logf(&ctx, "Ran %d tests", run_count);
- libusbx_testlib_logf(&ctx, "Passed %d tests", pass_count);
- libusbx_testlib_logf(&ctx, "Failed %d tests", fail_count);
- libusbx_testlib_logf(&ctx, "Error in %d tests", error_count);
- libusbx_testlib_logf(&ctx, "Skipped %d tests", skip_count);
+ libusb_testlib_logf(&ctx, "---");
+ libusb_testlib_logf(&ctx, "Ran %d tests", run_count);
+ libusb_testlib_logf(&ctx, "Passed %d tests", pass_count);
+ libusb_testlib_logf(&ctx, "Failed %d tests", fail_count);
+ libusb_testlib_logf(&ctx, "Error in %d tests", error_count);
+ libusb_testlib_logf(&ctx, "Skipped %d tests", skip_count);
cleanup_test_output(&ctx);
return pass_count != run_count;