2014-08-07 12:52:50 +05:30
/*
2006-06-17 02:20:39 +00:00
Unix SMB / CIFS implementation .
SMB torture tester
Copyright ( C ) Jelmer Vernooij 2006
2014-08-07 12:52:50 +05:30
2006-06-17 02:20:39 +00:00
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 .
2014-08-07 12:52:50 +05:30
2006-06-17 02:20:39 +00:00
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 .
2014-08-07 12:52:50 +05:30
2006-06-17 02:20:39 +00:00
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
2012-05-10 14:51:13 +02:00
if ( ! torture_smb2_connection ( torture_ctx , & tree1 ) ) {
torture_fail ( torture_ctx ,
" Establishing SMB2 connection failed \n " ) ;
2007-05-13 12:52:13 +00:00
return false ;
2012-05-10 14:51:13 +02:00
}
2007-05-13 12:52:13 +00:00
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
{
2014-08-07 12:52:50 +05:30
struct torture_test * test ;
2007-05-13 12:52:13 +00:00
struct torture_tcase * tcase ;
2014-08-07 12:52:50 +05:30
2007-05-13 12:52:13 +00:00
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 ;
2016-02-05 11:32:18 +01:00
DLIST_ADD_END ( tcase - > tests , 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 ) ) {
2012-05-10 14:51:13 +02:00
torture_fail ( torture_ctx ,
" Establishing SMB2 connection failed \n " ) ;
2011-10-26 22:48:29 +02:00
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 ) ) {
2012-05-10 14:51:13 +02:00
torture_fail ( torture_ctx ,
" Establishing SMB2 connection failed \n " ) ;
2011-10-26 22:48:29 +02:00
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 ;
2016-02-05 11:32:18 +01:00
DLIST_ADD_END ( tcase - > tests , test ) ;
2007-05-13 12:52:13 +00:00
return test ;
}
2006-06-17 02:20:39 +00:00
2017-04-20 12:24:43 -07:00
NTSTATUS torture_smb2_init ( TALLOC_CTX * ctx )
2006-06-17 02:20:39 +00:00
{
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 ) ;
2012-03-01 15:59:41 +01:00
torture_suite_add_suite ( suite , torture_smb2_scan_init ( ) ) ;
2013-08-22 11:06:59 +00:00
torture_suite_add_suite ( suite , torture_smb2_getinfo_init ( ) ) ;
2010-12-11 03:26:31 +01:00
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 ( ) ) ;
2015-08-12 11:06:15 +02:00
torture_suite_add_suite ( suite , torture_smb2_notify_disabled_init ( ) ) ;
2009-03-26 09:32:50 -07:00
torture_suite_add_suite ( suite , torture_smb2_durable_open_init ( ) ) ;
2013-02-12 17:45:23 +01:00
torture_suite_add_suite ( suite , torture_smb2_durable_open_disconnect_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 ( ) ) ;
2017-01-11 17:09:54 +01:00
torture_suite_add_suite ( suite , torture_smb2_compound_find_init ( ) ) ;
2009-07-30 15:10:50 -07:00
torture_suite_add_suite ( suite , torture_smb2_oplocks_init ( ) ) ;
2017-03-01 18:13:35 +01:00
torture_suite_add_suite ( suite , torture_smb2_kernel_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 ( ) ) ;
2014-08-07 12:52:50 +05:30
torture_suite_add_suite ( suite , torture_smb2_replay_init ( ) ) ;
2016-06-23 19:13:05 +02:00
torture_suite_add_simple_test ( suite , " dosmode " , torture_smb2_dosmode ) ;
2016-07-11 11:32:19 -07:00
torture_suite_add_simple_test ( suite , " maxfid " , torture_smb2_maxfid ) ;
2017-02-27 07:12:09 +01:00
torture_suite_add_suite ( suite , torture_smb2_crediting_init ( ) ) ;
2006-10-16 13:06:41 +00:00
2013-04-04 17:15:30 -07:00
torture_suite_add_suite ( suite , torture_smb2_doc_init ( ) ) ;
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 ;
}