[prev in list] [next in list] [prev in thread] [next in thread] 

List:       samba-technical
Subject:    Re: smbtorture - RAW-ECHO test patch
From:       Martin Pala <Martin.Pala () Sun ! COM>
Date:       2007-09-27 12:52:44
Message-ID: 46FBA79C.3030901 () sun ! com
[Download RAW message or body]

Volker Lendecke wrote:
> On Tue, Sep 25, 2007 at 10:34:15AM +0200, Martin Pala wrote:
>
>   
>> here is patch which implements the RAW-ECHO test.
>>     
>
> ...
>
>   
>> +   Unix SMB/CIFS implementation.
>> +   RAW_ECHO individual test suite
>> +   Copyright (C) Andrew Tridgell 2003
>>     
>
> Can you change this to your own personal (!) copyright
> please?
>
> Volker
>   

OK, modified patch attached.

Thanks,

Martin




["smbtorture-echo.patch" (text/x-patch)]

diff -Naur samba-4.0.0tp5/source/torture/raw/echo.c samba-4.0.0tp5-mp/source/torture/raw/echo.c
--- samba-4.0.0tp5/source/torture/raw/echo.c	1970-01-01 01:00:00.000000000 +0100
+++ samba-4.0.0tp5-mp/source/torture/raw/echo.c	2007-09-24 16:43:15.527041000 +0200
@@ -0,0 +1,119 @@
+/* 
+   Unix SMB/CIFS implementation.
+   RAW_ECHO individual test suite
+   Copyright (C) Martin Pala 2007
+   
+   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 "torture/torture.h"
+#include "system/time.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
+#include "lib/cmdline/popt_common.h"
+
+
+/* basic testing of RAW_ECHO call
+*/
+BOOL torture_raw_echo(struct torture_context *torture)
+{
+        struct smb_echo p;
+	struct smbcli_state *cli;
+	const char *host = torture_setting_string(torture, "host", NULL);
+	BOOL ret = False;
+	TALLOC_CTX *mem_ctx;
+	NTSTATUS status;
+
+	mem_ctx = talloc_init("torture_raw_echo");
+
+	/* Prepare echo parameters */
+        p.in.repeat_count = 1;
+        p.in.size = 0;
+        p.in.data = NULL;
+
+
+	/* Establish connection */
+        cli = smbcli_state_init(mem_ctx);
+        if (!cli) {
+                torture_comment(torture, "Failed initialize smbcli_struct to connect with %s\n", host);
+                goto done;
+        }
+        if (!smbcli_socket_connect(cli, host)) {
+                torture_comment(torture, "Failed to connect with %s\n", host);
+                goto done;
+        }
+
+
+	/* Try echo right after negotiate protocol request */
+	printf("testing echo -- no session established\n");
+
+        status = smbcli_negprot(cli);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+		printf("(%d) Failed to negotiate protocol - status %s, should be %s\n",
+		       __LINE__, nt_errstr(status), nt_errstr(NT_STATUS_OK));
+		goto done;
+	}
+        status = smb_raw_echo(cli->transport, &p);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+		printf("(%d) Incorrect status %s - should be %s\n",
+		       __LINE__, nt_errstr(status), nt_errstr(NT_STATUS_OK));
+		goto done;
+	}
+
+
+	/* Try echo right after session setup request */
+	printf("testing echo -- session ready\n");
+
+	status = smbcli_session_setup(cli, cmdline_credentials);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+		printf("(%d) Failed to establish session - status %s, should be %s\n",
+		       __LINE__, nt_errstr(status), nt_errstr(NT_STATUS_OK));
+		goto done;
+	}
+
+        status = smb_raw_echo(cli->transport, &p);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+		printf("(%d) Incorrect status %s - should be %s\n",
+		       __LINE__, nt_errstr(status), nt_errstr(NT_STATUS_OK));
+		goto done;
+	}
+
+
+	/* Try echo right after logoff request */
+	printf("testing echo -- session logged off\n");
+
+	status = smb_raw_ulogoff(cli->session);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+		printf("(%d) Failed to logoff - status %s, should be %s\n",
+		       __LINE__, nt_errstr(status), nt_errstr(NT_STATUS_OK));
+		goto done;
+	}
+
+        status = smb_raw_echo(cli->transport, &p);
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+		printf("(%d) Incorrect status %s - should be %s\n",
+		       __LINE__, nt_errstr(status), nt_errstr(NT_STATUS_OK));
+		goto done;
+	}
+
+
+	ret = True;
+done:
+	talloc_free(mem_ctx);
+	return ret;
+}
+
diff -Naur samba-4.0.0tp5/source/torture/raw/missing.txt samba-4.0.0tp5-mp/source/torture/raw/missing.txt
--- samba-4.0.0tp5/source/torture/raw/missing.txt	2004-04-04 13:51:10.000000000 +0200
+++ samba-4.0.0tp5-mp/source/torture/raw/missing.txt	2007-09-24 16:51:47.176612000 +0200
@@ -18,8 +18,6 @@
 
 - SMBtcon
 
-- SMBecho
-
 - SMBfunique
 
 - SMBsearch vs SMBffirst?
diff -Naur samba-4.0.0tp5/source/torture/raw/raw.c samba-4.0.0tp5-mp/source/torture/raw/raw.c
--- samba-4.0.0tp5/source/torture/raw/raw.c	2007-05-25 15:03:33.000000000 +0200
+++ samba-4.0.0tp5-mp/source/torture/raw/raw.c	2007-09-24 12:55:46.506927000 +0200
@@ -62,6 +62,7 @@
 	torture_suite_add_simple_test(suite, "SAMBA3CHECKFSP", torture_samba3_checkfsp);
 	torture_suite_add_simple_test(suite, "SAMBA3BADPATH", torture_samba3_badpath);
 	torture_suite_add_simple_test(suite, "SCAN-EAMAX", torture_max_eas);
+	torture_suite_add_simple_test(suite, "ECHO", torture_raw_echo);
 
 	suite->description = talloc_strdup(suite, 
 							"Tests for the raw SMB interface");
--- samba-4.0.0tp5/source/torture/config.mk	2007-04-20 13:28:25.000000000 +0200
+++ samba-4.0.0tp5-mp/source/torture/config.mk	2007-09-24 12:52:37.962948000 +0200
@@ -87,6 +87,7 @@
 		raw/samba3hide.o \
 		raw/samba3misc.o \
 		raw/composite.o \
+		raw/echo.o \
 		raw/raw.o
 PRIVATE_DEPENDENCIES = \
 		LIBCLI_SMB LIBCLI_LSA LIBCLI_SMB_COMPOSITE \


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic