Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GaeshaFSALBaseTest : public gtest::GaneshaBaseTest {
- protected:
- virtual void SetUp() {
- fsal_status_t status;
- struct attrlist attrs_out;
- gtest::GaneshaBaseTest::SetUp();
- a_export = get_gsh_export(export_id);
- ASSERT_NE(a_export, nullptr);
- status = nfs_export_get_root_entry(a_export, &root_entry);
- ASSERT_EQ(status.major, 0);
- ASSERT_NE(root_entry, nullptr);
- /* Ganesha call paths need real or forged context info */
- memset(&user_credentials, 0, sizeof(struct user_cred));
- memset(&req_ctx, 0, sizeof(struct req_op_context));
- memset(&attrs, 0, sizeof(attrs));
- memset(&exp_perms, 0, sizeof(struct export_perms));
- req_ctx.ctx_export = a_export;
- req_ctx.fsal_export = a_export->fsal_export;
- req_ctx.creds = &user_credentials;
- req_ctx.export_perms = &exp_perms;
- /* stashed in tls */
- op_ctx = &req_ctx;
- // create root directory for test
- FSAL_SET_MASK(attrs.valid_mask,
- ATTR_MODE | ATTR_OWNER | ATTR_GROUP);
- attrs.mode = 0777; /* XXX */
- attrs.owner = 667;
- attrs.group = 766;
- fsal_prepare_attrs(&attrs_out, 0);
- status = fsal_create(root_entry, TEST_ROOT, DIRECTORY, &attrs, NULL,
- &test_root, &attrs_out);
- ASSERT_EQ(status.major, 0);
- ASSERT_NE(test_root, nullptr);
- fsal_release_attrs(&attrs_out);
- }
- virtual void TearDown() {
- fsal_status_t status;
- status = test_root->obj_ops.unlink(root_entry, test_root, TEST_ROOT);
- EXPECT_EQ(0, status.major);
- test_root->obj_ops.put_ref(test_root);
- test_root = NULL;
- root_entry->obj_ops.put_ref(root_entry);
- root_entry = NULL;
- gtest::GaneshaBaseTest::TearDown();
- }
- struct req_op_context req_ctx;
- struct user_cred user_credentials;
- struct attrlist attrs;
- struct export_perms exp_perms;
- struct gsh_export* a_export = nullptr;
- struct fsal_obj_handle *root_entry = nullptr;
- struct fsal_obj_handle *test_root = nullptr;
- }
- class GaeshaNFS4BaseTest : public gtest::GaneshaBaseTest {
- protected:
- virtual void SetUp() {
- bool fhres;
- gtest::GaeshaFSALBaseTest::SetUp();
- memset(&data, 0, sizeof(struct compound_data));
- memset(&arg, 0, sizeof(nfs_arg_t));
- memset(&resp, 0, sizeof(struct nfs_resop4));
- arg.arg_compound4.argarray.argarray_len = 1;
- arg.arg_compound4.argarray.argarray_val = (struct nfs_argop4 *)
- gsh_calloc(1, sizeof(struct nfs_argop4));
- op = &arg.arg_compound4.argarray.argarray_val[0];
- /* Setup some basic stuff (that will be overrode) so TearDown works. */
- data.minorversion = 0;
- op->argop = NFS4_OP_PUTROOTFH;
- /* Convert root_obj to a file handle in the args */
- fhres = nfs4_FSALToFhandle(true, &data.currentFH, test_root,
- op_ctx->ctx_export);
- EXPECT_EQ(fhres, true);
- }
- virtual void TearDown() {
- bool rc;
- set_current_entry(&data, nullptr);
- nfs4_Compound_FreeOne(&resp);
- /* Free the compound data and response */
- compound_data_Free(&data);
- /* Free the args structure. */
- rc = xdr_free((xdrproc_t) xdr_COMPOUND4args, &arg);
- EXPECT_EQ(rc, true);
- gtest::GaeshaFSALBaseTest::TearDown();
- }
- struct compound_data data;
- struct nfs_argop4 *op;
- nfs_arg_t arg;
- struct nfs_resop4 resp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement