diff options
author | Puran Chand <pchand@vmware.com> | 2017-11-29 13:41:05 +0530 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-12-10 04:56:23 +0100 |
commit | 2ab9847f54da80352e6ce1f4281649a86558a822 (patch) | |
tree | 5fcb526e0a55c3be44f52c1cf5ef1fd6ed534bd6 /source4/torture/libsmbclient | |
parent | d2b9f18a0d16e1f03a19229bed6e8ffa02744e63 (diff) | |
download | samba-2ab9847f54da80352e6ce1f4281649a86558a822.tar.gz |
Added smbc_SetLogCallback which lets third party code to capture libsmbclient logs
Signed-off-by: Puran Chand <pchand@vmware.com>
Reviewed-by: Garming Sam <garming@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sun Dec 10 04:56:23 CET 2017 on sn-devel-144
Diffstat (limited to 'source4/torture/libsmbclient')
-rw-r--r-- | source4/torture/libsmbclient/libsmbclient.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c index a56a5de55d7..13de2b5653e 100644 --- a/source4/torture/libsmbclient/libsmbclient.c +++ b/source4/torture/libsmbclient/libsmbclient.c @@ -24,6 +24,19 @@ #include <libsmbclient.h> #include "torture/libsmbclient/proto.h" +/* test string to compare with when debug_callback is called */ +#define TEST_STRING "smbc_setLogCallback test" + +/* Dummy log callback function */ +static void debug_callback(void *private_ptr, int level, const char *msg) +{ + bool *found = private_ptr; + if (strstr(msg, TEST_STRING) != NULL) { + *found = true; + } + return; +} + bool torture_libsmbclient_init_context(struct torture_context *tctx, SMBCCTX **ctx_p) { @@ -56,6 +69,7 @@ static bool torture_libsmbclient_version(struct torture_context *tctx) static bool torture_libsmbclient_initialize(struct torture_context *tctx) { SMBCCTX *ctx; + bool ret = false; torture_comment(tctx, "Testing smbc_new_context\n"); @@ -66,6 +80,14 @@ static bool torture_libsmbclient_initialize(struct torture_context *tctx) torture_assert(tctx, smbc_init_context(ctx), "failed to init context"); + smbc_setLogCallback(ctx, &ret, debug_callback); + DEBUG(0, (TEST_STRING"\n")); + torture_assert(tctx, ret, "Failed debug_callback not called"); + ret = false; + smbc_setLogCallback(ctx, NULL, NULL); + DEBUG(0, (TEST_STRING"\n")); + torture_assert(tctx, !ret, "Failed debug_callback called"); + smbc_free_context(ctx, 1); return true; |