diff options
Diffstat (limited to 'test/core')
-rwxr-xr-x | test/core/bad_client/gen_build_yaml.py | 8 | ||||
-rwxr-xr-x | test/core/bad_ssl/gen_build_yaml.py | 12 | ||||
-rw-r--r-- | test/core/census/context_test.c (renamed from test/core/census/tag_set_test.c) | 280 | ||||
-rwxr-xr-x | test/core/end2end/gen_build_yaml.py | 8 | ||||
-rw-r--r-- | test/core/statistics/census_log_tests.c | 6 | ||||
-rw-r--r-- | test/core/support/sync_test.c | 4 | ||||
-rw-r--r-- | test/core/support/time_test.c | 8 | ||||
-rw-r--r-- | test/core/surface/server_chttp2_test.c | 30 | ||||
-rw-r--r-- | test/core/transport/chttp2/timeout_encoding_test.c | 2 | ||||
-rw-r--r-- | test/core/util/test_config.h | 18 |
10 files changed, 194 insertions, 182 deletions
diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index c538bffd71..f37aa66c5f 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -67,9 +67,7 @@ def main(): 'vs_proj_dir': 'test/bad_client', 'deps': [ 'grpc_test_util_unsecure', - 'grpc_unsecure', - 'gpr_test_util', - 'gpr' + 'grpc_unsecure' ] }], 'targets': [ @@ -84,9 +82,7 @@ def main(): 'deps': [ 'bad_client_test', 'grpc_test_util_unsecure', - 'grpc_unsecure', - 'gpr_test_util', - 'gpr' + 'grpc_unsecure' ] } for t in sorted(BAD_CLIENT_TESTS.keys())]} diff --git a/test/core/bad_ssl/gen_build_yaml.py b/test/core/bad_ssl/gen_build_yaml.py index cc097a8fdf..9f05fed485 100755 --- a/test/core/bad_ssl/gen_build_yaml.py +++ b/test/core/bad_ssl/gen_build_yaml.py @@ -58,9 +58,7 @@ def main(): 'platforms': ['linux', 'posix', 'mac'], 'deps': [ 'grpc_test_util', - 'grpc', - 'gpr_test_util', - 'gpr' + 'grpc' ] } ], @@ -76,9 +74,7 @@ def main(): 'deps': [ 'bad_ssl_test_server', 'grpc_test_util', - 'grpc', - 'gpr_test_util', - 'gpr' + 'grpc' ] } for t in sorted(BAD_CLIENT_TESTS.keys())] + [ @@ -92,9 +88,7 @@ def main(): 'platforms': ['linux', 'posix', 'mac'], 'deps': [ 'grpc_test_util', - 'grpc', - 'gpr_test_util', - 'gpr' + 'grpc' ] } for t in sorted(BAD_CLIENT_TESTS.keys())]} diff --git a/test/core/census/tag_set_test.c b/test/core/census/context_test.c index 1056e98d55..63e7103ddc 100644 --- a/test/core/census/tag_set_test.c +++ b/test/core/census/context_test.c @@ -31,7 +31,7 @@ * */ -// Test census_tag_set functions, including encoding/decoding +// Test census_context functions, including encoding/decoding #include <grpc/census.h> #include <grpc/support/log.h> @@ -46,7 +46,7 @@ static uint8_t one_byte_val = 7; static uint32_t four_byte_val = 0x12345678; static uint64_t eight_byte_val = 0x1234567890abcdef; -// A set of tags Used to create a basic tag_set for testing. Each tag has a +// A set of tags Used to create a basic context for testing. Each tag has a // unique set of flags. Note that replace_add_delete_test() relies on specific // offsets into this array - if you add or delete entries, you will also need // to change the test. @@ -65,7 +65,7 @@ static census_tag basic_tags[BASIC_TAG_COUNT] = { /* 7 */ {"k7", (char *)&four_byte_val, 4, CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS | CENSUS_TAG_BINARY}}; -// Set of tags used to modify the basic tag_set. Note that +// Set of tags used to modify the basic context. Note that // replace_add_delete_test() relies on specific offsets into this array - if // you add or delete entries, you will also need to change the test. Other // tests that rely on specific instances have XXX_XXX_OFFSET definitions (also @@ -99,35 +99,34 @@ static bool compare_tag(const census_tag *t1, const census_tag *t2) { t1->flags == t2->flags); } -// Utility function to validate a tag exists in tag set. -static bool validate_tag(const census_tag_set *cts, const census_tag *tag) { +// Utility function to validate a tag exists in context. +static bool validate_tag(const census_context *context, const census_tag *tag) { census_tag tag2; - if (census_tag_set_get_tag_by_key(cts, tag->key, &tag2) != 1) return false; + if (census_context_get_tag(context, tag->key, &tag2) != 1) return false; return compare_tag(tag, &tag2); } -// Create an empty tag_set. +// Create an empty context. static void empty_test(void) { - struct census_tag_set *cts = census_tag_set_create(NULL, NULL, 0, NULL); - GPR_ASSERT(cts != NULL); - const census_tag_set_create_status *status = - census_tag_set_get_create_status(cts); - census_tag_set_create_status expected = {0, 0, 0, 0, 0, 0, 0, 0}; + struct census_context *context = census_context_create(NULL, NULL, 0, NULL); + GPR_ASSERT(context != NULL); + const census_context_status *status = census_context_get_status(context); + census_context_status expected = {0, 0, 0, 0, 0, 0, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); } -// Test create and iteration over basic tag set. +// Test create and iteration over basic context. static void basic_test(void) { - const census_tag_set_create_status *status; - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, &status); - census_tag_set_create_status expected = {2, 2, 4, 0, 8, 0, 0, 0}; + const census_context_status *status; + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, &status); + census_context_status expected = {2, 2, 4, 0, 8, 0, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - census_tag_set_iterator it; - census_tag_set_initialize_iterator(cts, &it); + census_context_iterator it; + census_context_initialize_iterator(context, &it); census_tag tag; - while (census_tag_set_next_tag(&it, &tag)) { + while (census_context_next_tag(&it, &tag)) { // can't rely on tag return order: make sure it matches exactly one. int matches = 0; for (int i = 0; i < BASIC_TAG_COUNT; i++) { @@ -135,29 +134,28 @@ static void basic_test(void) { } GPR_ASSERT(matches == 1); } - census_tag_set_destroy(cts); + census_context_destroy(context); } -// Test that census_tag_set_get_tag_by_key(). +// Test census_context_get_tag(). static void lookup_by_key_test(void) { - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); census_tag tag; for (int i = 0; i < BASIC_TAG_COUNT; i++) { - GPR_ASSERT(census_tag_set_get_tag_by_key(cts, basic_tags[i].key, &tag) == - 1); + GPR_ASSERT(census_context_get_tag(context, basic_tags[i].key, &tag) == 1); GPR_ASSERT(compare_tag(&tag, &basic_tags[i])); } // non-existent keys - GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "key", &tag) == 0); - GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "key01", &tag) == 0); - GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "k9", &tag) == 0); - GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "random", &tag) == 0); - GPR_ASSERT(census_tag_set_get_tag_by_key(cts, "", &tag) == 0); - census_tag_set_destroy(cts); + GPR_ASSERT(census_context_get_tag(context, "key", &tag) == 0); + GPR_ASSERT(census_context_get_tag(context, "key01", &tag) == 0); + GPR_ASSERT(census_context_get_tag(context, "k9", &tag) == 0); + GPR_ASSERT(census_context_get_tag(context, "random", &tag) == 0); + GPR_ASSERT(census_context_get_tag(context, "", &tag) == 0); + census_context_destroy(context); } -// Try creating tag set with invalid entries. +// Try creating context with invalid entries. static void invalid_test(void) { char key[300]; memset(key, 'k', 299); @@ -168,155 +166,156 @@ static void invalid_test(void) { // long keys, short value. Key lengths (including terminator) should be // <= 255 (CENSUS_MAX_TAG_KV_LEN) GPR_ASSERT(strlen(key) == 299); - const census_tag_set_create_status *status; - struct census_tag_set *cts = census_tag_set_create(NULL, &tag, 1, &status); - census_tag_set_create_status expected = {0, 0, 0, 0, 0, 0, 1, 0}; + const census_context_status *status; + struct census_context *context = + census_context_create(NULL, &tag, 1, &status); + census_context_status expected = {0, 0, 0, 0, 0, 0, 1, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); key[CENSUS_MAX_TAG_KV_LEN] = 0; GPR_ASSERT(strlen(key) == CENSUS_MAX_TAG_KV_LEN); - cts = census_tag_set_create(NULL, &tag, 1, &status); + context = census_context_create(NULL, &tag, 1, &status); GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); key[CENSUS_MAX_TAG_KV_LEN - 1] = 0; GPR_ASSERT(strlen(key) == CENSUS_MAX_TAG_KV_LEN - 1); - cts = census_tag_set_create(NULL, &tag, 1, &status); - census_tag_set_create_status expected2 = {0, 0, 1, 0, 1, 0, 0, 0}; + context = census_context_create(NULL, &tag, 1, &status); + census_context_status expected2 = {0, 0, 1, 0, 1, 0, 0, 0}; GPR_ASSERT(memcmp(status, &expected2, sizeof(expected2)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); // now try with long values tag.value_len = 300; - cts = census_tag_set_create(NULL, &tag, 1, &status); + context = census_context_create(NULL, &tag, 1, &status); GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); tag.value_len = CENSUS_MAX_TAG_KV_LEN + 1; - cts = census_tag_set_create(NULL, &tag, 1, &status); + context = census_context_create(NULL, &tag, 1, &status); GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); tag.value_len = CENSUS_MAX_TAG_KV_LEN; - cts = census_tag_set_create(NULL, &tag, 1, &status); + context = census_context_create(NULL, &tag, 1, &status); GPR_ASSERT(memcmp(status, &expected2, sizeof(expected2)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); // 0 length key. key[0] = 0; - cts = census_tag_set_create(NULL, &tag, 1, &status); + context = census_context_create(NULL, &tag, 1, &status); GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - census_tag_set_destroy(cts); + census_context_destroy(context); } -// Make a copy of a tag set +// Make a copy of a context static void copy_test(void) { - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); - const census_tag_set_create_status *status; - struct census_tag_set *cts2 = census_tag_set_create(cts, NULL, 0, &status); - census_tag_set_create_status expected = {2, 2, 4, 0, 0, 0, 0, 0}; + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + const census_context_status *status; + struct census_context *context2 = + census_context_create(context, NULL, 0, &status); + census_context_status expected = {2, 2, 4, 0, 0, 0, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); for (int i = 0; i < BASIC_TAG_COUNT; i++) { census_tag tag; - GPR_ASSERT(census_tag_set_get_tag_by_key(cts2, basic_tags[i].key, &tag) == - 1); + GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) == 1); GPR_ASSERT(compare_tag(&tag, &basic_tags[i])); } - census_tag_set_destroy(cts); - census_tag_set_destroy(cts2); + census_context_destroy(context); + census_context_destroy(context2); } // replace a single tag value static void replace_value_test(void) { - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); - const census_tag_set_create_status *status; - struct census_tag_set *cts2 = census_tag_set_create( - cts, modify_tags + REPLACE_VALUE_OFFSET, 1, &status); - census_tag_set_create_status expected = {2, 2, 4, 0, 0, 1, 0, 0}; + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + const census_context_status *status; + struct census_context *context2 = census_context_create( + context, modify_tags + REPLACE_VALUE_OFFSET, 1, &status); + census_context_status expected = {2, 2, 4, 0, 0, 1, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); census_tag tag; - GPR_ASSERT(census_tag_set_get_tag_by_key( - cts2, modify_tags[REPLACE_VALUE_OFFSET].key, &tag) == 1); + GPR_ASSERT(census_context_get_tag( + context2, modify_tags[REPLACE_VALUE_OFFSET].key, &tag) == 1); GPR_ASSERT(compare_tag(&tag, &modify_tags[REPLACE_VALUE_OFFSET])); - census_tag_set_destroy(cts); - census_tag_set_destroy(cts2); + census_context_destroy(context); + census_context_destroy(context2); } // replace a single tags flags static void replace_flags_test(void) { - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); - const census_tag_set_create_status *status; - struct census_tag_set *cts2 = - census_tag_set_create(cts, modify_tags + REPLACE_FLAG_OFFSET, 1, &status); - census_tag_set_create_status expected = {1, 2, 5, 0, 0, 1, 0, 0}; + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + const census_context_status *status; + struct census_context *context2 = census_context_create( + context, modify_tags + REPLACE_FLAG_OFFSET, 1, &status); + census_context_status expected = {1, 2, 5, 0, 0, 1, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); census_tag tag; - GPR_ASSERT(census_tag_set_get_tag_by_key( - cts2, modify_tags[REPLACE_FLAG_OFFSET].key, &tag) == 1); + GPR_ASSERT(census_context_get_tag( + context2, modify_tags[REPLACE_FLAG_OFFSET].key, &tag) == 1); GPR_ASSERT(compare_tag(&tag, &modify_tags[REPLACE_FLAG_OFFSET])); - census_tag_set_destroy(cts); - census_tag_set_destroy(cts2); + census_context_destroy(context); + census_context_destroy(context2); } // delete a single tag. static void delete_tag_test(void) { - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); - const census_tag_set_create_status *status; - struct census_tag_set *cts2 = - census_tag_set_create(cts, modify_tags + DELETE_TAG_OFFSET, 1, &status); - census_tag_set_create_status expected = {2, 1, 4, 1, 0, 0, 0, 0}; + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + const census_context_status *status; + struct census_context *context2 = census_context_create( + context, modify_tags + DELETE_TAG_OFFSET, 1, &status); + census_context_status expected = {2, 1, 4, 1, 0, 0, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); census_tag tag; - GPR_ASSERT(census_tag_set_get_tag_by_key( - cts2, modify_tags[DELETE_TAG_OFFSET].key, &tag) == 0); - census_tag_set_destroy(cts); - census_tag_set_destroy(cts2); + GPR_ASSERT(census_context_get_tag( + context2, modify_tags[DELETE_TAG_OFFSET].key, &tag) == 0); + census_context_destroy(context); + census_context_destroy(context2); } // add a single new tag. static void add_tag_test(void) { - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); - const census_tag_set_create_status *status; - struct census_tag_set *cts2 = - census_tag_set_create(cts, modify_tags + ADD_TAG_OFFSET, 1, &status); - census_tag_set_create_status expected = {2, 2, 5, 0, 1, 0, 0, 0}; + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + const census_context_status *status; + struct census_context *context2 = + census_context_create(context, modify_tags + ADD_TAG_OFFSET, 1, &status); + census_context_status expected = {2, 2, 5, 0, 1, 0, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); census_tag tag; - GPR_ASSERT(census_tag_set_get_tag_by_key( - cts2, modify_tags[ADD_TAG_OFFSET].key, &tag) == 1); + GPR_ASSERT(census_context_get_tag(context2, modify_tags[ADD_TAG_OFFSET].key, + &tag) == 1); GPR_ASSERT(compare_tag(&tag, &modify_tags[ADD_TAG_OFFSET])); - census_tag_set_destroy(cts); - census_tag_set_destroy(cts2); + census_context_destroy(context); + census_context_destroy(context2); } // test many changes at once. static void replace_add_delete_test(void) { - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); - const census_tag_set_create_status *status; - struct census_tag_set *cts2 = - census_tag_set_create(cts, modify_tags, MODIFY_TAG_COUNT, &status); - census_tag_set_create_status expected = {2, 1, 6, 2, 3, 4, 0, 2}; + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + const census_context_status *status; + struct census_context *context2 = + census_context_create(context, modify_tags, MODIFY_TAG_COUNT, &status); + census_context_status expected = {2, 1, 6, 2, 3, 4, 0, 2}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); - // validate tag set contents. Use specific indices into the two arrays + // validate context contents. Use specific indices into the two arrays // holding tag values. - GPR_ASSERT(validate_tag(cts2, &basic_tags[3])); - GPR_ASSERT(validate_tag(cts2, &basic_tags[4])); - GPR_ASSERT(validate_tag(cts2, &modify_tags[0])); - GPR_ASSERT(validate_tag(cts2, &modify_tags[1])); - GPR_ASSERT(validate_tag(cts2, &modify_tags[6])); - GPR_ASSERT(validate_tag(cts2, &modify_tags[7])); - GPR_ASSERT(validate_tag(cts2, &modify_tags[8])); - GPR_ASSERT(validate_tag(cts2, &modify_tags[9])); - GPR_ASSERT(validate_tag(cts2, &modify_tags[10])); - GPR_ASSERT(!validate_tag(cts2, &basic_tags[0])); - GPR_ASSERT(!validate_tag(cts2, &basic_tags[1])); - GPR_ASSERT(!validate_tag(cts2, &basic_tags[2])); - GPR_ASSERT(!validate_tag(cts2, &basic_tags[5])); - GPR_ASSERT(!validate_tag(cts2, &basic_tags[6])); - GPR_ASSERT(!validate_tag(cts2, &basic_tags[7])); - census_tag_set_destroy(cts); - census_tag_set_destroy(cts2); + GPR_ASSERT(validate_tag(context2, &basic_tags[3])); + GPR_ASSERT(validate_tag(context2, &basic_tags[4])); + GPR_ASSERT(validate_tag(context2, &modify_tags[0])); + GPR_ASSERT(validate_tag(context2, &modify_tags[1])); + GPR_ASSERT(validate_tag(context2, &modify_tags[6])); + GPR_ASSERT(validate_tag(context2, &modify_tags[7])); + GPR_ASSERT(validate_tag(context2, &modify_tags[8])); + GPR_ASSERT(validate_tag(context2, &modify_tags[9])); + GPR_ASSERT(validate_tag(context2, &modify_tags[10])); + GPR_ASSERT(!validate_tag(context2, &basic_tags[0])); + GPR_ASSERT(!validate_tag(context2, &basic_tags[1])); + GPR_ASSERT(!validate_tag(context2, &basic_tags[2])); + GPR_ASSERT(!validate_tag(context2, &basic_tags[5])); + GPR_ASSERT(!validate_tag(context2, &basic_tags[6])); + GPR_ASSERT(!validate_tag(context2, &basic_tags[7])); + census_context_destroy(context); + census_context_destroy(context2); } #define BUF_SIZE 200 @@ -324,38 +323,37 @@ static void replace_add_delete_test(void) { // test encode/decode. static void encode_decode_test(void) { char buffer[BUF_SIZE]; - struct census_tag_set *cts = - census_tag_set_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); + struct census_context *context = + census_context_create(NULL, basic_tags, BASIC_TAG_COUNT, NULL); size_t print_bsize; size_t bin_bsize; // Test with too small a buffer - GPR_ASSERT(census_tag_set_encode(cts, buffer, 2, &print_bsize, &bin_bsize) == - NULL); - char *b_buffer = - census_tag_set_encode(cts, buffer, BUF_SIZE, &print_bsize, &bin_bsize); + GPR_ASSERT(census_context_encode(context, buffer, 2, &print_bsize, + &bin_bsize) == NULL); + char *b_buffer = census_context_encode(context, buffer, BUF_SIZE, + &print_bsize, &bin_bsize); GPR_ASSERT(b_buffer != NULL && print_bsize > 0 && bin_bsize > 0 && print_bsize + bin_bsize <= BUF_SIZE && b_buffer == buffer + print_bsize); - census_tag_set *cts2 = - census_tag_set_decode(buffer, print_bsize, b_buffer, bin_bsize); - GPR_ASSERT(cts2 != NULL); - const census_tag_set_create_status *status = - census_tag_set_get_create_status(cts2); - census_tag_set_create_status expected = {2, 2, 0, 0, 0, 0, 0, 0}; + census_context *context2 = + census_context_decode(buffer, print_bsize, b_buffer, bin_bsize); + GPR_ASSERT(context2 != NULL); + const census_context_status *status = census_context_get_status(context2); + census_context_status expected = {2, 2, 0, 0, 0, 0, 0, 0}; GPR_ASSERT(memcmp(status, &expected, sizeof(expected)) == 0); for (int i = 0; i < BASIC_TAG_COUNT; i++) { census_tag tag; if (CENSUS_TAG_IS_PROPAGATED(basic_tags[i].flags)) { - GPR_ASSERT(census_tag_set_get_tag_by_key(cts2, basic_tags[i].key, &tag) == + GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) == 1); GPR_ASSERT(compare_tag(&tag, &basic_tags[i])); } else { - GPR_ASSERT(census_tag_set_get_tag_by_key(cts2, basic_tags[i].key, &tag) == + GPR_ASSERT(census_context_get_tag(context2, basic_tags[i].key, &tag) == 0); } } - census_tag_set_destroy(cts2); - census_tag_set_destroy(cts); + census_context_destroy(context2); + census_context_destroy(context); } int main(int argc, char *argv[]) { diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index f24dbe72cf..d4fa7ab518 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -152,15 +152,11 @@ def main(): sec_deps = [ 'end2end_certs', 'grpc_test_util', - 'grpc', - 'gpr_test_util', - 'gpr' + 'grpc' ] unsec_deps = [ 'grpc_test_util_unsecure', - 'grpc_unsecure', - 'gpr_test_util', - 'gpr' + 'grpc_unsecure' ] json = { '#': 'generated with test/end2end/gen_build_json.py', diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index aac20fd96a..77cc57d4d6 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -237,8 +237,8 @@ static void reader_thread(void *arg) { gpr_timespec interval; int counter = 0; printf(" Reader starting\n"); - interval = gpr_time_from_micros(args->read_iteration_interval_in_msec * 1000, - GPR_TIMESPAN); + interval = gpr_time_from_micros( + (int64_t)args->read_iteration_interval_in_msec * 1000, GPR_TIMESPAN); gpr_mu_lock(args->mu); while (!args->stop_flag && records_read < args->total_records) { gpr_cv_wait(&args->stop, args->mu, interval); diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c index 0149bc3afd..d311eb136a 100644 --- a/test/core/support/sync_test.c +++ b/test/core/support/sync_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -251,7 +251,7 @@ static void test(const char *name, void (*body)(void *m), gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; gpr_timespec deadline = gpr_time_add( - start, gpr_time_from_micros(timeout_s * 1000000, GPR_TIMESPAN)); + start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN)); fprintf(stderr, "%s:", name); while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) { iterations <<= 1; diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c index fc26f94d29..6cc3786df1 100644 --- a/test/core/support/time_test.c +++ b/test/core/support/time_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -125,15 +125,15 @@ static void test_values(void) { } /* Test possible overflow in conversion of -ve values. */ - x = gpr_time_from_micros(-(LONG_MAX - 999997), GPR_TIMESPAN); + x = gpr_time_from_micros(-(INT64_MAX - 999997), GPR_TIMESPAN); GPR_ASSERT(x.tv_sec < 0); GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC); - x = gpr_time_from_nanos(-(LONG_MAX - 999999997), GPR_TIMESPAN); + x = gpr_time_from_nanos(-(INT64_MAX - 999999997), GPR_TIMESPAN); GPR_ASSERT(x.tv_sec < 0); GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC); - x = gpr_time_from_millis(-(LONG_MAX - 997), GPR_TIMESPAN); + x = gpr_time_from_millis(-(INT64_MAX - 997), GPR_TIMESPAN); GPR_ASSERT(x.tv_sec < 0); GPR_ASSERT(x.tv_nsec >= 0 && x.tv_nsec < GPR_NS_PER_SEC); diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c index ec7df6f0e3..84b345bb50 100644 --- a/test/core/surface/server_chttp2_test.c +++ b/test/core/surface/server_chttp2_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,14 @@ */ #include <grpc/grpc.h> +#include <grpc/grpc_security.h> +#include <grpc/support/alloc.h> +#include <grpc/support/host_port.h> #include <grpc/support/log.h> +#include <grpc/support/time.h> +#include "src/core/security/credentials.h" +#include "src/core/tsi/fake_transport_security.h" +#include "test/core/util/port.h" #include "test/core/util/test_config.h" void test_unparsable_target(void) { @@ -40,10 +47,31 @@ void test_unparsable_target(void) { GPR_ASSERT(port == 0); } +void test_add_same_port_twice() { + int port = grpc_pick_unused_port_or_die(); + char *addr = NULL; + grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_server *server = grpc_server_create(NULL, NULL); + grpc_server_credentials *fake_creds = + grpc_fake_transport_security_server_credentials_create(); + gpr_join_host_port(&addr, "localhost", port); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds)); + GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, fake_creds) == 0); + + grpc_server_credentials_release(fake_creds); + gpr_free(addr); + grpc_server_shutdown_and_notify(server, cq, NULL); + grpc_completion_queue_pluck(cq, NULL, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); + grpc_server_destroy(server); + grpc_completion_queue_destroy(cq); +} + int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); test_unparsable_target(); + test_add_same_port_twice(); grpc_shutdown(); return 0; } diff --git a/test/core/transport/chttp2/timeout_encoding_test.c b/test/core/transport/chttp2/timeout_encoding_test.c index f0e8ec386f..483e79fb25 100644 --- a/test/core/transport/chttp2/timeout_encoding_test.c +++ b/test/core/transport/chttp2/timeout_encoding_test.c @@ -93,7 +93,7 @@ static void assert_decodes_as(const char *buffer, gpr_timespec expected) { } void decode_suite(char ext, - gpr_timespec (*answer)(long x, gpr_clock_type clock)) { + gpr_timespec (*answer)(int64_t x, gpr_clock_type clock)) { long test_vals[] = {1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9}; diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 15b71747fb..f6bb2e1f72 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,16 +54,16 @@ extern double g_fixture_slowdown_factor; (GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR * \ g_fixture_slowdown_factor) -#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ - gpr_time_add( \ - gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_millis((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ +#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ + gpr_time_add( \ + gpr_now(GPR_CLOCK_MONOTONIC), \ + gpr_time_from_millis((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ GPR_TIMESPAN)) -#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ - gpr_time_add( \ - gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_micros((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ +#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ + gpr_time_add( \ + gpr_now(GPR_CLOCK_MONOTONIC), \ + gpr_time_from_micros((int64_t)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ GPR_TIMESPAN)) #ifndef GRPC_TEST_CUSTOM_PICK_PORT |