test: wrap long lines at 80 columns

This commit is contained in:
Ben Noordhuis 2013-09-11 16:59:55 +02:00
parent ce3c38a5d8
commit f5baf210df
14 changed files with 129 additions and 35 deletions

View File

@ -86,7 +86,9 @@ static int test_async(int nthreads) {
ctx->loop = uv_loop_new(); ctx->loop = uv_loop_new();
ASSERT(ctx->loop != NULL); ASSERT(ctx->loop != NULL);
ASSERT(0 == uv_async_init(ctx->loop, &ctx->worker_async, worker_async_cb)); ASSERT(0 == uv_async_init(ctx->loop, &ctx->worker_async, worker_async_cb));
ASSERT(0 == uv_async_init(uv_default_loop(), &ctx->main_async, main_async_cb)); ASSERT(0 == uv_async_init(uv_default_loop(),
&ctx->main_async,
main_async_cb));
ASSERT(0 == uv_thread_create(&ctx->thread, worker, ctx)); ASSERT(0 == uv_thread_create(&ctx->thread, worker, ctx));
} }

View File

@ -148,7 +148,9 @@ static void pinger_read_cb(uv_stream_t* tcp,
if (pinger->state == 0) { if (pinger->state == 0) {
pinger->pongs++; pinger->pongs++;
if (uv_now(loop) - start_time > TIME) { if (uv_now(loop) - start_time > TIME) {
uv_shutdown(&pinger->shutdown_req, (uv_stream_t*) tcp, pinger_shutdown_cb); uv_shutdown(&pinger->shutdown_req,
(uv_stream_t*) tcp,
pinger_shutdown_cb);
break; break;
} else { } else {
pinger_write_ping(pinger); pinger_write_ping(pinger);

View File

@ -229,7 +229,10 @@ static void pipe_make_connect(conn_rec* p) {
r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0); r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0);
ASSERT(r == 0); ASSERT(r == 0);
uv_pipe_connect(&((pipe_conn_rec*)p)->conn_req, (uv_pipe_t*)&p->stream, TEST_PIPENAME, connect_cb); uv_pipe_connect(&((pipe_conn_rec*) p)->conn_req,
(uv_pipe_t*) &p->stream,
TEST_PIPENAME,
connect_cb);
#if DEBUG #if DEBUG
printf("make connect %d\n", p->i); printf("make connect %d\n", p->i);
@ -308,20 +311,40 @@ static int pound_it(int concurrency,
BENCHMARK_IMPL(tcp4_pound_100) { BENCHMARK_IMPL(tcp4_pound_100) {
return pound_it(100, "tcp", tcp_do_setup, tcp_do_connect, tcp_make_connect, NULL); return pound_it(100,
"tcp",
tcp_do_setup,
tcp_do_connect,
tcp_make_connect,
NULL);
} }
BENCHMARK_IMPL(tcp4_pound_1000) { BENCHMARK_IMPL(tcp4_pound_1000) {
return pound_it(1000, "tcp", tcp_do_setup, tcp_do_connect, tcp_make_connect, NULL); return pound_it(1000,
"tcp",
tcp_do_setup,
tcp_do_connect,
tcp_make_connect,
NULL);
} }
BENCHMARK_IMPL(pipe_pound_100) { BENCHMARK_IMPL(pipe_pound_100) {
return pound_it(100, "pipe", pipe_do_setup, pipe_do_connect, pipe_make_connect, NULL); return pound_it(100,
"pipe",
pipe_do_setup,
pipe_do_connect,
pipe_make_connect,
NULL);
} }
BENCHMARK_IMPL(pipe_pound_1000) { BENCHMARK_IMPL(pipe_pound_1000) {
return pound_it(1000, "pipe", pipe_do_setup, pipe_do_connect, pipe_make_connect, NULL); return pound_it(1000,
"pipe",
pipe_do_setup,
pipe_do_connect,
pipe_make_connect,
NULL);
} }

View File

@ -101,11 +101,16 @@ static void show_stats(uv_timer_t* handle, int status) {
uv_update_time(loop); uv_update_time(loop);
diff = uv_now(loop) - start_time; diff = uv_now(loop) - start_time;
LOGF("%s_pump%d_client: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", write_sockets, LOGF("%s_pump%d_client: %.1f gbit/s\n",
type == TCP ? "tcp" : "pipe",
write_sockets,
gbit(nsent_total, diff)); gbit(nsent_total, diff));
for (i = 0; i < write_sockets; i++) { for (i = 0; i < write_sockets; i++) {
uv_close(type == TCP ? (uv_handle_t*)&tcp_write_handles[i] : (uv_handle_t*)&pipe_write_handles[i], NULL); if (type == TCP)
uv_close((uv_handle_t*) &tcp_write_handles[i], NULL);
else
uv_close((uv_handle_t*) &pipe_write_handles[i], NULL);
} }
exit(0); exit(0);
@ -123,7 +128,9 @@ static void read_show_stats(void) {
uv_update_time(loop); uv_update_time(loop);
diff = uv_now(loop) - start_time; diff = uv_now(loop) - start_time;
LOGF("%s_pump%d_server: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", max_read_sockets, LOGF("%s_pump%d_server: %.1f gbit/s\n",
type == TCP ? "tcp" : "pipe",
max_read_sockets,
gbit(nrecv_total, diff)); gbit(nrecv_total, diff));
} }
@ -219,7 +226,10 @@ static void connect_cb(uv_connect_t* req, int status) {
/* Yay! start writing */ /* Yay! start writing */
for (i = 0; i < write_sockets; i++) { for (i = 0; i < write_sockets; i++) {
do_write(type == TCP ? (uv_stream_t*)&tcp_write_handles[i] : (uv_stream_t*)&pipe_write_handles[i]); if (type == TCP)
do_write((uv_stream_t*) &tcp_write_handles[i]);
else
do_write((uv_stream_t*) &pipe_write_handles[i]);
} }
} }
} }

View File

@ -26,7 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN" /* "Take eight!" */ #define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN"
#define TEST_DURATION 5000 /* ms */ #define TEST_DURATION 5000 /* ms */

View File

@ -159,12 +159,16 @@ static void process_req(uv_stream_t* handle,
/* process len and id */ /* process len and id */
if (readbuf_remaining < hdrbuf_remaining) { if (readbuf_remaining < hdrbuf_remaining) {
/* too little to get request header. save for next buffer */ /* too little to get request header. save for next buffer */
memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], dnsreq, readbuf_remaining); memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining],
dnsreq,
readbuf_remaining);
hdrbuf_remaining = DNSREC_LEN - readbuf_remaining; hdrbuf_remaining = DNSREC_LEN - readbuf_remaining;
break; break;
} else { } else {
/* save header */ /* save header */
memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], dnsreq, hdrbuf_remaining); memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining],
dnsreq,
hdrbuf_remaining);
dnsreq += hdrbuf_remaining; dnsreq += hdrbuf_remaining;
readbuf_remaining -= hdrbuf_remaining; readbuf_remaining -= hdrbuf_remaining;
hdrbuf_remaining = 0; hdrbuf_remaining = 0;
@ -192,7 +196,9 @@ static void process_req(uv_stream_t* handle,
} }
} }
/* if we had to use bytes from prev buffer, start processing the current one */ /* If we had to use bytes from prev buffer, start processing the current
* one.
*/
if (usingprev == 1) { if (usingprev == 1) {
/* free previous buffer */ /* free previous buffer */
free(dns->state.prevbuf_ptr); free(dns->state.prevbuf_ptr);

View File

@ -110,7 +110,9 @@ int process_start(char *name, char *part, process_info_t *p, int is_helper) {
if (!SetHandleInformation(nul, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) if (!SetHandleInformation(nul, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
goto error; goto error;
result = GetModuleFileNameW(NULL, (WCHAR*)&image, sizeof(image) / sizeof(WCHAR)); result = GetModuleFileNameW(NULL,
(WCHAR*) &image,
sizeof(image) / sizeof(WCHAR));
if (result == 0 || result == sizeof(image)) if (result == 0 || result == sizeof(image))
goto error; goto error;
@ -214,8 +216,12 @@ int process_copy_output(process_info_t *p, int fd) {
char buf[1024]; char buf[1024];
char *line, *start; char *line, *start;
if (SetFilePointer(p->stdio_out, 0, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER) if (SetFilePointer(p->stdio_out,
0,
0,
FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
return -1; return -1;
}
if (tap_output) if (tap_output)
write(fd, "#", 1); write(fd, "#", 1);
@ -337,8 +343,13 @@ static int clear_line() {
if (!SetConsoleCursorPosition(handle, coord)) if (!SetConsoleCursorPosition(handle, coord))
return -1; return -1;
if (!FillConsoleOutputCharacterW(handle, 0x20, info.dwSize.X, coord, &written)) if (!FillConsoleOutputCharacterW(handle,
0x20,
info.dwSize.X,
coord,
&written)) {
return -1; return -1;
}
return 0; return 0;
} }

View File

@ -410,7 +410,8 @@ static int compare_task(const void* va, const void* vb) {
} }
static int find_helpers(const task_entry_t* task, const task_entry_t** helpers) { static int find_helpers(const task_entry_t* task,
const task_entry_t** helpers) {
const task_entry_t* helper; const task_entry_t* helper;
int n_helpers; int n_helpers;

View File

@ -1333,7 +1333,12 @@ TEST_IMPL(fs_symlink) {
close(link); close(link);
r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL); r = uv_fs_symlink(loop,
&req,
"test_file_symlink",
"test_file_symlink_symlink",
0,
NULL);
ASSERT(r == 0); ASSERT(r == 0);
uv_fs_req_cleanup(&req); uv_fs_req_cleanup(&req);
@ -1343,7 +1348,12 @@ TEST_IMPL(fs_symlink) {
uv_fs_req_cleanup(&req); uv_fs_req_cleanup(&req);
/* async link */ /* async link */
r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink2", 0, symlink_cb); r = uv_fs_symlink(loop,
&req,
"test_file",
"test_file_symlink2",
0,
symlink_cb);
ASSERT(r == 0); ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT); uv_run(loop, UV_RUN_DEFAULT);
ASSERT(symlink_cb_count == 1); ASSERT(symlink_cb_count == 1);
@ -1362,7 +1372,12 @@ TEST_IMPL(fs_symlink) {
close(link); close(link);
r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL); r = uv_fs_symlink(loop,
&req,
"test_file_symlink2",
"test_file_symlink2_symlink",
0,
NULL);
ASSERT(r == 0); ASSERT(r == 0);
uv_fs_req_cleanup(&req); uv_fs_req_cleanup(&req);

View File

@ -47,7 +47,9 @@ TEST_IMPL(get_currentexe) {
} }
match = strstr(buffer, path); match = strstr(buffer, path);
/* Verify that the path returned from uv_exepath is a subdirectory of executable_path */ /* Verify that the path returned from uv_exepath is a subdirectory of
* executable_path.
*/
ASSERT(match && !strcmp(match, path)); ASSERT(match && !strcmp(match, path));
ASSERT(size == strlen(buffer)); ASSERT(size == strlen(buffer));

View File

@ -78,7 +78,11 @@ static void pinger_write_ping(pinger_t* pinger) {
buf = uv_buf_init(PING, sizeof(PING) - 1); buf = uv_buf_init(PING, sizeof(PING) - 1);
req = malloc(sizeof(*req)); req = malloc(sizeof(*req));
if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) { if (uv_write(req,
(uv_stream_t*) &pinger->stream.tcp,
&buf,
1,
pinger_after_write)) {
FATAL("uv_write failed"); FATAL("uv_write failed");
} }

View File

@ -113,7 +113,9 @@ static void kill_cb(uv_process_t* process,
ASSERT(err == UV_ESRCH); ASSERT(err == UV_ESRCH);
} }
static void detach_failure_cb(uv_process_t* process, int64_t exit_status, int term_signal) { static void detach_failure_cb(uv_process_t* process,
int64_t exit_status,
int term_signal) {
printf("detach_cb\n"); printf("detach_cb\n");
exit_cb_called++; exit_cb_called++;
} }
@ -630,7 +632,11 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) {
options.stdio_count = 2; options.stdio_count = 2;
/* Create a pipe that'll cause a collision. */ /* Create a pipe that'll cause a collision. */
_snprintf(name, sizeof(name), "\\\\.\\pipe\\uv\\%p-%d", &out, GetCurrentProcessId()); _snprintf(name,
sizeof(name),
"\\\\.\\pipe\\uv\\%p-%d",
&out,
GetCurrentProcessId());
pipe_handle = CreateNamedPipeA(name, pipe_handle = CreateNamedPipeA(name,
PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
@ -729,8 +735,12 @@ TEST_IMPL(argument_escaping) {
wprintf(L" verbatim_output: %s\n", verbatim_output); wprintf(L" verbatim_output: %s\n", verbatim_output);
wprintf(L"non_verbatim_output: %s\n", non_verbatim_output); wprintf(L"non_verbatim_output: %s\n", non_verbatim_output);
ASSERT(wcscmp(verbatim_output, L"cmd.exe /c c:\\path\\to\\node.exe --eval \"require('c:\\\\path\\\\to\\\\test.js')\"") == 0); ASSERT(wcscmp(verbatim_output,
ASSERT(wcscmp(non_verbatim_output, L"cmd.exe /c \"c:\\path\\to\\node.exe --eval \\\"require('c:\\\\path\\\\to\\\\test.js')\\\"\"") == 0); L"cmd.exe /c c:\\path\\to\\node.exe --eval "
L"\"require('c:\\\\path\\\\to\\\\test.js')\"") == 0);
ASSERT(wcscmp(non_verbatim_output,
L"cmd.exe /c \"c:\\path\\to\\node.exe --eval "
L"\\\"require('c:\\\\path\\\\to\\\\test.js')\\\"\"") == 0);
free(verbatim_output); free(verbatim_output);
free(non_verbatim_output); free(non_verbatim_output);
@ -758,17 +768,23 @@ TEST_IMPL(environment_creation) {
WCHAR* env; WCHAR* env;
for (i = 0; i < sizeof(environment) / sizeof(environment[0]) - 1; i++) { for (i = 0; i < sizeof(environment) / sizeof(environment[0]) - 1; i++) {
ptr += uv_utf8_to_utf16(environment[i], ptr, expected + sizeof(expected) - ptr); ptr += uv_utf8_to_utf16(environment[i],
ptr,
expected + sizeof(expected) - ptr);
} }
memcpy(ptr, L"SYSTEMROOT=", sizeof(L"SYSTEMROOT=")); memcpy(ptr, L"SYSTEMROOT=", sizeof(L"SYSTEMROOT="));
ptr += sizeof(L"SYSTEMROOT=")/sizeof(WCHAR) - 1; ptr += sizeof(L"SYSTEMROOT=")/sizeof(WCHAR) - 1;
ptr += GetEnvironmentVariableW(L"SYSTEMROOT", ptr, expected + sizeof(expected) - ptr); ptr += GetEnvironmentVariableW(L"SYSTEMROOT",
ptr,
expected + sizeof(expected) - ptr);
++ptr; ++ptr;
memcpy(ptr, L"SYSTEMDRIVE=", sizeof(L"SYSTEMDRIVE=")); memcpy(ptr, L"SYSTEMDRIVE=", sizeof(L"SYSTEMDRIVE="));
ptr += sizeof(L"SYSTEMDRIVE=")/sizeof(WCHAR) - 1; ptr += sizeof(L"SYSTEMDRIVE=")/sizeof(WCHAR) - 1;
ptr += GetEnvironmentVariableW(L"SYSTEMDRIVE", ptr, expected + sizeof(expected) - ptr); ptr += GetEnvironmentVariableW(L"SYSTEMDRIVE",
ptr,
expected + sizeof(expected) - ptr);
++ptr; ++ptr;
*ptr = '\0'; *ptr = '\0';

View File

@ -116,7 +116,8 @@ TEST_IMPL(tcp_bind_error_addrnotavail_2) {
TEST_IMPL(tcp_bind_error_fault) { TEST_IMPL(tcp_bind_error_fault) {
char garbage[] = "blah blah blah blah blah blah blah blah blah blah blah blah"; char garbage[] =
"blah blah blah blah blah blah blah blah blah blah blah blah";
struct sockaddr_in* garbage_addr; struct sockaddr_in* garbage_addr;
uv_tcp_t server; uv_tcp_t server;
int r; int r;

View File

@ -92,7 +92,8 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) {
TEST_IMPL(tcp_bind6_error_fault) { TEST_IMPL(tcp_bind6_error_fault) {
char garbage[] = "blah blah blah blah blah blah blah blah blah blah blah blah"; char garbage[] =
"blah blah blah blah blah blah blah blah blah blah blah blah";
struct sockaddr_in6* garbage_addr; struct sockaddr_in6* garbage_addr;
uv_tcp_t server; uv_tcp_t server;
int r; int r;