2014-08-07 11:22:50 +04:00
/*
2006-06-17 06:20:39 +04:00
Unix SMB / CIFS implementation .
SMB torture tester
Copyright ( C ) Jelmer Vernooij 2006
2014-08-07 11:22:50 +04:00
2006-06-17 06:20:39 +04: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 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2006-06-17 06:20:39 +04:00
( at your option ) any later version .
2014-08-07 11:22:50 +04:00
2006-06-17 06:20:39 +04: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 11:22:50 +04:00
2006-06-17 06:20:39 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-06-17 06:20:39 +04:00
*/
# include "includes.h"
# include "libcli/smb2/smb2.h"
2006-06-20 11:02:19 +04:00
2008-04-27 17:02:46 +04:00
# include "torture/smbtorture.h"
2006-06-17 06:20:39 +04:00
# include "torture/smb2/proto.h"
2008-10-11 23:31:42 +04:00
# include "../lib/util/dlinklist.h"
2007-05-13 16:52:13 +04: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 02:05:44 +04:00
TALLOC_CTX * mem_ctx = talloc_new ( torture_ctx ) ;
2007-05-13 16:52:13 +04:00
2012-05-10 16:51:13 +04:00
if ( ! torture_smb2_connection ( torture_ctx , & tree1 ) ) {
torture_fail ( torture_ctx ,
" Establishing SMB2 connection failed \n " ) ;
2007-05-13 16:52:13 +04:00
return false ;
2012-05-10 16:51:13 +04:00
}
2007-05-13 16:52:13 +04:00
2011-10-28 02:05:44 +04: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 16:52:13 +04:00
fn = test - > fn ;
ret = fn ( torture_ctx , tree1 ) ;
2011-10-28 02:05:44 +04:00
talloc_free ( mem_ctx ) ;
2007-05-13 16:52:13 +04:00
return ret ;
}
2008-04-02 06:53:27 +04:00
struct torture_test * torture_suite_add_1smb2_test ( struct torture_suite * suite ,
2008-04-16 17:15:57 +04:00
const char * name ,
bool ( * run ) ( struct torture_context * ,
struct smb2_tree * ) )
2007-05-13 16:52:13 +04:00
{
2014-08-07 11:22:50 +04:00
struct torture_test * test ;
2007-05-13 16:52:13 +04:00
struct torture_tcase * tcase ;
2014-08-07 11:22:50 +04:00
2007-05-13 16:52:13 +04: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 13:32:18 +03:00
DLIST_ADD_END ( tcase - > tests , test ) ;
2008-04-16 17:16:56 +04: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-27 00:48:29 +04:00
bool ret = false ;
2008-04-16 17:16:56 +04:00
struct smb2_tree * tree1 ;
struct smb2_tree * tree2 ;
TALLOC_CTX * mem_ctx = talloc_new ( torture_ctx ) ;
2011-10-27 00:48:29 +04:00
if ( ! torture_smb2_connection ( torture_ctx , & tree1 ) ) {
2012-05-10 16:51:13 +04:00
torture_fail ( torture_ctx ,
" Establishing SMB2 connection failed \n " ) ;
2011-10-27 00:48:29 +04:00
goto done ;
2008-04-16 17:16:56 +04:00
}
talloc_steal ( mem_ctx , tree1 ) ;
2011-10-27 00:48:29 +04:00
if ( ! torture_smb2_connection ( torture_ctx , & tree2 ) ) {
2012-05-10 16:51:13 +04:00
torture_fail ( torture_ctx ,
" Establishing SMB2 connection failed \n " ) ;
2011-10-27 00:48:29 +04:00
goto done ;
}
2008-04-16 17:16:56 +04:00
talloc_steal ( mem_ctx , tree2 ) ;
fn = test - > fn ;
ret = fn ( torture_ctx , tree1 , tree2 ) ;
2011-10-27 00:48:29 +04:00
done :
2011-10-27 15:06:32 +04:00
/* the test may already have closed some of the connections */
2008-04-16 17:16:56 +04:00
talloc_free ( mem_ctx ) ;
return ret ;
}
2009-03-27 15:21:25 +03: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 17:16:56 +04: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 13:32:18 +03:00
DLIST_ADD_END ( tcase - > tests , test ) ;
2007-05-13 16:52:13 +04:00
return test ;
}
2006-06-17 06:20:39 +04:00
2017-04-20 22:24:43 +03:00
NTSTATUS torture_smb2_init ( TALLOC_CTX * ctx )
2006-06-17 06:20:39 +04:00
{
2017-04-25 00:41:26 +03:00
struct torture_suite * suite = torture_suite_create ( ctx , " smb2 " ) ;
2010-12-11 05:26:31 +03:00
torture_suite_add_simple_test ( suite , " connect " , torture_smb2_connect ) ;
2017-04-25 01:42:20 +03:00
torture_suite_add_suite ( suite , torture_smb2_scan_init ( suite ) ) ;
2017-04-25 02:04:10 +03:00
torture_suite_add_suite ( suite , torture_smb2_getinfo_init ( suite ) ) ;
2010-12-11 05:26:31 +03:00
torture_suite_add_simple_test ( suite , " setinfo " , torture_smb2_setinfo ) ;
2017-04-25 01:32:26 +03:00
torture_suite_add_suite ( suite , torture_smb2_lock_init ( suite ) ) ;
2017-04-25 01:38:38 +03:00
torture_suite_add_suite ( suite , torture_smb2_read_init ( suite ) ) ;
2018-10-28 21:29:26 +03:00
torture_suite_add_suite ( suite , torture_smb2_aio_delay_init ( suite ) ) ;
2017-04-25 01:17:45 +03:00
torture_suite_add_suite ( suite , torture_smb2_create_init ( suite ) ) ;
2018-11-14 15:45:11 +03:00
torture_suite_add_suite ( suite , torture_smb2_twrp_init ( suite ) ) ;
2017-04-25 01:11:19 +03:00
torture_suite_add_suite ( suite , torture_smb2_acls_init ( suite ) ) ;
2017-04-25 01:33:53 +03:00
torture_suite_add_suite ( suite , torture_smb2_notify_init ( suite ) ) ;
2017-07-13 17:05:49 +03:00
torture_suite_add_suite ( suite , torture_smb2_notify_inotify_init ( suite ) ) ;
2017-04-25 01:35:18 +03:00
torture_suite_add_suite ( suite ,
torture_smb2_notify_disabled_init ( suite ) ) ;
2017-04-25 01:25:38 +03:00
torture_suite_add_suite ( suite , torture_smb2_durable_open_init ( suite ) ) ;
torture_suite_add_suite ( suite ,
torture_smb2_durable_open_disconnect_init ( suite ) ) ;
2017-04-25 01:27:01 +03:00
torture_suite_add_suite ( suite ,
torture_smb2_durable_v2_open_init ( suite ) ) ;
2018-08-30 20:15:19 +03:00
torture_suite_add_suite ( suite ,
torture_smb2_durable_v2_delay_init ( suite ) ) ;
2017-04-25 01:22:37 +03:00
torture_suite_add_suite ( suite , torture_smb2_dir_init ( suite ) ) ;
2017-04-25 01:31:25 +03:00
torture_suite_add_suite ( suite , torture_smb2_lease_init ( suite ) ) ;
2017-04-25 01:13:10 +03:00
torture_suite_add_suite ( suite , torture_smb2_compound_init ( suite ) ) ;
torture_suite_add_suite ( suite , torture_smb2_compound_find_init ( suite ) ) ;
2017-04-25 01:37:12 +03:00
torture_suite_add_suite ( suite , torture_smb2_oplocks_init ( suite ) ) ;
torture_suite_add_suite ( suite , torture_smb2_kernel_oplocks_init ( suite ) ) ;
2017-04-25 01:45:02 +03:00
torture_suite_add_suite ( suite , torture_smb2_streams_init ( suite ) ) ;
2017-04-25 01:30:14 +03:00
torture_suite_add_suite ( suite , torture_smb2_ioctl_init ( suite ) ) ;
2018-09-29 02:08:22 +03:00
torture_suite_add_simple_test ( suite , " set-sparse-ioctl " ,
test_ioctl_set_sparse ) ;
2018-09-29 02:37:51 +03:00
torture_suite_add_simple_test ( suite , " zero-data-ioctl " ,
test_ioctl_zero_data ) ;
2017-04-25 01:40:16 +03:00
torture_suite_add_suite ( suite , torture_smb2_rename_init ( suite ) ) ;
2010-12-11 05:26:31 +03:00
torture_suite_add_1smb2_test ( suite , " bench-oplock " , test_smb2_bench_oplock ) ;
2017-06-01 00:43:41 +03:00
torture_suite_add_suite ( suite , torture_smb2_sharemode_init ( suite ) ) ;
2010-12-11 05:26:31 +03:00
torture_suite_add_1smb2_test ( suite , " hold-oplock " , test_smb2_hold_oplock ) ;
2017-04-25 01:43:27 +03:00
torture_suite_add_suite ( suite , torture_smb2_session_init ( suite ) ) ;
2017-04-25 01:41:18 +03:00
torture_suite_add_suite ( suite , torture_smb2_replay_init ( suite ) ) ;
2016-06-23 20:13:05 +03:00
torture_suite_add_simple_test ( suite , " dosmode " , torture_smb2_dosmode ) ;
2016-07-11 21:32:19 +03:00
torture_suite_add_simple_test ( suite , " maxfid " , torture_smb2_maxfid ) ;
2017-06-01 00:43:41 +03:00
torture_suite_add_simple_test ( suite , " hold-sharemode " ,
torture_smb2_hold_sharemode ) ;
torture_suite_add_simple_test ( suite , " check-sharemode " ,
torture_smb2_check_sharemode ) ;
2017-04-25 01:19:12 +03:00
torture_suite_add_suite ( suite , torture_smb2_crediting_init ( suite ) ) ;
2006-10-16 17:06:41 +04:00
2017-04-25 01:20:58 +03:00
torture_suite_add_suite ( suite , torture_smb2_doc_init ( suite ) ) ;
2016-01-19 16:55:03 +03:00
torture_suite_add_suite ( suite , torture_smb2_multichannel_init ( suite ) ) ;
2013-04-05 04:15:30 +04:00
2007-05-13 16:52:13 +04:00
suite - > description = talloc_strdup ( suite , " SMB2-specific tests " ) ;
2006-10-16 17:06:41 +04:00
2017-04-25 00:41:26 +03:00
torture_register_suite ( ctx , suite ) ;
2006-06-17 06:20:39 +04:00
return NT_STATUS_OK ;
}