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"
2020-12-02 19:24:22 +03:00
# include "lib/cmdline/cmdline.h"
2014-07-08 07:39:49 +04:00
# 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 (
2017-04-25 00:41:26 +03:00
ctx , " vfs " ) ;
2014-07-08 07:36:46 +04:00
suite - > description = talloc_strdup ( suite , " VFS modules tests " ) ;
2017-04-25 01:48:42 +03:00
torture_suite_add_suite ( suite , torture_vfs_fruit ( suite ) ) ;
torture_suite_add_suite ( suite , torture_vfs_fruit_netatalk ( suite ) ) ;
2017-04-25 01:46:47 +03:00
torture_suite_add_suite ( suite , torture_acl_xattr ( suite ) ) ;
2017-04-25 01:48:42 +03:00
torture_suite_add_suite ( suite , torture_vfs_fruit_file_id ( suite ) ) ;
2018-01-02 21:09:04 +03:00
torture_suite_add_suite ( suite , torture_vfs_fruit_timemachine ( suite ) ) ;
2018-10-04 15:28:15 +03:00
torture_suite_add_suite ( suite , torture_vfs_fruit_conversion ( suite ) ) ;
2019-07-05 18:35:50 +03:00
torture_suite_add_suite ( suite , torture_vfs_fruit_unfruit ( suite ) ) ;
2023-10-20 16:45:31 +03:00
torture_suite_add_1smb2_test ( suite , " fruit_validate_afpinfo " , test_fruit_validate_afpinfo ) ;
2014-07-08 07:47:02 +04:00
2017-04-25 00:41:26 +03:00
torture_register_suite ( ctx , suite ) ;
2014-07-08 07:36:46 +04:00
return NT_STATUS_OK ;
}