diff options
author | Daniel Pinto <danielpinto52@gmail.com> | 2017-05-18 23:44:16 +0100 |
---|---|---|
committer | Daniel Pinto <danielpinto52@gmail.com> | 2017-05-18 23:44:16 +0100 |
commit | ba3a5f82f11388237a3ba4995ddf0b6ffaaf492a (patch) | |
tree | c0cf4342524cd040e24fe9cc420bb70e21c0a9d5 /src/test/test_util.c | |
parent | ec6b2bbf9bb561e34f9fbe6663d1eb691604348d (diff) | |
download | tor-ba3a5f82f11388237a3ba4995ddf0b6ffaaf492a.tar.gz tor-ba3a5f82f11388237a3ba4995ddf0b6ffaaf492a.zip |
Add support for %include funcionality on torrc #1922
config_get_lines is now split into two functions:
- config_get_lines which is the same as before we had %include
- config_get_lines_include which actually processes %include
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index b3f8ecdf51..a861f15ab1 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -5731,6 +5731,85 @@ test_util_htonll(void *arg) ; } +static void +test_util_get_unquoted_path(void *arg) +{ + (void)arg; + + char *r; + + r = get_unquoted_path("\""); // " + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path("\"\"\""); // """ + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path("\\\""); // \" + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path("\\\"\\\""); // \"\" + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path("A\\B\\C\""); // A\B\C" + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path("\"A\\B\\C"); // "A\B\C + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path("\"A\\B\"C\""); // "A\B"C" + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path("A\\B\"C"); // A\B"C + tt_ptr_op(r, OP_EQ, NULL); + tor_free(r); + + r = get_unquoted_path(""); + tt_str_op(r, OP_EQ, ""); + tor_free(r); + + r = get_unquoted_path("\"\""); // "" + tt_str_op(r, OP_EQ, ""); + tor_free(r); + + r = get_unquoted_path("A\\B\\C"); // A\B\C + tt_str_op(r, OP_EQ, "A\\B\\C"); // A\B\C + tor_free(r); + + r = get_unquoted_path("\"A\\B\\C\""); // "A\B\C" + tt_str_op(r, OP_EQ, "A\\B\\C"); // A\B\C + tor_free(r); + + r = get_unquoted_path("\"\\\""); // "\" + tt_str_op(r, OP_EQ, "\\"); // \ /* comment to prevent line continuation */ + tor_free(r); + + r = get_unquoted_path("\"\\\"\""); // "\"" + tt_str_op(r, OP_EQ, "\""); // " + tor_free(r); + + r = get_unquoted_path("\"A\\B\\C\\\"\""); // "A\B\C\"" + tt_str_op(r, OP_EQ, "A\\B\\C\""); // A\B\C" + tor_free(r); + + r = get_unquoted_path("A\\B\\\"C"); // A\B\"C + tt_str_op(r, OP_EQ, "A\\B\"C"); // A\B"C + tor_free(r); + + r = get_unquoted_path("\"A\\B\\\"C\""); // "A\B\"C" + tt_str_op(r, OP_EQ, "A\\B\"C"); // A\B"C + tor_free(r); + + done: + ; +} + #define UTIL_LEGACY(name) \ { #name, test_util_ ## name , 0, NULL, NULL } @@ -5833,6 +5912,7 @@ struct testcase_t util_tests[] = { UTIL_TEST(monotonic_time, 0), UTIL_TEST(monotonic_time_ratchet, TT_FORK), UTIL_TEST(htonll, 0), + UTIL_TEST(get_unquoted_path, 0), END_OF_TESTCASES }; |