-
Notifications
You must be signed in to change notification settings - Fork 78
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
Fix test compilation errors on Windows #144
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ set(LIBKQUEUE_TEST_SOURCES | |
kqueue.c | ||
libkqueue.c | ||
main.c | ||
proc.c | ||
read.c | ||
test.c | ||
timer.c | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,10 @@ static void | |
test_libkqueue_version(struct test_context *ctx) | ||
{ | ||
struct kevent kev, receipt; | ||
struct timespec ts = {0, 0}; | ||
|
||
EV_SET(&kev, 0, EVFILT_LIBKQUEUE, EV_ADD, NOTE_VERSION, 0, NULL); | ||
if (kevent(ctx->kqfd, &kev, 1, &receipt, 1, &(struct timespec){}) != 1) { | ||
if (kevent(ctx->kqfd, &kev, 1, &receipt, 1, &ts) != 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Windows still doesn't support C11?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it still doesn't support compound literals. I even tried enabling the latest conforming preprocessor: |
||
printf("Unable to add the following kevent:\n%s\n", | ||
kevent_to_str(&kev)); | ||
die("kevent"); | ||
|
@@ -38,9 +39,10 @@ static void | |
test_libkqueue_version_str(struct test_context *ctx) | ||
{ | ||
struct kevent kev, receipt; | ||
struct timespec ts = { 0, 0 }; | ||
|
||
EV_SET(&kev, 0, EVFILT_LIBKQUEUE, EV_ADD, NOTE_VERSION_STR, 0, NULL); | ||
if (kevent(ctx->kqfd, &kev, 1, &receipt, 1, &(struct timespec){}) != 1) { | ||
if (kevent(ctx->kqfd, &kev, 1, &receipt, 1, &ts) != 1) { | ||
printf("Unable to add the following kevent:\n%s\n", | ||
kevent_to_str(&kev)); | ||
die("kevent"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,12 @@ | |
|
||
#include "common.h" | ||
|
||
#if defined(_WIN32) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MinGW supports usleep. |
||
#define SLEEP_MS(ms) Sleep(ms) | ||
#else | ||
#define SLEEP_MS(microseconds) usleep(microseconds * 1000) | ||
#endif | ||
|
||
void | ||
test_kevent_timer_add(struct test_context *ctx) | ||
{ | ||
|
@@ -204,7 +210,7 @@ test_kevent_timer_dispatch(struct test_context *ctx) | |
kevent_cmp(&kev, ret); | ||
|
||
/* Confirm that the knote is disabled due to EV_DISPATCH */ | ||
usleep(500000); /* 500 ms */ | ||
SLEEP_MS(500); | ||
test_no_kevents(ctx->kqfd); | ||
|
||
#if WITH_NATIVE_KQUEUE_BUGS || !defined(__FreeBSD__) | ||
|
@@ -223,7 +229,7 @@ test_kevent_timer_dispatch(struct test_context *ctx) | |
test_no_kevents(ctx->kqfd); | ||
|
||
/* Get the next event */ | ||
usleep(1100000); /* 1100 ms */ | ||
SLEEP_MS(1100); | ||
kev.flags = EV_ADD | EV_CLEAR | EV_DISPATCH; | ||
kev.data = 5; | ||
kevent_get(ret, NUM_ELEMENTS(ret), ctx->kqfd, 1); | ||
|
@@ -232,7 +238,7 @@ test_kevent_timer_dispatch(struct test_context *ctx) | |
|
||
/* Remove the knote and ensure the event no longer fires */ | ||
kevent_add(ctx->kqfd, &kev, 4, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); | ||
usleep(500000); /* 500 ms */ | ||
SLEEP_MS(500); | ||
test_no_kevents(ctx->kqfd); | ||
} | ||
#endif /* EV_DISPATCH */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd wrap a lot of these in ifdef _MSC_VER
MinGW supports a lot of this, including pthread.