2006-06-17 02:20:39 +00:00
/*
Unix SMB / CIFS implementation .
SMB torture tester
Copyright ( C ) Jelmer Vernooij 2006
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
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2006-06-17 02:20:39 +00:00
( 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
2007-07-10 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-06-17 02:20:39 +00:00
*/
# include "includes.h"
# include "libcli/smb2/smb2.h"
2006-06-20 07:02:19 +00:00
2008-04-27 14:02:46 +01:00
# include "torture/smbtorture.h"
2006-06-17 02:20:39 +00:00
# include "torture/smb2/proto.h"
2008-10-11 21:31:42 +02:00
# include "../lib/util/dlinklist.h"
2007-05-13 12:52:13 +00:00
static bool wrap_simple_1smb2_test ( struct torture_context * torture_ctx ,
struct torture_tcase * tcase ,
struct torture_test * test )
{
bool ( * fn ) ( struct torture_context * , struct smb2_tree * ) ;
bool ret ;
struct smb2_tree * tree1 ;
2011-10-28 00:05:44 +02:00
TALLOC_CTX * mem_ctx = talloc_new ( torture_ctx ) ;
2007-05-13 12:52:13 +00:00
if ( ! torture_smb2_connection ( torture_ctx , & tree1 ) )
return false ;
2011-10-28 00:05:44 +02:00
/*
* This is a trick :
* The test might close the connection . If we steal the tree context
* before that and free the parent instead of tree directly , we avoid
* a double free error .
*/
talloc_steal ( mem_ctx , tree1 ) ;
2007-05-13 12:52:13 +00:00
fn = test - > fn ;
ret = fn ( torture_ctx , tree1 ) ;
2011-10-28 00:05:44 +02:00
talloc_free ( mem_ctx ) ;
2007-05-13 12:52:13 +00:00
return ret ;
}
2008-04-02 04:53:27 +02:00
struct torture_test * torture_suite_add_1smb2_test ( struct torture_suite * suite ,
2008-04-16 15:15:57 +02:00
const char * name ,
bool ( * run ) ( struct torture_context * ,
struct smb2_tree * ) )
2007-05-13 12:52:13 +00:00
{
struct torture_test * test ;
struct torture_tcase * tcase ;
tcase = torture_suite_add_tcase ( suite , name ) ;
test = talloc ( tcase , struct torture_test ) ;
test - > name = talloc_strdup ( test , name ) ;
test - > description = NULL ;
test - > run = wrap_simple_1smb2_test ;
test - > fn = run ;
test - > dangerous = false ;
DLIST_ADD_END ( tcase - > tests , test , struct torture_test * ) ;
2008-04-16 15:16:56 +02:00
return test ;
}
static bool wrap_simple_2smb2_test ( struct torture_context * torture_ctx ,
struct torture_tcase * tcase ,
struct torture_test * test )
{
bool ( * fn ) ( struct torture_context * , struct smb2_tree * , struct smb2_tree * ) ;
2011-10-26 22:48:29 +02:00
bool ret = false ;
2008-04-16 15:16:56 +02:00
struct smb2_tree * tree1 ;
struct smb2_tree * tree2 ;
TALLOC_CTX * mem_ctx = talloc_new ( torture_ctx ) ;
2011-10-26 22:48:29 +02:00
if ( ! torture_smb2_connection ( torture_ctx , & tree1 ) ) {
goto done ;
2008-04-16 15:16:56 +02:00
}
talloc_steal ( mem_ctx , tree1 ) ;
2011-10-26 22:48:29 +02:00
if ( ! torture_smb2_connection ( torture_ctx , & tree2 ) ) {
goto done ;
}
2008-04-16 15:16:56 +02:00
talloc_steal ( mem_ctx , tree2 ) ;
fn = test - > fn ;
ret = fn ( torture_ctx , tree1 , tree2 ) ;
2011-10-26 22:48:29 +02:00
done :
2011-10-27 13:06:32 +02:00
/* the test may already have closed some of the connections */
2008-04-16 15:16:56 +02:00
talloc_free ( mem_ctx ) ;
return ret ;
}
2009-03-27 13:21:25 +01:00
struct torture_test * torture_suite_add_2smb2_test ( struct torture_suite * suite ,
const char * name ,
bool ( * run ) ( struct torture_context * ,
struct smb2_tree * ,
struct smb2_tree * ) )
2008-04-16 15:16:56 +02:00
{
struct torture_test * test ;
struct torture_tcase * tcase ;
tcase = torture_suite_add_tcase ( suite , name ) ;
test = talloc ( tcase , struct torture_test ) ;
test - > name = talloc_strdup ( test , name ) ;
test - > description = NULL ;
test - > run = wrap_simple_2smb2_test ;
test - > fn = run ;
test - > dangerous = false ;
DLIST_ADD_END ( tcase - > tests , test , struct torture_test * ) ;
2007-05-13 12:52:13 +00:00
return test ;
}
2006-06-17 02:20:39 +00:00
NTSTATUS torture_smb2_init ( void )
{
2010-12-11 03:26:31 +01:00
struct torture_suite * suite = torture_suite_create ( talloc_autofree_context ( ) , " smb2 " ) ;
torture_suite_add_simple_test ( suite , " connect " , torture_smb2_connect ) ;
torture_suite_add_simple_test ( suite , " scan " , torture_smb2_scan ) ;
torture_suite_add_simple_test ( suite , " scangetinfo " , torture_smb2_getinfo_scan ) ;
torture_suite_add_simple_test ( suite , " scansetinfo " , torture_smb2_setinfo_scan ) ;
torture_suite_add_simple_test ( suite , " scanfind " , torture_smb2_find_scan ) ;
torture_suite_add_simple_test ( suite , " getinfo " , torture_smb2_getinfo ) ;
torture_suite_add_simple_test ( suite , " setinfo " , torture_smb2_setinfo ) ;
2007-05-13 12:52:13 +00:00
torture_suite_add_suite ( suite , torture_smb2_lock_init ( ) ) ;
2008-05-27 18:20:04 +10:00
torture_suite_add_suite ( suite , torture_smb2_read_init ( ) ) ;
2008-05-28 18:48:23 +10:00
torture_suite_add_suite ( suite , torture_smb2_create_init ( ) ) ;
2009-07-04 16:16:23 -07:00
torture_suite_add_suite ( suite , torture_smb2_acls_init ( ) ) ;
2009-11-17 15:30:11 -08:00
torture_suite_add_suite ( suite , torture_smb2_notify_init ( ) ) ;
2009-03-26 09:32:50 -07:00
torture_suite_add_suite ( suite , torture_smb2_durable_open_init ( ) ) ;
2012-02-27 22:56:37 +01:00
torture_suite_add_suite ( suite , torture_smb2_durable_v2_open_init ( ) ) ;
2009-07-07 07:11:56 -07:00
torture_suite_add_suite ( suite , torture_smb2_dir_init ( ) ) ;
2009-03-27 19:14:01 -07:00
torture_suite_add_suite ( suite , torture_smb2_lease_init ( ) ) ;
2009-06-08 16:26:57 +02:00
torture_suite_add_suite ( suite , torture_smb2_compound_init ( ) ) ;
2009-07-30 15:10:50 -07:00
torture_suite_add_suite ( suite , torture_smb2_oplocks_init ( ) ) ;
2009-10-06 20:25:15 -07:00
torture_suite_add_suite ( suite , torture_smb2_streams_init ( ) ) ;
2011-09-22 22:23:08 +02:00
torture_suite_add_suite ( suite , torture_smb2_ioctl_init ( ) ) ;
2012-02-07 18:02:56 +01:00
torture_suite_add_suite ( suite , torture_smb2_rename_init ( ) ) ;
2010-12-11 03:26:31 +01:00
torture_suite_add_1smb2_test ( suite , " bench-oplock " , test_smb2_bench_oplock ) ;
torture_suite_add_1smb2_test ( suite , " hold-oplock " , test_smb2_hold_oplock ) ;
2012-02-26 17:53:13 +01:00
torture_suite_add_suite ( suite , torture_smb2_session_init ( ) ) ;
2006-10-16 13:06:41 +00:00
2007-05-13 12:52:13 +00:00
suite - > description = talloc_strdup ( suite , " SMB2-specific tests " ) ;
2006-10-16 13:06:41 +00:00
torture_register_suite ( suite ) ;
2006-06-17 02:20:39 +00:00
return NT_STATUS_OK ;
}