diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2017-04-29 09:15:14 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-05-19 08:47:10 -0400 |
commit | f8ef7c65d10ccd9403d9d64ceceba0dd74d6421f (patch) | |
tree | ba8345086b45682c3f0e586cf7f58db22fa9dbb0 /src/test | |
parent | 915fa39d0f927712f7a468c0a2f4497aef0a3b0f (diff) | |
download | tor-f8ef7c65d10ccd9403d9d64ceceba0dd74d6421f.tar.gz tor-f8ef7c65d10ccd9403d9d64ceceba0dd74d6421f.zip |
Add some Rust utility functions and print support
This gives an indication in the log that Tor was built with Rust
support, as well as laying some groundwork for further string-returning
APIs to be converted to Rust
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/include.am | 1 | ||||
-rw-r--r-- | src/test/test.c | 1 | ||||
-rw-r--r-- | src/test/test.h | 1 | ||||
-rw-r--r-- | src/test/test_rust.c | 31 |
4 files changed, 34 insertions, 0 deletions
diff --git a/src/test/include.am b/src/test/include.am index 8a465877d3..438eaddba8 100644 --- a/src/test/include.am +++ b/src/test/include.am @@ -130,6 +130,7 @@ src_test_test_SOURCES = \ src/test/test_routerkeys.c \ src/test/test_routerlist.c \ src/test/test_routerset.c \ + src/test/test_rust.c \ src/test/test_scheduler.c \ src/test/test_shared_random.c \ src/test/test_socks.c \ diff --git a/src/test/test.c b/src/test/test.c index 4d2cf1536b..18805cb3b7 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -1233,6 +1233,7 @@ struct testgroup_t testgroups[] = { { "routerkeys/", routerkeys_tests }, { "routerlist/", routerlist_tests }, { "routerset/" , routerset_tests }, + { "rust/", rust_tests }, { "scheduler/", scheduler_tests }, { "socks/", socks_tests }, { "shared-random/", sr_tests }, diff --git a/src/test/test.h b/src/test/test.h index 3d7d05e771..3dc1c332c7 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -231,6 +231,7 @@ extern struct testcase_t router_tests[]; extern struct testcase_t routerkeys_tests[]; extern struct testcase_t routerlist_tests[]; extern struct testcase_t routerset_tests[]; +extern struct testcase_t rust_tests[]; extern struct testcase_t scheduler_tests[]; extern struct testcase_t storagedir_tests[]; extern struct testcase_t socks_tests[]; diff --git a/src/test/test_rust.c b/src/test/test_rust.c new file mode 100644 index 0000000000..6ad57d6fcb --- /dev/null +++ b/src/test/test_rust.c @@ -0,0 +1,31 @@ +/* Copyright (c) 2017, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +#include "orconfig.h" +#include "compat_rust.h" +#include "test.h" +#include "util.h" + +static void +test_welcome_string(void *arg) +{ + (void)arg; + rust_str_t s = rust_welcome_string(); + const char *c_str = rust_str_get(s); + tt_assert(c_str); + size_t len = strlen(c_str); +#ifdef HAVE_RUST + tt_assert(len > 0); +#else + tt_assert(len == 0); +#endif + + done: + rust_str_free(s); +} + +struct testcase_t rust_tests[] = { + { "welcome_string", test_welcome_string, 0, NULL, NULL }, + END_OF_TESTCASES +}; + |