mirror of
https://github.com/samba-team/samba.git
synced 2025-03-11 16:58:40 +03:00
ctdb-tests: Iterate protocol tests internally
Instead of repeatedly running a test binary. Run time for these tests reduces from ~90s to ~75s. When run under valgrind, the run time for protocol_test_001.sh reduces from ~390s to <1s. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Mon Feb 14 04:32:29 UTC 2022 on sn-devel-184
This commit is contained in:
parent
2329305019
commit
17d792e9aa
@ -311,8 +311,7 @@ static void TEST_FUNC(NAME)(uint32_t cmd) \
|
||||
size_t buflen, np; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s %u\n", #NAME, cmd); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s %u\n", #NAME, cmd); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
FILL_FUNC(NAME)(mem_ctx, &c1, cmd); \
|
||||
@ -340,8 +339,7 @@ static void TEST_FUNC(NAME)(uint32_t cmd) \
|
||||
size_t buflen, len; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s %u\n", #NAME, cmd); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s %u\n", #NAME, cmd); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
fill_ctdb_event_header(&h1); \
|
||||
@ -379,15 +377,10 @@ EVENT_PROTOCOL1_TEST(struct ctdb_event_reply, ctdb_event_reply_data);
|
||||
EVENT_PROTOCOL2_TEST(struct ctdb_event_request, ctdb_event_request);
|
||||
EVENT_PROTOCOL2_TEST(struct ctdb_event_reply, ctdb_event_reply);
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
static void event_protocol_test(void)
|
||||
{
|
||||
uint32_t cmd;
|
||||
|
||||
if (argc == 2) {
|
||||
int seed = atoi(argv[1]);
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
TEST_FUNC(ctdb_event_script)();
|
||||
TEST_FUNC(ctdb_event_script_list)();
|
||||
|
||||
@ -410,6 +403,10 @@ int main(int argc, const char **argv)
|
||||
for (cmd=1; cmd<CTDB_EVENT_CMD_MAX; cmd++) {
|
||||
TEST_FUNC(ctdb_event_reply)(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
protocol_test_iterate(argc, argv, event_protocol_test);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,24 +2,6 @@
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
last_command=3
|
||||
ok_null
|
||||
|
||||
generate_output ()
|
||||
{
|
||||
for i in $(seq 1 $last_command) ; do
|
||||
echo "$1 $i"
|
||||
done
|
||||
}
|
||||
|
||||
output=$(
|
||||
generate_output "ctdb_event_request_data"
|
||||
generate_output "ctdb_event_reply_data"
|
||||
generate_output "ctdb_event_request"
|
||||
generate_output "ctdb_event_reply"
|
||||
)
|
||||
|
||||
ok "$output"
|
||||
|
||||
for i in $(seq 1 100) ; do
|
||||
unit_test event_protocol_test $i
|
||||
done
|
||||
unit_test event_protocol_test 1 100
|
||||
|
@ -4,6 +4,4 @@
|
||||
|
||||
ok_null
|
||||
|
||||
for i in $(seq 1 1000) ; do
|
||||
unit_test protocol_basic_test $i
|
||||
done
|
||||
unit_test protocol_basic_test 1 1000
|
||||
|
@ -4,6 +4,4 @@
|
||||
|
||||
ok_null
|
||||
|
||||
for i in $(seq 1 1000) ; do
|
||||
unit_test protocol_types_test $i
|
||||
done
|
||||
unit_test protocol_types_test 1 1000
|
||||
|
@ -4,6 +4,4 @@
|
||||
|
||||
ok_null
|
||||
|
||||
for i in $(seq 1 1000) ; do
|
||||
unit_test protocol_types_compat_test $i
|
||||
done
|
||||
unit_test protocol_types_compat_test 1 1000
|
||||
|
@ -2,65 +2,6 @@
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
last_control=158
|
||||
ok_null
|
||||
|
||||
generate_control_output ()
|
||||
{
|
||||
for i in $(seq 0 $last_control) ; do
|
||||
echo "$1 $i"
|
||||
done
|
||||
}
|
||||
|
||||
srvid_list="\
|
||||
f002000000000000 \
|
||||
f100000000000000 \
|
||||
f101000000000000 \
|
||||
f200000000000000 \
|
||||
f300000000000000 \
|
||||
f301000000000000 \
|
||||
f400000000000000 \
|
||||
f500000000000000 \
|
||||
f700000000000000 \
|
||||
f701000000000000 \
|
||||
f800000000000000 \
|
||||
f801000000000000 \
|
||||
f802000000000000 \
|
||||
f900000000000000 \
|
||||
fa00000000000000 \
|
||||
fb00000000000000 \
|
||||
fb01000000000000 \
|
||||
fb03000000000000 \
|
||||
fb04000000000000 \
|
||||
fc00000000000000 \
|
||||
"
|
||||
|
||||
generate_message_output ()
|
||||
{
|
||||
for i in $srvid_list ; do
|
||||
echo "$1 $i"
|
||||
done
|
||||
}
|
||||
|
||||
output=$(
|
||||
echo "ctdb_req_header"
|
||||
echo "ctdb_req_call"
|
||||
echo "ctdb_reply_call"
|
||||
echo "ctdb_reply_error"
|
||||
echo "ctdb_req_dmaster"
|
||||
echo "ctdb_reply_dmaster"
|
||||
generate_control_output "ctdb_req_control_data"
|
||||
generate_control_output "ctdb_reply_control_data"
|
||||
generate_control_output "ctdb_req_control"
|
||||
generate_control_output "ctdb_reply_control"
|
||||
generate_message_output "ctdb_message_data"
|
||||
generate_message_output "ctdb_req_message"
|
||||
echo "ctdb_req_message_data"
|
||||
echo "ctdb_req_keepalive"
|
||||
echo "ctdb_req_tunnel"
|
||||
)
|
||||
|
||||
ok "$output"
|
||||
|
||||
for i in $(seq 1 100) ; do
|
||||
unit_test protocol_ctdb_test $i
|
||||
done
|
||||
unit_test protocol_ctdb_test 1 100
|
||||
|
@ -4,6 +4,4 @@
|
||||
|
||||
ok_null
|
||||
|
||||
for i in $(seq 1 100) ; do
|
||||
unit_test protocol_ctdb_compat_test $i
|
||||
done
|
||||
unit_test protocol_ctdb_compat_test 1 100
|
||||
|
@ -78,13 +78,8 @@ static void test_ctdb_padding(void)
|
||||
assert(np == buflen);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void protocol_basic_test(void)
|
||||
{
|
||||
if (argc == 2) {
|
||||
int seed = atoi(argv[1]);
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
TEST_FUNC(ctdb_uint8)();
|
||||
TEST_FUNC(ctdb_uint16)();
|
||||
TEST_FUNC(ctdb_int32)();
|
||||
@ -102,6 +97,10 @@ int main(int argc, char *argv[])
|
||||
TEST_FUNC(ctdb_timeval)();
|
||||
|
||||
test_ctdb_padding();
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
protocol_test_iterate(argc, argv, protocol_basic_test);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ COMPAT_CTDB4_TEST(struct ctdb_req_tunnel, ctdb_req_tunnel, CTDB_REQ_TUNNEL);
|
||||
|
||||
#define NUM_CONTROLS 151
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void protocol_ctdb_compat_test(void)
|
||||
{
|
||||
uint32_t opcode;
|
||||
uint64_t test_srvid[] = {
|
||||
@ -1239,11 +1239,6 @@ int main(int argc, char *argv[])
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
if (argc == 2) {
|
||||
int seed = atoi(argv[1]);
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
COMPAT_TEST_FUNC(ctdb_req_header)();
|
||||
|
||||
COMPAT_TEST_FUNC(ctdb_req_call)();
|
||||
@ -1266,6 +1261,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
COMPAT_TEST_FUNC(ctdb_req_keepalive)();
|
||||
COMPAT_TEST_FUNC(ctdb_req_tunnel)();
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
protocol_test_iterate(argc, argv, protocol_ctdb_compat_test);
|
||||
return 0;
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ static void TEST_FUNC(NAME)(void) \
|
||||
size_t pkt_len, buflen, np; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s\n", #NAME); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s\n", #NAME); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
FILL_FUNC(NAME)(&c1); \
|
||||
@ -77,8 +76,7 @@ static void TEST_FUNC(NAME)(uint32_t opcode) \
|
||||
size_t pkt_len, buflen, np; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s %u\n", #NAME, opcode); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s %u\n", #NAME, opcode); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
FILL_FUNC(NAME)(mem_ctx, &c1, opcode); \
|
||||
@ -108,8 +106,7 @@ static void TEST_FUNC(NAME)(uint64_t srvid) \
|
||||
size_t pkt_len, buflen, np; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s %"PRIx64"\n", #NAME, srvid); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s %"PRIx64"\n", #NAME, srvid); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
FILL_FUNC(NAME)(mem_ctx, &c1, srvid); \
|
||||
@ -140,8 +137,7 @@ static void TEST_FUNC(NAME)(void) \
|
||||
size_t pkt_len, buflen, len; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s\n", #NAME); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s\n", #NAME); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
fill_ctdb_req_header(&h1); \
|
||||
@ -176,8 +172,7 @@ static void TEST_FUNC(NAME)(uint32_t opcode) \
|
||||
size_t pkt_len, buflen, len; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s %u\n", #NAME, opcode); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s %u\n", #NAME, opcode); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
fill_ctdb_req_header(&h1); \
|
||||
@ -212,8 +207,7 @@ static void TEST_FUNC(NAME)(uint32_t opcode) \
|
||||
size_t pkt_len, buflen, len; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s %u\n", #NAME, opcode); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s %u\n", #NAME, opcode); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
fill_ctdb_req_header(&h1); \
|
||||
@ -248,8 +242,7 @@ static void TEST_FUNC(NAME)(uint64_t srvid) \
|
||||
size_t pkt_len, buflen, len; \
|
||||
int ret; \
|
||||
\
|
||||
printf("%s %"PRIx64"\n", #NAME, srvid); \
|
||||
fflush(stdout); \
|
||||
protocol_test_iterate_tag("%s %"PRIx64"\n", #NAME, srvid); \
|
||||
mem_ctx = talloc_new(NULL); \
|
||||
assert(mem_ctx != NULL); \
|
||||
fill_ctdb_req_header(&h1); \
|
||||
@ -304,7 +297,7 @@ PROTOCOL_CTDB4_TEST(struct ctdb_req_keepalive, ctdb_req_keepalive,
|
||||
CTDB_REQ_KEEPALIVE);
|
||||
PROTOCOL_CTDB4_TEST(struct ctdb_req_tunnel, ctdb_req_tunnel, CTDB_REQ_TUNNEL);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void protocol_ctdb_test(void)
|
||||
{
|
||||
uint32_t opcode;
|
||||
uint64_t test_srvid[] = {
|
||||
@ -331,11 +324,6 @@ int main(int argc, char *argv[])
|
||||
};
|
||||
size_t i;
|
||||
|
||||
if (argc == 2) {
|
||||
int seed = atoi(argv[1]);
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
TEST_FUNC(ctdb_req_header)();
|
||||
|
||||
TEST_FUNC(ctdb_req_call)();
|
||||
@ -368,6 +356,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
TEST_FUNC(ctdb_req_keepalive)();
|
||||
TEST_FUNC(ctdb_req_tunnel)();
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
protocol_test_iterate(argc, argv, protocol_ctdb_test);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2317,13 +2317,8 @@ COMPAT_TYPE1_TEST(struct ctdb_g_lock, ctdb_g_lock);
|
||||
|
||||
COMPAT_TYPE3_TEST(struct ctdb_g_lock_list, ctdb_g_lock_list);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void protocol_types_compat_test(void)
|
||||
{
|
||||
if (argc == 2) {
|
||||
int seed = atoi(argv[1]);
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
COMPAT_TEST_FUNC(ctdb_statistics)();
|
||||
COMPAT_TEST_FUNC(ctdb_vnn_map)();
|
||||
COMPAT_TEST_FUNC(ctdb_dbid_map)();
|
||||
@ -2367,6 +2362,10 @@ int main(int argc, char *argv[])
|
||||
COMPAT_TEST_FUNC(ctdb_server_id)();
|
||||
COMPAT_TEST_FUNC(ctdb_g_lock)();
|
||||
COMPAT_TEST_FUNC(ctdb_g_lock_list)();
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
protocol_test_iterate(argc, argv, protocol_types_compat_test);
|
||||
return 0;
|
||||
}
|
||||
|
@ -128,13 +128,8 @@ static void test_ctdb_rec_buffer_read_write(void)
|
||||
talloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void protocol_types_test(void)
|
||||
{
|
||||
if (argc == 2) {
|
||||
int seed = atoi(argv[1]);
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
TEST_FUNC(ctdb_tdb_data)();
|
||||
TEST_FUNC(ctdb_tdb_datan)();
|
||||
TEST_FUNC(ctdb_latency_counter)();
|
||||
@ -190,6 +185,10 @@ int main(int argc, char *argv[])
|
||||
TEST_FUNC(sock_packet_header)();
|
||||
|
||||
test_ctdb_rec_buffer_read_write();
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
protocol_test_iterate(argc, argv, protocol_types_test);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user