Skip to content

Commit ab8a151

Browse files
Merge pull request #518 from compnerd/enable-testing
build: migrate to standard mechanism for testing
2 parents c023edd + 46862df commit ab8a151

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
66
project(dispatch
77
VERSION 1.3
88
LANGUAGES C CXX)
9-
enable_testing()
109

1110
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
1211
include(ClangClCompileRules)
@@ -36,6 +35,7 @@ include(CheckLibraryExists)
3635
include(CheckSymbolExists)
3736
include(GNUInstallDirs)
3837
include(SwiftSupport)
38+
include(CTest)
3939

4040
set(SWIFT_LIBDIR "lib" CACHE PATH "Library folder name, defined by swift main buildscript")
4141
set(INSTALL_LIBDIR "${SWIFT_LIBDIR}" CACHE PATH "Path where the libraries should be installed")
@@ -86,8 +86,6 @@ option(DISPATCH_ENABLE_ASSERTS "enable debug assertions" FALSE)
8686

8787
option(ENABLE_DTRACE "enable dtrace support" "")
8888

89-
option(ENABLE_TESTING "build libdispatch tests" ON)
90-
9189
option(ENABLE_THREAD_LOCAL_STORAGE "enable usage of thread local storage via _Thread_local" ON)
9290
set(DISPATCH_USE_THREAD_LOCAL_STORAGE ${ENABLE_THREAD_LOCAL_STORAGE})
9391

@@ -286,7 +284,7 @@ add_subdirectory(man)
286284
add_subdirectory(os)
287285
add_subdirectory(private)
288286
add_subdirectory(src)
289-
if(ENABLE_TESTING)
287+
if(BUILD_TESTING)
290288
add_subdirectory(tests)
291289
endif()
292290

tests/dispatch_context_for_key.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#if DISPATCH_API_VERSION >= 20100825 && DISPATCH_API_VERSION != 20101110
3333

34-
static char *ctxts[] = {"ctxt for app", "ctxt for key 1",
34+
static const char *ctxts[] = {"ctxt for app", "ctxt for key 1",
3535
"ctxt for key 2", "ctxt for key 1 bis", "ctxt for key 4"};
3636
volatile long ctxts_destroyed;
3737
static dispatch_group_t g;
@@ -58,20 +58,20 @@ test_context_for_key(void)
5858
dispatch_queue_t ttq = dispatch_get_global_queue(0, 0);
5959
dispatch_group_enter(g);
6060
#if DISPATCH_API_VERSION >= 20101011
61-
dispatch_queue_set_specific(tq, &ctxts[4], ctxts[4], destructor);
61+
dispatch_queue_set_specific(tq, &ctxts[4], (char *)ctxts[4], destructor);
6262
#else
6363
dispatch_set_context_for_key(tq, &ctxts[4], ctxts[4], ttq, destructor);
6464
#endif
6565
dispatch_set_target_queue(tq, ttq);
6666
dispatch_group_enter(g);
67-
dispatch_set_context(q, ctxts[0]);
67+
dispatch_set_context(q, (char *)ctxts[0]);
6868
dispatch_set_target_queue(q, tq);
6969
dispatch_set_finalizer_f(q, destructor);
7070

7171
dispatch_async(q, ^{
7272
dispatch_group_enter(g);
7373
#if DISPATCH_API_VERSION >= 20101011
74-
dispatch_queue_set_specific(q, &ctxts[1], ctxts[1], destructor);
74+
dispatch_queue_set_specific(q, &ctxts[1], (char *)ctxts[1], destructor);
7575
#else
7676
dispatch_set_context_for_key(q, &ctxts[1], ctxts[1], ttq, destructor);
7777
#endif
@@ -80,7 +80,7 @@ test_context_for_key(void)
8080
dispatch_async(dispatch_get_global_queue(0, 0), ^{
8181
dispatch_group_enter(g);
8282
#if DISPATCH_API_VERSION >= 20101011
83-
dispatch_queue_set_specific(q, &ctxts[2], ctxts[2], destructor);
83+
dispatch_queue_set_specific(q, &ctxts[2], (char *)ctxts[2], destructor);
8484
#else
8585
dispatch_set_context_for_key(q, &ctxts[2], ctxts[2], ttq, destructor);
8686
#endif
@@ -114,7 +114,7 @@ test_context_for_key(void)
114114
dispatch_group_enter(g);
115115
void *ctxt;
116116
#if DISPATCH_API_VERSION >= 20101011
117-
dispatch_queue_set_specific(q, &ctxts[1], ctxts[3], destructor);
117+
dispatch_queue_set_specific(q, &ctxts[1], (char *)ctxts[3], destructor);
118118
ctxt = dispatch_queue_get_specific(q, &ctxts[1]);
119119
#else
120120
dispatch_set_context_for_key(q, &ctxts[1], ctxts[3], ttq, destructor);

tests/dispatch_data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ test_concat(void)
4343
{
4444
dispatch_group_enter(g);
4545
dispatch_async(dispatch_get_main_queue(), ^{
46-
char* buffer1 = "This is buffer1 ";
46+
const char* buffer1 = "This is buffer1 ";
4747
size_t size1 = 17;
48-
char* buffer2 = "This is buffer2 ";
48+
const char* buffer2 = "This is buffer2 ";
4949
size_t size2 = 17;
5050
__block bool buffer2_destroyed = false;
5151

tests/dispatch_io_muxed.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ test_file_muxed(void)
4747
printf("\nFile Muxed\n");
4848

4949
#if defined(_WIN32)
50-
char *temp_dir = getenv("TMP");
50+
const char *temp_dir = getenv("TMP");
5151
if (!temp_dir) {
5252
temp_dir = getenv("TEMP");
5353
}
5454
if (!temp_dir) {
5555
test_ptr_notnull("temporary directory", temp_dir);
5656
test_stop();
5757
}
58-
char *path_separator = "\\";
58+
const char *path_separator = "\\";
5959
#else
60-
char *temp_dir = getenv("TMPDIR");
60+
const char *temp_dir = getenv("TMPDIR");
6161
if (!temp_dir) {
6262
temp_dir = "/tmp";
6363
}
64-
char *path_separator = "/";
64+
const char *path_separator = "/";
6565
#endif
6666
char *path = NULL;
6767
asprintf(&path, "%s%sdispatchtest_io.XXXXXX", temp_dir, path_separator);

0 commit comments

Comments
 (0)