diff --git a/core/tarantool.m b/core/tarantool.m index d14b975cd5ef172bc70021bd6d7d530ae913b9db..d095655fd1b3813a9f940aed2a4cbfb8b5e99607 100644 --- a/core/tarantool.m +++ b/core/tarantool.m @@ -440,7 +440,7 @@ main(int argc, char **argv) i = tarantool_cfg_iterator_init(); while ((key = tarantool_cfg_iterator_next(i, &cfg, &value)) != NULL) { - if (strcmp(key, cfg_paramname) == 0) { + if (strcmp(key, cfg_paramname) == 0 && value != NULL) { printf("%s\n", value); free(value); diff --git a/test/box/args.result b/test/box/args.result index d2b35788914ca961530a3ee49205101f90f1bbff..1b8217a75daabec33d25842c3207898b0e5f79cb 100644 --- a/test/box/args.result +++ b/test/box/args.result @@ -38,6 +38,8 @@ Usage: tarantool_box [OPTIONS] Please visit project home page at http://launchpad.net/tarantool to see online documentation, submit bugs or contribute a patch. +tarantool_box --cfg-get=custom_proc_title + tarantool_box -Z tarantool_box: -Z: unknown option diff --git a/test/box/args.test b/test/box/args.test index d9146f3044cfcdd8a9b0375666c2bcecbe3a4c65..75a6752c79b816d74c55c32bbe249699061e04b9 100644 --- a/test/box/args.test +++ b/test/box/args.test @@ -4,6 +4,9 @@ import os server.test_option("--help") server.test_option("-h") sys.stdout.push_filter("(/\S+)+/tarantool", "tarantool") +# Test a cfg-get for something that is not in the config +# file (used to crash, Bug#748599 +server.test_option("--cfg-get=custom_proc_title") server.test_option("-Z") server.test_option("--no-such-option") server.test_option("--version --no-such-option") diff --git a/test/box/protocol.c b/test/box/protocol.c index 4ad75a341bcba42e557107eb440e8e88b4ac6076..fa2d6d5ddcf5ac926b6c701bef238feae7dac34c 100644 --- a/test/box/protocol.c +++ b/test/box/protocol.c @@ -1,33 +1,46 @@ #include <connector/c/client.h> #include <stdio.h> -int main() { - struct tnt_connection *conn = tnt_connect("localhost", 33013); - if (conn == NULL) - return 1; +/** Server connection. Reused between tests. */ +struct tnt_connection *conn; - { - const char message[]= { - 0xd, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, - 0x4, 0x1, 0x0, 0x0, 0x0 }; - int res = tnt_execute_raw(conn, message, sizeof message); - printf("return_code: %d\n", res); // =0 - } - { - /* - * A test case for Bug#702397 - * https://bugs.launchpad.net/tarantool/+bug/702397 - * "If SELECT request specifies tuple count 0, no error" - */ - const char message[]= { - 0x11, 0x0, 0x0, 0x0, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 }; - int res = tnt_execute_raw(conn, message, sizeof message); - printf("return_code: %d\n", res); // =2 - } +/** Test the ping command. */ +void test_ping() +{ + const char message[]= { + 0xd, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, + 0x4, 0x1, 0x0, 0x0, 0x0 }; + int res = tnt_execute_raw(conn, message, sizeof message); + printf("return_code: %d\n", res); /* =0 */ +} + + +void test_bug702397() +{ + /* + * A test case for Bug#702397 + * https://bugs.launchpad.net/tarantool/+bug/702397 + * "If SELECT request specifies tuple count 0, no error" + */ + const char message[]= { + 0x11, 0x0, 0x0, 0x0, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 }; + int res = tnt_execute_raw(conn, message, sizeof message); + printf("return_code: %d\n", res); // =2 +} + +int main() +{ + conn = tnt_connect("localhost", 33013); + if (conn == NULL) + return 1; + + test_ping(); + test_bug702397(); - tnt_disconnect(conn); + tnt_disconnect(conn); return 0; }