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
{
2017-04-24 14:41:26 -07:00
struct torture_suite * suite = torture_suite_create ( ctx , " smb2 " ) ;
2010-12-11 03:26:31 +01:00
torture_suite_add_simple_test ( suite , " connect " , torture_smb2_connect ) ;
2017-04-24 15:42:20 -07:00
torture_suite_add_suite ( suite , torture_smb2_scan_init ( suite ) ) ;
2017-04-24 16:04:10 -07:00
torture_suite_add_suite ( suite , torture_smb2_getinfo_init ( suite ) ) ;
2010-12-11 03:26:31 +01:00
torture_suite_add_simple_test ( suite , " setinfo " , torture_smb2_setinfo ) ;
2017-04-24 15:32:26 -07:00
torture_suite_add_suite ( suite , torture_smb2_lock_init ( suite ) ) ;
2017-04-24 15:38:38 -07:00
torture_suite_add_suite ( suite , torture_smb2_read_init ( suite ) ) ;
2018-10-28 19:29:26 +01:00
torture_suite_add_suite ( suite , torture_smb2_aio_delay_init ( suite ) ) ;
2022-06-28 14:44:51 +00:00
torture_suite_add_suite ( suite , torture_smb2_bench_init ( suite ) ) ;
2017-04-24 15:17:45 -07:00
torture_suite_add_suite ( suite , torture_smb2_create_init ( suite ) ) ;
2018-11-14 13:45:11 +01:00
torture_suite_add_suite ( suite , torture_smb2_twrp_init ( suite ) ) ;
2019-08-30 14:49:24 +02:00
torture_suite_add_suite ( suite , torture_smb2_fileid_init ( suite ) ) ;
2017-04-24 15:11:19 -07:00
torture_suite_add_suite ( suite , torture_smb2_acls_init ( suite ) ) ;
2021-05-26 12:31:32 +02:00
torture_suite_add_suite ( suite , torture_smb2_acls_non_canonical_init ( suite ) ) ;
2017-04-24 15:33:53 -07:00
torture_suite_add_suite ( suite , torture_smb2_notify_init ( suite ) ) ;
2017-07-13 16:05:49 +02:00
torture_suite_add_suite ( suite , torture_smb2_notify_inotify_init ( suite ) ) ;
2017-04-24 15:35:18 -07:00
torture_suite_add_suite ( suite ,
torture_smb2_notify_disabled_init ( suite ) ) ;
2017-04-24 15:25:38 -07: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-24 15:27:01 -07:00
torture_suite_add_suite ( suite ,
torture_smb2_durable_v2_open_init ( suite ) ) ;
2018-08-30 19:15:19 +02:00
torture_suite_add_suite ( suite ,
torture_smb2_durable_v2_delay_init ( suite ) ) ;
2017-04-24 15:22:37 -07:00
torture_suite_add_suite ( suite , torture_smb2_dir_init ( suite ) ) ;
2017-04-24 15:31:25 -07:00
torture_suite_add_suite ( suite , torture_smb2_lease_init ( suite ) ) ;
2017-04-24 15:13:10 -07:00
torture_suite_add_suite ( suite , torture_smb2_compound_init ( suite ) ) ;
torture_suite_add_suite ( suite , torture_smb2_compound_find_init ( suite ) ) ;
2022-10-18 16:22:33 -07:00
torture_suite_add_suite ( suite , torture_smb2_compound_async_init ( suite ) ) ;
2017-04-24 15:37:12 -07:00
torture_suite_add_suite ( suite , torture_smb2_oplocks_init ( suite ) ) ;
torture_suite_add_suite ( suite , torture_smb2_kernel_oplocks_init ( suite ) ) ;
2017-04-24 15:45:02 -07:00
torture_suite_add_suite ( suite , torture_smb2_streams_init ( suite ) ) ;
2017-04-24 15:30:14 -07:00
torture_suite_add_suite ( suite , torture_smb2_ioctl_init ( suite ) ) ;
2018-09-28 16:08:22 -07:00
torture_suite_add_simple_test ( suite , " set-sparse-ioctl " ,
test_ioctl_set_sparse ) ;
2018-09-28 16:37:51 -07:00
torture_suite_add_simple_test ( suite , " zero-data-ioctl " ,
test_ioctl_zero_data ) ;
2022-11-10 14:41:15 -08:00
torture_suite_add_simple_test ( suite , " ioctl-on-stream " ,
test_ioctl_alternate_data_stream ) ;
2017-04-24 15:40:16 -07:00
torture_suite_add_suite ( suite , torture_smb2_rename_init ( suite ) ) ;
2017-05-31 14:43:41 -07:00
torture_suite_add_suite ( suite , torture_smb2_sharemode_init ( suite ) ) ;
2010-12-11 03:26:31 +01:00
torture_suite_add_1smb2_test ( suite , " hold-oplock " , test_smb2_hold_oplock ) ;
2017-04-24 15:43:27 -07:00
torture_suite_add_suite ( suite , torture_smb2_session_init ( suite ) ) ;
2023-06-20 12:46:31 +02:00
torture_suite_add_suite ( suite , torture_smb2_session_req_sign_init ( suite ) ) ;
2017-04-24 15:41:18 -07:00
torture_suite_add_suite ( suite , torture_smb2_replay_init ( suite ) ) ;
2016-06-23 19:13:05 +02:00
torture_suite_add_simple_test ( suite , " dosmode " , torture_smb2_dosmode ) ;
2022-01-25 17:59:37 +01:00
torture_suite_add_simple_test ( suite , " async_dosmode " , torture_smb2_async_dosmode ) ;
2016-07-11 11:32:19 -07:00
torture_suite_add_simple_test ( suite , " maxfid " , torture_smb2_maxfid ) ;
2017-05-31 14:43:41 -07: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-24 15:19:12 -07:00
torture_suite_add_suite ( suite , torture_smb2_crediting_init ( suite ) ) ;
2006-10-16 13:06:41 +00:00
2017-04-24 15:20:58 -07:00
torture_suite_add_suite ( suite , torture_smb2_doc_init ( suite ) ) ;
2016-01-19 14:55:03 +01:00
torture_suite_add_suite ( suite , torture_smb2_multichannel_init ( suite ) ) ;
2019-08-19 17:38:30 +02:00
torture_suite_add_suite ( suite , torture_smb2_samba3misc_init ( suite ) ) ;
2019-11-21 16:47:33 +01:00
torture_suite_add_suite ( suite , torture_smb2_timestamps_init ( suite ) ) ;
2020-03-06 16:21:47 +01:00
torture_suite_add_suite ( suite , torture_smb2_timestamp_resolution_init ( suite ) ) ;
2019-12-10 07:47:12 -07:00
torture_suite_add_1smb2_test ( suite , " openattr " , torture_smb2_openattrtest ) ;
torture_suite_add_1smb2_test ( suite , " winattr " , torture_smb2_winattrtest ) ;
2022-11-25 16:02:27 +01:00
torture_suite_add_1smb2_test ( suite , " winattr2 " , torture_smb2_winattr2 ) ;
2020-04-15 11:59:17 -07:00
torture_suite_add_1smb2_test ( suite , " sdread " , torture_smb2_sdreadtest ) ;
2019-12-10 13:49:28 -07:00
torture_suite_add_suite ( suite , torture_smb2_readwrite_init ( suite ) ) ;
2022-08-19 10:45:10 +02:00
torture_suite_add_suite ( suite , torture_smb2_max_allowed ( suite ) ) ;
2020-01-06 09:43:19 -07:00
torture_suite_add_1smb2_test ( suite , " tcon " , run_tcon_test ) ;
2020-01-23 07:26:53 -07:00
torture_suite_add_1smb2_test ( suite , " mkdir " , torture_smb2_mkdir ) ;
2022-12-01 06:09:09 +01:00
torture_suite_add_suite ( suite , torture_smb2_name_mangling_init ( suite ) ) ;
2013-04-04 17:15:30 -07:00
2019-12-10 12:06:13 -07:00
torture_suite_add_suite ( suite , torture_smb2_charset ( suite ) ) ;
2020-01-17 09:07:00 -07:00
torture_suite_add_1smb2_test ( suite , " secleak " , torture_smb2_sec_leak ) ;
2020-01-16 10:26:25 -07:00
torture_suite_add_1smb2_test ( suite , " session-id " , run_sessidtest ) ;
2019-12-17 14:03:19 -07:00
torture_suite_add_suite ( suite , torture_smb2_deny_init ( suite ) ) ;
2022-06-03 05:37:01 +02:00
torture_suite_add_suite ( suite , torture_smb2_ea ( suite ) ) ;
2022-09-01 18:55:23 +02:00
torture_suite_add_suite ( suite , torture_smb2_create_no_streams_init ( suite ) ) ;
2020-01-17 09:07:00 -07: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
2017-04-24 14:41:26 -07:00
torture_register_suite ( ctx , suite ) ;
2006-06-17 02:20:39 +00:00
return NT_STATUS_OK ;
}