[LTP] [COMMITTED] [PATCH] testcases: Remove dmapi
Cyril Hrubis
chrubis@suse.cz
Wed May 24 14:27:55 CEST 2017
The test was skipped from compilation for quite a long time, there is no
point in keeping it in the tree.
See also:
https://github.com/linux-test-project/ltp/issues/156
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
testcases/kernel/fs/Makefile | 6 -
testcases/kernel/fs/dmapi/Makefile | 59 -
testcases/kernel/fs/dmapi/README | 243 -
testcases/kernel/fs/dmapi/attr.c | 13507 -----------------------------
testcases/kernel/fs/dmapi/config.c | 491 --
testcases/kernel/fs/dmapi/disp.c | 4062 ---------
testcases/kernel/fs/dmapi/dm_impl.h | 158 -
testcases/kernel/fs/dmapi/dm_test.c | 522 --
testcases/kernel/fs/dmapi/dm_test.h | 171 -
testcases/kernel/fs/dmapi/dm_vars.h | 135 -
testcases/kernel/fs/dmapi/event.c | 1907 ----
testcases/kernel/fs/dmapi/event_am.c | 2548 ------
testcases/kernel/fs/dmapi/event_an.c | 3580 --------
testcases/kernel/fs/dmapi/event_sd.c | 7334 ----------------
testcases/kernel/fs/dmapi/event_sn.c | 1863 ----
testcases/kernel/fs/dmapi/event_us.c | 1034 ---
testcases/kernel/fs/dmapi/handle.c | 7051 ---------------
testcases/kernel/fs/dmapi/hole.c | 4616 ----------
testcases/kernel/fs/dmapi/invis.c | 2707 ------
testcases/kernel/fs/dmapi/mmap.c | 1619 ----
testcases/kernel/fs/dmapi/mmapfile.c | 135 -
testcases/kernel/fs/dmapi/mount.c | 871 --
testcases/kernel/fs/dmapi/objref.c | 764 --
testcases/kernel/fs/dmapi/pmr_post.c | 1366 ---
testcases/kernel/fs/dmapi/pmr_pre.c | 2579 ------
testcases/kernel/fs/dmapi/right.c | 2059 -----
testcases/kernel/fs/dmapi/runtest_off.sh | 42 -
testcases/kernel/fs/dmapi/runtest_on.sh | 29 -
testcases/kernel/fs/dmapi/session.c | 1362 ---
testcases/kernel/fs/dmapi/token.c | 845 --
30 files changed, 63665 deletions(-)
delete mode 100644 testcases/kernel/fs/dmapi/Makefile
delete mode 100644 testcases/kernel/fs/dmapi/README
delete mode 100644 testcases/kernel/fs/dmapi/attr.c
delete mode 100644 testcases/kernel/fs/dmapi/config.c
delete mode 100644 testcases/kernel/fs/dmapi/disp.c
delete mode 100644 testcases/kernel/fs/dmapi/dm_impl.h
delete mode 100644 testcases/kernel/fs/dmapi/dm_test.c
delete mode 100644 testcases/kernel/fs/dmapi/dm_test.h
delete mode 100644 testcases/kernel/fs/dmapi/dm_vars.h
delete mode 100644 testcases/kernel/fs/dmapi/event.c
delete mode 100644 testcases/kernel/fs/dmapi/event_am.c
delete mode 100644 testcases/kernel/fs/dmapi/event_an.c
delete mode 100644 testcases/kernel/fs/dmapi/event_sd.c
delete mode 100644 testcases/kernel/fs/dmapi/event_sn.c
delete mode 100644 testcases/kernel/fs/dmapi/event_us.c
delete mode 100644 testcases/kernel/fs/dmapi/handle.c
delete mode 100644 testcases/kernel/fs/dmapi/hole.c
delete mode 100644 testcases/kernel/fs/dmapi/invis.c
delete mode 100644 testcases/kernel/fs/dmapi/mmap.c
delete mode 100644 testcases/kernel/fs/dmapi/mmapfile.c
delete mode 100644 testcases/kernel/fs/dmapi/mount.c
delete mode 100644 testcases/kernel/fs/dmapi/objref.c
delete mode 100644 testcases/kernel/fs/dmapi/pmr_post.c
delete mode 100644 testcases/kernel/fs/dmapi/pmr_pre.c
delete mode 100644 testcases/kernel/fs/dmapi/right.c
delete mode 100755 testcases/kernel/fs/dmapi/runtest_off.sh
delete mode 100755 testcases/kernel/fs/dmapi/runtest_on.sh
delete mode 100644 testcases/kernel/fs/dmapi/session.c
delete mode 100644 testcases/kernel/fs/dmapi/token.c
diff --git a/testcases/kernel/fs/Makefile b/testcases/kernel/fs/Makefile
index d843b48b8..caa2c2df3 100644
--- a/testcases/kernel/fs/Makefile
+++ b/testcases/kernel/fs/Makefile
@@ -23,10 +23,4 @@
top_srcdir ?= ../../..
include $(top_srcdir)/include/mk/env_pre.mk
-
-# XXX (garrcoop): Need to add autoconf checks for JFS.
-# ext4-new-features: This test need to be configured be user.
-# Please read $LTPROOT/README to see the detail information
-FILTER_OUT_DIRS := dmapi
-
include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/fs/dmapi/Makefile b/testcases/kernel/fs/dmapi/Makefile
deleted file mode 100644
index 9ee7e1d44..000000000
--- a/testcases/kernel/fs/dmapi/Makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (c) International Business Machines Corp., 2004
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-top_srcdir ?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-# dmapi_imp is platform for DMAPI implementation (currently supported: JFS)
-dmapi_imp := JFS
-
-# dmapi_lib is path of user space library for DMAPI implementation
-LDLIBS += -ljfsdm
-
-CFLAGS += -g -Wall -D$(dmapi_imp)
-
-# Define USER_SPACE_FAULTS if DMAPI implementation handles user space
-# faults (JFS has plenty of handle code in user space, which causes
-# faults when invalid pointers are passed in)
-# Define DIRECTORY_LINKS if DMAPI FS supports links on directories (JFS
-# does not)
-# Define INTERIOR_HOLES if DMAPI implementation supports probing/punching
-# interior holes (JFS does); if not defined, only probing/punching
-# holes to end-of-file is supported
-# Define MULTIPLE_REGIONS if DMAPI implementation supports multiple
-# interior regions (JFS does); if not defined, only one region
-# covering entire file is supported
-#extra_cflags = -DUSER_SPACE_FAULTS
-#extra_cflags = -DDIRECTORY_LINKS
-#extra_cflags = -DINTERIOR_HOLES
-#extra_cflags = -DMULTIPLE_REGIONS
-CFLAGS += -DINTERIOR_HOLES -DMULTIPLE_REGIONS
-
-cflags = $(std_cflags) $(extra_cflags)
-
-lflags = $(dmapi_lib)
-lflags_thd = $(dmapi_lib) -lpthread
-
-FILTER_OUT_MAKE_TARGETS := dm_test
-
-dm_test.o: dm_test.c dm_impl.h
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
-
-$(MAKE_TARGETS): %: %.o dm_test.o dm_test.h
diff --git a/testcases/kernel/fs/dmapi/README b/testcases/kernel/fs/dmapi/README
deleted file mode 100644
index 6461a6f68..000000000
--- a/testcases/kernel/fs/dmapi/README
+++ /dev/null
@@ -1,243 +0,0 @@
-
- DMAPI Function Verification Test Bucket
-
-I. Test Bucket Introduction
-
-This test bucket tests the interfaces and events defined in the CAE
-Specification entitled "Systems Management: Data Storage Management (XDSM)
-API," which was copyrighted in February, 1997 by The Open Group. The test
-bucket consists of 20 executables containing 1097 variations which test 59 of
-67 published DMAPIs and all JFS-supported events except DM_EVENT_NOSPACE on a
-functional level.
-
-II. Test Bucket Contents
-
-These files provide the test harness:
-
-dm_test.h : Defines macros and constants common to all DMAPI test cases;
- some of the constants may be platform-dependent and should be
- reviewed prior to running the test bucket on a new platform
-dm_vars.h : Defines variation number bases for all DMAPI test cases;
- theoretically these could all be zero, but the author
- believes that giving every variation a unique number makes
- it much easier when discussing successes/failures
-dm_impl.h : Define implementation-dependent functions and variables
- common to all DMAPI test cases; these must be modified prior
- to running the test bucket on a new platform (note: although
- this is a .h file, it is really a .c file that is included by
- dm_test.c and is separated to make it easier to port to new
- platforms)
-dm_test.c : Define functions and variables common to all DMAPI test cases
-
-These files provide the test scenarios:
-
-attr.c : Tests dm_set_dmattr, dm_get_dmattr, dm_remove_dmattr,
- dm_getall_dmattr, dm_set_fileattr, dm_get_fileattr,
- dm_get_dirattrs, dm_set_inherit, dm_clear_inherit and
- dm_getall_inherit
-config.c : Tests dm_get_config
-disp.c : Tests dm_get_config_events, dm_set_disp, dm_getall_disp,
- dm_set_eventlist and dm_get_eventlist
-event.c : Tests dm_get_events, dm_respond_event, dm_move_event and
- dm_pending
-event_am.c : Tests DM_EVENT_ATTRIBUTE, DM_EVENT_CLOSE, DM_EVENT_DESTROY
- and dm_set_return_on_destroy
-event_an.c : Tests DM_EVENT_POSTCREATE, DM_EVENT_POSTREMOVE,
- DM_EVENT_POSTRENAME, DM_EVENT_POSTSYMLINK and
- DM_EVENT_POSTLINK
-event_sd.c : Tests DM_EVENT_READ, DM_EVENT_WRITE and DM_EVENT_TRUNCATE
-event_sn.c : Tests DM_EVENT_CREATE, DM_EVENT_REMOVE, DM_EVENT_RENAME,
- DM_EVENT_SYMLINK and DM_EVENT_LINK
-event_us.c : Tests DM_EVENT_USER, dm_create_userevent, dm_send_msg and
- dm_find_eventmsg
-handle.c : Tests dm_path_to_handle, dm_fd_to_handle,
- dm_path_to_fshandle, dm_handle_to_fshandle, dm_handle_cmp,
- dm_handle_free, dm_handle_is_valid, dm_handle_hash,
- dm_handle_to_fsid, dm_handle_to_igen, dm_handle_to_ino,
- dm_make_handle, dm_make_fshandle, dm_handle_to_path and
- dm_sync_by_handle
-hole.c : Tests dm_get_allocinfo, dm_probe_hole and dm_punch_hole
-invis.c : Tests dm_read_invis and dm_write_invis
-mmap.c : Tests DM_EVENT_READ and DM_EVENT_WRITE
-mmapfile.c : Helper for mmap, invokes mmap() from a different process
-mount.c : Tests dm_get_mountinfo
-objref.c : Tests dm_obj_ref_hold, dm_obj_ref_rele and dm_obj_ref_query
-pmr_pre.c : Tests dm_set_region
-pmr_post.c : Tests dm_get_region
-right.c : Tests dm_request_right, dm_release_right, dm_query_right,
- dm_upgrade_right and dm_downgrade_right
-session.c : Tests dm_create_session, dm_destroy_session,
- dm_getall_sessions and dm_query_session
-token.c : Tests dm_getall_tokens
-
-These scripts execute the test scenarios:
-
-runtest_off.sh : Executes test scenarios that must be run off the DM-enabled
- file system (any directory is fine)
-runtest_on.sh : Executes test scenarios that must be run from the root
- directory of the DM-enabled file system
-
-Other file(s):
-
-README : You're looking at it
-Makefile : Builds the test harness and scenario; the platform must be
- defined (i.e. JFS) to build the proper stuff in dm_impl.c,
- and other constants as necessary to build the proper support
- (i.e. MULTIPLE_REGIONS)
-
-III. Test Bucket Omissions
-
-This test bucket does not test the following DMAPIs because they are not
-supported by the originating platform (JFS):
-
- dm_create_by_handle
- dm_get_bulkall
- dm_get_bulkattr
- dm_mkdir_by_handle
- dm_symlink_by_handle
-
-This test bucket does not fully test the following DMAPIs because they are not
-fully supported by the originating platform (JFS); in other words, these tests
-will probably need further variations to fully test their functionality as the
-current variations only test the skeleton support provided by JFS:
-
- dm_clear_inherit
- dm_downgrade_right
- dm_getall_inherit
- dm_query_right
- dm_release_right
- dm_request_right
- dm_set_inherit
- dm_upgrade_right
-
-IV. Test Bucket Execution
-
-To run this test bucket against a DMAPI-enabled partition, make sure the
-DMAPI implementation (kernel and user space code) is installed on the system
-(see Implementation-dependent Notes below) and follow these steps:
-
- 1) Untar the tarball in a directory NOT on a DMAPI-enabled partition:
-
- tar -xvf dm_test.tar
-
- 2) Make the test bucket:
-
- make
-
- NOTE: Modify dmapi_lib in Makefile to point to the user space
- library for the DMAPI implementation to be tested
-
- 3) If the file system is compiled as a module, make sure it is
- installed first:
-
- modprobe blah
-
- 4) Run the test cases that require NOT being on a DMAPI-enabled
- partition:
-
- ./runtest_off.sh
-
- 5) Check the results of these test cases:
-
- grep status *.log
-
- 6) Mount the DMAPI-enabled partition:
-
- mount -t blah -o blah /dev/hdablah /dmapidir
-
- 7) Copy the test bucket to the root of the DMAPI-enabled partition:
-
- cp * /dmapidir
-
- 8) Make the root of the DMAPI-enabled partition the current directory:
-
- cd /dmapidir
-
- 9) Remove the copies of the log files just generated:
-
- rm -f *.log
-
- 10) Run the test cases that require being on a DMAPI-enabled partition:
-
- ./runtest_on.sh
-
- 11) Check the results of these test cases:
-
- grep status *.log
-
-V. Test Case Format
-
-The general format of a test case using the supplied test harness should be:
-
- if (DMVAR_EXEC(variation number)) {
- set up variation;
- if (set up variation failed)
- DMVAR_SKIP();
- else {
- execute variation;
- if (variation successful)
- DMVAR_PASS();
- else
- DMVAR_FAIL();
- clean up variation;
- }
- }
-
-VI. Test Case Options
-
-Following this format will allow the tester to be able to run a variation
-individually as the variation both initializes and terminates itself. Current
-options supported by the test harness are:
-
--runfrom n : Defines the starting variation to begin executing from; sets
- a variation range to execute when used along with -runto, or
- runs all variations greater than or equal to n if -runto is
- not specified
--runto n : Defines the stopping variation to end executing at; sets
- a variation range to execute when used along with -runfrom,
- or runs all variations less than or equal to n if -runfrom is
- not specified
--runonly n : Executes only variation n
--loglevel n : Write all messages less than or equal to n to the log file
--termlevel n : Write all messages less than or equal to n to the terminal
--logname s : Write all messages defined by -loglevel to the log file named
- s; if not defined, the default log file name is dm_logfile
-
-Options and corresponding option values MUST be separated by whitespace. Any
-unrecognized option (that is, one starting with a dash such as -devname) and
-its option value can be obtained by using the DMOPT_GET macro (such as
-DMOPT_GET("devname")).
-
-VII. Test Case Output
-
-Each line of output generated by the DMLOG_PRINT macro is prefixed with:
-
- [prog pid level]
-
-where:
- prog is the name of the test program
- pid is the decimal process identifier
- level is the decimal logging level
-
-VIII. Test Case Notes
-
-The test bucket contains several multithreaded test cases where one thread is
-responsible for generating DMAPI events while the other is responsible for
-receiving said events and communicating back to the generating thread what was
-or was not received. At first semaphores were used to control thread execution
-but this lead to several deadlocks when expected events did not arrive, so
-delays (EVENT_DELIVERY_DELAY macro) were used. This could lead to timing
-issues on some platforms, so if a variation fails make sure to check the log
-to see if the event arrived after the generating thread checked for its
-arrival.
-
-IX. Implementation-dependent Notes
-
-1) JFS
- a) Instructions for installing DMAPI for IBM JFS can be found at
- http://oss.software.ibm.com/jfs/.
- b) The test case and user space library must match the architecture
- of the kernel. In other words, the test case and library must be
- compiled as 32-bit if running on a 32-bit kernel, and must be compiled
- as 64-bit if running on a 64-bit kernel. Currently, JFS DMAPI does
- not support a 32-bit DM app running on a 64-bit kernel.
diff --git a/testcases/kernel/fs/dmapi/attr.c b/testcases/kernel/fs/dmapi/attr.c
deleted file mode 100644
index 1bea3831e..000000000
--- a/testcases/kernel/fs/dmapi/attr.c
+++ /dev/null
@@ -1,13507 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : attr.c - DMAPI attributes
- *
- * VARIATIONS : 204
- *
- * API'S TESTED : dm_set_dmattr
- * dm_get_dmattr
- * dm_remove_dmattr
- * dm_getall_dmattr
- * dm_set_fileattr
- * dm_get_fileattr
- * dm_get_dirattrs
- * dm_set_inherit
- * dm_clear_inherit
- * dm_getall_inherit
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/xattr.h>
-#include "dm_test.h"
-
-#define TMP_FILELEN 1000
-#define ATTR_NAME2 "DMAttr02"
-#define NUM_ATTRS 15
-#define ATTR_SMALLLEN (DWALIGN(sizeof(dm_stat_t)+1) + DWALIGN(sizeof(DUMMY_FILE)+1))
-#define MIN_ENTRYLEN (DWALIGN(sizeof(dm_stat_t)+1) + DWALIGN(sizeof(CURRENT_DIR)+1))
-#define DM_AT_ALL_DIRATTRS (DM_AT_DTIME|DM_AT_HANDLE|DM_AT_EMASK|DM_AT_PMANR|DM_AT_PATTR|DM_AT_STAT|DM_AT_CFLAG)
-#define NON_DM_ATTR_NAME "user.non-dm.attr"
-#define NON_DM_ATTR_VALUE "This is a non-DM attribute's value"
-
-/*
- * DIRENTS_FILES is very implementation-dependent, and is the number of files
- * that will just fill up the buffer passed to jfs_get_dirents; NUM_FILES
- * should be at least 3 times DIRENTS_FILES; ATTR_LISTLEN needs to be large
- * enough to contain 3 files (., .. and dummy.txt) worth of information while
- * ATTR_BIGLISTLEN needs to be large enough to contain NUM_FILES files worth
- * of information
- */
-#define DIRENTS_FILES 5
-#define NUM_FILES 15
-#define ATTR_LISTLEN 1000
-#define ATTR_BIGLISTLEN 10000
-
-char command[4096];
-char fullAttrName[32];
-dm_sessid_t sid;
-dm_size_t maxAttrSize;
-dm_size_t persInheritAttr;
-
-void LogDmStat(dm_stat_t * statdm)
-{
-
- DMLOG_PRINT(DMLVL_DEBUG, " dt_dev %d\n", statdm->dt_dev);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_ino %d\n", statdm->dt_ino);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_mode 0x%x\n", statdm->dt_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_nlink %d\n", statdm->dt_nlink);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_uid %d\n", statdm->dt_uid);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_gid %d\n", statdm->dt_gid);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_rdev %d\n", statdm->dt_rdev);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_size %lld\n", statdm->dt_size);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_blksize %d\n", statdm->dt_blksize);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_blocks %d\n", statdm->dt_blocks);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_atime %d\n", statdm->dt_atime);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_mtime %d\n", statdm->dt_mtime);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_ctime %d\n", statdm->dt_ctime);
-
-}
-
-void LogDmAttrs(dm_attrlist_t * attrlist)
-{
-
- int i = 0;
- dm_attrlist_t *attr = attrlist;
-
- while (attr != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG, " dmattr %d: name %.*s, value %.*s\n",
- i++, DM_ATTR_NAME_SIZE, attr->al_name.an_chars,
- DM_GET_LEN(attr, al_data), DM_GET_VALUE(attr,
- al_data,
- char *));
- attr = DM_STEP_TO_NEXT(attr, dm_attrlist_t *);
- }
-}
-
-void LogDirAttrs(void *attrlist, u_int mask)
-{
- int i = 0;
- dm_stat_t *stat = (dm_stat_t *) attrlist;
-
- while (stat != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG, " dirattr %d:\n", i++);
- DMLOG_PRINT(DMLVL_DEBUG, " dt_compname: %s\n",
- DM_GET_VALUE(stat, dt_compname, char *));
- if (mask & DM_AT_HANDLE)
- dm_LogHandle(DM_GET_VALUE(stat, dt_handle, void *),
- DM_GET_LEN(stat, dt_handle));
- if (mask & DM_AT_EMASK)
- DMLOG_PRINT(DMLVL_DEBUG, " dt_emask: %x\n",
- stat->dt_emask);
- if (mask & DM_AT_PMANR)
- DMLOG_PRINT(DMLVL_DEBUG, " dt_pmanreg: %s\n",
- stat->dt_pmanreg ? "DM_TRUE" : "DM_FALSE");
- if (mask & DM_AT_PATTR)
- DMLOG_PRINT(DMLVL_DEBUG, " dt_pers: %s\n",
- stat->dt_pers ? "DM_TRUE" : "DM_FALSE");
- if (mask & DM_AT_DTIME)
- DMLOG_PRINT(DMLVL_DEBUG, " dt_dtime: %d\n",
- stat->dt_dtime);
- if (mask & DM_AT_CFLAG)
- DMLOG_PRINT(DMLVL_DEBUG, " dt_change: %d\n",
- stat->dt_change);
- if (mask & DM_AT_STAT)
- LogDmStat(stat);
-
- stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
- }
-}
-
-dm_stat_t *GetDirEntry(void *attrlist, char *compname)
-{
-
- dm_stat_t *stat = (dm_stat_t *) attrlist;
-
- while (stat != NULL) {
- if (strcmp(DM_GET_VALUE(stat, dt_compname, char *), compname) ==
- 0)
- return stat;
- stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
- }
- return NULL;
-
-}
-
-dm_stat_t *GetLastDirEntry(void *attrlist)
-{
-
- dm_stat_t *stat = (dm_stat_t *) attrlist;
- dm_stat_t *laststat = NULL;
-
- while (stat != NULL) {
- laststat = stat;
- stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
- }
- return laststat;
-
-}
-
-int GetNumDirEntry(void *attrlist)
-{
-
- dm_stat_t *stat = (dm_stat_t *) attrlist;
- int i = 0;
-
- while (stat != NULL) {
- i++;
- stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
- }
- return i;
-
-}
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int i;
- int rc;
- char *szSessionInfo = "dm_test session info";
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else {
- int fd;
- void *fshanp;
- size_t fshlen;
-
- fd = open(DUMMY_TMP, O_RDWR | O_CREAT | O_TRUNC,
- DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < (TMP_FILELEN / DUMMY_STRLEN); i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc == 0) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_path_to_fshandle(DUMMY_TMP, &fshanp, &fshlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_fshandle! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_get_config(fshanp, fshlen, DM_CONFIG_MAX_ATTRIBUTE_SIZE,
- &maxAttrSize);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_config failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_handle_free(fshanp, fshlen);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_get_config(fshanp, fshlen,
- DM_CONFIG_PERS_INHERIT_ATTRIBS,
- &persInheritAttr);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_config failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_handle_free(fshanp, fshlen);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- dm_handle_free(fshanp, fshlen);
-
- sprintf(fullAttrName, "%s%s", DMAPI_ATTR_PREFIX, ATTR_NAME);
-
- /* Clean up any possible leftovers that could get in the way */
- remove(DUMMY_SUBDIR_FILE);
- unlink(DUMMY_SUBDIR_LINK);
- rmdir(DUMMY_SUBDIR_SUBDIR);
- remove(DUMMY_FILE);
- remove(DUMMY_FILE2);
- unlink(DUMMY_LINK);
- rmdir(DUMMY_SUBDIR);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI attribute tests\n");
-
- szFuncName = "dm_set_dmattr";
-
- /*
- * TEST : dm_set_dmattr - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_set_dmattr(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, &attrname, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, &attrname, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, INVALID_ADDR,
- &attrname, 0, sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - invalid attrnamep
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #10 (0 return code from strnlen_user
- * ignored, which indicated fault)
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- (dm_attrname_t *) INVALID_ADDR, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, INVALID_ADDR, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf),
- (void *)INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - empty attrname
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(empty attrname)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - zero buflen
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN], value[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(zero buflen)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, 0, NULL);
- if (rc == 0) {
- if ((rc =
- getxattr(DUMMY_FILE, fullAttrName, value,
- sizeof(value))) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected attribute length (%d vs %d)\n",
- szFuncName, 0, 0, rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - maximum buflen
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char *buf, *value;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((buf = malloc(maxAttrSize)) == NULL) {
- /* No clean up */
- } else if ((memset(buf, '1', maxAttrSize) == NULL) ||
- ((value = malloc(maxAttrSize)) == NULL)) {
- free(buf);
- } else if ((memset(value, 0, maxAttrSize) == NULL) ||
- ((rc = system(command)) == -1)) {
- free(value);
- free(buf);
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- free(value);
- free(buf);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- free(value);
- free(buf);
- }
- if (fd == -1 || rc == -1 || buf == NULL || value == NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(max buflen)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, maxAttrSize, buf);
- if (rc == 0) {
- if ((rc =
- getxattr(DUMMY_FILE, fullAttrName, value,
- maxAttrSize)) == maxAttrSize) {
- if (memcmp(buf, value, maxAttrSize) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected attribute value (%s vs %s)\n",
- szFuncName, 0, buf,
- value);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected attribute length (%d vs %d)\n",
- szFuncName, 0, maxAttrSize,
- rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- free(buf);
- free(value);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - buflen too big
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char *buf;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((buf = malloc(maxAttrSize + 1)) == NULL) {
- /* No clean up */
- } else if ((memset(buf, '2', maxAttrSize + 1) == NULL) ||
- ((rc = system(command)) == -1)) {
- free(buf);
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- free(buf);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- free(buf);
- }
- if (fd == -1 || rc == -1 || buf == NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen too big)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, maxAttrSize + 1, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- free(buf);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - one file attribute, setdtime zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 12)) {
- int fd;
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(one file attr, setdtime zero)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime == statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime unmodified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - one file attribute, setdtime non-zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 13)) {
- int fd;
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(one file attr, setdtime non-zero)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 1, sizeof(buf), buf);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime != statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - two file attributes
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- int buf2 = INVALID_ADDR;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(two file attr)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- if (rc == 0) {
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME2,
- DM_ATTR_NAME_SIZE);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf2),
- (void *)&buf2);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - multiple file attributes
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 15)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(multiple file attr)\n",
- szFuncName);
- for (i = 1; (i <= NUM_ATTRS) && (rc == 0); i++) {
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME,
- DM_ATTR_NAME_SIZE);
- attrname.an_chars[DM_ATTR_NAME_SIZE - 2] =
- '0' + (i / 10);
- attrname.an_chars[DM_ATTR_NAME_SIZE - 1] =
- '0' + (i % 10);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%.*s)\n",
- szFuncName, DM_ATTR_NAME_SIZE,
- attrname.an_chars);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf),
- buf);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - replace file attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 16)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN], value[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(attrname), &attrname)) == -1)
- ||
- ((rc =
- (getxattr
- (DUMMY_FILE, fullAttrName, value,
- sizeof(value)) == sizeof(attrname)) ? 0 : -1) == -1)
- ||
- ((rc =
- (memcmp(&attrname, value, sizeof(attrname)) ==
- 0) ? 0 : -1) == -1)) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(replace file attr)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- if (rc == 0) {
- if ((rc =
- getxattr(DUMMY_FILE, fullAttrName, value,
- sizeof(value))) ==
- ATTR_VALUELEN) {
- if (memcmp(buf, value, sizeof(buf)) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected attribute value (%s vs %s)\n",
- szFuncName, 0, buf,
- value);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected attribute length (%d vs %d)\n",
- szFuncName, 0,
- ATTR_VALUELEN, rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - one directory attribute, setdtime zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 17)) {
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- rmdir(DUMMY_SUBDIR);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(one dir attr, setdtime zero)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime == statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime unmodified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - one directory attribute, setdtime non-zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 18)) {
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- rmdir(DUMMY_SUBDIR);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(one dir attr, setdtime non-zero)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 1, sizeof(buf), buf);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime != statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 19)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 20)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_set_dmattr(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, &attrname, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_dmattr - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 21)) {
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_set_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &attrname, 0, sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_set_dmattr - invalidated hanp
- * EXPECTED: rc = -1, errno = BADF
- */
- if (DMVAR_EXEC(SET_DMATTR_BASE + 22)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_get_dmattr";
-
- /*
- * TEST : dm_get_dmattr - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_get_dmattr(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, &attrname, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, &attrname, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
- &attrname, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, INVALID_ADDR,
- &attrname, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - invalid attrnamep
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- (dm_attrname_t *) INVALID_ADDR,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 1, buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
- DMLOG_PRINT(DMLVL_DEBUG, "rlen %d\n");
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #13 (attrname not null-terminated)
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf),
- (void *)INVALID_ADDR, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG, "rc = %d, %s", rc, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf), buf,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - zero buflen, zero attribute length
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, 0, NULL)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(zero buflen, zero attr len)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, NULL, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - zero buflen, non-zero attribute length
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(zero buflen, non-zero attr len)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, NULL, &rlen);
- if (rc == -1) {
- if (errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n",
- rlen);
- if (rlen == ATTR_VALUELEN) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d\n",
- szFuncName, -1,
- E2BIG);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, -1,
- E2BIG, rlen,
- ATTR_VALUELEN);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, -1, E2BIG);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, -1);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - attribute not exist
- * EXPECTED: rc = -1, errno = ENOENT
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(attr not exist)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - buf too small
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen too small)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf) - 1, buf,
- &rlen);
- if (rc == -1 && errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- }
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 13)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- if (rlen == ATTR_VALUELEN) {
- if (memcmp
- (buf, ATTR_VALUE,
- ATTR_VALUELEN) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and rlen = %d but unexpected buf %s",
- szFuncName, 0, rlen,
- buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen = %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - maximum buflen
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char *buf;
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((buf = malloc(maxAttrSize)) == NULL) {
- /* No clean up */
- } else if ((memset(buf, '3', maxAttrSize) == NULL) ||
- ((rc = system(command)) == -1)) {
- free(buf);
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- free(buf);
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- free(buf);
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, maxAttrSize, buf)) == -1) {
- free(buf);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || buf == NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(max buflen)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, maxAttrSize, buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- if (rlen == maxAttrSize) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, 0, rlen,
- maxAttrSize);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- free(buf);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - directory handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 15)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- if (rlen == ATTR_VALUELEN) {
- if (memcmp
- (buf, ATTR_VALUE,
- ATTR_VALUELEN) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and rlen = %d but unexpected buf %s",
- szFuncName, 0, rlen,
- buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen = %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 16)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 17)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_get_dmattr(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, &attrname, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dmattr - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 18)) {
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_get_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &attrname, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_get_dmattr - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_DMATTR_BASE + 19)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc == remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_remove_dmattr";
-
- /*
- * TEST : dm_remove_dmattr - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_remove_dmattr(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, 0, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, 0, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, 0, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, INVALID_ADDR, 0,
- &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - invalid attrnamep
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
- (dm_attrname_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - attribute not exist
- * EXPECTED: rc = -1, errno = ENOENT
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(attr not exist)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
- &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - file attribute, setdtime zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 7)) {
- int fd;
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file attr, setdtime zero)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
- &attrname);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if (((rc =
- dm_get_dmattr(sid, hanp, hlen,
- DM_NO_TOKEN, &attrname,
- sizeof(buf), buf,
- &rlen)) == -1)
- && (errno == ENOENT)) {
- if ((rc2 == 0)
- && (statfs1.st_ctime ==
- statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime unmodified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
- szFuncName, 0, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - file attribute, setdtime non-zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 8)) {
- int fd;
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file attr, setdtime non-zero)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 1,
- &attrname);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if (((rc =
- dm_get_dmattr(sid, hanp, hlen,
- DM_NO_TOKEN, &attrname,
- sizeof(buf), buf,
- &rlen)) == -1)
- && (errno == ENOENT)) {
- if ((rc2 == 0)
- && (statfs1.st_ctime !=
- statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
- szFuncName, 0, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - directory attribute, setdtime zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 9)) {
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir attr, setdtime zero)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
- &attrname);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if (((rc =
- dm_get_dmattr(sid, hanp, hlen,
- DM_NO_TOKEN, &attrname,
- sizeof(buf), buf,
- &rlen)) == -1)
- && (errno == ENOENT)) {
- if ((rc2 == 0)
- && (statfs1.st_ctime ==
- statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime unmodified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
- szFuncName, 0, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - directory attribute, setdtime non-zero
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 10)) {
- int rc2;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- size_t rlen;
- struct stat statfs1, statfs2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- TIMESTAMP_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir attr, setdtime non-zero)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 1,
- &attrname);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if (((rc =
- dm_get_dmattr(sid, hanp, hlen,
- DM_NO_TOKEN, &attrname,
- sizeof(buf), buf,
- &rlen)) == -1)
- && (errno == ENOENT)) {
- if ((rc2 == 0)
- && (statfs1.st_ctime !=
- statfs2.st_ctime)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dtime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
- szFuncName, 0, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 11)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
- &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_remove_dmattr(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, 0, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_remove_dmattr - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 13)) {
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_remove_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, 0, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_remove_dmattr - invalidated handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
- szFuncName);
- rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
- &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_getall_dmattr";
-
- /*
- * TEST : dm_getall_dmattr - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_getall_dmattr(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, INVALID_ADDR,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen too small)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 1,
- buf, &rlen);
- if (rc == -1 && errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- }
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), (void *)INVALID_ADDR,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - no file attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(no file attr)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- if (rlen == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - one file attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(one file attr)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- LogDmAttrs((dm_attrlist_t *) buf);
- if (rlen ==
- DWALIGN(sizeof(dm_attrlist_t) +
- ATTR_VALUELEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d) %d\n",
- szFuncName, rc, errno, rlen);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - two file attributes
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1)
- || (memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE) ==
- NULL)
- ||
- (memcpy
- (attrname.an_chars, ATTR_NAME2,
- DM_ATTR_NAME_SIZE) == NULL)
- ||
- ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1)) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(two file attr)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- LogDmAttrs((dm_attrlist_t *) buf);
- if (rlen ==
- 2 * DWALIGN(sizeof(dm_attrlist_t) +
- ATTR_VALUELEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d) %d\n",
- szFuncName, rc, errno, rlen);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - multiple file attributes
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
- size_t len;
- size_t totlen;
- int i;
- void *totbuf;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- for (i = 0, len = 0, totlen = 0; i < NUM_ATTRS && rc == 0; i++) {
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- attrname.an_chars[DM_ATTR_NAME_SIZE - 2] =
- '0' + (i / 10);
- attrname.an_chars[DM_ATTR_NAME_SIZE - 1] =
- '0' + (i % 10);
- memcpy(buf + len, DUMMY_STRING, DUMMY_STRLEN);
- len += DUMMY_STRLEN;
- totlen += DWALIGN(len + sizeof(dm_attrlist_t));
- rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, len, buf);
- }
- if (rc != -1) {
- if ((totbuf = malloc(totlen)) == NULL) {
- close(fd);
- remove(DUMMY_FILE);
- }
- }
- if (fd == -1 || rc == -1 || totbuf == NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%d file attr)\n",
- szFuncName, NUM_ATTRS);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- totlen, totbuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- LogDmAttrs((dm_attrlist_t *) totbuf);
- if (rlen == totlen) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d) %d\n",
- szFuncName, rc, errno, rlen);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- free(totbuf);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - one file attribute with non-DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1)
- ||
- ((rc =
- setxattr(DUMMY_FILE, NON_DM_ATTR_NAME,
- NON_DM_ATTR_VALUE, sizeof(NON_DM_ATTR_VALUE),
- 0)) == -1)) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(one file attr with non-DM attr)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- LogDmAttrs((dm_attrlist_t *) buf);
- if (rlen ==
- DWALIGN(sizeof(dm_attrlist_t) +
- ATTR_VALUELEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d) %d\n",
- szFuncName, rc, errno, rlen);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - one directory attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 13)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No claen up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(one dir attr)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- LogDmAttrs((dm_attrlist_t *) buf);
- if (rlen ==
- DWALIGN(sizeof(dm_attrlist_t) +
- ATTR_VALUELEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen %d\n",
- szFuncName, 0, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d) %d\n",
- szFuncName, rc, errno, rlen);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 14)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 15)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_getall_dmattr(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_dmattr - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 16)) {
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_getall_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_getall_dmattr - invalidated handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GETALL_DMATTR_BASE + 17)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
- szFuncName);
- rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_set_fileattr";
-
- /*
- * TEST : dm_set_fileattr - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_set_fileattr(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, DM_AT_UID, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, DM_AT_UID, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, DM_AT_UID, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, INVALID_ADDR,
- DM_AT_UID, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - invalid mask
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #20 (0 returned instead of -1 and
- * EINVAL errno)
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid mask)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_HANDLE, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - invalid attrp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrp)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_UID,
- (dm_fileattr_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_ATIME on file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_atime = DUMMY_TIME;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_ATIME)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_ATIME, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_atime != statfs2.st_atime)
- && (statfs2.st_atime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and atime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but atime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_atime,
- statfs2.st_atime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_MTIME on file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_mtime = DUMMY_TIME;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_MTIME)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_MTIME, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_mtime != statfs2.st_mtime)
- && (statfs2.st_mtime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and mtime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but mtime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_mtime,
- statfs2.st_mtime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_CTIME on file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_ctime = DUMMY_TIME;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_CTIME)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_CTIME, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime != statfs2.st_ctime)
- && (statfs2.st_ctime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and ctime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_DTIME on file with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- fileattr.fa_dtime = DUMMY_TIME;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_DTIME with attr)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime != statfs2.st_ctime)
- && (statfs2.st_ctime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and ctime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_DTIME on file without DM attr
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #21 (dtime updated without any DM
- * attributes)
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_dtime = DUMMY_TIME;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_DTIME without attr)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime == statfs2.st_ctime)
- && (statfs2.st_ctime != DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and ctime unmodified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but ctime modified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_UID on file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_UID)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_UID, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_uid != statfs2.st_uid)
- && (statfs2.st_uid == DUMMY_UID)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and uid modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but uid unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_uid,
- statfs2.st_uid);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_GID on file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 13)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_gid = DUMMY_GID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_GID)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_GID, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_gid != statfs2.st_gid)
- && (statfs2.st_gid == DUMMY_GID)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and gid modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but gid unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_gid,
- statfs2.st_gid);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_MODE on file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_mode = DUMMY_MODE;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_MODE)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_MODE, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_mode != statfs2.st_mode)
- && ((statfs2.st_mode & MODE_MASK) ==
- DUMMY_MODE)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and mode modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but mode unmodified (%x vs %x)\n",
- szFuncName, 0,
- statfs1.st_mode,
- statfs2.st_mode);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_SIZE on file, shrink
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 15)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_size = TMP_FILELEN / 2;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_SIZE, shrink)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_SIZE, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_size != statfs2.st_size)
- && (statfs2.st_size == TMP_FILELEN / 2)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and size modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but size unmodified (%x vs %x)\n",
- szFuncName, 0,
- statfs1.st_size,
- statfs2.st_size);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_SIZE on file, expand
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 16)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_size = TMP_FILELEN * 2;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_SIZE, expand)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_SIZE, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_size != statfs2.st_size)
- && (statfs2.st_size == TMP_FILELEN * 2)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and size modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but size unmodified (%x vs %x)\n",
- szFuncName, 0,
- statfs1.st_size,
- statfs2.st_size);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 17)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_FILE, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_UID, &fileattr);
- rc2 |= stat(DUMMY_FILE, &statfs2);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_ATIME on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 18)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_atime = DUMMY_TIME;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_ATIME)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_ATIME, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_atime != statfs2.st_atime)
- && (statfs2.st_atime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and atime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but atime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_atime,
- statfs2.st_atime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_MTIME on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 19)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_mtime = DUMMY_TIME;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_MTIME)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_MTIME, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_mtime != statfs2.st_mtime)
- && (statfs2.st_mtime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and mtime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but mtime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_mtime,
- statfs2.st_mtime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_CTIME on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 20)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_ctime = DUMMY_TIME;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_CTIME)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_CTIME, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime != statfs2.st_ctime)
- && (statfs2.st_ctime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and ctime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_DTIME on directory with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 21)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- dm_attrname_t attrname;
- char buf[ATTR_LISTLEN];
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- fileattr.fa_dtime = DUMMY_TIME;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, ATTR_VALUELEN, buf)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir DM_AT_DTIME with attr)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime != statfs2.st_ctime)
- && (statfs2.st_ctime == DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and ctime modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_DTIME on directory without DM attribute
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 22)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_dtime = DUMMY_TIME;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir DM_AT_DTIME without attr)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_ctime == statfs2.st_ctime)
- && (statfs2.st_ctime != DUMMY_TIME)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and ctime unmodified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but ctime modified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_ctime,
- statfs2.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_UID on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 23)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_UID)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_UID, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_uid != statfs2.st_uid)
- && (statfs2.st_uid == DUMMY_UID)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and uid modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but uid unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_uid,
- statfs2.st_uid);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_GID on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 24)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_gid = DUMMY_GID;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_GID)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_GID, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_gid != statfs2.st_gid)
- && (statfs2.st_gid == DUMMY_GID)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and gid modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but gid unmodified (%d vs %d)\n",
- szFuncName, 0,
- statfs1.st_gid,
- statfs2.st_gid);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_AT_MODE on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 25)) {
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
- struct stat statfs1, statfs2;
- int rc2;
-
- /* Variation set up */
- fileattr.fa_mode = DUMMY_MODE;
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- rc2 = stat(DUMMY_SUBDIR, &statfs1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_MODE)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_MODE, &fileattr);
- rc2 |= stat(DUMMY_SUBDIR, &statfs2);
- if (rc == 0) {
- if ((rc2 == 0)
- && (statfs1.st_mode != statfs2.st_mode)
- && ((statfs2.st_mode & MODE_MASK) ==
- DUMMY_MODE)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and mode modified\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but mode unmodified (%x vs %x)\n",
- szFuncName, 0,
- statfs1.st_mode,
- statfs2.st_mode);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 26)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_set_fileattr(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, DM_AT_UID, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_fileattr - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 27)) {
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_set_fileattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, DM_AT_UID, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_set_fileattr - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_FILEATTR_BASE + 28)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_fileattr_t fileattr;
-
- /* Variation set up */
- fileattr.fa_uid = DUMMY_UID;
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_UID, &fileattr);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_get_fileattr";
-
- /*
- * TEST : dm_get_fileattr - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_get_fileattr(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, INVALID_ADDR,
- DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - invalid mask
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #22 (0 returned instead of -1 and
- * EINVAL errno)
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid mask)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_HANDLE, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - invalid statp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid statp)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK,
- (dm_stat_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_EMASK on file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
- DMEV_SET(DM_EVENT_CLOSE, eventset);
- DMEV_SET(DM_EVENT_DESTROY, eventset);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_EMASK)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &stat);
- if (rc == 0) {
- if (memcmp
- (&eventset, &stat.dt_emask,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected emask (%llx vs %llx)\n",
- szFuncName, 0, eventset,
- stat.dt_emask);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(eventset);
- rc |=
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- rc |= close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - file DM_AT_PMANR with region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
- dm_region_t region = { 0, 0, DM_REGION_READ };
- dm_boolean_t exactflag;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, 1, ®ion,
- &exactflag)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_PMANR with region)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_PMANR, &stat);
- if (rc == 0) {
- if (stat.dt_pmanreg == DM_TRUE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected pmanreg (%d vs %d)\n",
- szFuncName, 0, DM_TRUE,
- stat.dt_pmanreg);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - file DM_AT_PMANR without region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_PMANR without region)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_PMANR, &stat);
- if (rc == 0) {
- if (stat.dt_pmanreg == DM_FALSE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected pmanreg (%d vs %d)\n",
- szFuncName, 0, DM_FALSE,
- stat.dt_pmanreg);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - file DM_AT_PATTR with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_PATTR with attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_PATTR, &stat);
- if (rc == 0) {
- if (stat.dt_pers == DM_TRUE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
- szFuncName, 0, DM_TRUE,
- stat.dt_pers);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - file DM_AT_PATTR without DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_PATTR without attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_PATTR, &stat);
- if (rc == 0) {
- if (stat.dt_pers == DM_FALSE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
- szFuncName, 0, DM_FALSE,
- stat.dt_pers);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - file DM_AT_DTIME with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- stat.dt_dtime = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_DTIME with attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &stat);
- if (rc == 0) {
- if (stat.dt_dtime != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime not set\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - file DM_AT_DTIME without DM attribute
- * EXPECTED: rc = 0
- *
- * This variation uncovered XFS BUG #23 (dtime updated without any DM
- * attributes)
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 13)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- stat.dt_dtime = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file DM_AT_DTIME without attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &stat);
- if (rc == 0) {
- if (stat.dt_dtime == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime set\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - file DM_AT_STAT
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t statdm;
- struct stat statfs;
- int varStatus;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = stat(DUMMY_FILE, &statfs)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_STAT)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_STAT, &statdm);
- if (rc == 0) {
- varStatus = DMSTAT_PASS;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d\n",
- szFuncName, rc);
- if (statfs.st_dev != statdm.dt_dev) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching dev (%lld vs %lld)\n",
- szFuncName, statfs.st_dev,
- statdm.dt_dev);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_ino != statdm.dt_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching ino (%lld vs %lld)\n",
- szFuncName, statfs.st_ino,
- statdm.dt_ino);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_mode != statdm.dt_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching mode (%d vs %d)\n",
- szFuncName, statfs.st_mode,
- statdm.dt_mode);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_nlink != statdm.dt_nlink) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching nlink (%d vs %d)\n",
- szFuncName, statfs.st_nlink,
- statdm.dt_nlink);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_uid != statdm.dt_uid) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching uid (%d vs %d)\n",
- szFuncName, statfs.st_uid,
- statdm.dt_uid);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_gid != statdm.dt_gid) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching gid (%d vs %d)\n",
- szFuncName, statfs.st_gid,
- statdm.dt_gid);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_rdev != statdm.dt_rdev) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching rdev (%lld vs %lld)\n",
- szFuncName, statfs.st_rdev,
- statdm.dt_rdev);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_size != statdm.dt_size) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching size (%lld vs %lld)\n",
- szFuncName, statfs.st_size,
- statdm.dt_size);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_atime != statdm.dt_atime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching atime (%d vs %d)\n",
- szFuncName, statfs.st_atime,
- statdm.dt_atime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_mtime != statdm.dt_mtime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching mtime (%d vs %d)\n",
- szFuncName, statfs.st_mtime,
- statdm.dt_mtime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_ctime != statdm.dt_ctime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching ctime (%d vs %d)\n",
- szFuncName, statfs.st_ctime,
- statdm.dt_ctime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_blksize != statdm.dt_blksize) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching blksize (%d vs %d)\n",
- szFuncName,
- statfs.st_blksize,
- statdm.dt_blksize);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_blocks != statdm.dt_blocks) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching blocks (%lld vs %lld)\n",
- szFuncName,
- statfs.st_blocks,
- statdm.dt_blocks);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_EMASK on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 15)) {
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
- DMEV_SET(DM_EVENT_CLOSE, eventset);
- DMEV_SET(DM_EVENT_DESTROY, eventset);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_EMASK)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &stat);
- if (rc == 0) {
- if (memcmp
- (&eventset, &stat.dt_emask,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected emask (%llx vs %llx)\n",
- szFuncName, 0, eventset,
- stat.dt_emask);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(eventset);
- rc |=
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_PMANR on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 16)) {
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_PMANR)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_PMANR, &stat);
- if (rc == 0) {
- if (stat.dt_pmanreg == DM_FALSE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected pmanreg (%d vs %d)\n",
- szFuncName, 0, DM_FALSE,
- stat.dt_pmanreg);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_PATTR on directory with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 17)) {
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir DM_AT_PATTR with attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_PATTR, &stat);
- if (rc == 0) {
- if (stat.dt_pers == DM_TRUE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
- szFuncName, 0, DM_TRUE,
- stat.dt_pers);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_PATTR on directory without DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 18)) {
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir DM_AT_PATTR without attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_PATTR, &stat);
- if (rc == 0) {
- if (stat.dt_pers == DM_FALSE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
- szFuncName, 0, DM_FALSE,
- stat.dt_pers);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_DTIME on directory with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 19)) {
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- stat.dt_dtime = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir DM_AT_DTIME with attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &stat);
- if (rc == 0) {
- if (stat.dt_dtime != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime not set\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_DTIME on directory without DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 20)) {
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- stat.dt_dtime = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(dir DM_AT_DTIME without attr)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_DTIME, &stat);
- if (rc == 0) {
- if (stat.dt_dtime == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime set\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_AT_STAT on directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 21)) {
- void *hanp;
- size_t hlen;
- dm_stat_t statdm;
- struct stat statfs;
- int varStatus;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = stat(DUMMY_SUBDIR, &statfs)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_STAT)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_STAT, &statdm);
- if (rc == 0) {
- varStatus = DMSTAT_PASS;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d\n",
- szFuncName, rc);
- if (statfs.st_dev != statdm.dt_dev) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching dev (%lld vs %lld)\n",
- szFuncName, statfs.st_dev,
- statdm.dt_dev);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_ino != statdm.dt_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching ino (%lld vs %lld)\n",
- szFuncName, statfs.st_ino,
- statdm.dt_ino);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_mode != statdm.dt_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching mode (%d vs %d)\n",
- szFuncName, statfs.st_mode,
- statdm.dt_mode);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_nlink != statdm.dt_nlink) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching nlink (%d vs %d)\n",
- szFuncName, statfs.st_nlink,
- statdm.dt_nlink);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_uid != statdm.dt_uid) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching uid (%d vs %d)\n",
- szFuncName, statfs.st_uid,
- statdm.dt_uid);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_gid != statdm.dt_gid) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching gid (%d vs %d)\n",
- szFuncName, statfs.st_gid,
- statdm.dt_gid);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_rdev != statdm.dt_rdev) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching rdev (%lld vs %lld)\n",
- szFuncName, statfs.st_rdev,
- statdm.dt_rdev);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_size != statdm.dt_size) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching size (%lld vs %lld)\n",
- szFuncName, statfs.st_size,
- statdm.dt_size);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_atime != statdm.dt_atime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching atime (%d vs %d)\n",
- szFuncName, statfs.st_atime,
- statdm.dt_atime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_mtime != statdm.dt_mtime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching mtime (%d vs %d)\n",
- szFuncName, statfs.st_mtime,
- statdm.dt_mtime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_ctime != statdm.dt_ctime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching ctime (%d vs %d)\n",
- szFuncName, statfs.st_ctime,
- statdm.dt_ctime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_blksize != statdm.dt_blksize) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching blksize (%d vs %d)\n",
- szFuncName,
- statfs.st_blksize,
- statdm.dt_blksize);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_blocks != statdm.dt_blocks) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching blocks (%lld vs %lld)\n",
- szFuncName,
- statfs.st_blocks,
- statdm.dt_blocks);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 22)) {
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 23)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_get_fileattr(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_fileattr - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 24)) {
- dm_stat_t stat;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_get_fileattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_get_fileattr - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_FILEATTR_BASE + 25)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_stat_t stat;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &stat);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_init_attrloc";
-
- /*
- * TEST : dm_init_attrloc - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 1)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_init_attrloc(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 2)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_init_attrloc(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_init_attrloc(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 4)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_init_attrloc(sid, hanp, hlen, INVALID_ADDR,
- &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - invalid locp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 5)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid locp)\n",
- szFuncName);
- rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- (dm_attrloc_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 6)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - directory handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 7)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "loc = %lld\n", loc);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 8)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "loc = %lld\n", loc);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 9)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_init_attrloc(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_init_attrloc - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 10)) {
- dm_attrloc_t loc;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_init_attrloc(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_init_attrloc - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 11)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rmdir(DUMMY_SUBDIR)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_get_dirattrs";
-
- /*
- * TEST : dm_get_dirattrs - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 1)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_get_dirattrs(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, DM_AT_EMASK, &loc,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 2)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, DM_AT_EMASK, &loc,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid hlen
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, DM_AT_EMASK, &loc,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 4)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, INVALID_ADDR,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid mask
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #24 (0 returned instead of -1 and
- * EINVAL errno)
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 5)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid mask)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_SIZE, &loc, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid locp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 6)) {
- void *hanp;
- size_t hlen;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid locp)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK,
- (dm_attrloc_t *) INVALID_ADDR,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid loc
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 7)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- loc = INVALID_ADDR;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid loc)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid buflen
- * EXPECTED: rc = 1
- *
- * This variation uncovered XFS BUG #26 (-1 and E2BIG errno returned
- * instead of 1)
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 8)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, 0, buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- DMVAR_ENDPASSEXP(szFuncName, 1, rc);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 9)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- (void *)INVALID_ADDR, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 10)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 11)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_HANDLE
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 12)) {
- void *dhanp, *fhanp;
- size_t dhlen, fhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
- &fhlen)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1) {
- dm_handle_free(fhanp, fhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_HANDLE)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_HANDLE, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_HANDLE);
- if (entry != NULL) {
- if (dm_handle_cmp
- (fhanp, fhlen,
- DM_GET_VALUE(entry, dt_handle,
- void *),
- DM_GET_LEN(entry,
- dt_handle)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but handles NOT same\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_EMASK
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 13)) {
- void *dhanp, *fhanp;
- size_t dhlen, fhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
- dm_eventset_t eventset;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
- DMEV_SET(DM_EVENT_CLOSE, eventset);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
- &fhlen)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_set_eventlist(sid, fhanp, fhlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- dm_handle_free(fhanp, fhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_EMASK)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_EMASK);
- if (entry != NULL) {
- if (eventset == entry->dt_emask) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but emasks NOT same (%llx vs %llx)\n",
- szFuncName, 0,
- eventset,
- entry->dt_emask);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_PMANR with region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 14)) {
- void *dhanp, *fhanp;
- size_t dhlen, fhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
- dm_region_t region = { 0, 0, DM_REGION_READ };
- dm_boolean_t exactflag;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
- &fhlen)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_set_region(sid, fhanp, fhlen, DM_NO_TOKEN, 1,
- ®ion, &exactflag)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- dm_handle_free(fhanp, fhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_PMANR with region)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_PMANR, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_PMANR);
- if (entry != NULL) {
- if (entry->dt_pmanreg == DM_TRUE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but pmanreg NOT same (%d vs %d)\n",
- szFuncName, 0,
- entry->dt_pmanreg,
- DM_TRUE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_PMANR without region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 15)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- rc |= dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN, &loc);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_PMANR without region)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_PMANR, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_PMANR);
- if (entry != NULL) {
- if (entry->dt_pmanreg == DM_FALSE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but pmanreg NOT same (%d vs %d)\n",
- szFuncName, 0,
- entry->dt_pmanreg,
- DM_FALSE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_PATTR with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 16)) {
- void *dhanp, *fhanp;
- size_t dhlen, fhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
- dm_attrname_t attrname;
- char attrbuf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(attrbuf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
- &fhlen)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_set_dmattr(sid, fhanp, fhlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(attrbuf),
- attrbuf)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- dm_handle_free(fhanp, fhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_PATTR with DM attr)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_PATTR, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_PATTR);
- if (entry != NULL) {
- if (entry->dt_pers == DM_TRUE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but pers NOT same (%d vs %d)\n",
- szFuncName, 0,
- entry->dt_pers,
- DM_TRUE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_PATTR without DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 17)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_PATTR without DM attr)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_PATTR, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_PATTR);
- if (entry != NULL) {
- if (entry->dt_pers == DM_FALSE) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but pers NOT same (%d vs %d)\n",
- szFuncName, 0,
- entry->dt_pers,
- DM_FALSE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_DTIME with DM attribute
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 18)) {
- void *dhanp, *fhanp;
- size_t dhlen, fhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
- dm_attrname_t attrname;
- char attrbuf[ATTR_VALUELEN];
- struct stat statfs;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(attrbuf, ATTR_VALUE, ATTR_VALUELEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
- &fhlen)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else if (((rc = stat(DUMMY_SUBDIR_FILE, &statfs)) == -1) ||
- ((rc =
- dm_set_dmattr(sid, fhanp, fhlen, DM_NO_TOKEN,
- &attrname, 0, sizeof(attrbuf),
- attrbuf)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- dm_handle_free(fhanp, fhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_DTIME with DM attr)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_DTIME, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_DTIME);
- if (entry != NULL) {
- if (entry->dt_dtime == statfs.st_ctime) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime NOT same (%d vs %d)\n",
- szFuncName, 0,
- entry->dt_dtime,
- statfs.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_DTIME without DM attribute
- * EXPECTED: rc = 0
- *
- * This variation uncovered XFS BUG #25 (dtime updated without any DM
- * attributes)
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 19)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
- struct stat statfs;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else if (((rc = stat(DUMMY_SUBDIR_FILE, &statfs)) == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_DTIME without DM attr)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_DTIME, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_DTIME);
- if (entry != NULL) {
- if (entry->dt_dtime != statfs.st_ctime) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but dtime same (%d vs %d)\n",
- szFuncName, 0,
- entry->dt_dtime,
- statfs.st_ctime);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_CFLAG with no change
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 20)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf1, 0, ATTR_LISTLEN);
- memset(buf2, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
- &rlen)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_CFLAG with no change)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf2),
- buf2, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry1 =
- GetDirEntry(buf1, DUMMY_FILE);
- dm_stat_t *entry2 =
- GetDirEntry(buf2, DUMMY_FILE);
- LogDirAttrs(buf2, DM_AT_CFLAG);
- if ((entry1 != NULL) && (entry2 != NULL)) {
- if (entry1->dt_change ==
- entry2->dt_change) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but change not same (%d vs %d)\n",
- szFuncName, 0,
- entry1->dt_change,
- entry2->dt_change);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_CFLAG with data change
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 21)) {
- int fd;
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf1, 0, ATTR_LISTLEN);
- memset(buf2, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((fd = open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
- &rlen)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN ? -1 : 0) == 1))) {
- close(fd);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_CFLAG with data change)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf2),
- buf2, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry1 =
- GetDirEntry(buf1, DUMMY_FILE);
- dm_stat_t *entry2 =
- GetDirEntry(buf2, DUMMY_FILE);
- LogDirAttrs(buf2, DM_AT_CFLAG);
- if ((entry1 != NULL) && (entry2 != NULL)) {
- if (entry1->dt_change !=
- entry2->dt_change) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but change same (%d vs %d)\n",
- szFuncName, 0,
- entry1->dt_change,
- entry2->dt_change);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_CFLAG with metadata change
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 22)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf1, 0, ATTR_LISTLEN);
- memset(buf2, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
- &rlen)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- chown(DUMMY_SUBDIR_FILE, DUMMY_UID,
- DUMMY_GID)) == -1)) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_CFLAG with metadata change)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf2),
- buf2, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry1 =
- GetDirEntry(buf1, DUMMY_FILE);
- dm_stat_t *entry2 =
- GetDirEntry(buf2, DUMMY_FILE);
- LogDirAttrs(buf2, DM_AT_CFLAG);
- if ((entry1 != NULL) && (entry2 != NULL)) {
- if (entry1->dt_change !=
- entry2->dt_change) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but change same (%d vs %d)\n",
- szFuncName, 0,
- entry1->dt_change,
- entry2->dt_change);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_CFLAG with DM attribute change
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 23)) {
- void *dhanp, *fhanp;
- size_t dhlen, fhlen;
- dm_attrloc_t loc;
- char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
- size_t rlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(buf1, 0, ATTR_LISTLEN);
- memset(buf2, 0, ATTR_LISTLEN);
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
- &fhlen)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
- &rlen)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- dm_set_dmattr(sid, fhanp, fhlen, DM_NO_TOKEN,
- &attrname, 0, 0, NULL)) == -1)) {
- dm_handle_free(fhanp, fhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_CFLAG with DM attr change)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf2),
- buf2, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry1 =
- GetDirEntry(buf1, DUMMY_FILE);
- dm_stat_t *entry2 =
- GetDirEntry(buf2, DUMMY_FILE);
- LogDirAttrs(buf2, DM_AT_CFLAG);
- if ((entry1 != NULL) && (entry2 != NULL)) {
- if (entry1->dt_change !=
- entry2->dt_change) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but change same (%d vs %d)\n",
- szFuncName, 0,
- entry1->dt_change,
- entry2->dt_change);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_CFLAG with non-DM attribute change
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 23)) {
- void *dhanp, *fhanp;
- size_t dhlen, fhlen;
- dm_attrloc_t loc;
- char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
- size_t rlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(buf1, 0, ATTR_LISTLEN);
- memset(buf2, 0, ATTR_LISTLEN);
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
- &fhlen)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
- &rlen)) == -1)
- ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- ||
- ((rc =
- setxattr(DUMMY_SUBDIR_FILE, NON_DM_ATTR_NAME,
- NON_DM_ATTR_VALUE, sizeof(NON_DM_ATTR_VALUE),
- 0)) == -1)) {
- dm_handle_free(fhanp, fhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_CFLAG with non-DM attr change)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_CFLAG, &loc, sizeof(buf2),
- buf2, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry1 =
- GetDirEntry(buf1, DUMMY_FILE);
- dm_stat_t *entry2 =
- GetDirEntry(buf2, DUMMY_FILE);
- LogDirAttrs(buf2, DM_AT_CFLAG);
- if ((entry1 != NULL) && (entry2 != NULL)) {
- if (entry1->dt_change !=
- entry2->dt_change) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but change same (%d vs %d)\n",
- szFuncName, 0,
- entry1->dt_change,
- entry2->dt_change);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 24)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
- struct stat statfs;
- int varStatus;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = stat(DUMMY_SUBDIR_FILE, &statfs)) == -1)) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_STAT)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_STAT);
- if (entry != NULL) {
- varStatus = DMSTAT_PASS;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d\n",
- szFuncName, rc);
- if (statfs.st_dev != entry->dt_dev) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching dev (%lld vs %lld)\n",
- szFuncName,
- statfs.st_dev,
- entry->dt_dev);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_ino != entry->dt_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching ino (%lld vs %lld)\n",
- szFuncName,
- statfs.st_ino,
- entry->dt_ino);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_mode != entry->dt_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching mode (%d vs %d)\n",
- szFuncName,
- statfs.st_mode,
- entry->dt_mode);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_nlink != entry->dt_nlink) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching nlink (%d vs %d)\n",
- szFuncName,
- statfs.st_nlink,
- entry->dt_nlink);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_uid != entry->dt_uid) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching uid (%d vs %d)\n",
- szFuncName,
- statfs.st_uid,
- entry->dt_uid);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_gid != entry->dt_gid) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching gid (%d vs %d)\n",
- szFuncName,
- statfs.st_gid,
- entry->dt_gid);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_rdev != entry->dt_rdev) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching rdev (%lld vs %lld)\n",
- szFuncName,
- statfs.st_rdev,
- entry->dt_rdev);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_size != entry->dt_size) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching size (%lld vs %lld)\n",
- szFuncName,
- statfs.st_size,
- entry->dt_size);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_atime != entry->dt_atime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching atime (%d vs %d)\n",
- szFuncName,
- statfs.st_atime,
- entry->dt_atime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_mtime != entry->dt_mtime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching mtime (%d vs %d)\n",
- szFuncName,
- statfs.st_mtime,
- entry->dt_mtime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_ctime != entry->dt_ctime) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching ctime (%d vs %d)\n",
- szFuncName,
- statfs.st_ctime,
- entry->dt_ctime);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_blksize !=
- entry->dt_blksize) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching blksize (%d vs %d)\n",
- szFuncName,
- statfs.st_blksize,
- entry->dt_blksize);
- varStatus = DMSTAT_FAIL;
- }
- if (statfs.st_blocks !=
- entry->dt_blocks) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with nonmatching blocks (%lld vs %lld)\n",
- szFuncName,
- statfs.st_blocks,
- entry->dt_blocks);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT returned over two calls
- * EXPECTED: rc = 1, 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 25)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf1[2 * ATTR_SMALLLEN];
- char buf2[ATTR_SMALLLEN + 1];
- size_t rlen1, rlen2;
- dm_stat_t *entry;
- int rc1, rc2;
- int varStatus;
- int num;
-
- /* Variation set up */
- memset(buf1, 0, sizeof(buf1));
- memset(buf2, 0, sizeof(buf2));
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT over two calls)\n",
- szFuncName);
- rc1 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf1),
- buf1, &rlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "1st call: rc %d, rlen %d, loc %llx\n", rc1,
- rlen1, loc);
- rc2 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf2),
- buf2, &rlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "2nd call: rc %d, rlen %d, loc %llx\n", rc2,
- rlen2, loc);
- varStatus = DMSTAT_PASS;
- if (rc1 == 1) {
- if (((num = GetNumDirEntry(buf1)) == 2)
- && (rlen1 >= 2 * MIN_ENTRYLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "1st call attrs:\n");
- LogDirAttrs(buf1, DM_AT_STAT);
- if (((entry =
- GetDirEntry(buf1,
- CURRENT_DIR)) != NULL)
- &&
- ((entry =
- GetDirEntry(buf1,
- PARENT_DIR)) !=
- NULL)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 1st call returned expected rc = %d and %d entries %s and %s in buffer\n",
- szFuncName, rc1,
- num, CURRENT_DIR,
- PARENT_DIR);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned expected rc = %d but entries %s and/or %s not in buffer\n",
- szFuncName, rc1,
- CURRENT_DIR,
- PARENT_DIR);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc1, rlen1,
- num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned unexpected rc = %d\n",
- szFuncName, rc1);
- varStatus = DMSTAT_FAIL;
- }
- if (rc2 == 0) {
- if (((num = GetNumDirEntry(buf2)) == 1)
- && (rlen2 >= MIN_ENTRYLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "2nd call attrs:\n");
- LogDirAttrs(buf2, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf2,
- DUMMY_FILE)) != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 2nd call returned expected rc = %d and %d entry %s in buffer\n",
- szFuncName, rc2,
- num, DUMMY_FILE);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned expected rc = %d but entry %s not in buffer\n",
- szFuncName, rc2,
- DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc2, rlen2,
- num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned unexpected rc = %d\n",
- szFuncName, rc2);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT returned over three calls,
- * third buffer too small
- * EXPECTED: rc = 1, 1, 1
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 26)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf1[ATTR_SMALLLEN];
- char buf2[ATTR_SMALLLEN];
- char buf3[ATTR_SMALLLEN / 2];
- size_t rlen1, rlen2, rlen3;
- dm_stat_t *entry;
- int rc1, rc2, rc3;
- int varStatus;
- int num;
-
- /* Variation set up */
- memset(buf1, 0, sizeof(buf1));
- memset(buf2, 0, sizeof(buf2));
- memset(buf3, 0, sizeof(buf3));
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT over three calls, third buf too small)\n",
- szFuncName);
- rc1 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf1),
- buf1, &rlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "1st call: rc %d, rlen %d, loc %llx\n", rc1,
- rlen1, loc);
- rc2 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf2),
- buf2, &rlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "2nd call: rc %d, rlen %d, loc %llx\n", rc2,
- rlen2, loc);
- rc3 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf3),
- buf3, &rlen3);
- DMLOG_PRINT(DMLVL_DEBUG,
- "3rd call: rc %d, rlen %d, loc %llx\n", rc3,
- rlen3, loc);
- varStatus = DMSTAT_PASS;
- if (rc1 == 1) {
- if (((num = GetNumDirEntry(buf1)) == 1)
- && (rlen1 >= MIN_ENTRYLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "1st call attrs:\n");
- LogDirAttrs(buf1, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf1,
- CURRENT_DIR)) !=
- NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 1st call returned expected rc = %d and %d entry %s in buffer\n",
- szFuncName, rc1,
- num, CURRENT_DIR);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned expected rc = %d but entry %s not in buffer\n",
- szFuncName, rc1,
- CURRENT_DIR);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc1, rlen1,
- num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned unexpected rc = %d\n",
- szFuncName, rc1);
- varStatus = DMSTAT_FAIL;
- }
- if (rc2 == 1) {
- if (((num = GetNumDirEntry(buf2)) == 1)
- && (rlen2 >= MIN_ENTRYLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "2nd call attrs:\n");
- LogDirAttrs(buf2, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf2,
- PARENT_DIR)) != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 2nd call returned expected rc = %d and %d entry %s in buffer\n",
- szFuncName, rc2,
- num, PARENT_DIR);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned expected rc = %d but entry %s not in buffer\n",
- szFuncName, rc2,
- PARENT_DIR);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc2, rlen2,
- num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned unexpected rc = %d\n",
- szFuncName, rc2);
- varStatus = DMSTAT_FAIL;
- }
- if (rc3 == 1) {
- if (rlen3 == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 3rd call returned expected rc = %d and empty buffer\n",
- szFuncName, rc3);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 3rd call returned expected rc = %d but unexpected rlen = %d\n",
- szFuncName, rc3, rlen3);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 3rd call returned unexpected rc = %d\n",
- szFuncName, rc3);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT returned over three calls
- * EXPECTED: rc = 1, 1, 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 27)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf1[ATTR_SMALLLEN];
- char buf2[ATTR_SMALLLEN];
- char buf3[ATTR_SMALLLEN];
- size_t rlen1, rlen2, rlen3;
- dm_stat_t *entry;
- int rc1, rc2, rc3;
- int varStatus;
- int num;
-
- /* Variation set up */
- memset(buf1, 0, sizeof(buf1));
- memset(buf2, 0, sizeof(buf2));
- memset(buf3, 0, sizeof(buf3));
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT over three calls)\n",
- szFuncName);
- rc1 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf1),
- buf1, &rlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "1st call: rc %d, rlen %d, loc %llx\n", rc1,
- rlen1, loc);
- rc2 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf2),
- buf2, &rlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "2nd call: rc %d, rlen %d, loc %llx\n", rc2,
- rlen2, loc);
- rc3 =
- dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf3),
- buf3, &rlen3);
- DMLOG_PRINT(DMLVL_DEBUG,
- "3rd call: rc %d, rlen %d, loc %llx\n", rc3,
- rlen3, loc);
- varStatus = DMSTAT_PASS;
- if (rc1 == 1) {
- if (((num = GetNumDirEntry(buf1)) == 1)
- && (rlen1 >= MIN_ENTRYLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "1st call attrs:\n");
- LogDirAttrs(buf1, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf1,
- CURRENT_DIR)) !=
- NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 1st call returned expected rc = %d and %d entry %s in buffer\n",
- szFuncName, rc1,
- num, CURRENT_DIR);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned expected rc = %d but entry %s not in buffer\n",
- szFuncName, rc1,
- CURRENT_DIR);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned expected rc = %d but unexpected rlen = %d\n and/or number of entries in buffer %d",
- szFuncName, rc1, rlen1,
- num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call returned unexpected rc = %d\n",
- szFuncName, rc1);
- varStatus = DMSTAT_FAIL;
- }
- if (rc2 == 1) {
- if (((num = GetNumDirEntry(buf2)) == 1)
- && (rlen2 >= MIN_ENTRYLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "2nd call attrs:\n");
- LogDirAttrs(buf2, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf2,
- PARENT_DIR)) != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 2nd call returned expected rc = %d and %d entry %s in buffer\n",
- szFuncName, rc2,
- num, PARENT_DIR);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned expected rc = %d but entry %s not in buffer\n",
- szFuncName, rc2,
- PARENT_DIR);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc2, rlen2,
- num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call returned unexpected rc = %d\n",
- szFuncName, rc2);
- varStatus = DMSTAT_FAIL;
- }
- if (rc3 == 0) {
- if (((num = GetNumDirEntry(buf3)) == 1)
- && (rlen3 >= MIN_ENTRYLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "3rd call attrs:\n");
- LogDirAttrs(buf3, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf3,
- DUMMY_FILE)) != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s 3rd call returned expected rc = %d and %d entry %s in buffer\n",
- szFuncName, rc3,
- num, DUMMY_FILE);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 3rd call returned expected rc = %d but entry %s not in buffer\n",
- szFuncName, rc3,
- DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 3rd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc3, rlen3,
- num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s 3rd call returned unexpected rc = %d\n",
- szFuncName, rc3);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT with one buffer (files
- * returned from jfs_readdir > files fit in buffer)
- * EXPECTED: rc = 1
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 28)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_SMALLLEN * (DIRENTS_FILES - 1)];
- size_t rlen;
- dm_stat_t *entry;
- int varStatus;
- int i;
- char *filename;
- int num;
-
- /* Variation set up */
- memset(buf, 0, sizeof(buf));
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else {
- for (i = 0; i < NUM_FILES && rc == 0; i++) {
- sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
- DUMMY_SUBDIR_FILE, i);
- rc = system(command);
- }
- if ((rc == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- }
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT with %d files)\n",
- szFuncName, DIRENTS_FILES - 1);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- varStatus = DMSTAT_PASS;
- if (rc == 1) {
- if (((num =
- GetNumDirEntry(buf)) == DIRENTS_FILES - 1)
- && (rlen >=
- (DIRENTS_FILES - 1) * MIN_ENTRYLEN)) {
- filename = strchr(command, '/') + 1;
- DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
- LogDirAttrs(buf, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf,
- filename)) == NULL) {
- if (((entry =
- GetLastDirEntry(buf)) !=
- NULL)
- && (entry->dt_compname.
- vd_length > 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
- szFuncName,
- rc, num,
- filename);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but empty entry in buffer\n",
- szFuncName,
- rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but entry %s in buffer\n",
- szFuncName, rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc, rlen, num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d\n",
- szFuncName, rc);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT with one buffer (files
- * returned from jfs_readdir > files fit in buffer)
- * EXPECTED: rc = 1
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 29)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_SMALLLEN * DIRENTS_FILES];
- size_t rlen;
- dm_stat_t *entry;
- int varStatus;
- int i;
- char *filename;
- int num;
-
- /* Variation set up */
- memset(buf, 0, sizeof(buf));
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else {
- for (i = 0; i < NUM_FILES && rc == 0; i++) {
- sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
- DUMMY_SUBDIR_FILE, i);
- rc = system(command);
- }
- if ((rc == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- }
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT with %d files)\n",
- szFuncName, DIRENTS_FILES);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- varStatus = DMSTAT_PASS;
- if (rc == 1) {
- if (((num =
- GetNumDirEntry(buf)) == DIRENTS_FILES)
- && (rlen >= DIRENTS_FILES * MIN_ENTRYLEN)) {
- filename = strchr(command, '/') + 1;
- DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
- LogDirAttrs(buf, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf,
- filename)) == NULL) {
- if (((entry =
- GetLastDirEntry(buf)) !=
- NULL)
- && (entry->dt_compname.
- vd_length > 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
- szFuncName,
- rc, num,
- filename);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but empty entry in buffer\n",
- szFuncName,
- rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but entry %s in buffer\n",
- szFuncName, rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc, rlen, num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d\n",
- szFuncName, rc);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT with one buffer (files
- * returned from jfs_readdir > files fit in buffer)
- * EXPECTED: rc = 1
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 30)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_SMALLLEN * (DIRENTS_FILES + 1)];
- size_t rlen;
- dm_stat_t *entry;
- int varStatus;
- int i;
- char *filename;
- int num;
-
- /* Variation set up */
- memset(buf, 0, sizeof(buf));
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else {
- for (i = 0; i < NUM_FILES && rc == 0; i++) {
- sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
- DUMMY_SUBDIR_FILE, i);
- rc = system(command);
- }
- if ((rc == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- }
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT with %d files)\n",
- szFuncName, DIRENTS_FILES + 1);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- varStatus = DMSTAT_PASS;
- if (rc == 1) {
- if (((num =
- GetNumDirEntry(buf)) == DIRENTS_FILES + 1)
- && (rlen >=
- (DIRENTS_FILES + 1) * MIN_ENTRYLEN)) {
- filename = strchr(command, '/') + 1;
- DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
- LogDirAttrs(buf, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf,
- filename)) == NULL) {
- if (((entry =
- GetLastDirEntry(buf)) !=
- NULL)
- && (entry->dt_compname.
- vd_length > 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
- szFuncName,
- rc, num,
- filename);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but empty entry in buffer\n",
- szFuncName,
- rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but entry %s in buffer\n",
- szFuncName, rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc, rlen, num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d\n",
- szFuncName, rc);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT with one buffer (files
- * returned from jfs_readdir > files fit in buffer)
- * EXPECTED: rc = 1
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 31)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_SMALLLEN * ((2 * DIRENTS_FILES) - 1)];
- size_t rlen;
- dm_stat_t *entry;
- int varStatus;
- int i;
- char *filename;
- int num;
-
- /* Variation set up */
- memset(buf, 0, sizeof(buf));
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else {
- for (i = 0; i < NUM_FILES && rc == 0; i++) {
- sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
- DUMMY_SUBDIR_FILE, i);
- rc = system(command);
- }
- if ((rc == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- }
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT with %d files)\n",
- szFuncName, (2 * DIRENTS_FILES) - 1);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- varStatus = DMSTAT_PASS;
- if (rc == 1) {
- if (((num =
- GetNumDirEntry(buf)) ==
- (2 * DIRENTS_FILES) - 1)
- && (rlen >=
- ((2 * DIRENTS_FILES) -
- 1) * MIN_ENTRYLEN)) {
- filename = strchr(command, '/') + 1;
- DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
- LogDirAttrs(buf, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf,
- filename)) == NULL) {
- if (((entry =
- GetLastDirEntry(buf)) !=
- NULL)
- && (entry->dt_compname.
- vd_length > 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
- szFuncName,
- rc, num,
- filename);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but empty entry in buffer\n",
- szFuncName,
- rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but entry %s in buffer\n",
- szFuncName, rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc, rlen, num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d\n",
- szFuncName, rc);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT with one buffer (files
- * returned from jfs_readdir > files fit in buffer)
- * EXPECTED: rc = 1
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 32)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_SMALLLEN * (2 * DIRENTS_FILES)];
- size_t rlen;
- dm_stat_t *entry;
- int varStatus;
- int i;
- char *filename;
- int num;
-
- /* Variation set up */
- memset(buf, 0, sizeof(buf));
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else {
- for (i = 0; i < NUM_FILES && rc == 0; i++) {
- sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
- DUMMY_SUBDIR_FILE, i);
- rc = system(command);
- }
- if ((rc == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- }
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT with %d files)\n",
- szFuncName, 2 * DIRENTS_FILES);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- varStatus = DMSTAT_PASS;
- if (rc == 1) {
- if (((num =
- GetNumDirEntry(buf)) == 2 * DIRENTS_FILES)
- && (rlen >=
- (2 * DIRENTS_FILES) * MIN_ENTRYLEN)) {
- filename = strchr(command, '/') + 1;
- DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
- LogDirAttrs(buf, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf,
- filename)) == NULL) {
- if (((entry =
- GetLastDirEntry(buf)) !=
- NULL)
- && (entry->dt_compname.
- vd_length > 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
- szFuncName,
- rc, num,
- filename);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but empty entry in buffer\n",
- szFuncName,
- rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but entry %s in buffer\n",
- szFuncName, rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc, rlen, num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d\n",
- szFuncName, rc);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT with one buffer (files
- * returned from jfs_readdir > files fit in buffer)
- * EXPECTED: rc = 1
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 33)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_SMALLLEN * ((2 * DIRENTS_FILES) + 1)];
- size_t rlen;
- dm_stat_t *entry;
- int varStatus;
- int i;
- char *filename;
- int num;
-
- /* Variation set up */
- memset(buf, 0, sizeof(buf));
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else {
- for (i = 0; i < NUM_FILES && rc == 0; i++) {
- sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
- DUMMY_SUBDIR_FILE, i);
- rc = system(command);
- }
- if ((rc == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- }
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT with %d files)\n",
- szFuncName, (2 * DIRENTS_FILES) + 1);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- varStatus = DMSTAT_PASS;
- if (rc == 1) {
- if (((num =
- GetNumDirEntry(buf)) ==
- (2 * DIRENTS_FILES) + 1)
- && (rlen >=
- ((2 * DIRENTS_FILES) +
- 1) * MIN_ENTRYLEN)) {
- filename = strchr(command, '/') + 1;
- DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
- LogDirAttrs(buf, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf,
- filename)) == NULL) {
- if (((entry =
- GetLastDirEntry(buf)) !=
- NULL)
- && (entry->dt_compname.
- vd_length > 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
- szFuncName,
- rc, num,
- filename);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but empty entry in buffer\n",
- szFuncName,
- rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but entry %s in buffer\n",
- szFuncName, rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc, rlen, num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d\n",
- szFuncName, rc);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_STAT with one buffer (files
- * returned from jfs_readdir < files fit in buffer)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 34)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_BIGLISTLEN];
- size_t rlen;
- dm_stat_t *entry;
- int varStatus;
- int i;
- char *filename;
- int num;
-
- /* Variation set up */
- memset(buf, 0, sizeof(buf));
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else {
- for (i = 0; i < NUM_FILES && rc == 0; i++) {
- sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
- DUMMY_SUBDIR_FILE, i);
- rc = system(command);
- }
- if ((rc == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- }
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_AT_STAT with %d files)\n",
- szFuncName, NUM_FILES + 2);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_STAT, &loc, sizeof(buf), buf,
- &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- varStatus = DMSTAT_PASS;
- if (rc == 0) {
- if (((num =
- GetNumDirEntry(buf)) == NUM_FILES + 2)
- && (rlen >=
- (NUM_FILES + 2) * MIN_ENTRYLEN)) {
- filename = strchr(command, '/') + 1;
- DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
- LogDirAttrs(buf, DM_AT_STAT);
- if ((entry =
- GetDirEntry(buf,
- filename)) != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d, expected number of entries in buffer %d, and entry %s in buffer\n",
- szFuncName, rc, num,
- filename);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but entry %s not in buffer\n",
- szFuncName, rc,
- filename);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
- szFuncName, rc, rlen, num);
- varStatus = DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d\n",
- szFuncName, rc);
- varStatus = DMSTAT_FAIL;
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_HANDLE with link
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 35)) {
- void *dhanp, *fhanp1, *fhanp2;
- size_t dhlen, fhlen1, fhlen2;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = system(command)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp1,
- &fhlen1)) == -1) {
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = link(DUMMY_SUBDIR_FILE, DUMMY_SUBDIR_LINK)) ==
- -1) {
- dm_handle_free(fhanp1, fhlen1);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_LINK, &fhanp2,
- &fhlen2)) == -1) {
- unlink(DUMMY_SUBDIR_LINK);
- dm_handle_free(fhanp1, fhlen1);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1) {
- dm_handle_free(fhanp2, fhlen2);
- unlink(DUMMY_SUBDIR_LINK);
- dm_handle_free(fhanp1, fhlen1);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_HANDLE with link)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_HANDLE, &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry1 =
- GetDirEntry(buf, DUMMY_FILE);
- dm_stat_t *entry2 =
- GetDirEntry(buf, DUMMY_LINK);
- LogDirAttrs(buf, DM_AT_HANDLE);
- if (entry1 != NULL) {
- if (dm_handle_cmp
- (fhanp1, fhlen1,
- DM_GET_VALUE(entry1, dt_handle,
- void *),
- DM_GET_LEN(entry1,
- dt_handle)) == 0) {
- if (entry2 != NULL) {
- if (dm_handle_cmp
- (fhanp2, fhlen2,
- DM_GET_VALUE
- (entry2, dt_handle,
- void *),
- DM_GET_LEN(entry2,
- dt_handle))
- == 0) {
- DMLOG_PRINT
- (DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName,
- 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT
- (DMLVL_ERR,
- "%s failed with expected rc = %d but link handles NOT same\n",
- szFuncName,
- 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName,
- 0,
- DUMMY_LINK);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but file handles NOT same\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= remove(DUMMY_SUBDIR_LINK);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- dm_handle_free(fhanp1, fhlen1);
- dm_handle_free(fhanp2, fhlen2);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_AT_EMASK (verify no handle)
- * EXPECTED: rc = 0
- *
- * This variation uncovered XFS BUG #28 (handle returned when
- * DM_AT_HANDLE not set in mask)
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 36)) {
- void *dhanp;
- size_t dhlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- memset(buf, 0, ATTR_LISTLEN);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
- &dhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if (((rc = system(command)) == -1) ||
- ((rc =
- dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
- &loc)) == -1)) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(~DM_AT_HANDLE)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
- DM_AT_ALL_DIRATTRS &
- (~DM_AT_HANDLE), &loc, sizeof(buf),
- buf, &rlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "call: rc %d, loc %lld, rlen %d\n", rc, loc,
- rlen);
- if (rc == 0) {
- dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
- LogDirAttrs(buf, DM_AT_ALL_DIRATTRS);
- if (entry != NULL) {
- if ((entry->dt_handle.vd_offset == 0)
- && (entry->dt_handle.vd_length ==
- 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but handle non-zero (offset %d, length %d)\n",
- szFuncName, 0,
- entry->dt_handle.
- vd_offset,
- entry->dt_handle.
- vd_length);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unable to find entry %s",
- szFuncName, 0, DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 37)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- remove(DUMMY_FILE);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 38)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if (((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1)
- || ((rc = system(command)) == -1)) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_get_dirattrs(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, DM_AT_EMASK, &loc,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 39)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_dirattrs - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_DIRATTRS_BASE + 40)) {
- void *hanp;
- size_t hlen;
- dm_attrloc_t loc;
- char buf[ATTR_LISTLEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
- &loc)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = rmdir(DUMMY_SUBDIR)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
- DM_AT_EMASK, &loc, sizeof(buf),
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_set_inherit";
-
- /*
- * TEST : dm_set_inherit - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_set_inherit(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_inherit - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_set_inherit(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_inherit - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_set_inherit(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_inherit - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_set_inherit(sid, hanp, hlen, INVALID_ADDR,
- &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_inherit - invalid attrnamep
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
- szFuncName);
- rc = dm_set_inherit(sid, hanp, hlen, DM_NO_TOKEN,
- (dm_attrname_t *) INVALID_ADDR, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc,
- persInheritAttr ? EFAULT : ENOSYS);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_inherit - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_set_inherit(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_inherit - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 7)) {
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_set_inherit(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_set_inherit - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_set_inherit(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_inherit - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_INHERIT_BASE + 9)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_set_inherit(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_clear_inherit";
-
- /*
- * TEST : dm_clear_inherit - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_clear_inherit(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_clear_inherit - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_clear_inherit(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_clear_inherit - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_clear_inherit(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_clear_inherit - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_clear_inherit(sid, hanp, hlen, INVALID_ADDR,
- &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_clear_inherit - invalid attrnamep
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
- szFuncName);
- rc = dm_clear_inherit(sid, hanp, hlen, DM_NO_TOKEN,
- (dm_attrname_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc,
- persInheritAttr ? EFAULT : ENOSYS);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_clear_inherit - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_clear_inherit(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_clear_inherit - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 7)) {
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_clear_inherit(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_clear_inherit - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_clear_inherit(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_clear_inherit - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 9)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_clear_inherit(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_getall_inherit";
-
- /*
- * TEST : dm_getall_inherit - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_getall_inherit(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, 1, &inheritbuf,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_inherit - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_getall_inherit(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, 1, &inheritbuf,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_inherit - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_getall_inherit(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, 1, &inheritbuf,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_inherit - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_getall_inherit(sid, hanp, hlen, INVALID_ADDR, 1,
- &inheritbuf, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_inherit - invalid inheritbufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid inheritbufp)\n",
- szFuncName);
- rc = dm_getall_inherit(sid, hanp, hlen, DM_NO_TOKEN, 1,
- (dm_inherit_t *) INVALID_ADDR,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc,
- persInheritAttr ? EFAULT : ENOSYS);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_inherit - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_getall_inherit(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, 1, &inheritbuf,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_inherit - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 7)) {
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_getall_inherit(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, 1, &inheritbuf, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_getall_inherit - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_getall_inherit(sid, hanp, hlen, DM_NO_TOKEN, 1,
- &inheritbuf, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_inherit - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_INHERIT_BASE + 9)) {
- void *hanp;
- size_t hlen;
- dm_inherit_t inheritbuf;
- u_int nelem;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_getall_inherit(sid, hanp, hlen, DM_NO_TOKEN, 1,
- &inheritbuf, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- remove(DUMMY_TMP);
-
- DMLOG_STOP();
-
- tst_exit();
-}
diff --git a/testcases/kernel/fs/dmapi/config.c b/testcases/kernel/fs/dmapi/config.c
deleted file mode 100644
index 657484f90..000000000
--- a/testcases/kernel/fs/dmapi/config.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : config.c
- *
- * VARIATIONS : 28
- *
- * API'S TESTED : dm_get_config
- */
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include "dm_test.h"
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int rc;
- int i;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION AND NO PREEXISTING FILES!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI configuration tests\n");
-
- szFuncName = "dm_get_config";
-
- /*
- * TEST : dm_get_config - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_config((void *)INVALID_ADDR, hlen,
- DM_CONFIG_BULKALL, &retval);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_config(hanp, INVALID_ADDR,
- DM_CONFIG_BULKALL, &retval);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config - invalid flagname
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid flagname)\n",
- szFuncName);
- rc = dm_get_config(hanp, hlen, INVALID_ADDR, &retval);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config - invalid retvalp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid retvalp)\n",
- szFuncName);
- rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
- (dm_size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 5)) {
- dm_size_t retval;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_get_config(DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_CONFIG_BULKALL, &retval);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_get_config - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
- &retval);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config - directory handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
- &retval);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
- &retval);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config - invalidated handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_CONFIG_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
- szFuncName);
- rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
- &retval);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config
- * EXPECTED: rc = 0
- */
- for (i = 1; i < CONFIG_MAX; i++) {
- if (DMVAR_EXEC(GET_CONFIG_BASE + 9 + i)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_size_t retval;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%s)\n", szFuncName,
- dmimpl_expectedResults[i].name);
- rc = dm_get_config(hanp, hlen, i, &retval);
- if (rc == 0) {
- if (retval ==
- dmimpl_expectedResults[i].result) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected retval (%lld vs %lld)\n",
- szFuncName, 0,
- retval,
- dmimpl_expectedResults
- [i].result);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
- }
-
- DMLOG_STOP();
-
- tst_exit();
-
-}
diff --git a/testcases/kernel/fs/dmapi/disp.c b/testcases/kernel/fs/dmapi/disp.c
deleted file mode 100644
index 7b4123fe8..000000000
--- a/testcases/kernel/fs/dmapi/disp.c
+++ /dev/null
@@ -1,4062 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : disp.c
- *
- * VARIATIONS : 155
- *
- * API'S TESTED : dm_get_config_events
- * dm_set_disp
- * dm_getall_disp
- * dm_set_eventlist
- * dm_get_eventlist
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define TMP_FILELEN 1000
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummyFile2[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int i;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events, maxEvents, minEvents;
- void *fshanp;
- size_t fshlen;
- int varNum;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- int fd;
-
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummyFile2, "%s/%s", mountPt, DUMMY_FILE2);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- remove(DummyFile);
- remove(DummyFile2);
- rmdir(DummySubdir);
-
- EVENT_DELIVERY_DELAY;
- fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < TMP_FILELEN / DUMMY_STRLEN; i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc != -1) {
- rc = fsync(fd);
- }
- if (rc != -1) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy dir failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(maxEvents);
- DMEV_SET(DM_EVENT_PREUNMOUNT, maxEvents);
- DMEV_SET(DM_EVENT_UNMOUNT, maxEvents);
- DMEV_SET(DM_EVENT_CREATE, maxEvents);
- DMEV_SET(DM_EVENT_CLOSE, maxEvents);
- DMEV_SET(DM_EVENT_POSTCREATE, maxEvents);
- DMEV_SET(DM_EVENT_REMOVE, maxEvents);
- DMEV_SET(DM_EVENT_POSTREMOVE, maxEvents);
- DMEV_SET(DM_EVENT_RENAME, maxEvents);
- DMEV_SET(DM_EVENT_POSTRENAME, maxEvents);
- DMEV_SET(DM_EVENT_LINK, maxEvents);
- DMEV_SET(DM_EVENT_POSTLINK, maxEvents);
- DMEV_SET(DM_EVENT_SYMLINK, maxEvents);
- DMEV_SET(DM_EVENT_POSTSYMLINK, maxEvents);
- DMEV_SET(DM_EVENT_ATTRIBUTE, maxEvents);
- DMEV_SET(DM_EVENT_DESTROY, maxEvents);
- DMEV_SET(DM_EVENT_NOSPACE, maxEvents);
-
- DMEV_ZERO(minEvents);
- DMEV_SET(DM_EVENT_PREUNMOUNT, minEvents);
- DMEV_SET(DM_EVENT_UNMOUNT, minEvents);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI disposition/eventlist tests\n");
-
- szFuncName = "dm_get_config_events";
-
- /*
- * TEST : dm_get_config_events - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 1)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_config_events((void *)INVALID_ADDR, hlen,
- DM_EVENT_MAX, &eventset,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 2)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_config_events(hanp, INVALID_ADDR,
- DM_EVENT_MAX, &eventset,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - invalid nelem
- * EXPECTED: rc = -1, errno = E2BIG
- *
- * This variation uncovered XFS BUG #18 (nelem not updated)
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelem)\n",
- szFuncName);
- rc = dm_get_config_events(hanp, hlen, 0, &eventset,
- &nelem);
- if (rc == -1) {
- if (errno == E2BIG) {
- if (nelem == DM_EVENT_MAX) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d (nelem = %d)\n",
- szFuncName, rc,
- errno, nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, rc,
- nelem,
- DM_EVENT_MAX);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - invalid eventsetp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 4)) {
- void *hanp;
- size_t hlen;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
- szFuncName);
- rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
- (dm_eventset_t *)
- INVALID_ADDR, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - invalid nelemp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 5)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
-
- /* Variation set up */
- rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
- szFuncName);
- rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
- &eventset,
- (u_int *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - fs handle
- * EXPECTED: rc = 0
- *
- * This variation uncovered XFS BUG #19 (DM_EVENT_USER not returned)
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 6)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
- &eventset, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_MAX) {
- if (memcmp
- (&eventset, &dmimpl_eventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- eventset,
- dmimpl_eventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_DESTROY + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 7)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_path_to_handle(DummyFile, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
- &eventset, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_MAX) {
- if (memcmp
- (&eventset, &dmimpl_eventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- eventset,
- dmimpl_eventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_DESTROY + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - dir handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 8)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_path_to_handle(DummySubdir, &hanp, &hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
- &eventset, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_MAX) {
- if (memcmp
- (&eventset, &dmimpl_eventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- eventset,
- dmimpl_eventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_DESTROY + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_config_events - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 9)) {
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_get_config_events(DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_EVENT_MAX, &eventset, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_get_config_events - invalidated handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 10)) {
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyFile, DummyFile2);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile2, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile2);
- } else if ((rc = remove(DummyFile2)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
- szFuncName);
- rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
- &eventset, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_set_disp";
-
- /*
- * TEST : dm_set_disp - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 1)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_set_disp(DM_NO_SESSION, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 2)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_set_disp(INVALID_ADDR, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 3)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_set_disp(newsid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 4)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 5)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, hlen, INVALID_ADDR,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid eventsetp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 6)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- (dm_eventset_t *) INVALID_ADDR,
- DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid maxevent
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 7)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid maxevent)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX + 1);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 8)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 9)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid global handle event
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 10)) {
- dm_sessid_t newsid;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_POSTCREATE, eventset);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(invalid global handle event)\n",
- szFuncName);
- rc = dm_set_disp(newsid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_set_disp - invalid fs handle event
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 11)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_MOUNT, eventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(invalid fs handle event)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_disp - valid global handle event
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 12)) {
- dm_sessid_t newsid;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_MOUNT, eventset);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(valid global handle event)\n",
- szFuncName);
- rc = dm_set_disp(newsid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_set_disp - valid fs handle event
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_DISP_BASE + 13)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_POSTCREATE, eventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid fs handle event)\n",
- szFuncName);
- rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_getall_disp";
-
- /*
- * TEST : dm_getall_disp - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 1)) {
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_getall_disp(DM_NO_SESSION, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_getall_disp - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 2)) {
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_getall_disp(INVALID_ADDR, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_getall_disp - invalidated sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 3)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &maxEvents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- } else if ((rc = dm_destroy_session(newsid)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n",
- szFuncName);
- rc = dm_getall_disp(newsid, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_disp - NULL bufp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 4)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &maxEvents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL bufp)\n", szFuncName);
- rc = dm_getall_disp(newsid, sizeof(buf), NULL, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_disp - invalid bufp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 5)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &maxEvents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_getall_disp(newsid, sizeof(buf),
- (void *)INVALID_ADDR, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_disp - NULL rlenp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 6)) {
- dm_sessid_t newsid;
- char buf[64];
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &maxEvents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL rlenp)\n",
- szFuncName);
- rc = dm_getall_disp(newsid, sizeof(buf), buf, NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_disp - invalid rlenp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 7)) {
- dm_sessid_t newsid;
- char buf[64];
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &maxEvents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_getall_disp(newsid, sizeof(buf), buf,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_disp - zero buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 8)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &maxEvents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen zero)\n",
- szFuncName);
- rc = dm_getall_disp(newsid, 0, buf, &rlen);
- if (rc == -1 && errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- }
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_getall_disp - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_DISP_BASE + 9)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
- &maxEvents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_getall_disp(newsid, sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- dm_dispinfo_t *di = (dm_dispinfo_t *) buf;
- if (rlen == sizeof(dm_dispinfo_t) + hlen) {
- if (dm_handle_cmp
- (hanp, hlen,
- DM_GET_VALUE(di, di_fshandle,
- void *),
- DM_GET_LEN(di,
- di_fshandle)) == 0) {
- if (di->di_eventset ==
- maxEvents) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName,
- 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected eventset (%llx vs %llx)\n",
- szFuncName,
- 0,
- di->
- di_eventset,
- maxEvents);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected fs handle (%llx vs %llx)\n",
- szFuncName, 0,
- *(__u64 *) hanp,
- *(__u64 *)
- DM_GET_VALUE(di,
- di_fshandle,
- void
- *));
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, 0, rlen,
- sizeof(dm_dispinfo_t) +
- hlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_set_eventlist";
-
- /*
- * TEST : dm_set_eventlist - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 1)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_set_eventlist(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 2)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_set_eventlist(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 3)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_set_eventlist(newsid, (void *)INVALID_ADDR,
- hlen, DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 4)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_set_eventlist(newsid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 5)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_set_eventlist(newsid, hanp, hlen, INVALID_ADDR,
- &eventset, DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - invalid eventsetp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 6)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
- szFuncName);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- (dm_eventset_t *) INVALID_ADDR,
- DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - invalid maxevent
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 7)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset = minEvents;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid maxevent)\n",
- szFuncName);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX + 1);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - maxevent < high set event
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 8)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventset = minEvents;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(maxevent < high set event)\n",
- szFuncName);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_ATTRIBUTE);
- if (rc == 0) {
- if ((dm_get_eventlist
- (newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &eventset, &nelem) == 0)
- && (nelem == DM_EVENT_ATTRIBUTE + 1)
- &&
- (DMEV_ISSET(DM_EVENT_ATTRIBUTE, eventset)))
- {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but high set event cleared\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_eventlist - maxevent > high set event
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_EVENTLIST_BASE + 9)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventset = minEvents;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(maxevent > high set event)\n",
- szFuncName);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &eventset, DM_EVENT_MAX);
- if (rc == 0) {
- if ((dm_get_eventlist
- (newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &eventset, &nelem) == 0)
- && (nelem == DM_EVENT_UNMOUNT + 1)
- &&
- (!DMEV_ISSET(DM_EVENT_ATTRIBUTE, eventset)))
- {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but high set event still set\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * Global handle dm_set_eventlist variations
- *
- * This variation uncovered XFS BUG #15 (EBADF errno returned instead
- * of EINVAL)
- */
- for (i = 0, varNum = SET_EVENTLIST_BASE + 10; i < DM_EVENT_MAX;
- i++, varNum++) {
- if (DMVAR_EXEC(varNum)) {
- dm_sessid_t newsid;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(i, eventset);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(global handle, %s)\n",
- szFuncName,
- dmimpl_validEvents[i].name);
- rc = dm_set_eventlist(newsid, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
- }
-
- /*
- * File system handle dm_set_eventlist variations
- */
- for (i = 0; i < DM_EVENT_MAX; i++, varNum++) {
- if (DMVAR_EXEC(varNum)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(i, eventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DummyFile, &hanp,
- &hlen)) == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle, %s)\n",
- szFuncName,
- dmimpl_validEvents[i].name);
- rc = dm_set_eventlist(newsid, hanp, hlen,
- DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- if (dmimpl_validEvents[i].bFSHandle)
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
- else
- DMVAR_ENDFAILEXP(szFuncName, -1, rc,
- EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
- }
-
- /*
- * Directory handle dm_set_eventlist variations
- */
- for (i = 0; i < DM_EVENT_MAX; i++, varNum++) {
- if (DMVAR_EXEC(varNum)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(i, eventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DummySubdir, &hanp,
- &hlen)) == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle, %s)\n",
- szFuncName,
- dmimpl_validEvents[i].name);
- rc = dm_set_eventlist(newsid, hanp, hlen,
- DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- if (dmimpl_validEvents[i].bDirHandle)
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
- else
- DMVAR_ENDFAILEXP(szFuncName, -1, rc,
- EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
- }
-
- /*
- * File handle dm_set_eventlist variations
- */
- for (i = 0; i < DM_EVENT_MAX; i++, varNum++) {
- if (DMVAR_EXEC(varNum)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t eventset;
-
- /* Variation set up */
- DMEV_ZERO(eventset);
- DMEV_SET(i, eventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DummyFile, &hanp,
- &hlen)) == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file handle, %s)\n", szFuncName,
- dmimpl_validEvents[i].name);
- rc = dm_set_eventlist(newsid, hanp, hlen,
- DM_NO_TOKEN, &eventset,
- DM_EVENT_MAX);
- if (dmimpl_validEvents[i].bFileHandle)
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
- else
- DMVAR_ENDFAILEXP(szFuncName, -1, rc,
- EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
- }
-
- szFuncName = "dm_get_eventlist";
-
- /*
- * TEST : dm_get_eventlist - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 1)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_get_eventlist(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, DM_EVENT_MAX,
- &outeventset, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 2)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_get_eventlist(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, DM_EVENT_MAX,
- &outeventset, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 3)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, (void *)INVALID_ADDR,
- hlen, DM_NO_TOKEN, DM_EVENT_MAX,
- &outeventset, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 4)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, DM_EVENT_MAX,
- &outeventset, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 5)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, INVALID_ADDR,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #16 (0 returned instead of -1 and
- * errno EINVAL)
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 6)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid nelem, fs handle
- * EXPECTED: rc = -1, errno = E2BIG
- *
- * This variation uncovered XFS BUG #17 (EINVAL errno returned instead
- * of E2BIG, nelemp not updated)
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 7)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(invalid nelem, fs handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- 0, &outeventset, &nelem);
- if (rc == -1) {
- if (errno == E2BIG) {
- if (nelem == DM_EVENT_ATTRIBUTE + 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d (nelem = %d)\n",
- szFuncName, rc,
- errno, nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, rc,
- nelem,
- DM_EVENT_ATTRIBUTE +
- 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid nelem, file handle
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 8)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(invalid nelem, file handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- 0, &outeventset, &nelem);
- if (rc == -1) {
- if (errno == E2BIG) {
- if (nelem == DM_EVENT_ATTRIBUTE + 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d (nelem = %d)\n",
- szFuncName, rc,
- errno, nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, rc,
- nelem,
- DM_EVENT_ATTRIBUTE +
- 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid eventsetp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 9)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX,
- (dm_eventset_t *) INVALID_ADDR,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalid nelemp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 10)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- (u_int *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - zero event, fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 11)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(zero event, fs handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == 0) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - zero event, file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 12)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(zero event, file handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == 0) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - one event, fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 13)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(one event, fs handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_ATTRIBUTE + 1) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_ATTRIBUTE + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - one event, file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 14)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(one event, file handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_ATTRIBUTE + 1) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_ATTRIBUTE + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - multi event, fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 15)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_CLOSE, ineventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- DMEV_SET(DM_EVENT_DESTROY, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(multi event, fs handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_DESTROY + 1) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_DESTROY + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - multi event, file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 16)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_CLOSE, ineventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- DMEV_SET(DM_EVENT_DESTROY, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(multi event, file handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_DESTROY + 1) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_DESTROY + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - read event
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 17)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
- dm_region_t region = { 0, 0, DM_REGION_READ };
- dm_boolean_t exactflag;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_READ, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
- ®ion, &exactflag)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(read event)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_READ + 1) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_READ + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - write event
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 18)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
- dm_region_t region = { 0, 10, DM_REGION_WRITE };
- dm_boolean_t exactflag;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_WRITE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
- ®ion, &exactflag)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(write event)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_WRITE + 1) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_WRITE + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - truncate event
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 19)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
- dm_region_t region =
- { TMP_FILELEN - 10, 0, DM_REGION_TRUNCATE };
- dm_boolean_t exactflag;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_TRUNCATE, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- } else
- if ((rc =
- dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
- ®ion, &exactflag)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(truncate event)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_TRUNCATE + 1) {
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_TRUNCATE + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - event union, file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 20)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
- dm_region_t region =
- { TMP_FILELEN - 10, 0, DM_REGION_TRUNCATE };
- dm_boolean_t exactflag;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
- DMEV_SET(DM_EVENT_CLOSE, ineventset);
- DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
- DMEV_SET(DM_EVENT_DESTROY, ineventset);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- } else
- if (((rc =
- dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
- ®ion, &exactflag)) == -1)) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(event union, file handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == DM_EVENT_DESTROY + 1) {
- DMEV_SET(DM_EVENT_TRUNCATE, ineventset);
- if (memcmp
- (&ineventset, &outeventset,
- sizeof(dm_eventset_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
- szFuncName, 0,
- ineventset,
- outeventset);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- DM_EVENT_DESTROY + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- DMEV_ZERO(ineventset);
- rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- &ineventset, DM_EVENT_MAX);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_eventlist - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 21)) {
- dm_sessid_t newsid;
- dm_eventset_t outeventset;
- u_int nelem;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
-
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_get_eventlist - invalidated file handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_EVENTLIST_BASE + 22)) {
- dm_sessid_t newsid;
- void *hanp;
- size_t hlen;
- dm_eventset_t ineventset, outeventset;
- u_int nelem;
-
- /* Variation set up */
- DMEV_ZERO(ineventset);
- DMEV_ZERO(outeventset);
-
- sprintf(command, "cp %s %s", DummyFile, DummyFile2);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- remove(DummyFile2);
- } else if ((rc = dm_path_to_handle(DummyFile2, &hanp, &hlen)) ==
- -1) {
- dm_destroy_session(newsid);
- remove(DummyFile2);
- } else if ((rc = remove(DummyFile2)) == -1) {
- dm_handle_free(hanp, hlen);
- dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(invalidated file handle)\n",
- szFuncName);
- rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
- DM_EVENT_MAX, &outeventset,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /* We now need to repoint preunmount/unmount back to original session */
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_fshandle failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_disp(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- remove(DummyFile);
- rmdir(DummySubdir);
- dm_handle_free(fshanp, fshlen);
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- switch (type) {
- case DM_EVENT_PREUNMOUNT:
- case DM_EVENT_READ:
- case DM_EVENT_WRITE:
- case DM_EVENT_TRUNCATE:
- case DM_EVENT_CREATE:
- case DM_EVENT_REMOVE:
- case DM_EVENT_RENAME:
- case DM_EVENT_LINK:
- case DM_EVENT_SYMLINK:
- response = DM_RESP_CONTINUE;
- break;
-
- case DM_EVENT_POSTCREATE:
- case DM_EVENT_POSTREMOVE:
- case DM_EVENT_POSTRENAME:
- case DM_EVENT_POSTLINK:
- case DM_EVENT_POSTSYMLINK:
- case DM_EVENT_ATTRIBUTE:
- case DM_EVENT_CLOSE:
- response = DM_RESP_INVALID;
- break;
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/dm_impl.h b/testcases/kernel/fs/dmapi/dm_impl.h
deleted file mode 100644
index 62f1877e7..000000000
--- a/testcases/kernel/fs/dmapi/dm_impl.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : dm_impl.h
- *
- * PURPOSE : Define implementation-dependent functions and variables
- * common to all DMAPI test cases
- *
- * NOTES : The validEvents[] table is derived from the XDSM
- * specification, and then the row(s) for unsupported event(s)
- * are set to DM_FALSE. The definition from the specification
- * is:
- *
- * eventValidity_t validEvents[DM_EVENT_MAX] = {
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_CANCEL" },
- * { DM_TRUE , DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_MOUNT" },
- * { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_PREUNMOUNT" },
- * { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_UNMOUNT" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_DEBUT" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_CREATE" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_CLOSE" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTCREATE" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_REMOVE" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTREMOVE" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_RENAME" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTRENAME" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_LINK" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTLINK" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_SYMLINK" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTSYMLINK" },
- * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_READ" },
- * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_WRITE" },
- * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_TRUNCATE" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_ATTRIBUTE" },
- * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_DESTROY" },
- * { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_NOSPACE" },
- * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_USER" }
- * };
- *
- */
-
-#include <sys/mount.h>
-
-#ifdef JFS
-configResult_t dmimpl_expectedResults[CONFIG_MAX] = {
- { "DM_CONFIG_INVALID", 0 },
- { "DM_CONFIG_BULKALL", DM_FALSE },
- { "DM_CONFIG_CREATE_BY_HANDLE", DM_FALSE },
- { "DM_CONFIG_DTIME_OVERLOAD", DM_TRUE },
- { "DM_CONFIG_LEGACY", DM_TRUE },
- { "DM_CONFIG_LOCK_UPGRADE", DM_FALSE },
- { "DM_CONFIG_MAX_ATTR_ON_DESTROY", 256 /* from dmapi_jfs.c */},
- { "DM_CONFIG_MAX_ATTRIBUTE_SIZE", 0xFFFF /* from jfs_xattr.h */},
- { "DM_CONFIG_MAX_HANDLE_SIZE", 56 /* from dmapi_kern.h */},
- { "DM_CONFIG_MAX_MANAGED_REGIONS", 0x7FFFFFFF /* from dmapi_jfs.c */},
- { "DM_CONFIG_MAX_MESSAGE_DATA", 3960 /* from dmapi_private.h */},
- { "DM_CONFIG_OBJ_REF", DM_TRUE },
- { "DM_CONFIG_PENDING", DM_TRUE }, // ?
- { "DM_CONFIG_PERS_ATTRIBUTES", DM_TRUE },
- { "DM_CONFIG_PERS_EVENTS", DM_FALSE },
- { "DM_CONFIG_PERS_INHERIT_ATTRIBS", DM_FALSE },
- { "DM_CONFIG_PERS_MANAGED_REGIONS", DM_TRUE },
- { "DM_CONFIG_PUNCH_HOLE", DM_TRUE },
- { "DM_CONFIG_TOTAL_ATTRIBUTE_SPACE", 0x7FFFFFFF /* from dmapi_jfs.c */},
- { "DM_CONFIG_WILL_RETRY", DM_TRUE }
-};
-
-/* JFS does not support DM_EVENT_CANCEL or DM_EVENT_DEBUT */
-eventValidity_t dmimpl_validEvents[DM_EVENT_MAX] = {
- { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_CANCEL" },
- { DM_TRUE , DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_MOUNT" },
- { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_PREUNMOUNT" },
- { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_UNMOUNT" },
- { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_DEBUT" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_CREATE" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_CLOSE" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTCREATE" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_REMOVE" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTREMOVE" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_RENAME" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTRENAME" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_LINK" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTLINK" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_SYMLINK" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTSYMLINK" },
- { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_READ" },
- { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_WRITE" },
- { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_TRUNCATE" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_ATTRIBUTE" },
- { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_DESTROY" },
- { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_NOSPACE" },
- { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_USER" }
-};
-
-dm_eventset_t dmimpl_eventset =
-/* (1 << DM_EVENT_CANCEL) | */
- (1 << DM_EVENT_MOUNT) |
- (1 << DM_EVENT_PREUNMOUNT) |
- (1 << DM_EVENT_UNMOUNT) |
-/* (1 << DM_EVENT_DEBUT) | */
- (1 << DM_EVENT_CREATE) |
- (1 << DM_EVENT_CLOSE) |
- (1 << DM_EVENT_POSTCREATE) |
- (1 << DM_EVENT_REMOVE) |
- (1 << DM_EVENT_POSTREMOVE) |
- (1 << DM_EVENT_RENAME) |
- (1 << DM_EVENT_POSTRENAME) |
- (1 << DM_EVENT_LINK) |
- (1 << DM_EVENT_POSTLINK) |
- (1 << DM_EVENT_SYMLINK) |
- (1 << DM_EVENT_POSTSYMLINK) |
- (1 << DM_EVENT_READ) |
- (1 << DM_EVENT_WRITE) |
- (1 << DM_EVENT_TRUNCATE) |
- (1 << DM_EVENT_ATTRIBUTE) |
- (1 << DM_EVENT_DESTROY) |
- (1 << DM_EVENT_NOSPACE) |
- (1 << DM_EVENT_USER);
-
-int dmimpl_mount(char **mountPt, char **deviceNm) {
- char options[FILENAME_MAX];
-
- if ((*mountPt = DMOPT_GET("mtpt")) == NULL) {
- DMLOG_PRINT(DMLVL_ERR, "Missing mount point, use -mtpt (for example, -mtpt /dmapidir)\n");
- DM_EXIT();
- } else {
- DMLOG_PRINT(DMLVL_DEBUG, "Mount point is %s\n", *mountPt);
- }
-
- if ((*deviceNm = DMOPT_GET("device")) == NULL) {
- DMLOG_PRINT(DMLVL_ERR, "Missing device name, use -device (for example, -device /dev/hda5)\n");
- DM_EXIT();
- } else {
- DMLOG_PRINT(DMLVL_DEBUG, "Device name is %s\n", *deviceNm);
- }
-
- sprintf(options, "dmapi,mtpt=%s", *mountPt);
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "Mounting %s on %s now...\n", *deviceNm, *mountPt);
- return mount(*deviceNm, *mountPt, "jfs", 0, options);
-}
-#endif
diff --git a/testcases/kernel/fs/dmapi/dm_test.c b/testcases/kernel/fs/dmapi/dm_test.c
deleted file mode 100644
index dc0dbdaf6..000000000
--- a/testcases/kernel/fs/dmapi/dm_test.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * FILE NAME : dm_test.c
- *
- * PURPOSE : Define functions and variables common to all DMAPI test cases
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <errno.h>
-#include <time.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-#include "dm_test.h"
-
-#define TEST_NAME "dm_test"
-
-int dm_StartingVariation = 0;
-int dm_StoppingVariation = INT32_MAX;
-int dm_CurrentVariation = 0;
-u_int dm_FileLoggingLevel = 0;
-u_int dm_TerminalLoggingLevel = 0;
-char *dm_LogFileName = "dm_logfile";
-u_int dm_PassedVariations = 0;
-u_int dm_FailedVariations = 0;
-u_int dm_SkippedVariations = 0;
-char *dm_TestCaseName = TEST_NAME;
-int dm_fdLogFile;
-FILE *dm_fpLogFile;
-int dm_argc = 0;
-char **dm_argv = NULL;
-int dm_FileNewlineNeeded;
-int dm_TerminalNewlineNeeded;
-
-void dm_ParseCommandLineOptions(int argc, char **argv)
-{
-
- int i;
- char *p;
-
- if ((p = strrchr(argv[0], '/')) != NULL)
- dm_TestCaseName = ++p;
-
- for (i = 1; i < argc; i++) {
- if (argv[i][0] == '-') {
- if (strcmp(&argv[i][1], "runfrom") == 0) {
- if (i < argc - 1 && argv[i + 1][0] != '-')
- dm_StartingVariation = atoi(argv[++i]);
- else
- dm_Error
- ("invalid/missing runfrom argument\n");
- } else if (strcmp(&argv[i][1], "runto") == 0) {
- if (i < argc - 1 && argv[i + 1][0] != '-')
- dm_StoppingVariation = atoi(argv[++i]);
- else
- dm_Error
- ("invalid/missing runto argument\n");
- } else if (strcmp(&argv[i][1], "runonly") == 0) {
- if (i < argc - 1 && argv[i + 1][0] != '-') {
- dm_StartingVariation = atoi(argv[++i]);
- dm_StoppingVariation =
- dm_StartingVariation;
- } else
- dm_Error
- ("invalid/missing runonly argument\n");
- } else if (strcmp(&argv[i][1], "loglevel") == 0) {
- if (i < argc - 1 && argv[i + 1][0] != '-')
- dm_FileLoggingLevel = atoi(argv[++i]);
- else
- dm_Error
- ("invalid/missing loglevel argument\n");
- } else if (strcmp(&argv[i][1], "termlevel") == 0) {
- if (i < argc - 1 && argv[i + 1][0] != '-')
- dm_TerminalLoggingLevel =
- atoi(argv[++i]);
- else
- dm_Error
- ("invalid/missing termlevel argument\n");
- } else if (strcmp(&argv[i][1], "logname") == 0) {
- if (i < argc - 1 && argv[i + 1][0] != '-')
- dm_LogFileName = argv[++i];
- else
- dm_Error
- ("invalid/missing filename argument\n");
- } else if (strcmp(&argv[i][1], "?") == 0
- || strcmp(&argv[i][1], "help") == 0
- || strcmp(&argv[i][1], "-help") == 0) {
- printf("%s usage:\n", argv[0]);
- printf
- ("\t-runfrom n: set starting variation to n\n");
- printf
- ("\t-runto n: set stopping variation to n\n");
- printf("\t-runonly n: run only variation n\n");
- printf
- ("\t-loglevel n: set file logging level to n\n");
- printf
- ("\t-termlevel n: set terminal logging level to n\n");
- printf
- ("\t-logname s: set file log name to s\n");
- exit(0);
- } else if (i < argc - 1 && argv[i + 1][0] != '-')
- i++;
- }
- }
-
- dm_argc = argc;
- dm_argv = argv;
-
-}
-
-char *dm_GetCommandLineOption(char *option)
-{
-
- int i;
-
- if (!dm_argc)
- dm_Error
- ("Cannot get command line option without calling DMOPT_PARSE");
-
- for (i = 1; i < dm_argc; i++)
- if (dm_argv[i][0] == '-' &&
- strcmp(&dm_argv[i][1], option) == 0 &&
- i < dm_argc - 1 && dm_argv[i + 1][0] != '-')
- return dm_argv[i + 1];
- return NULL;
-
-}
-
-void dm_StartLogging(void)
-{
-
- struct utsname buf;
- char version[256];
- struct timeval tv;
- struct tm *pDT = NULL;
- struct tm sDT;
- int i;
-
- if (dm_fpLogFile)
- dm_Error("Cannot start logging when log file already open");
-
- dm_fdLogFile =
- open(dm_LogFileName, O_CREAT | O_APPEND | O_SYNC | O_WRONLY,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
-
- if (dm_fdLogFile == -1)
- dm_Error("Unable to open log file %s", dm_LogFileName);
-
- dm_fpLogFile = fdopen(dm_fdLogFile, "a");
-
- if (dm_fpLogFile == NULL)
- dm_Error("Unable to fdopen log file %s", dm_LogFileName);
-
- if (uname(&buf) == -1)
- strcpy(version, "Unknown Linux version");
- else
- sprintf(version, "%s %s", buf.sysname, buf.release);
-
- if (gettimeofday(&tv, NULL) != -1)
- pDT = (struct tm *)localtime_r(&tv.tv_sec, &sDT);
-
- if (dm_FileLoggingLevel) {
- fprintf(dm_fpLogFile, "%s running on %s\n", TEST_NAME, version);
- fprintf(dm_fpLogFile, "%s invoked with ", dm_TestCaseName);
- for (i = 1; i < dm_argc; i++)
- fprintf(dm_fpLogFile, "%s ", dm_argv[i]);
- if (pDT)
- fprintf(dm_fpLogFile,
- "\n%s starting at %02u:%02u:%02u on %02u/%02u/%04u\n",
- dm_TestCaseName, pDT->tm_hour, pDT->tm_min,
- pDT->tm_sec, pDT->tm_mon + 1, pDT->tm_mday,
- pDT->tm_year + 1900);
- else
- fprintf(dm_fpLogFile, "\n%s starting\n",
- dm_TestCaseName);
-
- }
-
- if (dm_TerminalLoggingLevel) {
- printf("%s running on %s\n", TEST_NAME, version);
- printf("%s invoked with ", dm_TestCaseName);
- for (i = 1; i < dm_argc; i++)
- printf("%s ", dm_argv[i]);
- if (pDT)
- printf
- ("\n%s starting at %02u:%02u:%02u on %02u/%02u/%04u\n",
- dm_TestCaseName, pDT->tm_hour, pDT->tm_min,
- pDT->tm_sec, pDT->tm_mon + 1, pDT->tm_mday,
- pDT->tm_year + 1900);
- else
- printf("\n%s starting\n", dm_TestCaseName);
- }
-
-}
-
-void dm_StopLogging(void)
-{
-
- struct timeval tv;
- struct tm *pDT = NULL;
- struct tm sDT;
- int ranVariations = 0;
- int percentSuccess = 0;
-
- if (!dm_fpLogFile)
- dm_Error("Cannot stop logging when log file not already open");
-
- ranVariations = dm_PassedVariations + dm_FailedVariations;
-
- if (dm_PassedVariations)
- percentSuccess = (dm_PassedVariations * 100) / ranVariations;
-
- if (gettimeofday(&tv, NULL) != -1)
- pDT = (struct tm *)localtime_r(&tv.tv_sec, &sDT);
-
- if (dm_FileLoggingLevel) {
- if (pDT)
- fprintf(dm_fpLogFile,
- "%s stopping at %02u:%02u:%02u on %02u/%02u/%04u\n",
- dm_TestCaseName, pDT->tm_hour, pDT->tm_min,
- pDT->tm_sec, pDT->tm_mon + 1, pDT->tm_mday,
- pDT->tm_year + 1900);
- else
- fprintf(dm_fpLogFile, "%s stopping\n", dm_TestCaseName);
-
- fprintf(dm_fpLogFile,
- "%s status: %u executed, %u passed, %u failed, %u skipped (%u%%)\n",
- dm_TestCaseName, ranVariations, dm_PassedVariations,
- dm_FailedVariations, dm_SkippedVariations,
- percentSuccess);
- }
-
- if (dm_TerminalLoggingLevel) {
- if (pDT)
- printf
- ("%s stopping at %02u:%02u:%02u on %02u/%02u/%04u\n",
- dm_TestCaseName, pDT->tm_hour, pDT->tm_min,
- pDT->tm_sec, pDT->tm_mon + 1, pDT->tm_mday,
- pDT->tm_year + 1900);
- else
- printf("%s stopping\n", dm_TestCaseName);
-
- printf
- ("%s status: %u executed, %u passed, %u failed, %u skipped (%u%%)\n",
- dm_TestCaseName, ranVariations, dm_PassedVariations,
- dm_FailedVariations, dm_SkippedVariations, percentSuccess);
- }
-
- fclose(dm_fpLogFile);
- close(dm_fdLogFile);
-
-}
-
-void dm_Error(char *format, ...)
-{
- va_list args;
- char fmtmsg[256];
-
- /*
- * Format error message including message inserts
- */
- va_start(args, format);
- vsprintf(fmtmsg, format, args);
- va_end(args);
-
- /*
- * Display error message if not detached or Presentation Manager process
- */
- printf("\n%s fatal error: %s\n", TEST_NAME, fmtmsg);
-
-}
-
-void dm_LogPrintf(u_int level, char *format, ...)
-{
-
- va_list args;
-
- va_start(args, format);
- if (level <= dm_FileLoggingLevel) {
- fprintf(dm_fpLogFile, "[%s %d %d] ", dm_TestCaseName, getpid(),
- level);
- vfprintf(dm_fpLogFile, format, args);
- dm_FileNewlineNeeded = 1;
- }
- va_end(args);
- va_start(args, format);
- if (level <= dm_TerminalLoggingLevel) {
- printf("[%s %d %d] ", dm_TestCaseName, getpid(), level);
- vprintf(format, args);
- dm_TerminalNewlineNeeded = 1;
- }
- va_end(args);
-
-}
-
-int dm_ExecuteVariation(int var)
-{
-
- if (dm_CurrentVariation)
- dm_Error("Cannot execute variation while variation active\n");
- if (var < dm_StartingVariation || var > dm_StoppingVariation)
- return 0;
-
- dm_CurrentVariation = var;
-
- if (dm_FileNewlineNeeded)
- fputc('\n', dm_fpLogFile);
- if (dm_TerminalNewlineNeeded)
- putchar('\n');
-
- dm_LogPrintf(DMLVL_DEBUG, "Variation %d starting\n", var);
-
- return 1;
-
-}
-
-void dm_PassVariation(void)
-{
-
- if (!dm_CurrentVariation)
- dm_Error("Cannot pass variation while variation not active\n");
-
- dm_LogPrintf(DMLVL_DEBUG, "Variation %d passed\n\n",
- dm_CurrentVariation);
- dm_FileNewlineNeeded = dm_TerminalNewlineNeeded = 0;
-
- dm_PassedVariations++;
-
- dm_CurrentVariation = 0;
-
-}
-
-void dm_FailVariation(void)
-{
-
- if (!dm_CurrentVariation)
- dm_Error("Cannot fail variation while variation not active\n");
-
- dm_LogPrintf(DMLVL_DEBUG, "Variation %d failed\n\n",
- dm_CurrentVariation);
- dm_FileNewlineNeeded = dm_TerminalNewlineNeeded = 0;
-
- dm_FailedVariations++;
-
- dm_CurrentVariation = 0;
-
-}
-
-void dm_SkipVariation(void)
-{
-
- if (!dm_CurrentVariation)
- dm_Error("Cannot skip variation while variation not active\n");
-
- dm_LogPrintf(DMLVL_DEBUG, "Variation %d skipped\n\n",
- dm_CurrentVariation);
- dm_FileNewlineNeeded = dm_TerminalNewlineNeeded = 0;
-
- dm_SkippedVariations++;
-
- dm_CurrentVariation = 0;
-
-}
-
-void dm_EndVariation_SuccessExpected(char *funcname, int expectedRC,
- int actualRC)
-{
-
- if (actualRC == expectedRC) {
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n",
- funcname, expectedRC);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- funcname, actualRC, errno);
- DMVAR_FAIL();
- }
-
-}
-
-void dm_EndVariation_FailureExpected(char *funcname, int expectedRC,
- int actualRC, int expectedErrno)
-{
-
- if (actualRC == expectedRC) {
- if (errno == expectedErrno) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d\n",
- funcname, expectedRC, expectedErrno);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d (expected %d)\n",
- funcname, expectedRC, errno, expectedErrno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d\n",
- funcname, actualRC);
- DMVAR_FAIL();
- }
-
-}
-
-int dm_CheckVariation_SuccessExpected(int expectedRC, int actualRC,
- dm_eventtype_t expectedEvent,
- dm_eventtype_t actualEvent)
-{
-
- if (expectedEvent == actualEvent) {
- if (actualRC == expectedRC) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Passed, received expected event %d\n",
- expectedEvent);
- return DMSTAT_PASS;
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Failed, received expected event %d but unexpected rc = %d (expected %d)\n",
- expectedEvent, actualRC, expectedRC);
- return DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Failed, received unexpected event %d (expected %d)\n",
- actualEvent, expectedEvent);
- return DMSTAT_FAIL;
- }
-
-}
-
-int dm_CheckVariation_FailureExpected(int expectedRC, int actualRC,
- int expectedErrno,
- dm_eventtype_t expectedEvent,
- dm_eventtype_t actualEvent)
-{
-
- if (expectedEvent == actualEvent) {
- if (actualRC == expectedRC) {
- if (errno == expectedErrno) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Passed, received expected event %d\n",
- expectedEvent);
- return DMSTAT_PASS;
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Failed, received expected event %d but unexpected errno = %d (expected %d)\n",
- expectedEvent, errno,
- expectedErrno);
- return DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Failed, received expected event %d but unexpected rc = %d (expected %d)\n",
- expectedEvent, actualRC, expectedRC);
- return DMSTAT_FAIL;
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Failed, received unexpected event %d (expected %d)\n",
- actualEvent, expectedEvent);
- return DMSTAT_FAIL;
- }
-
-}
-
-void dm_LogHandle(char *hdl, int len)
-{
-
- int i;
- char outbuf[256], *pch;
-
- memset(outbuf, 0, sizeof(outbuf));
-
- for (i = 0, pch = outbuf; i < len; i++, pch += 3)
- sprintf(pch, " %02X", hdl[i]);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Handle: %s\n", outbuf);
-
-}
-
-/* This static array is for the persistent managed region test */
-dm_region_t dm_PMR_regbuf[PMR_NUM_REGIONS] = {
-#ifdef MULTIPLE_REGIONS
- {0, 1000, DM_REGION_WRITE}
- ,
- {2000, 1000, DM_REGION_TRUNCATE}
- ,
- {3005, 995, DM_REGION_READ}
- ,
- {5432, 2345, DM_REGION_NOEVENT}
- ,
-#endif
- {8000, 0, DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE}
-};
-
-/* Include implementation-dependent functions and variables */
-#include "dm_impl.h"
diff --git a/testcases/kernel/fs/dmapi/dm_test.h b/testcases/kernel/fs/dmapi/dm_test.h
deleted file mode 100644
index d30e0c01d..000000000
--- a/testcases/kernel/fs/dmapi/dm_test.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * FILE NAME : dm_test.h
- *
- * PURPOSE : Define macros and constants common to all DMAPI test cases
- */
-
-#include <stdlib.h>
-#if HAVE_SYS_JFSDMAPI_H
-#include <sys/jfsdmapi.h>
-#endif
-#include "dm_vars.h"
-
-/* The following constants are implementation-independent */
-#define ABORT_ERRNO 12
-#define DUMMY_STRING "0123456789"
-#define DUMMY_STRING2 "9876543210"
-#define DUMMY_STRLEN (sizeof(DUMMY_STRING)-1)
-#define ATTR_NAME "DMAttr01"
-#define ATTR_VALUE "This is a DM attribute's value"
-#define ATTR_VALUELEN (sizeof(ATTR_VALUE)-1)
-#define DUMMY_TIME 0xCAFEFEED
-#define DUMMY_UID 0xDEAD
-#define DUMMY_GID 0xBEEF
-#define DUMMY_MODE 0xBAD
-#define MODE_MASK 0x0FFF
-#define CURRENT_DIR "."
-#define PARENT_DIR ".."
-#define MSG_DATA "This is the message data for a DM user event"
-#define MSG_DATALEN sizeof(MSG_DATA)
-#define DWALIGN(n) (((n)+(sizeof(int)-1)) & ~(sizeof(int)-1))
-
-/* The following constants are more than likely implementation-dependent */
-#define INVALID_ADDR 0xDEADBEEF
-#define FILE_HANDLELEN 24
-#define EVENT_DELIVERY_DELAY sleep(1)
-#define EVENT_DELIVERY_DELAY_LOOP { \
- do { \
- eventReceived = DM_EVENT_INVALID; \
- EVENT_DELIVERY_DELAY; \
- } while (eventReceived != DM_EVENT_INVALID); \
-}
-#define TIMESTAMP_DELAY { \
- DMLOG_PRINT(DMLVL_DEBUG, "Sleeping to guarantee timestamp change...\n"); \
- sleep(3); \
-}
-#define PAGE_SIZE 4096
-#define PAGEALIGN(n) (((n)+(PAGE_SIZE-1)) & ~(PAGE_SIZE-1))
-#define O_DIRECTORY 0200000
-
-/* The following constants are implementation-dependent */
-#define DMAPI_ATTR_PREFIX "user.dmi."
-#define PMR_ATTRNAME "system.dmi.persistent.regions"
-#define MAXFILESIZE ((__s64)1 << 52)
-#define ROOT_INODE 2
-#define BLK_SIZE 4096
-#define BLKALIGN(n) (((n)+(BLK_SIZE-1)) & ~(BLK_SIZE-1))
-#define UNALIGNED_BLK_OFF 1357 /* Odd number less than BLK_SIZE */
-
-/* The following constants are file/directory/link names */
-#define DUMMY_FILE "dummy.txt"
-#define DUMMY_FILE2 "dummy2.txt"
-#define DUMMY_LINK "dummy.lnk"
-#define DUMMY_SUBDIR "dummy.dir"
-#define DUMMY_SUBDIR2 "dummy2.dir"
-#define DUMMY_SUBDIR_FILE "dummy.dir/dummy.txt"
-#define DUMMY_SUBDIR_LINK "dummy.dir/dummy.lnk"
-#define DUMMY_SUBDIR_SUBDIR "dummy.dir/dummy.dir"
-#define DUMMY_SUBDIR2_FILE "dummy2.dir/dummy.txt"
-#define DUMMY_SUBDIR2_LINK "dummy2.dir/dummy.lnk"
-#define DUMMY_SUBDIR2_SUBDIR "dummy2.dir/dummy.dir"
-#define DUMMY_TMP "dummy.tmp"
-#define DUMMY_FILE_RO_MODE (S_IRUSR | S_IRGRP | S_IROTH)
-#define DUMMY_FILE_RW_MODE (DUMMY_FILE_RO_MODE | S_IWUSR)
-#define DUMMY_DIR_RO_MODE (DUMMY_FILE_RO_MODE | S_IXUSR | S_IXGRP | S_IXOTH)
-#define DUMMY_DIR_RW_MODE (DUMMY_DIR_RO_MODE | S_IWUSR)
-
-/* The following constants and macros pertain to DM logging */
-#define DMLVL_ERR 1
-#define DMLVL_WARN 2
-#define DMLVL_DEBUG 3
-#define DMLVL_INFO 4
-
-#define DMSTAT_PASS 1
-#define DMSTAT_FAIL 2
-#define DMSTAT_SKIP 3
-
-#define DMLOG_START() dm_StartLogging()
-#define DMLOG_STOP() dm_StopLogging()
-#define DMLOG_PRINT dm_LogPrintf
-#define DMVAR_EXEC(v) dm_ExecuteVariation(v)
-#define DMVAR_PASS() dm_PassVariation()
-#define DMVAR_FAIL() dm_FailVariation()
-#define DMVAR_SKIP() dm_SkipVariation()
-#define DMOPT_PARSE(c,v) dm_ParseCommandLineOptions(c, v)
-#define DMOPT_GET(o) dm_GetCommandLineOption(o)
-#define DM_ERROR dm_error
-#define DM_EXIT() exit(-1)
-#define DMVAR_ENDPASSEXP(n,e,a) dm_EndVariation_SuccessExpected(n, e, a)
-#define DMVAR_ENDFAILEXP(n,e,a,f) dm_EndVariation_FailureExpected(n, e, a, f);
-#define DMVAR_CHKPASSEXP(e1,a1,e2,a2) dm_CheckVariation_SuccessExpected(e1, a1, e2, a2)
-#define DMVAR_CHKFAILEXP(e1,a1,e,e2,a2) dm_CheckVariation_FailureExpected(e1, a1, e, e2, a2)
-#define DMVAR_END(s) { if ((s) == DMSTAT_PASS) DMVAR_PASS(); else DMVAR_FAIL(); }
-
-/* DM logging global functions */
-void dm_ParseCommandLineOptions(int argc, char **argv);
-char *dm_GetCommandLineOption(char *option);
-void dm_StartLogging(void);
-void dm_StopLogging(void);
-void dm_Error(char *format, ...);
-void dm_LogPrintf(u_int level, char *format, ...);
-int dm_ExecuteVariation(int var);
-void dm_PassVariation(void);
-void dm_FailVariation(void);
-void dm_SkipVariation(void);
-void dm_EndVariation_SuccessExpected(char *funcname, int expectedRC, int actualRC);
-void dm_EndVariation_FailureExpected(char *funcname, int expectedRC, int actualRC, int expectedErrno);
-#if HAVE_SYS_JFSDMAPI_H
-int dm_CheckVariation_SuccessExpected(int expectedRC, int actualRC, dm_eventtype_t expectedEvent, dm_eventtype_t actualEvent);
-int dm_CheckVariation_FailureExpected(int expectedRC, int actualRC, int expectedErrno, dm_eventtype_t expectedEvent, dm_eventtype_t actualEvent);
-void dm_LogHandle(char *hdl, int len);
-
-/* Persistent managed regions global data */
-
-#ifdef MULTIPLE_REGIONS
-#define PMR_NUM_REGIONS 5
-#else
-#define PMR_NUM_REGIONS 1
-#endif
-extern dm_region_t dm_PMR_regbuf[];
-
-/* Implementation-dependent data structures */
-typedef struct configResult {
- char *name;
- dm_size_t result;
-} configResult_t;
-
-typedef struct eventValidity {
- dm_boolean_t bGlobalHandle;
- dm_boolean_t bFSHandle;
- dm_boolean_t bDirHandle;
- dm_boolean_t bFileHandle;
- char * name;
-} eventValidity_t;
-
-/* Implementation-dependent global function */
-int dmimpl_mount(char **mountPt, char **deviceNm);
-
-/* Implementation-dependent global data */
-#define CONFIG_MAX 20
-extern configResult_t dmimpl_expectedResults[];
-extern eventValidity_t dmimpl_validEvents[];
-extern dm_eventset_t dmimpl_eventset;
-#endif
diff --git a/testcases/kernel/fs/dmapi/dm_vars.h b/testcases/kernel/fs/dmapi/dm_vars.h
deleted file mode 100644
index 8f6b4b3c6..000000000
--- a/testcases/kernel/fs/dmapi/dm_vars.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * FILE NAME : dm_vars.h
- *
- * PURPOSE : Define variation number bases for all DMAPI test cases
- */
-
-/* session.c */
-#define CREATE_SESSION_BASE 1000
-#define DESTROY_SESSION_BASE 1050
-#define GETALL_SESSIONS_BASE 1100
-#define QUERY_SESSION_BASE 1150
-
-/* handle.c */
-#define PATH_TO_HANDLE_BASE 1200
-#define FD_TO_HANDLE_BASE 1250
-#define PATH_TO_FSHANDLE_BASE 1300
-#define HANDLE_TO_FSHANDLE_BASE 1350
-#define HANDLE_CMP_BASE 1400
-#define HANDLE_FREE_BASE 1450
-#define HANDLE_IS_VALID_BASE 1500
-#define HANDLE_HASH_BASE 1550
-#define HANDLE_TO_FSID_BASE 1600
-#define HANDLE_TO_IGEN_BASE 1650
-#define HANDLE_TO_INO_BASE 1700
-#define MAKE_HANDLE_BASE 1750
-#define MAKE_FSHANDLE_BASE 1800
-#define HANDLE_TO_PATH_BASE 1850
-#define SYNC_BY_HANDLE_BASE 1900
-
-/* event_sn.c */
-#define DIR_SYNC_NAMESP_EVENT_BASE 1950
-#define FILE_SYNC_NAMESP_EVENT_BASE 2000
-
-/* event_sd.c */
-#define FILE_READ_DATA_EVENT_BASE 2050
-#define FILE_WRITE_DATA_EVENT_BASE 2100
-#define FILE_TRUNC_DATA_EVENT_BASE 2150
-
-/* event_an.c */
-#define DIR_ASYNC_NAMESP_EVENT_BASE 2200
-#define FILE_ASYNC_NAMESP_EVENT_BASE 2250
-
-/* pmr_pre.c */
-#define SET_REGION_BASE 2300
-
-/* pmr_post.c */
-#define GET_REGION_BASE 2350
-
-/* event_am.c */
-#define DIR_ASYNC_META_EVENT_BASE 2400
-#define FILE_ASYNC_META_EVENT_BASE 2450
-#define SET_RETURN_ON_DESTROY_BASE 2500
-
-/* hole.c */
-#define GET_ALLOCINFO_BASE 2550
-#define PROBE_HOLE_BASE 2600
-#define PUNCH_HOLE_BASE 2650
-
-/* invis.c */
-#define READ_INVIS_BASE 2700
-#define WRITE_INVIS_BASE 2750
-
-/* attr.c */
-#define SET_DMATTR_BASE 2800
-#define GET_DMATTR_BASE 2850
-#define REMOVE_DMATTR_BASE 2900
-#define GETALL_DMATTR_BASE 2950
-#define SET_FILEATTR_BASE 3000
-#define GET_FILEATTR_BASE 3050
-#define INIT_ATTRLOC_BASE 3100
-#define GET_DIRATTRS_BASE 3150
-#define SET_INHERIT_BASE 3200
-#define CLEAR_INHERIT_BASE 3250
-#define GETALL_INHERIT_BASE 3300
-
-/* event_us.c */
-#define CREATE_USEREVENT_BASE 3350
-#define SEND_MSG_BASE 3400
-#define FIND_EVENTMSG_BASE 3450
-
-/* disp.c */
-#define GET_CONFIG_EVENTS_BASE 3500
-#define SET_DISP_BASE 3550
-#define GETALL_DISP_BASE 3600
-#define SET_EVENTLIST_BASE 3650
-#define GET_EVENTLIST_BASE 3800
-
-/* config.c */
-#define GET_CONFIG_BASE 3850
-
-/* objref.c */
-#define OBJ_REF_HOLD_BASE 3900
-#define OBJ_REF_RELE_BASE 3950
-#define OBJ_REF_QUERY_BASE 4000
-
-/* mount.c */
-#define GET_MOUNTINFO_BASE 4050
-
-/* token.c */
-#define GETALL_TOKENS_BASE 4100
-
-/* right.c */
-#define REQUEST_RIGHT_BASE 4150
-#define RELEASE_RIGHT_BASE 4200
-#define QUERY_RIGHT_BASE 4250
-#define UPGRADE_RIGHT_BASE 4300
-#define DOWNGRADE_RIGHT_BASE 4350
-
-/* mmap.c */
-#define MMAP_READ_BASE 4400
-#define MMAP_WRITE_BASE 4450
-
-/* event.c */
-#define GET_EVENTS_BASE 4500
-#define RESPOND_EVENT_BASE 4550
-#define MOVE_EVENT_BASE 4600
-#define PENDING_BASE 4650
diff --git a/testcases/kernel/fs/dmapi/event.c b/testcases/kernel/fs/dmapi/event.c
deleted file mode 100644
index adc4681bc..000000000
--- a/testcases/kernel/fs/dmapi/event.c
+++ /dev/null
@@ -1,1907 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : event.c
- *
- * VARIATIONS : 41
- *
- * API'S TESTED : dm_get_events
- * dm_respond_event
- * dm_move_event
- * dm_pending
- */
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include <signal.h>
-#include "dm_test.h"
-
-#define MAX_EVENT (sizeof(dmMsgBuf)/(MSG_DATALEN+sizeof(dm_eventmsg_t)))
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char mountPt[FILENAME_MAX];
-char deviceNm[FILENAME_MAX];
-char *szFuncName;
-
-/* Variables for thread communications */
-int expectedNumMsg;
-u_int eventsFlags;
-int rcRespond;
-int errnoRespond;
-
-void *Thread(void *);
-
-void LogEventMsgs(void *bufp)
-{
- int i = 0;
- dm_eventmsg_t *em = (dm_eventmsg_t *) bufp;
-
- while (em != NULL) {
- DMLOG_PRINT(DMLVL_DEBUG, " eventmsg %d:\n", i++);
- DMLOG_PRINT(DMLVL_DEBUG, " ev_type: %d\n", em->ev_type);
- DMLOG_PRINT(DMLVL_DEBUG, " ev_token: %d\n", em->ev_token);
- DMLOG_PRINT(DMLVL_DEBUG, " ev_sequence: %d\n",
- em->ev_sequence);
- DMLOG_PRINT(DMLVL_DEBUG, " ev_data: length %d, value %s\n",
- DM_GET_LEN(em, ev_data), DM_GET_VALUE(em, ev_data,
- dm_eventtype_t));
-
- em = DM_STEP_TO_NEXT(em, dm_eventmsg_t *);
- }
-}
-
-dm_eventmsg_t *GetSyncEventMsg(void *bufp)
-{
- dm_eventmsg_t *em = (dm_eventmsg_t *) bufp;
-
- while (em != NULL) {
- if ((em->ev_type == DM_EVENT_USER)
- && (em->ev_token != DM_INVALID_TOKEN)) {
- return em;
- }
- em = DM_STEP_TO_NEXT(em, dm_eventmsg_t *);
- }
-
- return NULL;
-}
-
-int GetNumEventMsg(void *bufp)
-{
- dm_eventmsg_t *em = (dm_eventmsg_t *) bufp;
- int i = 0;
-
- while (em != NULL) {
- i++;
- em = DM_STEP_TO_NEXT(em, dm_eventmsg_t *);
- }
- return i;
-}
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI move event tests\n");
-
- szFuncName = "dm_get_events";
-
- /*
- * TEST : dm_get_events - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 1)) {
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_get_events(INVALID_ADDR, 0, 0, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_get_events - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 2)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 2));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 3)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 3));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 4)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 4));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - !DM_EV_WAIT with no messages
- * EXPECTED: rc = -1, errno = EAGAIN
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 5)) {
-
- /* Variation set up */
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 5));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - !DM_EV_WAIT with one message
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 6)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- expectedNumMsg = 1;
- eventsFlags = 0;
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 6));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - DM_EV_WAIT with one message
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 7)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- expectedNumMsg = 1;
- eventsFlags = DM_EV_WAIT;
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 7));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - !DM_EV_WAIT with two messages
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 8)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- expectedNumMsg = 2;
- eventsFlags = 0;
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_send_msg(sid, DM_MSGTYPE_ASYNC, MSG_DATALEN, buf);
- if (rc != -1) {
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 8));
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - DM_EV_WAIT with two messages
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 9)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- expectedNumMsg = 2;
- eventsFlags = DM_EV_WAIT;
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_send_msg(sid, DM_MSGTYPE_ASYNC, MSG_DATALEN, buf);
- if (rc != -1) {
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 9));
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_get_events - !DM_EV_WAIT with more than MAX_EVENT messages
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_EVENTS_BASE + 10)) {
- int i, j;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- expectedNumMsg = MAX_EVENT;
- eventsFlags = 0;
- for (i = 0, rc = 0; i < MAX_EVENT + 1 && rc == 0; i++) {
- j = sprintf(buf, "Multi event message %d", i);
- rc = dm_send_msg(sid, DM_MSGTYPE_ASYNC, j + 1, buf);
- }
- if (rc != -1) {
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(GET_EVENTS_BASE + 10));
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- j = sprintf(buf, "Multi event message %d", i);
- dm_send_msg(sid, DM_MSGTYPE_SYNC, j + 1, buf);
- pthread_join(tid, NULL);
- }
- }
-
- szFuncName = "dm_respond_event";
-
- /*
- * TEST : dm_respond_event - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 1)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_respond_event(INVALID_ADDR, token,
- DM_RESP_CONTINUE, 0, sizeof(buf),
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_respond_event - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 2)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_respond_event(DM_NO_SESSION, token,
- DM_RESP_CONTINUE, 0, sizeof(buf),
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_respond_event - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 3)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_respond_event(sid, INVALID_ADDR, DM_RESP_CONTINUE, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_respond_event - DM_NO_TOKEN token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 4)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN token)\n", szFuncName);
- rc = dm_respond_event(sid, DM_NO_TOKEN, DM_RESP_CONTINUE, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_respond_event - DM_INVALID_TOKEN token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 5)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_INVALID_TOKEN token)\n",
- szFuncName);
- rc = dm_respond_event(sid, DM_INVALID_TOKEN, DM_RESP_CONTINUE,
- 0, sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_respond_event - invalid response
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 6)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid response)\n",
- szFuncName);
- rc = dm_respond_event(sid, token, INVALID_ADDR, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_respond_event - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- *
- * This variation uncovered XFS BUG #37 (0 returned instead of -1 and
- * E2BIG)
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 7)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid response)\n",
- szFuncName);
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- INVALID_ADDR, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_respond_event - invalidated token
- * EXPECTED: rc = -1, errno = ESRCH
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 8)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc != -1) {
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- sizeof(buf), buf);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated token)\n",
- szFuncName);
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- sizeof(buf), buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ESRCH);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_respond_event - DM_RESP_INVALID
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 9)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(RESPOND_EVENT_BASE + 9));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_respond_event - DM_RESP_CONTINUE with zero reterror
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 10)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(RESPOND_EVENT_BASE + 10));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread continues variation */
- rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN,
- buf);
- if (rcRespond == 0) {
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected dm_send_msg rc = %d\n",
- szFuncName, rcRespond, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected dm_send_msg rc = %d and errno %d\n",
- szFuncName, rcRespond, rc,
- errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rcRespond,
- errnoRespond);
- DMVAR_FAIL();
- }
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_respond_event - DM_RESP_CONTINUE with non-zero reterror
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 11)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(RESPOND_EVENT_BASE + 11));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_respond_event - DM_RESP_ABORT with zero reterror
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 12)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(RESPOND_EVENT_BASE + 12));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_respond_event - DM_RESP_ABORT with non-zero reterror
- * EXPECTED: rc = ABORT_ERRNO
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 13)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(RESPOND_EVENT_BASE + 13));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread continues variation */
- rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN,
- buf);
- if (rcRespond == 0) {
- if (rc == -1) {
- if (errno == ABORT_ERRNO) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and dm_send_msg rc = %d\n",
- szFuncName,
- rcRespond, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and dm_send_msg rc = %d but unexpected errno (%d vs %d)\n",
- szFuncName,
- rcRespond, rc,
- errno, ABORT_ERRNO);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected dm_send_msg rc (%d vs %d)\n",
- szFuncName, rcRespond, rc,
- -1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rcRespond,
- errnoRespond);
- DMVAR_FAIL();
- }
- pthread_join(tid, NULL);
- }
- }
-
- /*
- * TEST : dm_respond_event - DM_RESP_DONTCARE
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RESPOND_EVENT_BASE + 14)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = pthread_create(&tid, NULL, Thread,
- (void *)(RESPOND_EVENT_BASE + 14));
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Message thread finishes off variation */
- dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- pthread_join(tid, NULL);
- }
- }
-
- szFuncName = "dm_move_event";
-
- /*
- * TEST : dm_move_event - invalid srcsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 1)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid srcsid)\n",
- szFuncName);
- rc = dm_move_event(INVALID_ADDR, token, targsid,
- &rtoken);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - DM_NO_SESSION srcsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 2)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION srcsid)\n",
- szFuncName);
- rc = dm_move_event(DM_NO_SESSION, token, targsid,
- &rtoken);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 3)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_move_event(sid, INVALID_ADDR, targsid, &rtoken);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - invalid targetsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 4)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid targetsid)\n",
- szFuncName);
- rc = dm_move_event(sid, token, INVALID_ADDR, &rtoken);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - DM_NO_SESSION targetsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 5)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_NO_SESSION targetsid)\n",
- szFuncName);
- rc = dm_move_event(sid, token, DM_NO_SESSION, &rtoken);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - invalid rtokenp
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #36 (event moved to targetsid
- * despite failure)
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 6)) {
- dm_sessid_t targsid;
- dm_token_t token;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rtokenp)\n",
- szFuncName);
- rc = dm_move_event(sid, token, targsid,
- (dm_token_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - token not in session
- * EXPECTED: rc = -1, errno = ENOENT
- *
- * This variation uncovered XFS BUG #34 (ESRCH returned instead of
- * ENOENT)
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 7)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(token not in session)\n",
- szFuncName);
- rc = dm_move_event(targsid, token, sid, &rtoken);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - srcsid == targetsid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 8)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(srcsid == targetsid)\n",
- szFuncName);
- rc = dm_move_event(sid, token, sid, &rtoken);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rtoken = %d\n",
- rtoken);
- rc = dm_find_eventmsg(sid, rtoken,
- sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && rlen > 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but token %d NOT in src/target session %d\n",
- szFuncName, 0, token, sid);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid, rtoken, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_move_event - srcsid != targetsid
- * EXPECTED: rc = 0
- *
- * This variation uncovered XFS BUG #35 (ESRCH returned instead of
- * EINVAL)
- */
- if (DMVAR_EXEC(MOVE_EVENT_BASE + 9)) {
- dm_sessid_t targsid;
- dm_token_t token, rtoken;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &targsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, buf,
- &token)) == -1) {
- dm_destroy_session(targsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(srcsid != targetsid)\n",
- szFuncName);
- rc = dm_move_event(sid, token, targsid, &rtoken);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rtoken = %d\n",
- rtoken);
- rc = dm_find_eventmsg(sid, token,
- sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == -1 && errno == EINVAL) {
- rc = dm_find_eventmsg(targsid, rtoken,
- sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && rlen > 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but token %d NOT in target session %d\n",
- szFuncName, 0,
- token, targsid);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but token %d still in source session %d\n",
- szFuncName, 0, token, sid);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(targsid, rtoken, DM_RESP_CONTINUE,
- 0, 0, NULL);
- rc |= dm_destroy_session(targsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- szFuncName = "dm_pending";
-
- /*
- * TEST : dm_pending - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PENDING_BASE + 1)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
- dm_timestruct_t delay;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_pending(INVALID_ADDR, token, &delay);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_pending - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PENDING_BASE + 2)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
- dm_timestruct_t delay;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_pending(DM_NO_SESSION, token, &delay);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_pending - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PENDING_BASE + 3)) {
- dm_timestruct_t delay;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_pending(sid, INVALID_ADDR, &delay);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_pending - DM_NO_TOKEN token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PENDING_BASE + 4)) {
- dm_timestruct_t delay;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN token)\n", szFuncName);
- rc = dm_pending(sid, DM_NO_TOKEN, &delay);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_pending - DM_INVALID_TOKEN token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PENDING_BASE + 5)) {
- dm_timestruct_t delay;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_INVALID_TOKEN token)\n",
- szFuncName);
- rc = dm_pending(sid, DM_INVALID_TOKEN, &delay);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_pending - invalid delay
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PENDING_BASE + 6)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_pending(sid, token,
- (dm_timestruct_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_respond_event - invalidated token
- * EXPECTED: rc = -1, errno = ESRCH
- */
- if (DMVAR_EXEC(PENDING_BASE + 7)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
- dm_timestruct_t delay;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc != -1) {
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- sizeof(buf), buf);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated token)\n",
- szFuncName);
- rc = dm_pending(sid, token, &delay);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ESRCH);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_pending - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PENDING_BASE + 8)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
- dm_timestruct_t delay;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_pending(sid, token, &delay);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- dm_token_t token;
- size_t rlen;
- dm_eventmsg_t *dmMsg;
- int numMsg;
-
- EVENT_DELIVERY_DELAY;
-
- switch ((long)parm) {
- case GET_EVENTS_BASE + 2:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n", szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, 0, dmMsgBuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0) {
- token = ((dm_eventmsg_t *) dmMsgBuf)->ev_token;
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- break;
-
- case GET_EVENTS_BASE + 3:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n", szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- (void *)INVALID_ADDR, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0) {
- token = ((dm_eventmsg_t *) dmMsgBuf)->ev_token;
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- break;
-
- case GET_EVENTS_BASE + 4:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n", szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0) {
- token = ((dm_eventmsg_t *) dmMsgBuf)->ev_token;
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- break;
-
- case GET_EVENTS_BASE + 5:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(!DM_EV_WAIT with no messages)\n",
- szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EAGAIN);
-
- /* Variation clean up */
-
- break;
-
- case GET_EVENTS_BASE + 6:
- case GET_EVENTS_BASE + 7:
- case GET_EVENTS_BASE + 8:
- case GET_EVENTS_BASE + 9:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%s with %d message(s))\n",
- szFuncName,
- (eventsFlags & DM_EV_WAIT) ? "DM_EV_WAIT" :
- "!DM_EV_WAIT", expectedNumMsg);
- do {
- rlen = 0;
- rc = dm_get_events(sid, MAX_EVENT, eventsFlags,
- sizeof(dmMsgBuf), dmMsgBuf, &rlen);
- } while ((eventsFlags & DM_EV_WAIT) && (rc == -1)
- && (errno == EINTR) && (rlen == 0));
- if (rc == 0) {
- LogEventMsgs(dmMsgBuf);
- numMsg = GetNumEventMsg(dmMsgBuf);
- dmMsg = GetSyncEventMsg(dmMsgBuf);
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
-
- if (numMsg == expectedNumMsg) {
- if (dmMsg != NULL) {
- if (dmMsg->ev_type == DM_EVENT_USER) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected event (%d vs %d)\n",
- szFuncName, 0,
- dmMsg->ev_type,
- DM_EVENT_USER);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but no synchronous event\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected number of events (%d vs %d)\n",
- szFuncName, 0, numMsg,
- expectedNumMsg);
- DMVAR_FAIL();
- }
- } else {
- dmMsg = NULL;
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid,
- dmMsg ? dmMsg->
- ev_token : DM_INVALID_TOKEN,
- DM_RESP_CONTINUE, 0, 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
-
- break;
-
- case GET_EVENTS_BASE + 10:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%s with %d messages)\n",
- szFuncName,
- (eventsFlags & DM_EV_WAIT) ? "DM_EV_WAIT" :
- "!DM_EV_WAIT", expectedNumMsg);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "1st call:\n");
- LogEventMsgs(dmMsgBuf);
- numMsg = GetNumEventMsg(dmMsgBuf);
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "2nd call:\n");
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- LogEventMsgs(dmMsgBuf);
- dmMsg = GetSyncEventMsg(dmMsgBuf);
-
- if (numMsg == expectedNumMsg) {
- if (dmMsg != NULL) {
- if (dmMsg->ev_type ==
- DM_EVENT_USER) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName,
- 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected event (%d vs %d)\n",
- szFuncName,
- 0,
- dmMsg->
- ev_type,
- DM_EVENT_USER);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but no synchronous event\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected number of events (%d vs %d)\n",
- szFuncName, 0, numMsg,
- expectedNumMsg);
- DMVAR_FAIL();
- }
- } else {
- dmMsg = NULL;
- DMLOG_PRINT(DMLVL_ERR,
- "%s 2nd call failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
- } else {
- dmMsg = NULL;
- DMLOG_PRINT(DMLVL_ERR,
- "%s 1st call failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid,
- dmMsg ? dmMsg->
- ev_token : DM_INVALID_TOKEN,
- DM_RESP_CONTINUE, 0, 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
-
- break;
-
- case RESPOND_EVENT_BASE + 9:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RESP_INVALID)\n", szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && ((dmMsg = GetSyncEventMsg(dmMsgBuf)) != NULL)) {
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_INVALID, 0, 0, NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_CONTINUE, 0, 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain synchronous event! (rc = %d, errno = %d)\n",
- rc, errno);
- }
- break;
-
- case RESPOND_EVENT_BASE + 10:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RESP_CONTINUE with zero reterror)\n",
- szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && ((dmMsg = GetSyncEventMsg(dmMsgBuf)) != NULL)) {
- rcRespond =
- dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_CONTINUE, 0, 0, NULL);
- errnoRespond = rcRespond == -1 ? errno : 0;
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain synchronous event! (rc = %d, errno = %d)\n",
- rc, errno);
- }
- break;
-
- case RESPOND_EVENT_BASE + 11:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RESP_CONTINUE with non-zero reterror)\n",
- szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && ((dmMsg = GetSyncEventMsg(dmMsgBuf)) != NULL)) {
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_CONTINUE, ABORT_ERRNO, 0,
- NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_CONTINUE, 0, 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain synchronous event! (rc = %d, errno = %d)\n",
- rc, errno);
- }
- break;
-
- case RESPOND_EVENT_BASE + 12:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RESP_ABORT with zero reterror)\n",
- szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && ((dmMsg = GetSyncEventMsg(dmMsgBuf)) != NULL)) {
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_ABORT, 0, 0, NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_CONTINUE, 0, 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain synchronous event! (rc = %d, errno = %d)\n",
- rc, errno);
- }
- break;
-
- case RESPOND_EVENT_BASE + 13:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RESP_ABORT with non-zero reterror)\n",
- szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && ((dmMsg = GetSyncEventMsg(dmMsgBuf)) != NULL)) {
- rcRespond =
- dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_ABORT, ABORT_ERRNO, 0,
- NULL);
- errnoRespond = rcRespond == -1 ? errno : 0;
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain synchronous event! (rc = %d, errno = %d)\n",
- rc, errno);
- }
- break;
-
- case RESPOND_EVENT_BASE + 14:
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RESP_DONTCARE)\n", szFuncName);
- rc = dm_get_events(sid, MAX_EVENT, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- if (rc == 0 && ((dmMsg = GetSyncEventMsg(dmMsgBuf)) != NULL)) {
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_ABORT, 0, 0, NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, dmMsg->ev_token,
- DM_RESP_CONTINUE, 0, 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain synchronous event! (rc = %d, errno = %d)\n",
- rc, errno);
- }
- break;
-
- }
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/event_am.c b/testcases/kernel/fs/dmapi/event_am.c
deleted file mode 100644
index 67132256a..000000000
--- a/testcases/kernel/fs/dmapi/event_am.c
+++ /dev/null
@@ -1,2548 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : event_am.c
- *
- * VARIATIONS : 31
- *
- * EVENTS TESTED: DM_EVENT_ATTRIBUTE
- * DM_EVENT_CLOSE
- * DM_EVENT_DESTROY
- *
- * API'S TESTED : dm_set_return_on_destroy
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-
-/* Variables for thread communications */
-dm_eventtype_t eventExpected;
-dm_eventtype_t eventReceived;
-dm_response_t eventResponse;
-void *hanp1, *hanp2, *ahanp1;
-size_t hlen1, hlen2, ahlen1;
-char name1[FILENAME_MAX];
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int rc;
- int varStatus;
- char *szSessionInfo = "dm_test session info";
- char *szFuncName;
- dm_eventset_t events;
- dm_size_t maxAttrSize;
- void *fshanp;
- size_t fshlen;
- dm_eventset_t AMevents;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- remove(DummyFile);
- rmdir(DummySubdir);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI asynchronous metadata event tests\n");
-
- /*
- * First batch of tests will be with events enabled on file system,
- * so set up events on fs accordingly
- */
- rc = dm_path_to_fshandle(mountPt, &fshanp, &fshlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_handle(fs) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_ATTRIBUTE, events);
- DMEV_SET(DM_EVENT_CLOSE, events);
- rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist(fs) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- /*
- * TEST : chmod - enabled on fs
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 1)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- rc = mkdir(DummySubdir, DUMMY_DIR_RO_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s)\n", DummySubdir);
- rc = chmod(DummySubdir, O_RDWR);
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummySubdir, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (!(statfs.st_mode & O_RDWR)) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object mode NOT correct! (%x vs %x)\n",
- O_RDWR, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : chown - enabled on fs
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 2)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- rc = mkdir(DummySubdir, DUMMY_DIR_RO_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s)\n", DummySubdir);
- rc = chown(DummySubdir, DUMMY_UID, DUMMY_GID);
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummySubdir, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_uid != DUMMY_UID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object uid NOT correct! (%x vs %x)\n",
- DUMMY_UID, statfs.st_uid);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_gid != DUMMY_GID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object gid NOT correct! (%x vs %x)\n",
- DUMMY_GID, statfs.st_gid);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : close - enabled on fs
- * EXPECTED: DM_EVENT_CLOSE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 3)) {
- int fd1, fd2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CLOSE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((fd1 = open(DummySubdir, O_DIRECTORY)) == -1) {
- rmdir(DummySubdir);
- } else if ((fd2 = open(DummySubdir, O_DIRECTORY)) == -1) {
- close(fd1);
- rmdir(DummySubdir);
- }
- if (fd1 == -1 || fd2 == -1 || fd1 == fd2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1\n", fd1);
- rc = close(fd1);
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1 returned %d\n",
- fd1, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- eventExpected = DM_EVENT_CLOSE;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #2\n", fd2);
- rc = close(fd2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "close(%d) #2 returned %d\n", fd2,
- rc);
- EVENT_DELIVERY_DELAY;
- varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived);
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : chmod - enabled on fs
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 1)) {
- int fd;
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s)\n", DummyFile);
- rc = chmod(DummyFile, O_RDWR);
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummyFile, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (!(statfs.st_mode & O_RDWR)) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object mode NOT correct! (%x vs %x)\n",
- O_RDWR, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : chown - enabled on fs
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 2)) {
- int fd;
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s)\n", DummyFile);
- rc = chown(DummyFile, DUMMY_UID, DUMMY_GID);
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummyFile, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_uid != DUMMY_UID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object uid NOT correct! (%x vs %x)\n",
- DUMMY_UID, statfs.st_uid);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_gid != DUMMY_GID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object gid NOT correct! (%x vs %x)\n",
- DUMMY_GID, statfs.st_gid);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : close - enabled on fs
- * EXPECTED: DM_EVENT_CLOSE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 3)) {
- int fd1, fd2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CLOSE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd1 =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((fd2 = open(DummyFile, O_RDONLY)) == -1) {
- close(fd1);
- remove(DummyFile);
- }
- if (fd1 == -1 || fd2 == -1 || fd1 == fd2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1\n", fd1);
- rc = close(fd1);
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1 returned %d\n",
- fd1, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- eventExpected = DM_EVENT_CLOSE;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #2\n", fd2);
- rc = close(fd2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "close(%d) #2 returned %d\n", fd2,
- rc);
- EVENT_DELIVERY_DELAY;
- varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived);
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /* Wait for all pending messages to be handled */
- EVENT_DELIVERY_DELAY_LOOP;
-
- /*
- * Next batch of tests will be with events enabled on object, so
- * clear events on fs
- */
- rc = dm_path_to_fshandle(mountPt, &fshanp, &fshlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_handle failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist(fs) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(AMevents);
- DMEV_SET(DM_EVENT_ATTRIBUTE, AMevents);
- DMEV_SET(DM_EVENT_CLOSE, AMevents);
-
- /*
- * TEST : chmod - enabled on directory
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 4)) {
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- } else
- if ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &AMevents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s)\n", DummySubdir);
- rc = chmod(DummySubdir, O_RDWR);
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummySubdir, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (!(statfs.st_mode & O_RDWR)) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object mode NOT correct! (%x vs %x)\n",
- O_RDWR, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : chown - enabled on directory
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 5)) {
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- } else
- if ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &AMevents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s)\n", DummySubdir);
- rc = chown(DummySubdir, DUMMY_UID, DUMMY_GID);
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummySubdir, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_uid != DUMMY_UID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object uid NOT correct! (%x vs %x)\n",
- DUMMY_UID, statfs.st_uid);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_gid != DUMMY_GID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object gid NOT correct! (%x vs %x)\n",
- DUMMY_GID, statfs.st_gid);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : close - enabled on directory
- * EXPECTED: DM_EVENT_CLOSE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 6)) {
- int fd1, fd2;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CLOSE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((fd1 = open(DummySubdir, O_DIRECTORY)) == -1) {
- rmdir(DummySubdir);
- } else if ((fd2 = open(DummySubdir, O_DIRECTORY)) == -1) {
- close(fd1);
- rmdir(DummySubdir);
- } else if ((rc = dm_fd_to_handle(fd2, &hanp, &hlen)) == -1) {
- close(fd2);
- close(fd1);
- rmdir(DummySubdir);
- } else
- if ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &AMevents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd2);
- close(fd1);
- rmdir(DummySubdir);
- }
- if (fd1 == -1 || fd2 == -1 || fd1 == fd2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1\n", fd1);
- rc = close(fd1);
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1 returned %d\n",
- fd1, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- eventExpected = DM_EVENT_CLOSE;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #2\n", fd2);
- rc = close(fd2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "close(%d) #2 returned %d\n", fd2,
- rc);
- EVENT_DELIVERY_DELAY;
- varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived);
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : chmod - enabled on file
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else if (((rc = close(fd)) == -1) ||
- ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &AMevents,
- DM_EVENT_MAX)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s)\n", DummyFile);
- rc = chmod(DummyFile, O_RDWR);
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummyFile, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (!(statfs.st_mode & O_RDWR)) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object mode NOT correct! (%x vs %x)\n",
- O_RDWR, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : chown - enabled on file
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else if (((rc = close(fd)) == -1) ||
- ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &AMevents,
- DM_EVENT_MAX)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s)\n", DummyFile);
- rc = chown(DummyFile, DUMMY_UID, DUMMY_GID);
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- rc |= stat(DummyFile, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object/entry handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object handle NOT correct! (%lld vs %d)\n",
- ino, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_uid != DUMMY_UID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object uid NOT correct! (%x vs %x)\n",
- DUMMY_UID, statfs.st_uid);
- varStatus = DMSTAT_FAIL;
- } else if (statfs.st_gid != DUMMY_GID) {
- DMLOG_PRINT(DMLVL_ERR,
- "Object gid NOT correct! (%x vs %x)\n",
- DUMMY_GID, statfs.st_gid);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : close - enabled on file
- * EXPECTED: DM_EVENT_CLOSE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 6)) {
- int fd1, fd2;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CLOSE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd1 =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((fd2 = open(DummyFile, O_RDONLY)) == -1) {
- close(fd1);
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd2, &hanp, &hlen)) == -1) {
- close(fd2);
- close(fd1);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
- &AMevents, DM_EVENT_MAX)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd2);
- close(fd1);
- remove(DummyFile);
- }
- if (fd1 == -1 || fd2 == -1 || fd1 == fd2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1\n", fd1);
- rc = close(fd1);
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1 returned %d\n",
- fd1, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- eventExpected = DM_EVENT_CLOSE;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #2\n", fd2);
- rc = close(fd2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "close(%d) #2 returned %d\n", fd2,
- rc);
- EVENT_DELIVERY_DELAY;
- varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived);
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /* Wait for all pending messages to be handled */
- EVENT_DELIVERY_DELAY_LOOP;
-
- /*
- * Last batch of tests will be with events disabled
- */
-
- /*
- * TEST : chmod - disabled
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 7)) {
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- rc = mkdir(DummySubdir, DUMMY_DIR_RO_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s)\n", DummySubdir);
- rc = chmod(DummySubdir, O_RDWR);
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : chown - disabled
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 8)) {
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- rc = mkdir(DummySubdir, DUMMY_DIR_RO_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s)\n", DummySubdir);
- rc = chown(DummySubdir, DUMMY_UID, DUMMY_GID);
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : close - disabled
- * EXPECTED: DM_EVENT_CLOSE
- */
- if (DMVAR_EXEC(DIR_ASYNC_META_EVENT_BASE + 9)) {
- int fd1, fd2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CLOSE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((fd1 = open(DummySubdir, O_DIRECTORY)) == -1) {
- rmdir(DummySubdir);
- } else if ((fd2 = open(DummySubdir, O_DIRECTORY)) == -1) {
- close(fd1);
- rmdir(DummySubdir);
- }
- if (fd1 == -1 || fd2 == -1 || fd1 == fd2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1\n", fd1);
- rc = close(fd1);
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1 returned %d\n",
- fd1, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #2\n", fd2);
- rc = close(fd2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "close(%d) #2 returned %d\n", fd2,
- rc);
- EVENT_DELIVERY_DELAY;
- varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived);
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : chmod - disabled
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 7)) {
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s)\n", DummyFile);
- rc = chmod(DummyFile, O_RDWR);
- DMLOG_PRINT(DMLVL_DEBUG, "chmod(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : chown - disabled
- * EXPECTED: DM_EVENT_ATTRIBUTE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 8)) {
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_ATTRIBUTE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s)\n", DummyFile);
- rc = chown(DummyFile, DUMMY_UID, DUMMY_GID);
- DMLOG_PRINT(DMLVL_DEBUG, "chown(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : close - disabled
- * EXPECTED: DM_EVENT_CLOSE
- */
- if (DMVAR_EXEC(FILE_ASYNC_META_EVENT_BASE + 9)) {
- int fd1, fd2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CLOSE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- if ((fd1 =
- open(DummyFile, O_RDONLY | O_CREAT,
- DUMMY_FILE_RO_MODE)) == -1) {
- /* No clean up */
- } else if ((fd2 = open(DummyFile, O_RDONLY)) == -1) {
- close(fd1);
- remove(DummyFile);
- }
- if (fd1 == -1 || fd2 == -1 || fd1 == fd2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1\n", fd1);
- rc = close(fd1);
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #1 returned %d\n",
- fd1, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "close(%d) #2\n", fd2);
- rc = close(fd2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "close(%d) #2 returned %d\n", fd2,
- rc);
- EVENT_DELIVERY_DELAY;
- varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived);
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /* From here on out we're only interested in the destroy event */
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_DESTROY, events);
- rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_get_config(fshanp, fshlen, DM_CONFIG_MAX_ATTR_ON_DESTROY,
- &maxAttrSize);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_config failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- DMLOG_PRINT(DMLVL_DEBUG, "DM_CONFIG_MAX_ATTR_ON_DESTROY %d\n",
- maxAttrSize);
- }
-
- szFuncName = "dm_set_return_on_destroy";
-
- /*
- * TEST : dm_set_return_on_destroy - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 1)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(INVALID_ADDR, fshanp,
- fshlen, DM_NO_TOKEN,
- &attrname, DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 2)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, (void *)INVALID_ADDR,
- fshlen, DM_NO_TOKEN,
- &attrname, DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 3)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, fshanp, INVALID_ADDR,
- DM_NO_TOKEN, &attrname,
- DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 4)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, fshanp, fshlen,
- INVALID_ADDR, &attrname,
- DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - invalid attrnamep
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #14 (non-0 return code from
- * copy_from_user returned)
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 5)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, fshanp, fshlen,
- DM_NO_TOKEN,
- (dm_attrname_t *)
- INVALID_ADDR, DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 6)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(DM_NO_SESSION, fshanp,
- fshlen, DM_NO_TOKEN,
- &attrname, DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - different sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 7)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
- dm_sessid_t newsid;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- } else
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(different sid)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(newsid, fshanp, fshlen,
- DM_NO_TOKEN, &attrname,
- DM_FALSE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, hanp, hlen,
- DM_NO_TOKEN, &attrname,
- DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 9)) {
- void *hanp;
- size_t hlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- } else
- if ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1) {
- rmdir(DummySubdir);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, hanp, hlen,
- DM_NO_TOKEN, &attrname,
- DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 10)) {
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_set_return_on_destroy(sid, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &attrname, DM_TRUE);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_set_return_on_destroy - valid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 11)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char buf[ATTR_VALUELEN];
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, sizeof(buf), buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_set_return_on_destroy(sid, fshanp, fshlen,
- DM_NO_TOKEN, &attrname,
- DM_TRUE);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - zero length attribute
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 12)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
- 0, 0, NULL)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(zero len attr)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, fshanp, fshlen,
- DM_NO_TOKEN, &attrname,
- DM_TRUE);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_set_return_on_destroy - attribute too big
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_RETURN_ON_DESTROY_BASE + 13)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_attrname_t attrname;
- char *buf;
-
- /* Variation set up */
- memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
- memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else if ((buf = malloc(maxAttrSize + 1)) == NULL) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- } else if ((memset(buf, '4', maxAttrSize + 1) == NULL) ||
- ((rc =
- dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
- &attrname, 0, maxAttrSize + 1,
- buf)) == -1)
- ||
- ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp,
- &fshlen)) == -1)) {
- free(buf);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1 || buf == NULL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(attr too big)\n",
- szFuncName);
- rc = dm_set_return_on_destroy(sid, fshanp, fshlen,
- DM_NO_TOKEN, &attrname,
- DM_TRUE);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- free(buf);
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- dm_handle_free(fshanp, fshlen);
-
- /* Wait for all pending messages to be handled */
- EVENT_DELIVERY_DELAY_LOOP;
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- int type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- /*rc = dm_request_right(sid, lhanp, lhlen, token, DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "dm_request_right failed! (rc = %d, errno = %d)\n", rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } */
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_ATTRIBUTE, events);
- DMEV_SET(DM_EVENT_CLOSE, events);
- DMEV_SET(DM_EVENT_DESTROY, events);
- rc = dm_set_disp(sid, lhanp, lhlen, DM_NO_TOKEN,
- &events, DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- /*rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "dm_request_right failed! (rc = %d, errno = %d)\n", rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } */
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_PREUNMOUNT) {
- /* SPECIAL CASE: need to set response */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_PREUNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle: %p\n",
- DM_GET_VALUE(nse, ne_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle length: %d\n",
- DM_GET_LEN(nse, ne_handle2));
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set response and bMounted */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_UNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_POSTCREATE) {
- /* SPECIAL CASE: need to save entry info */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- hanp2 = DM_GET_VALUE(nse, ne_handle2, void *);
- hlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(name1, DM_GET_VALUE(nse, ne_name1, char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTCREATE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " Parent handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Parent handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Entry handle: %p\n", hanp2);
- DMLOG_PRINT(DMLVL_DEBUG, " Entry handle length: %d\n",
- hlen2);
- DMLOG_PRINT(DMLVL_DEBUG, " Entry name: %s\n", name1);
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
-
- /* No response needed */
- response = DM_RESP_INVALID;
- } else {
- eventReceived = type;
- response = eventResponse;
-
- switch (type) {
- case DM_EVENT_ATTRIBUTE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- ahanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- ahlen1 = DM_GET_LEN(nse, ne_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_ATTRIBUTE\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Object handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Object handle length: %d\n",
- ahlen1);
-
- response = DM_RESP_INVALID;
- break;
- }
-
- case DM_EVENT_CLOSE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- ahanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- ahlen1 = DM_GET_LEN(nse, ne_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_CLOSE\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Object handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Object handle length: %d\n",
- ahlen1);
-
- response = DM_RESP_INVALID;
- break;
- }
-
- case DM_EVENT_DESTROY:
- {
- dm_destroy_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_destroy_event_t *);
- ahanp1 =
- DM_GET_VALUE(de, ds_handle, void *);
- ahlen1 = DM_GET_LEN(de, ds_handle);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_DESTROY\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Object handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Object handle length: %d\n",
- ahlen1);
- if (de->ds_attrname.an_chars[0]) {
- int attrlen =
- DM_GET_LEN(de, ds_attrcopy);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- " Attribute name: %.*s\n",
- 8,
- de->ds_attrname.
- an_chars);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Attribute value length: %d\n",
- attrlen);
- if (attrlen) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " Attribute value: %s\n",
- DM_GET_VALUE
- (de,
- ds_attrcopy,
- char *));
- }
- }
-
- response = DM_RESP_INVALID;
- break;
- }
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/event_an.c b/testcases/kernel/fs/dmapi/event_an.c
deleted file mode 100644
index 7d9510445..000000000
--- a/testcases/kernel/fs/dmapi/event_an.c
+++ /dev/null
@@ -1,3580 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : event_an.c
- *
- * VARIATIONS : 34
- *
- * EVENTS TESTED: DM_EVENT_POSTCREATE
- * DM_EVENT_POSTREMOVE
- * DM_EVENT_POSTRENAME
- * DM_EVENT_POSTSYMLINK
- * DM_EVENT_POSTLINK
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummyFile2[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-char DummySubdir2[FILENAME_MAX];
-char DummyLink[FILENAME_MAX];
-char DummySubdir2File[FILENAME_MAX];
-char DummySubdir2Subdir[FILENAME_MAX];
-
-/* Variables for thread communications */
-dm_eventtype_t eventExpected;
-dm_eventtype_t eventReceived;
-dm_response_t eventResponse;
-void *hanp1, *hanp2, *ahanp1, *ahanp2;
-size_t hlen1, hlen2, ahlen1, ahlen2;
-char name1[FILENAME_MAX], name2[FILENAME_MAX], aname1[FILENAME_MAX],
- aname2[FILENAME_MAX];
-dm_mode_t mode, amode;
-int aretcode;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int rc;
- int varStatus;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
- void *fshanp, *dhanp;
- size_t fshlen, dhlen;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummyFile2, "%s/%s", mountPt, DUMMY_FILE2);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
- sprintf(DummySubdir2, "%s/%s", mountPt, DUMMY_SUBDIR2);
- sprintf(DummyLink, "%s/%s", mountPt, DUMMY_LINK);
- sprintf(DummySubdir2File, "%s/%s", mountPt, DUMMY_SUBDIR2_FILE);
- sprintf(DummySubdir2Subdir, "%s/%s", mountPt,
- DUMMY_SUBDIR2_SUBDIR);
-
- remove(DummySubdir2File);
- rmdir(DummySubdir2Subdir);
- remove(DummyFile);
- remove(DummyFile2);
- unlink(DummyLink);
- rmdir(DummySubdir);
- rmdir(DummySubdir2);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI asynchronous namespace event tests\n");
-
- /*
- * First batch of tests will be with events enabled on file system,
- * so set up events on fs accordingly
- */
- rc = dm_path_to_fshandle(mountPt, &fshanp, &fshlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_handle(fs) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_CREATE, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_REMOVE, events);
- DMEV_SET(DM_EVENT_POSTREMOVE, events);
- DMEV_SET(DM_EVENT_RENAME, events);
- DMEV_SET(DM_EVENT_POSTRENAME, events);
- DMEV_SET(DM_EVENT_SYMLINK, events);
- DMEV_SET(DM_EVENT_POSTSYMLINK, events);
- DMEV_SET(DM_EVENT_LINK, events);
- DMEV_SET(DM_EVENT_POSTLINK, events);
- rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist(fs) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- /*
- * TEST : mkdir - enabled on fs
- * EXPECTED: DM_EVENT_POSTCREATE
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 1)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTCREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir,
- rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= stat(DummySubdir, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (dm_handle_cmp(hanp1, hlen1, ahanp1, ahlen1)
- != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : rmdir - enabled on fs
- * EXPECTED: DM_EVENT_POSTREMOVE
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 2)) {
- dm_ino_t ino;
- struct stat statfs;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTREMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = stat(DummySubdir, &statfs)) == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
- rc = rmdir(DummySubdir);
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : mv - enabled on fs
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 3)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir, DummySubdir2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (ahanp1, ahlen1, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink - enabled on fs
- * EXPECTED: DM_EVENT_POSTSYMLINK
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 4)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTSYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n",
- DummySubdir, DummySubdir2);
- rc = symlink(DummySubdir, DummySubdir2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= lstat(DummySubdir2, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DummySubdir) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- aname2, DummySubdir);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummySubdir2);
- rc |= rmdir(DummySubdir);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link - enabled on fs
- * EXPECTED: DM_EVENT_POSTLINK
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 5)) {
-#ifdef DIRECTORY_LINKS
- dm_ino_t ino, ino1, ino2;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir,
- DummyLink);
- rc = link(DummySubdir, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummySubdir, DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%d vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%d vs %d)\n",
- ino2, ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- rc |= unlink(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with DIRECTORY_LINKS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : open - enabled on fs
- * EXPECTED: DM_EVENT_POSTCREATE
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 1)) {
- int fd;
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTCREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
- fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile,
- rc);
- rc = (fd == -1) ? -1 : 0;
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= stat(DummyFile, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (dm_handle_cmp(hanp1, hlen1, ahanp1, ahlen1)
- != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : remove - enabled on fs
- * EXPECTED: DM_EVENT_POSTREMOVE
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 2)) {
- int fd;
- dm_ino_t ino;
- struct stat statfs;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTREMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if (((rc = close(fd)) == -1) ||
- ((rc = stat(DummyFile, &statfs)) == -1)) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
- rc = remove(DummyFile);
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : mv - enabled on fs
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 3)) {
- int fd;
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummyFile, DummyFile2);
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummyFile, DummyFile2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n", DummyFile,
- DummyFile2, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (ahanp1, ahlen1, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_FILE2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_FILE2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink - enabled on fs
- * EXPECTED: DM_EVENT_POSTSYMLINK
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 4)) {
- int fd;
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTSYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile,
- DummyLink);
- rc = symlink(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n", DummyFile,
- DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= lstat(DummyLink, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DummyFile) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- aname2, DummyFile);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummyLink);
- rc |= remove(DummyFile);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link - enabled on fs
- * EXPECTED: DM_EVENT_POSTLINK
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 5)) {
- dm_ino_t ino, ino1, ino2;
- void *hanp;
- size_t hlen;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile,
- DummyLink);
- rc = link(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummyFile, DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%d vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%d vs %d)\n",
- ino2, ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- rc |= remove(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /* Wait for all pending messages to be handled */
- EVENT_DELIVERY_DELAY_LOOP;
-
- /*
- * Next batch of tests will be with events enabled on directory, so
- * clear events on fs and set up events on dir accordingly
- */
- rc = dm_path_to_fshandle(mountPt, &fshanp, &fshlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_handle failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist(fs) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_path_to_handle(mountPt, &dhanp, &dhlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_handle failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_CREATE, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_REMOVE, events);
- DMEV_SET(DM_EVENT_POSTREMOVE, events);
- DMEV_SET(DM_EVENT_RENAME, events);
- DMEV_SET(DM_EVENT_POSTRENAME, events);
- DMEV_SET(DM_EVENT_SYMLINK, events);
- DMEV_SET(DM_EVENT_POSTSYMLINK, events);
- DMEV_SET(DM_EVENT_LINK, events);
- DMEV_SET(DM_EVENT_POSTLINK, events);
- rc = dm_set_eventlist(sid, dhanp, dhlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist(dir) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- /*
- * TEST : mkdir - enabled on directory
- * EXPECTED: DM_EVENT_POSTCREATE
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 6)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTCREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir,
- rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= stat(DummySubdir, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (dm_handle_cmp(hanp1, hlen1, ahanp1, ahlen1)
- != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : rmdir - enabled on directory
- * EXPECTED: DM_EVENT_POSTREMOVE
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 7)) {
- dm_ino_t ino;
- struct stat statfs;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTREMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = stat(DummySubdir, &statfs)) == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
- rc = rmdir(DummySubdir);
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : mv - enabled on source and destination directory
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 8)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir, DummySubdir2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (ahanp1, ahlen1, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : mv - enabled on source directory
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 9)) {
- void *dhanp;
- size_t dhlen;
- dm_ino_t ino1, ino2, dino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir, DummySubdir2Subdir);
- EVENT_DELIVERY_DELAY;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DummySubdir2, DUMMY_DIR_RW_MODE)) == -1) {
- rmdir(DummySubdir);
- } else
- if ((rc =
- dm_path_to_handle(DummySubdir2, &dhanp,
- &dhlen)) == -1) {
- rmdir(DummySubdir2);
- rmdir(DummySubdir);
- } else if ((rc = dm_handle_to_ino(dhanp, dhlen, &dino)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DummySubdir2);
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir, DummySubdir2Subdir);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir, DummySubdir2Subdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != dino) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT correct! (%lld vs %d)\n",
- ino2, dino);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir2Subdir);
- rc |= rmdir(DummySubdir2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : mv - enabled on destination directory
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 10)) {
- void *dhanp;
- size_t dhlen;
- dm_ino_t ino1, ino2, dino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir2Subdir, DummySubdir);
- EVENT_DELIVERY_DELAY;
- if ((rc = mkdir(DummySubdir2, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DummySubdir2Subdir, DUMMY_DIR_RW_MODE))
- == -1) {
- rmdir(DummySubdir2);
- } else
- if ((rc =
- dm_path_to_handle(DummySubdir2, &dhanp,
- &dhlen)) == -1) {
- rmdir(DummySubdir2Subdir);
- rmdir(DummySubdir2);
- } else if ((rc = dm_handle_to_ino(dhanp, dhlen, &dino)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DummySubdir2Subdir);
- rmdir(DummySubdir2);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir2Subdir, DummySubdir);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir2Subdir, DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != dino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT correct! (%lld vs %d)\n",
- ino1, dino);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir2);
- rc |= rmdir(DummySubdir);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dhanp, dhlen);
- }
- }
-
- /*
- * TEST : symlink - enabled on directory
- * EXPECTED: DM_EVENT_POSTSYMLINK
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 11)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTSYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n",
- DummySubdir, DummySubdir2);
- rc = symlink(DummySubdir, DummySubdir2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= lstat(DummySubdir2, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DummySubdir) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- aname2, DummySubdir);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummySubdir2);
- rc |= rmdir(DummySubdir);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link - enabled on directory
- * EXPECTED: DM_EVENT_POSTLINK
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 12)) {
-#ifdef DIRECTORY_LINKS
- dm_ino_t ino, ino1, ino2;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir,
- DummyLink);
- rc = link(DummySubdir, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummySubdir, DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%d vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%d vs %d)\n",
- ino2, ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- rc |= unlink(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with DIRECTORY_LINKS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : open - enabled on directory
- * EXPECTED: DM_EVENT_POSTCREATE
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 6)) {
- int fd;
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTCREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
- fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile,
- rc);
- rc = (fd == -1) ? -1 : 0;
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= stat(DummyFile, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (dm_handle_cmp(hanp1, hlen1, ahanp1, ahlen1)
- != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : remove - enabled on directory
- * EXPECTED: DM_EVENT_POSTREMOVE
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 7)) {
- int fd;
- dm_ino_t ino;
- struct stat statfs;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTREMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if (((rc = close(fd)) == -1) ||
- ((rc = stat(DummyFile, &statfs)) == -1)) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
- rc = remove(DummyFile);
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (amode != statfs.st_mode) {
- DMLOG_PRINT(DMLVL_ERR,
- "Modes NOT same! (%d vs %d)\n",
- amode, statfs.st_mode);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : mv - enabled on source and destination directory
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 8)) {
- int fd;
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummyFile, DummyFile2);
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummyFile, DummyFile2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n", DummyFile,
- DummyFile2, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (ahanp1, ahlen1, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_FILE2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_FILE2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : mv - enabled on source directory
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 9)) {
- int fd;
- void *dhanp;
- size_t dhlen;
- dm_ino_t ino1, ino2, dino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummyFile, DummySubdir2File);
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if (((rc = close(fd)) == -1) ||
- ((rc =
- mkdir(DummySubdir2, DUMMY_DIR_RW_MODE)) == -1)) {
- remove(DummyFile);
- } else
- if ((rc =
- dm_path_to_handle(DummySubdir2, &dhanp,
- &dhlen)) == -1) {
- rmdir(DummySubdir2);
- remove(DummyFile);
- } else if ((rc = dm_handle_to_ino(dhanp, dhlen, &dino)) == -1) {
- dm_handle_free(dhanp, dhlen);
- rmdir(DummySubdir2);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummyFile, DummySubdir2File);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n", DummyFile,
- DummySubdir2File, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != dino) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT correct! (%lld vs %d)\n",
- ino2, dino);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummySubdir2File);
- rc |= rmdir(DummySubdir2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : mv - enabled on destination directory
- * EXPECTED: DM_EVENT_POSTRENAME
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 10)) {
- int fd;
- void *dhanp;
- size_t dhlen;
- dm_ino_t ino1, ino2, dino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTRENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir2File, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = mkdir(DummySubdir2, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummySubdir2File, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DummySubdir2);
- } else if ((rc = close(fd)) == -1) {
- remove(DummySubdir2File);
- rmdir(DummySubdir2);
- } else
- if ((rc =
- dm_path_to_handle(DummySubdir2, &dhanp,
- &dhlen)) == -1) {
- remove(DummySubdir2File);
- rmdir(DummySubdir2);
- } else if ((rc = dm_handle_to_ino(dhanp, dhlen, &dino)) == -1) {
- dm_handle_free(dhanp, dhlen);
- remove(DummySubdir2File);
- rmdir(DummySubdir2);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir2File, DummyFile);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir2File, DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != dino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT correct! (%lld vs %d)\n",
- ino1, dino);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp2, hlen2, ahanp2, ahlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- rc |= rmdir(DummySubdir2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink - enabled on directory
- * EXPECTED: DM_EVENT_POSTSYMLINK
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 11)) {
- int fd;
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTSYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile,
- DummyLink);
- rc = symlink(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n", DummyFile,
- DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- struct stat statfs;
-
- rc = dm_handle_to_ino(ahanp1, ahlen1, &ino1);
- rc |= dm_handle_to_ino(ahanp2, ahlen2, &ino2);
- rc |= lstat(DummyLink, &statfs);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != statfs.st_ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry handle NOT correct! (%lld vs %d)\n",
- ino2, statfs.st_ino);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, ahanp1, ahlen1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- aname1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(aname2, DummyFile) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- aname2, DummyFile);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, aname1) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry names NOT same! (%s vs %s)\n",
- name1, aname1);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, aname2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT same! (%s vs %s)\n",
- name2, aname2);
- varStatus = DMSTAT_FAIL;
- } else if (aretcode != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Return codes NOT same! (%d vs %d)\n",
- mode, amode);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummyLink);
- rc |= remove(DummyFile);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link - enabled on directory
- * EXPECTED: DM_EVENT_POSTLINK
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 12)) {
- dm_ino_t ino, ino1, ino2;
- void *hanp;
- size_t hlen;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_POSTLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile,
- DummyLink);
- rc = link(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummyFile, DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%d vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%d vs %d)\n",
- ino2, ino);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- rc |= remove(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /* Wait for all pending messages to be handled */
- EVENT_DELIVERY_DELAY_LOOP;
-
- /*
- * Last batch of tests will be with events disabled, so clear events
- * on dir
- */
- DMEV_ZERO(events);
- rc = dm_set_eventlist(sid, dhanp, dhlen, DM_NO_TOKEN, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist(dir) failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- /*
- * TEST : mkdir - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 13)) {
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir,
- rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : rmdir - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 14)) {
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
- rc = rmdir(DummySubdir);
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n",
- DummySubdir, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : mv - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 15)) {
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir, DummySubdir2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 16)) {
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n",
- DummySubdir, DummySubdir2);
- rc = symlink(DummySubdir, DummySubdir2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummySubdir2);
- rc |= rmdir(DummySubdir);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(DIR_ASYNC_NAMESP_EVENT_BASE + 17)) {
-#ifdef DIRECTORY_LINKS
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir,
- DummyLink);
- rc = link(DummySubdir, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummySubdir, DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- rc |= unlink(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with DIRECTORY_LINKS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : open - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 13)) {
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
- fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile,
- rc);
- rc = (fd == -1) ? -1 : 0;
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : remove - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 14)) {
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
- rc = remove(DummyFile);
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n",
- DummyFile, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : mv - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 15)) {
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummyFile, DummyFile2);
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummyFile, DummyFile2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n", DummyFile,
- DummyFile2, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile2);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 16)) {
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = close(fd)) == -1) {
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile,
- DummyLink);
- rc = symlink(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n", DummyFile,
- DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummyLink);
- rc |= remove(DummyFile);
- EVENT_DELIVERY_DELAY;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link - disabled
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_ASYNC_NAMESP_EVENT_BASE + 17)) {
- void *hanp;
- size_t hlen;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile,
- DummyLink);
- rc = link(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummyFile, DummyLink, rc);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- rc |= remove(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- int type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_CREATE, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_REMOVE, events);
- DMEV_SET(DM_EVENT_POSTREMOVE, events);
- DMEV_SET(DM_EVENT_RENAME, events);
- DMEV_SET(DM_EVENT_POSTRENAME, events);
- DMEV_SET(DM_EVENT_SYMLINK, events);
- DMEV_SET(DM_EVENT_POSTSYMLINK, events);
- DMEV_SET(DM_EVENT_LINK, events);
- DMEV_SET(DM_EVENT_POSTLINK, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_PREUNMOUNT) {
- /* SPECIAL CASE: need to set response */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_PREUNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle: %p\n",
- DM_GET_VALUE(nse, ne_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle length: %d\n",
- DM_GET_LEN(nse, ne_handle2));
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set response and bMounted */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_UNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- eventReceived = type;
- response = eventResponse;
-
- switch (type) {
- case DM_EVENT_CREATE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- mode = nse->ne_mode;
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_CREATE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
- mode);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry name: %s\n",
- name1);
-
- break;
- }
-
- case DM_EVENT_POSTCREATE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- amode = nse->ne_mode;
- ahanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- ahlen1 = DM_GET_LEN(nse, ne_handle1);
- ahanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- ahlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(aname1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- aretcode = nse->ne_retcode;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTCREATE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
- amode);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- ahlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry handle: %p\n",
- ahanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry handle length: %d\n",
- ahlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry name: %s\n",
- aname1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Return code: %x\n",
- aretcode);
-
- response = DM_RESP_INVALID;
- break;
- }
-
- case DM_EVENT_REMOVE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- mode = nse->ne_mode;
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_REMOVE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
- mode);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry name: %s\n",
- name1);
-
- break;
- }
-
- case DM_EVENT_POSTREMOVE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- amode = nse->ne_mode;
- ahanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- ahlen1 = DM_GET_LEN(nse, ne_handle1);
- strcpy(aname1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- aretcode = nse->ne_retcode;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTREMOVE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
- amode);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- ahlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry name: %s\n",
- aname1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Return code: %x\n",
- aretcode);
-
- response = DM_RESP_INVALID;
- break;
- }
-
- case DM_EVENT_RENAME:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- hanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- hlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- strcpy(name2,
- DM_GET_VALUE(nse, ne_name2,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_RENAME\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New parent handle: %p\n",
- hanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New parent handle length: %d\n",
- hlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old entry name: %s\n",
- name1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New entry name: %s\n",
- name2);
-
- break;
- }
-
- case DM_EVENT_POSTRENAME:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- ahanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- ahlen1 = DM_GET_LEN(nse, ne_handle1);
- ahanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- ahlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(aname1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- strcpy(aname2,
- DM_GET_VALUE(nse, ne_name2,
- char *));
- aretcode = nse->ne_retcode;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTRENAME\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old parent handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old parent handle length: %d\n",
- ahlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New parent handle: %p\n",
- ahanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New parent handle length: %d\n",
- ahlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old entry name: %s\n",
- aname1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New entry name: %s\n",
- aname2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Return code: %x\n",
- aretcode);
-
- response = DM_RESP_INVALID;
- break;
- }
-
- case DM_EVENT_SYMLINK:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- strcpy(name2,
- DM_GET_VALUE(nse, ne_name2,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_SYMLINK\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Symlink entry name: %s\n",
- name1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Symlink contents: %s\n",
- name2);
-
- break;
- }
-
- case DM_EVENT_POSTSYMLINK:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- ahanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- ahlen1 = DM_GET_LEN(nse, ne_handle1);
- ahanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- ahlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(aname1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- strcpy(aname2,
- DM_GET_VALUE(nse, ne_name2,
- char *));
- aretcode = nse->ne_retcode;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTSYMLINK\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- ahlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry handle: %p\n",
- ahanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry handle length: %d\n",
- ahlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Symlink entry name: %s\n",
- aname1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Symlink contents: %s\n",
- aname2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Return code: %x\n",
- aretcode);
-
- response = DM_RESP_INVALID;
- break;
- }
-
- case DM_EVENT_LINK:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- hanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- hlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_LINK\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Source link handle: %p\n",
- hanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Source link handle length: %d\n",
- hlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Target entry name: %s\n",
- name1);
-
- break;
- }
-
- case DM_EVENT_POSTLINK:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- ahanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- ahlen1 = DM_GET_LEN(nse, ne_handle1);
- ahanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- ahlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(aname1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- aretcode = nse->ne_retcode;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTLINK\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- ahanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- ahlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Source link handle: %p\n",
- ahanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Source link handle length: %d\n",
- ahlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Target entry name: %s\n",
- aname1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Return code: %x\n",
- aretcode);
-
- response = DM_RESP_INVALID;
- break;
- }
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/event_sd.c b/testcases/kernel/fs/dmapi/event_sd.c
deleted file mode 100644
index e59629d8e..000000000
--- a/testcases/kernel/fs/dmapi/event_sd.c
+++ /dev/null
@@ -1,7334 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : event_sd.c
- *
- * VARIATIONS : 89
- *
- * EVENTS TESTED: DM_EVENT_READ
- * DM_EVENT_WRITE
- * DM_EVENT_TRUNCATE
- *
- * NOTES : The EVENT_DELIVERY_DELAY_LOOP macro is needed prior to
- * invoking the routine (i.e. read) that generates the event
- * being tested because the system("cp DUMMY_FILE DummyFile")
- * call will generate DM_EVENT_WRITE events that can interfere
- * with the results of the test.
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define TMP_FILELEN 10000
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-
-/* Variables for thread communications */
-dm_eventtype_t eventExpected;
-dm_eventtype_t eventReceived;
-dm_response_t eventResponse;
-void *hanp1, *hanp2;
-size_t hlen1, hlen2;
-char name1[FILENAME_MAX];
-dm_off_t offset;
-dm_size_t length;
-int numRegions;
-dm_region_t Regions[10];
-int eventPending;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int i;
- int rc;
- int varStatus;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- int fd;
-
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
-
- remove(DummyFile);
-
- EVENT_DELIVERY_DELAY;
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < TMP_FILELEN / DUMMY_STRLEN; i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc == 0) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- }
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI synchronous data event tests\n");
-
- /*
- * TEST : read - no regions
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 1)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 0;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one READ region covering entire file, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 2)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one READ region covering entire file, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_READ (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 3)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one WRITE region covering entire file
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 4)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one TRUNCATE region covering entire file
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 5)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - two READ regions covering part of file, read from one, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 6)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2222, SEEK_SET)) != 2222) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2222) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2222) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2222);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - two READ regions covering part of file, read from one, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_READ (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 7)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2222, SEEK_SET)) != 2222) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2222) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2222) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2222);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - two non-READ regions covering part of file, read from one
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 8)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - two non-READ regions covering part of file, read from other
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 9)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2222, SEEK_SET)) != 2222) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2222) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - three different regions covering part of file, read from READ, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 10)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 4444, SEEK_SET)) != 4444) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 4444) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 4444) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 4444);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - three different regions covering part of file, read from READ, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_READ (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 11)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 4444, SEEK_SET)) != 4444) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 4444) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 4444) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 4444);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - three READ regions covering part of file, read from outside all
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 12)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_READ;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 3333, SEEK_SET)) != 3333) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 3333) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - three different regions covering part of file, read from READ overlapping start, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 13)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2997, SEEK_SET)) != 2997) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2997) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - three different regions covering part of file, read from READ overlapping start, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_READ (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 14)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2997, SEEK_SET)) != 2997) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2997) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte READ region one byte before start of read
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 15)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte READ region at start of read, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 16)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte READ region at end of read, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 17)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = DUMMY_STRLEN;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte READ region one byte beyond end of read
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 18)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = DUMMY_STRLEN + 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte read one byte before start of multibyte READ region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 19)) {
- int fd;
- char buf[1];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, 1, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte read at start of multibyte READ region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 20)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, 1, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte read at end of multibyte READ region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 21)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, DUMMY_STRLEN, SEEK_SET)) !=
- DUMMY_STRLEN) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, 1, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte read one byte beyond end of multibyte READ region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 22)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, DUMMY_STRLEN + 1, SEEK_SET)) !=
- DUMMY_STRLEN + 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != DUMMY_STRLEN + 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, 1, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte read one byte before start of one-byte READ region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 23)) {
- int fd;
- char buf[1];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, 1, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte read at start/end of one-byte READ region
- * EXPECTED: DM_EVENT_READ, DM_RESP_CONTINUE
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 24)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, 1, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one-byte read one byte beyond end of one-byte READ region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 25)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2, SEEK_SET)) != 2) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, 1, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one R/W/T region, read from it, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 26)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN / 2;
- Regions[0].rg_flags =
- DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - three overlapping R/W/T regions, read from them, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 27)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN / 2;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 0;
- Regions[1].rg_size = DUMMY_STRLEN / 2;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 0;
- Regions[2].rg_size = DUMMY_STRLEN / 2;
- Regions[2].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - one DM_REGION_NOEVENT region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 28)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN / 2;
- Regions[0].rg_flags = DM_REGION_NOEVENT;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- rc = read(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - read from different fd than initialized READ region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 29)) {
- int fd1, fd2;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd1 =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd1 == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- fd2 = open(DummyFile, O_RDWR);
- rc = fd2 == -1 ? -1 : read(fd2, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd1);
- rc |= close(fd2);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - dm_pending without O_NONBLOCK
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 30)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- eventPending = 1;
- rc = read(fd, buf, DUMMY_STRLEN);
- eventPending = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "read(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : read - dm_pending with O_NONBLOCK
- * EXPECTED: DM_EVENT_READ (rc = -1, errno = EAGAIN)
- *
- * This variation uncovered XFS BUG #40 (returned errno instead of
- * -1 and errno)
- */
- if (DMVAR_EXEC(FILE_READ_DATA_EVENT_BASE + 31)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT | O_NONBLOCK,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s)\n", DummyFile);
- eventPending = 1;
- rc = read(fd, buf, DUMMY_STRLEN);
- eventPending = 0;
- DMLOG_PRINT(DMLVL_DEBUG, "read(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, EAGAIN, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - no regions
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 1)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 0;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one WRITE region covering entire file, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 2)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one WRITE region covering entire file, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_WRITE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 3)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one READ region covering entire file
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 4)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one TRUNCATE region covering entire file
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 5)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - two WRITE regions covering part of file, write to one, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 6)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2222, SEEK_SET)) != 2222) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2222) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2222) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2222);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - two WRITE regions covering part of file, write to one, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_WRITE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 7)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2222, SEEK_SET)) != 2222) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2222) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2222) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2222);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - two non-WRITE regions covering part of file, write to one
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 8)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - two non-WRITE regions covering part of file, write to other
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 9)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2222, SEEK_SET)) != 2222) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2222) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG,
- "write(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - three different regions covering part of file, write to WRITE, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 10)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 4444, SEEK_SET)) != 4444) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 4444) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 4444) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 4444);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - three different regions covering part of file, write to WRITE, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_WRITE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 11)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 4444, SEEK_SET)) != 4444) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 4444) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 4444) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 4444);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - three WRITE regions covering part of file, write to outside all
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 12)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_WRITE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_WRITE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 3333, SEEK_SET)) != 3333) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 3333) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - three different regions covering part of file, write to WRITE overlapping start, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 13)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2997, SEEK_SET)) != 2997) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2997) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - three different regions covering part of file, write to WRITE overlapping start, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_WRITE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 14)) {
- int fd;
- char buf[DUMMY_STRLEN];
- dm_off_t off;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2997, SEEK_SET)) != 2997) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2997) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte WRITE region one byte before start of write
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 15)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte WRITE region at start of write, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 16)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte WRITE region at end of write, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 17)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = DUMMY_STRLEN;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte WRITE region one byte beyond end of write
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 18)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = DUMMY_STRLEN + 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte write one byte before start of multibyte WRITE region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 19)) {
- int fd;
- char buf[1];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- buf[0] = '0';
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte write at start of multibyte WRITE region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 20)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- buf[0] = '1';
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte write at end of multibyte WRITE region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 21)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, DUMMY_STRLEN, SEEK_SET)) !=
- DUMMY_STRLEN) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- buf[0] = '0';
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte write one byte beyond end of multibyte WRITE region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 22)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, DUMMY_STRLEN + 1, SEEK_SET)) !=
- DUMMY_STRLEN + 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != DUMMY_STRLEN + 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- buf[0] = '1';
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte write one byte before start of one-byte WRITE region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 23)) {
- int fd;
- char buf[1];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- buf[0] = '0';
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte write at start/end of one-byte WRITE region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 24)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 1, SEEK_SET)) != 1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- buf[0] = '1';
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one-byte write one byte beyond end of one-byte WRITE region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 25)) {
- int fd;
- char buf[1];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((off = lseek(fd, 2, SEEK_SET)) != 2) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != 2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- buf[0] = '2';
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(1, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one R/W/T region, write to it, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 26)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN / 2;
- Regions[0].rg_flags =
- DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - three overlapping R/W/T regions, write to them, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 27)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN / 2;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 0;
- Regions[1].rg_size = DUMMY_STRLEN / 2;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 0;
- Regions[2].rg_size = DUMMY_STRLEN / 2;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one DM_REGION_NOEVENT region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 28)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN / 2;
- Regions[0].rg_flags = DM_REGION_NOEVENT;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one WRITE region covering entire file (size 0), write beyond EOF, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 29)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else
- if ((off =
- lseek(fd, TMP_FILELEN + DUMMY_STRLEN,
- SEEK_SET)) != TMP_FILELEN + DUMMY_STRLEN) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != TMP_FILELEN + DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != TMP_FILELEN + DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - one WRITE region covering entire file (size TMP_FILELEN), write beyond EOF, DM_RESP_CONTINUE
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 30)) {
- int fd;
- char buf[DUMMY_STRLEN];
- off_t off;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = TMP_FILELEN;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else
- if ((off =
- lseek(fd, TMP_FILELEN + DUMMY_STRLEN,
- SEEK_SET)) != TMP_FILELEN + DUMMY_STRLEN) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1 || off != TMP_FILELEN + DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- rc = write(fd, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - write to different fd than initialized WRITE region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 31)) {
- int fd1, fd2;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd1 =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd1 == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- fd2 = open(DummyFile, O_RDWR);
- rc = fd2 == -1 ? -1 : write(fd2, buf, DUMMY_STRLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd1);
- rc |= close(fd2);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - dm_pending without O_NONBLOCK
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 32)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- eventPending = 1;
- rc = write(fd, buf, DUMMY_STRLEN);
- eventPending = 0;
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(DUMMY_STRLEN, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : write - dm_pending with O_NONBLOCK
- * EXPECTED: DM_EVENT_WRITE (rc = -1, errno = EAGAIN)
- */
- if (DMVAR_EXEC(FILE_WRITE_DATA_EVENT_BASE + 33)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT | O_NONBLOCK,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s)\n", DummyFile);
- eventPending = 1;
- rc = write(fd, buf, DUMMY_STRLEN);
- eventPending = 0;
- DMLOG_PRINT(DMLVL_DEBUG, "write(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, EAGAIN, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- } else if (length != DUMMY_STRLEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- length, DUMMY_STRLEN);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - no regions
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 1)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 0;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 5000);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - one TRUNCATE region covering entire file, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 2)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 5000);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 5000) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 5000);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - one TRUNCATE region covering entire file, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_TRUNCATE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 3)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 5000);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 5000) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 5000);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - one READ region covering entire file
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 4)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 5000);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - one WRITE region covering entire file
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 5)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 5000);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - two TRUNCATE regions covering part of file, truncate in one, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 6)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 2222);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2222) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2222);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - two TRUNCATE regions covering part of file, truncate in one, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_TRUNCATE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 7)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 2222);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2222) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2222);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - two non-TRUNCATE regions covering part of file, truncate in one
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 8)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 0);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - two non-TRUNCATE regions covering part of file, truncate in other
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 9)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 2;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 2222);
- DMLOG_PRINT(DMLVL_DEBUG,
- "ftruncate(%s) returned %d, buffer contents [%.*s]\n",
- DummyFile, rc, DUMMY_STRLEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three different regions covering part of file, truncate in TRUNCATE, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 10)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_WRITE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 4444);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 4444) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 4444);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three different regions covering part of file, truncate in TRUNCATE, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_TRUNCATE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 11)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_WRITE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 4444);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 4444) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 4444);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three TRUNCATE regions covering part of file, truncate beyond all
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 12)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 4000;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 6000);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three different regions covering part of file, truncate in TRUNCATE, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 13)) {
- int fd;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memcpy(buf, DUMMY_STRING, DUMMY_STRLEN);
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 2997);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three different regions covering part of file, truncate in TRUNCATE, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_TRUNCATE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 14)) {
- int fd;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 2997);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 2997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three different regions covering part of file, truncate before TRUNCATE, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 15)) {
- int fd;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 1997);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three different regions covering part of file, truncate before TRUNCATE, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_TRUNCATE (rc = -1, errno = ABORT_ERRNO)
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 16)) {
- int fd;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 1000;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 2000;
- Regions[1].rg_size = 1000;
- Regions[1].rg_flags = DM_REGION_TRUNCATE;
- Regions[2].rg_offset = 3005;
- Regions[2].rg_size = 1000;
- Regions[2].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 1997);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- eventResponse = DM_RESP_CONTINUE;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1997) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - truncate one byte before start of one-byte TRUNCATE region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 17)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 0);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 2997);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - truncate at start/end of one-byte TRUNCATE region, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 18)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - truncate one byte beyond end of one-byte TRUNCATE region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 19)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 1;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, 2);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - one R/W/T region, truncate in it, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 20)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags =
- DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, DUMMY_STRLEN / 2);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != DUMMY_STRLEN / 2) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - three overlapping R/W/T regions, truncate in them, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 21)) {
- int fd;
-
- /* Variation set up */
- numRegions = 3;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_READ;
- Regions[1].rg_offset = 0;
- Regions[1].rg_size = DUMMY_STRLEN;
- Regions[1].rg_flags = DM_REGION_WRITE;
- Regions[2].rg_offset = 0;
- Regions[2].rg_size = DUMMY_STRLEN;
- Regions[2].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, DUMMY_STRLEN / 2);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != DUMMY_STRLEN / 2) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 0);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : ftruncate - one DM_REGION_NOEVENT region
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 22)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_NOEVENT;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s)\n", DummyFile);
- rc = ftruncate(fd, DUMMY_STRLEN / 2);
- DMLOG_PRINT(DMLVL_DEBUG, "ftruncate(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : open with O_TRUNC - one TRUNCATE region covering entire file, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 23)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s, O_TRUNC)\n",
- DummyFile);
- fd = open(DummyFile, O_RDWR | O_CREAT | O_TRUNC,
- DUMMY_FILE_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG,
- "open(%s, O_TRUNC) returned %d\n",
- DummyFile, fd);
- rc = fd == -1 ? -1 : 0;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 5000);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : open with O_TRUNC - one-byte TRUNCATE region past EOF, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 24)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = TMP_FILELEN;
- Regions[0].rg_size = 1;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s, O_TRUNC)\n",
- DummyFile);
- fd = open(DummyFile, O_RDWR | O_CREAT | O_TRUNC,
- DUMMY_FILE_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG,
- "open(%s, O_TRUNC) returned %d\n",
- DummyFile, fd);
- rc = fd == -1 ? -1 : 0;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 5000);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : creat - one TRUNCATE region covering entire file, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_TRUNCATE
- */
- if (DMVAR_EXEC(FILE_TRUNC_DATA_EVENT_BASE + 25)) {
- int fd;
-
- /* Variation set up */
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- EVENT_DELIVERY_DELAY;
- rc = system(command);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY_LOOP;
- eventExpected = DM_EVENT_TRUNCATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- DMLOG_PRINT(DMLVL_DEBUG, "creat(%s)\n", DummyFile);
- fd = creat(DummyFile, S_IRWXU);
- DMLOG_PRINT(DMLVL_DEBUG, "creat(%s) returned %d\n",
- DummyFile, fd);
- rc = fd == -1 ? -1 : 0;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Handles NOT same!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (offset != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- offset, 5000);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- remove(DUMMY_FILE);
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_READ, events);
- DMEV_SET(DM_EVENT_WRITE, events);
- DMEV_SET(DM_EVENT_TRUNCATE, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_CLR(DM_EVENT_READ, events);
- DMEV_CLR(DM_EVENT_WRITE, events);
- DMEV_CLR(DM_EVENT_TRUNCATE, events);
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_PREUNMOUNT) {
- /* SPECIAL CASE: need to set response */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_PREUNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle: %p\n",
- DM_GET_VALUE(nse, ne_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle length: %d\n",
- DM_GET_LEN(nse, ne_handle2));
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set response and bMounted */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_UNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_POSTCREATE) {
- /* SPECIAL CASE: need to set regions (if any) and response */
- dm_boolean_t exactflag;
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- int retcode = nse->ne_retcode;
- hanp2 = DM_GET_VALUE(nse, ne_handle2, void *);
- hlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(name1, DM_GET_VALUE(nse, ne_name1, char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTCREATE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " Parent handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Parent handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Entry handle: %p\n", hanp2);
- DMLOG_PRINT(DMLVL_DEBUG, " Entry handle length: %d\n",
- hlen2);
- DMLOG_PRINT(DMLVL_DEBUG, " Entry name: %s\n", name1);
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- retcode);
-
- if ((retcode == 0) && (numRegions > 0)) {
- rc = dm_set_region(sid, hanp2, hlen2,
- DM_NO_TOKEN, numRegions,
- Regions, &exactflag);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_region failed! (rc = %d, errno = %d)\n",
- rc, errno);
- } else {
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_set_regions succesfully set %d region(s)\n",
- numRegions);
- }
- }
-
- /* No response needed */
- response = DM_RESP_INVALID;
- } else {
- eventReceived = type;
- response = eventResponse;
-
- switch (type) {
- case DM_EVENT_READ:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- dm_timestruct_t delay;
-
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
- length = de->de_length;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_READ\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Length: %d\n", length);
-
- if (eventPending) {
- rc = dm_pending(sid, token,
- &delay);
- DMLOG_PRINT(DMLVL_DEBUG,
- "pending returned %d\n",
- rc);
- EVENT_DELIVERY_DELAY;
- EVENT_DELIVERY_DELAY;
- EVENT_DELIVERY_DELAY;
- }
-
- break;
- }
-
- case DM_EVENT_WRITE:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- dm_timestruct_t delay;
-
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
- length = de->de_length;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_WRITE\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Length: %d\n", length);
-
- if (eventPending) {
- rc = dm_pending(sid, token,
- &delay);
- DMLOG_PRINT(DMLVL_DEBUG,
- "pending returned %d\n",
- rc);
- EVENT_DELIVERY_DELAY;
- EVENT_DELIVERY_DELAY;
- EVENT_DELIVERY_DELAY;
- }
-
- break;
- }
-
- case DM_EVENT_TRUNCATE:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- dm_timestruct_t delay;
-
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_TRUNCATE\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
-
- if (eventPending) {
- rc = dm_pending(sid, token,
- &delay);
- DMLOG_PRINT(DMLVL_DEBUG,
- "pending returned %d\n",
- rc);
- EVENT_DELIVERY_DELAY;
- EVENT_DELIVERY_DELAY;
- EVENT_DELIVERY_DELAY;
- }
-
- break;
- }
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/event_sn.c b/testcases/kernel/fs/dmapi/event_sn.c
deleted file mode 100644
index 34031b5b9..000000000
--- a/testcases/kernel/fs/dmapi/event_sn.c
+++ /dev/null
@@ -1,1863 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : event_sn.c
- *
- * VARIATIONS : 20
- *
- * EVENTS TESTED: DM_EVENT_CREATE
- * DM_EVENT_REMOVE
- * DM_EVENT_RENAME
- * DM_EVENT_SYMLINK
- * DM_EVENT_LINK
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummyFile2[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-char DummySubdir2[FILENAME_MAX];
-char DummyLink[FILENAME_MAX];
-
-/* Variables for thread communications */
-dm_eventtype_t eventExpected;
-dm_eventtype_t eventReceived;
-dm_response_t eventResponse;
-void *hanp1, *hanp2;
-size_t hlen1, hlen2;
-char name1[FILENAME_MAX], name2[FILENAME_MAX];
-dm_mode_t mode;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int rc;
- int varStatus;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummyFile2, "%s/%s", mountPt, DUMMY_FILE2);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
- sprintf(DummySubdir2, "%s/%s", mountPt, DUMMY_SUBDIR2);
- sprintf(DummyLink, "%s/%s", mountPt, DUMMY_LINK);
-
- remove(DummyFile);
- remove(DummyFile2);
- unlink(DummyLink);
- rmdir(DummySubdir);
- rmdir(DummySubdir2);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI synchronous namespace event tests\n");
-
- /*
- * TEST : mkdir - DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_CREATE
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 1)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir,
- rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : mkdir - DM_RESP_ABORT
- * EXPECTED: DM_EVENT_CREATE
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 2)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir,
- rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : rmdir - DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_REMOVE
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 3)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_REMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
- rc = rmdir(DummySubdir);
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n",
- DummySubdir, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : rmdir - DM_RESP_ABORT
- * EXPECTED: DM_EVENT_REMOVE
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 4)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_REMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
- rc = rmdir(DummySubdir);
- DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n",
- DummySubdir, rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : mv - DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_RENAME
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 5)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_RENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir, DummySubdir2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, hanp2, hlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : mv - DM_RESP_ABORT
- * EXPECTED: DM_EVENT_RENAME
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 6)) {
- dm_ino_t ino1, ino2;
-
- /* Variation set up */
- eventExpected = DM_EVENT_RENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummySubdir, DummySubdir2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- if ((varStatus =
- (rc == 0 ? DMSTAT_FAIL : DMSTAT_PASS)) ==
- DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, hanp2, hlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink - DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_SYMLINK
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 7)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_SYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n",
- DummySubdir, DummySubdir2);
- rc = symlink(DummySubdir, DummySubdir2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DummySubdir) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- name2, DummySubdir);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummySubdir2);
- rc |= rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink - DM_RESP_ABORT
- * EXPECTED: DM_EVENT_SYMLINK
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 8)) {
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_SYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n",
- DummySubdir, DummySubdir2);
- rc = symlink(DummySubdir, DummySubdir2);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n",
- DummySubdir, DummySubdir2, rc);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_SUBDIR2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_SUBDIR2);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DummySubdir) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- name2, DummySubdir);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link - DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_LINK
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 9)) {
-#ifdef DIRECTORY_LINKS
- dm_ino_t ino1, ino2, ino3;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- eventExpected = DM_EVENT_LINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir,
- DummyLink);
- rc = link(DummySubdir, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummySubdir, DummyLink, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino3);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino3) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%lld vs %lld)\n",
- ino2, ino3);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- rc |= unlink(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with DIRECTORY_LINKS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : link - DM_RESP_ABORT
- * EXPECTED: DM_EVENT_LINK
- */
- if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 10)) {
-#ifdef DIRECTORY_LINKS
- dm_ino_t ino1, ino2, ino3;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- eventExpected = DM_EVENT_LINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir,
- DummyLink);
- rc = link(DummySubdir, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummySubdir, DummyLink, rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino3);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino3) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%lld vs %lld)\n",
- ino2, ino3);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with DIRECTORY_LINKS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : open
- * EXPECTED: DM_EVENT_CREATE, DM_RESP_CONTINUE
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 1)) {
- int fd;
- dm_ino_t ino;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
- fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile,
- fd);
- rc = (fd == -1) ? -1 : 0;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s %s)\n",
- name1, DUMMY_SUBDIR);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : open
- * EXPECTED: DM_EVENT_CREATE, DM_RESP_ABORT
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 2)) {
- dm_ino_t ino;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_CREATE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
-
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
- fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile,
- fd);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, fd, ABORT_ERRNO, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : remove
- * EXPECTED: DM_EVENT_REMOVE, DM_RESP_CONTINUE
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 3)) {
- dm_ino_t ino;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_REMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) != -1) {
- rc = close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
- rc = remove(DummyFile);
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : remove
- * EXPECTED: DM_EVENT_REMOVE, DM_RESP_ABORT
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 4)) {
- dm_ino_t ino;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_REMOVE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) != -1) {
- rc = close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
- rc = remove(DummyFile);
- DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n",
- DummyFile, rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : mv
- * EXPECTED: DM_EVENT_RENAME, DM_RESP_CONTINUE
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 5)) {
- dm_ino_t ino1, ino2;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_RENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummyFile, DummyFile2);
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) != -1) {
- rc = close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummyFile, DummyFile2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n", DummyFile,
- DummyFile2, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, hanp2, hlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DUMMY_FILE2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_FILE2);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : mv
- * EXPECTED: DM_EVENT_RENAME, DM_RESP_ABORT
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 6)) {
- dm_ino_t ino1, ino2;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_RENAME;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- sprintf(command, "mv %s %s", DummyFile, DummyFile2);
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) != -1) {
- rc = close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n",
- DummyFile, DummyFile2);
- rc = system(command);
- DMLOG_PRINT(DMLVL_DEBUG,
- "system(mv %s %s) returned %d\n", DummyFile,
- DummyFile2, rc);
- if ((varStatus =
- (rc == 0 ? DMSTAT_FAIL : DMSTAT_PASS)) ==
- DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "New parent handle NOT root! (%lld vs %d)\n",
- ino2, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else
- if (dm_handle_cmp
- (hanp1, hlen1, hanp2, hlen2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old parent handle NOT equal to new parent handle!\n");
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_FILE) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Old entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_FILE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DUMMY_FILE2) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "New entry name NOT correct! (%s vs %s)\n",
- name2, DUMMY_FILE2);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink
- * EXPECTED: DM_EVENT_SYMLINK, DM_RESP_CONTINUE
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 7)) {
- dm_ino_t ino;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_SYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) != -1) {
- rc = close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile,
- DummyLink);
- rc = symlink(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n", DummyFile,
- DummyLink, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DummyFile) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- name2, DummyFile);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = unlink(DummyLink);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : symlink
- * EXPECTED: DM_EVENT_SYMLINK, DM_RESP_ABORT
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 8)) {
- dm_ino_t ino;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_SYMLINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) != -1) {
- rc = close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile,
- DummyLink);
- rc = symlink(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG,
- "symlink(%s, %s) returned %d\n", DummyFile,
- DummyLink, rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name2, DummyFile) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Symlink contents NOT correct! (%s vs %s)\n",
- name2, DummyFile);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : link
- * EXPECTED: DM_EVENT_LINK, DM_RESP_CONTINUE
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 9)) {
- dm_ino_t ino1, ino2, ino3;
- void *hanp;
- size_t hlen;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_LINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile,
- DummyLink);
- rc = link(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummyFile, DummyLink, rc);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino3);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino3) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%lld vs %lld)\n",
- ino2, ino3);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- rc |= remove(DummyLink);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : link
- * EXPECTED: DM_EVENT_LINK, DM_RESP_ABORT
- */
- if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 10)) {
- dm_ino_t ino1, ino2, ino3;
- void *hanp;
- size_t hlen;
- int fd;
-
- /* Variation set up */
- eventExpected = DM_EVENT_LINK;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- eventResponse = DM_RESP_ABORT;
- EVENT_DELIVERY_DELAY;
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile,
- DummyLink);
- rc = link(DummyFile, DummyLink);
- DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n",
- DummyFile, DummyLink, rc);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO,
- eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
- rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
- rc |= dm_handle_to_ino(hanp, hlen, &ino3);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "Unable to obtain inode!\n");
- varStatus = DMSTAT_FAIL;
- } else if (ino1 != ROOT_INODE) {
- DMLOG_PRINT(DMLVL_ERR,
- "Parent handle NOT root! (%lld vs %d)\n",
- ino1, ROOT_INODE);
- varStatus = DMSTAT_FAIL;
- } else if (ino2 != ino3) {
- DMLOG_PRINT(DMLVL_ERR,
- "Source link handle NOT correct! (%lld vs %lld)\n",
- ino2, ino3);
- varStatus = DMSTAT_FAIL;
- } else if (strcmp(name1, DUMMY_LINK) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Target entry name NOT correct! (%s vs %s)\n",
- name1, DUMMY_LINK);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- eventResponse = DM_RESP_CONTINUE;
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- int type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_NOSPACE, events);
- DMEV_SET(DM_EVENT_CREATE, events);
- DMEV_SET(DM_EVENT_REMOVE, events);
- DMEV_SET(DM_EVENT_RENAME, events);
- DMEV_SET(DM_EVENT_SYMLINK, events);
- DMEV_SET(DM_EVENT_LINK, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_PREUNMOUNT) {
- /* SPECIAL CASE: need to set response */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_PREUNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle: %p\n",
- DM_GET_VALUE(nse, ne_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle length: %d\n",
- DM_GET_LEN(nse, ne_handle2));
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set response and bMounted */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_UNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- eventReceived = type;
- response = eventResponse;
-
- switch (type) {
- case DM_EVENT_CREATE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- mode = nse->ne_mode;
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_CREATE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
- mode);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry name: %s\n",
- name1);
-
- break;
- }
-
- case DM_EVENT_REMOVE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- mode = nse->ne_mode;
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_REMOVE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
- mode);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry name: %s\n",
- name1);
-
- break;
- }
-
- case DM_EVENT_RENAME:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- hanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- hlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- strcpy(name2,
- DM_GET_VALUE(nse, ne_name2,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_RENAME\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New parent handle: %p\n",
- hanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New parent handle length: %d\n",
- hlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Old entry name: %s\n",
- name1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " New entry name: %s\n",
- name2);
-
- break;
- }
-
- case DM_EVENT_SYMLINK:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
- strcpy(name2,
- DM_GET_VALUE(nse, ne_name2,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_SYMLINK\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Symlink entry name: %s\n",
- name1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Symlink contents: %s\n",
- name2);
-
- break;
- }
-
- case DM_EVENT_LINK:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
- hanp1 =
- DM_GET_VALUE(nse, ne_handle1,
- void *);
- hlen1 = DM_GET_LEN(nse, ne_handle1);
- hanp2 =
- DM_GET_VALUE(nse, ne_handle2,
- void *);
- hlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(name1,
- DM_GET_VALUE(nse, ne_name1,
- char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_LINK\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Source link handle: %p\n",
- hanp2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Source link handle length: %d\n",
- hlen2);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Target entry name: %s\n",
- name1);
-
- break;
- }
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/event_us.c b/testcases/kernel/fs/dmapi/event_us.c
deleted file mode 100644
index 46925fed7..000000000
--- a/testcases/kernel/fs/dmapi/event_us.c
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : event_us.c
- *
- * VARIATIONS : 21
- *
- * EVENTS TESTED: DM_EVENT_USER
- *
- * API'S TESTED : dm_create_userevent
- * dm_send_msg
- * dm_find_eventmsg
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/mount.h>
-#include "dm_test.h"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char *mountPt;
-char *deviceNm;
-void *fshanp;
-size_t fshlen;
-dm_size_t maxMsgDat;
-
-/* Variables for thread communications */
-dm_eventtype_t eventExpected;
-dm_eventtype_t eventReceived;
-dm_response_t eventResponse;
-void *hanp2;
-size_t hlen2;
-char name1[FILENAME_MAX];
-dm_token_t tokenReceived;
-char msgDataReceived[MSG_DATALEN];
-dm_size_t msgDataLenReceived;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int rc;
- int varStatus;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- rc = dm_get_config(fshanp, fshlen, DM_CONFIG_MAX_MESSAGE_DATA,
- &maxMsgDat);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_config failed! (rc = %d, errno = %d)\n",
- rc, errno);
- umount(mountPt);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI user event tests\n");
-
- szFuncName = "dm_create_userevent";
-
- /*
- * TEST : dm_create_uservent - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 1)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_create_userevent(INVALID_ADDR, MSG_DATALEN, buf,
- &token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_uservent - invalid msglen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 2)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid msglen)\n", szFuncName);
- rc = dm_create_userevent(sid, maxMsgDat + 1, buf, &token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_uservent - invalid msgdatap
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 3)) {
- dm_token_t token;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid msgdatap)\n", szFuncName);
- rc = dm_create_userevent(sid, MSG_DATALEN, (void *)INVALID_ADDR,
- &token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_uservent - invalid tokenp
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #11 (unused tevp left on queue)
- */
- if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 4)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid tokenp)\n", szFuncName);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf,
- (dm_token_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_uservent - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 5)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : dm_create_uservent - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 6)) {
- char buf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_create_userevent(DM_NO_SESSION, MSG_DATALEN, buf,
- &token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_send_msg";
-
- /*
- * TEST : dm_send_msg - invalid targetsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 1)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid targetsid)\n", szFuncName);
- rc = dm_send_msg(INVALID_ADDR, DM_MSGTYPE_SYNC, MSG_DATALEN,
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_send_msg - invalid msgtype
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 2)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid msgtype)\n", szFuncName);
- rc = dm_send_msg(sid, INVALID_ADDR, MSG_DATALEN, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_send_msg - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 3)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n", szFuncName);
- rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, maxMsgDat + 1, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_send_msg - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 4)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n", szFuncName);
- rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN,
- (void *)INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_send_msg - DM_RESP_CONTINUE
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 5)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- eventExpected = DM_EVENT_USER;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- memcpy(buf, MSG_DATA, MSG_DATALEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(continue response)\n", szFuncName);
- rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (tokenReceived == 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Token NOT correct! (%d vs non-zero)\n",
- tokenReceived);
- varStatus = DMSTAT_FAIL;
- }
- if (msgDataLenReceived != MSG_DATALEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Message lengths NOT same! (%d vs %d)\n",
- msgDataLenReceived, MSG_DATALEN);
- varStatus = DMSTAT_FAIL;
- } else if (memcmp(msgDataReceived, buf, MSG_DATALEN) !=
- 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Message data NOT same! (%s vs %s)\n",
- msgDataReceived, buf);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_send_msg - DM_RESP_ABORT
- * EXPECTED: rc = -1, errno = ABORT_ERRNO
- *
- * This variation uncovered XFS BUG #39 (response reterror returned
- * instead of -1 and errno set to reterror)
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 6)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- eventExpected = DM_EVENT_USER;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
- memcpy(buf, MSG_DATA, MSG_DATALEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(abort response)\n", szFuncName);
- rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- if ((varStatus =
- DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (tokenReceived == 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Token NOT correct! (%d vs non-zero)\n",
- tokenReceived);
- varStatus = DMSTAT_FAIL;
- }
- if (msgDataLenReceived != MSG_DATALEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Message lengths NOT same! (%d vs %d)\n",
- msgDataLenReceived, MSG_DATALEN);
- varStatus = DMSTAT_FAIL;
- } else if (memcmp(msgDataReceived, buf, MSG_DATALEN) !=
- 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Message data NOT same! (%s vs %s)\n",
- msgDataReceived, buf);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_send_msg - DM_MSGTYPE_ASYNC
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 7)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- eventExpected = DM_EVENT_USER;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- memcpy(buf, MSG_DATA, MSG_DATALEN);
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_MSGTYPE_ASYNC)\n", szFuncName);
- rc = dm_send_msg(sid, DM_MSGTYPE_ASYNC, MSG_DATALEN, buf);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (tokenReceived != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Token NOT correct! (%d vs %d)\n",
- tokenReceived, 0);
- varStatus = DMSTAT_FAIL;
- }
- if (msgDataLenReceived != MSG_DATALEN) {
- DMLOG_PRINT(DMLVL_ERR,
- "Message lengths NOT same! (%d vs %d)\n",
- msgDataLenReceived, MSG_DATALEN);
- varStatus = DMSTAT_FAIL;
- } else if (memcmp(msgDataReceived, buf, MSG_DATALEN) !=
- 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "Message data NOT same! (%s vs %s)\n",
- msgDataReceived, buf);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_send_msg - DM_NO_SESSION targetsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SEND_MSG_BASE + 8)) {
- char buf[MSG_DATALEN];
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION targetsid)\n",
- szFuncName);
- rc = dm_send_msg(DM_NO_SESSION, DM_MSGTYPE_SYNC, MSG_DATALEN,
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_find_eventmsg";
-
- /*
- * TEST : dm_find_eventmsg - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 1)) {
- dm_token_t token;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to initialize variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_find_eventmsg(INVALID_ADDR, token, MSG_DATALEN,
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_find_eventmsg - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 2)) {
- dm_token_t token;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to initialize variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_find_eventmsg(sid, INVALID_ADDR, MSG_DATALEN,
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_find_eventmsg - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 3)) {
- dm_token_t token;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to initialize variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
- szFuncName);
- rc = dm_find_eventmsg(sid, token, MSG_DATALEN - 1, buf,
- &rlen);
- if (rc == -1) {
- if (errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n",
- rlen);
- if (rlen ==
- MSG_DATALEN +
- sizeof(dm_eventmsg_t)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d, expected errno = %d, and expected rlen = %d\n",
- szFuncName, rc,
- errno, rlen);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, rc,
- errno, rlen,
- MSG_DATALEN);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_find_eventmsg - invalid bufp
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 4)) {
- dm_token_t token;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to initialize variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_find_eventmsg(sid, token, MSG_DATALEN,
- (void *)INVALID_ADDR, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_find_eventmsg - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 5)) {
- dm_token_t token;
- char buf[MSG_DATALEN];
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to initialize variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_find_eventmsg(sid, token, MSG_DATALEN, buf,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_find_eventmsg - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 6)) {
- dm_token_t token;
- char bufin[MSG_DATALEN],
- bufout[MSG_DATALEN + sizeof(dm_eventmsg_t)];
- size_t rlen;
-
- /* Variation set up */
- memcpy(bufin, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, bufin, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to initialize variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_find_eventmsg(sid, token, sizeof(bufout),
- bufout, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- if (rlen == MSG_DATALEN + sizeof(dm_eventmsg_t)) {
- if (memcmp
- (bufin,
- bufout + sizeof(dm_eventmsg_t),
- MSG_DATALEN) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d, expected rlen %d, and expected buffer %s\n",
- szFuncName, rc,
- rlen,
- bufout +
- sizeof
- (dm_eventmsg_t));
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected rlen %d but expected buffer %s\n",
- szFuncName, rc,
- rlen, bufout);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s passed with expected rc = %d but unexpected rlen %d\n",
- szFuncName, rc, rlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_find_eventmsg - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 7)) {
- dm_token_t token;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to initialize variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_find_eventmsg(DM_NO_SESSION, token, MSG_DATALEN,
- buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- EVENT_DELIVERY_DELAY;
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- int type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- fshanp = DM_GET_VALUE(me, me_handle1, void *);
- fshlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- fshanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- fshlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(fshanp, fshlen);
-
- /*rc = dm_request_right(sid, fshanp, fshlen, token, DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "dm_request_right failed! (rc = %d, errno = %d)\n", rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } */
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_ATTRIBUTE, events);
- DMEV_SET(DM_EVENT_CLOSE, events);
- DMEV_SET(DM_EVENT_DESTROY, events);
- rc = dm_set_disp(sid, fshanp, fshlen, DM_NO_TOKEN,
- &events, DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &events, DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- /*rc = dm_release_right(sid, fshanp, fshlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "dm_request_right failed! (rc = %d, errno = %d)\n", rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } */
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_PREUNMOUNT) {
- /* SPECIAL CASE: need to set response */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_PREUNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle: %p\n",
- DM_GET_VALUE(nse, ne_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle length: %d\n",
- DM_GET_LEN(nse, ne_handle2));
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set response and bMounted */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_UNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_POSTCREATE) {
- /* SPECIAL CASE: need to save entry info */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- hanp2 = DM_GET_VALUE(nse, ne_handle2, void *);
- hlen2 = DM_GET_LEN(nse, ne_handle2);
- strcpy(name1, DM_GET_VALUE(nse, ne_name1, char *));
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_POSTCREATE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " Parent handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Parent handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Entry handle: %p\n", hanp2);
- DMLOG_PRINT(DMLVL_DEBUG, " Entry handle length: %d\n",
- hlen2);
- DMLOG_PRINT(DMLVL_DEBUG, " Entry name: %s\n", name1);
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
-
- /* No response needed */
- response = DM_RESP_INVALID;
- } else {
- eventReceived = type;
- response = eventResponse;
-
- switch (type) {
- case DM_EVENT_USER:
- {
- memcpy(&tokenReceived, &token,
- sizeof(dm_token_t));
- msgDataLenReceived =
- DM_GET_LEN(dmMsg, ev_data);
- memcpy(msgDataReceived,
- DM_GET_VALUE(dmMsg, ev_data,
- char *),
- msgDataLenReceived);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_USER\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Message length: %d\n",
- msgDataLenReceived);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Message data: %s\n",
- msgDataReceived);
-
- response = eventResponse;
- break;
- }
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/handle.c b/testcases/kernel/fs/dmapi/handle.c
deleted file mode 100644
index 3a57c2ebf..000000000
--- a/testcases/kernel/fs/dmapi/handle.c
+++ /dev/null
@@ -1,7051 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : handle.c
- *
- * VARIATIONS : 156
- *
- * API'S TESTED : dm_path_to_handle
- * dm_fd_to_handle
- * dm_path_to_fshandle
- * dm_handle_to_fshandle
- * dm_handle_cmp
- * dm_handle_free
- * dm_handle_is_valid
- * dm_handle_hash
- * dm_handle_to_fsid
- * dm_handle_to_igen
- * dm_handle_to_ino
- * dm_make_handle
- * dm_make_fshandle
- * dm_handle_to_path
- * dm_sync_by_handle
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "dm_test.h"
-
-#define PATHBUF_LEN 256
-
-#define DIR_LEVEL1 "level1"
-#define DIR_LEVEL2 "level1/level2"
-#define DIR_LEVEL3 "level1/level2/level3"
-#define DIR_LEVEL4 "level1/level2/level3/level4"
-#define FILE_LEVEL4 "level1/level2/level3/level4/dummy.txt"
-#define PATH_NOTDIR "dummy.txt/dummy.txt"
-#define FILE_NOTDMAPI "/usr/include/errno.h"
-#define PATH_TOOLONG "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456"
-
-char *mountPt;
-char DummySubdirFile[FILENAME_MAX];
-dm_sessid_t sid;
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int rc;
- dm_boolean_t bRC;
- char *szSessionInfo = "dm_test session info";
- void *mtpthanp, *curdirhanp;
- size_t mtpthlen, curdirhlen;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- if ((mountPt = DMOPT_GET("mtpt")) == NULL) {
- DMLOG_PRINT(DMLVL_ERR,
- "Missing mount point, use -mtpt (for example, -mtpt /dmapidir)\n");
- DM_EXIT();
- } else {
- DMLOG_PRINT(DMLVL_DEBUG, "Mount point is %s\n", mountPt);
- }
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if (((rc = dm_path_to_handle(mountPt, &mtpthanp, &mtpthlen)) != 0)
- ||
- ((rc =
- dm_path_to_handle(CURRENT_DIR, &curdirhanp,
- &curdirhlen)) != 0)) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_path_to_handle failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if (dm_handle_cmp(mtpthanp, mtpthlen, curdirhanp, curdirhlen) !=
- 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "This test case must be run from the root directory of the DMAPI FS (%s)\n",
- mountPt);
- DM_EXIT();
- } else {
- sprintf(DummySubdirFile, "%s/%s", mountPt, DUMMY_SUBDIR_FILE);
-
- remove(DUMMY_SUBDIR_FILE);
- unlink(DUMMY_SUBDIR_LINK);
- rmdir(DUMMY_SUBDIR_SUBDIR);
- remove(DUMMY_FILE);
- remove(DUMMY_FILE2);
- unlink(DUMMY_LINK);
- rmdir(DUMMY_SUBDIR);
- remove(FILE_LEVEL4);
- rmdir(DIR_LEVEL4);
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI handle tests\n");
-
- szFuncName = "dm_path_to_handle";
-
- /*
- * TEST : dm_path_to_handle - invalid path
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #3 (0 return code from strnlen_user
- * ignored, which indicated fault)
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 1)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid path)\n", szFuncName);
- rc = dm_path_to_handle((char *)INVALID_ADDR, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_handle - nonexistent path, current directory
- * EXPECTED: rc = -1, errno = ENOENT
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 2)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nonexistent path in curdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_handle - file in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file in curdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_handle - link in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* no clean up */
- } else if ((rc = link(DUMMY_FILE, DUMMY_LINK)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(link in curdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_LINK, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- rc |= unlink(DUMMY_LINK);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_handle - directory in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 5)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir in curdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_handle - nonexistent path in subdirectory
- * EXPECTED: rc = -1, errno = ENOENT
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 6)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(nonexistent path in subdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_SUBDIR_FILE, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_path_to_handle - file in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file in subdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_SUBDIR_FILE, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_handle - link in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = link(DUMMY_SUBDIR_FILE, DUMMY_SUBDIR_LINK)) ==
- -1) {
- close(fd);
- remove(DUMMY_SUBDIR_FILE);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(link in subdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_SUBDIR_LINK, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= unlink(DUMMY_SUBDIR_LINK);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_handle - directory in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 9)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DUMMY_SUBDIR_SUBDIR, DUMMY_DIR_RW_MODE))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir in subdir)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_SUBDIR_SUBDIR, &hanp,
- &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR_SUBDIR);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_handle - path too long
- * EXPECTED: rc = -1, errno = ENAMETOOLONG
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 10)) {
- void *hanp;
- size_t hlen;
- char *szTooLong = PATH_TOOLONG;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(path too long)\n", szFuncName);
- rc = dm_path_to_handle(szTooLong, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENAMETOOLONG);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_handle - path includes invalid directory
- * EXPECTED: rc = -1, errno = ENOTDIR
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(path not dir)\n",
- szFuncName);
- rc = dm_path_to_handle(PATH_NOTDIR, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOTDIR);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_path_to_handle - path not DMAPI
- * EXPECTED: rc = -1, errno = ENXIO
- *
- * This variation uncovered XFS BUG #4 (EINVAL errno returned instead
- * of ENXIO)
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 12)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(path not DMAPI)\n", szFuncName);
- rc = dm_path_to_handle(FILE_NOTDMAPI, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENXIO);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_handle - invalid hanpp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 13)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanpp)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_FILE,
- (void **)INVALID_ADDR, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_path_to_handle - invalid hlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 14)) {
- int fd;
- void *hanp;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlenp)\n",
- szFuncName);
- rc = dm_path_to_handle(DUMMY_FILE, &hanp,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_path_to_handle - different paths to same file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 15)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%s)\n", szFuncName,
- DUMMY_SUBDIR_FILE);
- rc = dm_path_to_handle(DUMMY_SUBDIR_FILE, &hanp1,
- &hlen1);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp1 = %p, hlen1 = %d\n", hanp1,
- hlen1);
- dm_LogHandle(hanp1, hlen1);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%s)\n", szFuncName,
- DummySubdirFile);
- rc = dm_path_to_handle(DummySubdirFile, &hanp2,
- &hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp2 = %p, hlen2 = %d\n",
- hanp2, hlen2);
- dm_LogHandle(hanp2, hlen2);
- }
- }
-
- if (rc == 0) {
- if (dm_handle_cmp(hanp1, hlen1, hanp2, hlen2) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and handles same\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but handles NOT same\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_path_to_handle - empty path
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 16)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(empty path)\n", szFuncName);
- rc = dm_path_to_handle("", &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
-
- if (dm_handle_cmp(mtpthanp, mtpthlen, hanp, hlen) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected handle\n",
- szFuncName, 0);
- DMVAR_PASS();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
-
- /*
- * TEST : dm_path_to_handle - current directory path
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_HANDLE_BASE + 17)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(curdir path)\n", szFuncName);
- rc = dm_path_to_handle(CURRENT_DIR, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
-
- if (dm_handle_cmp(mtpthanp, mtpthlen, hanp, hlen) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected handle\n",
- szFuncName, 0);
- DMVAR_PASS();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
-
- szFuncName = "dm_fd_to_handle";
-
- /*
- * TEST : dm_fd_to_handle - invalid fd
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 1)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid fd)\n", szFuncName);
- rc = dm_fd_to_handle(INVALID_ADDR, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_fd_to_handle - file fd in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file in curdir)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - link fd in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 3)) {
- int fd_f, fd_l;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd_f =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = link(DUMMY_FILE, DUMMY_LINK)) == -1) {
- close(fd_f);
- remove(DUMMY_FILE);
- } else if ((fd_l = open(DUMMY_FILE, O_RDWR)) == -1) {
- unlink(DUMMY_LINK);
- close(fd_f);
- remove(DUMMY_FILE);
- }
- if (fd_f == -1 || rc == -1 || fd_l == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(link in curdir)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd_l, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd_f);
- rc |= close(fd_l);
- rc |= remove(DUMMY_FILE);
- rc |= remove(DUMMY_LINK);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - directory fd in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_SUBDIR, O_DIRECTORY)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir in curdir)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - file fd in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file in subdir)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - link fd in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 6)) {
- int fd_f, fd_l;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd_f =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = link(DUMMY_SUBDIR_FILE, DUMMY_SUBDIR_LINK)) ==
- -1) {
- remove(DUMMY_SUBDIR_FILE);
- close(fd_f);
- rmdir(DUMMY_SUBDIR);
- } else if ((fd_l = open(DUMMY_SUBDIR_FILE, O_RDWR)) == -1) {
- unlink(DUMMY_SUBDIR_LINK);
- close(fd_f);
- remove(DUMMY_SUBDIR_FILE);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd_f == -1 || fd_l == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(link in subdir)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd_l, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd_f);
- rc |= close(fd_l);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= unlink(DUMMY_SUBDIR_LINK);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - directory fd in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DUMMY_SUBDIR_SUBDIR, DUMMY_DIR_RW_MODE))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((fd = open(DUMMY_SUBDIR_SUBDIR, O_DIRECTORY)) == -1) {
- rmdir(DUMMY_SUBDIR_SUBDIR);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir in subdir)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= rmdir(DUMMY_SUBDIR_SUBDIR);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - fd not DMAPI
- * EXPECTED: rc = -1, errno = ENXIO
- *
- * This variation uncovered XFS BUG #27 (EBADF errno returned instead
- * of ENXIO)
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- fd = open(FILE_NOTDMAPI, O_RDONLY);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fd not DMAPI)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENXIO);
-
- /* Variation clean up */
- rc = close(fd);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - invalid hanpp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 9)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanpp)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, (void **)INVALID_ADDR, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_fd_to_handle - invalid hlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 10)) {
- int fd;
- void *hanp;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlenp)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, &hanp,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_fd_to_handle - stdin fd
- * EXPECTED: rc = -1, errno = ENXIO
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 11)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(stdin fd)\n", szFuncName);
- rc = dm_fd_to_handle(0, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENXIO);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_fd_to_handle - stdout fd
- * EXPECTED: rc = -1, errno = ENXIO
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 12)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(stdout fd)\n", szFuncName);
- rc = dm_fd_to_handle(1, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENXIO);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_fd_to_handle - stderr fd
- * EXPECTED: rc = -1, errno = ENXIO
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 13)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(stderr fd)\n", szFuncName);
- rc = dm_fd_to_handle(2, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENXIO);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_fd_to_handle - invalidated fd
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(FD_TO_HANDLE_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) != -1) {
- rc = close(fd);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated fd)\n",
- szFuncName);
- rc = dm_fd_to_handle(fd, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- szFuncName = "dm_path_to_fshandle";
-
- /*
- * TEST : dm_path_to_fshandle - invalid path
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #5 (0 return code from strnlen_user
- * ignored, which indicated fault)
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 1)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid path)\n", szFuncName);
- rc = dm_path_to_fshandle((char *)INVALID_ADDR, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_fshandle - nonexistent path in current directory
- * EXPECTED: rc = -1, errno = ENOENT
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 2)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nonexistent path in curdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_fshandle - file in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file in curdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - link in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = link(DUMMY_FILE, DUMMY_LINK)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(link in curdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_LINK, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- rc |= unlink(DUMMY_LINK);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - directory in current directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 5)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir in curdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_SUBDIR, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - nonexistent path in subdirectory
- * EXPECTED: rc = -1, errno = ENOENT
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 6)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(nonexistent path in subdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_SUBDIR_FILE, &hanp,
- &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - file in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file in subdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_SUBDIR_FILE, &hanp,
- &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - link in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = link(DUMMY_SUBDIR_FILE, DUMMY_SUBDIR_LINK)) ==
- -1) {
- close(fd);
- remove(DUMMY_SUBDIR_FILE);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(link in subdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_SUBDIR_LINK, &hanp,
- &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= unlink(DUMMY_SUBDIR_LINK);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - directory in subdirectory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 9)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DUMMY_SUBDIR_SUBDIR, DUMMY_DIR_RW_MODE))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir in subdir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_SUBDIR_SUBDIR, &hanp,
- &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR_SUBDIR);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - path too long
- * EXPECTED: rc = -1, errno = ENAMETOOLONG
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 10)) {
- void *hanp;
- size_t hlen;
- char *szTooLong = PATH_TOOLONG;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(path too long)\n", szFuncName);
- rc = dm_path_to_fshandle(szTooLong, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENAMETOOLONG);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_fshandle - path includes invalid directory
- * EXPECTED: rc = -1, errno = ENOTDIR
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(path not dir)\n",
- szFuncName);
- rc = dm_path_to_fshandle(PATH_NOTDIR, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOTDIR);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - path not DMAPI
- * EXPECTED: rc = -1, errno = ENXIO
- *
- * This variation uncovered XFS BUG #6 (EINVAL errno returned instead
- * of ENXIO)
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 12)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(path not DMAPI)\n", szFuncName);
- rc = dm_path_to_fshandle(FILE_NOTDMAPI, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENXIO);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_path_to_fshandle - invalid hanpp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 13)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- size_t hlen;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanpp)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_FILE,
- (void **)INVALID_ADDR, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_path_to_fshandle - invalid hlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 14)) {
- int fd;
- void *hanp;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlenp)\n",
- szFuncName);
- rc = dm_path_to_fshandle(DUMMY_FILE, &hanp,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_path_to_fshandle - empty path
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 15)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(empty path)\n", szFuncName);
- rc = dm_path_to_fshandle("", &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
-
- /*
- * TEST : dm_path_to_fshandle - current directory path
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PATH_TO_FSHANDLE_BASE + 16)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(curdir path)\n", szFuncName);
- rc = dm_path_to_fshandle(CURRENT_DIR, &hanp, &hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "hanp = %p, hlen = %d\n", hanp,
- hlen);
- dm_LogHandle(hanp, hlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
-
- szFuncName = "dm_handle_to_fshandle";
-
- /*
- * TEST : dm_handle_to_fshandle - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_handle_to_fshandle((void *)INVALID_ADDR, hlen,
- &fshanp, &fshlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_fshandle - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 2)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_handle_to_fshandle(hanp, INVALID_ADDR, &fshanp,
- &fshlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_fshandle - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 3)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "fshanp = %p, fshlen = %d\n",
- fshanp, fshlen);
- dm_LogHandle(fshanp, fshlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_fshandle - directory handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 4)) {
- void *hanp, *fshanp;
- size_t hlen, fshlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "fshanp = %p, fshlen = %d\n",
- fshanp, fshlen);
- dm_LogHandle(fshanp, fshlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_fshandle - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 5)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "fshanp = %p, fshlen = %d\n",
- fshanp, fshlen);
- dm_LogHandle(fshanp, fshlen);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_fshandle - invalid fshanpp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 6)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp;
- size_t hlen, fshlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid fshanpp)\n",
- szFuncName);
- rc = dm_handle_to_fshandle(hanp, hlen,
- (void **)INVALID_ADDR,
- &fshlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_fshandle - invalid fshlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 7)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp, *fshanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid fshlenp)\n",
- szFuncName);
- rc = dm_handle_to_fshandle(hanp, hlen, &fshanp,
- (void *)INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_fshandle - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_FSHANDLE_BASE + 8)) {
- void *fshanp;
- size_t fshlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_handle_to_fshandle(DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- &fshanp, &fshlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_handle_cmp";
-
- /*
- * TEST : dm_handle_cmp - invalid hanp1
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp1)\n",
- szFuncName);
- rc = dm_handle_cmp((char *)INVALID_ADDR, hlen, hanp,
- hlen);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_cmp - invalid hlen1
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen1)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp, INVALID_ADDR, hanp, hlen);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - invalid hanp2
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 3)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp2)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp, hlen, (char *)INVALID_ADDR,
- hlen);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_cmp - invalid hlen2
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen2)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp, hlen, hanp, INVALID_ADDR);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hlen1 < hlen2
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(hlen1 < hlen2)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp, hlen, hanp, hlen + 1);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 == hanp2 (same file handles)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 == hanp2, same file handle)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp, hlen, hanp, hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 == hanp2 (same fs handles)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 == hanp2, same fs handle)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp, hlen, hanp, hlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hlen1 > hlen2
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(hlen1 > hlen2)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp, hlen, hanp, hlen - 1);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 == hanp2 (different file handles, same path)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 9)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp1, &hlen1))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp2, &hlen2))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 == hanp2, diff file handles from same path)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 == hanp2 (different fs handles, same path)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 10)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_FILE, &hanp1,
- &hlen1)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_FILE, &hanp2,
- &hlen2)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 == hanp2, diff fs handles from same path)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 == hanp2 (different file handles, one path, one fd)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 11)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp1, &hlen1))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp2, &hlen2)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 == hanp2, diff file handles from path, fd)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 == hanp2 (different file handles, same fd)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 12)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp1, &hlen1)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp2, &hlen2)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 == hanp2, diff file handles from same fd)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 != hanp2 (different path)
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 13)) {
- int fd1, fd2;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((fd1 =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp1, &hlen1))
- == -1) {
- close(fd1);
- remove(DUMMY_FILE);
- } else
- if ((fd2 =
- open(DUMMY_FILE2, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- close(fd1);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- } else if ((rc = dm_path_to_handle(DUMMY_FILE2, &hanp2, &hlen2))
- == -1) {
- close(fd1);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- close(fd2);
- remove(DUMMY_FILE2);
- }
- if (fd1 == -1 || rc == -1 || fd2 == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 != hanp2, different paths)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd1);
- rc |= remove(DUMMY_FILE);
- rc |= close(fd2);
- rc |= remove(DUMMY_FILE2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 != hanp2 (different fd)
- * EXPECTED: rc != 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 14)) {
- int fd1, fd2;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((fd1 =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd1, &hanp1, &hlen1)) == -1) {
- close(fd1);
- remove(DUMMY_FILE);
- } else
- if ((fd2 =
- open(DUMMY_FILE2, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- close(fd1);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- } else if ((rc = dm_fd_to_handle(fd2, &hanp2, &hlen2)) == -1) {
- close(fd1);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- close(fd2);
- remove(DUMMY_FILE2);
- }
- if (fd1 == -1 || rc == -1 || fd2 == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 != hanp2, different fd's)\n",
- szFuncName);
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd1);
- rc |= remove(DUMMY_FILE);
- rc |= close(fd2);
- rc |= remove(DUMMY_FILE2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 == hanp2 (global handle)
- * EXPECTED: rc = 0
- *
- * This variation uncovered XFS BUG #41 (fault occurred instead of
- * rc = 0)
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 15)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(hanp1 == hanp2, global handle)\n",
- szFuncName);
- rc = dm_handle_cmp(DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_GLOBAL_HANP, DM_GLOBAL_HLEN);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_handle_cmp - hanp1 != hanp2 (file and global handle)
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_CMP_BASE + 16)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(hanp1 != hanp2, file and global handle)\n",
- szFuncName);
- rc = dm_handle_cmp(DM_GLOBAL_HANP, DM_GLOBAL_HLEN, hanp,
- hlen);
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_handle_free";
-
- /*
- * TEST : dm_handle_free - invalid hanp
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- dm_handle_free((char *)INVALID_ADDR, FILE_HANDLELEN);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_free - file handle from path
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle from path)\n",
- szFuncName);
- dm_handle_free(hanp, hlen);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_handle_free - file handle from fd
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle from fd)\n",
- szFuncName);
- dm_handle_free(hanp, hlen);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_handle_free - fs handle from path
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle from path)\n",
- szFuncName);
- dm_handle_free(hanp, hlen);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_handle_free - fs handle from handle
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 5)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp1, &hlen1)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp1, hlen1, &hanp2,
- &hlen2)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle from handle)\n",
- szFuncName);
- dm_handle_free(hanp2, hlen2);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- }
- }
-
- /*
- * TEST : dm_handle_free - file handle from make
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 6)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
- dm_fsid_t fsid;
- dm_igen_t igen;
- dm_ino_t ino;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp1, &hlen1))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if (((rc = dm_handle_to_fsid(hanp1, hlen1, &fsid)) == -1)
- || ((rc = dm_handle_to_igen(hanp1, hlen1, &igen)) ==
- -1)
- || ((rc = dm_handle_to_ino(hanp1, hlen1, &ino)) ==
- -1)
- ||
- ((rc =
- dm_make_handle(&fsid, &ino, &igen, &hanp2,
- &hlen2)) == -1)) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle from make)\n",
- szFuncName);
- dm_handle_free(hanp2, hlen2);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_handle_free - fs handle from make
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 7)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
- dm_fsid_t fsid;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_FILE, &hanp1,
- &hlen1)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if (((rc = dm_handle_to_fsid(hanp1, hlen1, &fsid)) == -1)
- || ((rc = dm_make_fshandle(&fsid, &hanp2, &hlen2)) ==
- -1)) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp1, hlen1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle from make)\n",
- szFuncName);
- dm_handle_free(hanp2, hlen2);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- }
- }
-
- /*
- * TEST : dm_handle_free - global handle
- * EXPECTED: return
- */
- if (DMVAR_EXEC(HANDLE_FREE_BASE + 8)) {
-#ifdef USER_SPACE_FAULTS
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- dm_handle_free(DM_GLOBAL_HANP, DM_GLOBAL_HLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed\n", szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- szFuncName = "dm_handle_is_valid";
-
- /*
- * TEST : dm_handle_is_valid - invalid hanp
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- bRC = dm_handle_is_valid((char *)INVALID_ADDR, FILE_HANDLELEN);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_is_valid - file handle
- * EXPECTED: rc = DM_TRUE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen);
- DMVAR_ENDPASSEXP(szFuncName, DM_TRUE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - file handle, hlen too small
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file hlen too small)\n",
- szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen - 1);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - file handle, hlen too big
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file hlen too big)\n",
- szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen + 1);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - modified file handle
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memset(hanp, 0, hlen);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(modified file handle)\n",
- szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - fs handle
- * EXPECTED: rc = DM_TRUE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen);
- DMVAR_ENDPASSEXP(szFuncName, DM_TRUE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - fs handle, hlen too small
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs hlen too small)\n",
- szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen - 1);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - fs handle, hlen too big
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs hlen too big)\n",
- szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen + 1);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - modified fs handle
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- memset(hanp, 0, hlen);
- DMLOG_PRINT(DMLVL_DEBUG, "%s(modified fs handle)\n",
- szFuncName);
- bRC = dm_handle_is_valid(hanp, hlen);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_is_valid - global handle
- * EXPECTED: rc = DM_TRUE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 10)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- bRC = dm_handle_is_valid(DM_GLOBAL_HANP, DM_GLOBAL_HLEN);
- DMVAR_ENDPASSEXP(szFuncName, DM_TRUE, bRC);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_handle_is_valid - invalid handle
- * EXPECTED: rc = DM_FALSE
- */
- if (DMVAR_EXEC(HANDLE_IS_VALID_BASE + 11)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid handle)\n", szFuncName);
- bRC = dm_handle_is_valid(DM_INVALID_HANP, DM_INVALID_HLEN);
- DMVAR_ENDPASSEXP(szFuncName, DM_FALSE, bRC);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_handle_hash";
-
- /*
- * TEST : dm_handle_hash - invalid hanp
- * EXPECTED: rc = ?
- */
- if (DMVAR_EXEC(HANDLE_HASH_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_handle_hash((char *)INVALID_ADDR, FILE_HANDLELEN);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed with rc = %u\n",
- szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_hash - file handle
- * EXPECTED: rc = ?
- */
- if (DMVAR_EXEC(HANDLE_HASH_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_handle_hash(hanp, hlen);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed with rc = %u\n",
- szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_hash - fs handle
- * EXPECTED: rc = ?
- */
- if (DMVAR_EXEC(HANDLE_HASH_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_handle_hash(hanp, hlen);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed with rc = %u\n",
- szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_hash - global handle
- * EXPECTED: rc = ?
- */
- if (DMVAR_EXEC(HANDLE_HASH_BASE + 4)) {
-#ifdef USER_SPACE_FAULTS
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_handle_hash(DM_GLOBAL_HANP, DM_GLOBAL_HLEN);
- DMLOG_PRINT(DMLVL_DEBUG, "%s passed with rc = %u\n",
- szFuncName);
- DMVAR_PASS();
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- szFuncName = "dm_handle_to_fsid";
-
- /*
- * TEST : dm_handle_to_fsid - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_FSID_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- dm_fsid_t fsidp;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_handle_to_fsid((char *)INVALID_ADDR, FILE_HANDLELEN,
- &fsidp);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_fsid - invalid fsidp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_FSID_BASE + 2)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid fsidp)\n",
- szFuncName);
- rc = dm_handle_to_fsid(hanp, hlen,
- (dm_fsid_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_fsid - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_FSID_BASE + 3)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_fsid_t fsidp;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_FILE, &fshanp,
- &fshlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_handle_to_fsid(hanp, hlen, &fsidp);
- if (rc == 0) {
- if (memcmp(hanp, &fsidp, sizeof(dm_fsid_t)) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected fsid (0x%16llX vs 0x%16llX)\n",
- szFuncName, rc, fsidp,
- *(dm_fsid_t *) hanp);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_fsid - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_FSID_BASE + 4)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_fsid_t fsidp;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_FILE, &fshanp,
- &fshlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_handle_to_fsid(hanp, hlen, &fsidp);
- if (rc == 0) {
- if (memcmp(hanp, &fsidp, sizeof(dm_fsid_t)) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected fsid (0x%16llX vs 0x%16llX)\n",
- szFuncName, rc, fsidp,
- *(dm_fsid_t *) hanp);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_fsid - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_FSID_BASE + 5)) {
- dm_fsid_t fsidp;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_handle_to_fsid(DM_GLOBAL_HANP, DM_GLOBAL_HLEN, &fsidp);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_handle_to_igen";
-
- /*
- * TEST : dm_handle_to_igen - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_IGEN_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- dm_igen_t igen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_handle_to_igen((char *)INVALID_ADDR, FILE_HANDLELEN,
- &igen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_igen - invalid igenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_IGEN_BASE + 2)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid igenp)\n",
- szFuncName);
- rc = dm_handle_to_igen(hanp, hlen,
- (dm_igen_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_igen - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_IGEN_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_igen_t igen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_handle_to_igen(hanp, hlen, &igen);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_igen - directory handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_IGEN_BASE + 4)) {
- void *hanp;
- size_t hlen;
- dm_igen_t igen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_handle_to_igen(hanp, hlen, &igen);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_igen - fs handle from file
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_IGEN_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_igen_t igen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle from file)\n",
- szFuncName);
- rc = dm_handle_to_igen(hanp, hlen, &igen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_igen - fs handle from directory
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_IGEN_BASE + 6)) {
- void *hanp;
- size_t hlen;
- dm_igen_t igen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_SUBDIR, &hanp,
- &hlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle from dir)\n",
- szFuncName);
- rc = dm_handle_to_igen(hanp, hlen, &igen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_igen - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_IGEN_BASE + 7)) {
- dm_igen_t igen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_handle_to_igen(DM_GLOBAL_HANP, DM_GLOBAL_HLEN, &igen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_handle_to_ino";
-
- /*
- * TEST : dm_handle_to_ino - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_INO_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- dm_ino_t ino;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_handle_to_ino((char *)INVALID_ADDR, FILE_HANDLELEN,
- &ino);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_ino - invalid inop
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_INO_BASE + 2)) {
-#ifdef USER_SPACE_FAULTS
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid inop)\n",
- szFuncName);
- rc = dm_handle_to_ino(hanp, hlen,
- (dm_ino_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_handle_to_ino - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_INO_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_handle_to_ino(hanp, hlen, &ino);
- if (rc == 0) {
- struct stat statfs;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- rc = stat(DUMMY_FILE, &statfs);
- if (rc == 0) {
- if (ino == statfs.st_ino) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "ino %d from stat() matches returned value\n",
- statfs.st_ino);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "BUT... ino %d from stat() does not match returned value %lld\n",
- statfs.st_ino, ino);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "BUT... stat() failed with rc = %d (errno = %d)\n",
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_ino - directory handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_INO_BASE + 4)) {
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_handle_to_ino(hanp, hlen, &ino);
- if (rc == 0) {
- struct stat statfs;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, rc);
- rc = stat(DUMMY_SUBDIR, &statfs);
- if (rc == 0) {
- if (ino == statfs.st_ino) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "ino %d from stat() matches returned value\n",
- statfs.st_ino);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "BUT... ino %d from stat() does not match returned value %lld\n",
- statfs.st_ino, ino);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "BUT... stat() failed with rc = %d (errno = %d)\n",
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_ino - fs handle from file
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_INO_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle from file)\n",
- szFuncName);
- rc = dm_handle_to_ino(hanp, hlen, &ino);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_ino - fs handle from directory
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_INO_BASE + 6)) {
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_SUBDIR, &hanp,
- &hlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle from dir)\n",
- szFuncName);
- rc = dm_handle_to_ino(hanp, hlen, &ino);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_ino - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_INO_BASE + 7)) {
- dm_ino_t ino;
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_handle_to_ino(DM_GLOBAL_HANP, DM_GLOBAL_HLEN, &ino);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_make_handle";
-
- /*
- * TEST : dm_make_handle - invalid fsidp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_HANDLE_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- void *hanp;
- size_t hlen;
- dm_ino_t ino;
- dm_igen_t igen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid fsidp)\n", szFuncName);
- rc = dm_make_handle((dm_fsid_t *) INVALID_ADDR, &ino, &igen,
- &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_handle - invalid inop
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_HANDLE_BASE + 2)) {
-#ifdef USER_SPACE_FAULTS
- void *hanp;
- size_t hlen;
- dm_fsid_t fsid;
- dm_igen_t igen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid inop)\n", szFuncName);
- rc = dm_make_handle(&fsid, (dm_ino_t *) INVALID_ADDR, &igen,
- &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_handle - invalid igenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_HANDLE_BASE + 3)) {
-#ifdef USER_SPACE_FAULTS
- void *hanp;
- size_t hlen;
- dm_fsid_t fsid;
- dm_ino_t ino;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid igenp)\n", szFuncName);
- rc = dm_make_handle(&fsid, &ino, (dm_igen_t *) INVALID_ADDR,
- &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_handle - invalid hanpp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_HANDLE_BASE + 4)) {
-#ifdef USER_SPACE_FAULTS
- size_t hlen;
- dm_fsid_t fsid;
- dm_igen_t igen;
- dm_ino_t ino;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanpp)\n", szFuncName);
- rc = dm_make_handle(&fsid, &ino, &igen, (void **)INVALID_ADDR,
- &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_handle - invalid hlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_HANDLE_BASE + 5)) {
-#ifdef USER_SPACE_FAULTS
- void *hanp;
- dm_fsid_t fsid;
- dm_igen_t igen;
- dm_ino_t ino;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlenp)\n", szFuncName);
- rc = dm_make_handle(&fsid, &ino, &igen, &hanp,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_handle - file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(MAKE_HANDLE_BASE + 6)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
- dm_fsid_t fsid;
- dm_igen_t igen;
- dm_ino_t ino;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp1, &hlen1))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if (((rc = dm_handle_to_fsid(hanp1, hlen1, &fsid)) == -1)
- || ((rc = dm_handle_to_igen(hanp1, hlen1, &igen)) ==
- -1)
- || ((rc = dm_handle_to_ino(hanp1, hlen1, &ino)) ==
- -1)) {
- dm_handle_free(hanp1, hlen1);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file)\n", szFuncName);
- rc = dm_make_handle(&fsid, &ino, &igen, &hanp2, &hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp2,
- hlen2);
- dm_LogHandle(hanp2, hlen2);
-
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = 0 but unexpected dm_handle_cmp rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_make_handle - directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(MAKE_HANDLE_BASE + 7)) {
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
- dm_fsid_t fsid;
- dm_igen_t igen;
- dm_ino_t ino;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &hanp1,
- &hlen1)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if (((rc = dm_handle_to_fsid(hanp1, hlen1, &fsid)) == -1)
- || ((rc = dm_handle_to_igen(hanp1, hlen1, &igen)) ==
- -1)
- || ((rc = dm_handle_to_ino(hanp1, hlen1, &ino)) ==
- -1)) {
- dm_handle_free(hanp1, hlen1);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir)\n", szFuncName);
- rc = dm_make_handle(&fsid, &ino, &igen, &hanp2, &hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp2,
- hlen2);
- dm_LogHandle(hanp2, hlen2);
-
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = 0 but unexpected dm_handle_cmp rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- szFuncName = "dm_make_fshandle";
-
- /*
- * TEST : dm_make_fshandle - invalid fsidp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_FSHANDLE_BASE + 1)) {
-#ifdef USER_SPACE_FAULTS
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid fsidp)\n", szFuncName);
- rc = dm_make_fshandle((dm_fsid_t *) INVALID_ADDR, &hanp, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_fshandle - invalid hanpp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_FSHANDLE_BASE + 2)) {
-#ifdef USER_SPACE_FAULTS
- size_t hlen;
- dm_fsid_t fsid;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanpp)\n", szFuncName);
- rc = dm_make_fshandle(&fsid, (void **)INVALID_ADDR, &hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_fshandle - invalid hlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(MAKE_FSHANDLE_BASE + 3)) {
-#ifdef USER_SPACE_FAULTS
- void *hanp;
- dm_fsid_t fsid;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlenp)\n", szFuncName);
- rc = dm_make_fshandle(&fsid, &hanp, (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with USER_SPACE_FAULTS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_make_fshandle - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(MAKE_FSHANDLE_BASE + 4)) {
- int fd;
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
- dm_fsid_t fsid;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_FILE, &hanp1,
- &hlen1)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = dm_handle_to_fsid(hanp1, hlen1, &fsid)) == -1) {
- dm_handle_free(hanp1, hlen1);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_make_fshandle(&fsid, &hanp2, &hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp2,
- hlen2);
- dm_LogHandle(hanp2, hlen2);
-
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = 0 but unexpected dm_handle_cmp rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- /*
- * TEST : dm_make_fshandle - directory handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(MAKE_FSHANDLE_BASE + 5)) {
- void *hanp1, *hanp2;
- size_t hlen1, hlen2;
- dm_fsid_t fsid;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_SUBDIR, &hanp1,
- &hlen1)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = dm_handle_to_fsid(hanp1, hlen1, &fsid)) == -1) {
- dm_handle_free(hanp1, hlen1);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_make_fshandle(&fsid, &hanp2, &hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "hanp = %p, hlen = %d\n", hanp2,
- hlen2);
- dm_LogHandle(hanp2, hlen2);
-
- rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = 0 but unexpected dm_handle_cmp rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp1, hlen1);
- dm_handle_free(hanp2, hlen2);
- }
- }
-
- szFuncName = "dm_handle_to_path";
-
- /*
- * TEST : dm_handle_to_path - invalid dirhanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 1)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid dirhanp)\n",
- szFuncName);
- rc = dm_handle_to_path((void *)INVALID_ADDR, dirhlen,
- targhanp, targhlen, PATHBUF_LEN,
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalid dirhlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 2)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid dirhlen)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, INVALID_ADDR, targhanp,
- targhlen, PATHBUF_LEN, pathbuf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalid targhanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 3)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid targhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen,
- (void *)INVALID_ADDR, targhlen,
- PATHBUF_LEN, pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalid targhlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 4)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid targhlen)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- INVALID_ADDR, PATHBUF_LEN,
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 5)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, 1, pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalid pathbufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 6)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid pathbufp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, PATHBUF_LEN,
- (char *)INVALID_ADDR, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 7)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, PATHBUF_LEN, pathbuf,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - file dirhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 8)) {
- int fd1, fd2;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd1 =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd1, &targhanp, &targhlen)) ==
- -1) {
- close(fd1);
- remove(DUMMY_FILE);
- } else
- if ((fd2 =
- open(DUMMY_FILE2, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- close(fd1);
- remove(DUMMY_FILE);
- dm_handle_free(targhanp, targhlen);
- } else if ((rc = dm_fd_to_handle(fd2, &dirhanp, &dirhlen)) ==
- -1) {
- close(fd2);
- remove(DUMMY_FILE2);
- close(fd1);
- remove(DUMMY_FILE);
- dm_handle_free(targhanp, targhlen);
- }
- if (fd1 == -1 || fd2 == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file dirhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd1);
- rc |= close(fd2);
- rc |= remove(DUMMY_FILE);
- rc |= remove(DUMMY_FILE2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - directory targhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 9)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &targhanp,
- &targhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir targhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - absolute root directory
- * EXPECTED: rc = 0
- *
- * This variation uncovered XFS BUG #12 (only worked if dirhanp was
- * current directory)
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 10)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(absolute root dir)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "rlen = %d, pathbuf = \"%s\"\n",
- rlen, pathbuf);
-
- if (strncmp(pathbuf, DUMMY_FILE, rlen) == 0) {
- *(pathbuf + rlen) = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and path = %s (length %d)\n",
- szFuncName, rc, pathbuf,
- rlen);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected path (%s vs %s)\n",
- szFuncName, rc, pathbuf,
- DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - relative root directory
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 11)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle("", &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(relative root dir)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "rlen = %d, pathbuf = \"%s\"\n",
- rlen, pathbuf);
-
- if (strncmp(pathbuf, DUMMY_FILE, rlen) == 0) {
- *(pathbuf + rlen) = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and path = %s (length %d)\n",
- szFuncName, rc, pathbuf,
- rlen);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected path (%s vs %s)\n",
- szFuncName, rc, pathbuf,
- DUMMY_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - file in subdirectory, one level
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 12)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dirhanp,
- &dirhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file in subdir)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "rlen = %d, pathbuf = \"%s\"\n",
- rlen, pathbuf);
-
- if (strncmp(pathbuf, DUMMY_SUBDIR_FILE, rlen) ==
- 0) {
- *(pathbuf + rlen) = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and path = %s (length %d)\n",
- szFuncName, rc, pathbuf,
- rlen);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected path (%s vs %s)\n",
- szFuncName, rc, pathbuf,
- DUMMY_SUBDIR_FILE);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - link in subdirectory, one level
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 13)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dirhanp,
- &dirhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = link(DUMMY_SUBDIR_FILE, DUMMY_SUBDIR_LINK)) ==
- -1) {
- close(fd);
- rmdir(DUMMY_SUBDIR);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR_LINK, &targhanp,
- &targhlen)) == -1) {
- unlink(DUMMY_SUBDIR_LINK);
- close(fd);
- rmdir(DUMMY_SUBDIR);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(link in subdir)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "rlen = %d, pathbuf = \"%s\"\n",
- rlen, pathbuf);
-
- if (strncmp(pathbuf, DUMMY_SUBDIR_LINK, rlen) ==
- 0) {
- *(pathbuf + rlen) = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and path = %s (length %d)\n",
- szFuncName, rc, pathbuf,
- rlen);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected path (%s vs %s)\n",
- szFuncName, rc, pathbuf,
- DUMMY_SUBDIR_LINK);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_SUBDIR_FILE);
- rc |= unlink(DUMMY_SUBDIR_LINK);
- rc |= rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - file in subdirectory, multiple levels
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 14)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DIR_LEVEL1, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DIR_LEVEL2, DUMMY_DIR_RW_MODE)) == -1) {
- rmdir(DIR_LEVEL1);
- } else if ((rc = mkdir(DIR_LEVEL3, DUMMY_DIR_RW_MODE)) == -1) {
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else if ((rc = mkdir(DIR_LEVEL4, DUMMY_DIR_RW_MODE)) == -1) {
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else
- if ((rc =
- dm_path_to_handle(DIR_LEVEL4, &dirhanp,
- &dirhlen)) == -1) {
- rmdir(DIR_LEVEL4);
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else
- if ((fd =
- open(FILE_LEVEL4, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DIR_LEVEL4);
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else
- if ((rc =
- dm_path_to_handle(FILE_LEVEL4, &targhanp,
- &targhlen)) == -1) {
- close(fd);
- remove(FILE_LEVEL4);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DIR_LEVEL4);
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(file in multiple subdir)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "rlen = %d, pathbuf = \"%s\"\n",
- rlen, pathbuf);
-
- if (strncmp(pathbuf, FILE_LEVEL4, rlen) == 0) {
- *(pathbuf + rlen) = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and path = %s (length %d)\n",
- szFuncName, rc, pathbuf,
- rlen);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected path (%s vs %s)\n",
- szFuncName, rc, pathbuf,
- FILE_LEVEL4);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(FILE_LEVEL4);
- rc |= rmdir(DIR_LEVEL4);
- rc |= rmdir(DIR_LEVEL3);
- rc |= rmdir(DIR_LEVEL2);
- rc |= rmdir(DIR_LEVEL1);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - targhanp not in dirhanp
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 15)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DIR_LEVEL1, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = mkdir(DIR_LEVEL2, DUMMY_DIR_RW_MODE)) == -1) {
- rmdir(DIR_LEVEL1);
- } else if ((rc = mkdir(DIR_LEVEL3, DUMMY_DIR_RW_MODE)) == -1) {
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else
- if ((rc =
- dm_path_to_handle(DIR_LEVEL3, &dirhanp,
- &dirhlen)) == -1) {
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else if ((rc = mkdir(DIR_LEVEL4, DUMMY_DIR_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else
- if ((fd =
- open(FILE_LEVEL4, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- rmdir(DIR_LEVEL4);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- } else
- if ((rc =
- dm_path_to_handle(FILE_LEVEL4, &targhanp,
- &targhlen)) == -1) {
- close(fd);
- remove(FILE_LEVEL4);
- rmdir(DIR_LEVEL4);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DIR_LEVEL3);
- rmdir(DIR_LEVEL2);
- rmdir(DIR_LEVEL1);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(targhanp not in dirhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(FILE_LEVEL4);
- rc |= rmdir(DIR_LEVEL4);
- rc |= rmdir(DIR_LEVEL3);
- rc |= rmdir(DIR_LEVEL2);
- rc |= rmdir(DIR_LEVEL1);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - fs dirhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 16)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc =
- dm_path_to_fshandle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs dirhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, PATHBUF_LEN, pathbuf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - fs targhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 17)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_FILE, &targhanp,
- &targhlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs targhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, PATHBUF_LEN, pathbuf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - global dirhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 18)) {
- int fd;
- void *targhanp;
- size_t targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global dirhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- targhanp, targhlen, PATHBUF_LEN,
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - global targhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 19)) {
- void *dirhanp;
- size_t dirhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- rc = dm_path_to_handle(mountPt, &dirhanp, &dirhlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global targhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN, PATHBUF_LEN,
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(dirhanp, dirhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalidated dirhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 20)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dirhanp,
- &dirhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = rmdir(DUMMY_SUBDIR)) == -1) {
- dm_handle_free(targhanp, targhlen);
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(dirhanp, dirhlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated dirhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- /*
- * TEST : dm_handle_to_path - invalidated targhanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(HANDLE_TO_PATH_BASE + 21)) {
- int fd;
- void *dirhanp, *targhanp;
- size_t dirhlen, targhlen;
- char pathbuf[PATHBUF_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_handle(DUMMY_SUBDIR, &dirhanp,
- &dirhlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- } else
- if ((fd =
- open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = dm_fd_to_handle(fd, &targhanp, &targhlen)) ==
- -1) {
- close(fd);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(targhanp, targhlen);
- remove(DUMMY_SUBDIR_FILE);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- } else if ((rc = remove(DUMMY_SUBDIR_FILE)) == -1) {
- dm_handle_free(targhanp, targhlen);
- dm_handle_free(dirhanp, dirhlen);
- rmdir(DUMMY_SUBDIR);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated targhanp)\n",
- szFuncName);
- rc = dm_handle_to_path(dirhanp, dirhlen, targhanp,
- targhlen, sizeof(pathbuf),
- pathbuf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(dirhanp, dirhlen);
- dm_handle_free(targhanp, targhlen);
- }
- }
-
- szFuncName = "dm_sync_by_handle";
-
- /*
- * TEST : dm_sync_by_handle - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_sync_by_handle(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_sync_by_handle(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_sync_by_handle(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_sync_by_handle(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_sync_by_handle(sid, hanp, hlen, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) ==
- DUMMY_STRLEN) ? 0 : -1) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_sync_by_handle(sid, hanp, hlen, DM_NO_TOKEN);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 7)) {
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_sync_by_handle(sid, hanp, hlen, DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_sync_by_handle(sid, hanp, hlen, DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_sync_by_handle - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 9)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_sync_by_handle(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_sync_by_handle - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SYNC_BY_HANDLE_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- remove(DUMMY_FILE);
- dm_handle_free(hanp, hlen);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_sync_by_handle(sid, hanp, hlen, DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- dm_handle_free(mtpthanp, mtpthlen);
- dm_handle_free(curdirhanp, curdirhlen);
-
- DMLOG_STOP();
-
- tst_exit();
-
-}
diff --git a/testcases/kernel/fs/dmapi/hole.c b/testcases/kernel/fs/dmapi/hole.c
deleted file mode 100644
index daddc9ab3..000000000
--- a/testcases/kernel/fs/dmapi/hole.c
+++ /dev/null
@@ -1,4616 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : hole.c
- *
- * VARIATIONS : 77
- *
- * API'S TESTED : dm_get_allocinfo
- * dm_probe_hole
- * dm_punch_hole
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define TMP_FILELEN 500000
-#define NUM_EXTENTS 8
-
-char command[4096];
-dm_sessid_t sid;
-dm_extent_t Extents[NUM_EXTENTS];
-dm_extent_t bigExtents[20];
-
-void LogExtents(dm_extent_t * pext, u_int nelem)
-{
-
- int i;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Extents:\n");
- for (i = 0; i < nelem; i++, pext++) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " extent %d: type %d, offset %lld, length %lld\n",
- i + 1, pext->ex_type, pext->ex_offset,
- pext->ex_length);
- }
-
-}
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int i;
- int rc;
- char *szSessionInfo = "dm_test session info";
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else {
- int fd;
-
- fd = open(DUMMY_TMP, O_RDWR | O_CREAT | O_TRUNC,
- DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < (TMP_FILELEN / DUMMY_STRLEN); i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc == 0) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI file hole tests\n");
-
- szFuncName = "dm_get_allocinfo";
-
- /*
- * TEST : dm_get_allocinfo - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_get_allocinfo(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, &off, NUM_EXTENTS,
- Extents, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, &off, NUM_EXTENTS,
- Extents, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #7 (EOPNOTSUPP errno returned
- * instead of EINVAL)
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, &off, NUM_EXTENTS,
- Extents, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, INVALID_ADDR,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - invalid offp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid offp)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- (dm_off_t *) INVALID_ADDR,
- NUM_EXTENTS, Extents, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - unaligned offp
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = UNALIGNED_BLK_OFF;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(unaligned offp)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - off past EOF
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = TMP_FILELEN + 1;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(off past EOF)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - zero nelem
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem zero)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, 0, Extents, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - invalid extentp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid extentp)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS,
- (dm_extent_t *) INVALID_ADDR,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - invalid nelemp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- (u_int *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - zero-length file
- * EXPECTED: rc = 0, nelem = 0
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(zero-length file)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n", rc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, " off = %lld\n", off);
- if (nelem == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n", nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - file all resident
- * EXPECTED: rc = 0, nelem = 1
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 13)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file all resident)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n", rc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, " off = %lld\n", off);
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n", nelem);
- LogExtents(Extents, nelem);
- if ((Extents[0].ex_length ==
- TMP_FILELEN)
- && (Extents[0].ex_offset == 0)
- && (Extents[0].ex_type ==
- DM_EXTENT_RES)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s extent information correct\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s extent information NOT correct!\n",
- szFuncName);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - file all hole
- * EXPECTED: rc = 0, nelem = 1
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if (((off =
- lseek(fd, TMP_FILELEN - DUMMY_STRLEN,
- SEEK_SET)) != TMP_FILELEN - DUMMY_STRLEN)
- ||
- ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) == -1)
- ||
- ((rc =
- ftruncate(fd,
- ((TMP_FILELEN / 2) & (~(BLK_SIZE - 1))))) ==
- -1)
- || ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1)) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || off != (TMP_FILELEN - DUMMY_STRLEN) || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- off = 0;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file all hole)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n", rc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, " off = %lld\n", off);
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n", nelem);
- LogExtents(Extents, nelem);
- if ((Extents[0].ex_length ==
- ((TMP_FILELEN /
- 2) & (~(BLK_SIZE - 1))))
- && (Extents[0].ex_offset == 0)
- && (Extents[0].ex_type ==
- DM_EXTENT_HOLE)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s extent information correct\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s extent information NOT correct!\n",
- szFuncName);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - hole, then resident
- * EXPECTED: rc = 0, nelem = 2
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 15)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if (((off =
- lseek(fd, TMP_FILELEN - DUMMY_STRLEN,
- SEEK_SET)) != TMP_FILELEN - DUMMY_STRLEN)
- ||
- ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) == -1)
- || ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1)) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || off != (TMP_FILELEN - DUMMY_STRLEN) || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- off = 0;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(hole, resident)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, " off = %lld\n", off);
- if (nelem == 2) {
- int i;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n", nelem);
- LogExtents(Extents, nelem);
- if ((i = 1)
- && (Extents[0].ex_length +
- Extents[1].ex_length ==
- TMP_FILELEN) && (i = 2)
- && (Extents[0].ex_offset == 0)
- && (i = 3)
- && (Extents[0].ex_length ==
- Extents[1].ex_offset) && (i = 4)
- && (Extents[0].ex_type ==
- DM_EXTENT_HOLE) && (i = 5)
- && (Extents[1].ex_type ==
- DM_EXTENT_RES)
- ) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s extent information correct\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s extent information NOT correct! (test %d failed)\n",
- szFuncName, i);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem, 2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - resident, then hole
- * EXPECTED: rc = 0, nelem = 2
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 16)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if (((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) == -1)
- ||
- ((off =
- lseek(fd, TMP_FILELEN - DUMMY_STRLEN,
- SEEK_SET)) != TMP_FILELEN - DUMMY_STRLEN)
- ||
- ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) == -1)
- ||
- ((rc =
- ftruncate(fd,
- ((TMP_FILELEN / 2) & (~(BLK_SIZE - 1))))) ==
- -1)
- || ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1)) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || off != (TMP_FILELEN - DUMMY_STRLEN) || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- off = 0;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(resident, hole)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, " off = %lld\n", off);
- if (nelem == 2) {
- int i;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n", nelem);
- LogExtents(Extents, nelem);
- if ((i = 1)
- && (Extents[0].ex_length +
- Extents[1].ex_length ==
- ((TMP_FILELEN /
- 2) & (~(BLK_SIZE - 1))))
- && (i = 2)
- && (Extents[0].ex_offset == 0)
- && (i = 3)
- && (Extents[0].ex_length ==
- Extents[1].ex_offset) && (i = 4)
- && (Extents[0].ex_type ==
- DM_EXTENT_RES) && (i = 5)
- && (Extents[1].ex_type ==
- DM_EXTENT_HOLE)
- ) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s extent information correct\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s extent information NOT correct! (test %d failed)\n",
- szFuncName, i);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem, 2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - resident, then hole, then resident
- * EXPECTED: rc = 0, nelem = 3
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 17)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- if ((fd =
- open(DUMMY_FILE, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if (((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) == -1)
- ||
- ((off =
- lseek(fd, TMP_FILELEN - DUMMY_STRLEN,
- SEEK_SET)) != TMP_FILELEN - DUMMY_STRLEN)
- ||
- ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) == -1)
- || ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1)) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || off != (TMP_FILELEN - DUMMY_STRLEN) || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- off = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(resident, hole, resident)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- int i;
- DMLOG_PRINT(DMLVL_DEBUG, " off = %lld\n", off);
-
- if (nelem == 3) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n", nelem);
- LogExtents(Extents, nelem);
- if ((i = 1)
- && (Extents[0].ex_length +
- Extents[1].ex_length +
- Extents[2].ex_length ==
- TMP_FILELEN) && (i = 2)
- && (Extents[0].ex_offset == 0)
- && (i = 3)
- && (Extents[0].ex_length ==
- Extents[1].ex_offset) && (i = 4)
- && (Extents[1].ex_length +
- Extents[1].ex_offset ==
- Extents[2].ex_offset) && (i = 5)
- && (Extents[0].ex_type ==
- DM_EXTENT_RES) && (i = 6)
- && (Extents[1].ex_type ==
- DM_EXTENT_HOLE) && (i = 7)
- && (Extents[2].ex_type ==
- DM_EXTENT_RES)
- ) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s extent information correct\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s extent information NOT correct! (test %d failed)\n",
- szFuncName, i);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem, 3);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - resident, then hole, then resident, then hole, etc.
- * EXPECTED: rc = 1, nelem = 8
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 18)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
- int i;
-
- /* Variation set up */
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- for (i = 0, rc = 0; rc == 0 && i < TMP_FILELEN;
- i += TMP_FILELEN / (NUM_EXTENTS + 2)) {
- if ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) != -1) {
- if ((off = lseek(fd, i, SEEK_SET)) != off) {
- rc = -1;
- }
- }
- }
- if ((rc == -1) ||
- ((off =
- lseek(fd, TMP_FILELEN - DUMMY_STRLEN, SEEK_SET)) != off)
- ||
- ((rc =
- (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) ? -1 : 0) == -1)
- || ((rc = dm_fd_to_handle(fd, &hanp, &hlen)))) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || off != TMP_FILELEN - DUMMY_STRLEN || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- off = 0;
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(resident, hole, resident, hole, etc.)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 1) {
- int i;
- DMLOG_PRINT(DMLVL_DEBUG, " off = %lld\n", off);
-
- if (nelem == NUM_EXTENTS) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n", nelem);
- LogExtents(Extents, nelem);
- if ((i = 1)
- && (Extents[0].ex_offset == 0)
- && (i = 2)
- && (Extents[0].ex_length ==
- Extents[1].ex_offset) && (i = 3)
- && (Extents[1].ex_length +
- Extents[1].ex_offset ==
- Extents[2].ex_offset) && (i = 4)
- && (Extents[2].ex_length +
- Extents[2].ex_offset ==
- Extents[3].ex_offset) && (i = 5)
- && (Extents[3].ex_length +
- Extents[3].ex_offset ==
- Extents[4].ex_offset) && (i = 6)
- && (Extents[4].ex_length +
- Extents[4].ex_offset ==
- Extents[5].ex_offset) && (i = 7)
- && (Extents[5].ex_length +
- Extents[5].ex_offset ==
- Extents[6].ex_offset) && (i = 8)
- && (Extents[6].ex_length +
- Extents[6].ex_offset ==
- Extents[7].ex_offset) && (i = 9)
- && (Extents[7].ex_length +
- Extents[7].ex_offset == off)
- && (i = 10)
- && (Extents[0].ex_type ==
- DM_EXTENT_RES) && (i = 11)
- && (Extents[1].ex_type ==
- DM_EXTENT_HOLE) && (i = 12)
- && (Extents[2].ex_type ==
- DM_EXTENT_RES) && (i = 13)
- && (Extents[3].ex_type ==
- DM_EXTENT_HOLE) && (i = 14)
- && (Extents[4].ex_type ==
- DM_EXTENT_RES) && (i = 15)
- && (Extents[5].ex_type ==
- DM_EXTENT_HOLE) && (i = 16)
- && (Extents[6].ex_type ==
- DM_EXTENT_RES) && (i = 17)
- && (Extents[7].ex_type ==
- DM_EXTENT_HOLE)
- ) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s extent information correct\n",
- szFuncName);
-
- rc = dm_get_allocinfo(sid, hanp,
- hlen,
- DM_NO_TOKEN,
- &off,
- sizeof
- (bigExtents)
- /
- sizeof
- (dm_extent_t),
- bigExtents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "second %s returned %d\n",
- szFuncName, rc);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n",
- nelem);
- LogExtents(bigExtents,
- nelem);
- if (bigExtents
- [nelem -
- 1].ex_offset +
- bigExtents[nelem -
- 1].
- ex_length ==
- TMP_FILELEN) {
- DMLOG_PRINT
- (DMLVL_DEBUG,
- "second %s extent information correct\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT
- (DMLVL_ERR,
- "second %s extent information NOT correct!\n",
- szFuncName);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "second %s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName,
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s extent information NOT correct! (test %d failed)\n",
- szFuncName, i);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem, 3);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 19)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_get_allocinfo(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, &off, NUM_EXTENTS,
- Extents, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 20)) {
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_SUBDIR, &hanp,
- &hlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_allocinfo - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 21)) {
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_get_allocinfo(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, &off, NUM_EXTENTS, Extents,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_get_allocinfo - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_ALLOCINFO_BASE + 22)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
- &off, NUM_EXTENTS, Extents,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_probe_hole";
-
- /*
- * TEST : dm_probe_hole - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_probe_hole(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, inoff, inlen, &outoff,
- &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_probe_hole(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, inoff, inlen, &outoff,
- &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
- inoff, inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, INVALID_ADDR, inoff,
- inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - invalid off
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = TMP_FILELEN + 1, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid off)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - invalid len
- * EXPECTED: rc = -1, errno = E2BIG
- *
- * This variation uncovered XFS BUG #8 (0 returned instead of -1 and
- * errno E2BIG)
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = TMP_FILELEN + 1, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid len)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - invalid roffp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid roffp)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, (dm_off_t *) INVALID_ADDR,
- &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff,
- (dm_size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - entire file
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(entire file)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "In -> offset %lld, length %lld\n",
- inoff, inlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Out <- offset %lld, length %lld\n",
- outoff, outlen);
- if (outoff == inoff) {
- if (outlen == inlen) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outlen (%d vs %d)\n",
- szFuncName, rc,
- outlen, inlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outoff (%d vs %d)\n",
- szFuncName, rc, outoff,
- inoff);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - end of file without rounding
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = BLKALIGN(UNALIGNED_BLK_OFF), outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(end of file without rounding)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "In -> offset %lld, length %lld\n",
- inoff, inlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Out <- offset %lld, length %lld\n",
- outoff, outlen);
- if (outoff == inoff) {
- if (outlen == inlen) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outlen (%d vs %d)\n",
- szFuncName, rc,
- outlen, inlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outoff (%d vs %d)\n",
- szFuncName, rc, outoff,
- inoff);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - end of file with rounding
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = UNALIGNED_BLK_OFF, outoff;
- dm_size_t inlen = TMP_FILELEN - UNALIGNED_BLK_OFF, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(end of file with rounding)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "In -> offset %lld, length %lld\n",
- inoff, inlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Out <- offset %lld, length %lld\n",
- outoff, outlen);
- if ((outoff >= inoff)
- && (!(outoff & (BLK_SIZE - 1)))) {
- if (outlen == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outlen (%d vs %d)\n",
- szFuncName, rc,
- outlen, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outoff %d\n",
- szFuncName, rc, outoff);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - middle of file without rounding
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 13)) {
-#ifdef INTERIOR_HOLES
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = BLKALIGN(UNALIGNED_BLK_OFF), outoff;
- dm_size_t inlen =
- BLKALIGN(TMP_FILELEN - BLK_SIZE - UNALIGNED_BLK_OFF),
- outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(middle of file without rounding)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "In -> offset %lld, length %lld\n",
- inoff, inlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Out <- offset %lld, length %lld\n",
- outoff, outlen);
- if (outoff == inoff) {
- if (outlen == inlen) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outlen (%d vs %d)\n",
- szFuncName, rc,
- outlen, inlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outoff (%d vs %d)\n",
- szFuncName, rc, outoff,
- inoff);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with INTERIOR_HOLES defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_probe_hole - middle of file with rounding, large
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 14)) {
-#ifdef INTERIOR_HOLES
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = UNALIGNED_BLK_OFF, outoff;
- dm_size_t inlen =
- TMP_FILELEN - BLK_SIZE - UNALIGNED_BLK_OFF, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(middle of file with rounding, large)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "In -> offset %lld, length %lld\n",
- inoff, inlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Out <- offset %lld, length %lld\n",
- outoff, outlen);
- if ((outoff >= inoff)
- && (!(outoff & (BLK_SIZE - 1)))) {
- if ((outlen <= inlen)
- && (!(outlen & (BLK_SIZE - 1)))) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outlen %d\n",
- szFuncName, rc,
- outlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outoff %d\n",
- szFuncName, rc, outoff);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with INTERIOR_HOLES defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_probe_hole - middle of file with rounding, small
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 15)) {
-#ifdef INTERIOR_HOLES
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = TMP_FILELEN / 2 - BLK_SIZE, outoff;
- dm_size_t inlen = 5 * BLK_SIZE, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(middle of file with rounding, small)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "In -> offset %lld, length %lld\n",
- inoff, inlen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Out <- offset %lld, length %lld\n",
- outoff, outlen);
- if ((outoff >= inoff)
- && (!(outoff & (BLK_SIZE - 1)))) {
- if ((outlen <= inlen)
- && (!(outlen & (BLK_SIZE - 1)))) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc %d\n",
- szFuncName, rc);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outlen %d\n",
- szFuncName, rc,
- outlen);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc %d but unexpected outoff %d\n",
- szFuncName, rc, outoff);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with INTERIOR_HOLES defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_probe_hole - middle of file with rounding, no hole
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 16)) {
-#ifdef INTERIOR_HOLES
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff =
- ((TMP_FILELEN / 2) & ~(BLK_SIZE - 1)) + 1, outoff;
- dm_size_t inlen = BLK_SIZE, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(middle of file with rounding, no hole)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with INTERIOR_HOLES defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_probe_hole - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 17)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_probe_hole(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, inoff, inlen, &outoff,
- &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 18)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_SUBDIR, &hanp,
- &hlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_probe_hole - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 19)) {
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_probe_hole(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, inoff, inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_probe_hole - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(PROBE_HOLE_BASE + 20)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0, outoff;
- dm_size_t inlen = 0, outlen;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, &outoff, &outlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_punch_hole";
-
- /*
- * TEST : dm_punch_hole - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_punch_hole(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, off, len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_punch_hole(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, off, len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
- == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
- off, len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, INVALID_ADDR, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - invalid off
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = TMP_FILELEN + 1;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid off)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - invalid len
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = TMP_FILELEN + 1;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid len)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - unaligned off
- * EXPECTED: rc = -1, errno = EAGAIN
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 1;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(unaligned off)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EAGAIN);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - unaligned len
- * EXPECTED: rc = -1, errno = EAGAIN
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 1;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(unaligned len)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EAGAIN);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - unaligned off and len
- * EXPECTED: rc = -1, errno = EAGAIN
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 10)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = UNALIGNED_BLK_OFF;
- dm_size_t len = TMP_FILELEN - UNALIGNED_BLK_OFF;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(unaligned off and len)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EAGAIN);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - truncate entire file
- * EXPECTED: rc = 0, nelem = 0
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(truncate entire file)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- off = 0;
- rc = dm_get_allocinfo(sid, hanp, hlen,
- DM_NO_TOKEN, &off,
- NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n",
- rc);
- if (rc == 0) {
- if (nelem == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n",
- nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem,
- 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_allocinfo failed with unexpected rc = %d (errno = %d)\n",
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - truncate part of file, len 0
- * EXPECTED: rc = 0, nelem = 1
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLK_SIZE;
- dm_size_t len = 0;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(truncate part of file, len 0)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- off = 0;
- rc = dm_get_allocinfo(sid, hanp, hlen,
- DM_NO_TOKEN, &off,
- NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n",
- rc);
- if (rc == 0) {
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n",
- nelem);
- LogExtents(Extents, nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem,
- 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_allocinfo failed with unexpected rc = %d (errno = %d)\n",
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - truncate part of file, len non-zero
- * EXPECTED: rc = 0, nelem = 1
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 13)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLK_SIZE;
- dm_size_t len = TMP_FILELEN - BLK_SIZE;
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(truncate part of file, len non-0)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- off = 0;
- rc = dm_get_allocinfo(sid, hanp, hlen,
- DM_NO_TOKEN, &off,
- NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n",
- rc);
- if (rc == 0) {
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n",
- nelem);
- LogExtents(Extents, nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem,
- 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_allocinfo failed with unexpected rc = %d (errno = %d)\n",
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - small hole
- * EXPECTED: rc = 0, nelem = 3
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 14)) {
-#ifdef INTERIOR_HOLES
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = (TMP_FILELEN / 2) & (~(BLK_SIZE - 1));
- dm_size_t len = 2 * BLK_SIZE;
- u_int nelem;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(small hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- off = 0;
- rc = dm_get_allocinfo(sid, hanp, hlen,
- DM_NO_TOKEN, &off,
- NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n",
- rc);
- if (rc == 0) {
- if (nelem == 3) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n",
- nelem);
- LogExtents(Extents, nelem);
- if ((lseek
- (fd, TMP_FILELEN / 2,
- SEEK_SET) ==
- (TMP_FILELEN / 2))
- &&
- (read(fd, buf, DUMMY_STRLEN)
- == DUMMY_STRLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer from hole: [%s]\n",
- buf);
- }
- if ((lseek
- (fd, TMP_FILELEN - 10,
- SEEK_SET) ==
- (TMP_FILELEN - 10))
- &&
- (read(fd, buf, DUMMY_STRLEN)
- == DUMMY_STRLEN)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer from resident extent: [%s]\n",
- buf);
- }
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem,
- 3);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_allocinfo failed with unexpected rc = %d (errno = %d)\n",
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with INTERIOR_HOLES defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_punch_hole - large hole
- * EXPECTED: rc = 0, nelem = 3
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 15)) {
-#ifdef INTERIOR_HOLES
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLK_SIZE;
- dm_size_t len =
- (TMP_FILELEN - (2 * BLK_SIZE)) & (~(BLK_SIZE - 1));
- u_int nelem;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(large hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMLOG_PRINT(DMLVL_DEBUG, "%s returned %d\n", szFuncName,
- rc);
- if (rc == 0) {
- off = 0;
- rc = dm_get_allocinfo(sid, hanp, hlen,
- DM_NO_TOKEN, &off,
- NUM_EXTENTS, Extents,
- &nelem);
- DMLOG_PRINT(DMLVL_DEBUG,
- "dm_get_allocinfo returned %d\n",
- rc);
- if (rc == 0) {
- if (nelem == 3) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " nelem = %d\n",
- nelem);
- LogExtents(Extents, nelem);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s nelem NOT correct! (%d vs %d)\n",
- szFuncName, nelem,
- 3);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_allocinfo failed with unexpected rc = %d (errno = %d)\n",
- rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with INTERIOR_HOLES defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_punch_hole - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 16)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_punch_hole(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, off, len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 17)) {
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_path_to_fshandle(DUMMY_SUBDIR, &hanp,
- &hlen)) == -1) {
- rmdir(DUMMY_SUBDIR);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DUMMY_SUBDIR);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 18)) {
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_punch_hole(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, off, len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_punch_hole - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 19)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DUMMY_FILE);
- } else if ((rc = remove(DUMMY_FILE)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private read mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 20)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private read mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private write mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 21)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private write mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private exec mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 22)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private exec mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private r/w mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 23)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private r/w mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared read mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 24)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared read mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared write mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 25)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared write mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared exec mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 26)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared exec mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared r/w mmap overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 27)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = 0;
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared r/w mmap overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private read mmap not overlapping hole
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 28)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private read mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private write mmap not overlapping hole
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 29)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private write mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private exec mmap not overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 30)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private exec mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - private r/w mmap not overlapping hole
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 31)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private r/w mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared read mmap not overlapping hole
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 32)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared read mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared write mmap not overlapping hole
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 33)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared write mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared exec mmap not overlapping hole
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 34)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared exec mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_punch_hole - shared r/w mmap not overlapping hole
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(PUNCH_HOLE_BASE + 35)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_off_t off = BLKALIGN(TMP_FILELEN / 2);
- dm_size_t len = 0;
- void *memmap;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
- remove(DUMMY_FILE);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DUMMY_FILE);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, 0)) == MAP_FAILED) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DUMMY_FILE);
- }
- if (fd == -1 || rc == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared r/w mmap not overlap hole)\n",
- szFuncName);
- rc = dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, off,
- len);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DUMMY_FILE);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- remove(DUMMY_TMP);
-
- DMLOG_STOP();
-
- tst_exit();
-}
diff --git a/testcases/kernel/fs/dmapi/invis.c b/testcases/kernel/fs/dmapi/invis.c
deleted file mode 100644
index 75be0f4f5..000000000
--- a/testcases/kernel/fs/dmapi/invis.c
+++ /dev/null
@@ -1,2707 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : invis.c
- *
- * VARIATIONS : 32
- *
- * API'S TESTED : dm_read_invis
- * dm_write_invis
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define TMP_FILELEN 1000
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-char DummyTmp[FILENAME_MAX];
-char DummyString[DUMMY_STRLEN];
-
-/* Variables for thread communications */
-dm_eventtype_t eventReceived;
-void *hanp1;
-size_t hlen1;
-dm_off_t offset;
-dm_size_t length;
-int numRegions;
-dm_region_t maxRegions[1], minRegions[1];
-
-void *Thread(void *);
-
-void LogStat(struct stat *statfs)
-{
-
- DMLOG_PRINT(DMLVL_DEBUG, " st_dev %d\n", statfs->st_dev);
- DMLOG_PRINT(DMLVL_DEBUG, " st_ino %d\n", statfs->st_ino);
- DMLOG_PRINT(DMLVL_DEBUG, " st_mode 0x%x\n", statfs->st_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " st_nlink %d\n", statfs->st_nlink);
- DMLOG_PRINT(DMLVL_DEBUG, " st_uid %d\n", statfs->st_uid);
- DMLOG_PRINT(DMLVL_DEBUG, " st_gid %d\n", statfs->st_gid);
- DMLOG_PRINT(DMLVL_DEBUG, " st_rdev %d\n", statfs->st_rdev);
- DMLOG_PRINT(DMLVL_DEBUG, " st_size %lld\n", statfs->st_size);
- DMLOG_PRINT(DMLVL_DEBUG, " st_blksize %d\n", statfs->st_blksize);
- DMLOG_PRINT(DMLVL_DEBUG, " st_blocks %d\n", statfs->st_blocks);
- DMLOG_PRINT(DMLVL_DEBUG, " st_atime %d\n", statfs->st_atime);
- DMLOG_PRINT(DMLVL_DEBUG, " st_mtime %d\n", statfs->st_mtime);
- DMLOG_PRINT(DMLVL_DEBUG, " st_ctime %d\n", statfs->st_ctime);
-
-}
-
-/*
- * StatCmp is used instead of memcmp because some of the pad fields or unused
- * fields may not be the same even though the pertinent info may be the same
- */
-int StatCmp(struct stat *stat1, struct stat *stat2)
-{
-
- if ((stat1->st_dev != stat2->st_dev) ||
- (stat1->st_ino != stat2->st_ino) ||
- (stat1->st_mode != stat2->st_mode) ||
- (stat1->st_nlink != stat2->st_nlink) ||
- (stat1->st_uid != stat2->st_uid) ||
- (stat1->st_gid != stat2->st_gid) ||
- (stat1->st_rdev != stat2->st_rdev) ||
- (stat1->st_size != stat2->st_size) ||
- (stat1->st_blksize != stat2->st_blksize) ||
- (stat1->st_blocks != stat2->st_blocks) ||
- (stat1->st_atime != stat2->st_atime) ||
- (stat1->st_mtime != stat2->st_mtime) ||
- (stat1->st_ctime != stat2->st_ctime)) {
- return -1;
- } else {
- return 0;
- }
-
-}
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int i;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events, maxFileEvents, minFileEvents;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- int fd;
-
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
- sprintf(DummyTmp, "%s/%s", mountPt, DUMMY_TMP);
-
- remove(DummyFile);
- rmdir(DummySubdir);
-
- memcpy(DummyString, DUMMY_STRING, DUMMY_STRLEN);
-
- EVENT_DELIVERY_DELAY;
- fd = open(DummyTmp, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < TMP_FILELEN / DUMMY_STRLEN; i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc != -1) {
- rc = fsync(fd);
- }
- if (rc != -1) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- }
-
- numRegions = 1;
- maxRegions[0].rg_offset = 0;
- maxRegions[0].rg_size = 0;
- maxRegions[0].rg_flags =
- DM_REGION_READ | DM_REGION_WRITE | DM_REGION_TRUNCATE;
- minRegions[0].rg_offset = 0;
- minRegions[0].rg_size = 0;
- minRegions[0].rg_flags = DM_REGION_NOEVENT;
-
- DMEV_ZERO(maxFileEvents);
- DMEV_SET(DM_EVENT_PREUNMOUNT, maxFileEvents);
- DMEV_SET(DM_EVENT_UNMOUNT, maxFileEvents);
- DMEV_SET(DM_EVENT_CREATE, maxFileEvents);
- DMEV_SET(DM_EVENT_CLOSE, maxFileEvents);
- DMEV_SET(DM_EVENT_POSTCREATE, maxFileEvents);
- DMEV_SET(DM_EVENT_REMOVE, maxFileEvents);
- DMEV_SET(DM_EVENT_POSTREMOVE, maxFileEvents);
- DMEV_SET(DM_EVENT_RENAME, maxFileEvents);
- DMEV_SET(DM_EVENT_POSTRENAME, maxFileEvents);
- DMEV_SET(DM_EVENT_LINK, maxFileEvents);
- DMEV_SET(DM_EVENT_POSTLINK, maxFileEvents);
- DMEV_SET(DM_EVENT_SYMLINK, maxFileEvents);
- DMEV_SET(DM_EVENT_POSTSYMLINK, maxFileEvents);
- DMEV_SET(DM_EVENT_ATTRIBUTE, maxFileEvents);
-
- DMEV_ZERO(minFileEvents);
- DMEV_SET(DM_EVENT_PREUNMOUNT, minFileEvents);
- DMEV_SET(DM_EVENT_UNMOUNT, minFileEvents);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI invisible read/write tests\n");
-
- szFuncName = "dm_read_invis";
-
- /*
- * TEST : dm_read_invis - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 1)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_read_invis(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, inoff, inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 2)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_read_invis(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, inoff, inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
- inoff, inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 4)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, INVALID_ADDR, inoff,
- inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - invalid off
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #9 (0 returned instead of -1 and
- * errno EINVAL)
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 5)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = TMP_FILELEN + 1;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid off)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 6)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, (void *)INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - file start
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 7)) {
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file start)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == inlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "read %d bytes\n", rc);
- if (memcmp(buf, DUMMY_STRING, DUMMY_STRLEN) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if ((rc2 == 0)
- &&
- (StatCmp(&statfs1, &statfs2)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - file middle
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 8)) {
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t inoff = (TMP_FILELEN / 2) - ((TMP_FILELEN / 2) % 10);
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file middle)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == inlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "read %d bytes\n", rc);
- if (memcmp(buf, DUMMY_STRING, DUMMY_STRLEN) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if ((rc2 == 0)
- &&
- (StatCmp(&statfs1, &statfs2)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - file end
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 9)) {
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t inoff = TMP_FILELEN - DUMMY_STRLEN;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file end)\n", szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == inlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "read %d bytes\n", rc);
- if (memcmp(buf, DUMMY_STRING, DUMMY_STRLEN) ==
- 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if ((rc2 == 0)
- &&
- (StatCmp(&statfs1, &statfs2)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - overlaps file end
- * EXPECTED: rc = DUMMY_STRLEN/2
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 10)) {
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t inoff = TMP_FILELEN - (DUMMY_STRLEN / 2);
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(overlaps file end)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == DUMMY_STRLEN / 2) {
- DMLOG_PRINT(DMLVL_DEBUG, "read %d bytes\n", rc);
- if (memcmp
- (buf, DummyString + (DUMMY_STRLEN / 2),
- DUMMY_STRLEN / 2) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if ((rc2 == 0)
- &&
- (StatCmp(&statfs1, &statfs2)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 11)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_read_invis(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, inoff, inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 12)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(directory handle)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 13)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_read_invis - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 14)) {
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_read_invis(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, inoff, inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_read_invis - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(READ_INVIS_BASE + 15)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- } else if ((rc = remove(DummyFile)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_read_invis(sid, hanp, hlen, DM_NO_TOKEN, inoff,
- inlen, buf);
- DMLOG_PRINT(DMLVL_DEBUG, "GOT %d, %s\n", rc, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- szFuncName = "dm_write_invis";
-
- /*
- * TEST : dm_write_invis - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 1)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_write_invis(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, 0, outoff, outlen,
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 2)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_write_invis(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, 0, outoff, outlen,
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 3)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, 0, outoff, outlen,
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 4)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, INVALID_ADDR, 0,
- outoff, outlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - invalid off+len
- * EXPECTED: rc = -1, errno = EFBIG
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 5)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = MAXFILESIZE - 5;
- dm_size_t outlen = TMP_FILELEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid off+len)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- outoff, outlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFBIG);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 6)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- outoff, outlen,
- (void *)INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - file start, async
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 7)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDWR)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file start, async)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- outoff, outlen, DUMMY_STRING2);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == outlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "wrote %d bytes\n",
- rc);
- if ((rc2 == 0)
- && (lseek(fd, outoff, SEEK_SET) == outoff)
- && (read(fd, buf, DUMMY_STRLEN) == outlen)
- && (memcmp(buf, DUMMY_STRING2, DUMMY_STRLEN)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if (StatCmp(&statfs1, &statfs2)
- == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING2,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - file middle, async
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 8)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t outoff = (TMP_FILELEN / 2) - ((TMP_FILELEN / 2) % 10);
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDWR)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file middle, async)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- outoff, outlen, DUMMY_STRING2);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == outlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "wrote %d bytes\n",
- rc);
- if ((rc2 == 0)
- && (lseek(fd, outoff, SEEK_SET) == outoff)
- && (read(fd, buf, DUMMY_STRLEN) == outlen)
- && (memcmp(buf, DUMMY_STRING2, DUMMY_STRLEN)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if (StatCmp(&statfs1, &statfs2)
- == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING2,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - file end, async
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 9)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t outoff = TMP_FILELEN - DUMMY_STRLEN;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDWR)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file end, async)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- outoff, outlen, DUMMY_STRING2);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == outlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "wrote %d bytes\n",
- rc);
- if ((rc2 == 0)
- && (lseek(fd, outoff, SEEK_SET) == outoff)
- && (read(fd, buf, DUMMY_STRLEN) == outlen)
- && (memcmp(buf, DUMMY_STRING2, DUMMY_STRLEN)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if (StatCmp(&statfs1, &statfs2)
- == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING2,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - file start, sync
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 10)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDWR)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file start, sync)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN,
- DM_WRITE_SYNC, outoff, outlen,
- DUMMY_STRING2);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == outlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "wrote %d bytes\n",
- rc);
- if ((rc2 == 0)
- && (lseek(fd, outoff, SEEK_SET) == outoff)
- && (read(fd, buf, DUMMY_STRLEN) == outlen)
- && (memcmp(buf, DUMMY_STRING2, DUMMY_STRLEN)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if (StatCmp(&statfs1, &statfs2)
- == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING2,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - file middle, sync
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 11)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t outoff = (TMP_FILELEN / 2) - ((TMP_FILELEN / 2) % 10);
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDWR)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file middle, sync)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN,
- DM_WRITE_SYNC, outoff, outlen,
- DUMMY_STRING2);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == outlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "wrote %d bytes\n",
- rc);
- if ((rc2 == 0)
- && (lseek(fd, outoff, SEEK_SET) == outoff)
- && (read(fd, buf, DUMMY_STRLEN) == outlen)
- && (memcmp(buf, DUMMY_STRING2, DUMMY_STRLEN)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if (StatCmp(&statfs1, &statfs2)
- == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING2,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - file end, sync
- * EXPECTED: rc = DUMMY_STRLEN
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 12)) {
- int fd;
- void *hanp, *fshanp;
- size_t hlen, fshlen;
- dm_off_t outoff = TMP_FILELEN - DUMMY_STRLEN;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
- struct stat statfs1, statfs2;
- int errnoSaved = 0;
- dm_boolean_t exactflag;
- int rc2;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDWR)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_handle_to_fshandle(hanp, hlen, &fshanp,
- &fshlen)) == -1) {
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &maxFileEvents, DM_EVENT_MAX)) == -1)
- ||
- ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, maxRegions,
- &exactflag)) == -1)
- || ((rc = stat(DummyFile, &statfs1)) == -1)) {
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! %d\n", errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- TIMESTAMP_DELAY;
- eventReceived = DM_EVENT_INVALID;
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file end, sync)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN,
- DM_WRITE_SYNC, outoff, outlen,
- DUMMY_STRING2);
- errnoSaved = errno;
- EVENT_DELIVERY_DELAY;
- rc2 = stat(DummyFile, &statfs2);
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, numRegions,
- minRegions, &exactflag);
- dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN,
- &minFileEvents, DM_EVENT_MAX);
- if (rc == outlen) {
- DMLOG_PRINT(DMLVL_DEBUG, "wrote %d bytes\n",
- rc);
- if ((rc2 == 0)
- && (lseek(fd, outoff, SEEK_SET) == outoff)
- && (read(fd, buf, DUMMY_STRLEN) == outlen)
- && (memcmp(buf, DUMMY_STRING2, DUMMY_STRLEN)
- == 0)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buffer contents [%.*s]\n",
- rc, buf);
- if (eventReceived == DM_EVENT_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "no event received\n");
- if (StatCmp(&statfs1, &statfs2)
- == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info same\n");
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "stat info NOT same!\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info before:\n");
- LogStat(&statfs1);
- DMLOG_PRINT(DMLVL_DEBUG,
- "stat info after:\n");
- LogStat(&statfs2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "event %d received!\n",
- eventReceived);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "buffer contents NOT correct! (%.*s vs %.*s)\n",
- DUMMY_STRLEN, DUMMY_STRING2,
- rc, buf);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errnoSaved);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 13)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_write_invis(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, 0, outoff, outlen,
- buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 14)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(directory handle)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- outoff, outlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 15)) {
- void *hanp;
- size_t hlen;
- dm_off_t outoff = 0;
- dm_size_t outlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- outoff, outlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_write_invis - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 16)) {
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_write_invis(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, 0, inoff, inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_write_invis - invalidated hanp
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(WRITE_INVIS_BASE + 17)) {
- void *hanp;
- size_t hlen;
- dm_off_t inoff = 0;
- dm_size_t inlen = DUMMY_STRLEN;
- char buf[DUMMY_STRLEN];
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- remove(DummyFile);
- } else if ((rc = remove(DummyFile)) == -1) {
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
- szFuncName);
- rc = dm_write_invis(sid, hanp, hlen, DM_NO_TOKEN, 0,
- inoff, inlen, buf);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- dm_handle_free(hanp, hlen);
- }
- }
-
- remove(DummyTmp);
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_CREATE, events);
- DMEV_SET(DM_EVENT_CLOSE, events);
- DMEV_SET(DM_EVENT_POSTCREATE, events);
- DMEV_SET(DM_EVENT_REMOVE, events);
- DMEV_SET(DM_EVENT_POSTREMOVE, events);
- DMEV_SET(DM_EVENT_RENAME, events);
- DMEV_SET(DM_EVENT_POSTRENAME, events);
- DMEV_SET(DM_EVENT_LINK, events);
- DMEV_SET(DM_EVENT_POSTLINK, events);
- DMEV_SET(DM_EVENT_SYMLINK, events);
- DMEV_SET(DM_EVENT_POSTSYMLINK, events);
- DMEV_SET(DM_EVENT_READ, events);
- DMEV_SET(DM_EVENT_WRITE, events);
- DMEV_SET(DM_EVENT_TRUNCATE, events);
- DMEV_SET(DM_EVENT_ATTRIBUTE, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_PREUNMOUNT) {
- /* SPECIAL CASE: need to set response */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_PREUNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle: %p\n",
- DM_GET_VALUE(nse, ne_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Root directory handle length: %d\n",
- DM_GET_LEN(nse, ne_handle2));
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set response and bMounted */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_UNMOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Unmount mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- DM_GET_VALUE(nse, ne_handle1, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n",
- DM_GET_LEN(nse, ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG, " Return code: %x\n",
- nse->ne_retcode);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- eventReceived = type;
-
- switch (type) {
- case DM_EVENT_READ:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
- length = de->de_length;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_READ\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Length: %d\n", length);
-
- response = DM_RESP_CONTINUE;
- break;
- }
-
- case DM_EVENT_WRITE:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
- length = de->de_length;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_WRITE\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Length: %d\n", length);
-
- response = DM_RESP_CONTINUE;
- break;
- }
-
- case DM_EVENT_TRUNCATE:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_TRUNCATE\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
-
- response = DM_RESP_CONTINUE;
- break;
- }
-
- case DM_EVENT_CREATE:
- case DM_EVENT_REMOVE:
- case DM_EVENT_RENAME:
- case DM_EVENT_LINK:
- case DM_EVENT_SYMLINK:
- response = DM_RESP_CONTINUE;
- break;
-
- case DM_EVENT_POSTCREATE:
- case DM_EVENT_POSTREMOVE:
- case DM_EVENT_POSTRENAME:
- case DM_EVENT_POSTLINK:
- case DM_EVENT_POSTSYMLINK:
- case DM_EVENT_ATTRIBUTE:
- case DM_EVENT_CLOSE:
- response = DM_RESP_INVALID;
- break;
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/mmap.c b/testcases/kernel/fs/dmapi/mmap.c
deleted file mode 100644
index 639cf5616..000000000
--- a/testcases/kernel/fs/dmapi/mmap.c
+++ /dev/null
@@ -1,1619 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : mmap.c
- *
- * VARIATIONS : 18
- *
- * EVENTS TESTED: DM_EVENT_READ
- * DM_EVENT_WRITE
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/mount.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define TMP_FILELEN 50000
-#define MMAPFILE_EXE "mmapfile"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummyTmp[FILENAME_MAX];
-
-/* Variables for thread communications */
-dm_eventtype_t eventExpected;
-dm_eventtype_t eventReceived;
-dm_response_t eventResponse;
-void *hanp1;
-size_t hlen1;
-dm_off_t offset;
-dm_size_t length;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int rc;
- int i;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- int fd;
-
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummyTmp, "%s/%s", mountPt, DUMMY_TMP);
-
- remove(DummyFile);
-
- EVENT_DELIVERY_DELAY;
- fd = open(DummyTmp, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < TMP_FILELEN / DUMMY_STRLEN; i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc != -1) {
- rc = fsync(fd);
- }
- if (rc != -1) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- }
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI memory mapped file synchronous event data tests\n");
-
- /*
- * TEST : mmap - no regions
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = 0;
- size_t inlen = DUMMY_STRLEN;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_INVALID;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_REGION_WRITE
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = 0;
- size_t inlen = DUMMY_STRLEN;
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_INVALID;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_REGION_TRUNCATE
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = 0;
- size_t inlen = DUMMY_STRLEN;
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_INVALID;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_READ, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_READ
- *
- * This variation uncovered XFS BUG #33 (entire file returned instead
- * of mapped region only)
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(0);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int varStatus;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (inoff != offset) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- inoff, offset);
- varStatus = DMSTAT_FAIL;
- } else if (inlen != length) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- inlen, length);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_READ, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(0);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int varStatus;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 0);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (inoff != offset) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- inoff, offset);
- varStatus = DMSTAT_FAIL;
- } else if (inlen != length) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- inlen, length);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_READ
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(0);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = TMP_FILELEN / 2;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_READ
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(TMP_FILELEN / 4);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = TMP_FILELEN / 2;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_READ
- * EXPECTED: DM_EVENT_READ
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(TMP_FILELEN / 4);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int varStatus;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_READ;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = TMP_FILELEN / 4;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (inoff != offset) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- inoff, offset);
- varStatus = DMSTAT_FAIL;
- } else if (inlen != length) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- inlen, length);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_READ
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_READ_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(TMP_FILELEN / 4);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDONLY, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - no regions
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = 0;
- size_t inlen = DUMMY_STRLEN;
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_INVALID;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else if ((rc = close(fd)) == -1) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_REGION_READ
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = 0;
- size_t inlen = DUMMY_STRLEN;
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_INVALID;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_READ;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_REGION_TRUNCATE
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = 0;
- size_t inlen = DUMMY_STRLEN;
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_INVALID;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_TRUNCATE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_WRITE, DM_RESP_CONTINUE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(0);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int varStatus;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (inoff != offset) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- inoff, offset);
- varStatus = DMSTAT_FAIL;
- } else if (inlen != length) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- inlen, length);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_WRITE, DM_RESP_ABORT
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(0);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int varStatus;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_ABORT;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 0);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (inoff != offset) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- inoff, offset);
- varStatus = DMSTAT_FAIL;
- } else if (inlen != length) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- inlen, length);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_WRITE
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(0);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = TMP_FILELEN / 2;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_WRITE
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(TMP_FILELEN / 4);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = TMP_FILELEN / 2;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_WRITE
- * EXPECTED: DM_EVENT_WRITE
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(TMP_FILELEN / 4);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int varStatus;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_WRITE;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = TMP_FILELEN / 4;
- Regions[0].rg_size = 0;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- if ((varStatus =
- DMVAR_CHKPASSEXP(0, rc, eventExpected,
- eventReceived)) == DMSTAT_PASS) {
- if (inoff != offset) {
- DMLOG_PRINT(DMLVL_ERR,
- "Offset NOT correct! (%d vs %d)\n",
- inoff, offset);
- varStatus = DMSTAT_FAIL;
- } else if (inlen != length) {
- DMLOG_PRINT(DMLVL_ERR,
- "Length NOT correct! (%d vs %d)\n",
- inlen, length);
- varStatus = DMSTAT_FAIL;
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : mmap - one region, DM_EVENT_WRITE
- * EXPECTED: no event
- */
- if (DMVAR_EXEC(MMAP_WRITE_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- off_t inoff = PAGEALIGN(TMP_FILELEN / 4);
- size_t inlen = PAGEALIGN(DUMMY_STRLEN);
- dm_boolean_t exactflag;
- int numRegions;
- dm_region_t Regions[1];
-
- /* Variation set up */
- eventExpected = DM_EVENT_INVALID;
- eventReceived = DM_EVENT_INVALID;
- eventResponse = DM_RESP_CONTINUE;
- numRegions = 1;
- Regions[0].rg_offset = 0;
- Regions[0].rg_size = DUMMY_STRLEN;
- Regions[0].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DummyTmp, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- numRegions, Regions, &exactflag)) == -1)
- || ((rc = close(fd)) == -1)) {
- dm_handle_free(hanp, hlen);
- remove(DummyFile);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE,
- DummyFile, O_RDWR, inoff, (long)inlen, 1);
- DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
- rc = system(command);
- EVENT_DELIVERY_DELAY;
- DMVAR_END(DMVAR_CHKPASSEXP
- (0, rc, eventExpected, eventReceived));
-
- /* Variation clean up */
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- remove(DummyFile);
- remove(DummyTmp);
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_READ, events);
- DMEV_SET(DM_EVENT_WRITE, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- eventReceived = type;
-
- switch (type) {
- case DM_EVENT_PREUNMOUNT:
- response = DM_RESP_CONTINUE;
- break;
-
- case DM_EVENT_READ:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
- length = de->de_length;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_READ\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Length: %d\n", length);
-
- response = eventResponse;
- break;
- }
-
- case DM_EVENT_WRITE:
- {
- dm_data_event_t *de =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_data_event_t *);
- hanp1 =
- DM_GET_VALUE(de, de_handle, void *);
- hlen1 = DM_GET_LEN(de, de_handle);
- offset = de->de_offset;
- length = de->de_length;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_WRITE\n");
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle: %p\n", hanp1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Handle length: %d\n",
- hlen1);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Offset: %d\n", offset);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Length: %d\n", length);
-
- response = eventResponse;
- break;
- }
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/mmapfile.c b/testcases/kernel/fs/dmapi/mmapfile.c
deleted file mode 100644
index 9f10376d0..000000000
--- a/testcases/kernel/fs/dmapi/mmapfile.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * FILE NAME : mmapfile.c
- *
- * PURPOSE : This executable is invoked by the mmap test case to invoke
- * mmap() from a process different than mmap. If mmap() is
- * invoked by the mmap process, a hang will generally occur
- * because sys_mmap obtains write access to mmap_sem, and any
- * page fault within the same process (while process is
- * responding to read/write event generated by mmap() call)
- * requires read access to the same mmap_sem.
- *
- * PARAMETERS : argv[1] - name of file being memory mapped
- * argv[2] - open flags:
- * 0 - read-only
- * 1 - write-only
- * 2 - read-write
- * argv[3] - offset within file of memory mapped region
- * argv[4] - length of memory mapped region
- * argv[5] - mmap() expected pass/fail status
- * 0 - fail
- * 1 - pass
- *
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-char DummyFile[FILENAME_MAX];
-
-int main(int argc, char **argv)
-{
- int rc;
- int fd;
- int openflags;
- int offset;
- int length;
- int passflag;
- int flags;
- void *memmap;
-
- if (--argc != 5) {
- printf("usage: %s filename openflags offset length passflag\n",
- argv[0]);
- exit(-1);
- }
-
- passflag = atoi(argv[5]);
- if ((passflag != 0) && (passflag != 1)) {
- printf("%s error: invalid passflag %s\n", argv[0], argv[5]);
- exit(-1);
- }
-
- length = atoi(argv[4]);
- if (length < 0) {
- printf("%s error: invalid length %s\n", argv[0], argv[4]);
- exit(-1);
- }
-
- offset = atoi(argv[3]);
- if (offset < 0) {
- printf("%s error: invalid offset %s\n", argv[0], argv[3]);
- exit(-1);
- }
- if (offset & (PAGE_SIZE - 1)) {
- printf("%s error: unaligned offset %d\n", argv[0], offset);
- exit(-1);
- }
-
- openflags = atoi(argv[2]);
- if (openflags == O_RDONLY) {
- flags = PROT_READ;
- } else if (openflags == O_WRONLY) {
- flags = PROT_WRITE;
- } else if (openflags == O_RDWR) {
- flags = PROT_READ | PROT_WRITE;
- } else {
- printf("%s error: invalid openflags %s\n", argv[0], argv[2]);
- exit(-1);
- }
-
- printf("invoking open(%s, %d)\n", argv[1], openflags);
- fd = open(argv[1], openflags);
- if (fd == -1) {
- printf("%s error: open failed with rc = %d (errno = %d)\n",
- argv[0], rc, errno);
- exit(-1);
- }
-
- printf("invoking memmap(%d, %d, %s, %d)\n", length, flags, argv[1],
- offset);
- memmap = mmap(NULL, length, flags, MAP_SHARED, fd, offset);
- if (memmap == MAP_FAILED) {
- printf("%s error: mmap failed with errno = %d\n", argv[0],
- errno);
- if (passflag) {
- close(fd);
- exit(-1);
- }
- }
-
- EVENT_DELIVERY_DELAY;
-
- if (memmap != MAP_FAILED) {
- printf("invoking munmap(%p, %d)\n", memmap, length);
- munmap(memmap, length);
- }
-
- close(fd);
-
- _exit(0);
- tst_exit();
-}
diff --git a/testcases/kernel/fs/dmapi/mount.c b/testcases/kernel/fs/dmapi/mount.c
deleted file mode 100644
index 8bfd42915..000000000
--- a/testcases/kernel/fs/dmapi/mount.c
+++ /dev/null
@@ -1,871 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : mount.c
- *
- * VARIATIONS : 12
- *
- * API'S TESTED : dm_get_mountinfo
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define MOUNTEVENT_LEN 100
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-dm_mount_event_t *me_ptr;
-dm_size_t me_len;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- remove(DummyFile);
- rmdir(DummySubdir);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI mount tests\n");
-
- szFuncName = "dm_set_dmattr";
-
- /*
- * TEST : dm_get_mountinfo - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_get_mountinfo(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, hanp, INVALID_ADDR,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, hanp, hlen, INVALID_ADDR,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - invalid buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN, 0,
- buf, &rlen);
- if (rc == -1) {
- if (errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n",
- rlen);
- if (rlen == me_len) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d\n",
- szFuncName, -1,
- E2BIG);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, -1,
- E2BIG, rlen,
- me_len);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, -1, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - invalid bufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), (void *)INVALID_ADDR,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - invalid rlenp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
- if (rlen == me_len) {
- if (memcmp(buf, me_ptr, rlen) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but mount info not same\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but mount info len not same (%d vs %d)\n",
- szFuncName, 0, rlen,
- me_len);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_get_mountinfo(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, sizeof(buf), buf,
- &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 10)) {
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_get_mountinfo(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_get_mountinfo - file handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
- -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_mountinfo - dir handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 12)) {
- void *hanp;
- size_t hlen;
- char buf[MOUNTEVENT_LEN];
- size_t rlen;
-
- /* Variation set up */
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- if (me_ptr != NULL) {
- free(me_ptr);
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *hanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t hlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- hanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", hlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(hanp, hlen);
-
- rc = dm_request_right(sid, hanp, hlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_set_disp(sid, hanp, hlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, hanp, hlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- me_len =
- me->me_roothandle.vd_offset +
- me->me_roothandle.vd_length;
- if ((me_ptr = malloc(me_len)) == NULL) {
- DMLOG_PRINT(DMLVL_ERR,
- "malloc failed! (errno = %d)\n",
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- memcpy(me_ptr, me, me_len);
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- switch (type) {
- case DM_EVENT_PREUNMOUNT:
- response = DM_RESP_CONTINUE;
- break;
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/objref.c b/testcases/kernel/fs/dmapi/objref.c
deleted file mode 100644
index 889d62633..000000000
--- a/testcases/kernel/fs/dmapi/objref.c
+++ /dev/null
@@ -1,764 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : objref.c
- *
- * VARIATIONS : 24
- *
- * API'S TESTED : dm_obj_ref_hold
- * dm_obj_ref_rele
- * dm_obj_ref_query
- */
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummySubdir[FILENAME_MAX];
-int runTestOnCreate;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- rmdir(DummySubdir);
- }
-
- /* This is what kicks off the test case, variations done in thread */
- runTestOnCreate = 1;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- runTestOnCreate = 0;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "mkdir failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "rmdir failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void DoTest(dm_token_t token, void *hanp, size_t hlen)
-{
-
- char *szFuncName;
- int rc;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI object reference tests\n");
-
- szFuncName = "dm_obj_ref_hold";
-
- /*
- * TEST : dm_obj_ref_hold - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 1)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_obj_ref_hold(INVALID_ADDR, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_hold - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 2)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_obj_ref_hold(sid, INVALID_ADDR, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_hold - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 3)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_obj_ref_hold(sid, token, (void *)INVALID_ADDR, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_hold - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 4)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
- rc = dm_obj_ref_hold(sid, token, hanp, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_hold - multiple holds
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 5)) {
-
- /* Variation set up */
- rc = dm_obj_ref_hold(sid, token, hanp, hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(multiple holds)\n",
- szFuncName);
- rc = dm_obj_ref_hold(sid, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- rc = dm_obj_ref_rele(sid, token, hanp, hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_obj_ref_hold - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 6)) {
- int rc2;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_obj_ref_hold(sid, token, hanp, hlen);
- if (rc == 0) {
- if ((rc2 =
- dm_obj_ref_query(sid, token, hanp, hlen)) == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected dm_obj_ref_query rc = %d\n",
- szFuncName, 0, rc2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_obj_ref_rele(sid, token, hanp, hlen);
- }
-
- /*
- * TEST : dm_obj_ref_hold - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 7)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_obj_ref_hold(DM_NO_SESSION, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_hold - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 8)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_obj_ref_hold(sid, token, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_obj_ref_rele";
-
- /*
- * TEST : dm_obj_ref_rele - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 1)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_obj_ref_rele(INVALID_ADDR, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_rele - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 2)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_obj_ref_rele(sid, INVALID_ADDR, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_rele - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 3)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_obj_ref_rele(sid, token, (void *)INVALID_ADDR, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_rele - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 4)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
- rc = dm_obj_ref_rele(sid, token, hanp, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_rele - no hold
- * EXPECTED: rc = -1, errno = EACCES
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 5)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(no hold)\n", szFuncName);
- rc = dm_obj_ref_rele(sid, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_rele - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 6)) {
- int rc2;
-
- /* Variation set up */
- rc = dm_obj_ref_hold(sid, token, hanp, hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
- rc = dm_obj_ref_rele(sid, token, hanp, hlen);
- if (rc == 0) {
- if ((rc2 =
- dm_obj_ref_query(sid, token, hanp,
- hlen)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected dm_obj_ref_query rc = %d\n",
- szFuncName, 0, rc2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
- }
- }
-
- /*
- * TEST : dm_obj_ref_rele - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 7)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_obj_ref_rele(DM_NO_SESSION, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_rele - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 8)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_obj_ref_rele(sid, token, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- szFuncName = "dm_obj_ref_query";
-
- /*
- * TEST : dm_obj_ref_query - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 1)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_obj_ref_query(INVALID_ADDR, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_query - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 2)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_obj_ref_query(sid, INVALID_ADDR, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_query - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 3)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_obj_ref_query(sid, token, (void *)INVALID_ADDR, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_query - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 4)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
- rc = dm_obj_ref_query(sid, token, hanp, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_query - not held
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 5)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(not held)\n", szFuncName);
- rc = dm_obj_ref_query(sid, token, hanp, hlen);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_query - held
- * EXPECTED: rc = 1
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 6)) {
-
- /* Variation set up */
- rc = dm_obj_ref_hold(sid, token, hanp, hlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(held)\n", szFuncName);
- rc = dm_obj_ref_query(sid, token, hanp, hlen);
- DMVAR_ENDPASSEXP(szFuncName, 1, rc);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_obj_ref_query - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 7)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_obj_ref_query(DM_NO_SESSION, token, hanp, hlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_obj_ref_query - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 8)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_obj_ref_query(sid, token, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_CREATE, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_CREATE) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- void *hanp = DM_GET_VALUE(nse, ne_handle1, void *);
- size_t hlen = DM_GET_LEN(nse, ne_handle1);
-
- if (runTestOnCreate) {
- DoTest(token, hanp, hlen);
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- switch (type) {
- case DM_EVENT_PREUNMOUNT:
- response = DM_RESP_CONTINUE;
- break;
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/pmr_post.c b/testcases/kernel/fs/dmapi/pmr_post.c
deleted file mode 100644
index bfd89f535..000000000
--- a/testcases/kernel/fs/dmapi/pmr_post.c
+++ /dev/null
@@ -1,1366 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : pmr_post.c
- *
- * VARIATIONS : 15
- *
- * API'S TESTED : dm_get_region
- *
- * NOTES : The first variation of this test case, when run after
- * pmr_pre and rebooting, verifies that persistent managed
- * regions work
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-
-#define TMP_FILELEN 10000
-
-void *Thread(void *);
-
-void LogRegions(dm_region_t * rgns, u_int nelem)
-{
- int i;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Regions:\n");
- for (i = 0; i < nelem; i++) {
- DMLOG_PRINT(DMLVL_DEBUG,
- " region %d: offset %lld, size %lld, flags %d\n",
- i, rgns[i].rg_offset, rgns[i].rg_size,
- rgns[i].rg_flags);
- }
-}
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int i;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
- char buf[MSG_DATALEN];
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- int fd;
-
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- /* DO NOT REMOVE DummyFile, IT HAS THE REGIONS FOR FIRST VAR */
- remove(DummySubdir);
-
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < (TMP_FILELEN / DUMMY_STRLEN); i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc == 0) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- }
-
- /* This is what kicks off the test case, variations done in thread */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_send_msg failed! (rc = %d, errno = %d)\n", rc,
- errno);
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- remove(DUMMY_FILE);
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void DoTest()
-{
-
- int rc;
- char *szFuncName;
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI persistent managed regions test\n");
-
- szFuncName = "dm_get_region";
-
- /*
- * TEST : dm_get_region - persistent, Part II
- * EXPECTED: rc = 0, nelem = 5
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[PMR_NUM_REGIONS];
- int varStatus;
- int i;
-
- /* Variation set up */
- if ((fd = open(DummyFile, O_RDWR)) == -1) {
- /* No clean up */
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (fd == -1 || rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(persistent, Part II)\n",
- szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- sizeof(regbuf) / sizeof(dm_region_t),
- regbuf, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- }
- varStatus = DMSTAT_PASS;
- if (rc != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "%s returned unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- varStatus = DMSTAT_FAIL;
- } else if (nelem != PMR_NUM_REGIONS) {
- DMLOG_PRINT(DMLVL_ERR,
- "Number of regions NOT correct! (%d vs %d)\n",
- nelem, PMR_NUM_REGIONS);
- varStatus = DMSTAT_FAIL;
- } else {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s returned expected rc = %d\n",
- szFuncName, rc, errno);
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", rc,
- errno);
- LogRegions(regbuf, nelem);
-
- for (i = 0; i < PMR_NUM_REGIONS; i++) {
- if (regbuf[i].rg_offset !=
- dm_PMR_regbuf[i].rg_offset) {
- DMLOG_PRINT(DMLVL_ERR,
- "region %d offset NOT correct! (%lld vs %d)\n",
- i,
- regbuf[i].rg_offset,
- dm_PMR_regbuf[i].
- rg_offset);
- varStatus = DMSTAT_FAIL;
- }
- if (regbuf[i].rg_size !=
- dm_PMR_regbuf[i].rg_size) {
- DMLOG_PRINT(DMLVL_ERR,
- "region %d size NOT correct! (%lld vs %d)\n",
- i,
- regbuf[i].rg_size,
- dm_PMR_regbuf[i].
- rg_size);
- varStatus = DMSTAT_FAIL;
- }
- if (regbuf[i].rg_flags !=
- dm_PMR_regbuf[i].rg_flags) {
- DMLOG_PRINT(DMLVL_ERR,
- "region %d flags NOT correct! (%lld vs %d)\n",
- i,
- regbuf[i].rg_flags,
- dm_PMR_regbuf[i].
- rg_flags);
- varStatus = DMSTAT_FAIL;
- }
- }
- }
- DMVAR_END(varStatus);
-
- /* Variation clean up */
- EVENT_DELIVERY_DELAY;
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_get_region(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, nelemin, ®buf,
- &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_get_region(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, nelemin, ®buf,
- &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_get_region(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
- nelemin, ®buf, &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_get_region(sid, hanp, hlen, INVALID_ADDR,
- nelemin, ®buf, &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - invalid regbufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid regbufp)\n",
- szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin,
- (dm_region_t *) INVALID_ADDR,
- &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - invalid nelemp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
- szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin, ®buf,
- (u_int *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - DM_SO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 8)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_get_region(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, nelemin, ®buf,
- &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 9)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®buf, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n",
- szFuncName);
- rc = dm_get_region(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, nelemin, ®buf,
- &nelemout);
- if (rc == -1 && errno == EBADF) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
- nelemout);
- }
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 10)) {
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin, ®buf, &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 11)) {
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
-
- /* Variation set up */
- nelemin = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_fshandle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin, ®buf, &nelemout);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - nelem 0
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbuf;
-
- /* Variation set up */
- nelemin = 0;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 0)\n", szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin, ®buf, &nelemout);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
- nelemout);
- if (nelemin == nelemout) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelemp (%d vs %d)\n",
- szFuncName, 0, nelemin,
- nelemout);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - nelem 1
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbufin, regbufout;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 1;
- memset(®bufin, 0, sizeof(regbufin));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- ®bufin, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 1)\n", szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin, ®bufout, &nelemout);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
- nelemout);
- if (nelemin == nelemout) {
- if (memcmp
- (®bufin, ®bufout,
- sizeof(dm_region_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected regions\n",
- szFuncName, 0);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Region in:\n");
- LogRegions(®bufin, nelemin);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Region out:\n");
- LogRegions(®bufout,
- nelemout);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelemp (%d vs %d)\n",
- szFuncName, 0, nelemin,
- nelemout);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_get_region - nelem 2
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 13)) {
-#ifdef MULTIPLE_REGIONS
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbufin[2], regbufout[2];
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelemin = 2;
- regbufin[0].rg_offset = 0;
- regbufin[0].rg_size = 1000;
- regbufin[0].rg_flags = DM_REGION_READ;
- regbufin[1].rg_offset = 2000;
- regbufin[1].rg_size = 1000;
- regbufin[1].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- regbufin, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 2)\n", szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin, regbufout, &nelemout);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
- nelemout);
- if (nelemin == nelemout) {
- if (memcmp
- (®bufin, ®bufout,
- sizeof(dm_region_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected regions\n",
- szFuncName, 0);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Region in:\n");
- LogRegions(regbufin, nelemin);
- DMLOG_PRINT(DMLVL_DEBUG,
- "Region out:\n");
- LogRegions(regbufout, nelemout);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelemp (%d vs %d)\n",
- szFuncName, 0, nelemin,
- nelemout);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with MULTIPLE_REGIONS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_get_region - regbuf too small
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GET_REGION_BASE + 14)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelemin, nelemout;
- dm_region_t regbufin[2], regbufout[1];
- dm_boolean_t exactflag;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelemin = 2;
- regbufin[0].rg_offset = 0;
- regbufin[0].rg_size = 1000;
- regbufin[0].rg_flags = DM_REGION_READ;
- regbufin[1].rg_offset = 2000;
- regbufin[1].rg_size = 1000;
- regbufin[1].rg_flags = DM_REGION_WRITE;
-#else
- nelemin = 1;
- regbufin[0].rg_offset = 0;
- regbufin[0].rg_size = 1000;
- regbufin[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin,
- regbufin, &exactflag)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(regbuf too small)\n",
- szFuncName);
- rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN,
- nelemin - 1, regbufout, &nelemout);
- if (rc == -1) {
- if (errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
- nelemout);
- if (nelemout == nelemin) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d\n",
- szFuncName, rc,
- errno);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected errno = %d but unexpected nelemp (%d vs %d)\n",
- szFuncName, rc,
- errno, nelemout,
- nelemin);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set bMounted and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set response and bMounted */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_USER) {
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_USER\n");
-
- DoTest();
-
- response = DM_RESP_CONTINUE;
- } else {
- DMLOG_PRINT(DMLVL_ERR, "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/pmr_pre.c b/testcases/kernel/fs/dmapi/pmr_pre.c
deleted file mode 100644
index 1b6ab4826..000000000
--- a/testcases/kernel/fs/dmapi/pmr_pre.c
+++ /dev/null
@@ -1,2579 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : pmr_pre.c
- *
- * VARIATIONS : 33
- *
- * API'S TESTED : dm_set_region
- *
- * NOTES : The last variation of this test case, when run before
- * rebooting and pmr_post, verifies that persistent managed
- * regions work
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/xattr.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define ATTR_LISTLEN 1000
-#define TMP_FILELEN 10000 /* must be > 2*PAGE_SIZE */
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-char *PMR_AttrName = PMR_ATTRNAME;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int i;
- int rc;
- char *szSessionInfo = "dm_test session info";
- char *szFuncName;
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- int fd;
-
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- remove(DummyFile);
- rmdir(DummySubdir);
-
- EVENT_DELIVERY_DELAY;
- fd = open(DUMMY_FILE, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd != -1) {
- for (i = 0; i < (TMP_FILELEN / DUMMY_STRLEN); i++) {
- if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
- DUMMY_STRLEN) {
- rc = -1;
- break;
- }
- }
- } else {
- rc = -1;
- }
- if (rc == 0) {
- rc = close(fd);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "creating dummy file failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
- }
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Starting DMAPI persistent managed regions test initialization\n");
-
- szFuncName = "dm_set_region";
-
- /*
- * TEST : dm_set_region - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 1)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_set_region(INVALID_ADDR, hanp, hlen,
- DM_NO_TOKEN, nelem, ®buf,
- &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 2)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp\n",
- szFuncName);
- rc = dm_set_region(sid, (void *)INVALID_ADDR, hlen,
- DM_NO_TOKEN, nelem, ®buf,
- &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 3)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
- nelem, ®buf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 4)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, INVALID_ADDR, nelem,
- ®buf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - invalid nelem
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 5)) {
- int fd;
- void *hanp;
- size_t hlen;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
- dm_size_t retval;
-
- /* Variation set up */
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((rc =
- dm_get_config(hanp, hlen,
- DM_CONFIG_MAX_MANAGED_REGIONS,
- &retval)) == -1) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelem)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN,
- retval + 1, ®buf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - invalid regbufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 6)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelem = 1;
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid regbufp)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- (dm_region_t *) INVALID_ADDR,
- &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - invalid exactflagp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 7)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
-
- /* Variation set up */
- nelem = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid exactflagp)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- ®buf,
- (dm_boolean_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 8)) {
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelem = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_set_region(DM_NO_SESSION, hanp, hlen,
- DM_NO_TOKEN, nelem, ®buf,
- &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 9)) {
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelem = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n",
- szFuncName);
- rc = dm_set_region(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- DM_NO_TOKEN, nelem, ®buf,
- &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - directory handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 10)) {
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelem = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
- /* No clean up */
- } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
- == -1) {
- rmdir(DummySubdir);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- ®buf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - fs handle
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 11)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
-
- /* Variation set up */
- nelem = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
- == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- ®buf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - nelem 0
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 12)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_boolean_t exactflag;
- char value[ATTR_LISTLEN];
-
- /* Variation set up */
- nelem = 0;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 0)\n", szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- NULL, &exactflag);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "exactflag = %d\n",
- exactflag);
- if (((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) == -1)
- && (errno == ENODATA)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected getxattr(%s) rc (%d vs %d), errno %d\n",
- szFuncName, 0, PMR_AttrName,
- rc, -1, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - nelem 1
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 13)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf;
- dm_boolean_t exactflag;
- char value[ATTR_LISTLEN];
-
- /* Variation set up */
- nelem = 1;
- memset(®buf, 0, sizeof(regbuf));
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 1)\n", szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- ®buf, &exactflag);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "exactflag = %d\n",
- exactflag);
- if ((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) >=
- sizeof(dm_region_t)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected getxattr(%s) rc (%d vs %d), errno %d\n",
- szFuncName, 0, PMR_AttrName,
- rc, sizeof(dm_region_t),
- errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - nelem 2
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 14)) {
-#ifdef MULTIPLE_REGIONS
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- char value[ATTR_LISTLEN];
-
- /* Variation set up */
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = 1000;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = 2000;
- regbuf[1].rg_size = 1000;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 2)\n", szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "exactflag = %d\n",
- exactflag);
- if ((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) >=
- (2 * sizeof(dm_region_t))) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected getxattr(%s) rc (%d vs %d), errno %d\n",
- szFuncName, 0, PMR_AttrName,
- rc, 2 * sizeof(dm_region_t),
- errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
-#else
- DMLOG_PRINT(DMLVL_WARN,
- "Test case not built with MULTIPLE_REGIONS defined\n");
- DMVAR_SKIP();
-#endif
- }
-
- /*
- * TEST : dm_set_region - clear
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 15)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- char value[ATTR_LISTLEN];
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = 1000;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = 2000;
- regbuf[1].rg_size = 1000;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = 1000;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag)) == -1)
- ||
- ((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) <
- (nelem * sizeof(dm_region_t)))) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- rc = -1; /* rc could be >= 0 from getxattr */
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(clear)\n", szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, 0,
- NULL, &exactflag);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "exactflag = %d\n",
- exactflag);
- if (((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) == -1)
- && (errno == ENODATA)) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected getxattr(%s) rc (%d vs %d), errno %d\n",
- szFuncName, 0, PMR_AttrName,
- rc, -1, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - replace
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 16)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- char value[ATTR_LISTLEN];
- ssize_t xattrlen;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = 1000;
- regbuf[0].rg_flags = DM_REGION_WRITE;
- regbuf[1].rg_offset = 2000;
- regbuf[1].rg_size = 1000;
- regbuf[1].rg_flags = DM_REGION_READ;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = 1000;
- regbuf[0].rg_flags = DM_REGION_WRITE;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if (((rc =
- dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag)) == -1)
- ||
- ((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) <
- (nelem * sizeof(dm_region_t)))) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- rc = -1; /* rc could be >= 0 from getxattr */
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- xattrlen = rc;
-
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = 1000;
- regbuf[0].rg_flags = DM_REGION_READ;
-
- DMLOG_PRINT(DMLVL_DEBUG, "%s(replace)\n", szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "exactflag = %d\n",
- exactflag);
-#ifdef MULTIPLE_REGIONS
- if ((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) < xattrlen) {
-#else
- if ((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) == xattrlen) {
-#endif
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected getxattr(%s) rc (%d vs %d), errno %d\n",
- szFuncName, 0, PMR_AttrName,
- rc, xattrlen, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private read mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 17)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private read mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private write mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 18)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = PAGE_SIZE;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_WRITE;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_PRIVATE, fd,
- PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private write mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private exec mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 19)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = PAGE_SIZE;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_WRITE;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, fd,
- PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private exec mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private read/write mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 20)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private r/w mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared read mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 21)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared read mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared write mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 22)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = PAGE_SIZE;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_WRITE;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_SHARED, fd,
- PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared write mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared exec mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 23)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = PAGE_SIZE;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_WRITE;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_SHARED, fd,
- PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared exec mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared read/write mmap overlapping region
- * EXPECTED: rc = -1, errno = EBUSY
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 24)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared r/w mmap overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private read mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 25)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = PAGE_SIZE;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_WRITE;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, fd,
- PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private read mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private write mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 26)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private write mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private exec mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 27)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_PRIVATE, fd,
- 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private exec mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - private r/w mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 28)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_PRIVATE, fd, 2 * PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(private r/w mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared read mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 29)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = PAGE_SIZE;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_WRITE;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd,
- PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared read mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared write mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 30)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_WRITE, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared write mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared exec mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 31)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_EXEC, MAP_SHARED, fd,
- 0)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared exec mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - shared r/w mmap not overlapping region
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 32)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[2];
- dm_boolean_t exactflag;
- void *memmap;
-
- /* Variation set up */
-#ifdef MULTIPLE_REGIONS
- nelem = 2;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
- regbuf[1].rg_offset = PAGE_SIZE;
- regbuf[1].rg_size = PAGE_SIZE / 2;
- regbuf[1].rg_flags = DM_REGION_WRITE;
-#else
- nelem = 1;
- regbuf[0].rg_offset = 0;
- regbuf[0].rg_size = PAGE_SIZE / 2;
- regbuf[0].rg_flags = DM_REGION_READ;
-#endif
-
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- } else
- if ((memmap =
- mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, 2 * PAGE_SIZE)) == MAP_FAILED) {
- close(fd);
- remove(DummyFile);
- dm_handle_free(hanp, hlen);
- }
- if (rc == -1 || fd == -1 || memmap == MAP_FAILED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(shared r/w mmap not overlap region)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- munmap(memmap, PAGE_SIZE);
- rc = close(fd);
- rc |= remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- /*
- * TEST : dm_set_region - persistent, Part I
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(SET_REGION_BASE + 33)) {
- int fd;
- void *hanp;
- size_t hlen;
- u_int nelem;
- dm_region_t regbuf[PMR_NUM_REGIONS];
- dm_boolean_t exactflag;
- char value[ATTR_LISTLEN];
-
- /* Variation set up */
- nelem = PMR_NUM_REGIONS;
- memcpy(regbuf, dm_PMR_regbuf, nelem * sizeof(dm_region_t));
- sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
- if ((rc = system(command)) == -1) {
- /* No clean up */
- } else
- if ((fd =
- open(DummyFile, O_RDWR | O_CREAT,
- DUMMY_FILE_RW_MODE)) == -1) {
- remove(DummyFile);
- } else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
- close(fd);
- remove(DummyFile);
- }
- if (rc == -1 || fd == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(persistent, Part I)\n",
- szFuncName);
- rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelem,
- regbuf, &exactflag);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "exactflag = %d\n",
- exactflag);
- if ((rc =
- getxattr(DummyFile, PMR_AttrName, value,
- sizeof(value))) >=
- (PMR_NUM_REGIONS * sizeof(dm_region_t))) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = 0\n",
- szFuncName);
- DMVAR_PASS();
-
- printf
- ("********************************************************\n");
- printf
- ("* PLEASE REBOOT AND RUN pmr_post TO COMPLETE VARIATION *\n");
- printf
- ("********************************************************\n");
-
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected getxattr(%s) rc (%d vs %d), errno %d\n",
- szFuncName, 0, PMR_AttrName,
- rc,
- PMR_NUM_REGIONS *
- sizeof(dm_region_t), errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = close(fd);
- /* DO NOT REMOVE DummyFile, IT IS NEEDED BY pmr_post */
- /*rc |= remove(DummyFile); */
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(hanp, hlen);
- }
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- remove(DUMMY_FILE);
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set bMounted and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- /* SPECIAL CASE: need to set bMounted and response */
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
-
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- DMLOG_PRINT(DMLVL_ERR, "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/right.c b/testcases/kernel/fs/dmapi/right.c
deleted file mode 100644
index 1604f015a..000000000
--- a/testcases/kernel/fs/dmapi/right.c
+++ /dev/null
@@ -1,2059 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : right.c
- *
- * VARIATIONS : 63
- *
- * API'S TESTED : dm_request_right
- * dm_release_right
- * dm_query_right
- * dm_upgrade_right
- * dm_downgrade_right
- */
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char command[4096];
-char *mountPt;
-char *deviceNm;
-char DummyFile[FILENAME_MAX];
-char DummySubdir[FILENAME_MAX];
-int fd_f;
-int runTestOnCreate;
-
-void *Thread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *varstr;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- remove(DummyFile);
- rmdir(DummySubdir);
- }
-
- fd_f = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
- if (fd_f == -1) {
- DMLOG_PRINT(DMLVL_ERR, "open failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- /* This is what kicks off the test case, variations done in thread */
- runTestOnCreate = 1;
- rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
- runTestOnCreate = 0;
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "mkdir failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- rc = rmdir(DummySubdir);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "rmdir failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- rc = close(fd_f);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "close failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- rc = remove(DummyFile);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "remove failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void DoTest(dm_token_t token, void *hanp, size_t hlen)
-{
-
- char *szFuncName;
- int rc;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI rights tests\n");
-
- szFuncName = "dm_request_right";
-
- /*
- * TEST : dm_request_right - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 1)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_request_right(INVALID_ADDR, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 2)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_request_right(sid, (void *)INVALID_ADDR, hlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 3)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
- rc = dm_request_right(sid, hanp, INVALID_ADDR, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 4)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_request_right(sid, hanp, hlen, INVALID_ADDR, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - invalid right
- * EXPECTED: rc = -1, errno = EINVAL
- *
- * This variation uncovered XFS BUG #29 (0 returned instead of -1 and
- * errno EINVAL)
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 5)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid right)\n", szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token, 0, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - DM_NO_TOKEN
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 6)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
- rc = dm_request_right(sid, hanp, hlen, DM_NO_TOKEN, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_NULL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 7)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RIGHT_NULL -> DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_NULL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 8)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL -> DM_RIGHT_EXCL)\n",
- szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_SHARED
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 9)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RIGHT_SHARED -> DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_SHARED,
- * DM_RR_WAIT clear
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 10)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RIGHT_SHARED -> DM_RIGHT_EXCL, DM_RR_WAIT clear)\n",
- szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_EXCL);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_SHARED,
- * DM_RR_WAIT set
- * EXPECTED: rc = -1, errno = EACCES
- *
- * This variation uncovered XFS BUG #30 (0 returned instead of -1 and
- * errno EACCES)
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 11)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RIGHT_SHARED -> DM_RIGHT_EXCL, DM_RR_WAIT set)\n",
- szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_EXCL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 12)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RIGHT_EXCL -> DM_RIGHT_EXCL)\n",
- szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_EXCL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 13)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(DM_RIGHT_EXCL -> DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_request_right - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 14)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_request_right(DM_NO_SESSION, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 15)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_request_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- token, 0, DM_RIGHT_SHARED);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_request_right - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 16)) {
- void *fhanp;
- size_t fhlen;
-
- /* Variation set up */
- rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_request_right(sid, fhanp, fhlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, fhanp, fhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_request_right - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 17)) {
- void *fshanp;
- size_t fshlen;
-
- /* Variation set up */
- rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_request_right(sid, fshanp, fshlen, token, 0,
- DM_RIGHT_SHARED);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, fshanp, fshlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- szFuncName = "dm_release_right";
-
- /*
- * TEST : dm_release_right - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 1)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_release_right(INVALID_ADDR, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 2)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_release_right(sid, (void *)INVALID_ADDR, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 3)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
- rc = dm_release_right(sid, hanp, INVALID_ADDR, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 4)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_release_right(sid, hanp, hlen, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - DM_NO_TOKEN
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 5)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
- rc = dm_release_right(sid, hanp, hlen, DM_NO_TOKEN);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - DM_RIGHT_NULL
- * EXPECTED: rc = -1, errno = EACCES
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 6)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
- rc = dm_release_right(sid, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - DM_RIGHT_SHARED
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 7)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_release_right(sid, hanp, hlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_release_right - DM_RIGHT_EXCL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 8)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n",
- szFuncName);
- rc = dm_release_right(sid, hanp, hlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_release_right - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 9)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_release_right(DM_NO_SESSION, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 10)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_release_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
- token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_release_right - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 11)) {
- void *fhanp;
- size_t fhlen;
-
- /* Variation set up */
- if ((rc == dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fhanp, fhlen, token, 0,
- DM_RIGHT_SHARED)) == -1) {
- dm_handle_free(fhanp, fhlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_release_right(sid, fhanp, fhlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_release_right - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 12)) {
- void *fshanp;
- size_t fshlen;
-
- /* Variation set up */
- if ((rc == dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) ==
- -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fshanp, fshlen, token, 0,
- DM_RIGHT_SHARED)) == -1) {
- dm_handle_free(fshanp, fshlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_release_right(sid, fshanp, fshlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- szFuncName = "dm_query_right";
-
- /*
- * TEST : dm_query_right - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 1)) {
- dm_right_t right;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_query_right(INVALID_ADDR, hanp, hlen, token, &right);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 2)) {
- dm_right_t right;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
- rc = dm_query_right(sid, (void *)INVALID_ADDR, hlen, token,
- &right);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 3)) {
- dm_right_t right;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
- rc = dm_query_right(sid, hanp, INVALID_ADDR, token, &right);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 4)) {
- dm_right_t right;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
- rc = dm_query_right(sid, hanp, hlen, INVALID_ADDR, &right);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - invalid rightp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 5)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rightp)\n", szFuncName);
- rc = dm_query_right(sid, hanp, hlen, token,
- (dm_right_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - DM_NO_TOKEN
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 6)) {
- dm_right_t right;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
- rc = dm_query_right(sid, hanp, hlen, DM_NO_TOKEN, &right);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - DM_RIGHT_SHARED
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 7)) {
- dm_right_t right;
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_query_right(sid, hanp, hlen, token, &right);
- if (rc == 0) {
- if (right == DM_RIGHT_SHARED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected right (%d vs %d)\n",
- szFuncName, 0, right,
- DM_RIGHT_SHARED);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_right - DM_RIGHT_EXCL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 8)) {
- dm_right_t right;
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_query_right(sid, hanp, hlen, token, &right);
- if (rc == 0) {
- if (right == DM_RIGHT_EXCL) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected right (%d vs %d)\n",
- szFuncName, 0, right,
- DM_RIGHT_EXCL);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_right - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 9)) {
- dm_right_t right;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_query_right(DM_NO_SESSION, hanp, hlen, token, &right);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 10)) {
- dm_right_t right;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
- rc = dm_query_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token,
- &right);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_right - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 11)) {
- void *fhanp;
- size_t fhlen;
- dm_right_t right;
-
- /* Variation set up */
- if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fhanp, fhlen, token, 0,
- DM_RIGHT_SHARED)) == -1) {
- dm_handle_free(fhanp, fhlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_query_right(sid, fhanp, fhlen, token, &right);
- if (rc == 0) {
- if (right == DM_RIGHT_SHARED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected right (%d vs %d)\n",
- szFuncName, 0, right,
- DM_RIGHT_SHARED);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_release_right(sid, fhanp, fhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_query_right - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(QUERY_RIGHT_BASE + 12)) {
- void *fshanp;
- size_t fshlen;
- dm_right_t right;
-
- /* Variation set up */
- if ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fshanp, fshlen, token, 0,
- DM_RIGHT_SHARED)) == -1) {
- dm_handle_free(fshanp, fshlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_query_right(sid, fshanp, fshlen, token, &right);
- if (rc == 0) {
- if (right == DM_RIGHT_SHARED) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected right (%d vs %d)\n",
- szFuncName, 0, right,
- DM_RIGHT_SHARED);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_release_right(sid, fshanp, fshlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- szFuncName = "dm_upgrade_right";
-
- /*
- * TEST : dm_upgrade_right - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 1)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_upgrade_right(INVALID_ADDR, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 2)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_upgrade_right(sid, (void *)INVALID_ADDR, hlen,
- token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 3)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_upgrade_right(sid, hanp, INVALID_ADDR, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 4)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_upgrade_right(sid, hanp, hlen, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - DM_RIGHT_NULL
- * EXPECTED: rc = -1, errno = EPERM
- *
- * This variation uncovered XFS BUG #31 (EACCES returned instead of
- * EPERM)
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 5)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
- rc = dm_upgrade_right(sid, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_upgrade_right - DM_RIGHT_SHARED
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 6)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_upgrade_right(sid, hanp, hlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - DM_RIGHT_EXCL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 7)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n",
- szFuncName);
- rc = dm_upgrade_right(sid, hanp, hlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 8)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_upgrade_right(DM_NO_SESSION, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 9)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n",
- szFuncName);
- rc = dm_upgrade_right(sid, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_upgrade_right - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 10)) {
- void *fhanp;
- size_t fhlen;
-
- /* Variation set up */
- if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fhanp, fhlen, token, 0,
- DM_RIGHT_SHARED)) == -1) {
- dm_handle_free(fhanp, fhlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_upgrade_right(sid, fhanp, fhlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, fhanp, fhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_upgrade_right - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 11)) {
- void *fshanp;
- size_t fshlen;
-
- /* Variation set up */
- if ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fshanp, fshlen, token, 0,
- DM_RIGHT_SHARED)) == -1) {
- dm_handle_free(fshanp, fshlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_upgrade_right(sid, fshanp, fshlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, fshanp, fshlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- }
- }
-
- szFuncName = "dm_downgrade_right";
-
- /*
- * TEST : dm_downgrade_right - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 1)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_downgrade_right(INVALID_ADDR, hanp, hlen,
- token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - invalid hanp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 2)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
- szFuncName);
- rc = dm_downgrade_right(sid, (void *)INVALID_ADDR, hlen,
- token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - invalid hlen
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 3)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
- szFuncName);
- rc = dm_downgrade_right(sid, hanp, INVALID_ADDR, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - invalid token
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 4)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
- szFuncName);
- rc = dm_downgrade_right(sid, hanp, hlen, INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - DM_RIGHT_NULL
- * EXPECTED: rc = -1, errno = EPERM
- *
- * This variation uncovered XFS BUG #32 (EACCES returned instead of
- * EPERM)
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 5)) {
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
- rc = dm_downgrade_right(sid, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_downgrade_right - DM_RIGHT_SHARED
- * EXPECTED: rc = -1, errno = EPERM
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 6)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n",
- szFuncName);
- rc = dm_downgrade_right(sid, hanp, hlen, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - DM_RIGHT_EXCL
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 7)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n",
- szFuncName);
- rc = dm_downgrade_right(sid, hanp, hlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 8)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_downgrade_right(DM_NO_SESSION, hanp, hlen,
- token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - global handle
- * EXPECTED: rc = -1, errno = EBADF
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 9)) {
-
- /* Variation set up */
- rc = dm_request_right(sid, hanp, hlen, token, 0,
- DM_RIGHT_SHARED);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
- szFuncName);
- rc = dm_downgrade_right(sid, DM_GLOBAL_HANP,
- DM_GLOBAL_HLEN, token);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
-
- /* Variation clean up */
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_downgrade_right - file handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 10)) {
- void *fhanp;
- size_t fhlen;
-
- /* Variation set up */
- if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fhanp, fhlen, token, 0,
- DM_RIGHT_EXCL)) == -1) {
- dm_handle_free(fhanp, fhlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
- szFuncName);
- rc = dm_downgrade_right(sid, fhanp, fhlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, fhanp, fhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fhanp, fhlen);
- }
- }
-
- /*
- * TEST : dm_downgrade_right - fs handle
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 11)) {
- void *fshanp;
- size_t fshlen;
-
- /* Variation set up */
- if ((rc =
- dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_request_right(sid, fshanp, fshlen, token, 0,
- DM_RIGHT_EXCL)) == -1) {
- dm_handle_free(fshanp, fshlen);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
- rc = dm_downgrade_right(sid, fshanp, fshlen, token);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_release_right(sid, fshanp, fshlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- dm_handle_free(fshanp, fshlen);
- }
- }
-
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t lhlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- lhanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", lhlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(lhanp, lhlen);
-
- rc = dm_request_right(sid, lhanp, lhlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_CREATE, events);
- rc = dm_set_disp(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, lhanp, lhlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_CREATE) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- void *hanp = DM_GET_VALUE(nse, ne_handle1, void *);
- size_t hlen = DM_GET_LEN(nse, ne_handle1);
-
- if (runTestOnCreate) {
- DoTest(token, hanp, hlen);
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- switch (type) {
- case DM_EVENT_PREUNMOUNT:
- response = DM_RESP_CONTINUE;
- break;
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
diff --git a/testcases/kernel/fs/dmapi/runtest_off.sh b/testcases/kernel/fs/dmapi/runtest_off.sh
deleted file mode 100755
index 95d506c40..000000000
--- a/testcases/kernel/fs/dmapi/runtest_off.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-# bsh
-#
-# Copyright (c) International Business Machines Corp., 2004
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-#
-# This script, and hence the invoked test cases, need to be run from a
-# directory that is NOT on the DMAPI-enabled partition (/dmtest below) being
-# tested; also, the DMAPI-enabled partition must be a disk (/dev/hda7 below)
-# preformatted for JFS via mkfs.fs
-#
-./event_sn -loglevel 4 -termlevel 4 -logname event_sn.log -mtpt /dmtest -device /dev/hda7
-./event_sd -loglevel 4 -termlevel 4 -logname event_sd.log -mtpt /dmtest -device /dev/hda7
-./event_an -loglevel 4 -termlevel 4 -logname event_an.log -mtpt /dmtest -device /dev/hda7
-# For true results, run pmr_pre, reboot and run pmr_post to test persistent
-# managed regions across reboots; however, the tests will work when run in
-# succession as below
-./pmr_pre -loglevel 4 -termlevel 4 -logname pmr_pre.log -mtpt /dmtest -device /dev/hda7
-./pmr_post -loglevel 4 -termlevel 4 -logname pmr_post.log -mtpt /dmtest -device /dev/hda7
-./event_am -loglevel 4 -termlevel 4 -logname event_am.log -mtpt /dmtest -device /dev/hda7
-./invis -loglevel 4 -termlevel 4 -logname invis.log -mtpt /dmtest -device /dev/hda7
-./event_us -loglevel 4 -termlevel 4 -logname event_us.log -mtpt /dmtest -device /dev/hda7
-./disp -loglevel 4 -termlevel 4 -logname disp.log -mtpt /dmtest -device /dev/hda7
-./objref -loglevel 4 -termlevel 4 -logname objref.log -mtpt /dmtest -device /dev/hda7
-./mount -loglevel 4 -termlevel 4 -logname mount.log -mtpt /dmtest -device /dev/hda7
-./token -loglevel 4 -termlevel 4 -logname token.log -mtpt /dmtest -device /dev/hda7
-./right -loglevel 4 -termlevel 4 -logname right.log -mtpt /dmtest -device /dev/hda7
-./mmap -loglevel 4 -termlevel 4 -logname mmap.log -mtpt /dmtest -device /dev/hda7
diff --git a/testcases/kernel/fs/dmapi/runtest_on.sh b/testcases/kernel/fs/dmapi/runtest_on.sh
deleted file mode 100755
index 7fb3e55e3..000000000
--- a/testcases/kernel/fs/dmapi/runtest_on.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-# bsh
-#
-# Copyright (c) International Business Machines Corp., 2004
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-#
-# This script, and hence the invoked test cases, need to be run from the
-# root directory of the DMAPI-enabled partition (/dmtest below) being tested
-#
-./session -loglevel 4 -termlevel 4 -logname session.log
-./handle -loglevel 4 -termlevel 4 -logname handle.log -mtpt /dmtest
-./hole -loglevel 4 -termlevel 4 -logname hole.log
-./attr -loglevel 4 -termlevel 4 -logname attr.log
-./config -loglevel 4 -termlevel 4 -logname config.log
-./event -loglevel 4 -termlevel 4 -logname event.log
diff --git a/testcases/kernel/fs/dmapi/session.c b/testcases/kernel/fs/dmapi/session.c
deleted file mode 100644
index dd57160bb..000000000
--- a/testcases/kernel/fs/dmapi/session.c
+++ /dev/null
@@ -1,1362 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : session.c
- *
- * VARIATIONS : 35
- *
- * API'S TESTED : dm_create_session
- * dm_destroy_session
- * dm_getall_sessions
- * dm_query_session
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "dm_test.h"
-
-#define NUM_SESSIONS 8
-
-char dmMsgBuf[4096];
-
-void LogSessions(dm_sessid_t * sid, u_int nelem)
-{
- int i;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Sessions:\n");
- for (i = 0; i < nelem; i++) {
- DMLOG_PRINT(DMLVL_DEBUG, " element %d: %d\n", i, sid[i]);
- }
-}
-
-int main(int argc, char **argv)
-{
-
- char *szSessionInfo = "dm_test session info";
- char *szFuncName;
- char *varstr;
- int i;
- int rc;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else {
- int nexist;
- rc = dm_getall_sessions(0, NULL, &nexist);
-
- if (rc == -1 && errno == E2BIG) {
- dm_sessid_t *psid;
-
- DMLOG_PRINT(DMLVL_DEBUG, "%d sessions already exist\n",
- nexist);
-
- if ((psid = malloc(nexist * sizeof(dm_sessid_t))) != NULL) {
- if ((rc =
- dm_getall_sessions(nexist, psid,
- &nexist)) == 0) {
- for (rc = 0, i = 0; i < nexist; i++) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "destroying session %d\n",
- psid[i]);
- rc |=
- dm_destroy_session(psid[i]);
- }
-
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed, unable to destroy existing sessions\n");
- DM_EXIT();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_getall_sessions failed, unable to destroy existing sessions\n");
- DM_EXIT();
- }
-
- free(psid);
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "malloc failed, unable to destroy existing sessions\n");
- DM_EXIT();
- }
- }
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI session tests\n");
-
- szFuncName = "dm_create_session";
-
- /*
- * TEST : dm_create_session - invalid oldsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 1)) {
- dm_sessid_t newsid;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid oldsid)\n", szFuncName);
- rc = dm_create_session(INVALID_ADDR, szSessionInfo, &newsid);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_session - NULL sessinfop
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 2)) {
- dm_sessid_t newsid;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL sessinfop)\n", szFuncName);
- rc = dm_create_session(DM_NO_SESSION, NULL, &newsid);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_session - invalid sessinfop
- * EXPECTED: rc = -1, errno = EFAULT
- *
- * This variation uncovered XFS BUG #2 (0 return code from strnlen_user
- * ignored, which indicated fault)
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 3)) {
- dm_sessid_t newsid;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sessinfop)\n", szFuncName);
- rc = dm_create_session(DM_NO_SESSION, (char *)INVALID_ADDR,
- &newsid);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_session - NULL newsidp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 4)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL newsidp)\n", szFuncName);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_session - invalid newsidp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 5)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid newsidp)\n", szFuncName);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
- (dm_sessid_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_session - DM_NO_SESSION oldsid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 6)) {
- dm_sessid_t newsid;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION oldsid)\n",
- szFuncName);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n", newsid);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : dm_create_session - valid oldsid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 7)) {
- dm_sessid_t newsid, oldsid;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- oldsid = newsid;
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid oldsid)\n",
- szFuncName);
- rc = dm_create_session(oldsid, szSessionInfo, &newsid);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n",
- newsid);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_create_session - invalidated oldsid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 8)) {
- dm_sessid_t newsid, oldsid, delsid;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_session(oldsid =
- newsid, szSessionInfo,
- &newsid)) == -1) {
- dm_destroy_session(oldsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- delsid = newsid;
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated oldsid)\n",
- szFuncName);
- rc = dm_create_session(oldsid, szSessionInfo, &newsid);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_destroy_session(delsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_create_session - maximum sessinfo
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 9)) {
- dm_sessid_t newsid;
- char *szBig =
- "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(max sessionfo)\n", szFuncName);
- rc = dm_create_session(DM_NO_SESSION, szBig, &newsid);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n", newsid);
- }
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
-
- /*
- * TEST : dm_create_session - sessinfo too big
- * EXPECTED: rc = -1, errno = E2BIG
- *
- * This variation uncovered XFS BUG #1 (sessinfo simply truncated, API
- * passed)
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 10)) {
- dm_sessid_t newsid;
- char *szTooBig =
- "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456";
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(sessinfo too big)\n", szFuncName);
- rc = dm_create_session(DM_NO_SESSION, szTooBig, &newsid);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_create_session - multiple sessions with same sessinfo
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(CREATE_SESSION_BASE + 11)) {
- dm_sessid_t newsid1, newsid2;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid1);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(same sessinfo)\n",
- szFuncName);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid2);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "1st newsid = %d, 2nd newsid = %d\n",
- newsid1, newsid2);
- if (newsid1 != newsid2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but session IDs same\n",
- szFuncName, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid1);
- rc |= dm_destroy_session(newsid2);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- szFuncName = "dm_destroy_session";
-
- /*
- * TEST : dm_destroy_session - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(DESTROY_SESSION_BASE + 1)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_destroy_session(DM_NO_SESSION);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_destroy_session - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(DESTROY_SESSION_BASE + 2)) {
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_destroy_session(INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_destroy_session - invalidated sid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(DESTROY_SESSION_BASE + 3)) {
- dm_sessid_t newsid;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) != -1) {
- rc = dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n",
- szFuncName);
- rc = dm_destroy_session(newsid);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_destroy_session - valid sid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(DESTROY_SESSION_BASE + 4)) {
- dm_sessid_t newsid;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid sid)\n", szFuncName);
- rc = dm_destroy_session(newsid);
- DMVAR_ENDPASSEXP(szFuncName, 0, rc);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_destroy_session - sid with oustanding events
- * EXPECTED: rc = -1, erno = EBUSY
- */
- if (DMVAR_EXEC(DESTROY_SESSION_BASE + 5)) {
- dm_sessid_t newsid;
- char buf[MSG_DATALEN];
- size_t rlen;
-
- /* Variation set up */
- memcpy(buf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- rc |= dm_send_msg(newsid, DM_MSGTYPE_ASYNC, MSG_DATALEN, buf);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid sid)\n", szFuncName);
- rc = dm_destroy_session(newsid);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
-
- /* Variation clean up */
- rc = dm_get_events(newsid, 1, 0, sizeof(dmMsgBuf),
- dmMsgBuf, &rlen);
- rc |= dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- szFuncName = "dm_getall_sessions";
-
- /*
- * TEST : dm_getall_sessions - NULL sidbufp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 1)) {
- dm_sessid_t newsid;
- int nelem;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL sidbufp)\n",
- szFuncName);
- rc = dm_getall_sessions(1, NULL, &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_sessions - invalid sidbufp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 2)) {
- dm_sessid_t newsid;
- int nelem;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sidbufp)\n",
- szFuncName);
- rc = dm_getall_sessions(1, (dm_sessid_t *) INVALID_ADDR,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_sessions - NULL nelemp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 3)) {
- dm_sessid_t newsid, sidArray[1];
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL nelemp)\n",
- szFuncName);
- rc = dm_getall_sessions(1, sidArray, NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_sessions - invalid nelemp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 4)) {
- dm_sessid_t newsid, sidArray[1];
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
- szFuncName);
- rc = dm_getall_sessions(1, sidArray,
- (u_int *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_sessions - zero nelem, zero sessions
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 5)) {
- dm_sessid_t sidArray[1];
- int nelem;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(zero nelem, zero sessions)\n",
- szFuncName);
- rc = dm_getall_sessions(0, sidArray, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 0);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_getall_sessions - zero nelem, one session
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 6)) {
- dm_sessid_t newsid, sidArray[1];
- int nelem;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(zero nelem, one session)\n",
- szFuncName);
- rc = dm_getall_sessions(0, sidArray, &nelem);
-
- if (rc == -1) {
- if (errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
- nelem);
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d\n",
- szFuncName, -1,
- E2BIG);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected errno = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, -1,
- E2BIG, nelem, 1);
- DMVAR_PASS();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, -1, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_sessions - one nelem, one session
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 7)) {
- dm_sessid_t newsid, sidArray[1];
- int nelem;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(one nelem, one session)\n",
- szFuncName);
- rc = dm_getall_sessions(1, sidArray, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
-
- if (nelem == 1) {
- LogSessions(sidArray, nelem);
-
- if (newsid == sidArray[0]) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and nelem = %d but unexpected session ID (%d vs %d)\n",
- szFuncName, 0,
- nelem, newsid,
- sidArray[0]);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_sessions - two nelem, one session
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 8)) {
- dm_sessid_t newsid, sidArray[2];
- int nelem;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(two nelem, one session)\n",
- szFuncName);
- rc = dm_getall_sessions(2, sidArray, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
-
- if (nelem == 1) {
- LogSessions(sidArray, nelem);
-
- if (newsid == sidArray[0]) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and nelem = %d but unexpected session ID (%d vs %d)\n",
- szFuncName, 0,
- nelem, newsid,
- sidArray[0]);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_sessions - ten nelem, eight sessions
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 9)) {
- dm_sessid_t sidExpected[NUM_SESSIONS], sidArray[10];
- int nelem;
-
- /* Variation set up */
- for (i = 0, rc = 0; i < NUM_SESSIONS && rc == 0; i++) {
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
- &sidExpected[i]);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- for (i--; i >= 0; i--) {
- dm_destroy_session(sidExpected[i]);
- }
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(%d nelem, %d sessions)\n",
- szFuncName,
- sizeof(sidArray) / sizeof(dm_sessid_t),
- NUM_SESSIONS);
- rc = dm_getall_sessions(sizeof(sidArray) /
- sizeof(dm_sessid_t), sidArray,
- &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
-
- if (nelem == NUM_SESSIONS) {
- LogSessions(sidArray, nelem);
-
- if (memcmp
- (sidArray, sidExpected,
- NUM_SESSIONS *
- sizeof(dm_sessid_t)) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and nelem = %d but unexpected session ID(s)\n",
- szFuncName, 0,
- nelem);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem,
- NUM_SESSIONS);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- for (i = 0, rc = 0; i < NUM_SESSIONS; i++) {
- rc |= dm_destroy_session(sidExpected[i]);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- szFuncName = "dm_query_session";
-
- /*
- * TEST : dm_query_session - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 1)) {
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
- rc = dm_query_session(DM_NO_SESSION, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_session - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 2)) {
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
-
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
- rc = dm_query_session(INVALID_ADDR, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
-
- /*
- * TEST : dm_query_session - invalidated sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 3)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
- if ((rc =
- dm_create_session(DM_NO_SESSION, szSessionInfo,
- &newsid)) != -1) {
- rc = dm_destroy_session(newsid);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n",
- szFuncName);
- rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- }
- }
-
- /*
- * TEST : dm_query_session - NULL bufp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 4)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL bufp)\n", szFuncName);
- rc = dm_query_session(newsid, sizeof(buf), NULL, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_session - invalid bufp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 5)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
- szFuncName);
- rc = dm_query_session(newsid, sizeof(buf),
- (void *)INVALID_ADDR, &rlen);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_session - NULL rlenp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 6)) {
- dm_sessid_t newsid;
- char buf[64];
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL rlenp)\n",
- szFuncName);
- rc = dm_query_session(newsid, sizeof(buf), buf, NULL);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_session - invalid rlenp
- * EXPECTED: rc = -1, errno EFAULT
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 7)) {
- dm_sessid_t newsid;
- char buf[64];
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
- szFuncName);
- rc = dm_query_session(newsid, sizeof(buf), buf,
- (size_t *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_session - zero buflen
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 8)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen zero)\n",
- szFuncName);
- rc = dm_query_session(newsid, 0, buf, &rlen);
- if (rc == -1) {
- if (errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n",
- rlen);
-
- if (rlen == strlen(szSessionInfo) + 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d\n",
- szFuncName, -1,
- E2BIG);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, -1,
- E2BIG, rlen,
- strlen
- (szSessionInfo) +
- 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, -1, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_session - valid
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 9)) {
- dm_sessid_t newsid;
- char buf[64];
- size_t rlen;
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName,
- sizeof(buf));
- rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
-
- if (rlen == strlen(szSessionInfo) + 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buf = \"%s\"\n", buf);
-
- if (strcmp(buf, szSessionInfo) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and rlen = %d but unexpected session info (\"%s\" vs \"%s\")\n",
- szFuncName, 0, rlen,
- buf, szSessionInfo);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, 0, rlen,
- strlen(szSessionInfo) + 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_query_session - maximum sessionfo
- * sessioninfo
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(QUERY_SESSION_BASE + 10)) {
- dm_sessid_t newsid;
- char buf[512];
- size_t rlen;
- char *szBig =
- "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
-
- /* Variation set up */
- rc = dm_create_session(DM_NO_SESSION, szBig, &newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(max sessinfo)\n",
- szFuncName, sizeof(buf));
- rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
-
- if (rlen == DM_SESSION_INFO_LEN) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "buf = \"%s\"\n", buf);
-
- if (strncmp
- (buf, szBig,
- DM_SESSION_INFO_LEN - 1) == 0) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and rlen = %d but unexpected session info (\"%s\" vs \"%s\")\n",
- szFuncName, 0, rlen,
- buf, szSessionInfo);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
- szFuncName, 0, rlen,
- DM_SESSION_INFO_LEN);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_destroy_session(newsid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- DMLOG_STOP();
-
- tst_exit();
-
-}
diff --git a/testcases/kernel/fs/dmapi/token.c b/testcases/kernel/fs/dmapi/token.c
deleted file mode 100644
index dd877cb12..000000000
--- a/testcases/kernel/fs/dmapi/token.c
+++ /dev/null
@@ -1,845 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2004
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * TEST CASE : token.c
- *
- * VARIATIONS : 9
- *
- * API'S TESTED : dm_getall_tokens
- */
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-#include "dm_test.h"
-
-#define TOKBUF_NUM 10
-#define TOKBUF_LEN (TOKBUF_NUM * sizeof(dm_token_t))
-
-pthread_t tid;
-dm_sessid_t sid;
-char dmMsgBuf[4096];
-char *mountPt;
-char *deviceNm;
-char DummySubdir[FILENAME_MAX];
-dm_token_t createToken;
-
-void *Thread(void *);
-void *TokenThread(void *);
-
-int main(int argc, char **argv)
-{
-
- char *szFuncName;
- char *varstr;
- int rc;
- char *szSessionInfo = "dm_test session info";
- dm_eventset_t events;
-
- DMOPT_PARSE(argc, argv);
- DMLOG_START();
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_MOUNT, events);
-
- /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
- if ((rc = dm_init_service(&varstr)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_init_service failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
- == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_create_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- DM_EXIT();
- } else
- if ((rc =
- dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
- &events, DM_EVENT_MAX)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
- DMLOG_PRINT(DMLVL_ERR,
- "pthread_create failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
- errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
-
- rmdir(DummySubdir);
- }
-
- DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI tokens tests\n");
-
- szFuncName = "dm_getall_tokens";
-
- /*
- * TEST : dm_getall_tokens - invalid sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 1)) {
- dm_token_t buf[TOKBUF_NUM];
- u_int nelem;
- char msgbuf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, msgbuf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
- szFuncName);
- rc = dm_getall_tokens(INVALID_ADDR, TOKBUF_NUM, buf,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_tokens - invalid nelem
- * EXPECTED: rc = -1, errno = E2BIG
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 2)) {
- dm_token_t buf[TOKBUF_NUM];
- u_int nelem;
- char msgbuf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, msgbuf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelem)\n",
- szFuncName);
- rc = dm_getall_tokens(sid, 0, buf, &nelem);
- if (rc == -1) {
- if (errno == E2BIG) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
- nelem);
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d and expected errno = %d\n",
- szFuncName, -1,
- E2BIG);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d and expected errno = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, -1,
- E2BIG, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected errno = %d\n",
- szFuncName, -1, errno);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d\n",
- szFuncName, rc);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_tokens - invalid tokenbufp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 3)) {
- u_int nelem;
- char msgbuf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, msgbuf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid tokenbufp)\n",
- szFuncName);
- rc = dm_getall_tokens(sid, TOKBUF_NUM,
- (dm_token_t *) INVALID_ADDR,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_tokens - invalid nelemp
- * EXPECTED: rc = -1, errno = EFAULT
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 4)) {
- dm_token_t buf[TOKBUF_NUM];
- char msgbuf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, msgbuf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
- szFuncName);
- rc = dm_getall_tokens(sid, TOKBUF_NUM, buf,
- (u_int *) INVALID_ADDR);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_tokens - one userevent token
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 5)) {
- dm_token_t buf[TOKBUF_NUM];
- u_int nelem;
- char msgbuf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, msgbuf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(one userevent token)\n",
- szFuncName);
- rc = dm_getall_tokens(sid, TOKBUF_NUM, buf, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "token 0: %d\n", buf[0]);
- if (token == buf[0]) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected token (%d vs %d)\n",
- szFuncName, 0,
- token, buf[0]);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_tokens - two userevent tokens
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 6)) {
- dm_token_t buf[TOKBUF_NUM];
- u_int nelem;
- char msgbuf[MSG_DATALEN];
- dm_token_t token1, token2;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, msgbuf,
- &token1)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, msgbuf,
- &token2)) == -1) {
- dm_respond_event(sid, token1, DM_RESP_CONTINUE, 0, 0,
- NULL);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(two userevent tokens)\n",
- szFuncName);
- rc = dm_getall_tokens(sid, TOKBUF_NUM, buf, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == 2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "token 0: %d\n", buf[0]);
- DMLOG_PRINT(DMLVL_DEBUG,
- "token 1: %d\n", buf[1]);
- if (token1 == buf[0]
- || token1 == buf[1]) {
- if (token2 == buf[0]
- || token2 == buf[1]) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName,
- 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but token = %d not in buf\n",
- szFuncName,
- 0, token2);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but token = %d not in buf\n",
- szFuncName, 0,
- token1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token2, DM_RESP_CONTINUE, 0,
- 0, NULL);
- rc |=
- dm_respond_event(sid, token1, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- /*
- * TEST : dm_getall_tokens - one event token
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 7)) {
- dm_token_t buf[TOKBUF_NUM];
- u_int nelem;
- pthread_t tidToken;
-
- /* Variation set up */
- createToken = 0;
- rc = pthread_create(&tidToken, NULL, TokenThread, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to set up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- /* Wait for DM_EVENT_CREATE event to set token */
- while (createToken == 0) {
- EVENT_DELIVERY_DELAY;
- }
- DMLOG_PRINT(DMLVL_DEBUG, "%s(one event token)\n",
- szFuncName);
- rc = dm_getall_tokens(sid, TOKBUF_NUM, buf, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == 1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "token 0: %d\n", buf[0]);
- if (buf[0] == createToken) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName, 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected token (%d vs %d)\n",
- szFuncName, 0,
- buf[0],
- createToken);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- pthread_join(tidToken, NULL);
- }
- }
-
- /*
- * TEST : dm_getall_tokens - one event token, one userevent token
- * EXPECTED: rc = 0
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 8)) {
- dm_token_t buf[TOKBUF_NUM];
- u_int nelem;
- char msgbuf[MSG_DATALEN];
- dm_token_t token;
- pthread_t tidToken;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- createToken = 0;
- if ((rc =
- dm_create_userevent(sid, MSG_DATALEN, msgbuf,
- &token)) == -1) {
- /* No clean up */
- } else
- if ((rc =
- pthread_create(&tidToken, NULL, TokenThread,
- NULL)) == -1) {
- dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0,
- NULL);
- }
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- /* Wait for DM_EVENT_CREATE event to set token */
- while (createToken == 0) {
- EVENT_DELIVERY_DELAY;
- }
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s(one event token, one userevent token)\n",
- szFuncName);
- rc = dm_getall_tokens(sid, TOKBUF_NUM, buf, &nelem);
- if (rc == 0) {
- DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
- if (nelem == 2) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "token 0: %d\n", buf[0]);
- DMLOG_PRINT(DMLVL_DEBUG,
- "token 1: %d\n", buf[1]);
- if (token == buf[0] || token == buf[1]) {
- if (createToken == buf[0]
- || createToken == buf[1]) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "%s passed with expected rc = %d\n",
- szFuncName,
- 0);
- DMVAR_PASS();
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but token = %d not in buf\n",
- szFuncName,
- 0,
- createToken);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but token = %d not in buf\n",
- szFuncName, 0,
- token);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
- szFuncName, 0, nelem, 1);
- DMVAR_FAIL();
- }
- } else {
- DMLOG_PRINT(DMLVL_ERR,
- "%s failed with unexpected rc = %d (errno = %d)\n",
- szFuncName, rc, errno);
- DMVAR_FAIL();
- }
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- pthread_join(tidToken, NULL);
- }
- }
-
- /*
- * TEST : dm_getall_tokens - DM_NO_SESSION sid
- * EXPECTED: rc = -1, errno = EINVAL
- */
- if (DMVAR_EXEC(GETALL_TOKENS_BASE + 9)) {
- dm_token_t buf[TOKBUF_NUM];
- u_int nelem;
- char msgbuf[MSG_DATALEN];
- dm_token_t token;
-
- /* Variation set up */
- memcpy(msgbuf, MSG_DATA, MSG_DATALEN);
- rc = dm_create_userevent(sid, MSG_DATALEN, msgbuf, &token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- DMVAR_SKIP();
- } else {
- /* Variation */
- DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION, sid)\n",
- szFuncName);
- rc = dm_getall_tokens(DM_NO_SESSION, TOKBUF_NUM, buf,
- &nelem);
- DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
-
- /* Variation clean up */
- rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0,
- 0, NULL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Unable to clean up variation! (errno = %d)\n",
- errno);
- }
- }
- }
-
- rc = umount(mountPt);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- pthread_join(tid, NULL);
-
- rc = dm_destroy_session(sid);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_destroy_session failed! (rc = %d, errno = %d)\n",
- rc, errno);
- }
-
- DMLOG_STOP();
-
- tst_exit();
-}
-
-void *Thread(void *parm)
-{
- int rc;
- size_t dmMsgBufLen;
- dm_eventmsg_t *dmMsg;
- int bMounted = DM_FALSE;
- dm_eventtype_t type;
- dm_token_t token;
- dm_eventset_t events;
- dm_response_t response;
-
- do {
- /* Loop until message received (wait could be interrupted) */
- do {
- DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
- dmMsgBufLen = 0;
-
- rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
- dmMsgBuf, &dmMsgBufLen);
- DMLOG_PRINT(DMLVL_DEBUG,
- "... dm_get_events returned %d (errno %d)\n",
- rc, errno);
- } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
-
- if (rc) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_get_events failed with rc = %d, errno = %d\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- } else {
- dmMsg = (dm_eventmsg_t *) dmMsgBuf;
- token = dmMsg->ev_token;
- type = dmMsg->ev_type;
-
- DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
- }
-
- if (type == DM_EVENT_MOUNT) {
- /* SPECIAL CASE: need to set disposition, events and response */
- dm_mount_event_t *me =
- DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
- void *hanp = DM_GET_VALUE(me, me_handle1, void *);
- size_t hlen = DM_GET_LEN(me, me_handle1);
-
- DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
- DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
- hanp);
- DMLOG_PRINT(DMLVL_DEBUG,
- " File system handle length: %d\n", hlen);
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
- DM_GET_VALUE(me, me_handle2, void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Mountpoint handle length: %d\n",
- DM_GET_LEN(me, me_handle2));
- DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
- DM_GET_VALUE(me, me_name1, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
- DM_GET_VALUE(me, me_name2, char *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
- DM_GET_VALUE(me, me_roothandle, void *));
- DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
- DM_GET_LEN(me, me_roothandle));
-
- bMounted = dm_handle_is_valid(hanp, hlen);
-
- rc = dm_request_right(sid, hanp, hlen, token,
- DM_RR_WAIT, DM_RIGHT_EXCL);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- DMEV_ZERO(events);
- DMEV_SET(DM_EVENT_PREUNMOUNT, events);
- DMEV_SET(DM_EVENT_UNMOUNT, events);
- DMEV_SET(DM_EVENT_CREATE, events);
- rc = dm_set_disp(sid, hanp, hlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_disp failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_set_eventlist(sid, hanp, hlen, token, &events,
- DM_EVENT_MAX);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- rc = dm_release_right(sid, hanp, hlen, token);
- if (rc == -1) {
- DMLOG_PRINT(DMLVL_ERR,
- "dm_request_right failed! (rc = %d, errno = %d)\n",
- rc, errno);
- dm_destroy_session(sid);
- DM_EXIT();
- }
-
- response = DM_RESP_CONTINUE;
- } else if (type == DM_EVENT_UNMOUNT) {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
- if (nse->ne_retcode == 0) {
- bMounted = DM_FALSE;
- }
-
- response = DM_RESP_CONTINUE;
- } else {
- switch (type) {
- case DM_EVENT_PREUNMOUNT:
- response = DM_RESP_CONTINUE;
- break;
-
- case DM_EVENT_CREATE:
- {
- dm_namesp_event_t *nse =
- DM_GET_VALUE(dmMsg, ev_data,
- dm_namesp_event_t *);
-
- DMLOG_PRINT(DMLVL_DEBUG,
- "Message is DM_EVENT_CREATE\n");
- DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n",
- nse->ne_mode);
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle: %p\n",
- DM_GET_VALUE(nse,
- ne_handle1,
- void *));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Parent handle length: %d\n",
- DM_GET_LEN(nse,
- ne_handle1));
- DMLOG_PRINT(DMLVL_DEBUG,
- " Entry name: %s\n",
- DM_GET_VALUE(nse, ne_name1,
- char *));
-
- createToken = token;
- DMLOG_PRINT(DMLVL_DEBUG,
- " Token: %d\n",
- createToken);
-
- /* Wait for main thread to call dm_getall_tokens */
- sleep(3);
-
- response = DM_RESP_CONTINUE;
- break;
- }
-
- default:
- {
- DMLOG_PRINT(DMLVL_ERR,
- "Message is unexpected!\n");
- response = DM_RESP_ABORT;
- break;
- }
- }
- }
-
- if (response != DM_RESP_INVALID) {
- DMLOG_PRINT(DMLVL_DEBUG,
- "Responding to message %d with %d\n", type,
- response);
- rc = dm_respond_event(sid, token, response,
- response ==
- DM_RESP_ABORT ? ABORT_ERRNO : 0,
- 0, NULL);
- }
- } while (bMounted);
-
- pthread_exit(0);
-}
-
-void *TokenThread(void *parm)
-{
- int rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
-
- if (rc != -1) {
- rmdir(DummySubdir);
- }
-
- pthread_exit(0);
-}
--
2.13.0
More information about the ltp
mailing list