Author: mimir
Date: 2005-08-02 18:15:23 +0000 (Tue, 02 Aug 2005)
New Revision: 8930

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8930

Log:
Add the libnet share tests based on code submitted by
Gregory Leocadie <[EMAIL PROTECTED]>. Listing shares passes,
deleting not yet - it's a work in progress.


rafal


Added:
   branches/SAMBA_4_0/source/torture/libnet/libnet_share.c
Modified:
   branches/SAMBA_4_0/source/torture/config.mk
   branches/SAMBA_4_0/source/torture/torture.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/config.mk
===================================================================
--- branches/SAMBA_4_0/source/torture/config.mk 2005-08-02 18:14:01 UTC (rev 
8929)
+++ branches/SAMBA_4_0/source/torture/config.mk 2005-08-02 18:15:23 UTC (rev 
8930)
@@ -199,6 +199,7 @@
                torture/libnet/domain.o \
                torture/libnet/libnet_lookup.o \
                torture/libnet/libnet_user.o \
+               torture/libnet/libnet_share.o \
                torture/libnet/libnet_rpc.o
 REQUIRED_SUBSYSTEMS = \
                NDR_ALL RPC_NDR_SAMR LIBNET

Added: branches/SAMBA_4_0/source/torture/libnet/libnet_share.c
===================================================================
--- branches/SAMBA_4_0/source/torture/libnet/libnet_share.c     2005-08-02 
18:14:01 UTC (rev 8929)
+++ branches/SAMBA_4_0/source/torture/libnet/libnet_share.c     2005-08-02 
18:15:23 UTC (rev 8930)
@@ -0,0 +1,92 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Test suite for libnet calls.
+
+   Copyright (C) Gregory LEOCADIE <[EMAIL PROTECTED]> 2005
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "libnet/libnet.h"
+#include "lib/cmdline/popt_common.h"
+
+
+#define TEST_SHARENAME "libnetsharetest"
+
+
+BOOL torture_listshares(void)
+{
+       struct libnet_ListShares share;
+       NTSTATUS  status;
+       uint32_t levels[] = { 0, 1, 2, 501, 502 };
+       int i;
+       BOOL ret = True;
+       struct libnet_context* libnetctx;
+       const char* host;
+       TALLOC_CTX *mem_ctx;
+
+       mem_ctx = talloc_init("test_listshares");
+       host = lp_parm_string(-1, "torture", "host");
+
+       libnetctx = libnet_context_init(NULL);
+       libnetctx->cred = cmdline_credentials;
+       
+       printf("Testing libnet_ListShare\n");
+       
+       share.in.server_name = talloc_asprintf(mem_ctx, "%s", host);
+
+       for (i = 0; i < ARRAY_SIZE(levels); i++) {
+               share.in.level = levels[i];
+               printf("testing libnet_ListShare level %u\n", share.in.level);
+
+               status = libnet_ListShares(libnetctx, mem_ctx, &share);
+               if (!NT_STATUS_IS_OK(status)) {
+                       printf("libnet_ListShare level %u failed - %s\n", 
share.in.level, nt_errstr(status));
+                       ret = False;
+               }
+       }
+
+       return ret;
+}
+
+
+BOOL torture_delshare(void)
+{
+       struct libnet_context* libnetctx;
+       const char* host;
+       TALLOC_CTX *mem_ctx;
+       NTSTATUS  status;
+       BOOL ret = True;
+       struct libnet_DelShare share;
+       
+       mem_ctx = talloc_init("test_listshares");
+       host = lp_parm_string(-1, "torture", "host");
+
+       libnetctx = libnet_context_init(NULL);
+       libnetctx->cred = cmdline_credentials;
+
+       share.in.server_name    = host;
+       share.in.share_name     = TEST_SHARENAME;
+
+       status = libnet_DelShare(libnetctx, mem_ctx, &share);
+       if (!NT_STATUS_IS_OK(status)) {
+               ret = False;
+       }
+
+       talloc_free(mem_ctx);
+
+       return ret;
+}

Modified: branches/SAMBA_4_0/source/torture/torture.c
===================================================================
--- branches/SAMBA_4_0/source/torture/torture.c 2005-08-02 18:14:01 UTC (rev 
8929)
+++ branches/SAMBA_4_0/source/torture/torture.c 2005-08-02 18:15:23 UTC (rev 
8930)
@@ -2345,6 +2345,7 @@
        {"NET-API-LOOKUPPDC", torture_lookup_pdc, 0},
        {"NET-API-CREATEUSER", torture_createuser, 0},
        {"NET-API-RPCCONNECT", torture_rpc_connect, 0},
+       {"NET-API-LISTSHARES", torture_listshares, 0},
 
        {NULL, NULL, 0}};
 

Reply via email to