
This is an automated email from the git hooks/post-receive script. dgoulet pushed a change to branch main in repository tor. from 34da50718a fix minor typos in conflux and pow areas new bbb3396d79 Add test for \r in directory parsing new c5889d3f15 Test \r more effectively using 2 lines new 738785ead8 Test both \r and \r\n with the expected failure conditions added new 6bf56ac301 Merge branch 'tor-gitlab/mr/703' The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: src/test/test_parsecommon.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) -- To stop receiving notification emails like this one, please contact the administrator of this repository.

This is an automated email from the git hooks/post-receive script. dgoulet pushed a commit to branch main in repository tor. commit bbb3396d7925e5d08617f31340514f4d7f2684b8 Author: Saksham Mittal <gotlouemail@gmail.com> AuthorDate: Sun Mar 19 08:27:42 2023 +0530 Add test for \r in directory parsing --- src/test/test_parsecommon.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/test_parsecommon.c b/src/test/test_parsecommon.c index b32840264e..a171cfa7cf 100644 --- a/src/test/test_parsecommon.c +++ b/src/test/test_parsecommon.c @@ -253,6 +253,32 @@ test_parsecommon_get_next_token_success(void *arg) return; } +static void +test_parsecommon_get_next_token_carriage_return(void *arg) +{ + memarea_t *area = memarea_new(); + const char *str = "uptime 1024\r"; + const char *end = str + strlen(str); + const char **s = &str; + token_rule_t table = T01("uptime", K_UPTIME, GE(1), NO_OBJ); + (void)arg; + + directory_token_t *token = get_next_token(area, s, end, &table); + + tt_int_op(token->tp, OP_EQ, K_UPTIME); + tt_int_op(token->n_args, OP_EQ, 1); + tt_str_op(*(token->args), OP_EQ, "1024"); + tt_assert(!token->object_type); + tt_int_op(token->object_size, OP_EQ, 0); + tt_assert(!token->object_body); + + tt_ptr_op(*s, OP_EQ, end); + + done: + memarea_drop_all(area); + return; +} + static void test_parsecommon_get_next_token_concat_args(void *arg) { @@ -571,6 +597,7 @@ test_parsecommon_get_next_token_err_bad_base64(void *arg) struct testcase_t parsecommon_tests[] = { PARSECOMMON_TEST(tokenize_string_null), + PARSECOMMON_TEST(get_next_token_carriage_return), PARSECOMMON_TEST(tokenize_string_multiple_lines), PARSECOMMON_TEST(tokenize_string_min_cnt), PARSECOMMON_TEST(tokenize_string_max_cnt), -- To stop receiving notification emails like this one, please contact the administrator of this repository.

This is an automated email from the git hooks/post-receive script. dgoulet pushed a commit to branch main in repository tor. commit c5889d3f1584e60633f4dfec6e63f6dc471915e2 Author: Saksham Mittal <gotlouemail@gmail.com> AuthorDate: Mon Mar 27 20:22:24 2023 +0530 Test \r more effectively using 2 lines --- src/test/test_parsecommon.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/test/test_parsecommon.c b/src/test/test_parsecommon.c index a171cfa7cf..06dbea3a75 100644 --- a/src/test/test_parsecommon.c +++ b/src/test/test_parsecommon.c @@ -257,28 +257,41 @@ static void test_parsecommon_get_next_token_carriage_return(void *arg) { memarea_t *area = memarea_new(); - const char *str = "uptime 1024\r"; - const char *end = str + strlen(str); - const char **s = &str; - token_rule_t table = T01("uptime", K_UPTIME, GE(1), NO_OBJ); + smartlist_t *tokens = smartlist_new(); + (void)arg; - directory_token_t *token = get_next_token(area, s, end, &table); + token_rule_t table[] = { + T01("uptime", K_UPTIME, GE(1), NO_OBJ), + T01("hibernating", K_HIBERNATING, GE(1), NO_OBJ), + END_OF_TABLE, + }; + + char *str = tor_strdup("hibernating 0\r\nuptime 1024\n"); + + int retval = + tokenize_string(area, str, NULL, + tokens, table, 0); + + tt_int_op(smartlist_len(tokens), OP_EQ, 2); + directory_token_t *token = smartlist_get(tokens, 0); + + tt_int_op(token->tp, OP_EQ, K_HIBERNATING); + + token = smartlist_get(tokens, 1); tt_int_op(token->tp, OP_EQ, K_UPTIME); - tt_int_op(token->n_args, OP_EQ, 1); - tt_str_op(*(token->args), OP_EQ, "1024"); - tt_assert(!token->object_type); - tt_int_op(token->object_size, OP_EQ, 0); - tt_assert(!token->object_body); - tt_ptr_op(*s, OP_EQ, end); + tt_int_op(retval, OP_EQ, 0); done: + tor_free(str); memarea_drop_all(area); + smartlist_free(tokens); return; } + static void test_parsecommon_get_next_token_concat_args(void *arg) { -- To stop receiving notification emails like this one, please contact the administrator of this repository.

This is an automated email from the git hooks/post-receive script. dgoulet pushed a commit to branch main in repository tor. commit 738785ead8fae752d40a3afa8b861d52519eabe0 Author: Saksham Mittal <gotlouemail@gmail.com> AuthorDate: Fri Mar 31 11:04:18 2023 +0530 Test both \r and \r\n with the expected failure conditions added --- src/test/test_parsecommon.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/test_parsecommon.c b/src/test/test_parsecommon.c index 06dbea3a75..866f89a4e1 100644 --- a/src/test/test_parsecommon.c +++ b/src/test/test_parsecommon.c @@ -267,13 +267,15 @@ test_parsecommon_get_next_token_carriage_return(void *arg) END_OF_TABLE, }; - char *str = tor_strdup("hibernating 0\r\nuptime 1024\n"); + char *str = tor_strdup( + "hibernating 0\r\nuptime 1024\n" + "hibernating 0\ruptime 1024\n"); int retval = tokenize_string(area, str, NULL, tokens, table, 0); - tt_int_op(smartlist_len(tokens), OP_EQ, 2); + tt_int_op(smartlist_len(tokens), OP_EQ, 3); directory_token_t *token = smartlist_get(tokens, 0); tt_int_op(token->tp, OP_EQ, K_HIBERNATING); @@ -282,7 +284,11 @@ test_parsecommon_get_next_token_carriage_return(void *arg) tt_int_op(token->tp, OP_EQ, K_UPTIME); - tt_int_op(retval, OP_EQ, 0); + token = smartlist_get(tokens, 2); + + tt_int_op(token->tp, OP_EQ, K_HIBERNATING); + + tt_int_op(retval, OP_EQ, -1); done: tor_free(str); @@ -291,7 +297,6 @@ test_parsecommon_get_next_token_carriage_return(void *arg) return; } - static void test_parsecommon_get_next_token_concat_args(void *arg) { -- To stop receiving notification emails like this one, please contact the administrator of this repository.

This is an automated email from the git hooks/post-receive script. dgoulet pushed a commit to branch main in repository tor. commit 6bf56ac301d6321b9b72c11aef73d64e0aa38c23 Merge: 34da50718a 738785ead8 Author: David Goulet <dgoulet@torproject.org> AuthorDate: Wed May 24 10:38:58 2023 -0400 Merge branch 'tor-gitlab/mr/703' src/test/test_parsecommon.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) -- To stop receiving notification emails like this one, please contact the administrator of this repository.
participants (1)
-
gitolite role