Skip to content

Revert "Fix compilation warnings in extended test suite" #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions tests/bsdtests.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,6 @@ test_long_format(long actual, long expected, const char* format, ...)
_test_long(NULL, 0, desc, actual, expected);
}

void
_test_sizet(const char* file, long line, const char* desc, size_t actual, size_t expected)
{
_test_print(file, line, desc,
(actual == expected), "%zd", actual, "%zd", expected);
}

void
test_sizet_format(size_t actual, size_t expected, const char* format, ...)
{
GENERATE_DESC
_test_sizet(NULL, 0, desc, actual, expected);
}

void
_test_uint64(const char* file, long line, const char* desc, uint64_t actual, uint64_t expected)
{
Expand Down Expand Up @@ -269,32 +255,6 @@ test_long_greater_than_or_equal_format(long actual, long expected_max, const cha
_test_long_greater_than_or_equal(NULL, 0, desc, actual, expected_max);
}

void
_test_sizet_less_than(const char* file, long line, const char* desc, size_t actual, size_t expected_max)
{
_test_print(file, line, desc, (actual < expected_max), "%zd", actual, "<%zd", expected_max);
}

void
test_sizet_less_than_format(size_t actual, size_t expected_max, const char* format, ...)
{
GENERATE_DESC
_test_sizet_less_than(NULL, 0, desc, actual, expected_max);
}

void
_test_sizet_less_than_or_equal(const char* file, long line, const char* desc, size_t actual, size_t expected_max)
{
_test_print(file, line, desc, (actual <= expected_max), "%zd", actual, "<=%zd", expected_max);
}

void
test_sizet_less_than_or_equal_format(size_t actual, size_t expected_max, const char* format, ...)
{
GENERATE_DESC
_test_sizet_less_than_or_equal(NULL, 0, desc, actual, expected_max);
}

void
_test_double_less_than(const char* file, long line, const char* desc, double val, double max_expected)
{
Expand Down
12 changes: 0 additions & 12 deletions tests/bsdtests.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ void _test_long(const char* file, long line, const char* desc, long actual, long
#define test_long(a,b,c) _test_long(__SOURCE_FILE__, __LINE__, a, b, c)
void test_long_format(long actual, long expected, const char *format, ...) __printflike(3,4);

void _test_sizet(const char* file, long line, const char* desc, size_t actual, size_t expected);
#define test_sizet(a,b,c) _test_sizet(__SOURCE_FILE__, __LINE__, a, b, c)
void test_sizet_format(size_t actual, size_t expected, const char *format, ...) __printflike(3,4);

void _test_uint64(const char* file, long line, const char* desc, uint64_t actual, uint64_t expected);
#define test_uint64(a,b,c) _test_uint64(__SOURCE_FILE__, __LINE__, a, b, c)
void test_uint64_format(uint64_t actual, uint64_t expected, const char* desc, ...);
Expand All @@ -115,14 +111,6 @@ void _test_long_greater_than_or_equal(const char* file, long line, const char* d
#define test_long_greater_than_or_equal(a,b,c) _test_long_greater_than_or_equal(__SOURCE_FILE__, __LINE__, a, b, c)
void test_long_greater_than_or_equal_format(long actual, long expected_min, const char *format, ...) __printflike(3,4);

void _test_sizet_less_than(const char* file, long line, const char* desc, size_t actual, size_t max_expected);
#define test_sizet_less_than(a,b,c) _test_sizet_less_than(__SOURCE_FILE__, __LINE__, a, b, c)
void test_sizet_less_than_format(size_t actual, size_t max_expected, const char *format, ...) __printflike(3,4);

void _test_sizet_less_than_or_equal(const char* file, long line, const char* desc, size_t actual, size_t max_expected);
#define test_sizet_less_than_or_equal(a,b,c) _test_sizet_less_than_or_equal(__SOURCE_FILE__, __LINE__, a, b, c)
void test_sizet_less_than_or_equal_format(size_t actual, size_t max_expected, const char *format, ...) __printflike(3,4);

void _test_double_less_than_or_equal(const char* file, long line, const char* desc, double val, double max_expected);
#define test_double_less_than_or_equal(d, v, m) _test_double_less_than_or_equal(__SOURCE_FILE__, __LINE__, d, v, m)
void test_double_less_than_or_equal_format(double val, double max_expected, const char *format, ...) __printflike(3,4);
Expand Down
6 changes: 3 additions & 3 deletions tests/dispatch_cascade.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ union {
char padding[64];
} indices[BLOCKS];

size_t iterations = (QUEUES * BLOCKS) / 4;
size_t iterations = QUEUES * BLOCKS * 0.25;

static void
noop(void *ctxt __attribute__((unused)))
Expand All @@ -57,7 +57,7 @@ cleanup(void *ctxt __attribute__((unused)))
exit(0);
}

static void
void
histogram(void)
{
size_t counts[QUEUES] = {};
Expand Down Expand Up @@ -92,7 +92,7 @@ histogram(void)
}
}

static void
void
cascade(void* context)
{
size_t idx, *idxptr = context;
Expand Down
30 changes: 15 additions & 15 deletions tests/dispatch_concur.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ test_concur_async(size_t n, size_t qw)
if (qw > 1) {
size_t concurrency = MIN(n * workers, qw);
if (done > min_acceptable_concurrency) {
test_sizet_less_than_or_equal("concurrently completed workers", done, concurrency);
test_long_less_than_or_equal("concurrently completed workers", done, concurrency);
} else {
test_sizet("concurrently completed workers", done, concurrency);
test_long("concurrently completed workers", done, concurrency);
}
} else {
test_sizet_less_than_or_equal("concurrently completed workers", done, 1);
test_long_less_than_or_equal("concurrently completed workers", done, 1);
}

for (i = 0, mc = mcs; i < n; i++, mc++) {
Expand All @@ -116,9 +116,9 @@ test_concur_async(size_t n, size_t qw)

size_t expect = MIN(n, qw);
if (max_concur > min_acceptable_concurrency) {
test_sizet_less_than_or_equal("max submission concurrency", max_concur, expect);
test_long_less_than_or_equal("max submission concurrency", max_concur, expect);
} else {
test_sizet("max submission concurrency", max_concur, expect);
test_long("max submission concurrency", max_concur, expect);
}

dispatch_group_wait(gw, DISPATCH_TIME_FOREVER);
Expand Down Expand Up @@ -159,9 +159,9 @@ test_concur_sync(size_t n, size_t qw)

size_t expect = qw == 1 ? 1 : n;
if (max_concur > min_acceptable_concurrency) {
test_sizet_less_than_or_equal("max sync concurrency", max_concur, expect);
test_long_less_than_or_equal("max sync concurrency", max_concur, expect);
} else {
test_sizet("max sync concurrency", max_concur, expect);
test_long("max sync concurrency", max_concur, expect);
}
}

Expand Down Expand Up @@ -190,9 +190,9 @@ test_concur_apply(size_t n, size_t qw)

size_t expect = MIN(n, qw);
if (max_concur > min_acceptable_concurrency) {
test_sizet_less_than_or_equal("max apply concurrency", max_concur, expect);
test_long_less_than_or_equal("max apply concurrency", max_concur, expect);
} else {
test_sizet("max apply concurrency", max_concur, expect);
test_long("max apply concurrency", max_concur, expect);
}
}

Expand Down Expand Up @@ -231,19 +231,19 @@ main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
dispatch_test_start("Dispatch Private Concurrent/Wide Queue"); // <rdar://problem/8049506&8169448&8186485>

#ifdef __linux__
activecpu = (uint32_t)sysconf(_SC_NPROCESSORS_ONLN);
activecpu = sysconf(_SC_NPROCESSORS_ONLN);
#else
size_t s = sizeof(activecpu);
sysctlbyname("hw.activecpu", &activecpu, &s, NULL, 0);
#endif
size_t n = activecpu / 2 > 1 ? activecpu / 2 : 1, w = activecpu * 2;
min_acceptable_concurrency = (uint32_t)n;
min_acceptable_concurrency = n;
dispatch_queue_t tq, ttq;
long qw, tqw, ttqw;
const char *ql, *tql, *ttql;
size_t qi, tqi, ttqi;
long qws[] = {
0, LONG_MAX, (long)w, 1, // 0 <=> global queue
0, LONG_MAX, w, 1, // 0 <=> global queue
};

g = dispatch_group_create();
Expand All @@ -262,16 +262,16 @@ main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
"queue hierarchy: %s -> %s -> %s\n",
use_group_async ? "_group" : "", ql, tql, ttql);
fflush(stdout);
test_concur_async(n, (size_t)MIN(qw, MIN(tqw, ttqw)));
test_concur_async(n, MIN(qw, MIN(tqw, ttqw)));
}
fprintf(stdout, "Testing dispatch_sync on "
"queue hierarchy: %s -> %s -> %s\n", ql, tql, ttql);
fflush(stdout);
test_concur_sync(w, (size_t)MIN(qw, MIN(tqw, ttqw)));
test_concur_sync(w, MIN(qw, MIN(tqw, ttqw)));
fprintf(stdout, "Testing dispatch_apply on "
"queue hierarchy: %s -> %s -> %s\n", ql, tql, ttql);
fflush(stdout);
test_concur_apply(activecpu, (size_t)MIN(qw, MIN(tqw, ttqw)));
test_concur_apply(activecpu, MIN(qw, MIN(tqw, ttqw)));
dispatch_release(q);
}
dispatch_release(tq);
Expand Down
4 changes: 2 additions & 2 deletions tests/dispatch_drift.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ main(int argc __attribute__((unused)), char* argv[] __attribute__((unused)))
uint64_t interval = 1000000000 / 100;
double interval_d = interval / 1000000000.0;
// for 25 seconds
unsigned int target = (unsigned int)(25.0 / interval_d);
unsigned int target = 25 / interval_d;

dispatch_test_start("Dispatch Timer Drift");

dispatch_source_t t = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
test_ptr_notnull("dispatch_source_create", t);

dispatch_source_set_timer(t, dispatch_time(DISPATCH_TIME_NOW, (int64_t)interval), interval, 0);
dispatch_source_set_timer(t, dispatch_time(DISPATCH_TIME_NOW, interval), interval, 0);

dispatch_source_set_event_handler(t, ^{
struct timeval now_tv;
Expand Down
46 changes: 23 additions & 23 deletions tests/dispatch_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#endif
#endif

static void
void
test_fin(void *cxt)
{
test_ptr("test_fin run", cxt, cxt);
Expand Down Expand Up @@ -96,7 +96,7 @@ test_io_close(int with_timer, bool from_path)
test_errno("fstat", errno, 0);
test_stop();
}
const size_t size = (size_t)sb.st_size / chunks;
const size_t size = sb.st_size / chunks;
const int expected_error = with_timer? ECANCELED : 0;
dispatch_source_t t = NULL;
dispatch_group_t g = dispatch_group_create();
Expand Down Expand Up @@ -142,7 +142,7 @@ test_io_close(int with_timer, bool from_path)
for (i = 0; i < chunks; i++) {
data[i] = dispatch_data_empty;
dispatch_group_enter(g);
dispatch_io_read(io, (off_t)(i * size), size, dispatch_get_global_queue(0,0),
dispatch_io_read(io, i * size, size, dispatch_get_global_queue(0,0),
^(bool done, dispatch_data_t d, int error) {
if (d) {
chunk_size[i] += dispatch_data_get_size(d);
Expand Down Expand Up @@ -180,16 +180,16 @@ test_io_close(int with_timer, bool from_path)
}
for (i = 0; i < chunks; i++) {
if (with_timer) {
test_sizet_less_than("chunk size", chunk_size[i], size + 1);
test_long_less_than("chunk size", chunk_size[i], size + 1);
} else {
test_sizet("chunk size", chunk_size[i], size);
test_long("chunk size", chunk_size[i], size);
}
total += chunk_size[i];
}
if (with_timer) {
test_sizet_less_than("total size", total, chunks * size + 1);
test_long_less_than("total size", total, chunks * size + 1);
} else {
test_sizet("total size", total, chunks * size);
test_long("total size", total, chunks * size);
}
}

Expand Down Expand Up @@ -251,7 +251,7 @@ test_io_read_write(void)
test_errno("fstat", errno, 0);
test_stop();
}
const size_t siz_in = MIN(1024 * 1024, (size_t)sb.st_size);
const size_t siz_in = MIN(1024 * 1024, sb.st_size);

int out = mkstemp(path_out);
if (out == -1) {
Expand Down Expand Up @@ -283,19 +283,19 @@ test_io_read_write(void)
dispatch_group_enter(g);
dispatch_io_read(io_in, 0, siz_in, q,
^(bool done_in, dispatch_data_t data_in, int err_in) {
test_sizet_less_than("read size", dispatch_data_get_size(data_in),
test_long_less_than("read size", dispatch_data_get_size(data_in),
siz_in);
if (data_in) {
dispatch_group_enter(g);
dispatch_io_write(io_out, 0, data_in, q,
^(bool done_out, dispatch_data_t data_out, int err_out) {
if (done_out) {
test_errno("dispatch_io_write", err_out, 0);
test_sizet("remaining write size",
test_long("remaining write size",
data_out ? dispatch_data_get_size(data_out) : 0, 0);
dispatch_group_leave(g);
} else {
test_sizet_less_than("remaining write size",
test_long_less_than("remaining write size",
dispatch_data_get_size(data_out), siz_in);
}
});
Expand All @@ -321,7 +321,7 @@ test_io_read_write(void)
}
close(out);
size_t siz_cmp = dispatch_data_get_size(cmp);
test_sizet("readback size", siz_cmp, siz_in);
test_long("readback size", siz_cmp, siz_in);
const void *data_buf, *cmp_buf;
dispatch_data_t data_map, cmp_map;
data_map = dispatch_data_create_map(data, &data_buf, NULL);
Expand Down Expand Up @@ -378,7 +378,7 @@ test_async_read(char *path, size_t size, int option, dispatch_queue_t queue,
}
free(buffer);
close(fd);
process_data((size_t)r);
process_data(r);
});
break;
case DISPATCH_READ_ON_CONCURRENT_QUEUE:
Expand Down Expand Up @@ -455,7 +455,7 @@ test_read_dirs(char **paths, dispatch_queue_t queue, dispatch_group_t g,
test_ptr_notnull("fts_open failed", tree);
test_stop();
}
int files_opened = 0;
unsigned int files_opened = 0;
size_t size, total_size = 0;
FTSENT *node;
while ((node = fts_read(tree)) &&
Expand All @@ -465,11 +465,11 @@ test_read_dirs(char **paths, dispatch_queue_t queue, dispatch_group_t g,
} else if (node->fts_info == FTS_F) {
dispatch_group_enter(g);
dispatch_semaphore_wait(s, DISPATCH_TIME_FOREVER);
size = (size_t)node->fts_statp->st_size;
size = node->fts_statp->st_size;
total_size += size;
files_opened++;
test_async_read(node->fts_path, size, option, queue, ^(size_t len){
OSAtomicAdd32((int32_t)len, (volatile int32_t *)bytes);
OSAtomicAdd32(len, bytes);
dispatch_semaphore_signal(s);
dispatch_group_leave(g);
});
Expand All @@ -485,7 +485,7 @@ test_read_dirs(char **paths, dispatch_queue_t queue, dispatch_group_t g,
test_stop();
}
test_group_wait(g);
test_sizet("total size", *bytes, total_size);
test_long("total size", *bytes, total_size);
return files_opened;
}

Expand All @@ -506,7 +506,7 @@ test_read_many_files(void)
dispatch_semaphore_t s = dispatch_semaphore_create(maxopenfiles);
uint64_t start;
volatile uint32_t bytes;
int files_read, i;
unsigned int files_read, i;

const dispatch_queue_t queues[] = {
[DISPATCH_ASYNC_READ_ON_CONCURRENT_QUEUE] =
Expand Down Expand Up @@ -546,7 +546,7 @@ test_read_many_files(void)
l.rlim_cur = 2 * maxopenfiles + 256;
setrlimit(RLIMIT_NOFILE, &l);
}
for (i = 0; i < (int)(sizeof(queues)/sizeof(dispatch_queue_t)); ++i) {
for (i = 0; i < sizeof(queues)/sizeof(dispatch_queue_t); ++i) {
fprintf(stdout, "%s:\n", names[i]);
bytes = 0;
start = mach_absolute_time();
Expand Down Expand Up @@ -610,7 +610,7 @@ test_io_from_io(void) // rdar://problem/8388909
#else
test_errno("error from write to write protected directory", err_out, EACCES);
#endif
test_sizet("unwritten data", dispatch_data_get_size(data_out), 256);
test_long("unwritten data", dispatch_data_get_size(data_out), 256);
if (!err_out && done) {
test_stop();
}
Expand Down Expand Up @@ -661,11 +661,11 @@ test_io_from_io(void) // rdar://problem/8388909
^(bool done, dispatch_data_t data_out, int err_out) {
if (done) {
test_errno("dispatch_io_write", err_out, 0);
test_sizet("remaining write size",
test_long("remaining write size",
data_out ? dispatch_data_get_size(data_out) : 0, 0);
dispatch_group_leave(g);
} else {
test_sizet_less_than("remaining write size",
test_long_less_than("remaining write size",
dispatch_data_get_size(data_out), siz_in);
}
});
Expand Down Expand Up @@ -696,7 +696,7 @@ test_io_from_io(void) // rdar://problem/8388909
dispatch_release(io2);
test_group_wait(g);
dispatch_release(g);
test_sizet("readback size", dispatch_data_get_size(data_out), siz_in);
test_long("readback size", dispatch_data_get_size(data_out), siz_in);
dispatch_release(data_out);
#endif
}
Expand Down
Loading