2014-07-08 07:36:46 +04:00
/*
Unix SMB / CIFS implementation .
Copyright ( C ) Ralph Boehme 2014
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 3 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 , see < http : //www.gnu.org/licenses/>.
*/
# include "includes.h"
2014-07-08 07:39:49 +04:00
# include "system/filesys.h"
# include "libcli/libcli.h"
# include "../lib/util/dlinklist.h"
2014-07-08 07:36:46 +04:00
2014-07-08 07:39:49 +04:00
# include "libcli/smb2/smb2.h"
# include "libcli/smb2/smb2_calls.h"
# include "lib/cmdline/popt_common.h"
# include "param/param.h"
# include "libcli/resolve/resolve.h"
# include "torture/util.h"
2014-07-08 07:36:46 +04:00
# include "torture/smbtorture.h"
# include "torture/vfs/proto.h"
2014-07-08 07:39:49 +04:00
# include "torture/smb2/proto.h"
static bool wrap_2ns_smb2_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 * ) ;
2016-12-11 21:02:37 +03:00
bool ok ;
2014-07-08 07:39:49 +04:00
2016-12-11 21:02:37 +03:00
struct smb2_tree * tree1 = NULL ;
struct smb2_tree * tree2 = NULL ;
2014-07-08 07:39:49 +04:00
TALLOC_CTX * mem_ctx = talloc_new ( torture_ctx ) ;
2016-12-11 21:02:37 +03:00
if ( ! torture_smb2_connection ( torture_ctx , & tree1 ) ) {
2014-07-08 07:39:49 +04:00
torture_fail ( torture_ctx ,
2016-12-11 21:02:37 +03:00
" Establishing SMB2 connection failed \n " ) ;
return false ;
2014-07-08 07:39:49 +04:00
}
2016-12-11 21:02:37 +03: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 .
*/
2014-07-08 07:39:49 +04:00
talloc_steal ( mem_ctx , tree1 ) ;
2016-12-11 21:02:37 +03:00
ok = torture_smb2_con_sopt ( torture_ctx , " share2 " , & tree2 ) ;
if ( ok ) {
talloc_steal ( mem_ctx , tree2 ) ;
2014-07-08 07:39:49 +04:00
}
fn = test - > fn ;
2016-12-11 21:02:37 +03:00
ok = fn ( torture_ctx , tree1 , tree2 ) ;
2014-07-08 07:39:49 +04:00
/* the test may already have closed some of the connections */
talloc_free ( mem_ctx ) ;
2016-12-11 21:02:37 +03:00
return ok ;
2014-07-08 07:39:49 +04:00
}
/*
2016-12-11 21:02:37 +03:00
* Run a test with 2 connected trees , the default share and another
* taken from option strings " torture:share2 "
2014-07-08 07:39:49 +04:00
*/
struct torture_test * torture_suite_add_2ns_smb2_test ( struct torture_suite * suite ,
const char * name ,
bool ( * run ) ( struct torture_context * ,
struct smb2_tree * ,
struct smb2_tree * ) )
{
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_2ns_smb2_test ;
test - > fn = run ;
test - > dangerous = false ;
2016-02-05 13:32:18 +03:00
DLIST_ADD_END ( tcase - > tests , test ) ;
2014-07-08 07:39:49 +04:00
return test ;
}
2014-07-08 07:36:46 +04:00
2017-04-20 22:24:43 +03:00
NTSTATUS torture_vfs_init ( TALLOC_CTX * ctx )
2014-07-08 07:36:46 +04:00
{
struct torture_suite * suite = torture_suite_create (
talloc_autofree_context ( ) , " vfs " ) ;
suite - > description = talloc_strdup ( suite , " VFS modules tests " ) ;
2014-07-08 07:47:02 +04:00
torture_suite_add_suite ( suite , torture_vfs_fruit ( ) ) ;
2016-11-16 00:31:20 +03:00
torture_suite_add_suite ( suite , torture_vfs_fruit_netatalk ( ) ) ;
2016-08-25 17:30:24 +03:00
torture_suite_add_suite ( suite , torture_acl_xattr ( ) ) ;
2017-03-23 22:32:04 +03:00
torture_suite_add_suite ( suite , torture_vfs_fruit_file_id ( ) ) ;
2014-07-08 07:47:02 +04:00
2014-07-08 07:36:46 +04:00
torture_register_suite ( suite ) ;
return NT_STATUS_OK ;
}