diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-03-06 23:03:34 +0000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-06-10 11:36:38 +0200 |
commit | 235915063957dc9ff31a8e6777e0f63b7f3bf07c (patch) | |
tree | 4a3948dd76a481a90789cb740c4f7a77bb1af6bd /source3/lib/socket_wrapper/testsuite.c | |
parent | bd793fb235cd18da8e9d779c767cac81fa3f758e (diff) | |
download | samba-235915063957dc9ff31a8e6777e0f63b7f3bf07c.tar.gz samba-235915063957dc9ff31a8e6777e0f63b7f3bf07c.tar.bz2 samba-235915063957dc9ff31a8e6777e0f63b7f3bf07c.zip |
r21729: Some more tests
(cherry picked from commit d2baa8218cf504d6631d610f9fd393ad8c61574c)
(This used to be commit cf6d815ba82a25c1e1f1dfdb8548cc588d44d1aa)
Diffstat (limited to 'source3/lib/socket_wrapper/testsuite.c')
-rw-r--r-- | source3/lib/socket_wrapper/testsuite.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/source3/lib/socket_wrapper/testsuite.c b/source3/lib/socket_wrapper/testsuite.c index a3e6580409..65ae9a0584 100644 --- a/source3/lib/socket_wrapper/testsuite.c +++ b/source3/lib/socket_wrapper/testsuite.c @@ -26,15 +26,24 @@ #include "torture/torture.h" static char *old_dir = NULL; +static char *old_iface = NULL; static void backup_env(void) { old_dir = getenv("SOCKET_WRAPPER_DIR"); + old_iface = getenv("SOCKET_WRAPPER_DEFAULT_IFACE"); } static void restore_env(void) { - setenv("SOCKET_WRAPPER_DIR", old_dir, 1); + if (old_dir == NULL) + unsetenv("SOCKET_WRAPPER_DIR"); + else + setenv("SOCKET_WRAPPER_DIR", old_dir, 1); + if (old_iface == NULL) + unsetenv("SOCKET_WRAPPER_DEFAULT_IFACE"); + else + setenv("SOCKET_WRAPPER_DEFAULT_IFACE", old_iface, 1); } static bool test_socket_wrapper_dir(struct torture_context *tctx) @@ -70,6 +79,20 @@ static bool test_swrap_socket(struct torture_context *tctx) return true; } +unsigned int socket_wrapper_default_iface(void); +static bool test_socket_wrapper_default_iface(struct torture_context *tctx) +{ + backup_env(); + unsetenv("SOCKET_WRAPPER_DEFAULT_IFACE"); + torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 1, "unset"); + setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "2", 1); + torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 2, "unset"); + setenv("SOCKET_WRAPPER_DEFAULT_IFACE", "bla", 1); + torture_assert_int_equal(tctx, socket_wrapper_default_iface(), 1, "unset"); + restore_env(); + return true; +} + struct torture_suite *torture_local_socket_wrapper(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, @@ -77,6 +100,7 @@ struct torture_suite *torture_local_socket_wrapper(TALLOC_CTX *mem_ctx) torture_suite_add_simple_test(suite, "socket_wrapper_dir", test_socket_wrapper_dir); torture_suite_add_simple_test(suite, "socket", test_swrap_socket); + torture_suite_add_simple_test(suite, "socket_wrapper_default_iface", test_socket_wrapper_default_iface); return suite; } |