torture: Fix winbind.wbclient.ResolveWinsByIp test
[sfrench/samba-autobuild/.git] / nsswitch / libwbclient / tests / wbclient.c
index 5bce0aead8853cc93771f8bd338e5cbee9e94d92..d482ed216a5348dbdb46c3b64184ef250a5b4ccc 100644 (file)
@@ -22,6 +22,7 @@
 #include "libcli/util/werror.h"
 #include "lib/util/data_blob.h"
 #include "lib/util/time.h"
+#include "libcli/resolve/resolve.h"
 #include "nsswitch/libwbclient/wbclient.h"
 #include "torture/smbtorture.h"
 #include "torture/winbind/proto.h"
@@ -418,10 +419,21 @@ static bool test_wbc_resolve_winsbyname(struct torture_context *tctx)
 static bool test_wbc_resolve_winsbyip(struct torture_context *tctx)
 {
        const char *ip;
+       const char *host;
+       struct nbt_name nbt_name;
        char *name;
        wbcErr ret;
+       NTSTATUS status;
 
-       ip = torture_setting_string(tctx, "host", NULL);
+       host = torture_setting_string(tctx, "host", NULL);
+
+       make_nbt_name_server(&nbt_name, host);
+
+       status = resolve_name_ex(lpcfg_resolve_context(tctx->lp_ctx),
+                                0, 0, &nbt_name, tctx, &ip, tctx->ev);
+       torture_assert_ntstatus_ok(tctx, status,
+                       talloc_asprintf(tctx,"Failed to resolve %s: %s",
+                                       nbt_name.name, nt_errstr(status)));
 
        ret = wbcResolveWinsByIP(ip, &name);