Remove c-ares tests and benchmarks
This commit is contained in:
parent
3a8bb3b2b1
commit
35c4858231
@ -1,117 +0,0 @@
|
||||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h> /* strlen */
|
||||
|
||||
static uv_loop_t* loop;
|
||||
|
||||
static ares_channel channel;
|
||||
static struct ares_options options;
|
||||
static int optmask;
|
||||
|
||||
static int ares_callbacks;
|
||||
static int ares_errors;
|
||||
static int argument;
|
||||
|
||||
#define NUM_CALLS_TO_START 1000
|
||||
|
||||
static int64_t start_time;
|
||||
static int64_t end_time;
|
||||
|
||||
|
||||
/* callback method. */
|
||||
static void aresbynamecallback(void *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
struct hostent *hostent) {
|
||||
ares_callbacks++;
|
||||
if (status != 0) {
|
||||
ares_errors++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void prep_tcploopback()
|
||||
{
|
||||
/* for test, use echo server - TCP port TEST_PORT on loopback */
|
||||
struct sockaddr_in test_server = uv_ip4_addr("127.0.0.1", 0);
|
||||
int rc = 0;
|
||||
optmask = 0;
|
||||
|
||||
optmask = ARES_OPT_SERVERS | ARES_OPT_TCP_PORT | ARES_OPT_FLAGS;
|
||||
options.servers = &test_server.sin_addr;
|
||||
options.nservers = 1;
|
||||
options.tcp_port = TEST_PORT_2;
|
||||
options.flags = ARES_FLAG_USEVC;
|
||||
|
||||
rc = uv_ares_init_options(loop, &channel, &options, optmask);
|
||||
|
||||
ASSERT(rc == ARES_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
BENCHMARK_IMPL(gethostbyname) {
|
||||
|
||||
int rc = 0;
|
||||
int ares_start;;
|
||||
|
||||
rc = ares_library_init(ARES_LIB_INIT_ALL);
|
||||
if (rc != 0) {
|
||||
printf("ares library init fails %d\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
loop = uv_default_loop();
|
||||
|
||||
ares_callbacks = 0;
|
||||
ares_errors = 0;
|
||||
|
||||
start_time = uv_hrtime();
|
||||
|
||||
prep_tcploopback();
|
||||
|
||||
for (ares_start = 0; ares_start < NUM_CALLS_TO_START; ares_start++) {
|
||||
ares_gethostbyname(channel,
|
||||
"echos.srv",
|
||||
AF_INET,
|
||||
&aresbynamecallback,
|
||||
&argument);
|
||||
}
|
||||
|
||||
uv_run(loop);
|
||||
|
||||
uv_ares_destroy(loop, channel);
|
||||
|
||||
end_time = uv_hrtime();
|
||||
|
||||
if (ares_errors > 0) {
|
||||
printf("There were %d failures\n", ares_errors);
|
||||
}
|
||||
LOGF("ares_gethostbyname: %.0f req/s\n",
|
||||
1e9 * ares_callbacks / (double)(end_time - start_time));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -42,7 +42,6 @@ BENCHMARK_DECLARE (udp_packet_storm_10v1000)
|
||||
BENCHMARK_DECLARE (udp_packet_storm_100v100)
|
||||
BENCHMARK_DECLARE (udp_packet_storm_100v1000)
|
||||
BENCHMARK_DECLARE (udp_packet_storm_1000v1000)
|
||||
BENCHMARK_DECLARE (gethostbyname)
|
||||
BENCHMARK_DECLARE (getaddrinfo)
|
||||
BENCHMARK_DECLARE (fs_stat)
|
||||
BENCHMARK_DECLARE (async1)
|
||||
@ -109,9 +108,6 @@ TASK_LIST_START
|
||||
BENCHMARK_ENTRY (udp_packet_storm_100v1000)
|
||||
BENCHMARK_ENTRY (udp_packet_storm_1000v1000)
|
||||
|
||||
BENCHMARK_ENTRY (gethostbyname)
|
||||
BENCHMARK_HELPER (gethostbyname, dns_server)
|
||||
|
||||
BENCHMARK_ENTRY (getaddrinfo)
|
||||
|
||||
BENCHMARK_ENTRY (fs_stat)
|
||||
|
||||
@ -1,180 +0,0 @@
|
||||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h> /* strlen */
|
||||
|
||||
static ares_channel channel;
|
||||
|
||||
static int ares_bynamecallbacks;
|
||||
static int bynamecallbacksig;
|
||||
static int ares_byaddrcallbacks;
|
||||
static int byaddrcallbacksig;
|
||||
|
||||
static void aresbynamecallback( void *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
struct hostent *hostent) {
|
||||
int * iargs;
|
||||
ASSERT(arg != NULL);
|
||||
iargs = (int*)arg;
|
||||
ASSERT(*iargs == bynamecallbacksig);
|
||||
ASSERT(timeouts == 0);
|
||||
|
||||
printf("aresbynamecallback %d\n", ares_bynamecallbacks++);
|
||||
}
|
||||
|
||||
|
||||
static void aresbyaddrcallback( void *arg,
|
||||
int status,
|
||||
int timeouts,
|
||||
struct hostent *hostent) {
|
||||
int * iargs;
|
||||
ASSERT(arg != NULL);
|
||||
iargs = (int*)arg;
|
||||
ASSERT(*iargs == byaddrcallbacksig);
|
||||
ASSERT(timeouts == 0);
|
||||
|
||||
printf("aresbyaddrcallback %d\n", ares_byaddrcallbacks++);
|
||||
}
|
||||
|
||||
|
||||
static void setup_cares() {
|
||||
int r;
|
||||
struct ares_options options;
|
||||
memset(&options, 0, sizeof options);
|
||||
r = uv_ares_init_options(uv_default_loop(), &channel, &options, 0);
|
||||
ASSERT(r == ARES_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(gethostbyname) {
|
||||
|
||||
int rc = 0;
|
||||
char addr[4];
|
||||
|
||||
rc = ares_library_init(ARES_LIB_INIT_ALL);
|
||||
if (rc != 0) {
|
||||
printf("ares library init fails %d\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Start basic gethostbyname test\n");
|
||||
setup_cares();
|
||||
|
||||
ares_bynamecallbacks = 0;
|
||||
bynamecallbacksig = 7;
|
||||
|
||||
ares_gethostbyname(channel,
|
||||
"microsoft.com",
|
||||
AF_INET,
|
||||
&aresbynamecallback,
|
||||
&bynamecallbacksig);
|
||||
uv_run(uv_default_loop());
|
||||
|
||||
ASSERT(ares_bynamecallbacks == 1);
|
||||
|
||||
uv_ares_destroy(uv_default_loop(), channel);
|
||||
printf("Done basic gethostbyname test\n");
|
||||
|
||||
|
||||
/* two sequential call on new channel */
|
||||
|
||||
printf("Start gethostbyname and gethostbyaddr sequential test\n");
|
||||
setup_cares();
|
||||
|
||||
ares_bynamecallbacks = 0;
|
||||
bynamecallbacksig = 7;
|
||||
|
||||
ares_gethostbyname(channel,
|
||||
"microsoft.com",
|
||||
AF_INET,
|
||||
&aresbynamecallback,
|
||||
&bynamecallbacksig);
|
||||
uv_run(uv_default_loop());
|
||||
|
||||
ASSERT(ares_bynamecallbacks == 1);
|
||||
|
||||
ares_byaddrcallbacks = 0;
|
||||
byaddrcallbacksig = 8;
|
||||
addr[0] = 10;
|
||||
addr[1] = 0;
|
||||
addr[2] = 1;
|
||||
addr[3] = 99;
|
||||
|
||||
ares_gethostbyaddr(channel,
|
||||
addr,
|
||||
4,
|
||||
AF_INET,
|
||||
&aresbyaddrcallback,
|
||||
&byaddrcallbacksig);
|
||||
|
||||
uv_run(uv_default_loop());
|
||||
|
||||
ASSERT(ares_byaddrcallbacks == 1);
|
||||
|
||||
uv_ares_destroy(uv_default_loop(), channel);
|
||||
printf("Done gethostbyname and gethostbyaddr sequential test\n");
|
||||
|
||||
|
||||
/* two simultaneous calls on new channel */
|
||||
|
||||
printf("Start gethostbyname and gethostbyaddr concurrent test\n");
|
||||
setup_cares();
|
||||
|
||||
ares_bynamecallbacks = 0;
|
||||
bynamecallbacksig = 7;
|
||||
|
||||
ares_gethostbyname(channel,
|
||||
"microsoft.com",
|
||||
AF_INET,
|
||||
&aresbynamecallback,
|
||||
&bynamecallbacksig);
|
||||
|
||||
ares_byaddrcallbacks = 0;
|
||||
byaddrcallbacksig = 8;
|
||||
addr[0] = 10;
|
||||
addr[1] = 0;
|
||||
addr[2] = 1;
|
||||
addr[3] = 99;
|
||||
|
||||
ares_gethostbyaddr(channel,
|
||||
addr,
|
||||
4,
|
||||
AF_INET,
|
||||
&aresbyaddrcallback,
|
||||
&byaddrcallbacksig);
|
||||
|
||||
uv_run(uv_default_loop());
|
||||
|
||||
ASSERT(ares_bynamecallbacks == 1);
|
||||
ASSERT(ares_byaddrcallbacks == 1);
|
||||
|
||||
|
||||
uv_ares_destroy(uv_default_loop(), channel);
|
||||
printf("Done gethostbyname and gethostbyaddr concurrent test\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -119,7 +119,6 @@ TEST_DECLARE (get_memory)
|
||||
TEST_DECLARE (hrtime)
|
||||
TEST_DECLARE (getaddrinfo_basic)
|
||||
TEST_DECLARE (getaddrinfo_concurrent)
|
||||
TEST_DECLARE (gethostbyname)
|
||||
TEST_DECLARE (getsockname_tcp)
|
||||
TEST_DECLARE (getsockname_udp)
|
||||
TEST_DECLARE (fail_always)
|
||||
@ -344,8 +343,6 @@ TASK_LIST_START
|
||||
TEST_ENTRY (getaddrinfo_basic)
|
||||
TEST_ENTRY (getaddrinfo_concurrent)
|
||||
|
||||
TEST_ENTRY (gethostbyname)
|
||||
|
||||
TEST_ENTRY (getsockname_tcp)
|
||||
TEST_ENTRY (getsockname_udp)
|
||||
|
||||
|
||||
2
uv.gyp
2
uv.gyp
@ -320,7 +320,6 @@
|
||||
'test/test-get-currentexe.c',
|
||||
'test/test-get-memory.c',
|
||||
'test/test-getaddrinfo.c',
|
||||
'test/test-gethostbyname.c',
|
||||
'test/test-getsockname.c',
|
||||
'test/test-hrtime.c',
|
||||
'test/test-idle.c',
|
||||
@ -408,7 +407,6 @@
|
||||
'type': 'executable',
|
||||
'dependencies': [ 'uv' ],
|
||||
'sources': [
|
||||
'test/benchmark-ares.c',
|
||||
'test/benchmark-async.c',
|
||||
'test/benchmark-async-pummel.c',
|
||||
'test/benchmark-fs-stat.c',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user