Upgrade to LTP 20170929

A short log of commits merged as part of this is available in
Merge list

Bug: 67107373

No new disabled tests due to failure to build.

New configuration(s) added in android/include/config.h:
 HAVE_STRUCT_MMSGHDR
 HAVE_STRUCT_UTSNAME_DOMAINNAME
 HAVE_STRUCT_XT_ENTRY_MATCH
 HAVE_STRUCT_XT_ENTRY_TARGET

Following shows the new or deleted test suites in that will be run by 'vts':
                 Deleted                        Added
        ---------------------------------------------------------
 fcntl-locktests_android                      cve

Following shows the difference in testcases that will be run by 'vts':
                 Deleted                    Added
        ---------------------------------------------------------
net_stress.multicast.mcast4-grpope03 net_stress.multicast.mcast4-group-multiple-socket
net_stress.multicast.mcast4-grpope02 net_stress.multicast.mcast6-group-same-group
net_stress.multicast.mcast4-grpope01 net_stress.multicast.mcast4-group-source-filter
net_stress.multicast.mcast4-grpope04 net_stress.multicast.mcast6-group-source-filter
net_stress.multicast.mcast6-grpope01 net_stress.multicast.mcast4-group-single-socket
net_stress.multicast.mcast6-grpope03 net_stress.multicast.mcast6-group-multiple-socket
net_stress.multicast.mcast6-grpope02 net_stress.multicast.mcast6-group-single-socket
net_stress.multicast.mcast6-grpope04 net_stress.multicast.mcast4-group-same-group
        syscalls.lseek03        syscalls.keyctl04
        syscalls.lseek10        syscalls.keyctl05
        syscalls.lseek06         syscalls.msync04
        syscalls.lseek05   syscalls.cve-2017-6951
        syscalls.lseek04         syscalls.fcntl36
        syscalls.shmat03         syscalls.fcntl35
        syscalls.lseek09 syscalls.clock_nanosleep02
        syscalls.lseek08    syscalls.getsockopt02
        syscalls.write02 syscalls.copy_file_range01
        quickhit.lseek03         quickhit.lseek11
        quickhit.lseek05         quickhit.lseek07

Change-Id: Ib7f5c927098193c28200f06fb4d82578944f1eb8
Signed-off-by: Sandeep Patil <sspatil@google.com>
diff --git a/Android.bp b/Android.bp
index c002d6c..acfcfe7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -18,11 +18,11 @@
 build = ["gen.bp"]
 
 genrule {
-    name: "ltp_linux_syscall_numbers",
-    tool_files: ["testcases/kernel/include/regen.sh"],
-    cmd: "$(location) $(genDir)/linux_syscall_numbers.h",
-    srcs: ["testcases/kernel/include/*.in"],
-    out: ["linux_syscall_numbers.h"],
+    name: "ltp_syscalls_h",
+    tool_files: ["include/lapi/syscalls/regen.sh"],
+    cmd: "$(location) $(genDir)/lapi/syscalls.h",
+    srcs: ["include/lapi/syscalls/*.in"],
+    out: ["lapi/syscalls.h"],
 }
 
 cc_defaults {
@@ -46,8 +46,11 @@
         "-Wno-empty-body",
         "-Wno-format",
         "-Wno-gnu-designator",
+	"-Wno-implicit-function-declaration",
+	"-Wno-incompatible-pointer-types-discards-qualifiers",
         "-Wno-knr-promoted-parameter",
         "-Wno-macro-redefined",
+	"-Wno-missing-braces",
         "-Wno-missing-field-initializers",
         "-Wno-parentheses-equality",
         "-Wno-pointer-arith",
@@ -76,7 +79,7 @@
         },
     },
 
-    generated_headers: ["ltp_linux_syscall_numbers"],
+    generated_headers: ["ltp_syscalls_h"],
 
     static_libs: ["libcap"],
 
diff --git a/README b/README
deleted file mode 100644
index bf0061c..0000000
--- a/README
+++ /dev/null
@@ -1,48 +0,0 @@
-Linux Test Project
-------------------
-
-Linux Test Project is a joint project started by SGI, OSDL and Bull developed
-and maintained by IBM, Cisco, Fujitsu, SUSE, Red Hat, Oracle and others. The
-project goal is to deliver tests to the open source community that validate the
-reliability, robustness, and stability of Linux.
-
-The LTP testsuite contains a collection of tools for testing the Linux kernel
-and related features. Our goal is to improve the Linux kernel and system
-libraries by bringing test automation to the testing effort. Interested open
-source contributors are encouraged to join.
-
-Project pages are located at: http://linux-test-project.github.io/
-
-The latest image is always available at:
-https://github.com/linux-test-project/ltp/releases
-
-The discussion about the project happens at ltp mailing list:
-http://lists.linux.it/listinfo/ltp
-
-The git repository is located at GitHub at:
-https://github.com/linux-test-project/ltp
-
-Warning!
---------
-Be careful with these tests!
-
-Don't run them on production systems. Growfiles, doio, and iogen in particular
-stress the I/O capabilities of systems and while they should not cause problems
-on properly functioning systems, they are intended to find (or cause) problems.
-
-Developers corner
------------------
-
-Before you start you should read following documents:
-
-* doc/test-writing-guidelines.txt
-* doc/build-system-guide.txt
-
-these two should contain all information needed for modifying or creating LTP
-testcases. If something is not covered there don't hesitate to ask on the LTP
-mailing list.
-
-Also note that these documents are available online at:
-
-https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines
-https://github.com/linux-test-project/ltp/wiki/BuildSystem
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ffa769d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,140 @@
+Linux Test Project
+==================
+
+Linux Test Project is a joint project started by SGI, OSDL and Bull developed
+and maintained by IBM, Cisco, Fujitsu, SUSE, Red Hat, Oracle and others. The
+project goal is to deliver tests to the open source community that validate the
+reliability, robustness, and stability of Linux.
+
+The LTP testsuite contains a collection of tools for testing the Linux kernel
+and related features. Our goal is to improve the Linux kernel and system
+libraries by bringing test automation to the testing effort. Interested open
+source contributors are encouraged to join.
+
+Project pages are located at: http://linux-test-project.github.io/
+
+The latest image is always available at:
+https://github.com/linux-test-project/ltp/releases
+
+The discussion about the project happens at ltp mailing list:
+http://lists.linux.it/listinfo/ltp
+
+The git repository is located at GitHub at:
+https://github.com/linux-test-project/ltp
+
+Warning!
+========
+
+**Be careful with these tests!**
+
+Don't run them on production systems. Growfiles, doio, and iogen in particular
+stress the I/O capabilities of systems and while they should not cause problems
+on properly functioning systems, they are intended to find (or cause) problems.
+
+Quick guide to running the tests
+================================
+
+If you have git, autoconf, automake, m4, the linux headers and the common
+developer packages installed, the chances are the following will work.
+
+```
+$ git clone https://github.com/linux-test-project/ltp.git
+$ cd ltp
+$ make autotools
+$ ./configure
+$ make
+$ make install
+```
+
+This will install LTP to `/opt/ltp`.
+* If you have a problem see `doc/mini-howto-building-ltp-from-git.txt`.
+* If you still have a problem see `INSTALL` and `./configure --help`.
+* Failing that, ask for help on the mailing list or Github.
+
+Some tests will be disabled if the configure script can not find their build
+dependencies.
+
+* If a test returns `TCONF` due to a missing component, check the `./configure`
+  output.
+* If a tests fails due to a missing user or group, see the Quick Start section
+  of `INSTALL`.
+
+To run all the test suites
+
+```
+$ cd /opt/ltp
+$ ./runltp
+```
+
+Note that many test cases have to be executed as root.
+
+To run a particular test suite
+
+```
+$ ./runltp -f syscalls
+```
+
+To run all tests with `madvise` in the name
+
+```
+$ ./runltp -f syscalls -s madvise
+```
+Also see
+
+```
+$ ./runltp --help
+```
+
+Test suites (e.g. syscalls) are defined in the runtest directory. Each file
+contains a list of test cases in a simple format, see doc/ltp-run-files.txt.
+
+Each test case has its own executable or script, these can be executed
+directly
+
+```
+$ testcases/bin/abort01
+```
+
+Some have arguments
+
+```
+$ testcases/bin/fork13 -i 37
+```
+
+The vast majority of test cases accept the -h (help) switch
+
+```
+$ testcases/bin/ioctl01 -h
+```
+
+Many require certain environment variables to be set
+
+```
+$ LTPROOT=/opt/ltp PATH="$PATH:$LTPROOT/testcases/bin" testcases/bin/wc01.sh
+```
+
+Most commonly, the path variable needs to be set and also `LTPROOT`, but there
+are a number of other variables, `runltp` usually sets these for you.
+
+Note that all shell scripts need the `PATH` to be set. However this is not
+limited to shell scripts, many C based tests need environment variables as
+well.
+
+Developers corner
+=================
+
+Before you start you should read following documents:
+
+* `doc/test-writing-guidelines.txt`
+* `doc/build-system-guide.txt`
+
+There is also a step-by-step tutorial:
+
+* `doc/c-test-tutorial-simple.txt`
+
+If something is not covered there don't hesitate to ask on the LTP mailing
+list. Also note that these documents are available online at:
+
+https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines
+https://github.com/linux-test-project/ltp/wiki/BuildSystem
+https://github.com/linux-test-project/ltp/wiki/C-Test-Case-Tutorial
diff --git a/VERSION b/VERSION
index 43cf3b2..b92e2b2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-20170516
+20170929
diff --git a/android/Android.ltp.mk b/android/Android.ltp.mk
index 4a26697..0f77394 100644
--- a/android/Android.ltp.mk
+++ b/android/Android.ltp.mk
@@ -49,6 +49,10 @@
 module_src_files := testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/mcast-group-source-filter
+module_src_files := testcases/network/stress/multicast/grp-operation/mcast-group-source-filter
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/smack_file_access.sh
 module_src_files := testcases/kernel/security/smack/smack_file_access.sh
 include $(ltp_build_prebuilt)
@@ -81,6 +85,14 @@
 module_src_files := testcases/network/stress/tcp/uni-tso/tcp6-uni-tso13
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/route4-redirect
+module_src_files := testcases/network/stress/route/route4-redirect
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/tcp4-uni-tso13
+module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso13
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp6-uni-tso10
 module_src_files := testcases/network/stress/tcp/uni-tso/tcp6-uni-tso10
 include $(ltp_build_prebuilt)
@@ -121,6 +133,10 @@
 module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic06
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-multi-diffip04
+module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip04
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/data/file01/in.zip
 module_src_files := testcases/commands/file/datafiles/in.zip
 include $(ltp_build_prebuilt)
@@ -201,6 +217,10 @@
 module_src_files := testcases/commands/ar/datafiles/file2.in
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-multi-diffnic03
+module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic03
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/fs_bind/bind/test24
 module_src_files := testcases/kernel/fs/fs_bind/bind/test24
 include $(ltp_build_prebuilt)
@@ -233,10 +253,6 @@
 module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp4-uni-sackoff05
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-dsackoff03
-module_src_files := testcases/network/stress/tcp/uni-dsackoff/tcp6-uni-dsackoff03
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/tpm_changeauth_tests_exp02.sh
 module_src_files := testcases/commands/tpm-tools/tpm/tpm_changeauth/tpm_changeauth_tests_exp02.sh
 include $(ltp_build_prebuilt)
@@ -265,10 +281,6 @@
 module_src_files := testcases/network/stress/tcp/multi-diffport/tcp6-multi-diffport01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-winscale08
-module_src_files := testcases/network/stress/tcp/uni-winscale/tcp4-uni-winscale08
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/tcp6-uni-winscale11
 module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale11
 include $(ltp_build_prebuilt)
@@ -593,6 +605,10 @@
 module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp4-uni-sackoff03
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/mcast-lib.sh
+module_src_files := testcases/network/stress/multicast/grp-operation/mcast-lib.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-uni-sackoff08
 module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp4-uni-sackoff08
 include $(ltp_build_prebuilt)
@@ -801,12 +817,12 @@
 module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso10
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-tso11
-module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso11
+module_prebuilt := testcases/bin/sctp01.sh
+module_src_files := testcases/network/sctp/sctp01.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-tso12
-module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso12
+module_prebuilt := testcases/bin/test_net_stress.sh
+module_src_files := testcases/network/stress/ns-tools/test_net_stress.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/dctcp01.sh
@@ -1073,20 +1089,8 @@
 module_src_files := testcases/network/stress/broken_ip/broken_ip6-dstaddr
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/mcast6-grpope03
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast6-grpope03
-include $(ltp_build_prebuilt)
-
-module_prebuilt := testcases/bin/mcast6-grpope02
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast6-grpope02
-include $(ltp_build_prebuilt)
-
-module_prebuilt := testcases/bin/mcast6-grpope01
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast6-grpope01
-include $(ltp_build_prebuilt)
-
-module_prebuilt := testcases/bin/bg_tcp_traffic
-module_src_files := testcases/network/stress/ns-tools/bg_tcp_traffic
+module_prebuilt := testcases/bin/tcp6-uni-sackoff06
+module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp6-uni-sackoff06
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/memcg_lib.sh
@@ -1401,6 +1405,10 @@
 module_src_files := testcases/kernel/fs/fs_bind/rbind/test28
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-multi-sameport08
+module_src_files := testcases/network/stress/tcp/multi-sameport/tcp6-multi-sameport08
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/fs_bind/rbind/test22
 module_src_files := testcases/kernel/fs/fs_bind/rbind/test22
 include $(ltp_build_prebuilt)
@@ -1449,8 +1457,8 @@
 module_src_files := testcases/network/stress/tcp/multi-sameport/tcp6-multi-sameport07
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-tso13
-module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso13
+module_prebuilt := testcases/bin/file01.sh
+module_src_files := testcases/commands/file/file01.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tpm_changeauth_tests_exp03.sh
@@ -1493,6 +1501,10 @@
 module_src_files := testcases/commands/file/datafiles/in.src.rpm
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp4-uni-tso11
+module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso11
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp6-uni-dsackoff01
 module_src_files := testcases/network/stress/tcp/uni-dsackoff/tcp6-uni-dsackoff01
 include $(ltp_build_prebuilt)
@@ -1501,6 +1513,10 @@
 module_src_files := testcases/network/multicast/mc_commo/mc_commo
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-uni-dsackoff03
+module_src_files := testcases/network/stress/tcp/uni-dsackoff/tcp6-uni-dsackoff03
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp6-uni-dsackoff02
 module_src_files := testcases/network/stress/tcp/uni-dsackoff/tcp6-uni-dsackoff02
 include $(ltp_build_prebuilt)
@@ -1557,6 +1573,10 @@
 module_src_files := testcases/network/stress/ftp/ftp-download-stress01-rmt
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/udp_ipsec_vti.sh
+module_src_files := testcases/network/stress/udp/udp_ipsec_vti.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/broken_ip4-protcol
 module_src_files := testcases/network/stress/broken_ip/broken_ip4-protcol
 include $(ltp_build_prebuilt)
@@ -1705,8 +1725,8 @@
 module_src_files := testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/mcast4-grpope01
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast4-grpope01
+module_prebuilt := testcases/bin/tcp4-multi-diffport14
+module_src_files := testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport14
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/gzip_tests.sh
@@ -1729,18 +1749,10 @@
 module_src_files := testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/tpmtoken_objects_tests_exp01.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-winscale06
-module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale06
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/daemonlib.sh
 module_src_files := testcases/lib/daemonlib.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-winscale07
-module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale07
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/iptables_tests.sh
 module_src_files := testcases/network/iptables/iptables_tests.sh
 include $(ltp_build_prebuilt)
@@ -1753,8 +1765,8 @@
 module_src_files := testcases/kernel/io/stress_floppy/datafiles/dumpdir/1K_file
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-multi-diffport11
-module_src_files := testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport11
+module_prebuilt := testcases/bin/tcp6-uni-winscale01
+module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale01
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp4-multi-diffport12
@@ -2129,6 +2141,10 @@
 module_src_files := testcases/network/tcp_cmds/rcp/rcp01
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/unzip01.sh
+module_src_files := testcases/commands/unzip/unzip01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/icmp6-multi-diffip04
 module_src_files := testcases/network/stress/icmp/multi-diffip/icmp6-multi-diffip04
 include $(ltp_build_prebuilt)
@@ -2245,6 +2261,10 @@
 module_src_files := testcases/commands/tpm-tools/tpm/tpm_selftest/tpm_selftest_tests.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/dynamic_debug01.sh
+module_src_files := testcases/kernel/tracing/dynamic_debug/dynamic_debug01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/memcg_memsw_limit_in_bytes_test.sh
 module_src_files := testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh
 include $(ltp_build_prebuilt)
@@ -2389,6 +2409,10 @@
 module_src_files := testcases/network/stress/tcp/uni-pktlossdup/tcp6-uni-pktlossdup01
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp_ipsec_vti.sh
+module_src_files := testcases/network/stress/tcp/tcp_ipsec_vti.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/mcast6-queryfld05
 module_src_files := testcases/network/stress/multicast/query-flood/mcast6-queryfld05
 include $(ltp_build_prebuilt)
@@ -2441,8 +2465,8 @@
 module_src_files := testcases/kernel/controllers/freezer/freeze_cancel.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/route4-redirect
-module_src_files := testcases/network/stress/route/route4-redirect
+module_prebuilt := testcases/bin/mcast-group-same-group
+module_src_files := testcases/network/stress/multicast/grp-operation/mcast-group-same-group
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/route6-change-gw
@@ -2841,10 +2865,6 @@
 module_src_files := testcases/network/stress/route/route4-rmmod
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-multi-diffport14
-module_src_files := testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport14
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/ipvlan01.sh
 module_src_files := testcases/network/virt/ipvlan01.sh
 include $(ltp_build_prebuilt)
@@ -2969,8 +2989,8 @@
 module_src_files := testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffip04
-module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip04
+module_prebuilt := testcases/bin/dccp01.sh
+module_src_files := testcases/network/dccp/dccp01.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/pm_sched_mc.py
@@ -3009,18 +3029,14 @@
 module_src_files := testcases/network/stress/interface/if-route-addlarge
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffnic03
-module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic03
+module_prebuilt := testcases/bin/gdb01.sh
+module_src_files := testcases/commands/gdb/gdb01.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/udp6-multi-diffport05
 module_src_files := testcases/network/stress/udp/multi-diffport/udp6-multi-diffport05
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffnic02
-module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic02
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/tcp4-uni-dsackoff11
 module_src_files := testcases/network/stress/tcp/uni-dsackoff/tcp4-uni-dsackoff11
 include $(ltp_build_prebuilt)
@@ -3205,6 +3221,10 @@
 module_src_files := testcases/network/stress/tcp/uni-basic/tcp4-uni-basic08
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/mcast-group-single-socket
+module_src_files := testcases/network/stress/multicast/grp-operation/mcast-group-single-socket
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-multi-sameport11
 module_src_files := testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport11
 include $(ltp_build_prebuilt)
@@ -3245,10 +3265,6 @@
 module_src_files := testcases/kernel/power_management/pm_cpu_consolidation.py
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-winscale01
-module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale01
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/check_netem
 module_src_files := testcases/network/stress/ns-tools/check_netem
 include $(ltp_build_prebuilt)
@@ -3361,6 +3377,10 @@
 module_src_files := testcases/kernel/sched/hyperthreading/ht_affinity/smt_smp_affinity.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/mcast-group-multiple-socket
+module_src_files := testcases/network/stress/multicast/grp-operation/mcast-group-multiple-socket
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-uni-winscale06
 module_src_files := testcases/network/stress/tcp/uni-winscale/tcp4-uni-winscale06
 include $(ltp_build_prebuilt)
@@ -3373,10 +3393,6 @@
 module_src_files := testcases/kernel/security/integrity/ima/tests/ima_policy.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/mcast6-grpope04
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast6-grpope04
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/parameters.sh
 module_src_files := testcases/kernel/controllers/cpuctl/parameters.sh
 include $(ltp_build_prebuilt)
@@ -3389,8 +3405,8 @@
 module_src_files := testcases/commands/ar/datafiles/file1.in
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-sameport08
-module_src_files := testcases/network/stress/tcp/multi-sameport/tcp6-multi-sameport08
+module_prebuilt := testcases/bin/broken_ip6-version
+module_src_files := testcases/network/stress/broken_ip/broken_ip6-version
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/data/file01/in.tar
@@ -3477,20 +3493,20 @@
 module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale05
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/mcast4-grpope03
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast4-grpope03
+module_prebuilt := testcases/bin/tcp6-uni-winscale06
+module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale06
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/mcast4-grpope02
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast4-grpope02
+module_prebuilt := testcases/bin/tcp6-uni-winscale07
+module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale07
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp4-multi-diffport10
 module_src_files := testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport10
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/mcast4-grpope04
-module_src_files := testcases/network/stress/multicast/grp-operation/mcast4-grpope04
+module_prebuilt := testcases/bin/tcp4-multi-diffport11
+module_src_files := testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport11
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/fs_bind/bin/check_prop
@@ -3529,8 +3545,8 @@
 module_src_files := testcases/network/multicast/mc_opts/mc_opts
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/broken_ip6-version
-module_src_files := testcases/network/stress/broken_ip/broken_ip6-version
+module_prebuilt := testcases/bin/vma05.sh
+module_src_files := testcases/kernel/mem/vma/vma05.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp4-uni-pktlossdup07
@@ -3625,6 +3641,10 @@
 module_src_files := testcases/network/tcp_cmds/ping/ping01.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp4-uni-tso12
+module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso12
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/broken_ip4-ihl
 module_src_files := testcases/network/stress/broken_ip/broken_ip4-ihl
 include $(ltp_build_prebuilt)
@@ -3705,8 +3725,8 @@
 module_src_files := testcases/commands/tpm-tools/tpm/tpm_changeauth/tpm_changeauth_tests.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/if-lib.sh
-module_src_files := testcases/network/stress/interface/if-lib.sh
+module_prebuilt := testcases/bin/tcp6-multi-diffnic02
+module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic02
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/modaltr.sh
@@ -3817,8 +3837,8 @@
 module_src_files := testcases/network/stress/interface/if-addr-addlarge
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-sackoff06
-module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp6-uni-sackoff06
+module_prebuilt := testcases/bin/tcp4-uni-winscale08
+module_src_files := testcases/network/stress/tcp/uni-winscale/tcp4-uni-winscale08
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp4-uni-winscale09
diff --git a/android/include/config.h b/android/include/config.h
index 32e339d..c23c805 100644
--- a/android/include/config.h
+++ b/android/include/config.h
@@ -132,7 +132,7 @@
 /* #undef HAVE_LIBACL */
 
 /* Define to 1 if you have the <libaio.h> header file. */
-#define HAVE_LIBAIO_H 1
+/* undef HAVE_LIBAIO_H */
 
 /* Define to 1 if you have libcap-2 installed. */
 #define HAVE_LIBCAP 1
@@ -281,6 +281,9 @@
 /* Define to 1 if the system has the type `struct iovec'. */
 #define HAVE_STRUCT_IOVEC 1
 
+/* Define to 1 if the system has the type `struct mmsghdr'. */
+#define HAVE_STRUCT_MMSGHDR 1
+
 /* Define to 1 if the system has the type `struct modify_ldt_ldt_s'. */
 /* #undef HAVE_STRUCT_MODIFY_LDT_LDT_S */
 
@@ -318,6 +321,15 @@
 /* Define to 1 if the system has the type `struct user_regs_struct'. */
 #define HAVE_STRUCT_USER_REGS_STRUCT 1
 
+/* Define to 1 if `domainname' is a member of `struct utsname'. */
+#define HAVE_STRUCT_UTSNAME_DOMAINNAME 1
+
+/* Define to 1 if the system has the type `struct xt_entry_match'. */
+#define HAVE_STRUCT_XT_ENTRY_MATCH 1
+
+/* Define to 1 if the system has the type `struct xt_entry_target'. */
+#define HAVE_STRUCT_XT_ENTRY_TARGET 1
+
 /* Define to 1 if you have __sync_add_and_fetch */
 #define HAVE_SYNC_ADD_AND_FETCH 1
 
diff --git a/android/ltp_package_list.mk b/android/ltp_package_list.mk
index 1dbd3fd..70b81e2 100644
--- a/android/ltp_package_list.mk
+++ b/android/ltp_package_list.mk
@@ -39,6 +39,7 @@
   ltp_asapi_02 \
   ltp_asapi_03 \
   ltp_asyncio02 \
+  ltp_autogroup01 \
   ltp_bdflush01 \
   ltp_bind01 \
   ltp_bind02 \
@@ -77,6 +78,7 @@
   ltp_clock_gettime02 \
   ltp_clock_gettime03 \
   ltp_clock_nanosleep01 \
+  ltp_clock_nanosleep02 \
   ltp_clock_nanosleep2_01 \
   ltp_clock_settime02 \
   ltp_clock_settime03 \
@@ -88,10 +90,12 @@
   ltp_clone06 \
   ltp_clone07 \
   ltp_clone08 \
+  ltp_clone09 \
   ltp_close01 \
   ltp_close02 \
   ltp_close08 \
   ltp_connect01 \
+  ltp_copy_file_range01 \
   ltp_cpuacct_task \
   ltp_cpuctl_def_task01 \
   ltp_cpuctl_def_task02 \
@@ -121,6 +125,16 @@
   ltp_create_long_dirs \
   ltp_create_short_dirs \
   ltp_createfile \
+  ltp_cve-2012-0957 \
+  ltp_cve-2014-0196 \
+  ltp_cve-2016-10044 \
+  ltp_cve-2016-4997 \
+  ltp_cve-2016-7042 \
+  ltp_cve-2016-7117 \
+  ltp_cve-2017-2618 \
+  ltp_cve-2017-2671 \
+  ltp_cve-2017-5669 \
+  ltp_cve-2017-6951 \
   ltp_data_space \
   ltp_delete_module01 \
   ltp_delete_module02 \
@@ -201,6 +215,8 @@
   ltp_fanotify04 \
   ltp_fanotify05 \
   ltp_fanotify06 \
+  ltp_fanotify07 \
+  ltp_fanotify08 \
   ltp_fchdir01 \
   ltp_fchdir02 \
   ltp_fchdir03 \
@@ -282,6 +298,10 @@
   ltp_fcntl33_64 \
   ltp_fcntl34 \
   ltp_fcntl34_64 \
+  ltp_fcntl35 \
+  ltp_fcntl35_64 \
+  ltp_fcntl36 \
+  ltp_fcntl36_64 \
   ltp_fdatasync01 \
   ltp_fdatasync02 \
   ltp_flistxattr01 \
@@ -446,6 +466,7 @@
   ltp_getsid02 \
   ltp_getsockname01 \
   ltp_getsockopt01 \
+  ltp_getsockopt02 \
   ltp_gettid01 \
   ltp_gettimeofday01 \
   ltp_gettimeofday02 \
@@ -501,6 +522,8 @@
   ltp_keyctl01 \
   ltp_keyctl02 \
   ltp_keyctl03 \
+  ltp_keyctl04 \
+  ltp_keyctl05 \
   ltp_kill01 \
   ltp_kill02 \
   ltp_kill03 \
@@ -540,14 +563,7 @@
   ltp_locktests \
   ltp_lseek01 \
   ltp_lseek02 \
-  ltp_lseek03 \
-  ltp_lseek04 \
-  ltp_lseek05 \
-  ltp_lseek06 \
   ltp_lseek07 \
-  ltp_lseek08 \
-  ltp_lseek09 \
-  ltp_lseek10 \
   ltp_lseek11 \
   ltp_lstat01 \
   ltp_lstat01_64 \
@@ -579,6 +595,7 @@
   ltp_memcg_process_stress \
   ltp_memcg_test_1 \
   ltp_memcg_test_2 \
+  ltp_memcg_test_3 \
   ltp_memcg_test_4 \
   ltp_memcmp01 \
   ltp_memcpy01 \
@@ -684,6 +701,7 @@
   ltp_msync01 \
   ltp_msync02 \
   ltp_msync03 \
+  ltp_msync04 \
   ltp_mtest01 \
   ltp_munlock01 \
   ltp_munlock02 \
@@ -1019,7 +1037,10 @@
   ltp_splice01 \
   ltp_splice02 \
   ltp_splice03 \
+  ltp_splice04 \
+  ltp_splice05 \
   ltp_ssetmask01 \
+  ltp_stack_clash \
   ltp_stack_space \
   ltp_stat01 \
   ltp_stat01_64 \
@@ -1104,7 +1125,6 @@
   ltp_testcases_bin_assign_password.sh \
   ltp_testcases_bin_at_allow01 \
   ltp_testcases_bin_at_deny01 \
-  ltp_testcases_bin_bg_tcp_traffic \
   ltp_testcases_bin_broken_ip4-checksum \
   ltp_testcases_bin_broken_ip4-dstaddr \
   ltp_testcases_bin_broken_ip4-fragment \
@@ -1165,6 +1185,7 @@
   ltp_testcases_bin_create_file \
   ltp_testcases_bin_daemonlib.sh \
   ltp_testcases_bin_data \
+  ltp_testcases_bin_dccp01.sh \
   ltp_testcases_bin_dctcp01.sh \
   ltp_testcases_bin_df01.sh \
   ltp_testcases_bin_dhcp_lib.sh \
@@ -1175,6 +1196,7 @@
   ltp_testcases_bin_dns-stress02-rmt \
   ltp_testcases_bin_dnsmasq_tests.sh \
   ltp_testcases_bin_du01.sh \
+  ltp_testcases_bin_dynamic_debug01.sh \
   ltp_testcases_bin_echo01 \
   ltp_testcases_bin_eject-tests.sh \
   ltp_testcases_bin_ext4-alloc-test.sh \
@@ -1187,6 +1209,7 @@
   ltp_testcases_bin_ext4_persist_prealloc_test.sh \
   ltp_testcases_bin_ext4_subdir_limit_test.sh \
   ltp_testcases_bin_ext4_uninit_groups_test.sh \
+  ltp_testcases_bin_file01.sh \
   ltp_testcases_bin_filecapstest.sh \
   ltp_testcases_bin_find_portbundle \
   ltp_testcases_bin_finger01 \
@@ -1352,6 +1375,7 @@
   ltp_testcases_bin_ftrace_stress_ftrace_tracing_max_latency.sh \
   ltp_testcases_bin_ftrace_stress_ftrace_tracing_on.sh \
   ltp_testcases_bin_ftrace_stress_test.sh \
+  ltp_testcases_bin_gdb01.sh \
   ltp_testcases_bin_geneve01.sh \
   ltp_testcases_bin_get_ifname \
   ltp_testcases_bin_gre01.sh \
@@ -1392,7 +1416,6 @@
   ltp_testcases_bin_icmp6-multi-diffnic07 \
   ltp_testcases_bin_if-addr-adddel \
   ltp_testcases_bin_if-addr-addlarge \
-  ltp_testcases_bin_if-lib.sh \
   ltp_testcases_bin_if-mtu-change \
   ltp_testcases_bin_if-route-adddel \
   ltp_testcases_bin_if-route-addlarge \
@@ -1427,10 +1450,11 @@
   ltp_testcases_bin_mc_commo \
   ltp_testcases_bin_mc_member \
   ltp_testcases_bin_mc_opts \
-  ltp_testcases_bin_mcast4-grpope01 \
-  ltp_testcases_bin_mcast4-grpope02 \
-  ltp_testcases_bin_mcast4-grpope03 \
-  ltp_testcases_bin_mcast4-grpope04 \
+  ltp_testcases_bin_mcast-group-multiple-socket \
+  ltp_testcases_bin_mcast-group-same-group \
+  ltp_testcases_bin_mcast-group-single-socket \
+  ltp_testcases_bin_mcast-group-source-filter \
+  ltp_testcases_bin_mcast-lib.sh \
   ltp_testcases_bin_mcast4-pktfld01 \
   ltp_testcases_bin_mcast4-pktfld02 \
   ltp_testcases_bin_mcast4-queryfld01 \
@@ -1439,10 +1463,6 @@
   ltp_testcases_bin_mcast4-queryfld04 \
   ltp_testcases_bin_mcast4-queryfld05 \
   ltp_testcases_bin_mcast4-queryfld06 \
-  ltp_testcases_bin_mcast6-grpope01 \
-  ltp_testcases_bin_mcast6-grpope02 \
-  ltp_testcases_bin_mcast6-grpope03 \
-  ltp_testcases_bin_mcast6-grpope04 \
   ltp_testcases_bin_mcast6-pktfld01 \
   ltp_testcases_bin_mcast6-pktfld02 \
   ltp_testcases_bin_mcast6-queryfld01 \
@@ -1544,6 +1564,7 @@
   ltp_testcases_bin_rwho01 \
   ltp_testcases_bin_rwtest \
   ltp_testcases_bin_sched_stress.sh \
+  ltp_testcases_bin_sctp01.sh \
   ltp_testcases_bin_sendfile01 \
   ltp_testcases_bin_set_ipv4addr \
   ltp_testcases_bin_smack_common.sh \
@@ -1882,6 +1903,7 @@
   ltp_testcases_bin_tcp6-uni-winscale14 \
   ltp_testcases_bin_tcp_fastopen_run.sh \
   ltp_testcases_bin_tcp_ipsec.sh \
+  ltp_testcases_bin_tcp_ipsec_vti.sh \
   ltp_testcases_bin_tcpdump01 \
   ltp_testcases_bin_telnet01 \
   ltp_testcases_bin_test.sh \
@@ -1895,6 +1917,7 @@
   ltp_testcases_bin_test_controllers.sh \
   ltp_testcases_bin_test_ioctl \
   ltp_testcases_bin_test_net.sh \
+  ltp_testcases_bin_test_net_stress.sh \
   ltp_testcases_bin_test_robind.sh \
   ltp_testcases_bin_testall.sh \
   ltp_testcases_bin_tpm_changeauth_tests.sh \
@@ -1998,12 +2021,15 @@
   ltp_testcases_bin_udp6-uni-basic06 \
   ltp_testcases_bin_udp6-uni-basic07 \
   ltp_testcases_bin_udp_ipsec.sh \
+  ltp_testcases_bin_udp_ipsec_vti.sh \
+  ltp_testcases_bin_unzip01.sh \
   ltp_testcases_bin_utimensat_tests.sh \
   ltp_testcases_bin_vfork_freeze.sh \
   ltp_testcases_bin_virt_lib.sh \
   ltp_testcases_bin_vlan01.sh \
   ltp_testcases_bin_vlan02.sh \
   ltp_testcases_bin_vlan03.sh \
+  ltp_testcases_bin_vma05.sh \
   ltp_testcases_bin_vxlan01.sh \
   ltp_testcases_bin_vxlan02.sh \
   ltp_testcases_bin_vxlan03.sh \
@@ -2127,6 +2153,9 @@
   ltp_tst_ncpus \
   ltp_tst_ncpus_conf \
   ltp_tst_ncpus_max \
+  ltp_tst_net_iface_prefix \
+  ltp_tst_net_ip_prefix \
+  ltp_tst_net_vars \
   ltp_tst_process_state \
   ltp_tst_random \
   ltp_tst_record_childstatus \
@@ -2173,6 +2202,7 @@
   ltp_vma02 \
   ltp_vma03 \
   ltp_vma04 \
+  ltp_vma05_vdso \
   ltp_vmsplice01 \
   ltp_vmsplice02 \
   ltp_wait01 \
@@ -2195,7 +2225,6 @@
   ltp_waitpid12 \
   ltp_waitpid13 \
   ltp_write01 \
-  ltp_write02 \
   ltp_write03 \
   ltp_write04 \
   ltp_write05 \
@@ -2205,4 +2234,4 @@
   ltp_writev05 \
   ltp_writev06 \
   ltp_writev07 \
-  ltp_zram03
+  ltp_zram03
\ No newline at end of file
diff --git a/android/tools/custom_cflags.json b/android/tools/custom_cflags.json
index 64d085e..34cd799 100644
--- a/android/tools/custom_cflags.json
+++ b/android/tools/custom_cflags.json
@@ -1,3 +1,4 @@
 {
-  "testcases/kernel/syscalls/getcwd/getcwd02": ["-U_FORTIFY_SOURCE"]
+  "testcases/kernel/syscalls/getcwd/getcwd02": ["-U_FORTIFY_SOURCE"],
+  "testcases/cve/stack_clash": ["-Wno-infinite-recursion"]
 }
diff --git a/configure.ac b/configure.ac
index ecc9a26..458a5b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,7 +31,6 @@
 AC_PREFIX_DEFAULT(/opt/ltp)
 
 AC_CHECK_HEADERS([ \
-    dmapi.h \
     ifaddrs.h \
     libaio.h \
     mm.h \
@@ -44,7 +43,6 @@
     sys/epoll.h \
     sys/inotify.h \
     sys/fanotify.h \
-    sys/jfsdmapi.h \
     sys/prctl.h \
 ])
 
@@ -132,6 +130,8 @@
 
 AC_CONFIG_SUBDIRS([utils/ffsb-6.0-rc2])
 
+AC_CONFIG_COMMANDS([syscalls.h], [cd include/lapi/syscalls; ./regen.sh])
+
 # END testsuites knobs
 LTP_CHECK_FORTIFY_SOURCE
 LTP_CHECK_CC_WARN_OLDSTYLE
@@ -189,5 +189,8 @@
 LTP_CHECK_KEYUTILS_SUPPORT
 LTP_CHECK_SYNC_ADD_AND_FETCH
 LTP_CHECK_BUILTIN_CLEAR_CACHE
+LTP_CHECK_MMSGHDR
+LTP_CHECK_UNAME_DOMAINNAME
+LTP_CHECK_X_TABLES
 
 AC_OUTPUT
diff --git a/doc/c-test-tutorial-simple.txt b/doc/c-test-tutorial-simple.txt
new file mode 100644
index 0000000..61cfd10
--- /dev/null
+++ b/doc/c-test-tutorial-simple.txt
@@ -0,0 +1,1096 @@
+C Test Case Tutorial
+====================
+
+This is a step-by-step tutorial on writing a simple C LTP test, where topics
+of the LTP and Linux kernel testing will be introduced gradually using a
+concrete example. Most sections will include exercises, some trivial and
+others not so much. If you find an exercise is leading you off at too much of
+a tangent, just leave it for later and move on.
+
+LTP tests can be written in C or Shell script. This tutorial is only for tests
+written in C using the new LTP test API. Note that while we go into some
+detail on using Git, this is not intended as a canonical or complete guide
+for Git.
+
+0. Assumptions & Feedback
+-------------------------
+
+We assume the reader is familiar with C, Git and common Unix/Linux/GNU tools
+and has some general knowledge of Operating Systems. Experienced Linux
+developers may find it too verbose while people new to system level Linux
+development may find it overwhelming.
+
+Comments and feedback are welcome, please direct them to the mailing list (see
++README+).
+
+1. Getting Started
+------------------
+
+Git-clone the main LTP repository as described in the +README+ and change
+directory to the checked-out Git repository. We recommend installing the LTP
+and running one of the tests mentioned in the Quick guide (in the +README+) to
+ensure you are starting from a good state.
+
+We also recommended cloning the Linux kernel repository for reference, this
+guide will refer to files and directories within the mainline kernel 4.12.
+
+[source,shell]
+------------------------------------------------------------------------------
+$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
+------------------------------------------------------------------------------
+
+There are a number of other repositories which are useful for reference as
+well, including the GNU C library +glibc+ and the alternative C library
++musl+. Some system calls are partially or even entirely implemented in user
+land as part of the standard C library. So in these cases, the C library is an
+important reference. +glibc+ is the most common C library for Linux, however
++musl+ is generally easier to understand.
+
+How system calls are implemented varies from one architecture to another and
+across kernel and C library versions. To find out whether a system call is
+actually accessing the kernel (whether it is actually a system call) on any
+given machine you can use the +strace+ utility. This intercepts system calls
+made by an executable and prints them. We will use this later in the tutorial.
+
+2. Choose a System Call to test
+-------------------------------
+
+We will use the +statx()+ system call, to provide a concrete example of a
+test. At the time of writing there is no test for this call which was
+introduced in Linux kernel version 4.11.
+
+Linux system call specific tests are primarily contained in
++testcases/kernel/syscalls+, but you should also +git grep+ the entire LTP
+repository to check for any existing usages of a system call.
+
+One way to find a system call which is not currently tested by the LTP is to
+look at +include/linux/syscalls.h+ in the kernel tree.
+
+Something the LTP excels at is ensuring bug-fixes are back ported to
+maintenance releases, so targeting a specific regression is another
+option.
+
+2.1. Find an untested System call
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Try to find an untested system call which has a manual page (i.e. +man
+syscall+ produces a result). It is a good idea to Git-clone the latest kernel
+man-pages repository.
+
+[source,shell]
+------------------------------------------------------------------------------
+$ git clone git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
+------------------------------------------------------------------------------
+
+At the time of writing the difference between the latest man-pages release and
+the +HEAD+ of the repository (usually the latest commit) is well over 100
+commits. This represents about 9 weeks of changes. If you are using a stable
+Linux distribution, your man-pages package may well be years old. So as with
+the kernel, it is best to have the Git repository as a reference.
+
+You could also find a system call with untested parameters or use whatever it
+is you are planning to use the LTP for.
+
+3. Create the test skeleton
+---------------------------
+
+I shall call my test +statx01.c+, by the time you read this that file name
+will probably be taken, so increment the number in the file name as
+appropriate or replace +statx+ with the system call chosen in exercise 2.1.
+
+[source,shell]
+------------------------------------------------------------------------------
+$ mkdir testcases/kernel/syscalls/statx
+$ cd testcases/kernel/syscalls/statx
+$ echo statx >> .gitignore
+------------------------------------------------------------------------------
+
+Next open +statx01.c+ and add the following boilerplate. Make sure to change
+the copy right notice to your name/company, correct the test name and minimum
+kernel version if necessary. I will explain what the code does below.
+
+[source,c]
+------------------------------------------------------------------------------
+/*
+ * Copyright (c) 2017 Instruction Ignorer <"can't"@be.bothered.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Test statx
+ *
+ * All tests should start with a description of _what_ we are testing.
+ * Non-trivial explanations of _how_ the code works should also go here.
+ * Include relevant links, Git commit hashes and CVE numbers.
+ * Inline comments should be avoided.
+ */
+
+#include "tst_test.h"
+
+static void run(void)
+{
+	tst_res(TPASS, "Doing hardly anything is easy");
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.min_kver = "4.11",
+};
+------------------------------------------------------------------------------
+
+Starting with the +#include+ statement we copy in the main LTP test library
+headers. This includes the most common test API functions and the test harness
+initialisation code. It is important to note that this is a completely
+ordinary, independent C program, however +main()+ is missing because it is
+implemented in +tst_test.h+.
+
+We specify what code we want to run as part of the test using the +tst_test
+test+ structure. Various callbacks can be set by the test writer, including
++test.test_all+, which we have set to +run()+. The test harness will execute
+this callback in a separate process (using +fork()+), forcibly terminating it
+if it does not return after +test.timeout+ seconds.
+
+We have also set +test.min_kver+ to the kernel version where +statx+ was
+introduced. The test library will determine the kernel version at runtime. If
+the version is less than 4.11 then the test harness will return +TCONF+,
+indicating that this test is not suitable for the current system
+configuration.
+
+Occasionally features are back ported to older kernel versions, so +statx+ may
+exist on kernels with a lower version. However we don't need to worry about
+that unless there is evidence of it happening.
+
+As mentioned in the code itself, you should specify what you are testing and
+the expected outcome, even if it is relatively simple. If your program flow is
+necessarily complex and difficult to understand (which is often the case when
+trying to manipulate the kernel into doing something bad), then a detailed
+explanation of how the code works is welcome.
+
+What you should not do, is use inline comments or include the same level of
+explanation which is written here. As a general rule, if something is easy to
+document, then the code should also be easy to read. So don't document the easy
+stuff (except for the basic test specification).
+
+Before continuing we should compile this and check that the basics work. In
+order to compile the test we need a +Makefile+ in the same subdirectory. If
+one already exists, then nothing needs to be done, otherwise add one with the
+following contents.
+
+[source,make]
+------------------------------------------------------------------------------
+# Copyright (c) 2017 Linux Test Project
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+------------------------------------------------------------------------------
+
+This will automatically add +statx01.c+ as a build target producing a
++statx01+ executable. Unless you have heavily deviated from the tutorial, and
+probably need to change +top_srcdir+, nothing else needs to be done.
+
+Normally, if you were starting a Makefile from scratch, then you would need to
+add +statx01+ as a build target. Specifying that you would like to run some
+program (e.g. +gcc+ or +clang+) to transform +statx01.c+ into +statx01+. Here
+we don't need to do that, but sometimes it is still necessary. For example, if
+we needed to link to the POSIX threading library, then we could add the
+following line after +testcases.mk+.
+
+[source,make]
+--------------------------------------------------------------------------------
+statx01: CFLAGS += -pthread
+--------------------------------------------------------------------------------
+
+Assuming you are in the test's subdirectory +testcases/kernel/syscalls/statx+,
+do
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ make
+$ ./statx01
+--------------------------------------------------------------------------------
+
+This should build the test and then run it. However, even though the test is
+in the +syscalls+ directory it won't be automatically ran as part of the
+_syscalls_ test group (remember +./runltp -f syscalls+ from the +README+?). For
+this we need to add it to the +runtest+ file. So open +runtest/statx+ and add
+the lines starting with a +++.
+
+[source,diff]
+--------------------------------------------------------------------------------
+ statvfs01 statvfs01
+ statvfs02 statvfs02
+ 
++statx01 statx01
++
+ stime01 stime01
+ stime02 stime02
+ 
+--------------------------------------------------------------------------------
+
+The +runtest+ files are in a two column format. The first column is the test
+name, which is mainly used by test runners for reporting and filtering. It is
+just a single string of text with no spaces. The second column, which can
+contain spaces, is passed to the shell in order to execute the test. Often it
+is just the executable name, but some tests also take arguments (the LTP has a
+library for argument parsing, by the way).
+
+If you haven't done so already, we should add all these new files to Git. It
+is vitally important that you do not make changes to the master branch. If you
+do then pulling changes from upstream becomes a major issue. So first of all
+create a new branch.
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ git checkout -b statx01 master
+--------------------------------------------------------------------------------
+
+Now we want to add the files we have created or modified, but before doing a
+commit make sure you have configured Git correctly. You need to at least set
+your Name and e-mail address in +~/.gitconfig+, but there are some other
+settings which come in handy too. My relatively simple configuration is similar to
+the below
+
+[source,conf]
+--------------------------------------------------------------------------------
+[user]
+	name = Sarah Jane
+	email = sjane@e-mail.address
+[core]
+	editor = emacs
+[sendemail]
+	smtpServer = smtp.server.address
+--------------------------------------------------------------------------------
+
+Obviously you need to at least change your name and e-mail. The SMTP server is
+useful for +git send-mail+, which we will discuss later. The editor value is
+used for things like writing commits (without the +-m+ option).
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ git add -v :/testcases/kernel/syscalls/statx :/runtest/syscalls
+$ git commit -m "statx01: Add new test for statx syscall"
+--------------------------------------------------------------------------------
+
+This should add all the new files in the +statx+ directory and the +runtest+
+file. It is good practice to commit early and often. Later on we will do a
+Git-rebase, which allows us to clean up the commit history. So don't worry
+about how presentable your commit log is for now. Also don't hesitate to
+create a new branch when doing the exercises or experimenting. This will allow
+you to diverge from the tutorial and then easily come back again.
+
+I can't emphasize enough that Git makes things easy through branching and that
+things quickly get complicated if you don't do it. However if you do get into
+a mess, Git-reflog and Git-reset, will usually get you out of it. If you also
+mess that up then it may be possible to cherry pick 'dangling' commits out of
+the database into a branch.
+
+3.1 Report TCONF instead of TPASS
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Maybe the test should report "TCONF: Not implemented" instead or perhaps
++TBROK+. Try changing it do so (see +doc/test-writing-guidelines.txt+ or
+https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines[the
+Wiki]).
+
+3.2 Check Git ignores the executable
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Is your +.gitignore+ correct?
+
+3.3 Run checkpatch.pl on the source file
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The LTP follows the Linux style guidelines where possible. Check what happens
+if you run +kernel/linux/scripts/checkpatch.pl --no-tree -f statx01.c+ and
+correct any style issues.
+
+3.4 Install the LTP and run the test with runtest
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Run +statx01+ on its own; similar to the +madvise+ tests in the +README+.
+
+4. Call the system call
+-----------------------
+
+At the time of writing +statx+ has no +glibc+ wrapper. It is also fairly common
+for a distribution's C library version to be older than its kernel or it may use a
+cut down C library in comparison to the GNU one. So we must call +statx()+
+using the general +syscall()+ interface.
+
+The LTP contains a library for dealing with the +syscall+ interface, which is
+located in +include/lapi+. System call numbers are listed against the relevant
+call in the +*.in+ files (e.g. +x86_64.in+) which are used to generate
++syscalls.h+, which is the header you should include. On rare occasions you
+may find the system call number is missing from the +*.in+ files and will need
+to add it (see include/lapi/syscall/strip_syscall.awk).
+
+System call numbers vary between architectures, hence why there are multiple
++*.in+ files for each architecture. You can find the various values for the
++statx+ system call across a number of +uinstd.h+ files in the Linux kernel.
+
+Note that we don't use the system-call-identifier value available in
++/usr/include/linux/uinstd.h+ because the kernel might be much newer than the
+user land development packages.
+
+For +statx+ we had to add +statx 332+ to +testcases/kernel/include/x86_64.in+,
++statx 383+ to +testcases/kernel/include/powerpc.in+, etc.  Now lets look at
+the code, which I will explain in more detail further down.
+
+[source,c]
+--------------------------------------------------------------------------------
+/*
+ * Test statx
+ *
+ * Check if statx exists and what error code it returns when we give it dodgy
+ * data.
+ */
+
+#include <stdint.h>
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+
+struct statx_timestamp {
+	int64_t	       tv_sec;
+	uint32_t       tv_nsec;
+	int32_t	       __reserved;
+};
+
+struct statx {
+	uint32_t	stx_mask;
+	uint32_t	stx_blksize;
+	uint64_t	stx_attributes;
+	uint32_t	stx_nlink;
+	uint32_t	stx_uid;
+	uint32_t	stx_gid;
+	uint16_t	stx_mode;
+	uint16_t	__spare0[1];
+	uint64_t	stx_ino;
+	uint64_t	stx_size;
+	uint64_t	stx_blocks;
+	uint64_t	stx_attributes_mask;
+	struct statx_timestamp	stx_atime;
+	struct statx_timestamp	stx_btime;
+	struct statx_timestamp	stx_ctime;
+	struct statx_timestamp	stx_mtime;
+	uint32_t	stx_rdev_major;
+	uint32_t	stx_rdev_minor;
+	uint32_t	stx_dev_major;
+	uint32_t	stx_dev_minor;
+	uint64_t	__spare2[14];
+};
+
+static int sys_statx(int dirfd, const char *pathname, int flags,
+		     unsigned int mask, struct statx *statxbuf)
+{
+	return tst_syscall(__NR_statx, dirfd, pathname, flags, mask, statxbuf);
+}
+
+...
+--------------------------------------------------------------------------------
+
+So the top part of the code is now boiler plate for calling +statx+. It is
+common for the kernel to be newer than the user land libraries and headers. So
+for new system calls like +statx+, we copy, with a few modifications, the
+relevant definitions into the LTP. This is somewhat like 'vendoring', although
+we are usually just copying headers required for interacting with the Kernel's
+ABI (Application Binary Interface), rather than internalising actual
+functionality.
+
+So from the top we include the +stdint.h+ library which gives us the standard
++(u)int*_t+ type definitions. We use these in place of the Kernel type
+definitions such as +__u64+ in +linux/types.h+. We then have a couple of
+structure definitions which form part of the +statx+ API. These were copied
+from +include/uapi/linux/stat.h+ in the Kernel tree.
+
+After that, there is a wrapper function, which saves us from writing
++tst_syscall(__NR_statx, ...+, every time we want to make a call to
++statx+. This also provides a stub for when +statx+ is eventually integrated
+into the LTP library and also implemented by the C library. At that point we
+can switch to using the C library implementation if available or fallback to
+our own.
+
+The advantage of using the C library implementation is that it will often be
+better supported across multiple architectures. It will also mean we are using
+the system call in the same way most real programs would. Sometimes there are
+advantages to bypassing the C library, but in general it should not be our
+first choice.
+
+The final test should do a check during configuration (i.e. when we run
++./configure+ before building) which checks if the +statx+ system call and
+associated structures exists. This requires writing an +m4+ file for use with
++configure.ac+ which is processed during +make autotools+ and produces the
+configure script.
+
+For the time being though we shall just ignore this. All you need to know for
+now is that this is a problem which eventually needs to be dealt with and that
+there is a system in place to handle it.
+
+[source,c]
+--------------------------------------------------------------------------------
+...
+
+static void run(void)
+{
+	struct statx statxbuf = { 0 };
+
+	TEST(sys_statx(0, NULL, 0, 0, &statxbuf));
+
+	if (TEST_RETURN == 0)
+		tst_res(TFAIL, "statx thinks it can stat NULL");
+	else if (TEST_ERRNO == EFAULT)
+		tst_res(TPASS, "statx set errno to EFAULT as expected");
+	else
+		tst_res(TFAIL | TERRNO, "statx set errno to some unexpected value");
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.min_kver = "4.11",
+};
+--------------------------------------------------------------------------------
+
+The +TEST+ macro sets +TEST_RETURN+ to the return value of +tst_statx()+ and
++TEST_ERRNO+ to the value of +errno+ immediately after the functions
+return. This is mainly just for convenience, although it potentially could
+have other uses.
+
+We check whether the return value indicates success and if it doesn't also
+check the value of +errno+. The last call to +tst_res+ includes +TERRNO+,
+which will print the current error number and associated description in
+addition to the message we have provided. Note that it uses the current value
+of +errno+ not +TEST_ERRNO+.
+
+What we should have done in the example above is use +TTERRNO+ which takes the
+value of +TEST_ERRNO+.
+
+If we try to run the test on a kernel where +statx+ does not exist, then
++tst_syscall+ will cause it to fail gracefully with +TCONF+. Where +TCONF+
+indicates the test is not applicable to our configuration.
+
+The function +tst_syscall+ calls +tst_brk(TCONF,...)+ on failure. +tst_brk+
+causes the test to exit immediately, which prevents any further test code from
+being run.
+
+4.1 What are the differences between tst_brk and tst_res?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+See +include/tst_test.h+ and the
+https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines[test
+writing guide]. Also what do they have in common?
+
+4.2 What happens if you call tst_res(TINFO, ...) after sys_statx?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Does the test still function correctly?
+
+4.3 Extend the test to handle other basic error conditions.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For example, see if you can trigger +ENOENT+ instead. You shouldn't
+have to create any files, which is discussed in the next section.
+
+5. Setup, Cleanup and files
+---------------------------
+
+Some tests require resources to be allocated, or system settings to be
+changed, before the test begins. This 'setup' only has to be done once at the
+beginning and at the end of the test needs to be removed or reverted. The
+'cleanup' also has to be done regardless of whether the test breaks.
+
+Fortunately, like most test libraries, we have setup and cleanup (teardown)
+callbacks. +setup+ is called once before +run+ and +cleanup+ is called once
+afterwards. Note that +run+ itself can be called multiple times by the test
+harness, but that +setup+ and +cleanup+ are only called once.
+
+If either your code, a +SAFE_*+ macro or a library function such as
++tst_syscall+ call +tst_brk+, then +run+ will exit immediately and the
++cleanup+ function is then called. Once 'cleanup' is completed, the test
+executable will then exit altogether abandoning any remaining iterations of
++run+.
+
+For +statx+ we would like to create some files or file like objects which we
+have control over. Deciding where to create the files is easy, we just create
+it in the current working directory and let the LTP test harness handle where
+that should be by setting +.needs_tmpdir = 1+.
+
+[source,c]
+--------------------------------------------------------------------------------
+/*
+ * Test statx
+ *
+ * Check if statx exists and what error code it returns when we give it dodgy
+ * data. Then stat a file and check it returns success.
+ */
+
+#include <stdint.h>
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+#include "lapi/fcntl.h"
+
+#define FNAME "file_to_stat"
+#define STATX_BASIC_STATS 0x000007ffU
+
+/*************** statx structure and wrapper goes here ! ***************/
+
+...
+--------------------------------------------------------------------------------
+
+We have added an extra include +lapi/fcntl.h+ which wraps the system header by
+the same name (+#include <fcntl.h>+). This header ensures we have definitions
+for recently added macros such as +AT_FDCWD+ by providing fall backs if the
+system header does not have them. The +lapi+ directory contains a number of
+headers like this.
+
+At some point we may wish to add +lapi/stat.h+ to provide a fall back for
+macros such as +STATX_BASIC_STATS+. However for the time being we have just
+defined it in the test.
+
+[source,c]
+--------------------------------------------------------------------------------
+...
+
+static void setup(void)
+{
+	SAFE_TOUCH(FNAME, 0777, NULL);
+}
+
+static void run(void)
+{
+	struct statx statxbuf = { 0 };
+
+	TEST(sys_statx(0, NULL, 0, 0, &statxbuf));
+	if (TEST_RETURN == 0)
+		tst_res(TFAIL, "statx thinks it can stat NULL");
+	else if (TEST_ERRNO == EFAULT)
+		tst_res(TPASS, "statx set errno to EFAULT as expected");
+	else
+		tst_res(TFAIL | TERRNO, "statx set errno to some unexpected value");
+
+	TEST(sys_statx(AT_FDCWD, FNAME, 0, STATX_BASIC_STATS, &statxbuf));
+	if (TEST_RETURN == 0)
+		tst_res(TPASS, "It returned zero so it must have worked!");
+	else
+		tst_res(TFAIL | TERRNO, "statx can not stat a basic file");
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.test_all = run,
+	.min_kver = "4.11",
+	.needs_tmpdir = 1
+};
+--------------------------------------------------------------------------------
+
+The +setup+ callback uses one of the LTP's +SAFE+ functions to create an empty
+file +file_to_stat+. Because we have set +.needs_tmpdir+, we can just create
+this file in the present working directory. We don't need to create a
++cleanup+ callback yet because the LTP test harness will recursively delete
+the temporary directory and its contents.
+
+The +run+ function can be called multiple times by the test harness, however
++setup+ and +cleanup+ callbacks will only be ran once.
+
+[WARNING]
+By this point you may have begun to explore the LTP library headers or older
+tests. In which case you will have come across functions from the old API such
+as +tst_brkm+. The old API is being phased out, so you should not use these
+functions.
+
+So far we haven't had to do any clean up. So our example doesn't answer the
+question "what happens if part of the clean up fails?". To answer this we are
+going to modify the test to ask the (highly contrived) question "What happens
+if I create and open a file, then create a hard-link to it, then call open
+again on the hard-link, then 'stat' the file".
+
+[source,c]
+--------------------------------------------------------------------------------
+#define LNAME "file_to_stat_link"
+
+...
+
+static void setup(void)
+{
+	fd = SAFE_OPEN(FNAME, O_CREAT, 0777);
+	SAFE_LINK(FNAME, LNAME);
+	lfd = SAFE_OPEN(LNAME, 0);
+}
+
+static void cleanup(void)
+{
+	if (lfd != 0)
+		SAFE_CLOSE(lfd);
+
+	if (fd != 0)
+		SAFE_CLOSE(fd);
+}
+
+static void run(void)
+{
+        ...
+
+	TEST(sys_statx(AT_FDCWD, LNAME, 0, STATX_BASIC_STATS, &statxbuf));
+	if (TEST_RETURN == 0)
+		tst_res(TPASS, "It returned zero so it must have worked!");
+	else
+		tst_res(TFAIL | TERRNO, "statx can not stat a basic file");
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.tcnt = 2,
+	.min_kver = "4.11",
+	.needs_tmpdir = 1
+};
+--------------------------------------------------------------------------------
+
+Because we are now opening a file, we need a +cleanup+ function to close the
+file descriptors. We have to manually close the files to ensure the temporary
+directory is deleted by the test harness (see the
+https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines[test
+writing guidelines] for details).
+
+As a matter of good practice, the file descriptors are closed in reverse
+order. In some circumstances the order in which clean up is performed is
+significant. In that case resources created towards the end of 'setup' are
+dependent on ones near the beginning. So during 'cleanup' we remove the
+dependants before their dependencies.
+
+If, for some reason, the file descriptor +lfd+ became invalid during the test,
+but +fd+ was still open, we do not want +SAFE_CLOSE(lfd)+ to cause the
++cleanup+ function to exit prematurely. If it did, then +fd+ would remain open
+which would cause problems on some file systems.
+
+Nor do we want to call +cleanup+ recursively. So during 'cleanup' +tst_brk+,
+and consequently the +SAFE+ functions, do not cause the test to exit with
++TBROK+. Instead they just print an error message with +TWARN+.
+
+It is not entirely necessary to check if the file descriptors have a none zero
+value before attempting to close them. However it avoids a bunch of spurious
+warning messages if we fail to open +file_to_stat+. Test case failures can be
+difficult to interpret at the best of times, so avoid filling the log with
+noise.
+
+5.1 Check statx returns the correct number of hard links
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The field +statx.stx_nlink+ should be equal to 2, right?
+
+5.2 Git-branch
+~~~~~~~~~~~~~~
+
+We are about to make some organisational changes to the test, so now would be
+a good time to branch. Then we can switch between the old and new versions, to
+check the behavior has not been changed by accident.
+
+6. Split the test
+-----------------
+
+In our current test, we have essentially rolled two different test cases into
+one. Firstly we check if an error is returned when bad arguments are provided
+and secondly we check what happens when we stat an actual file. Quite often it
+makes sense to call +tst_res+ multiple times in a single test case because we
+are checking different properties of the same result, but here we are clearly
+testing two different scenarios.
+
+So we should split the test in two. One obvious way to do this is to create
++statx02.c+, but that seems like overkill in order to separate two simple test
+cases. So, for now at least, we are going to do it a different way.
+
+[source,c]
+--------------------------------------------------------------------------------
+...
+
+static void run_stat_null(void)
+{
+	struct statx statxbuf = { 0 };
+
+	TEST(sys_statx(0, NULL, 0, 0, &statxbuf));
+	if (TEST_RETURN == 0)
+		tst_res(TFAIL, "statx thinks it can stat NULL");
+	else if (TEST_ERRNO == EFAULT)
+		tst_res(TPASS, "statx set errno to EFAULT as expected");
+	else
+		tst_res(TFAIL | TERRNO, "statx set errno to some unexpected value");
+}
+
+static void run_stat_symlink(void)
+{
+	struct statx statxbuf = { 0 };
+
+	TEST(sys_statx(AT_FDCWD, LNAME, 0, STATX_BASIC_STATS, &statxbuf));
+	if (TEST_RETURN == 0)
+		tst_res(TPASS, "It returned zero so it must have worked!");
+	else
+		tst_res(TFAIL | TERRNO, "statx can not stat a basic file");
+}
+
+static void run(unsigned int i)
+{
+	switch(i) {
+	case 0: run_stat_null();
+	case 1: run_stat_symlink();
+	}
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = run,
+	.tcnt = 2,
+	.min_kver = "4.11",
+	.needs_tmpdir = 1
+};
+--------------------------------------------------------------------------------
+
+So we have used an alternative form of the +test+ or +run+ callback which
+accepts an index. Some tests use this index with an array of parameters and
+expected return values. Others do something similar to the above. The index
+can be used how you want so long as each iteration calls +tst_res+ in a
+meaningful way.
+
+If an iteration fails to return a result (i.e. call +tst_res+ with a value
+other than +TINFO+) then the test harness will report +TBROK+ and print the
+iteration which failed. This prevents a scenario in your test from silently
+failing due to some faulty logic.
+
+6.1 What is wrong with the switch statement?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Were you paying attention? Also see the output of +checkpatch.pl+.
+
+6.2 Test a feature unique to statx
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+So far we have not tested anything which is unique to +statx+. So, for
+example, you could check stx_btime is correct (possibly only to within a
+margin of error) and that it differs from +stx_mtime+ after writing to the
+file.
+
+Alternatively you could check that +stx_dev_major+ and +stx_dev_minor+ are set
+correctly. Note that the LTP has helper functions for creating devices and
+file systems (see
+https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#2214-testing-with-a-block-device[section
+2.2.14] of the Test Writing Guidelines).
+
+This could be quite a challenging exercise. You may wish to tackle an
+altogether different test scenario instead. If you get stuck just move onto
+the next section and come back later.
+
+7. Submitting the test for review
+---------------------------------
+
+Ignoring the fact we should probably create +lapi/stat.h+ along with a bunch
+of fallback logic in the build system. We can now get our test ready for
+submission.
+
+The first thing you need to do before considering submitting your test is run
++scripts/checkpatch.pl --no-tree -f+ on +statx01.c+. Again, we use the kernel
+style guidelines where possible. Next you should create a new branch, this
+will allow you to reshape your commit history without fear.
+
+After that we have the pleasure of doing an interactive 'rebase' to clean up
+our commit history. In its current form the test only really needs a single
+commit, but if you have been using Git correctly then you should have
+many. The main reason we want to compress it to a single commit, is to make
+the LTP's Git-log readable. It also allows us to write a coherent description
+of the work as a whole in retrospective. Although, when adding a new test, the
+test description in the code will probably make the commit message redundant.
+
+Anyway, as an example, we shall look at my personal commit history from this
+tutorial and 'rebase' it. You should try following along with your own
+repository. First lets look at the commit history since we branched from
+master.
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ git log -oneline master..HEAD
+152d39fe7 (HEAD -> tutorial-rebase2, tutorial-rebase) tutorial: Start Submitting patch section
+70f7ce7ce statx01: Stop checkpatch from complaining
+bb0332bd7 tutorial: Fix review problems
+6a87a084a statx01: Fix review problems
+d784b1e85 test-writing-guidelines: Remove old API argument
+c26e1be7a fixup! tutorial
+1e24a5fb5 (me/tutorial-rebase) fixup! tutorial
+568a3f7be fixup! tutorial
+09dd2c829 statx: stage 6
+bfeef7902 statx: stage 5b
+76e03d714 statx: stage 5a
+98f5bc7ac statx: stage 4
+6f8c16438 statx: stage 3 (Add statx01)
+5d93b84d8 Add statx and other syscall numbers
+5ca627b78 tutorial: Add a step-by-step C test tutorial
+--------------------------------------------------------------------------------
+
+So we have told git to show all the commits which don't exist in 'master', but
+are in +HEAD+, where +HEAD+ is the top of the current branch. The current
+branch is +tutorial-rebase2+ which I just created. I have already done one
+'rebase' and submitted a patch for review, so my original branch was just called
++tutorial+.
+
+As usual my commit history is starting to look like a bit of mess! There is
+even a commit in there which should not be in the this branch (Remove old API
+argument), however it can be ignored for now and 'cherry picked' into a new branch
+later.
+
+For my patch I actually need at least two commits, one which contains the
+tutorial text and one which contains the test and associated files. So first
+of all I want to 'squash' (amalgamate) all the commits appended with
++tutorial:+ into the bottom commit.
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ git rebase -i 5ca627b78\^
+...
+--------------------------------------------------------------------------------
+
+This begins an interactive 'rebase' where commit 5ca6427b78 is the earliest
+commit we want to edit. The +^+ symbol after the commit hash, specifies the
+commit before this one. The interactive 'rebase' command takes the last commit
+we want to keep unaltered as it's argument (in other words it takes a
+non-inclusive range).
+
+Upon entering a similar command you will be presented with a text file
+similar to the following. The file should be displayed in your text editor of
+choice, if it doesn't, then you may change the editor variable in +.gitconfig+
+which was shown in section 3.
+
+[source,rebase]
+--------------------------------------------------------------------------------
+pick 5ca627b78 tutorial: Add a step-by-step C test tutorial
+pick 5d93b84d8 Add statx and other syscall numbers
+pick 6f8c16438 statx: stage 3 (Add statx01)
+pick 98f5bc7ac statx: stage 4
+pick 76e03d714 statx: stage 5a
+pick bfeef7902 statx: stage 5b
+pick 09dd2c829 statx: stage 6
+pick 568a3f7be fixup! tutorial
+pick 1e24a5fb5 fixup! tutorial
+pick c26e1be7a fixup! tutorial
+pick d784b1e85 test-writing-guidelines: Remove old API argument
+pick 6a87a084a statx01: Fix review problems
+pick bb0332bd7 tutorial: Fix review problems
+pick 70f7ce7ce statx01: Stop checkpatch from complaining
+pick 152d39fe7 tutorial: Start Submitting patch section
+--------------------------------------------------------------------------------
+
+The last commit from Git-log is shown at the top. The left hand column
+contains the commands we want to run on each commit. +pick+ just means we
+re-apply the commit as-is. We can reorder the lines to apply the commits in a
+different order, but we need to be careful when reordering commits to the same
+file. If your 'rebase' results in a merge conflict, then you have probably
+reordered some commits which contained changes to the same piece of code.
+
+Perhaps a better name for the interactive 'rebase' command would be 'replay'. As
+we pick a point in the commit history, undo all those commits before that
+point, then reapply them one at a time. During the replay we can reorder the
+commits, drop, merge, split and edit them, creating a new history.
+
+The commands I am going to use are +reword+ and +fixup+. The +reword+ command
+allows you to edit a single commit's message. The 'fixup' command 'squashes' a
+commit into the commit above/preceding it, merging the two commits into
+one. The commit which has +fixup+ applied has its commit message deleted. If
+you think a commit might have something useful in its message then you can use
++squash+ instead.
+
+[source,rebase]
+--------------------------------------------------------------------------------
+reword 5ca627b78 tutorial: Add a step-by-step C test tutorial
+fixup 568a3f7be fixup! tutorial
+fixup 1e24a5fb5 fixup! tutorial
+fixup c26e1be7a fixup! tutorial
+fixup bb0332bd7 tutorial: Fix review problems
+fixup 152d39fe7 tutorial: Start Submitting patch section
+fixup 276edecab tutorial: Save changes before rebase
+pick 5d93b84d8 Add statx and other syscall numbers
+pick 6f8c16438 statx: stage 3 (Add statx01)
+pick 98f5bc7ac statx: stage 4
+pick 76e03d714 statx: stage 5a
+pick bfeef7902 statx: stage 5b
+pick 09dd2c829 statx: stage 6
+pick d784b1e85 test-writing-guidelines: Remove old API argument
+pick 6a87a084a statx01: Fix review problems
+--------------------------------------------------------------------------------
+
+So all the commits marked with +fixup+ will be re-played by Git immediately
+after 5ca62 at the top. A new commit will then be created with the amalgamated
+changes of all the commits and 5ca62's log message. It turns out that I didn't
+need to reword anything, but there is no harm in checking. It is easy to
+forget the +Signed-off-by:+ line.
+
+I could now do the same for the commits to the +statx+ test, making the commit
+message prefixes consistent. However I am not actually going to submit the
+test (yet).
+
+I won't attempt to show you this, but if you need to do the opposite and split
+apart a commit. It is also possible using Git-rebase by marking a line with
++edit+. This will pause Git just after replaying the marked commit. You can
+then use a 'soft' Git-reset to bring the selected commit's changes back into
+the 'index' where you are then able to un-stage some parts before
+re-committing.
+
+You can also use +edit+ and +git commit --amend+ together to change a commit
+deep in your history, but without reseting the 'index'. The 'index' contains
+changes which you have staged with +git add+, but not yet committed.
+
+So now that the commit history has been cleaned up, we need to submit a patch
+to the mailing list or make a pull request on GitHub. The mailing list is the
+preferred place to make submissions and is more difficult for most people, so
+I will only cover that method.
+
+Just before we create the patch, we need to check that our changes will still
+apply to the master branch without problems. To do this we can use another
+type of 'rebase' and then try rebuilding and running the test.
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ git checkout master
+$ git pull origin
+$ git checkout tutorial-rebase2
+$ git rebase master
+--------------------------------------------------------------------------------
+
+Above, I update the master branch and then replay our changes onto it using
++git rebase master+. You may find that after the rebase there is a merge
+conflict. This will result in something which looks like the following (taken
+from a Makefile conflict which was caused by reordering commits in a 'rebase').
+
+[source,diff]
+--------------------------------------------------------------------------------
+<<<<<<< HEAD
+cve-2016-7117:	LDFLAGS += -lpthread
+=======
+cve-2014-0196:	LDFLAGS += -lpthread -lutil -lrt
+cve-2016-7117:	LDFLAGS += -lpthread -lrt
+>>>>>>> 4dbfb8e79... Add -lrt
+--------------------------------------------------------------------------------
+
+The first line tells us this is the beginning of a conflict. The third line
+separates the two conflicting pieces of content and the last line is the end
+of the conflict. Usually, all you need to do is remove the lines you don't
+want, stage the changes and continue the 'rebase' with +git rebase
+--continue+.
+
+In order to create a patch e-mail we use +git format-patch+, we can then send
+that e-mail using +git send-email+. It is also possible to import the patch
+(+mbox+) file into a number of e-mail programs.
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ git format-patch -1 -v 2 -o output --to ltp@lists.linux.it fd3cc8596
+output/v2-0001-tutorial-Add-a-step-by-step-C-test-tutorial.patch
+--------------------------------------------------------------------------------
+
+The first argument +-1+ specifies we want one commit from fd3cc8596
+onwards. If we wanted this commit and the one after it we could specify +-2+
+instead.
+
+This is my second patch submission so I have used +-v 2+, which indicates this
+is the second version of a patch set. The +-o+ option specifies the output
+directory (literally called +output+). The +--to+ option adds the +To:+ e-mail
+header, which I have set to the LTP mailing list.
+
+We can then send this patch with the following command sans +--dry-run+.
+
+[source,shell]
+--------------------------------------------------------------------------------
+$ git send-email --dry-run output/v2-0001-tutorial-Add-a-step-by-step-C-test-tutorial.patch
+--------------------------------------------------------------------------------
+
+Git will ask some questions (which you an ignore) and then tell you what it
+would do if this weren't a dry-run. In order for this to work you have to have
+a valid SMTP server set in +.gitconfig+ and also be signed up to the LTP
+mailing list under the same e-mail address you have configured in Git. You can
+sign up at https://lists.linux.it/listinfo/ltp.
+
+8. Doing code review
+--------------------
+
+While waiting for your test to be reviewed, you are invited and encouraged to
+review other contributors' code. This may seem bizarre when you are completely
+new to the project, but there are two important ways in which you can
+contribute here:
+
+A.   Point out logical errors in the code.
+B.   Improve your own understanding
+
+It doesn't matter whether you know the canonical way of writing an LTP test in
+C. An error of logic, when properly explained, is usually indisputable. These
+are the most important errors to find as they always result in false test
+results. Once someone points out such an error it is usually obvious to
+everyone that it is a bug and needs to be fixed.
+
+Obviously testing the patch is one way of finding errors. You can apply
+patches using +git am+. Then it is just a case of compiling and running the
+tests.
+
+Finally, reading and attempting to comment on other peoples patches, gives
+you a better understanding of the reviewers perspective. This is better for
+the project and for you.
+
+Style and organisational issues are best left to after you have found logical
+errors.
+
+9. Final notes
+--------------
+
+Hopefully you can now grasp the structure of an LTP test and have some idea of
+what is available in the LTP test library. There are a vast number of library
+functions available (mainly located in include and lib), some of which are
+documented in the test writing guidelines and many of which are not.
+
+We have only scratched the surface of the immense technical complexity of
+systems programming across multiple Kernel and C lib versions as well as
+different hardware architectures. The important thing to take away from this
+is that you have to be conscientious of what will happen on systems different
+from yours. The LTP has a huge and varied user base, so situations you may
+thing are unlikely can and do happen to somebody.
+
+Of course you don't want to spend time allowing for situations which may never
+arise either, so you have to do your research and think about each situation
+critically. The more systems you can test on before submitting your changes,
+the better, although we understand not everyone has access to a lab.
+
+One important topic which has not been covered by this tutorial, is
+multi-process or multi-threaded testing. The LTP library functions work inside
+child processes and threads, but their semantics change slightly. There are
+also various helper functions for synchronising and forking processes. For
+more information see the Test Writing Guidelines (either at
+https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines[the
+Wiki] or in ./doc), in particular sections 2.2.7 to 2.2.10 and 2.2.13.
+
+When it comes time to submit a test, the preferred way to do it is on the
+mailing list although you can also use GitHub. The LTP follows similar rules
+to the kernel for formatting and submitting patches. Generally speaking the
+review cycle is easier for small patches, so try to make small changes or
+additions where possible.
diff --git a/doc/ltp-run-files.txt b/doc/ltp-run-files.txt
index 36180b9..f8cc36b 100644
--- a/doc/ltp-run-files.txt
+++ b/doc/ltp-run-files.txt
@@ -1,4 +1,43 @@
-List of scripts or executables that need to be run for complete LTP execution.
+The runtest files contain a list of test cases to be executed.
+
+File Format
+-----------
+
+Lines starting with a '#' are comments and blank lines are ignored.
+
+Otherwise, lines start with a test name followed by white space, then some
+shell script to be executed. For example
+
+Test Name
+|       Delimiter               Test case argument
+|       |                       |
+v       v                       v
+splice02 seq 1 20000 | splice02 splice02-temp
+         ^             ^                    ^
+         |             |                    |
+         |             Test case executable |
+         -----------Shell script-------------
+
+So the splice02 runtest entry pipes the output of seq into the splice02 test
+executable. Most runtest entries are simpler than this, for example
+
+splice03 splice03
+
+Here the test name and executable have the same name and no arguments have
+been supplied.
+
+Run test files should start with a comment describing the tests they contain,
+e.g.
+
+#DESCRIPTION:Kernel system calls
+
+Note that the LTP has absorbed a number of other projects. Some of these have
+been fully converted to the LTP format, others have runtest files generated
+for them during installation, while some use a shell script to integrate them
+with the other tests.
+
+Test suites
+-----------
 
  - syscalls  (except epoll, see below)
  - fs
diff --git a/doc/style-guide.txt b/doc/style-guide.txt
index 08f126c..b853fa8 100644
--- a/doc/style-guide.txt
+++ b/doc/style-guide.txt
@@ -109,7 +109,7 @@
 8. Don't roll your own syscall numbers
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Header +linux_syscall_numbers.h+ exists for this purpose and does a pretty
+Header +lapi/syscalls.h+ exists for this purpose and does a pretty
 dang good job.
 
 9. Keep errors as short and sweet as possible
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 521773b..15d4189 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -215,7 +215,7 @@
 
 1. if '$LTPROOT' is set, return '$LTPROOT/testcases/data/$TCID'
 2. else if 'tst_tmpdir()' was called return '$STARTWD/datafiles'
-   (where '$STARTWD' is initial working directory as recorded by 'tst_tmdir()')
+   (where '$STARTWD' is initial working directory as recorded by 'tst_tmpdir()')
 3. else return '$CWD/datafiles'
 
 See 'testcases/commands/file/' for example.
@@ -224,9 +224,9 @@
 ^^^^^^^^^^^^^^^^^^^^
 
 If you test needs to execute a binary, place it in the same directory as the
-testcase and name the file starting with testname_ ('.tid' see below).
-Once the test is executed by the framework, the path to the directory with all
-LTP binaries is added to the '$PATH' and you can execute it just by its name.
+testcase and name the file starting with '${test_binary_name}_'.  Once the
+test is executed by the framework, the path to the directory with all LTP
+binaries is added to the '$PATH' and you can execute it just by its name.
 
 TIP: If you need to execute such test from the LTP tree, you can add path to
      current directory to '$PATH' manually with: 'PATH="$PATH:$PWD" ./foo01'.
@@ -288,7 +288,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getenv01",
 	.test_all = test,
 	.setup = setup,
 };
@@ -297,11 +296,6 @@
 Each test includes the 'tst_test.h' header and must define the 'struct
 tst_test test' structure.
 
-The '.tid' defines test name (usually syscall/libcall name + number). The name
-is used in the test results as well as a base for temporary directory name if
-temporary directory is needed. In most of the cases it's the same as test
-filename without the extension.
-
 The overall test initialization is done in the 'setup()' function.
 
 The overall cleanup is done in a 'cleanup()' function. Here 'cleanup()' is
@@ -326,7 +320,9 @@
 
 Each test has a default timeout set to 300s. The default timeout can be
 overriden by setting '.timeout' in the test structure or by calling
-'tst_set_timeout()' in the test 'setup()'.
+'tst_set_timeout()' in the test 'setup()'. There are a few testcases whose run
+time may vary arbitrarily, for these timeout can be disabled by setting it to
+-1.
 
 A word about the cleanup() callback
 +++++++++++++++++++++++++++++++++++
@@ -457,7 +453,8 @@
 -------------------------------------------------------------------------------
 
 Allows for setting timeout per test iteration dymanically in the test setup(),
-the timeout is specified in seconds.
+the timeout is specified in seconds. There are a few testcases whose runtime
+can vary arbitrarily, these can disable timeouts by setting it to -1.
 
 2.2.3 Test temporary directory
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1235,11 +1232,11 @@
 
 The test library looks for datafiles first, these are either stored in a
 directory called +datafiles+ in the +$PWD+ at the start of the test or in
-+$LTPROOT/testcases/data/$tid+. If the file is not found the library looks
-into +$LTPROOT/testcases/bin/+ and to +$PWD+ at the start of the test. This
-ensures that the testcases can copy the file(s) effortlessly both when test is
-started from the directory it was compiled in as well as when LTP was
-installed.
++$LTPROOT/testcases/data/${test_binary_name}+. If the file is not found the
+library looks into +$LTPROOT/testcases/bin/+ and to +$PWD+ at the start of the
+test. This ensures that the testcases can copy the file(s) effortlessly both
+when test is started from the directory it was compiled in as well as when LTP
+was installed.
 
 The file(s) are copied to the newly created test temporary directory which is
 set as the test working directory when the 'test()' functions is executed.
@@ -1312,7 +1309,6 @@
 # This is a basic test for true shell buildin
 #
 
-TST_ID="true01"
 TST_TESTFUNC=do_test
 . tst_test.sh
 
@@ -1358,7 +1354,6 @@
 # Example test with tests in separate functions
 #
 
-TST_ID="example01"
 TST_TESTFUNC=test
 TST_CNT=2
 . tst_test.sh
@@ -1387,7 +1382,6 @@
 # Example test with tests in a single function
 #
 
-TST_ID="example02"
 TST_TESTFUNC=do_test
 TST_CNT=2
 . tst_test.sh
@@ -1467,7 +1461,6 @@
 # Optional test command line parameters
 #
 
-TST_ID="example03"
 TST_OPTS="af:"
 TST_USAGE=usage
 TST_PARSE_ARGS=parse_args
@@ -1522,7 +1515,6 @@
 # Optional test positional paramters
 #
 
-TST_ID="example04"
 TST_POS_ARGS=3
 TST_USAGE=usage
 TST_TESTFUNC=do_test
diff --git a/gen.bp b/gen.bp
index 3d156ab..e6c5f3b 100644
--- a/gen.bp
+++ b/gen.bp
@@ -71,10 +71,7 @@
     stem: "wait402",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/wait4/wait402.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -83,10 +80,7 @@
     stem: "acct01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/acct/acct01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -95,10 +89,7 @@
     stem: "umount2_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/umount2/umount2_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -107,10 +98,7 @@
     stem: "waitpid13",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid13.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -119,10 +107,7 @@
     stem: "umount2_03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/umount2/umount2_03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -131,10 +116,7 @@
     stem: "umount2_02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/umount2/umount2_02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -160,10 +142,7 @@
     stem: "wait401",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/wait4/wait401.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -176,10 +155,7 @@
         "-D_GNU_SOURCE",
         "-DNUMA_VERSION1_COMPATIBILITY",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -188,10 +164,8 @@
     stem: "linkat02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/linkat/linkat02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    cflags: ["-Wno-error"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -200,10 +174,8 @@
     stem: "linkat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/linkat/linkat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    cflags: ["-Wno-error"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -212,10 +184,7 @@
     stem: "utime06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utime/utime06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -225,10 +194,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/lib6/asapi_01.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -238,10 +204,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/lib6/asapi_03.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -251,10 +214,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/lib6/asapi_02.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -263,10 +223,7 @@
     stem: "utimes01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utimes/utimes01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -275,10 +232,7 @@
     stem: "ioctl05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ioctl/ioctl05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -287,10 +241,7 @@
     stem: "ioctl04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ioctl/ioctl04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -299,10 +250,7 @@
     stem: "ioctl06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ioctl/ioctl06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -311,10 +259,7 @@
     stem: "ioctl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ioctl/ioctl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -323,10 +268,7 @@
     stem: "vmsplice02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/vmsplice/vmsplice02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -335,10 +277,7 @@
     stem: "ioctl03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ioctl/ioctl03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -382,10 +321,7 @@
     stem: "futex_wait05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wait05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -394,10 +330,7 @@
     stem: "futex_wait03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wait03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -406,10 +339,7 @@
     stem: "futex_wait01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wait01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -418,10 +348,7 @@
     stem: "getsockname01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getsockname/getsockname01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -439,10 +366,7 @@
     stem: "kcmp03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kcmp/kcmp03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -451,10 +375,7 @@
     stem: "kcmp02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kcmp/kcmp02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -463,10 +384,7 @@
     stem: "kcmp01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kcmp/kcmp01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -476,7 +394,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_test03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -491,10 +408,7 @@
     stem: "sched_setscheduler03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -503,10 +417,7 @@
     stem: "sched_getparam03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getparam/sched_getparam03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -515,10 +426,7 @@
     stem: "sched_getparam02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getparam/sched_getparam02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -527,10 +435,7 @@
     stem: "sched_getparam01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getparam/sched_getparam01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -539,11 +444,25 @@
     stem: "setegid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setegid/setegid02.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_vma05_vdso",
+    stem: "vma05_vdso",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/mem/vma/vma05_vdso.c"],
     local_include_dirs: [
+        "testcases/kernel/mem/include",
         "testcases/kernel/include",
         "include/old",
     ],
-    static_libs: ["libltp_ltp"],
+    static_libs: [
+        "libltp_mem",
+        "libltp_kerntest",
+        "libltp_ltp",
+    ],
 }
 
 cc_test {
@@ -551,10 +470,7 @@
     stem: "ptrace03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ptrace/ptrace03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -563,10 +479,7 @@
     stem: "ptrace02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ptrace/ptrace02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -575,10 +488,7 @@
     stem: "ptrace01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ptrace/ptrace01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -587,10 +497,7 @@
     stem: "waitpid10",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -599,10 +506,7 @@
     stem: "ptrace05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ptrace/ptrace05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -611,10 +515,7 @@
     stem: "ptrace04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ptrace/ptrace04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -628,10 +529,7 @@
         "-DPF_CAN=29",
         "-DAF_CAN=PF_CAN",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -640,10 +538,7 @@
     stem: "waitpid11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -652,10 +547,7 @@
     stem: "prctl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/prctl/prctl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -664,10 +556,7 @@
     stem: "execle01_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execle/execle01_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -676,10 +565,7 @@
     stem: "prctl02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/prctl/prctl02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -688,22 +574,25 @@
     stem: "renameat201",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/renameat2/renameat201.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_tee01",
-    stem: "tee01",
+    name: "ltp_tomoyo_file_test",
+    stem: "tomoyo_file_test",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/tee/tee01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/security/tomoyo/tomoyo_file_test.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_copy_file_range01",
+    stem: "copy_file_range01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/copy_file_range/copy_file_range01.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -720,10 +609,7 @@
     stem: "tee02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/tee/tee02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -749,10 +635,7 @@
     stem: "sighold02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sighold/sighold02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -761,10 +644,17 @@
     stem: "quotactl03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/quotactl/quotactl03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cve-2016-4997",
+    stem: "cve-2016-4997",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/cve/cve-2016-4997.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -773,10 +663,7 @@
     stem: "quotactl02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/quotactl/quotactl02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -785,10 +672,7 @@
     stem: "bdflush01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/bdflush/bdflush01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -797,10 +681,7 @@
     stem: "readdir02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readdir/readdir02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -809,10 +690,7 @@
     stem: "unlink05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/unlink/unlink05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -821,10 +699,7 @@
     stem: "float_bessel",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/math/float/float_bessel.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -833,10 +708,7 @@
     stem: "readv01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readv/readv01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -845,10 +717,7 @@
     stem: "setsid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setsid/setsid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -866,10 +735,7 @@
     stem: "pec_listener",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/connectors/pec/pec_listener.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -878,10 +744,7 @@
     stem: "stress_cd",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/io/stress_cd/stress_cd.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -891,7 +754,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lstat/lstat01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/lstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -905,7 +767,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lstat/lstat03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/lstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -919,7 +780,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lstat/lstat02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/lstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -932,10 +792,7 @@
     stem: "futex_wake01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wake01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -946,7 +803,6 @@
     srcs: ["testcases/network/tcp_cmds/echo/createfile.c"],
     cflags: ["-DDEBUG"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/network/tcp_cmds/include",
         "include/old",
     ],
@@ -958,10 +814,7 @@
     stem: "futex_wake02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wake02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -987,10 +840,7 @@
     stem: "futex_wake04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wake04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -999,10 +849,7 @@
     stem: "capset01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/capset/capset01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1011,10 +858,17 @@
     stem: "capset02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/capset/capset02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cve-2016-10044",
+    stem: "cve-2016-10044",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/cve/cve-2016-10044.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1023,10 +877,7 @@
     stem: "readlink04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readlink/readlink04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1035,10 +886,7 @@
     stem: "readlink01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readlink/readlink01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1048,7 +896,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuacct/cpuacct_task.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -1060,10 +907,7 @@
     stem: "readlink03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readlink/readlink03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1072,10 +916,7 @@
     stem: "mem03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/memmap/mem03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1084,10 +925,7 @@
     stem: "fstatat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fstatat/fstatat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1096,10 +934,7 @@
     stem: "exit_group01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/exit_group/exit_group01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1120,20 +955,12 @@
 }
 
 cc_test {
-    name: "ltp_thp02",
-    stem: "thp02",
+    name: "ltp_splice04",
+    stem: "splice04",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/thp/thp02.c"],
-    local_include_dirs: [
-        "testcases/kernel/mem/include",
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: [
-        "libltp_mem",
-        "libltp_kerntest",
-        "libltp_ltp",
-    ],
+    srcs: ["testcases/kernel/syscalls/splice/splice04.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -1142,7 +969,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/statfs/statfs03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/statfs",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -1155,10 +981,7 @@
     stem: "execve01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execve/execve01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1167,10 +990,7 @@
     stem: "execve03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execve/execve03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1179,10 +999,7 @@
     stem: "execve02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execve/execve02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1191,22 +1008,17 @@
     stem: "execve05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execve/execve05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_execve04",
-    stem: "execve04",
+    name: "ltp_cve-2014-0196",
+    stem: "cve-2014-0196",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/execve/execve04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/cve/cve-2014-0196.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1215,10 +1027,7 @@
     stem: "nice01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/nice/nice01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1227,10 +1036,7 @@
     stem: "tpci",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/pci/tpci_user/tpci.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1239,10 +1045,7 @@
     stem: "time02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/time/time02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1259,10 +1062,17 @@
     stem: "execve01_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execve/execve01_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cve-2012-0957",
+    stem: "cve-2012-0957",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/cve/cve-2012-0957.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1275,6 +1085,19 @@
 }
 
 cc_test {
+    name: "ltp_sendfile02",
+    stem: "sendfile02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/sendfile/sendfile02.c"],
+    local_include_dirs: [
+        "testcases/kernel/syscalls/sendfile",
+        "testcases/kernel/syscalls/utils",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_f3",
     stem: "f3",
     defaults: ["ltp_test_defaults"],
@@ -1304,10 +1127,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/pty/hangup01.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1333,10 +1153,7 @@
     stem: "socket02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socket/socket02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1346,7 +1163,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill12.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -1361,10 +1177,7 @@
     stem: "dup205",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup2/dup205.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1373,10 +1186,7 @@
     stem: "dup204",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup2/dup204.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1385,10 +1195,7 @@
     stem: "dup203",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup2/dup203.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1397,10 +1204,7 @@
     stem: "dup202",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup2/dup202.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1409,10 +1213,7 @@
     stem: "dup201",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup2/dup201.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1421,10 +1222,7 @@
     stem: "uname01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/uname/uname01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1433,10 +1231,7 @@
     stem: "uname03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/uname/uname03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1445,10 +1240,7 @@
     stem: "uname02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/uname/uname02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1458,7 +1250,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/truncate/truncate01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/truncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -1473,8 +1264,8 @@
     srcs: ["testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c"],
     local_include_dirs: [
         "testcases/kernel/mem/include",
-        "testcases/kernel/include",
         "testcases/kernel/mem/hugetlb/lib",
+        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: [
@@ -1490,10 +1281,7 @@
     stem: "ima_measure",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/integrity/ima/src/ima_measure.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
     shared_libs: [
         "libdl",
@@ -1506,10 +1294,7 @@
     stem: "execle01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execle/execle01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1518,10 +1303,7 @@
     stem: "ext4_test_inode_version",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_test_inode_version.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1538,10 +1320,7 @@
     stem: "getpriority02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpriority/getpriority02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1551,10 +1330,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c"],
     cflags: ["-DTEST_SIGWAIT"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1563,10 +1339,7 @@
     stem: "mkdirat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdirat/mkdirat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1575,10 +1348,7 @@
     stem: "sigprocmask01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigprocmask/sigprocmask01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1587,10 +1357,7 @@
     stem: "mkdirat02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdirat/mkdirat02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1599,10 +1366,7 @@
     stem: "tst_checkpoint",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/lib/tst_checkpoint.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1612,10 +1376,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/inode/inode01.c"],
     cflags: ["-DLINUX"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1625,10 +1386,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/inode/inode02.c"],
     cflags: ["-DLINUX"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1637,10 +1395,7 @@
     stem: "string01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/string/string01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1649,10 +1404,7 @@
     stem: "send01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/send/send01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1661,10 +1413,7 @@
     stem: "dirtyc0w_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/dirtyc0w/dirtyc0w_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1690,10 +1439,7 @@
     stem: "tkill02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/tkill/tkill02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1702,10 +1448,7 @@
     stem: "vmsplice01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/vmsplice/vmsplice01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1714,10 +1457,7 @@
     stem: "fork12",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork12.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1726,10 +1466,7 @@
     stem: "fork13",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork13.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1738,10 +1475,7 @@
     stem: "fork10",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1750,10 +1484,7 @@
     stem: "fork11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1762,10 +1493,7 @@
     stem: "nanosleep01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/nanosleep/nanosleep01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1774,10 +1502,7 @@
     stem: "fork14",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork14.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1786,10 +1511,7 @@
     stem: "nanosleep02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/nanosleep/nanosleep02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1798,10 +1520,7 @@
     stem: "read01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/read/read01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1810,10 +1529,7 @@
     stem: "execve_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execve/execve_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1822,10 +1538,7 @@
     stem: "fsync01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fsync/fsync01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1834,10 +1547,7 @@
     stem: "rename08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1846,10 +1556,7 @@
     stem: "fsync03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fsync/fsync03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1858,10 +1565,7 @@
     stem: "fsync02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fsync/fsync02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1870,10 +1574,7 @@
     stem: "rename05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1882,10 +1583,7 @@
     stem: "rename04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1894,10 +1592,7 @@
     stem: "rename07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1906,10 +1601,7 @@
     stem: "rename06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1918,10 +1610,7 @@
     stem: "rename01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1930,10 +1619,7 @@
     stem: "rename03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1942,10 +1628,7 @@
     stem: "rename02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1958,16 +1641,11 @@
 }
 
 cc_test {
-    name: "ltp_timer_create03",
-    stem: "timer_create03",
+    name: "ltp_sched_get_priority_max02",
+    stem: "sched_get_priority_max02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/timers/timer_create/timer_create03.c"],
-    cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "testcases/kernel/timers/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/sched_get_priority_max/sched_get_priority_max02.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1976,10 +1654,7 @@
     stem: "crash01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/crash/crash01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -1988,10 +1663,7 @@
     stem: "syslog12",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/syslog/syslog12.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2000,10 +1672,7 @@
     stem: "tst_kvcmp",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/lib/tst_kvcmp.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2012,10 +1681,7 @@
     stem: "modify_ldt03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/modify_ldt/modify_ldt03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2024,10 +1690,7 @@
     stem: "modify_ldt02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/modify_ldt/modify_ldt02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2036,10 +1699,7 @@
     stem: "modify_ldt01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/modify_ldt/modify_ldt01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2050,7 +1710,6 @@
     srcs: ["testcases/kernel/timers/timer_delete/timer_delete03.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -2063,10 +1722,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c"],
     cflags: ["-DTEST_RT_SIGTIMEDWAIT"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2075,10 +1731,7 @@
     stem: "getsid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getsid/getsid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2087,10 +1740,7 @@
     stem: "getsid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getsid/getsid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2099,10 +1749,7 @@
     stem: "getdomainname01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getdomainname/getdomainname01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2111,10 +1758,7 @@
     stem: "symlink03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/symlink/symlink03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2123,10 +1767,7 @@
     stem: "time01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/time/time01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2135,10 +1776,7 @@
     stem: "settimeofday01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/settimeofday/settimeofday01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2148,10 +1786,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/lib6/getaddrinfo_01.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2161,10 +1796,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/pty/pty01.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2173,10 +1805,7 @@
     stem: "settimeofday02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/settimeofday/settimeofday02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2186,8 +1815,8 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
+        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: [
@@ -2201,10 +1830,7 @@
     stem: "pm_get_sched_values",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/power_management/pm_get_sched_values.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2214,7 +1840,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/truncate/truncate03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/truncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -2228,7 +1853,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/truncate/truncate02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/truncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -2241,10 +1865,7 @@
     stem: "openat02_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/openat/openat02_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2253,10 +1874,7 @@
     stem: "brk01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/brk/brk01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2265,10 +1883,7 @@
     stem: "futex_wait04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wait04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2277,10 +1892,7 @@
     stem: "symlink04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/symlink/symlink04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2289,10 +1901,17 @@
     stem: "fdatasync01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fdatasync/fdatasync01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cve-2017-6951",
+    stem: "cve-2017-6951",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/cve/cve-2017-6951.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2301,10 +1920,7 @@
     stem: "ext4_file_time",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_file_time.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2313,10 +1929,7 @@
     stem: "setpgid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setpgid/setpgid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2325,10 +1938,7 @@
     stem: "sched_setattr01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setattr/sched_setattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2337,10 +1947,7 @@
     stem: "setpgid03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setpgid/setpgid03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2349,10 +1956,7 @@
     stem: "setpgid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setpgid/setpgid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2361,10 +1965,7 @@
     stem: "gettimeofday01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/gettimeofday/gettimeofday01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2373,10 +1974,7 @@
     stem: "sched_rr_get_interval03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2385,10 +1983,7 @@
     stem: "gettimeofday02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/gettimeofday/gettimeofday02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2398,7 +1993,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_test04.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -2415,7 +2009,6 @@
     srcs: ["testcases/kernel/timers/clock_settime/clock_settime03.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -2428,7 +2021,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/memctl/memctl_test01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -2460,10 +2052,7 @@
     stem: "fpathconf01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fpathconf/fpathconf01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2480,10 +2069,7 @@
     stem: "sched_getattr02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getattr/sched_getattr02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2492,10 +2078,7 @@
     stem: "mincore01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mincore/mincore01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2505,7 +2088,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/memcg/regression/memcg_test_4.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -2518,7 +2100,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_test02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -2533,10 +2114,7 @@
     stem: "rmdir05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rmdir/rmdir05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2545,10 +2123,7 @@
     stem: "rmdir04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rmdir/rmdir04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2557,10 +2132,7 @@
     stem: "rmdir01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rmdir/rmdir01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2570,7 +2142,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_test01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -2585,10 +2156,7 @@
     stem: "rmdir02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rmdir/rmdir02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2597,10 +2165,7 @@
     stem: "tomoyo_policy_io_test",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/tomoyo/tomoyo_policy_io_test.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2609,10 +2174,7 @@
     stem: "sched_rr_get_interval02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2621,10 +2183,7 @@
     stem: "getdtablesize01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getdtablesize/getdtablesize01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2670,10 +2229,7 @@
     stem: "fanotify05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fanotify/fanotify05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2682,10 +2238,16 @@
     stem: "fanotify04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fanotify/fanotify04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_fanotify07",
+    stem: "fanotify07",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/fanotify/fanotify07.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2694,10 +2256,7 @@
     stem: "fanotify06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fanotify/fanotify06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2706,10 +2265,7 @@
     stem: "fanotify01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fanotify/fanotify01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2718,10 +2274,7 @@
     stem: "fanotify03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fanotify/fanotify03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2730,10 +2283,7 @@
     stem: "fanotify02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fanotify/fanotify02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2742,10 +2292,16 @@
     stem: "sockioctl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sockioctl/sockioctl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_fanotify08",
+    stem: "fanotify08",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/fanotify/fanotify08.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2764,7 +2320,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/memcg/regression/memcg_test_2.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -2778,7 +2333,6 @@
     srcs: ["testcases/kernel/timers/clock_gettime/clock_gettime03.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -2792,7 +2346,6 @@
     srcs: ["testcases/kernel/timers/clock_gettime/clock_gettime02.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -2814,7 +2367,6 @@
     srcs: ["testcases/kernel/timers/timer_settime/timer_settime03.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -2826,10 +2378,7 @@
     stem: "execv01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execv/execv01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2840,7 +2389,6 @@
     srcs: ["testcases/kernel/timers/clock_settime/clock_settime02.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -2852,10 +2400,7 @@
     stem: "timerfd01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/timerfd/timerfd01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2865,7 +2410,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_latency_test.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -2880,10 +2424,7 @@
     stem: "timerfd03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/timerfd/timerfd03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2892,10 +2433,7 @@
     stem: "timerfd02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/timerfd/timerfd02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2904,10 +2442,16 @@
     stem: "mmstress_dummy",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mtest05/mmstress_dummy.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_nfs01_open_files",
+    stem: "nfs01_open_files",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/network/nfs/nfs_stress/nfs01_open_files.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2916,10 +2460,7 @@
     stem: "execv01_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execv/execv01_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2930,7 +2471,6 @@
     srcs: ["testcases/kernel/timers/timer_create/timer_create02.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -2943,22 +2483,20 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setns/setns01.c"],
     cflags: ["-Wno-unused-function"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_mmapstress03",
-    stem: "mmapstress03",
+    name: "ltp_stack_clash",
+    stem: "stack_clash",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/mmapstress/mmapstress03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
+    srcs: ["testcases/cve/stack_clash.c"],
+    cflags: [
+        "-D_GNU_SOURCE",
+        "-Wno-infinite-recursion",
     ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2967,10 +2505,7 @@
     stem: "mlock04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mlock/mlock04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2979,10 +2514,7 @@
     stem: "mmapstress01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -2991,10 +2523,7 @@
     stem: "mlock01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mlock/mlock01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3003,10 +2532,7 @@
     stem: "mmapstress06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3015,10 +2541,7 @@
     stem: "mlock03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mlock/mlock03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3027,10 +2550,7 @@
     stem: "mlock02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mlock/mlock02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3039,10 +2559,7 @@
     stem: "mmapstress09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3051,10 +2568,7 @@
     stem: "mincore02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mincore/mincore02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3063,10 +2577,7 @@
     stem: "futimesat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futimesat/futimesat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3075,10 +2586,7 @@
     stem: "openfile",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/openfile/openfile.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3087,10 +2595,7 @@
     stem: "inotify05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/inotify/inotify05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3099,10 +2604,7 @@
     stem: "inotify04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/inotify/inotify04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3111,10 +2613,7 @@
     stem: "mknod03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknod/mknod03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3123,10 +2622,7 @@
     stem: "inotify01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/inotify/inotify01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3135,10 +2631,7 @@
     stem: "mknod04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknod/mknod04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3147,58 +2640,7 @@
     stem: "inotify03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/inotify/inotify03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_inotify02",
-    stem: "inotify02",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/inotify/inotify02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_mknod09",
-    stem: "mknod09",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/mknod/mknod09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_mknod08",
-    stem: "mknod08",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/mknod/mknod08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_cap_bounds_rw",
-    stem: "cap_bounds_rw",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/security/cap_bound/cap_bounds_rw.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3209,7 +2651,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl31.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3218,13 +2659,48 @@
 }
 
 cc_test {
+    name: "ltp_mknod09",
+    stem: "mknod09",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/mknod/mknod09.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_mknod08",
+    stem: "mknod08",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/mknod/mknod08.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cap_bounds_rw",
+    stem: "cap_bounds_rw",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/security/cap_bound/cap_bounds_rw.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_write05",
+    stem: "write05",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/write/write05.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_fcntl18",
     stem: "fcntl18",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl18.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3239,7 +2715,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl19.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3252,10 +2727,7 @@
     stem: "inotify_init1_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/inotify_init/inotify_init1_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3264,10 +2736,7 @@
     stem: "inotify_init1_02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/inotify_init/inotify_init1_02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3278,7 +2747,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl12.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3293,7 +2761,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl13.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3308,7 +2775,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl10.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3323,7 +2789,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl11.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3338,7 +2803,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl16.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3353,7 +2817,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl17.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3368,7 +2831,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl14.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3383,7 +2845,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl15.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3396,10 +2857,7 @@
     stem: "getpgrp01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpgrp/getpgrp01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3408,10 +2866,7 @@
     stem: "setegid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setegid/setegid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3420,10 +2875,7 @@
     stem: "getresuid03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getresuid/getresuid03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3432,10 +2884,7 @@
     stem: "getresuid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getresuid/getresuid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3444,10 +2893,7 @@
     stem: "swapoff01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/swapoff/swapoff01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3456,10 +2902,7 @@
     stem: "sigpending02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigpending/sigpending02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3468,10 +2911,7 @@
     stem: "accept01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/accept/accept01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3480,10 +2920,7 @@
     stem: "write01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/write/write01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3492,10 +2929,7 @@
     stem: "readv03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readv/readv03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3504,10 +2938,7 @@
     stem: "readv02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readv/readv02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3533,10 +2964,7 @@
     stem: "capget01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/capget/capget01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3549,26 +2977,11 @@
 }
 
 cc_test {
-    name: "ltp_write02",
-    stem: "write02",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/write/write02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_sched_get_priority_min01",
     stem: "sched_get_priority_min01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_get_priority_min/sched_get_priority_min01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3577,10 +2990,7 @@
     stem: "sched_get_priority_min02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_get_priority_min/sched_get_priority_min02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3589,10 +2999,7 @@
     stem: "getresgid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getresgid/getresgid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3601,10 +3008,7 @@
     stem: "getresgid03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getresgid/getresgid03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3613,10 +3017,7 @@
     stem: "getresgid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getresgid/getresgid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3634,10 +3035,7 @@
     stem: "fdatasync02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fdatasync/fdatasync02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3656,7 +3054,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/timers/leapsec/leapsec_timer.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -3664,14 +3061,20 @@
 }
 
 cc_test {
+    name: "ltp_nice02",
+    stem: "nice02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/nice/nice02.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_flock05",
     stem: "flock05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flock/flock05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3680,10 +3083,7 @@
     stem: "flock04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flock/flock04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3692,10 +3092,7 @@
     stem: "flock06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flock/flock06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3704,10 +3101,7 @@
     stem: "flock01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flock/flock01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3716,10 +3110,7 @@
     stem: "flock03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flock/flock03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3728,10 +3119,7 @@
     stem: "flock02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flock/flock02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3740,10 +3128,7 @@
     stem: "recvfrom01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/recvfrom/recvfrom01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3752,10 +3137,16 @@
     stem: "mknodat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknodat/mknodat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_mknod06",
+    stem: "mknod06",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/mknod/mknod06.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3764,10 +3155,7 @@
     stem: "mknodat02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknodat/mknodat02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3776,10 +3164,7 @@
     stem: "fallocate01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fallocate/fallocate01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3788,10 +3173,7 @@
     stem: "fallocate03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fallocate/fallocate03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3800,10 +3182,7 @@
     stem: "fallocate02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fallocate/fallocate02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3812,10 +3191,7 @@
     stem: "fallocate04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fallocate/fallocate04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3824,10 +3200,7 @@
     stem: "mmap3",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mtest06/mmap3.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3836,10 +3209,7 @@
     stem: "mmap2",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mtest06/mmap2.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3848,10 +3218,7 @@
     stem: "dup01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup/dup01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3860,10 +3227,7 @@
     stem: "pathconf01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pathconf/pathconf01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3872,10 +3236,7 @@
     stem: "dup03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup/dup03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3884,10 +3245,7 @@
     stem: "dup02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup/dup02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3896,10 +3254,7 @@
     stem: "dup05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup/dup05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3908,10 +3263,7 @@
     stem: "dup04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup/dup04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3920,10 +3272,7 @@
     stem: "dup07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup/dup07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3932,10 +3281,7 @@
     stem: "dup06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup/dup06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3944,10 +3290,7 @@
     stem: "connect01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/connect/connect01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3956,10 +3299,7 @@
     stem: "pth_str03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/sched/pthreads/pth_str03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3968,10 +3308,7 @@
     stem: "pth_str02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/sched/pthreads/pth_str02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -3981,7 +3318,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/stat/stat05.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/stat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -3995,7 +3331,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/stat/stat06.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/stat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -4009,7 +3344,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/stat/stat01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/stat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -4023,7 +3357,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/stat/stat03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/stat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -4037,7 +3370,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/stat/stat02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/stat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -4050,10 +3382,7 @@
     stem: "readahead01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readahead/readahead01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4062,10 +3391,16 @@
     stem: "readahead02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readahead/readahead02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_getxattr02",
+    stem: "getxattr02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/getxattr/getxattr02.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4074,22 +3409,16 @@
     stem: "newuname01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/newuname/newuname01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_getsockopt01",
-    stem: "getsockopt01",
+    name: "ltp_getxattr01",
+    stem: "getxattr01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/getsockopt/getsockopt01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/getxattr/getxattr01.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4099,10 +3428,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/page/page02.c"],
     cflags: ["-DLINUX"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4111,10 +3437,7 @@
     stem: "setpgrp01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setpgrp/setpgrp01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4123,10 +3446,7 @@
     stem: "gettid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/gettid/gettid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4135,10 +3455,7 @@
     stem: "setpgrp02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setpgrp/setpgrp02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4147,10 +3464,7 @@
     stem: "mlockall03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mlockall/mlockall03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4159,10 +3473,7 @@
     stem: "mlockall02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mlockall/mlockall02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4171,10 +3482,7 @@
     stem: "mlockall01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mlockall/mlockall01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4183,10 +3491,7 @@
     stem: "syslogtst",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/syslog/syslogtst.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4195,10 +3500,7 @@
     stem: "set_robust_list01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/set_robust_list/set_robust_list01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4207,10 +3509,16 @@
     stem: "getdents01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getdents/getdents01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_timerfd_create01",
+    stem: "timerfd_create01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/timerfd/timerfd_create01.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4219,10 +3527,7 @@
     stem: "getdents02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getdents/getdents02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4231,10 +3536,7 @@
     stem: "open09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4243,10 +3545,7 @@
     stem: "open08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4255,10 +3554,7 @@
     stem: "quotactl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/quotactl/quotactl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4267,10 +3563,7 @@
     stem: "llseek01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/llseek/llseek01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4279,10 +3572,7 @@
     stem: "open04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4291,10 +3581,7 @@
     stem: "llseek03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/llseek/llseek03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4303,10 +3590,7 @@
     stem: "llseek02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/llseek/llseek02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4315,10 +3599,7 @@
     stem: "open01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4328,7 +3609,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_def_task01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -4343,10 +3623,7 @@
     stem: "open03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4355,10 +3632,7 @@
     stem: "open02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4367,10 +3641,7 @@
     stem: "getpgid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpgid/getpgid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4379,10 +3650,7 @@
     stem: "renameat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/renameat/renameat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4391,10 +3659,7 @@
     stem: "getpgid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpgid/getpgid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4403,10 +3668,7 @@
     stem: "rmdir03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rmdir/rmdir03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4415,10 +3677,7 @@
     stem: "ima_boot_aggregate",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
     shared_libs: [
         "libdl",
@@ -4432,7 +3691,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cgroup_fj/cgroup_fj_proc.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -4444,10 +3702,7 @@
     stem: "personality01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/personality/personality01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4456,20 +3711,18 @@
     stem: "personality02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/personality/personality02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_write05",
-    stem: "write05",
+    name: "ltp_timer_create03",
+    stem: "timer_create03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/write/write05.c"],
+    srcs: ["testcases/kernel/timers/timer_create/timer_create03.c"],
+    cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
+        "testcases/kernel/timers/include",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
@@ -4480,10 +3733,7 @@
     stem: "setrlimit01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setrlimit/setrlimit01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4492,10 +3742,7 @@
     stem: "syslog11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/syslog/syslog11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4504,10 +3751,7 @@
     stem: "setrlimit03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setrlimit/setrlimit03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4516,10 +3760,7 @@
     stem: "setrlimit02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setrlimit/setrlimit02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4528,10 +3769,7 @@
     stem: "symlink01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/symlink/symlink01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4548,10 +3786,7 @@
     stem: "mkdir01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdir/mkdir01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4560,10 +3795,7 @@
     stem: "symlink05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/symlink/symlink05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4572,10 +3804,7 @@
     stem: "sendto01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendto/sendto01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4588,10 +3817,7 @@
         "-D_LARGEFILE_SOURCE",
         "-D_LARGEFILE64_SOURCE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4600,10 +3826,7 @@
     stem: "sched_setaffinity01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4612,10 +3835,7 @@
     stem: "bind02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/bind/bind02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4624,10 +3844,7 @@
     stem: "bind01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/bind/bind01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4636,10 +3853,7 @@
     stem: "sched_yield01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_yield/sched_yield01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4656,10 +3870,7 @@
     stem: "request_key01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/request_key/request_key01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4669,7 +3880,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_latency_check_task.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -4686,7 +3896,6 @@
     srcs: ["testcases/kernel/timers/timer_create/timer_create04.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -4698,10 +3907,7 @@
     stem: "mmapstress04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4710,10 +3916,7 @@
     stem: "mmapstress07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4722,10 +3925,7 @@
     stem: "delete_module02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/module/delete_module/delete_module02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4734,10 +3934,7 @@
     stem: "setpriority02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setpriority/setpriority02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4754,10 +3951,7 @@
     stem: "waitpid05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4766,10 +3960,7 @@
     stem: "mmap09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4778,22 +3969,17 @@
     stem: "mmap08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_poll01",
-    stem: "poll01",
+    name: "ltp_cve-2017-5669",
+    stem: "cve-2017-5669",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/poll/poll01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/cve/cve-2017-5669.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4802,10 +3988,7 @@
     stem: "mmap03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4814,10 +3997,7 @@
     stem: "mmap02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4826,10 +4006,7 @@
     stem: "mmap01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4855,10 +4032,7 @@
     stem: "mmap07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4867,10 +4041,7 @@
     stem: "mmap06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4879,10 +4050,7 @@
     stem: "mmap05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4891,10 +4059,7 @@
     stem: "mmap04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4903,10 +4068,7 @@
     stem: "rt_sigprocmask01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4915,10 +4077,7 @@
     stem: "select02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/select/select02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4927,10 +4086,7 @@
     stem: "rt_sigprocmask02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4939,10 +4095,7 @@
     stem: "readlinkat02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readlinkat/readlinkat02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4951,10 +4104,7 @@
     stem: "readlinkat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readlinkat/readlinkat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4963,10 +4113,7 @@
     stem: "tst_sleep",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/lib/tst_sleep.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4975,10 +4122,7 @@
     stem: "sigaltstack01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigaltstack/sigaltstack01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4987,10 +4131,7 @@
     stem: "ssetmask01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ssetmask/ssetmask01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -4999,10 +4140,7 @@
     stem: "sigaltstack02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigaltstack/sigaltstack02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5012,7 +4150,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cgroup/getdelays.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -5032,10 +4169,7 @@
     stem: "float_trigo",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/math/float/float_trigo.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5070,7 +4204,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cgroup/test_6_2.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -5082,10 +4215,16 @@
     stem: "fchmodat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmodat/fchmodat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_tee01",
+    stem: "tee01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/tee/tee01.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5094,10 +4233,7 @@
     stem: "epoll_ctl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5106,10 +4242,7 @@
     stem: "sched_setscheduler01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5118,10 +4251,7 @@
     stem: "epoll_ctl02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5130,10 +4260,7 @@
     stem: "rtc01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/rtc/rtc01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5143,7 +4270,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pselect/pselect01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pselect",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5156,10 +4282,7 @@
     stem: "mmap1",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mtest06/mmap1.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5168,10 +4291,7 @@
     stem: "capget02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/capget/capget02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5180,10 +4300,7 @@
     stem: "socketcall02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socketcall/socketcall02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5192,10 +4309,7 @@
     stem: "ioperm01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ioperm/ioperm01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5206,8 +4320,8 @@
     srcs: ["testcases/kernel/syscalls/mbind/mbind01.c"],
     cflags: ["-Wno-unused"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
+        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: [
@@ -5221,10 +4335,7 @@
     stem: "request_key02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/request_key/request_key02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5234,7 +4345,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pselect/pselect03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pselect",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5247,10 +4357,7 @@
     stem: "execlp01_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execlp/execlp01_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5259,10 +4366,7 @@
     stem: "futex_wait_bitset01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wait_bitset01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5279,10 +4383,7 @@
     stem: "futex_wait_bitset02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/futex/futex_wait_bitset02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5292,10 +4393,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mount/mount05.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5305,10 +4403,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mount/mount04.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5317,10 +4412,7 @@
     stem: "memcmp01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/memcmp/memcmp01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5330,10 +4422,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mount/mount06.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5343,10 +4432,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mount/mount01.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5355,10 +4441,7 @@
     stem: "utime04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utime/utime04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5368,10 +4451,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mount/mount03.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5381,10 +4461,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mount/mount02.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5393,10 +4470,7 @@
     stem: "clone01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clone/clone01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5407,7 +4481,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl22.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5420,10 +4493,7 @@
     stem: "clone03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clone/clone03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5434,7 +4504,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl20.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5447,10 +4516,7 @@
     stem: "clone05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clone/clone05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5459,20 +4525,19 @@
     stem: "clone04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clone/clone04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_clone07",
-    stem: "clone07",
+    name: "ltp_fcntl25",
+    stem: "fcntl25",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/clone/clone07.c"],
+    srcs: ["testcases/kernel/syscalls/fcntl/fcntl25.c"],
+    cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
+        "testcases/kernel/syscalls/fcntl",
+        "testcases/kernel/syscalls/utils",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
@@ -5485,7 +4550,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl24.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5494,14 +4558,20 @@
 }
 
 cc_test {
+    name: "ltp_clone09",
+    stem: "clone09",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/clone/clone09.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_clone08",
     stem: "clone08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clone/clone08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5512,7 +4582,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl29.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5527,7 +4596,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl28.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5540,10 +4608,7 @@
     stem: "execl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execl/execl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5570,7 +4635,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pwritev/pwritev01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwritev",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5583,10 +4647,7 @@
     stem: "munlock01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/munlock/munlock01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5597,7 +4658,6 @@
     srcs: ["testcases/network/tcp_cmds/echo/echoes.c"],
     cflags: ["-DDEBUG"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/network/tcp_cmds/include",
         "include/old",
     ],
@@ -5610,7 +4670,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pwritev/pwritev02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwritev",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -5623,10 +4682,7 @@
     stem: "gethostbyname_r01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/gethostbyname_r/gethostbyname_r01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5635,10 +4691,7 @@
     stem: "listxattr03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/listxattr/listxattr03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5647,10 +4700,7 @@
     stem: "listxattr02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/listxattr/listxattr02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5660,10 +4710,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/sched/nptl/nptl01.c"],
     cflags: ["-DUSING_NPTL"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5680,10 +4727,7 @@
     stem: "sync_file_range01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sync_file_range/sync_file_range01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5692,10 +4736,7 @@
     stem: "waitid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitid/waitid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5704,10 +4745,7 @@
     stem: "delete_module01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/module/delete_module/delete_module01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5716,10 +4754,7 @@
     stem: "waitid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitid/waitid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5728,10 +4763,7 @@
     stem: "tbio",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/tbio/tbio_user/tbio.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5740,10 +4772,7 @@
     stem: "munlock02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/munlock/munlock02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5752,10 +4781,17 @@
     stem: "fork_exec_loop",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/freezer/fork_exec_loop.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cve-2017-2671",
+    stem: "cve-2017-2671",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/cve/cve-2017-2671.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5781,10 +4817,7 @@
     stem: "rename14",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename14.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5793,10 +4826,7 @@
     stem: "rename12",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename12.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5805,10 +4835,7 @@
     stem: "rename13",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename13.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5817,10 +4844,7 @@
     stem: "rename10",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5829,10 +4853,7 @@
     stem: "rename11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5850,10 +4871,7 @@
     stem: "fw_load",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/firmware/fw_load_user/fw_load.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5862,10 +4880,7 @@
     stem: "unshare01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/unshare/unshare01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5874,10 +4889,7 @@
     stem: "signalfd4_02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signalfd4/signalfd4_02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5886,10 +4898,7 @@
     stem: "unshare02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/unshare/unshare02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5898,10 +4907,7 @@
     stem: "fptest02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/math/fptests/fptest02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5910,10 +4916,7 @@
     stem: "smack_set_socket_labels",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/smack/smack_set_socket_labels.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5922,10 +4925,7 @@
     stem: "unlinkat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/unlinkat/unlinkat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5935,7 +4935,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/tcp_cmds/sendfile/testsf_s.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/network/tcp_cmds/include",
         "include/old",
     ],
@@ -5948,22 +4947,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c"],
     cflags: ["-DTEST_SIGWAITINFO"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_nfs01_open_files",
-    stem: "nfs01_open_files",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/network/nfs/nfs_stress/nfs01_open_files.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -5989,10 +4973,16 @@
     stem: "clock_nanosleep01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_clock_nanosleep02",
+    stem: "clock_nanosleep02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6001,10 +4991,7 @@
     stem: "readdir01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readdir/readdir01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6014,10 +5001,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/filecaps/check_simple_capset.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6044,7 +5028,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl_fj/cpuctl_fj_simple_echo.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -6056,10 +5039,7 @@
     stem: "delete_module03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/module/delete_module/delete_module03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6069,10 +5049,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/filecaps/inh_capped.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6082,7 +5059,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl_fj/cpuctl_fj_cpu-hog.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -6094,10 +5070,7 @@
     stem: "removexattr01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/removexattr/removexattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6106,10 +5079,7 @@
     stem: "removexattr02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/removexattr/removexattr02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6118,10 +5088,7 @@
     stem: "writev02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/writev/writev02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6130,10 +5097,7 @@
     stem: "exit01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/exit/exit01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6151,10 +5115,7 @@
     stem: "socketpair01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socketpair/socketpair01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6163,10 +5124,7 @@
     stem: "exit02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/exit/exit02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6179,10 +5137,7 @@
         "-D_FILE_OFFSET_BITS=64",
         "-D_LARGEFILE_SOURCE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6191,10 +5146,7 @@
     stem: "writev01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/writev/writev01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6212,10 +5164,7 @@
     stem: "fptest01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/math/fptests/fptest01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6224,10 +5173,7 @@
     stem: "writev07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/writev/writev07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6236,10 +5182,7 @@
     stem: "float_iperb",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/math/float/float_iperb.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6256,10 +5199,7 @@
     stem: "writev06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/writev/writev06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6276,10 +5216,7 @@
     stem: "writev05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/writev/writev05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6288,10 +5225,7 @@
     stem: "sched_get_priority_max01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_get_priority_max/sched_get_priority_max01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6300,10 +5234,7 @@
     stem: "rename09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rename/rename09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6312,10 +5243,7 @@
     stem: "cpufreq_boost",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6324,10 +5252,7 @@
     stem: "times01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/times/times01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6336,10 +5261,7 @@
     stem: "getrandom04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrandom/getrandom04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6348,10 +5270,7 @@
     stem: "times03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/times/times03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6360,10 +5279,7 @@
     stem: "getrandom01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrandom/getrandom01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6372,10 +5288,7 @@
     stem: "getrandom03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrandom/getrandom03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6384,10 +5297,7 @@
     stem: "getrandom02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrandom/getrandom02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6396,10 +5306,7 @@
     stem: "add_key01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/add_key/add_key01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6409,7 +5316,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/memcg/stress/memcg_process_stress.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -6425,10 +5331,7 @@
         "-D_FILE_OFFSET_BITS=64",
         "-D_LARGEFILE_SOURCE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6437,23 +5340,25 @@
     stem: "add_key02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/add_key/add_key02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_tomoyo_file_test",
-    stem: "tomoyo_file_test",
+    name: "ltp_thp02",
+    stem: "thp02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/security/tomoyo/tomoyo_file_test.c"],
+    srcs: ["testcases/kernel/mem/thp/thp02.c"],
     local_include_dirs: [
+        "testcases/kernel/mem/include",
         "testcases/kernel/include",
         "include/old",
     ],
-    static_libs: ["libltp_ltp"],
+    static_libs: [
+        "libltp_mem",
+        "libltp_kerntest",
+        "libltp_ltp",
+    ],
 }
 
 cc_test {
@@ -6461,10 +5366,7 @@
     stem: "fs_perms",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/fs_perms/fs_perms.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6473,10 +5375,7 @@
     stem: "exec_with_inh",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/cap_bound/exec_with_inh.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6485,10 +5384,7 @@
     stem: "recv01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/recv/recv01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6513,10 +5409,7 @@
     stem: "utime01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utime/utime01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6525,10 +5418,7 @@
     stem: "sysconf01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysconf/sysconf01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6538,10 +5428,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/page/page01.c"],
     cflags: ["-DLINUX"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6550,10 +5437,7 @@
     stem: "getitimer01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getitimer/getitimer01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6562,10 +5446,7 @@
     stem: "getitimer03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getitimer/getitimer03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6574,10 +5455,7 @@
     stem: "getitimer02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getitimer/getitimer02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6586,10 +5464,7 @@
     stem: "select01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/select/select01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6598,10 +5473,7 @@
     stem: "readdir21",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readdir/readdir21.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6610,10 +5482,7 @@
     stem: "sethostname02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sethostname/sethostname02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6627,10 +5496,7 @@
         "-DPF_CAN=29",
         "-DAF_CAN=PF_CAN",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6639,10 +5505,16 @@
     stem: "crash02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/crash/crash02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_tomoyo_new_test",
+    stem: "tomoyo_new_test",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/security/tomoyo/tomoyo_new_test.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6651,10 +5523,7 @@
     stem: "chroot04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chroot/chroot04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6663,10 +5532,7 @@
     stem: "chroot03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chroot/chroot03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6675,10 +5541,7 @@
     stem: "chroot02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chroot/chroot02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6687,10 +5550,7 @@
     stem: "chroot01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chroot/chroot01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6701,7 +5561,6 @@
     srcs: ["testcases/kernel/timers/timer_delete/timer_delete02.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -6713,10 +5572,16 @@
     stem: "adjtimex01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/adjtimex/adjtimex01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_tst_net_ip_prefix",
+    stem: "tst_net_ip_prefix",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/lib/tst_net_ip_prefix.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6725,10 +5590,7 @@
     stem: "adjtimex02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/adjtimex/adjtimex02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6737,10 +5599,7 @@
     stem: "umount01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/umount/umount01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6749,10 +5608,7 @@
     stem: "keyctl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/keyctl/keyctl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6761,10 +5617,7 @@
     stem: "keyctl03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/keyctl/keyctl03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6773,22 +5626,25 @@
     stem: "keyctl02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/keyctl/keyctl02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_timerfd_create01",
-    stem: "timerfd_create01",
+    name: "ltp_keyctl05",
+    stem: "keyctl05",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/timerfd/timerfd_create01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/keyctl/keyctl05.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_keyctl04",
+    stem: "keyctl04",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/keyctl/keyctl04.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6805,10 +5661,7 @@
     stem: "mem01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mem/mem01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6817,10 +5670,7 @@
     stem: "setpgid03_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setpgid/setpgid03_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6829,10 +5679,7 @@
     stem: "open12_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open12_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6841,10 +5688,7 @@
     stem: "symlink02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/symlink/symlink02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6853,10 +5697,7 @@
     stem: "cgroup_xattr",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cgroup_xattr/cgroup_xattr.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6878,14 +5719,11 @@
 }
 
 cc_test {
-    name: "ltp_cap_bset_inh_bounds",
-    stem: "cap_bset_inh_bounds",
+    name: "ltp_mmapstress03",
+    stem: "mmapstress03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/security/cap_bound/cap_bset_inh_bounds.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/mem/mmapstress/mmapstress03.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6895,10 +5733,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/filecaps/print_caps.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6907,10 +5742,7 @@
     stem: "mem02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mem/mem02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6919,10 +5751,7 @@
     stem: "mmapstress02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -6932,7 +5761,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/pids/pids_task1.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -6945,7 +5773,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pselect/pselect02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pselect",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -6959,7 +5786,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/pids/pids_task2.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -6971,10 +5797,7 @@
     stem: "umask01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/umask/umask01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7000,34 +5823,25 @@
     stem: "getxattr03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getxattr/getxattr03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_getxattr02",
-    stem: "getxattr02",
+    name: "ltp_getsockopt02",
+    stem: "getsockopt02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/getxattr/getxattr02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/getsockopt/getsockopt02.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_getxattr01",
-    stem: "getxattr01",
+    name: "ltp_getsockopt01",
+    stem: "getsockopt01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/getxattr/getxattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/getsockopt/getsockopt01.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7052,10 +5866,7 @@
     stem: "getxattr04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getxattr/getxattr04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7064,10 +5875,7 @@
     stem: "getpid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpid/getpid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7076,10 +5884,7 @@
     stem: "getpid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpid/getpid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7088,10 +5893,7 @@
     stem: "sysinfo02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysinfo/sysinfo02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7100,10 +5902,7 @@
     stem: "setsockopt01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setsockopt/setsockopt01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7129,10 +5928,7 @@
     stem: "setxattr03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setxattr/setxattr03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7141,10 +5937,7 @@
     stem: "setxattr02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setxattr/setxattr02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7153,10 +5946,7 @@
     stem: "setxattr01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setxattr/setxattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7165,10 +5955,7 @@
     stem: "utime02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utime/utime02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7178,7 +5965,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/preadv/preadv01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/preadv",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -7191,10 +5977,7 @@
     stem: "mmapstress05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7204,7 +5987,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/preadv/preadv02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/preadv",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -7217,10 +5999,7 @@
     stem: "utime05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utime/utime05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7230,10 +6009,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mount/setuid_test.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7242,10 +6018,7 @@
     stem: "open05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7254,10 +6027,7 @@
     stem: "getcpu01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getcpu/getcpu01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7266,10 +6036,7 @@
     stem: "dirtyc0w",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/dirtyc0w/dirtyc0w.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7278,10 +6045,16 @@
     stem: "epoll_wait01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/epoll_wait/epoll_wait01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_tst_net_vars",
+    stem: "tst_net_vars",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/lib/tst_net_vars.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7290,10 +6063,7 @@
     stem: "epoll_wait03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/epoll_wait/epoll_wait03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7302,10 +6072,7 @@
     stem: "epoll_wait02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/epoll_wait/epoll_wait02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7314,10 +6081,7 @@
     stem: "madvise01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/madvise/madvise01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7326,10 +6090,7 @@
     stem: "event_generator",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/connectors/pec/event_generator.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7338,10 +6099,7 @@
     stem: "umount02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/umount/umount02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7350,10 +6108,7 @@
     stem: "pipe01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7364,7 +6119,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl23.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -7377,10 +6131,7 @@
     stem: "pipe03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7389,10 +6140,7 @@
     stem: "pipe02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7401,10 +6149,7 @@
     stem: "pipe05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7413,10 +6158,7 @@
     stem: "pipe04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7425,10 +6167,7 @@
     stem: "pipe07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7437,10 +6176,7 @@
     stem: "pipe06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7449,10 +6185,7 @@
     stem: "pipe09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7461,10 +6194,7 @@
     stem: "pipe08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7475,7 +6205,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl21.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -7489,10 +6218,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c"],
     cflags: ["-DTEST_SIGTIMEDWAIT"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7501,10 +6227,7 @@
     stem: "sethostname01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sethostname/sethostname01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7530,10 +6253,7 @@
     stem: "sethostname03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sethostname/sethostname03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7542,20 +6262,17 @@
     stem: "clone02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clone/clone02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_tomoyo_new_test",
-    stem: "tomoyo_new_test",
+    name: "ltp_memcg_test_3",
+    stem: "memcg_test_3",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/security/tomoyo/tomoyo_new_test.c"],
+    srcs: ["testcases/kernel/controllers/memcg/regression/memcg_test_3.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
+        "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
@@ -7566,10 +6283,7 @@
     stem: "flistxattr03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flistxattr/flistxattr03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7578,10 +6292,7 @@
     stem: "flistxattr02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flistxattr/flistxattr02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7590,10 +6301,7 @@
     stem: "flistxattr01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/flistxattr/flistxattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7602,10 +6310,7 @@
     stem: "fchdir01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchdir/fchdir01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7614,10 +6319,7 @@
     stem: "fchdir03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchdir/fchdir03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7626,10 +6328,7 @@
     stem: "fchdir02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchdir/fchdir02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7638,10 +6337,7 @@
     stem: "munlockall01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/munlockall/munlockall01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7650,10 +6346,7 @@
     stem: "mknod01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknod/mknod01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7662,25 +6355,16 @@
     stem: "munlockall02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/munlockall/munlockall02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_fcntl25",
-    stem: "fcntl25",
+    name: "ltp_clone07",
+    stem: "clone07",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/fcntl/fcntl25.c"],
-    cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "testcases/kernel/syscalls/fcntl",
-        "testcases/kernel/syscalls/utils",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/clone/clone07.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7689,10 +6373,7 @@
     stem: "open07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7718,10 +6399,7 @@
     stem: "clone06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clone/clone06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7747,10 +6425,7 @@
     stem: "signalfd4_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signalfd4/signalfd4_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7759,10 +6434,7 @@
     stem: "inotify06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/inotify/inotify06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7771,10 +6443,7 @@
     stem: "sysctl03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysctl/sysctl03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7791,10 +6460,7 @@
     stem: "mmap-corruption01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmap-corruption01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7815,10 +6481,7 @@
     stem: "mknod05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknod/mknod05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7827,10 +6490,7 @@
     stem: "readlink02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/readlink/readlink02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7841,8 +6501,8 @@
     srcs: ["testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c"],
     local_include_dirs: [
         "testcases/kernel/mem/include",
-        "testcases/kernel/include",
         "testcases/kernel/mem/hugetlb/lib",
+        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: [
@@ -7858,10 +6518,7 @@
     stem: "timerfd_gettime01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/timerfd/timerfd_gettime01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7872,8 +6529,8 @@
     srcs: ["testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c"],
     local_include_dirs: [
         "testcases/kernel/mem/include",
-        "testcases/kernel/include",
         "testcases/kernel/mem/hugetlb/lib",
+        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: [
@@ -7889,10 +6546,7 @@
     stem: "tomoyo_filesystem_test",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7901,10 +6555,7 @@
     stem: "signal02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signal/signal02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7913,10 +6564,7 @@
     stem: "mknod07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknod/mknod07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7925,10 +6573,7 @@
     stem: "open06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7941,14 +6586,11 @@
 }
 
 cc_test {
-    name: "ltp_mknod06",
-    stem: "mknod06",
+    name: "ltp_inotify02",
+    stem: "inotify02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/mknod/mknod06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/inotify/inotify02.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7957,10 +6599,7 @@
     stem: "lseek01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lseek/lseek01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -7970,7 +6609,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendfile/sendfile08.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/sendfile",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -7979,15 +6617,11 @@
 }
 
 cc_test {
-    name: "ltp_lseek03",
-    stem: "lseek03",
+    name: "ltp_gentan",
+    stem: "gentan",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
+    srcs: ["testcases/misc/math/float/trigo/gentan.c"],
+    local_include_dirs: ["include/old"],
 }
 
 cc_test {
@@ -7995,10 +6629,7 @@
     stem: "lseek02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lseek/lseek02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8007,10 +6638,7 @@
     stem: "epoll-ltp",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/epoll/epoll-ltp.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8027,34 +6655,7 @@
     stem: "lseek07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lseek/lseek07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_lseek06",
-    stem: "lseek06",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_lseek09",
-    stem: "lseek09",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8065,7 +6666,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl27.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8079,7 +6679,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendfile/sendfile03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/sendfile",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8088,16 +6687,12 @@
 }
 
 cc_test {
-    name: "ltp_sendfile02",
-    stem: "sendfile02",
+    name: "ltp_cve-2017-2618",
+    stem: "cve-2017-2618",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/sendfile/sendfile02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "testcases/kernel/syscalls/sendfile",
-        "testcases/kernel/syscalls/utils",
-        "include/old",
-    ],
+    srcs: ["testcases/cve/cve-2017-2618.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8107,7 +6702,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendfile/sendfile05.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/sendfile",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8120,10 +6714,7 @@
     stem: "execl01_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execl/execl01_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8133,7 +6724,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendfile/sendfile07.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/sendfile",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8147,7 +6737,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendfile/sendfile06.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/sendfile",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8160,10 +6749,7 @@
     stem: "signal05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signal/signal05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8173,7 +6759,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/memcg/regression/memcg_test_1.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -8185,10 +6770,7 @@
     stem: "smack_notroot",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/smack/smack_notroot.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8197,10 +6779,7 @@
     stem: "open14",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open14.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8217,10 +6796,7 @@
     stem: "open13",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open13.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8229,10 +6805,7 @@
     stem: "open10",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8241,10 +6814,7 @@
     stem: "open11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/open/open11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8255,7 +6825,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl26.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8268,10 +6837,7 @@
     stem: "sched_getaffinity01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8280,10 +6846,7 @@
     stem: "getcwd04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getcwd/getcwd04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8293,10 +6856,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/lib6/in6_02.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8305,10 +6865,7 @@
     stem: "getcwd01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getcwd/getcwd01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8317,10 +6874,7 @@
     stem: "getcwd03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getcwd/getcwd03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8330,10 +6884,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getcwd/getcwd02.c"],
     cflags: ["-U_FORTIFY_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8350,10 +6901,7 @@
     stem: "timerfd_settime01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/timerfd/timerfd_settime01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8364,8 +6912,8 @@
     srcs: ["testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c"],
     local_include_dirs: [
         "testcases/kernel/mem/include",
-        "testcases/kernel/include",
         "testcases/kernel/mem/hugetlb/lib",
+        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: [
@@ -8382,7 +6930,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/recvmsg/recvmsg01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
     ],
@@ -8395,7 +6942,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/recvmsg/recvmsg03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
     ],
@@ -8408,7 +6954,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/recvmsg/recvmsg02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
     ],
@@ -8421,7 +6966,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mremap/mremap01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -8436,10 +6980,7 @@
     stem: "ltp_acpi",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/acpi/ltp_acpi.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8449,7 +6990,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mremap/mremap03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -8465,7 +7005,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mremap/mremap02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -8481,7 +7020,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mremap/mremap05.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -8496,10 +7034,7 @@
     stem: "mmap001",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap001.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8508,10 +7043,7 @@
     stem: "lgetxattr01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lgetxattr/lgetxattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8520,10 +7052,7 @@
     stem: "pause03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pause/pause03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8532,10 +7061,7 @@
     stem: "lgetxattr02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lgetxattr/lgetxattr02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8544,10 +7070,7 @@
     stem: "tomoyo_accept_test",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/tomoyo/tomoyo_accept_test.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8556,10 +7079,7 @@
     stem: "sysinfo01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysinfo/sysinfo01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8568,10 +7088,7 @@
     stem: "mmap14",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap14.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8580,10 +7097,7 @@
     stem: "mmap15",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap15.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8592,10 +7106,7 @@
     stem: "mmap16",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap16.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8604,10 +7115,7 @@
     stem: "mmap10",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8616,10 +7124,7 @@
     stem: "mmap11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8628,10 +7133,7 @@
     stem: "mmap12",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap12.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8640,10 +7142,7 @@
     stem: "mmap13",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mmap/mmap13.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8652,10 +7151,7 @@
     stem: "sysctl05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysctl/sysctl05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8664,10 +7160,7 @@
     stem: "sysctl04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysctl/sysctl04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8676,10 +7169,7 @@
     stem: "utime03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utime/utime03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8696,10 +7186,7 @@
     stem: "getrlimit01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrlimit/getrlimit01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8708,10 +7195,7 @@
     stem: "check_keepcaps",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/securebits/check_keepcaps.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8720,10 +7204,7 @@
     stem: "getrlimit02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrlimit/getrlimit02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8732,10 +7213,7 @@
     stem: "utimensat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/utimensat/utimensat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8744,10 +7222,7 @@
     stem: "nice04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/nice/nice04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8756,10 +7231,7 @@
     stem: "unlink07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/unlink/unlink07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8776,10 +7248,7 @@
     stem: "nice03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/nice/nice03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8788,22 +7257,16 @@
     stem: "cap_bounds_r",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/cap_bound/cap_bounds_r.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_nice02",
-    stem: "nice02",
+    name: "ltp_execve04",
+    stem: "execve04",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/nice/nice02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/execve/execve04.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8827,7 +7290,6 @@
     cflags: ["-D_LARGEFILE64_SOURCE"],
     local_include_dirs: [
         "testcases/kernel/fs/doio/include",
-        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
@@ -8838,10 +7300,7 @@
     stem: "access04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/access/access04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8850,10 +7309,7 @@
     stem: "epoll_create1_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8862,10 +7318,7 @@
     stem: "renameat202",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/renameat2/renameat202.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8874,10 +7327,7 @@
     stem: "unlink06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/unlink/unlink06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8886,8 +7336,8 @@
     stem: "pwrite04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pwrite/pwrite04.c"],
+    cflags: ["-Wno-error"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwrite",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8900,8 +7350,8 @@
     stem: "pwrite02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pwrite/pwrite02.c"],
+    cflags: ["-Wno-error"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwrite",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8914,8 +7364,8 @@
     stem: "pwrite01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pwrite/pwrite01.c"],
+    cflags: ["-Wno-error"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwrite",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -8924,14 +7374,20 @@
 }
 
 cc_test {
+    name: "ltp_splice05",
+    stem: "splice05",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/splice/splice05.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_setitimer01",
     stem: "setitimer01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setitimer/setitimer01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8940,10 +7396,7 @@
     stem: "stack_space",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/vmtests/stack_space.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8952,10 +7405,7 @@
     stem: "splice01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/splice/splice01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8964,10 +7414,7 @@
     stem: "splice03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/splice/splice03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8976,10 +7423,7 @@
     stem: "splice02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/splice/splice02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -8988,10 +7432,7 @@
     stem: "getresuid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getresuid/getresuid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9000,10 +7441,7 @@
     stem: "socket01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socket/socket01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9020,10 +7458,7 @@
     stem: "setitimer03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setitimer/setitimer03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9032,10 +7467,7 @@
     stem: "time-schedule",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/sched/tool/time-schedule.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9044,10 +7476,7 @@
     stem: "float_power",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/math/float/float_power.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9056,10 +7485,7 @@
     stem: "setitimer02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setitimer/setitimer02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9077,10 +7503,7 @@
     stem: "ioperm02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ioperm/ioperm02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9089,10 +7512,7 @@
     stem: "setdomainname02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setdomainname/setdomainname02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9109,10 +7529,7 @@
     stem: "timer_gettime01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/timer_gettime/timer_gettime01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9122,7 +7539,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendfile/sendfile09.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/sendfile",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -9136,10 +7552,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/pty/ptem01.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9148,19 +7561,8 @@
     stem: "swapoff02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/swapoff/swapoff02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_gentan",
-    stem: "gentan",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/misc/math/float/trigo/gentan.c"],
     local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -9170,7 +7572,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl30.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -9183,10 +7584,7 @@
     stem: "getpeername01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpeername/getpeername01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9197,7 +7595,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl32.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -9212,7 +7609,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl33.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -9227,7 +7623,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl34.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -9236,18 +7631,44 @@
 }
 
 cc_test {
-    name: "ltp_lseek04",
-    stem: "lseek04",
+    name: "ltp_fcntl35",
+    stem: "fcntl35",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek04.c"],
+    srcs: ["testcases/kernel/syscalls/fcntl/fcntl35.c"],
+    cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
+        "testcases/kernel/syscalls/fcntl",
+        "testcases/kernel/syscalls/utils",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
+    name: "ltp_fcntl36",
+    stem: "fcntl36",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/fcntl/fcntl36.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: [
+        "testcases/kernel/syscalls/fcntl",
+        "testcases/kernel/syscalls/utils",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cve-2016-7117",
+    stem: "cve-2016-7117",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/cve/cve-2016-7117.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_test03",
     stem: "test03",
     defaults: ["ltp_test_defaults"],
@@ -9315,10 +7736,7 @@
     stem: "accept4_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/accept4/accept4_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9346,7 +7764,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_def_task04.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -9361,10 +7778,7 @@
     stem: "endian_switch01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/switch/endian_switch01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9373,10 +7787,7 @@
     stem: "socketcall03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socketcall/socketcall03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9385,10 +7796,7 @@
     stem: "sendto02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendto/sendto02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9397,10 +7805,7 @@
     stem: "memcpy01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/memcpy/memcpy01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9409,10 +7814,7 @@
     stem: "sched_rr_get_interval01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9421,10 +7823,7 @@
     stem: "sigrelse01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sigrelse/sigrelse01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9433,22 +7832,7 @@
     stem: "waitpid08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_lseek08",
-    stem: "lseek08",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9457,10 +7841,7 @@
     stem: "sysfs05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysfs/sysfs05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9469,10 +7850,7 @@
     stem: "waitpid04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9481,10 +7859,7 @@
     stem: "waitpid07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9493,10 +7868,7 @@
     stem: "waitpid06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9505,10 +7877,7 @@
     stem: "waitpid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9518,7 +7887,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/io-throttle/iobw.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -9533,10 +7901,7 @@
     stem: "waitpid03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9545,10 +7910,7 @@
     stem: "waitpid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9557,10 +7919,7 @@
     stem: "alarm01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/alarm/alarm01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9569,10 +7928,7 @@
     stem: "sched_setscheduler02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9581,10 +7937,7 @@
     stem: "alarm03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/alarm/alarm03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9593,10 +7946,7 @@
     stem: "alarm02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/alarm/alarm02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9605,10 +7955,7 @@
     stem: "alarm05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/alarm/alarm05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9617,10 +7964,7 @@
     stem: "netstress",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/netstress/netstress.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9629,10 +7973,7 @@
     stem: "alarm07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/alarm/alarm07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9641,10 +7982,7 @@
     stem: "alarm06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/alarm/alarm06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9653,10 +7991,7 @@
     stem: "msync01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/msync/msync01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9665,10 +8000,7 @@
     stem: "msync03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/msync/msync03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9677,10 +8009,16 @@
     stem: "msync02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/msync/msync02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_msync04",
+    stem: "msync04",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/msync/msync04.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9690,7 +8028,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendfile/sendfile04.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/sendfile",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -9703,10 +8040,7 @@
     stem: "fchownat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchownat/fchownat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9715,10 +8049,7 @@
     stem: "tomoyo_new_file_test",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/tomoyo/tomoyo_new_file_test.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9727,10 +8058,7 @@
     stem: "tomoyo_rewrite_test",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/tomoyo/tomoyo_rewrite_test.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9739,10 +8067,7 @@
     stem: "fchownat02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchownat/fchownat02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9755,10 +8080,7 @@
         "-DGLIBC_SIGACTION_BUG=1",
         "-D_GNU_SOURCE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9771,10 +8093,7 @@
         "-DGLIBC_SIGACTION_BUG=1",
         "-D_GNU_SOURCE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9783,10 +8102,7 @@
     stem: "fchmod03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmod/fchmod03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9795,10 +8111,7 @@
     stem: "fchmod02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmod/fchmod02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9807,10 +8120,7 @@
     stem: "fchmod01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmod/fchmod01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9819,10 +8129,7 @@
     stem: "fchmod07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmod/fchmod07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9831,10 +8138,7 @@
     stem: "fchmod06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmod/fchmod06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9843,10 +8147,7 @@
     stem: "fchmod05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmod/fchmod05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9855,10 +8156,7 @@
     stem: "fchmod04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fchmod/fchmod04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9876,10 +8174,7 @@
     stem: "socketcall01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socketcall/socketcall01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9888,10 +8183,7 @@
     stem: "pipe2_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe2/pipe2_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9900,10 +8192,7 @@
     stem: "pipe2_02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe2/pipe2_02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9912,10 +8201,7 @@
     stem: "signal01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signal/signal01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9924,10 +8210,7 @@
     stem: "symlinkat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/symlinkat/symlinkat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9944,10 +8227,7 @@
     stem: "iopl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/iopl/iopl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9956,10 +8236,7 @@
     stem: "mprotect01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mprotect/mprotect01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9976,10 +8253,7 @@
     stem: "signal03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signal/signal03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -9988,10 +8262,7 @@
     stem: "ppoll01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ppoll/ppoll01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10000,10 +8271,7 @@
     stem: "stream04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/stream/stream04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10012,10 +8280,7 @@
     stem: "read03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/read/read03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10024,10 +8289,7 @@
     stem: "read02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/read/read02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10036,10 +8298,7 @@
     stem: "read04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/read/read04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10048,10 +8307,7 @@
     stem: "unlink08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/unlink/unlink08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10061,7 +8317,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cgroup/fork_processes.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -10073,10 +8328,7 @@
     stem: "signalfd01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signalfd/signalfd01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10085,10 +8337,7 @@
     stem: "timer_getoverrun01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10097,10 +8346,7 @@
     stem: "mknod02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mknod/mknod02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10109,10 +8355,7 @@
     stem: "sysfs06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysfs/sysfs06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10121,10 +8364,7 @@
     stem: "openat03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/openat/openat03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10133,10 +8373,7 @@
     stem: "openat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/openat/openat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10146,7 +8383,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill10.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -10161,10 +8397,7 @@
     stem: "setdomainname03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setdomainname/setdomainname03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10173,10 +8406,7 @@
     stem: "perf_event_open01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/perf_event_open/perf_event_open01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10194,7 +8424,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill11.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -10209,10 +8438,7 @@
     stem: "stream02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/stream/stream02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10221,10 +8447,7 @@
     stem: "vfork",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/freezer/vfork.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10233,10 +8456,7 @@
     stem: "tkill01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/tkill/tkill01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10245,10 +8465,7 @@
     stem: "getpagesize01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpagesize/getpagesize01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10266,10 +8483,7 @@
     stem: "stream03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/stream/stream03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10278,10 +8492,7 @@
     stem: "uaccess",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/uaccess/uaccess.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10290,10 +8501,7 @@
     stem: "sysfs01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysfs/sysfs01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10302,10 +8510,7 @@
     stem: "sysfs04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysfs/sysfs04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10314,10 +8519,7 @@
     stem: "getppid01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getppid/getppid01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10326,10 +8528,7 @@
     stem: "creat08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/creat/creat08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10338,10 +8537,7 @@
     stem: "sysfs03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysfs/sysfs03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10350,10 +8546,7 @@
     stem: "getppid02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getppid/getppid02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10362,10 +8555,7 @@
     stem: "creat05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/creat/creat05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10374,10 +8564,7 @@
     stem: "creat04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/creat/creat04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10386,10 +8573,7 @@
     stem: "creat07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/creat/creat07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10398,10 +8582,7 @@
     stem: "creat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/creat/creat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10410,10 +8591,7 @@
     stem: "signal04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signal/signal04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10422,10 +8600,7 @@
     stem: "creat03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/creat/creat03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10434,10 +8609,7 @@
     stem: "signal06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/signal/signal06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10454,10 +8626,7 @@
     stem: "link08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/link/link08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10466,10 +8635,7 @@
     stem: "write03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/write/write03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10478,10 +8644,7 @@
     stem: "gethostname01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/gethostname/gethostname01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10490,10 +8653,7 @@
     stem: "link04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/link/link04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10502,10 +8662,7 @@
     stem: "link07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/link/link07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10514,10 +8671,7 @@
     stem: "clock_nanosleep2_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10526,10 +8680,7 @@
     stem: "link03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/link/link03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10538,10 +8689,7 @@
     stem: "link02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/link/link02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10551,7 +8699,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fstatfs/fstatfs01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstatfs",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -10564,10 +8711,7 @@
     stem: "link05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/link/link05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10577,7 +8721,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fstatfs/fstatfs02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstatfs",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -10592,7 +8735,6 @@
     srcs: ["testcases/kernel/timers/timer_settime/timer_settime02.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/timers/include",
         "include/old",
     ],
@@ -10605,7 +8747,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/tcp_cmds/sendfile/testsf_c.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/network/tcp_cmds/include",
         "include/old",
     ],
@@ -10613,12 +8754,20 @@
 }
 
 cc_test {
+    name: "ltp_autogroup01",
+    stem: "autogroup01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/sched/autogroup/autogroup01.c"],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_cpuctl_def_task02",
     stem: "cpuctl_def_task02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_def_task02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -10633,10 +8782,7 @@
     stem: "link06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/link/link06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10645,10 +8791,7 @@
     stem: "waitpid12",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid12.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10657,10 +8800,7 @@
     stem: "sched_getattr01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getattr/sched_getattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10669,10 +8809,7 @@
     stem: "float_exp_log",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/misc/math/float/float_exp_log.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10681,10 +8818,7 @@
     stem: "execlp01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execlp/execlp01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10693,10 +8827,7 @@
     stem: "ima_mmap",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/integrity/ima/src/ima_mmap.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
     shared_libs: [
         "libdl",
@@ -10709,10 +8840,7 @@
     stem: "block_dev",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/block/block_dev_user/block_dev.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10740,7 +8868,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fstat/fstat03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -10763,7 +8890,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fstat/fstat05.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -10777,7 +8903,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/cpuctl/cpuctl_def_task03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -10793,7 +8918,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/memcg/control/mem_process.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/controllers/libcontrollers",
         "include/old",
     ],
@@ -10805,10 +8929,7 @@
     stem: "socketcall04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socketcall/socketcall04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10817,10 +8938,7 @@
     stem: "mtest01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mtest01/mtest01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10829,10 +8947,7 @@
     stem: "create_long_dirs",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_long_dirs.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10841,10 +8956,7 @@
     stem: "getpriority01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getpriority/getpriority01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10853,10 +8965,7 @@
     stem: "sysfs02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysfs/sysfs02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10865,10 +8974,7 @@
     stem: "kmsg01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/logging/kmsg/kmsg01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10878,7 +8984,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/statfs/statfs02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/statfs",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -10892,7 +8997,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/statfs/statfs01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/statfs",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -10905,10 +9009,7 @@
     stem: "madvise02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/madvise/madvise02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10917,10 +9018,7 @@
     stem: "madvise05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/madvise/madvise05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10929,10 +9027,7 @@
     stem: "close08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/close/close08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10941,10 +9036,7 @@
     stem: "madvise07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/madvise/madvise07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10953,10 +9045,7 @@
     stem: "madvise06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/madvise/madvise06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10965,10 +9054,7 @@
     stem: "madvise09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/madvise/madvise09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10977,10 +9063,7 @@
     stem: "madvise08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/madvise/madvise08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10989,10 +9072,7 @@
     stem: "iopl02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/iopl/iopl02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11001,10 +9081,7 @@
     stem: "close01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/close/close01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11013,10 +9090,7 @@
     stem: "close02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/close/close02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11026,7 +9100,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill09.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -11042,7 +9115,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill08.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -11057,10 +9129,7 @@
     stem: "rt_sigaction01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11077,10 +9146,7 @@
     stem: "rt_sigaction03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11089,10 +9155,7 @@
     stem: "rt_sigaction02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11102,7 +9165,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -11118,7 +9180,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -11134,7 +9195,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -11150,7 +9210,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill04.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -11166,7 +9225,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/clock_getres/clock_getres01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
     ],
@@ -11179,7 +9237,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/kill/kill06.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ipc/lib",
         "include/old",
     ],
@@ -11194,10 +9251,7 @@
     stem: "munmap01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/munmap/munmap01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11206,10 +9260,7 @@
     stem: "munmap03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/munmap/munmap03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11218,22 +9269,7 @@
     stem: "munmap02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/munmap/munmap02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_lseek05",
-    stem: "lseek05",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11242,10 +9278,7 @@
     stem: "pipe10",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11254,10 +9287,7 @@
     stem: "pipe11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pipe/pipe11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11266,10 +9296,7 @@
     stem: "dup3_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup3/dup3_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11278,10 +9305,7 @@
     stem: "exec_without_inh",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/cap_bound/exec_without_inh.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11290,10 +9314,7 @@
     stem: "dup3_02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/dup3/dup3_02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11302,10 +9323,7 @@
     stem: "sched_getscheduler02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11314,10 +9332,7 @@
     stem: "sched_getscheduler01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11326,10 +9341,7 @@
     stem: "execvp01_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execvp/execvp01_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11338,12 +9350,8 @@
     stem: "proc01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/proc/proc01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
-    shared_libs: ["libselinux"],
 }
 
 cc_test {
@@ -11351,10 +9359,7 @@
     stem: "creat07_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/creat/creat07_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11363,10 +9368,7 @@
     stem: "sbrk01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sbrk/sbrk01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11375,10 +9377,7 @@
     stem: "sbrk03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sbrk/sbrk03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11387,10 +9386,7 @@
     stem: "sbrk02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sbrk/sbrk02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11400,7 +9396,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pread/pread01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pread",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11413,10 +9408,7 @@
     stem: "sgetmask01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sgetmask/sgetmask01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11426,7 +9418,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pread/pread03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pread",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11440,7 +9431,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pread/pread02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pread",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11453,10 +9443,7 @@
     stem: "fork09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11465,10 +9452,7 @@
     stem: "fork08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11477,10 +9461,7 @@
     stem: "asyncio02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/asyncio/asyncio02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11489,10 +9470,7 @@
     stem: "zram03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/device-drivers/zram/zram03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11501,10 +9479,7 @@
     stem: "fork01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11513,10 +9488,7 @@
     stem: "write04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/write/write04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11525,10 +9497,7 @@
     stem: "fork03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11537,10 +9506,7 @@
     stem: "fork02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11549,10 +9515,7 @@
     stem: "fork05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11561,10 +9524,7 @@
     stem: "fork04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11573,10 +9533,7 @@
     stem: "fork07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11585,10 +9542,7 @@
     stem: "fork06",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fork/fork06.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11597,10 +9551,7 @@
     stem: "faccessat01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/faccessat/faccessat01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11626,10 +9577,7 @@
     stem: "socketpair02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/socketpair/socketpair02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11638,10 +9586,7 @@
     stem: "pth_str01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/sched/pthreads/pth_str01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11650,10 +9595,7 @@
     stem: "mmapstress08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11662,10 +9604,7 @@
     stem: "wait02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/wait/wait02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11674,10 +9613,7 @@
     stem: "wait01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/wait/wait01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11686,10 +9622,7 @@
     stem: "cacheflush01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/cacheflush/cacheflush01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11698,10 +9631,7 @@
     stem: "tst_random",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/lib/tst_random.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11710,10 +9640,7 @@
     stem: "eventfd2_01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/eventfd2/eventfd2_01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11722,10 +9649,7 @@
     stem: "poll02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/poll/poll02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11734,10 +9658,7 @@
     stem: "eventfd2_03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/eventfd2/eventfd2_03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11746,10 +9667,7 @@
     stem: "eventfd2_02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/eventfd2/eventfd2_02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11758,10 +9676,7 @@
     stem: "abort01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/abort/abort01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11771,7 +9686,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ftruncate/ftruncate01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ftruncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11784,10 +9698,7 @@
     stem: "pause01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pause/pause01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11797,7 +9708,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ftruncate/ftruncate03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ftruncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11811,7 +9721,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ftruncate/ftruncate02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ftruncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11825,7 +9734,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/ftruncate/ftruncate04.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/ftruncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11834,26 +9742,11 @@
 }
 
 cc_test {
-    name: "ltp_lseek10",
-    stem: "lseek10",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_lseek11",
     stem: "lseek11",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/lseek/lseek11.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11863,7 +9756,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fadvise/posix_fadvise03.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11877,7 +9769,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fadvise/posix_fadvise02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11891,7 +9782,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fadvise/posix_fadvise01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11904,10 +9794,7 @@
     stem: "getrusage03_child",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrusage/getrusage03_child.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11916,10 +9803,7 @@
     stem: "timed_forkbomb",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/controllers/freezer/timed_forkbomb.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11929,7 +9813,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fadvise/posix_fadvise04.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -11942,10 +9825,7 @@
     stem: "perf_event_open02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/perf_event_open/perf_event_open02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11954,10 +9834,7 @@
     stem: "setdomainname01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/setdomainname/setdomainname01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11974,10 +9851,7 @@
     stem: "pause02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/pause/pause02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11986,10 +9860,7 @@
     stem: "nsclone",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/fs_bind/bin/nsclone.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -11998,10 +9869,7 @@
     stem: "select04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/select/select04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12010,10 +9878,7 @@
     stem: "listxattr01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/listxattr/listxattr01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12022,10 +9887,7 @@
     stem: "select03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/select/select03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12034,10 +9896,7 @@
     stem: "set_tid_address01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/set_tid_address/set_tid_address01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12046,10 +9905,7 @@
     stem: "reboot02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/reboot/reboot02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12058,10 +9914,7 @@
     stem: "reboot01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/reboot/reboot01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12070,10 +9923,7 @@
     stem: "sched_setparam03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setparam/sched_setparam03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12082,10 +9932,7 @@
     stem: "sched_setparam02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setparam/sched_setparam02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12094,10 +9941,7 @@
     stem: "sched_setparam01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setparam/sched_setparam01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12122,10 +9966,7 @@
     stem: "sched_setparam05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setparam/sched_setparam05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12134,10 +9975,7 @@
     stem: "sched_setparam04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sched_setparam/sched_setparam04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12146,10 +9984,7 @@
     stem: "chmod05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chmod/chmod05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12158,10 +9993,7 @@
     stem: "chmod04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chmod/chmod04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12170,10 +10002,7 @@
     stem: "chmod07",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chmod/chmod07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12182,10 +10011,7 @@
     stem: "chmod01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chmod/chmod01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12194,10 +10020,7 @@
     stem: "chmod03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chmod/chmod03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12206,10 +10029,7 @@
     stem: "chmod02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chmod/chmod02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12219,7 +10039,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sendmsg/sendmsg01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
     ],
@@ -12231,10 +10050,7 @@
     stem: "newns",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/tomoyo/newns.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12252,10 +10068,7 @@
     stem: "eject_check_tray",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/commands/eject/eject_check_tray.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12264,10 +10077,7 @@
     stem: "mmstress",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mtest05/mmstress.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12276,10 +10086,7 @@
     stem: "waitpid09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/waitpid/waitpid09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12288,10 +10095,7 @@
     stem: "mprotect03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mprotect/mprotect03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12300,10 +10104,7 @@
     stem: "data_space",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/vmtests/data_space.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12312,10 +10113,7 @@
     stem: "get_robust_list01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/get_robust_list/get_robust_list01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12325,7 +10123,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fstat/fstat01.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12338,10 +10135,7 @@
     stem: "mprotect02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mprotect/mprotect02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12350,10 +10144,7 @@
     stem: "access01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/access/access01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12362,10 +10153,7 @@
     stem: "access03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/access/access03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12374,10 +10162,7 @@
     stem: "access02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/access/access02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12386,10 +10171,7 @@
     stem: "sync02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sync/sync02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12398,10 +10180,7 @@
     stem: "sync01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sync/sync01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12410,10 +10189,7 @@
     stem: "mprotect04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mprotect/mprotect04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12422,10 +10198,7 @@
     stem: "vfork01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/vfork/vfork01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12435,7 +10208,6 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/fstat/fstat02.c"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12448,10 +10220,7 @@
     stem: "mkdir09",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdir/mkdir09.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12460,10 +10229,7 @@
     stem: "mkdir08",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdir/mkdir08.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12472,10 +10238,7 @@
     stem: "smount",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/fs_bind/bin/smount.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12484,10 +10247,7 @@
     stem: "mkdir05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdir/mkdir05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12496,10 +10256,7 @@
     stem: "mkdir04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdir/mkdir04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12508,10 +10265,7 @@
     stem: "mkdir03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdir/mkdir03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12520,10 +10274,7 @@
     stem: "mkdir02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/mkdir/mkdir02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12532,10 +10283,7 @@
     stem: "stream05",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/stream/stream05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12544,10 +10292,7 @@
     stem: "vfork02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/vfork/vfork02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12556,10 +10301,7 @@
     stem: "stream01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/stream/stream01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12568,10 +10310,7 @@
     stem: "listen01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/listen/listen01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12580,10 +10319,7 @@
     stem: "nanosleep04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/nanosleep/nanosleep04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12592,10 +10328,7 @@
     stem: "create_short_dirs",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_short_dirs.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12604,10 +10337,7 @@
     stem: "chdir01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chdir/chdir01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12616,10 +10346,7 @@
     stem: "rt_sigqueueinfo01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/rt_sigqueueinfo/rt_sigqueueinfo01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12628,10 +10355,7 @@
     stem: "chdir03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chdir/chdir03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12640,10 +10364,7 @@
     stem: "chdir02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chdir/chdir02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12652,10 +10373,7 @@
     stem: "syscall01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/syscall/syscall01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12664,10 +10382,16 @@
     stem: "chdir04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/chdir/chdir04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cap_bset_inh_bounds",
+    stem: "cap_bset_inh_bounds",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/security/cap_bound/cap_bset_inh_bounds.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12676,10 +10400,7 @@
     stem: "sysctl01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/sysctl/sysctl01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12696,10 +10417,17 @@
     stem: "mmapstress10",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/mem/mmapstress/mmapstress10.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_cve-2016-7042",
+    stem: "cve-2016-7042",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/cve/cve-2016-7042.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12716,10 +10444,7 @@
     stem: "nanosleep03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/nanosleep/nanosleep03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12728,10 +10453,16 @@
     stem: "umount03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/umount/umount03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_tst_net_iface_prefix",
+    stem: "tst_net_iface_prefix",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/lib/tst_net_iface_prefix.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12740,10 +10471,7 @@
     stem: "tst_rod",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/lib/tst_rod.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12752,10 +10480,7 @@
     stem: "check_pe",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/cap_bound/check_pe.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12764,10 +10489,7 @@
     stem: "execvp01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/execvp/execvp01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12776,10 +10498,7 @@
     stem: "tomoyo_policy_memory_test",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/security/tomoyo/tomoyo_policy_memory_test.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12792,14 +10511,11 @@
 }
 
 cc_test {
-    name: "ltp_sched_get_priority_max02",
-    stem: "sched_get_priority_max02",
+    name: "ltp_poll01",
+    stem: "poll01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/sched_get_priority_max/sched_get_priority_max02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["testcases/kernel/syscalls/poll/poll01.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12808,10 +10524,7 @@
     stem: "getrusage04",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrusage/getrusage04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12820,10 +10533,7 @@
     stem: "getrusage01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrusage/getrusage01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12832,10 +10542,7 @@
     stem: "memset01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/memset/memset01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12844,10 +10551,7 @@
     stem: "getrusage03",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrusage/getrusage03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12856,10 +10560,7 @@
     stem: "getrusage02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/getrusage/getrusage02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12868,10 +10569,7 @@
     stem: "statvfs01",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/statvfs/statvfs01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12880,10 +10578,7 @@
     stem: "statvfs02",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/kernel/syscalls/statvfs/statvfs02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -12894,7 +10589,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl09.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12909,7 +10603,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl08.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12924,7 +10617,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl05.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12939,7 +10631,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl04.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12954,7 +10645,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl07.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12969,7 +10659,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl06.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12984,7 +10673,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl01.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -12999,7 +10687,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl03.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -13014,7 +10701,6 @@
     srcs: ["testcases/kernel/syscalls/fcntl/fcntl02.c"],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fcntl",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -13032,7 +10718,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/pread",
         "include/old",
@@ -13051,7 +10736,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13065,10 +10749,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13082,7 +10763,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/pread",
         "include/old",
@@ -13091,15 +10771,30 @@
 }
 
 cc_test {
+    name: "ltp_fcntl36_64",
+    stem: "fcntl36_64",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/fcntl/fcntl36.c"],
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-DTST_USE_NEWER64_SYSCALL=1",
+        "-D_GNU_SOURCE",
+    ],
+    local_include_dirs: [
+        "testcases/kernel/syscalls/utils",
+        "testcases/kernel/syscalls/fcntl",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_tst_res",
     stem: "tst_res",
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13113,7 +10808,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pselect",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -13138,10 +10832,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13156,7 +10847,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13176,10 +10866,7 @@
         "-D_GNU_SOURCE",
         "-DSHARED_OFILE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13193,7 +10880,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/ftruncate",
         "include/old",
@@ -13211,7 +10897,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/stat",
         "include/old",
@@ -13229,7 +10914,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -13248,7 +10932,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13266,7 +10949,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/ftruncate",
         "include/old",
@@ -13282,10 +10964,7 @@
         "testcases/kernel/fs/ftest/libftest.c",
         "testcases/kernel/fs/ftest/ftest03.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13300,7 +10979,24 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
+        "testcases/kernel/syscalls/utils",
+        "testcases/kernel/syscalls/fcntl",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_fcntl35_64",
+    stem: "fcntl35_64",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/fcntl/fcntl35.c"],
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-DTST_USE_NEWER64_SYSCALL=1",
+        "-D_GNU_SOURCE",
+    ],
+    local_include_dirs: [
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13319,7 +11015,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13338,7 +11033,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13358,10 +11052,7 @@
         "-D_GNU_SOURCE",
         "-DSHARED_OFILE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13371,10 +11062,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13386,10 +11074,7 @@
         "testcases/kernel/syscalls/swapon/swapon01.c",
         "testcases/kernel/syscalls/swapon/libswapon.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13400,7 +11085,6 @@
     srcs: ["testcases/network/tcp_cmds/sendfile/testsf_c.c"],
     cflags: ["-DINET6"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "include/old",
         "testcases/network/tcp_cmds/include",
     ],
@@ -13418,7 +11102,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13434,10 +11117,7 @@
         "testcases/kernel/syscalls/swapon/libswapon.c",
         "testcases/kernel/syscalls/swapon/swapon02.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13451,7 +11131,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -13469,7 +11148,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/lstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -13489,7 +11167,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -13518,7 +11195,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
         "testcases/kernel/syscalls/pwritev",
@@ -13577,7 +11253,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13596,7 +11271,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13627,7 +11301,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fstatfs",
         "include/old",
@@ -13645,7 +11318,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/ftruncate",
         "include/old",
@@ -13674,7 +11346,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
         "testcases/kernel/syscalls/statfs",
@@ -13693,7 +11364,6 @@
     ],
     cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/hotplug/memory_hotplug",
         "include/old",
     ],
@@ -13709,7 +11379,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pselect",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -13739,7 +11408,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13758,7 +11426,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13777,7 +11444,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13815,10 +11481,7 @@
         "testcases/kernel/fs/ftest/ftest07.c",
         "testcases/kernel/fs/ftest/libftest.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -13834,7 +11497,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -13852,7 +11514,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/ftruncate",
         "include/old",
@@ -13870,7 +11531,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/stat",
         "include/old",
@@ -13912,7 +11572,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/pread",
         "include/old",
@@ -13951,7 +11610,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -13980,7 +11638,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -14027,9 +11684,9 @@
     cflags: [
         "-D_FILE_OFFSET_BITS=64",
         "-DTST_USE_NEWER64_SYSCALL=1",
+        "-Wno-error",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwrite",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -14053,10 +11710,7 @@
         "-D_XOPEN_SOURCE_EXTENDED",
         "-D_XOPEN_SOURCE=500",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14067,7 +11721,6 @@
     srcs: ["testcases/network/tcp_cmds/sendfile/testsf_s.c"],
     cflags: ["-DINET6"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "include/old",
         "testcases/network/tcp_cmds/include",
     ],
@@ -14116,7 +11769,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -14132,10 +11784,7 @@
         "testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c",
         "testcases/kernel/sched/hyperthreading/ht_interrupt/ht_interrupt.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14150,7 +11799,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14164,10 +11812,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14182,7 +11827,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14200,7 +11844,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -14229,7 +11872,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/lstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -14268,7 +11910,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14286,7 +11927,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/stat",
         "include/old",
@@ -14305,7 +11945,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14324,7 +11963,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14343,7 +11981,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14362,7 +11999,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14378,10 +12014,7 @@
         "testcases/kernel/sched/hyperthreading/ht_enabled/ht_enabled.c",
         "testcases/kernel/sched/hyperthreading/ht_enabled/ht_utils.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14493,10 +12126,7 @@
         "testcases/kernel/sched/sched_stress/sched_tc6.c",
         "testcases/kernel/sched/sched_stress/sched.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14516,10 +12146,7 @@
         "-D_XOPEN_SOURCE_EXTENDED",
         "-D_XOPEN_SOURCE=500",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14533,7 +12160,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fadvise",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -14567,10 +12193,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14586,7 +12209,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -14611,10 +12233,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14624,10 +12243,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14639,10 +12255,7 @@
         "testcases/kernel/input/input_helper.c",
         "testcases/kernel/input/input05.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14654,10 +12267,7 @@
         "testcases/kernel/input/input04.c",
         "testcases/kernel/input/input_helper.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14669,10 +12279,7 @@
         "testcases/kernel/input/input_helper.c",
         "testcases/kernel/input/input03.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14687,7 +12294,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14703,10 +12309,7 @@
         "testcases/kernel/input/input_helper.c",
         "testcases/kernel/input/input01.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14722,7 +12325,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -14738,10 +12340,7 @@
         "testcases/kernel/sched/sched_stress/sched.c",
         "testcases/kernel/sched/sched_stress/sched_tc5.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14753,10 +12352,7 @@
         "testcases/kernel/fs/ftest/libftest.c",
         "testcases/kernel/fs/ftest/ftest06.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14768,10 +12364,7 @@
         "testcases/kernel/syscalls/memfd_create/memfd_create_common.c",
         "testcases/kernel/syscalls/memfd_create/memfd_create01.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14783,10 +12376,7 @@
         "testcases/kernel/sched/sched_stress/sched.c",
         "testcases/kernel/sched/sched_stress/sched_tc0.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14798,10 +12388,7 @@
         "testcases/kernel/sched/sched_stress/sched_tc3.c",
         "testcases/kernel/sched/sched_stress/sched.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14816,7 +12403,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14832,10 +12418,7 @@
         "testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c",
         "testcases/kernel/sched/hyperthreading/ht_affinity/ht_utils.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14858,10 +12441,7 @@
         "testcases/network/nfsv4/locks/locktests.c",
         "testcases/network/nfsv4/locks/netsync.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14875,7 +12455,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fstatfs",
         "include/old",
@@ -14891,10 +12470,7 @@
         "testcases/kernel/fs/ftest/libftest.c",
         "testcases/kernel/fs/ftest/ftest04.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14906,10 +12482,7 @@
         "testcases/kernel/fs/ftest/libftest.c",
         "testcases/kernel/fs/ftest/ftest05.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14924,7 +12497,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -14940,10 +12512,7 @@
         "testcases/kernel/fs/ftest/libftest.c",
         "testcases/kernel/fs/ftest/ftest01.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14955,10 +12524,7 @@
         "testcases/kernel/fs/ftest/ftest02.c",
         "testcases/kernel/fs/ftest/libftest.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14974,10 +12540,7 @@
         "-D_GNU_SOURCE",
         "-DSHARED_OFILE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -14992,7 +12555,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15008,10 +12570,7 @@
         "testcases/kernel/fs/ftest/libftest.c",
         "testcases/kernel/fs/ftest/ftest08.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15027,10 +12586,7 @@
         "-D_GNU_SOURCE",
         "-DSHARED_OFILE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15046,10 +12602,7 @@
         "-D_GNU_SOURCE",
         "-DSHARED_OFILE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15063,7 +12616,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/stat",
         "include/old",
@@ -15083,7 +12635,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -15119,10 +12670,7 @@
         "testcases/kernel/sched/sched_stress/sched.c",
         "testcases/kernel/sched/sched_stress/sched_tc2.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15185,10 +12733,7 @@
         "testcases/kernel/input/input_helper.c",
         "testcases/kernel/input/input06.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15200,10 +12745,7 @@
         "testcases/kernel/input/input_helper.c",
         "testcases/kernel/input/input02.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15217,7 +12759,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
         "testcases/kernel/syscalls/statfs",
@@ -15235,7 +12776,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15253,7 +12793,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/stat",
         "include/old",
@@ -15271,7 +12810,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15289,7 +12827,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/truncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15307,7 +12844,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/truncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15326,7 +12862,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15342,10 +12877,7 @@
         "testcases/kernel/sched/sched_stress/sched_tc4.c",
         "testcases/kernel/sched/sched_stress/sched.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15357,9 +12889,9 @@
     cflags: [
         "-D_FILE_OFFSET_BITS=64",
         "-DTST_USE_NEWER64_SYSCALL=1",
+        "-Wno-error",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwrite",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15379,7 +12911,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -15393,10 +12924,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15408,10 +12936,7 @@
         "testcases/kernel/sched/sched_stress/sched.c",
         "testcases/kernel/sched/sched_stress/sched_tc1.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15426,7 +12951,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15445,7 +12969,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15461,9 +12984,9 @@
     cflags: [
         "-D_FILE_OFFSET_BITS=64",
         "-DTST_USE_NEWER64_SYSCALL=1",
+        "-Wno-error",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pwrite",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15483,7 +13006,6 @@
         "-DOFF_T=off64_t",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/sendfile",
         "include/old",
@@ -15499,10 +13021,7 @@
         "testcases/kernel/syscalls/memfd_create/memfd_create_common.c",
         "testcases/kernel/syscalls/memfd_create/memfd_create02.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15517,7 +13036,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15536,7 +13054,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15565,7 +13082,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
         "testcases/kernel/syscalls/preadv",
@@ -15583,7 +13099,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
         "testcases/kernel/syscalls/statfs",
@@ -15602,7 +13117,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15621,7 +13135,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15635,10 +13148,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15650,10 +13160,7 @@
         "testcases/kernel/sched/sched_stress/sched_driver.c",
         "testcases/kernel/sched/sched_stress/sched.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15668,7 +13175,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15684,10 +13190,7 @@
         "testcases/kernel/syscalls/swapon/swapon03.c",
         "testcases/kernel/syscalls/swapon/libswapon.c",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15701,7 +13204,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/pselect",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15720,7 +13222,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15738,7 +13239,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
         "testcases/kernel/syscalls/preadv",
@@ -15756,7 +13256,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/fstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15774,7 +13273,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/lstat",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15792,7 +13290,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "include/old",
         "testcases/kernel/syscalls/pwritev",
@@ -15822,7 +13319,6 @@
         "-D_GNU_SOURCE",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/utils",
         "testcases/kernel/syscalls/fcntl",
         "include/old",
@@ -15842,10 +13338,7 @@
         "-D_GNU_SOURCE",
         "-DSHARED_OFILE",
     ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15859,7 +13352,6 @@
         "-DTST_USE_NEWER64_SYSCALL=1",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "testcases/kernel/syscalls/truncate",
         "testcases/kernel/syscalls/utils",
         "include/old",
@@ -15873,10 +13365,7 @@
     defaults: ["ltp_test_defaults"],
     srcs: ["tools/apicmds/ltpapicmd.c"],
     cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -15890,7 +13379,6 @@
         "-DDEBUG",
     ],
     local_include_dirs: [
-        "testcases/kernel/include",
         "include/old",
         "testcases/network/tcp_cmds/include",
     ],
@@ -15914,7 +13402,6 @@
     name: "libltp_controllers",
     defaults: ["ltp_defaults"],
     local_include_dirs: [
-        "testcases/kernel/include",
         "include",
         "include/old",
     ],
@@ -15981,6 +13468,7 @@
         "lib/tst_fs_type.c",
         "lib/tst_sig.c",
         "lib/tst_net.c",
+        "lib/tst_timer_test.c",
         "lib/tst_ansi_color.c",
         "lib/safe_pthread.c",
         "lib/tst_timer.c",
@@ -16000,6 +13488,7 @@
         "lib/tst_res.c",
         "lib/parse_opts.c",
         "lib/get_high_address.c",
+        "lib/tst_clocks.c",
         "lib/safe_macros.c",
         "lib/tst_kernel.c",
         "lib/tst_test.c",
diff --git a/include/config.h.default b/include/config.h.default
index dc38e5c..ef6a3d5 100644
--- a/include/config.h.default
+++ b/include/config.h.default
@@ -77,9 +77,6 @@
    you don't. */
 #undef HAVE_DECL_PTRACE_SETOPTIONS
 
-/* Define to 1 if you have the <dmapi.h> header file. */
-#undef HAVE_DMAPI_H
-
 /* Define to 1 if you have the <ifaddrs.h> header file. */
 #define HAVE_IFADDRS_H 1
 
@@ -200,9 +197,6 @@
 /* Define to 1 if you have the <sys/inotify.h> header file. */
 #define HAVE_SYS_INOTIFY_H 1
 
-/* Define to 1 if you have the <sys/jfsdmapi.h> header file. */
-#undef HAVE_SYS_JFSDMAPI_H
-
 /* Define to 1 if you have the <sys/prctl.h> header file. */
 #undef HAVE_SYS_PRCTL_H
 
diff --git a/include/lapi/.gitignore b/include/lapi/.gitignore
new file mode 100644
index 0000000..9867b3f
--- /dev/null
+++ b/include/lapi/.gitignore
@@ -0,0 +1 @@
+syscalls.h
diff --git a/include/lapi/fallocate.h b/include/lapi/fallocate.h
index 83a7986..3c711bd 100644
--- a/include/lapi/fallocate.h
+++ b/include/lapi/fallocate.h
@@ -22,7 +22,7 @@
 #include "config.h"
 #include "lapi/abisize.h"
 #include "lapi/seek.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #ifndef FALLOC_FL_KEEP_SIZE
 # define FALLOC_FL_KEEP_SIZE 0x01
diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
new file mode 100644
index 0000000..3e7ce47
--- /dev/null
+++ b/include/lapi/keyctl.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KEYCTL_H__
+#define KEYCTL_H__
+
+#include "config.h"
+#ifdef HAVE_KEYUTILS_H
+# include <keyutils.h>
+#else
+# ifdef HAVE_LINUX_KEYCTL_H
+#  include <linux/keyctl.h>
+# endif /* HAVE_LINUX_KEYCTL_H */
+# include <stdarg.h>
+# include <stdint.h>
+# include "lapi/syscalls.h"
+typedef int32_t key_serial_t;
+
+static inline key_serial_t add_key(const char *type,
+				   const char *description,
+				   const void *payload,
+				   size_t plen,
+				   key_serial_t ringid)
+{
+	return tst_syscall(__NR_add_key,
+		type, description, payload, plen, ringid);
+}
+
+static inline key_serial_t request_key(const char *type,
+				       const char *description,
+				       const char *callout_info,
+				       key_serial_t destringid)
+{
+	return tst_syscall(__NR_request_key,
+		type, description, callout_info, destringid);
+}
+
+static inline long keyctl(int cmd, ...)
+{
+	va_list va;
+	unsigned long arg2, arg3, arg4, arg5;
+
+	va_start(va, cmd);
+	arg2 = va_arg(va, unsigned long);
+	arg3 = va_arg(va, unsigned long);
+	arg4 = va_arg(va, unsigned long);
+	arg5 = va_arg(va, unsigned long);
+	va_end(va);
+
+	return tst_syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
+}
+#endif /* HAVE_KEYUTILS_H */
+
+#ifndef KEYCTL_GET_KEYRING_ID
+# define KEYCTL_GET_KEYRING_ID 0
+#endif
+
+#ifndef KEYCTL_SET_REQKEY_KEYRING
+# define KEYCTL_SET_REQKEY_KEYRING 14
+#endif
+
+#ifndef KEYCTL_JOIN_SESSION_KEYRING
+# define KEYCTL_JOIN_SESSION_KEYRING 1
+#endif
+
+#ifndef KEYCTL_UPDATE
+# define KEYCTL_UPDATE 2
+#endif
+
+#ifndef KEYCTL_SETPERM
+# define KEYCTL_SETPERM 5
+#endif
+
+#ifndef KEYCTL_UNLINK
+# define KEYCTL_UNLINK 9
+#endif
+
+#ifndef KEY_SPEC_THREAD_KEYRING
+# define KEY_SPEC_THREAD_KEYRING -1
+#endif
+
+#ifndef KEY_SPEC_SESSION_KEYRING
+# define KEY_SPEC_SESSION_KEYRING -3
+#endif
+
+#ifndef KEY_REQKEY_DEFL_THREAD_KEYRING
+# define KEY_REQKEY_DEFL_THREAD_KEYRING 1
+#endif
+
+#endif	/* KEYCTL_H__ */
diff --git a/include/lapi/mkdirat.h b/include/lapi/mkdirat.h
index d01b2b2..d61e56e 100644
--- a/include/lapi/mkdirat.h
+++ b/include/lapi/mkdirat.h
@@ -20,7 +20,7 @@
 #define __MKDIRAT_H__
 
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/fcntl.h"
 
 #ifndef HAVE_MKDIRAT
diff --git a/include/lapi/personality.h b/include/lapi/personality.h
new file mode 100644
index 0000000..d85baa0
--- /dev/null
+++ b/include/lapi/personality.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/* In the Linux kernel and glibc enums are (mostly) used for the constants,
+ * but in musl macros are used.
+ */
+
+#ifndef PERSONALITY_H
+#define PERSONALITY_H
+
+#include <sys/personality.h>
+
+#ifndef UNAME26
+# define UNAME26 0x0020000
+#endif
+
+#ifndef READ_IMPLIES_EXEC
+# define READ_IMPLIES_EXEC 0x0400000
+#endif
+
+#endif	/* PERSONALITY_H */
diff --git a/include/lapi/readlinkat.h b/include/lapi/readlinkat.h
index 83e1593..155f620 100644
--- a/include/lapi/readlinkat.h
+++ b/include/lapi/readlinkat.h
@@ -20,7 +20,7 @@
 #define __READLINKAT_H__
 
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/fcntl.h"
 
 #ifndef HAVE_READLINKAT
diff --git a/include/lapi/renameat.h b/include/lapi/renameat.h
index b0ec5bc..fe84e9d 100644
--- a/include/lapi/renameat.h
+++ b/include/lapi/renameat.h
@@ -22,7 +22,7 @@
 
 #include <sys/types.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_RENAMEAT)
 int renameat(int olddirfd, const char *oldpath, int newdirfd,
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index a0efbb0..057662d 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -19,7 +19,7 @@
 #ifndef __SCHED_H__
 #define __SCHED_H__
 
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include <stdint.h>
 #include <inttypes.h>
 
diff --git a/include/lapi/splice.h b/include/lapi/splice.h
index 4e243fd..8ac8bd4 100644
--- a/include/lapi/splice.h
+++ b/include/lapi/splice.h
@@ -22,13 +22,13 @@
 #define SPLICE_H
 
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_SPLICE)
 ssize_t splice(int fd_in, loff_t *off_in, int fd_out,
 	loff_t *off_out, size_t len, unsigned int flags)
 {
-	return ltp_syscall(__NR_splice, fd_in, off_in,
+	return tst_syscall(__NR_splice, fd_in, off_in,
 		fd_out, off_out, len, flags);
 }
 #endif
diff --git a/testcases/kernel/include/aarch64.in b/include/lapi/syscalls/aarch64.in
similarity index 98%
rename from testcases/kernel/include/aarch64.in
rename to include/lapi/syscalls/aarch64.in
index b81c068..8b725e3 100644
--- a/testcases/kernel/include/aarch64.in
+++ b/include/lapi/syscalls/aarch64.in
@@ -256,3 +256,4 @@
 kcmp 272
 getrandom 278
 memfd_create 279
+copy_file_range 391
diff --git a/testcases/kernel/include/arm.in b/include/lapi/syscalls/arm.in
similarity index 99%
rename from testcases/kernel/include/arm.in
rename to include/lapi/syscalls/arm.in
index 0a5dde1..1a13661 100644
--- a/testcases/kernel/include/arm.in
+++ b/include/lapi/syscalls/arm.in
@@ -339,3 +339,4 @@
 renameat2 (__NR_SYSCALL_BASE+382)
 getrandom (__NR_SYSCALL_BASE+384)
 memfd_create (__NR_SYSCALL_BASE+385)
+copy_file_range (__NR_SYSCALL_BASE+391)
diff --git a/testcases/kernel/include/hppa.in b/include/lapi/syscalls/hppa.in
similarity index 94%
rename from testcases/kernel/include/hppa.in
rename to include/lapi/syscalls/hppa.in
index 3946155..bb7a694 100644
--- a/testcases/kernel/include/hppa.in
+++ b/include/lapi/syscalls/hppa.in
@@ -16,3 +16,4 @@
 tee 293
 vmsplice 294
 memfd_create 340
+copy_file_range 346
diff --git a/testcases/kernel/include/i386.in b/include/lapi/syscalls/i386.in
similarity index 99%
rename from testcases/kernel/include/i386.in
rename to include/lapi/syscalls/i386.in
index 42c5e3f..9cbb139 100644
--- a/testcases/kernel/include/i386.in
+++ b/include/lapi/syscalls/i386.in
@@ -339,3 +339,4 @@
 renameat2 354
 getrandom 355
 memfd_create 356
+copy_file_range 377
diff --git a/testcases/kernel/include/ia64.in b/include/lapi/syscalls/ia64.in
similarity index 99%
rename from testcases/kernel/include/ia64.in
rename to include/lapi/syscalls/ia64.in
index dad25f4..1d5b21c 100644
--- a/testcases/kernel/include/ia64.in
+++ b/include/lapi/syscalls/ia64.in
@@ -295,3 +295,4 @@
 renameat2 1338
 getrandom 1339
 memfd_create 1340
+copy_file_range 1347
diff --git a/testcases/kernel/include/order b/include/lapi/syscalls/order
similarity index 100%
rename from testcases/kernel/include/order
rename to include/lapi/syscalls/order
diff --git a/testcases/kernel/include/powerpc.in b/include/lapi/syscalls/powerpc.in
similarity index 99%
rename from testcases/kernel/include/powerpc.in
rename to include/lapi/syscalls/powerpc.in
index 10a6e5d..f87192e 100644
--- a/testcases/kernel/include/powerpc.in
+++ b/include/lapi/syscalls/powerpc.in
@@ -346,3 +346,4 @@
 renameat2 357
 getrandom 359
 memfd_create 360
+copy_file_range 379
diff --git a/testcases/kernel/include/powerpc64.in b/include/lapi/syscalls/powerpc64.in
similarity index 99%
rename from testcases/kernel/include/powerpc64.in
rename to include/lapi/syscalls/powerpc64.in
index 10a6e5d..f87192e 100644
--- a/testcases/kernel/include/powerpc64.in
+++ b/include/lapi/syscalls/powerpc64.in
@@ -346,3 +346,4 @@
 renameat2 357
 getrandom 359
 memfd_create 360
+copy_file_range 379
diff --git a/testcases/kernel/include/regen.sh b/include/lapi/syscalls/regen.sh
similarity index 84%
rename from testcases/kernel/include/regen.sh
rename to include/lapi/syscalls/regen.sh
index 138661d..40b6ffc 100755
--- a/testcases/kernel/include/regen.sh
+++ b/include/lapi/syscalls/regen.sh
@@ -1,11 +1,15 @@
 #!/bin/sh
 
-output="linux_syscall_numbers.h"
+output="syscalls.h"
 
+# For soon to be able to provide an argument
+# for output file so the header generation can
+# be added as a dependency in Android.bp
 if [ $# -gt 0 ]; then
-    output=$1
+	output=$1
+	echo "ltp syscalls gen output: "$output
+	rm -f "${output}"
 fi
-echo "ltp testcases kernel include regen: output = "$output
 
 rm -f "${output}".[1-9]*
 output_pid="${output}.$$"
@@ -33,8 +37,8 @@
  * Licensed under the GPLv2 or later, see the COPYING file.
  */
 
-#ifndef __LINUX_SYSCALL_NUMBERS_H__
-#define __LINUX_SYSCALL_NUMBERS_H__
+#ifndef __LAPI_SYSCALLS_H__
+#define __LAPI_SYSCALLS_H__
 
 #include <errno.h>
 #include <sys/syscall.h>
@@ -66,7 +70,7 @@
 		tst_ret = syscall(NR, ##__VA_ARGS__); \\
 	} \\
 	if (tst_ret == -1 && errno == ENOSYS) { \\
-		tst_brk(TCONF, "syscall(%d) " #NR "not supported", NR); \\
+		tst_brk(TCONF, "syscall(%d) " #NR " not supported", NR); \\
 	} \\
 	tst_ret; \\
 })
@@ -129,6 +133,10 @@
 for arch in $(cat "${srcdir}/order") _footer ; do
 	cat "${output_pid}.${arch}"
 done >> "${output_pid}"
-mv "${output_pid}" "${output}"
+if [ $# -gt 0 ]; then
+	mv "${output_pid}" "${output}"
+else
+	mv "${output_pid}" "../${output}"
+fi
 rm -f "${output_pid}"*
 echo "OK!"
diff --git a/testcases/kernel/include/s390.in b/include/lapi/syscalls/s390.in
similarity index 99%
rename from testcases/kernel/include/s390.in
rename to include/lapi/syscalls/s390.in
index 770db7f..2526f38 100644
--- a/testcases/kernel/include/s390.in
+++ b/include/lapi/syscalls/s390.in
@@ -330,3 +330,4 @@
 renameat2 347
 getrandom 349
 memfd_create 350
+copy_file_range 375
diff --git a/testcases/kernel/include/s390x.in b/include/lapi/syscalls/s390x.in
similarity index 99%
rename from testcases/kernel/include/s390x.in
rename to include/lapi/syscalls/s390x.in
index 770db7f..2526f38 100644
--- a/testcases/kernel/include/s390x.in
+++ b/include/lapi/syscalls/s390x.in
@@ -330,3 +330,4 @@
 renameat2 347
 getrandom 349
 memfd_create 350
+copy_file_range 375
diff --git a/testcases/kernel/include/sh.in b/include/lapi/syscalls/sh.in
similarity index 99%
rename from testcases/kernel/include/sh.in
rename to include/lapi/syscalls/sh.in
index 0345f8d..b41b578 100644
--- a/testcases/kernel/include/sh.in
+++ b/include/lapi/syscalls/sh.in
@@ -363,3 +363,4 @@
 prlimit64 369
 kcmp 378
 memfd_create 385
+copy_file_range 391
diff --git a/testcases/kernel/include/sparc.in b/include/lapi/syscalls/sparc.in
similarity index 99%
rename from testcases/kernel/include/sparc.in
rename to include/lapi/syscalls/sparc.in
index b84c844..729768b 100644
--- a/testcases/kernel/include/sparc.in
+++ b/include/lapi/syscalls/sparc.in
@@ -335,3 +335,4 @@
 renameat2 345
 getrandom 347
 memfd_create 348
+copy_file_range 357
diff --git a/testcases/kernel/include/sparc64.in b/include/lapi/syscalls/sparc64.in
similarity index 99%
rename from testcases/kernel/include/sparc64.in
rename to include/lapi/syscalls/sparc64.in
index 7e0be30..9eb21ee 100644
--- a/testcases/kernel/include/sparc64.in
+++ b/include/lapi/syscalls/sparc64.in
@@ -311,3 +311,4 @@
 renameat2 345
 getrandom 347
 memfd_create 348
+copy_file_range 357
diff --git a/testcases/kernel/include/strip_syscall.awk b/include/lapi/syscalls/strip_syscall.awk
similarity index 100%
rename from testcases/kernel/include/strip_syscall.awk
rename to include/lapi/syscalls/strip_syscall.awk
diff --git a/testcases/kernel/include/x86_64.in b/include/lapi/syscalls/x86_64.in
similarity index 99%
rename from testcases/kernel/include/x86_64.in
rename to include/lapi/syscalls/x86_64.in
index dec7742..29051d4 100644
--- a/testcases/kernel/include/x86_64.in
+++ b/include/lapi/syscalls/x86_64.in
@@ -306,3 +306,4 @@
 renameat2 316
 getrandom 318
 memfd_create 319
+copy_file_range 326
diff --git a/include/lapi/tee.h b/include/lapi/tee.h
index 0ba10a6..1d98195 100644
--- a/include/lapi/tee.h
+++ b/include/lapi/tee.h
@@ -21,12 +21,12 @@
 #define TEE_H
 
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_TEE)
 ssize_t tee(int fd_in, int fd_out, size_t len, unsigned int flags)
 {
-	return ltp_syscall(__NR_tee, fd_in, fd_out, len, flags);
+	return tst_syscall(__NR_tee, fd_in, fd_out, len, flags);
 }
 #endif
 
diff --git a/include/lapi/timerfd.h b/include/lapi/timerfd.h
index f574ecf..467cd15 100644
--- a/include/lapi/timerfd.h
+++ b/include/lapi/timerfd.h
@@ -20,7 +20,7 @@
 
 #include <time.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #ifdef HAVE_SYS_TIMERFD_H
 #include <sys/timerfd.h>
diff --git a/include/lapi/vmsplice.h b/include/lapi/vmsplice.h
index 9dde9d6..d8b710f 100644
--- a/include/lapi/vmsplice.h
+++ b/include/lapi/vmsplice.h
@@ -22,7 +22,7 @@
 #define VMSPLICE_H
 
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #include "lapi/iovec.h"
 
@@ -30,7 +30,7 @@
 ssize_t vmsplice(int fd, const struct iovec *iov,
 	         unsigned long nr_segs, unsigned int flags)
 {
-	return ltp_syscall(__NR_vmsplice, fd, iov, nr_segs, flags);
+	return tst_syscall(__NR_vmsplice, fd, iov, nr_segs, flags);
 }
 #endif
 
diff --git a/include/mk/testcases.mk b/include/mk/testcases.mk
index f453f4e..bf97384 100644
--- a/include/mk/testcases.mk
+++ b/include/mk/testcases.mk
@@ -25,10 +25,6 @@
 
 APICMDS_DIR	:= $(abs_top_builddir)/tools/apicmds
 
-TKI_DIR		:= testcases/kernel/include
-
-LSN_H		:= $(abs_top_builddir)/$(TKI_DIR)/linux_syscall_numbers.h
-
 LIBLTP_DIR	:= $(abs_top_builddir)/lib
 
 LIBLTP		:= $(LIBLTP_DIR)/libltp.a
@@ -39,17 +35,11 @@
 $(LIBLTP): $(LIBLTP_DIR)
 	$(MAKE) -C "$^" -f "$(abs_top_srcdir)/lib/Makefile" all
 
-$(LSN_H): $(abs_top_builddir)/$(TKI_DIR)
-	$(MAKE) -C "$^" -f "$(abs_top_srcdir)/$(TKI_DIR)/Makefile" all
-
-MAKE_DEPS	:= $(LIBLTP) $(LSN_H)
-
-# For linux_syscall_numbers.h
-CPPFLAGS	+= -I$(abs_top_builddir)/$(TKI_DIR)
+MAKE_DEPS	:= $(LIBLTP)
 
 INSTALL_DIR	:= testcases/bin
 
 LDLIBS		+= -lltp
 
-$(APICMDS_DIR) $(LIBLTP_DIR) $(abs_top_builddir)/$(TKI_DIR): %:
+$(APICMDS_DIR) $(LIBLTP_DIR): %:
 	mkdir -p "$@"
diff --git a/include/old/test.h b/include/old/test.h
index b36764d..137ebb1 100644
--- a/include/old/test.h
+++ b/include/old/test.h
@@ -62,6 +62,7 @@
 #include "tst_clone.h"
 #include "old_device.h"
 #include "old_tmpdir.h"
+#include "tst_minmax.h"
 
 /*
  * Ensure that NUMSIGS is defined.
diff --git a/include/old/usctest.h b/include/old/usctest.h
index 9241d78..9b9446d 100644
--- a/include/old/usctest.h
+++ b/include/old/usctest.h
@@ -34,8 +34,6 @@
 #ifndef __USCTEST_H__
 #define __USCTEST_H__
 
-#include <sys/param.h>
-
 /*
  * Ensure that PATH_MAX is defined
  */
diff --git a/include/tst_clocks.h b/include/tst_clocks.h
new file mode 100644
index 0000000..ee2f645
--- /dev/null
+++ b/include/tst_clocks.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * clock_gettime() and clock_getres() functions
+ */
+
+#ifndef TST_CLOCKS__
+#define TST_CLOCKS__
+
+int tst_clock_getres(clockid_t clk_id, struct timespec *res);
+
+int tst_clock_gettime(clockid_t clk_id, struct timespec *ts);
+
+#endif /* TST_CLOCKS__ */
diff --git a/include/tst_fuzzy_sync.h b/include/tst_fuzzy_sync.h
new file mode 100644
index 0000000..2292174
--- /dev/null
+++ b/include/tst_fuzzy_sync.h
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Fuzzy Synchronisation - abreviated to fzsync
+ *
+ * This library is intended to help reproduce race conditions while running in
+ * a loop. You can use it to measure the time at which two functions are
+ * called in different threads. Then calculate the average time gap between
+ * the function calls and introduce a delay in one thread to synchronise the
+ * calls.
+ *
+ * It is called 'fuzzy' synchronisation because the time gap will naturally vary
+ * due to environmental factors. It is not a 'hard' synchronisation mechanism
+ * like lockstepping.
+ *
+ * For a usage example see testcases/cve/cve-2017-2671.c
+ */
+
+#include <sys/time.h>
+#include <time.h>
+
+#ifndef CLOCK_MONOTONIC_RAW
+# define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+#endif
+
+/**
+ * struct tst_fzsync_pair - the state of a two way synchronisation
+ * @avg_diff: The average time difference over multiple iterations
+ * @avg_diff_trgt: The desired average time difference, defaults to 0
+ * @avg_alpha: The rate at which old diff samples are forgotten,
+ *             defaults to 0.25
+ * @a: The time at which call site A was last passed
+ * @b: The time at which call site B was last passed
+ * @delay: The size of the delay, positive to delay A, negative to delay B
+ * @delay_inc: The step size of a delay increment, defaults to 10
+ * @update_gap: The number of iterations between recalculating the delay.
+ *              Defaults to 0xF and must be of the form $2^n - 1$
+ *
+ * This contains all the necessary state for synchronising two points A and
+ * B. Where A is the time of an event in one process and B is the time of an
+ * event in another process.
+ */
+struct tst_fzsync_pair {
+	double avg_diff;
+	double avg_diff_trgt;
+	double avg_alpha;
+	struct timespec a;
+	struct timespec b;
+	long delay;
+	long delay_inc;
+	int update_gap;
+};
+
+/**
+ * TST_FZSYNC_PAIR_INIT - Default values for struct tst_fzysnc_pair
+ */
+#define TST_FZSYNC_PAIR_INIT {	\
+	.avg_alpha = 0.25,	\
+	.delay_inc = 10,	\
+	.update_gap = 0xF	\
+}
+
+static void tst_fzsync_pair_info(struct tst_fzsync_pair *pair)
+{
+	tst_res(TINFO, "avg_diff = %.5gns, delay = %05ld loops",
+		pair->avg_diff, pair->delay);
+}
+
+/**
+ * tst_fzsync_delay_a - Perform spin delay for A, if needed
+ *
+ * Usually called just before the point you want to synchronise.
+ */
+static inline void tst_fzsync_delay_a(struct tst_fzsync_pair *pair)
+{
+	volatile long spin_delay = pair->delay;
+
+	while (spin_delay > 0)
+		spin_delay--;
+}
+
+/**
+ * tst_fzsync_delay_b - Perform spin delay for B, if needed
+ *
+ * Usually called just before the point you want to synchronise.
+ */
+static inline void tst_fzsync_delay_b(struct tst_fzsync_pair *pair)
+{
+	volatile long spin_delay = pair->delay;
+
+	while (spin_delay < 0)
+		spin_delay++;
+}
+
+static inline void tst_fzsync_time(struct timespec *t)
+{
+	clock_gettime(CLOCK_MONOTONIC_RAW, t);
+}
+
+/**
+ * tst_fzsync_time_a - Set A's time to now.
+ *
+ * Called at the point you want to synchronise.
+ */
+static inline void tst_fzsync_time_a(struct tst_fzsync_pair *pair)
+{
+	tst_fzsync_time(&pair->a);
+}
+
+/**
+ * tst_fzsync_time_b - Set B's call time to now.
+ *
+ * Called at the point you want to synchronise.
+ */
+static inline void tst_fzsync_time_b(struct tst_fzsync_pair *pair)
+{
+	tst_fzsync_time(&pair->b);
+}
+
+/**
+ * tst_exp_moving_avg - Exponential moving average
+ * @alpha: The preference for recent samples over old ones.
+ * @sample: The current sample
+ * @prev_avg: The average of the all the previous samples
+ *
+ * Returns average including the current sample.
+ */
+static inline double tst_exp_moving_avg(double alpha, long sample,
+					double prev_avg)
+{
+	return alpha * sample + (1.0 - alpha) * prev_avg;
+}
+
+/**
+ * tst_fzsync_pair_update - Recalculate the delay
+ * @loop_index: The i in "for(i = 0;..." or zero to ignore update_gap
+ * @pair: The state necessary for calculating the delay
+ *
+ * This should be called at the end of each loop to update the average
+ * measured time difference (between A and B) and update the delay. It is
+ * assumed that A and B are less than a second apart.
+ *
+ * The values of update_gap, avg_alpha and delay_inc decide the speed at which
+ * the algorithm approaches the optimum delay value and whether it is
+ * stable. If your test is behaving strangely, it could be because this
+ * algorithm is behaving chaotically and flip-flopping between large positve
+ * and negative delay values. You can call tst_fzysync_pair_info every few
+ * loops to check whether the average difference and delay values are stable.
+ */
+static void tst_fzsync_pair_update(int loop_index, struct tst_fzsync_pair *pair)
+{
+	long diff;
+	long inc = pair->delay_inc;
+	double target = pair->avg_diff_trgt;
+	double avg = pair->avg_diff;
+
+	diff = pair->a.tv_nsec - pair->b.tv_nsec;
+	avg = tst_exp_moving_avg(pair->avg_alpha, diff, avg);
+
+	if (!(loop_index & pair->update_gap)) {
+		if (avg > target)
+			pair->delay -= inc;
+		else if (avg < target)
+			pair->delay += inc;
+	}
+
+	pair->avg_diff = avg;
+}
diff --git a/include/tst_minmax.h b/include/tst_minmax.h
new file mode 100644
index 0000000..838c3a8
--- /dev/null
+++ b/include/tst_minmax.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TST_MINMAX_H__
+#define TST_MINMAX_H__
+
+#ifndef MIN
+# define MIN(a, b) ({ \
+	typeof(a) _a = (a); \
+	typeof(b) _b = (b); \
+	_a < _b ? _a : _b; \
+})
+#endif /* MIN */
+
+#ifndef MAX
+# define MAX(a, b) ({ \
+	typeof(a) _a = (a); \
+	typeof(b) _b = (b); \
+	_a > _b ? _a : _b; \
+})
+#endif /* MAX */
+
+#endif	/* TST_MINMAX_H__ */
diff --git a/include/tst_net.h b/include/tst_net.h
new file mode 100644
index 0000000..cb97b7b
--- /dev/null
+++ b/include/tst_net.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <arpa/inet.h>
+#include <errno.h>
+
+#define MAX_IPV4_PREFIX 32
+#define MAX_IPV6_PREFIX 128
+
+#define tst_res_comment(...) { \
+	fprintf(stderr, "# "); \
+	tst_res(__VA_ARGS__); } \
+
+
+#define tst_brk_comment(...) { \
+	fprintf(stderr, "# "); \
+	tst_brk(TCONF, __VA_ARGS__); } \
+
+static inline void print_svar(const char *name, const char *val)
+{
+	if (name && val)
+		printf("export %s=\"%s\"\n", name, val);
+}
+
+static inline void print_svar_change(const char *name, const char *val)
+{
+	if (name && val)
+		printf("export %s=\"${%s:-%s}\"\n", name, name, val);
+}
+
+/*
+ * Function bit_count is from ipcalc project, ipcalc.c.
+ */
+static int bit_count(uint32_t i)
+{
+	int c = 0;
+	unsigned int seen_one = 0;
+
+	while (i > 0) {
+		if (i & 1) {
+			seen_one = 1;
+			c++;
+		} else {
+			if (seen_one)
+				return -1;
+		}
+		i >>= 1;
+	}
+
+	return c;
+}
+
+/*
+ * Function mask2prefix is from ipcalc project, ipcalc.c.
+ */
+static int mask2prefix(struct in_addr mask)
+{
+	return bit_count(ntohl(mask.s_addr));
+}
+
+/*
+ * Function ipv4_mask_to_int is from ipcalc project, ipcalc.c.
+ */
+static int ipv4_mask_to_int(const char *prefix)
+{
+	int ret;
+	struct in_addr in;
+
+	ret = inet_pton(AF_INET, prefix, &in);
+	if (ret == 0)
+		return -1;
+
+	return mask2prefix(in);
+}
+
+/*
+ * Function safe_atoi is from ipcalc project, ipcalc.c.
+ */
+static int safe_atoi(const char *s, int *ret_i)
+{
+	char *x = NULL;
+	long l;
+
+	errno = 0;
+	l = strtol(s, &x, 0);
+
+	if (!x || x == s || *x || errno)
+		return errno > 0 ? -errno : -EINVAL;
+
+	if ((long)(int)l != l)
+		return -ERANGE;
+
+	*ret_i = (int)l;
+
+	return 0;
+}
+
+/*
+ * Function get_prefix use code from ipcalc project, str_to_prefix/ipcalc.c.
+ */
+static int get_prefix(const char *ip_str, int is_ipv6)
+{
+	char *prefix_str = NULL;
+	int prefix = -1, r;
+
+	prefix_str = strchr(ip_str, '/');
+	if (!prefix_str)
+		return -1;
+
+	*(prefix_str++) = '\0';
+
+	if (!is_ipv6 && strchr(prefix_str, '.'))
+		prefix = ipv4_mask_to_int(prefix_str);
+	else {
+		r = safe_atoi(prefix_str, &prefix);
+		if (r != 0)
+			tst_brk_comment("conversion error: '%s' is not integer",
+					prefix_str);
+	}
+
+	if (prefix < 0 || ((is_ipv6 && prefix > MAX_IPV6_PREFIX) ||
+		(!is_ipv6 && prefix > MAX_IPV4_PREFIX)))
+		tst_brk_comment("bad %s prefix: %s", is_ipv6 ?  "IPv6" : "IPv4",
+				prefix_str);
+
+	return prefix;
+}
+
+static void get_in_addr(const char *ip_str, struct in_addr *ip)
+{
+	if (inet_pton(AF_INET, ip_str, ip) <= 0)
+		tst_brk_comment("bad IPv4 address: '%s'", ip_str);
+}
+
+static void get_in6_addr(const char *ip_str, struct in6_addr *ip6)
+{
+	if (inet_pton(AF_INET6, ip_str, ip6) <= 0)
+		tst_brk_comment("bad IPv6 address: '%s'", ip_str);
+}
diff --git a/include/tst_safe_file_ops.h b/include/tst_safe_file_ops.h
index 4d19877..5c3fea4 100644
--- a/include/tst_safe_file_ops.h
+++ b/include/tst_safe_file_ops.h
@@ -38,6 +38,12 @@
 	file_lines_scanf(__FILE__, __LINE__, NULL, 1,\
 			(path), (fmt), ## __VA_ARGS__)
 
+#define SAFE_READ_MEMINFO(item) \
+       ({long tst_rval; \
+        SAFE_FILE_LINES_SCANF("/proc/meminfo", item " %ld", \
+                        &tst_rval); \
+        tst_rval;})
+
 #define FILE_PRINTF(path, fmt, ...) \
 	file_printf(__FILE__, __LINE__, \
 		    (path), (fmt), ## __VA_ARGS__)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index a25a4f0..1e034b8 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -430,4 +430,22 @@
 int safe_fsync(const char *file, const int lineno, int fd);
 #define SAFE_FSYNC(fd) safe_fsync(__FILE__, __LINE__, (fd))
 
+int safe_setsid(const char *file, const int lineno);
+#define SAFE_SETSID() safe_setsid(__FILE__, __LINE__)
+
+int safe_mknod(const char *file, const int lineno, const char *pathname,
+	mode_t mode, dev_t dev);
+#define SAFE_MKNOD(pathname, mode, dev) \
+	safe_mknod(__FILE__, __LINE__, (pathname), (mode), (dev))
+
+int safe_fanotify_init(const char *file, const int lineno,
+	unsigned int flags, unsigned int event_f_flags);
+#define SAFE_FANOTIFY_INIT(fan, mode)  \
+	safe_fanotify_init(__FILE__, __LINE__, (fan), (mode))
+
+int safe_personality(const char *filename, unsigned int lineno,
+		    unsigned long persona);
+#define SAFE_PERSONALITY(persona) safe_personality(__FILE__, __LINE__, persona)
+
+
 #endif /* SAFE_MACROS_H__ */
diff --git a/include/tst_safe_sysv_ipc.h b/include/tst_safe_sysv_ipc.h
index cbdefb9..e01957f 100644
--- a/include/tst_safe_sysv_ipc.h
+++ b/include/tst_safe_sysv_ipc.h
@@ -18,6 +18,11 @@
 #ifndef TST_SAFE_SYSV_IPC_H__
 #define TST_SAFE_SYSV_IPC_H__
 
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/shm.h>
+
 int safe_msgget(const char *file, const int lineno, key_t key, int msgflg);
 #define SAFE_MSGGET(key, msgflg) \
 	safe_msgget(__FILE__, __LINE__, (key), (msgflg))
@@ -39,4 +44,24 @@
 	(msqid) = ((cmd) == IPC_RMID ? -1 : (msqid)); \
 	} while (0)
 
+int safe_shmget(const char *file, const int lineno, key_t key, size_t size,
+		int shmflg);
+#define SAFE_SHMGET(key, size, shmflg) \
+	safe_shmget(__FILE__, __LINE__, (key), (size), (shmflg))
+
+void *safe_shmat(const char *file, const int lineno, int shmid,
+		const void *shmaddr, int shmflg);
+#define SAFE_SHMAT(shmid, shmaddr, shmflg) \
+	safe_shmat(__FILE__, __LINE__, (shmid), (shmaddr), (shmflg))
+
+int safe_shmdt(const char *file, const int lineno, const void *shmaddr);
+#define SAFE_SHMDT(shmaddr)	safe_shmdt(__FILE__, __LINE__, (shmaddr))
+
+int safe_shmctl(const char *file, const int lineno, int shmid, int cmd,
+		struct shmid_ds *buf);
+#define SAFE_SHMCTL(shmid, cmd, buf) do { \
+	safe_shmctl(__FILE__, __LINE__, (shmid), (cmd), (buf)); \
+	(shmid) = ((cmd) == IPC_RMID ? -1 : (shmid)); \
+	} while (0)
+
 #endif /* TST_SAFE_SYSV_IPC_H__ */
diff --git a/include/tst_test.h b/include/tst_test.h
index 335c826..ad468e8 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -23,6 +23,7 @@
 #endif /* __TEST_H__ */
 
 #include <unistd.h>
+#include <limits.h>
 
 #include "tst_common.h"
 #include "tst_res_flags.h"
@@ -38,6 +39,7 @@
 #include "tst_kvercmp.h"
 #include "tst_clone.h"
 #include "tst_kernel.h"
+#include "tst_minmax.h"
 
 /*
  * Reports testcase result.
@@ -112,6 +114,9 @@
 
 	const char *min_kver;
 
+	/* If set the test is compiled out */
+	const char *tconf_msg;
+
 	int needs_tmpdir:1;
 	int needs_root:1;
 	int forks_child:1;
@@ -119,6 +124,7 @@
 	int needs_checkpoints:1;
 	int format_device:1;
 	int mount_device:1;
+	int needs_rofs:1;
 
 	/* Minimal device size in megabytes */
 	unsigned int dev_min_size;
@@ -135,8 +141,8 @@
 	unsigned int mnt_flags;
 	void *mnt_data;
 
-	/* override default timeout per test run */
-	unsigned int timeout;
+	/* override default timeout per test run, disabled == -1 */
+	int timeout;
 
 	void (*setup)(void);
 	void (*cleanup)(void);
@@ -144,6 +150,9 @@
 	void (*test)(unsigned int test_nr);
 	void (*test_all)(void);
 
+	/* Sampling function for timer measurement testcases */
+	int (*sample)(int clk_id, long long usec);
+
 	/* NULL terminated array of resource file names */
 	const char *const *resource_files;
 };
@@ -178,12 +187,12 @@
 const char *tst_strerrno(int err);
 const char *tst_strsig(int sig);
 
+void tst_set_timeout(int timeout);
+
 #ifndef TST_NO_DEFAULT_MAIN
 
 static struct tst_test test;
 
-void tst_set_timeout(unsigned int timeout);
-
 int main(int argc, char *argv[])
 {
 	tst_run_tcases(argc, argv, &test);
@@ -191,9 +200,8 @@
 
 #endif /* TST_NO_DEFAULT_MAIN */
 
-#define TST_TEST_TCONF(message)                                              \
-        static void tst_do_test(void) { tst_brk(TCONF, "%s", message); };    \
-        static struct tst_test test = { .test_all = tst_do_test, .tid = "" } \
+#define TST_TEST_TCONF(message)                                 \
+        static struct tst_test test = { .tconf_msg = message  } \
 /*
  * This is a hack to make the testcases link without defining TCID
  */
diff --git a/include/tst_timer.h b/include/tst_timer.h
index f0a10bd..1b00e3c 100644
--- a/include/tst_timer.h
+++ b/include/tst_timer.h
@@ -51,6 +51,22 @@
 }
 
 /*
+ * Converts timeval to microseconds.
+ */
+static inline long long tst_timeval_to_us(struct timeval t)
+{
+	return t.tv_sec * 1000000 + t.tv_usec;
+}
+
+/*
+ * Converts timeval to miliseconds.
+ */
+static inline long long tst_timeval_to_ms(struct timeval t)
+{
+	return t.tv_sec * 1000 + (t.tv_usec + 500) / 1000;
+}
+
+/*
  * Converts ms to struct timeval
  */
 static inline struct timeval tst_ms_to_timeval(long long ms)
@@ -77,6 +93,32 @@
 }
 
 /*
+ * Converts ms to struct timespec
+ */
+static inline struct timespec tst_ms_to_timespec(long long ms)
+{
+	struct timespec ret;
+
+	ret.tv_sec = ms / 1000;
+	ret.tv_nsec = (ms % 1000) * 1000000;
+
+	return ret;
+}
+
+/*
+ * Converts us to struct timespec
+ */
+static inline struct timespec tst_us_to_timespec(long long us)
+{
+	struct timespec ret;
+
+	ret.tv_sec = us / 1000000;
+	ret.tv_nsec = (us % 1000000) * 1000;
+
+	return ret;
+}
+
+/*
  * Comparsions
  */
 static inline int tst_timespec_lt(struct timespec t1, struct timespec t2)
@@ -137,6 +179,38 @@
 }
 
 /*
+ * Returns difference between two timeval structures.
+ */
+static inline struct timeval tst_timeval_diff(struct timeval t1,
+                                              struct timeval t2)
+{
+	struct timeval res;
+
+	res.tv_sec = t1.tv_sec - t2.tv_sec;
+
+	if (t1.tv_usec < t2.tv_usec) {
+		res.tv_sec--;
+		res.tv_usec = 1000000 - (t2.tv_usec - t1.tv_usec);
+	} else {
+		res.tv_usec = t1.tv_usec - t2.tv_usec;
+	}
+
+	return res;
+}
+
+static inline long long tst_timeval_diff_us(struct timeval t1,
+                                            struct timeval t2)
+{
+	return tst_timeval_to_us(tst_timeval_diff(t1, t2));
+}
+
+static inline long long tst_timeval_diff_ms(struct timeval t1,
+                                            struct timeval t2)
+{
+	return tst_timeval_to_ms(tst_timeval_diff(t1, t2));
+}
+
+/*
  * Returns absolute value of difference between two timespec structures.
  */
 static inline struct timespec tst_timespec_abs_diff(struct timespec t1,
diff --git a/include/tst_timer_test.h b/include/tst_timer_test.h
new file mode 100644
index 0000000..59931d3
--- /dev/null
+++ b/include/tst_timer_test.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+ /*
+
+    Timer measuring library.
+
+    The test is supposed to define sampling function and set it in the tst_test
+    structure the rest of the work is then done by the library.
+
+    int sample(int clk_id, long long usec)
+    {
+	// Any setup done here
+
+	tst_timer_start(clk_id);
+	// Call that is being measured sleeps for usec
+	tst_timer_stop();
+	tst_timer_sample();
+
+	// Any cleanup done here
+
+	// Non-zero return exits the test
+    }
+
+    struct tst_test test = {
+	.tid = "syscall_name()",
+	.sample = sample,
+    };
+
+  */
+
+#ifndef TST_TIMER_TEST__
+#define TST_TIMER_TEST__
+
+#include "tst_test.h"
+#include "tst_timer.h"
+
+void tst_timer_sample(void);
+
+# ifdef TST_NO_DEFAULT_MAIN
+struct tst_test *tst_timer_test_setup(struct tst_test *test);
+# endif /* TST_NO_DEFAULT_MAIN */
+#endif /* TST_TIMER_TEST__ */
diff --git a/lib/Makefile b/lib/Makefile
index bfbdf25..4ab7c39 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -29,7 +29,7 @@
 ifneq ($(ANDROID),1)
 FILTER_OUT_DIRS		+= android_libpthread android_librt
 else
-FILTER_OUT_LIBSRCS	+= tlibio.c tst_path_has_mnt_flags.c
+FILTER_OUT_LIBSRCS	+= tlibio.c tst_path_has_mnt_flags.c tst_safe_sysv_ipc.c
 endif
 
 LIB			:= libltp.a
diff --git a/lib/android_libpthread/Makefile b/lib/android_libpthread/Makefile
new file mode 100644
index 0000000..2946d09
--- /dev/null
+++ b/lib/android_libpthread/Makefile
@@ -0,0 +1,7 @@
+top_srcdir		?= ../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+LIB			:= libpthread.a
+
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/lib/android_libpthread/stub.c b/lib/android_libpthread/stub.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/android_libpthread/stub.c
diff --git a/lib/android_librt/Makefile b/lib/android_librt/Makefile
new file mode 100644
index 0000000..ecb1fbe
--- /dev/null
+++ b/lib/android_librt/Makefile
@@ -0,0 +1,7 @@
+top_srcdir		?= ../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+LIB			:= librt.a
+
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/lib/android_librt/stub.c b/lib/android_librt/stub.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/android_librt/stub.c
diff --git a/lib/get_path.c b/lib/get_path.c
index cb8a3b5..aafbc2c 100644
--- a/lib/get_path.c
+++ b/lib/get_path.c
@@ -31,8 +31,6 @@
   * $PATH.
   */
 
-#include "test.h"
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -40,9 +38,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifndef MIN
-#define MIN(a, b) ((a)<(b)?(a):(b))
-#endif
+#include "test.h"
 
 static int file_exist(const char *path)
 {
diff --git a/lib/newlib_tests/test01.c b/lib/newlib_tests/test01.c
index 5771a66..32bba12 100644
--- a/lib/newlib_tests/test01.c
+++ b/lib/newlib_tests/test01.c
@@ -30,6 +30,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "test01",
 	.test_all = do_test,
 };
diff --git a/lib/newlib_tests/test02.c b/lib/newlib_tests/test02.c
index 0a0eff6..b4ea0b6 100644
--- a/lib/newlib_tests/test02.c
+++ b/lib/newlib_tests/test02.c
@@ -43,7 +43,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test02",
 	.tcnt = 2,
 	.test = do_test,
 };
diff --git a/lib/newlib_tests/test03.c b/lib/newlib_tests/test03.c
index d5772a8..8ed78aa 100644
--- a/lib/newlib_tests/test03.c
+++ b/lib/newlib_tests/test03.c
@@ -28,6 +28,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "test03",
 	.test_all = do_test,
 };
diff --git a/lib/newlib_tests/test04.c b/lib/newlib_tests/test04.c
index a9c6b3e..b233279 100644
--- a/lib/newlib_tests/test04.c
+++ b/lib/newlib_tests/test04.c
@@ -51,7 +51,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test04",
 	.tcnt = 2,
 	.test = do_test,
 	.setup = setup,
diff --git a/lib/newlib_tests/test05.c b/lib/newlib_tests/test05.c
index 886e04d..640abe4 100644
--- a/lib/newlib_tests/test05.c
+++ b/lib/newlib_tests/test05.c
@@ -47,7 +47,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test05",
 	.test_all = do_test,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/lib/newlib_tests/test06.c b/lib/newlib_tests/test06.c
index 22381fb..cce1768 100644
--- a/lib/newlib_tests/test06.c
+++ b/lib/newlib_tests/test06.c
@@ -47,7 +47,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test06",
 	.test_all = do_test,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/lib/newlib_tests/test07.c b/lib/newlib_tests/test07.c
index f067135..8c06506 100644
--- a/lib/newlib_tests/test07.c
+++ b/lib/newlib_tests/test07.c
@@ -45,7 +45,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test07",
 	.test_all = do_test,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/lib/newlib_tests/test08.c b/lib/newlib_tests/test08.c
index 77d530e..5463b53 100644
--- a/lib/newlib_tests/test08.c
+++ b/lib/newlib_tests/test08.c
@@ -70,7 +70,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test08",
 	.test_all = do_test,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/lib/newlib_tests/test09.c b/lib/newlib_tests/test09.c
index 0674754..02911bd 100644
--- a/lib/newlib_tests/test09.c
+++ b/lib/newlib_tests/test09.c
@@ -56,6 +56,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "test09",
 	.test_all = do_test,
 };
diff --git a/lib/newlib_tests/test10.c b/lib/newlib_tests/test10.c
index 01d4807..d0ad7a2 100644
--- a/lib/newlib_tests/test10.c
+++ b/lib/newlib_tests/test10.c
@@ -27,7 +27,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test10",
 	.test_all = do_test,
 	.timeout = 1,
 };
diff --git a/lib/newlib_tests/test11.c b/lib/newlib_tests/test11.c
index 1354f52..211e7e6 100644
--- a/lib/newlib_tests/test11.c
+++ b/lib/newlib_tests/test11.c
@@ -29,6 +29,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "test11",
 	.test_all = do_test,
 };
diff --git a/lib/newlib_tests/test12.c b/lib/newlib_tests/test12.c
index c7901f4..47ca735 100644
--- a/lib/newlib_tests/test12.c
+++ b/lib/newlib_tests/test12.c
@@ -26,7 +26,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test12",
 	.timeout = 2,
 	.test_all = do_test,
 };
diff --git a/lib/newlib_tests/test13.c b/lib/newlib_tests/test13.c
index 7ad5172..e71af19 100644
--- a/lib/newlib_tests/test13.c
+++ b/lib/newlib_tests/test13.c
@@ -30,7 +30,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test13",
 	.timeout = 1,
 	.forks_child = 1,
 	.test_all = do_test,
diff --git a/lib/newlib_tests/test14.c b/lib/newlib_tests/test14.c
index 4d94978..56d6d2f 100644
--- a/lib/newlib_tests/test14.c
+++ b/lib/newlib_tests/test14.c
@@ -39,7 +39,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test14",
 	.test_all = do_test,
 	.cleanup = cleanup,
 };
diff --git a/lib/newlib_tests/tst_device.c b/lib/newlib_tests/tst_device.c
index 9bcdce1..3314901 100644
--- a/lib/newlib_tests/tst_device.c
+++ b/lib/newlib_tests/tst_device.c
@@ -44,7 +44,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "tst_device",
 	.needs_tmpdir = 1,
 	.needs_device = 1,
 	.dev_min_size = 300,
diff --git a/lib/newlib_tests/tst_res_hexd.c b/lib/newlib_tests/tst_res_hexd.c
index 333ea56..bff9edd 100644
--- a/lib/newlib_tests/tst_res_hexd.c
+++ b/lib/newlib_tests/tst_res_hexd.c
@@ -26,6 +26,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "tst_res_hexd",
 	.test_all = do_test,
 };
diff --git a/lib/newlib_tests/tst_safe_fileops.c b/lib/newlib_tests/tst_safe_fileops.c
index bdf4e9d..1b8d523 100644
--- a/lib/newlib_tests/tst_safe_fileops.c
+++ b/lib/newlib_tests/tst_safe_fileops.c
@@ -35,6 +35,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "tst_safe_fileops",
 	.test_all = do_test,
 };
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index a6b4ff7..7ca1849 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -895,3 +895,30 @@
 
 	return rval;
 }
+
+pid_t safe_setsid(const char *file, const int lineno)
+{
+	pid_t rval;
+
+	rval = setsid();
+	if (rval == -1) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: setsid() failed", file, lineno);
+	}
+
+	return rval;
+}
+
+int safe_mknod(const char *file, const int lineno, const char *pathname,
+	mode_t mode, dev_t dev)
+{
+	int rval;
+
+	rval = mknod(pathname, mode, dev);
+	if (rval == -1) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: mknod() failed", file, lineno);
+	}
+
+	return rval;
+}
diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
new file mode 100644
index 0000000..87413a3
--- /dev/null
+++ b/lib/tst_clocks.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * clock_gettime() and clock_getres() functions
+ */
+
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <time.h>
+#include <sys/syscall.h>
+
+#include "tst_clocks.h"
+
+int tst_clock_getres(clockid_t clk_id, struct timespec *res)
+{
+	return syscall(SYS_clock_getres, clk_id, res);
+}
+
+int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
+{
+	return syscall(SYS_clock_gettime, clk_id, ts);
+}
diff --git a/lib/tst_device.c b/lib/tst_device.c
index c3cc478..67432ca 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -41,7 +41,7 @@
 #define LOOP_CONTROL_FILE "/dev/loop-control"
 
 #define DEV_FILE "test_dev.img"
-#define DEV_SIZE_MB 256
+#define DEV_SIZE_MB 256u
 
 static char dev_path[1024];
 static int device_acquired;
@@ -206,7 +206,7 @@
 	unsigned int acq_dev_size;
 	uint64_t ltp_dev_size;
 
-	acq_dev_size = size > DEV_SIZE_MB ? size : DEV_SIZE_MB;
+	acq_dev_size = MAX(size, DEV_SIZE_MB);
 
 	dev = getenv("LTP_DEV");
 
diff --git a/lib/tst_res.c b/lib/tst_res.c
index ff0ad68..8cf5f0d 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -91,6 +91,7 @@
 static void tst_print(const char *tcid, int tnum, int ttype, const char *tmesg);
 
 static int T_exitval = 0;	/* exit value used by tst_exit() */
+static int passed_cnt;
 static int T_mode = VERBOSE;	/* flag indicating print mode: VERBOSE, */
 				/* NOPASS, DISCARD */
 
@@ -166,6 +167,9 @@
 	 */
 	T_exitval |= ttype_result;
 
+	if (ttype_result == TPASS)
+		passed_cnt++;
+
 	check_env();
 
 	/*
@@ -390,7 +394,12 @@
 
 	tst_flush();
 
-	exit(T_exitval & ~TINFO);
+	T_exitval &= ~TINFO;
+
+	if (T_exitval == TCONF && passed_cnt)
+		T_exitval &= ~TCONF;
+
+	exit(T_exitval);
 }
 
 pid_t tst_fork(void)
diff --git a/lib/tst_resource.c b/lib/tst_resource.c
index 78450df..0b9b381 100644
--- a/lib/tst_resource.c
+++ b/lib/tst_resource.c
@@ -46,7 +46,7 @@
 	int ret;
 
 	/* 1. if LTPROOT is set, use $LTPROOT/testcases/data/$TCID
-	 * 2. else if startwd is set by tst_tmdir(), use $STARWD/datafiles
+	 * 2. else if startwd is set by tst_tmpdir(), use $STARWD/datafiles
 	 * 3. else use $CWD/datafiles */
 	if (ltproot) {
 		ret = snprintf(dataroot, PATH_MAX, "%s/testcases/data/%s",
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index e7f5095..b65a22b 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -17,9 +17,15 @@
 
 #define _GNU_SOURCE
 #include <unistd.h>
+#include <errno.h>
+#include "config.h"
+#ifdef HAVE_SYS_FANOTIFY_H
+# include <sys/fanotify.h>
+#endif
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_safe_macros.h"
+#include "lapi/personality.h"
 
 int safe_setpgid(const char *file, const int lineno, pid_t pid, pid_t pgid)
 {
@@ -47,3 +53,39 @@
 
 	return pgid;
 }
+
+int safe_fanotify_init(const char *file, const int lineno,
+	unsigned int flags, unsigned int event_f_flags)
+{
+	int rval;
+
+#ifdef HAVE_SYS_FANOTIFY_H
+	rval = fanotify_init(flags, event_f_flags);
+
+	if (rval == -1) {
+		if (errno == ENOSYS) {
+			tst_brk(TCONF,
+				"fanotify is not configured in this kernel.");
+		}
+		tst_brk(TBROK | TERRNO,
+			"%s:%d: fanotify_init() failed", file, lineno);
+	}
+#else
+	tst_brk(TCONF, "Header <sys/fanotify.h> is not present");
+#endif /* HAVE_SYS_FANOTIFY_H */
+
+	return rval;
+}
+
+int safe_personality(const char *filename, unsigned int lineno,
+		    unsigned long persona)
+{
+	int prev_persona = personality(persona);
+
+	if (prev_persona < 0) {
+		tst_brk_(filename, lineno, TBROK | TERRNO,
+			 "persona(%ld) failed", persona);
+	}
+
+	return prev_persona;
+}
diff --git a/lib/tst_safe_sysv_ipc.c b/lib/tst_safe_sysv_ipc.c
index cb2b304..ff53a24 100644
--- a/lib/tst_safe_sysv_ipc.c
+++ b/lib/tst_safe_sysv_ipc.c
@@ -18,6 +18,7 @@
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
+#include <sys/shm.h>
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_safe_sysv_ipc.h"
@@ -68,7 +69,7 @@
 int safe_msgctl(const char *file, const int lineno, int msqid, int cmd,
 		struct msqid_ds *buf)
 {
-	int  rval;
+	int rval;
 
 	rval = msgctl(msqid, cmd, buf);
 	if (rval == -1) {
@@ -78,3 +79,58 @@
 
 	return rval;
 }
+
+int safe_shmget(const char *file, const int lineno, key_t key, size_t size,
+		int shmflg)
+{
+	int rval;
+
+	rval = shmget(key, size, shmflg);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO, "%s:%d: shmget(%i, %zu, %x) failed",
+			file, lineno, (int)key, size, shmflg);
+	}
+
+	return rval;
+}
+
+void *safe_shmat(const char *file, const int lineno, int shmid,
+		const void *shmaddr, int shmflg)
+{
+	void *rval;
+
+	rval = shmat(shmid, shmaddr, shmflg);
+	if (rval == (void *)-1) {
+		tst_brk(TBROK | TERRNO, "%s:%d: shmat(%i, %p, %x) failed",
+			file, lineno, shmid, shmaddr, shmflg);
+	}
+
+	return rval;
+}
+
+int safe_shmdt(const char *file, const int lineno, const void *shmaddr)
+{
+	int rval;
+
+	rval = shmdt(shmaddr);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO, "%s:%d: shmdt(%p) failed",
+			file, lineno, shmaddr);
+	}
+
+	return rval;
+}
+
+int safe_shmctl(const char *file, const int lineno, int shmid, int cmd,
+		struct shmid_ds *buf)
+{
+	int rval;
+
+	rval = shmctl(shmid, cmd, buf);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO, "%s:%d: shmctl(%i, %i, %p) failed",
+			file, lineno, shmid, cmd, buf);
+	}
+
+	return rval;
+}
diff --git a/lib/tst_test.c b/lib/tst_test.c
index fa1417f..a627242 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <sys/mount.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/time.h>
@@ -29,7 +30,9 @@
 #include "tst_test.h"
 #include "tst_device.h"
 #include "lapi/futex.h"
+#include "lapi/syscalls.h"
 #include "tst_ansi_color.h"
+#include "tst_timer_test.h"
 
 #include "old_resource.h"
 #include "old_device.h"
@@ -40,7 +43,7 @@
 static int iterations = 1;
 static float duration = -1;
 static pid_t main_pid, lib_pid;
-static int device_mounted;
+static int mntpoint_mounted;
 
 struct results {
 	int passed;
@@ -116,11 +119,13 @@
 	if (ipc_fd > 0 && close(ipc_fd))
 		tst_res(TWARN | TERRNO, "close(ipc_fd) failed");
 
-	if (!access(shm_path, F_OK) && unlink(shm_path))
+	if (shm_path[0] && !access(shm_path, F_OK) && unlink(shm_path))
 		tst_res(TWARN | TERRNO, "unlink(%s) failed", shm_path);
 
-	msync((void*)results, size, MS_SYNC);
-	munmap((void*)results, size);
+	if (results) {
+		msync((void*)results, size, MS_SYNC);
+		munmap((void*)results, size);
+	}
 }
 
 void tst_reinit(void)
@@ -273,7 +278,13 @@
 {
 	print_result(file, lineno, ttype, fmt, va);
 
-	if (getpid() == main_pid)
+	/*
+	 * The getpid implementation in some C library versions may cause cloned
+	 * test threads to show the same pid as their parent when CLONE_VM is
+	 * specified but CLONE_THREAD is not. Use direct syscall to avoid
+	 * cleanup running in the child.
+	 */
+	if (syscall(SYS_getpid) == main_pid)
 		do_test_cleanup();
 
 	if (getpid() == lib_pid)
@@ -558,7 +569,7 @@
 		if (results->failed)
 			ret |= TFAIL;
 
-		if (results->skipped)
+		if (results->skipped && !results->passed)
 			ret |= TCONF;
 
 		if (results->warnings)
@@ -616,28 +627,68 @@
 		TST_RESOURCE_COPY(NULL, tst_test->resource_files[i], NULL);
 }
 
+static const char *get_tid(char *argv[])
+{
+	char *p;
+
+	if (!argv[0] || !argv[0][0]) {
+		tst_res(TINFO, "argv[0] is empty!");
+		return "ltp_empty_argv";
+	}
+
+	p = strrchr(argv[0], '/');
+	if (p)
+		return p+1;
+
+	return argv[0];
+}
+
 static struct tst_device tdev;
 struct tst_device *tst_device;
 
+static void assert_test_fn(void)
+{
+	int cnt = 0;
+
+	if (tst_test->test)
+		cnt++;
+
+	if (tst_test->test_all)
+		cnt++;
+
+	if (tst_test->sample)
+		cnt++;
+
+	if (!cnt)
+		tst_brk(TBROK, "No test function speficied");
+
+	if (cnt != 1)
+		tst_brk(TBROK, "You can define only one test function");
+
+	if (tst_test->test && !tst_test->tcnt)
+		tst_brk(TBROK, "Number of tests (tcnt) must not be > 0");
+
+	if (!tst_test->test && tst_test->tcnt)
+		tst_brk(TBROK, "You can define tcnt only for test()");
+}
+
 static void do_setup(int argc, char *argv[])
 {
 	if (!tst_test)
 		tst_brk(TBROK, "No tests to run");
 
+	if (tst_test->tconf_msg)
+		tst_brk(TCONF, "%s", tst_test->tconf_msg);
+
+	assert_test_fn();
+
+	if (tst_test->sample)
+		tst_test = tst_timer_test_setup(tst_test);
+
 	if (!tst_test->tid)
-		tst_brk(TBROK, "No tid set in test structure");
+		tst_test->tid = get_tid(argv);
 
-	if (!tst_test->test && !tst_test->test_all)
-		tst_brk(TBROK, "No test function speficied");
-
-	if (tst_test->test && tst_test->test_all)
-		tst_brk(TBROK, "You can define either test() or test_all()");
-
-	if (tst_test->test && !tst_test->tcnt)
-		tst_brk(TBROK, "Number of tests (tcnt) must not be > 0");
-
-	if (tst_test->test_all && tst_test->tcnt)
-		tst_brk(TBROK, "You can't define tcnt for test_all()");
+	parse_opts(argc, argv);
 
 	if (tst_test->needs_root && geteuid() != 0)
 		tst_brk(TCONF, "Test needs to be run as root");
@@ -653,14 +704,37 @@
 		tst_test->format_device = 1;
 	}
 
-	parse_opts(argc, argv);
-
 	setup_ipc();
 
 	if (needs_tmpdir() && !tst_tmpdir_created())
 		tst_tmpdir();
 
-	if (tst_test->needs_device) {
+	if (tst_test->mntpoint)
+		SAFE_MKDIR(tst_test->mntpoint, 0777);
+
+	if ((tst_test->needs_rofs || tst_test->mount_device) &&
+	    !tst_test->mntpoint) {
+		tst_brk(TBROK, "tst_test->mntpoint must be set!");
+	}
+
+	if (tst_test->needs_rofs) {
+		/* If we failed to mount read-only tmpfs. Fallback to
+		 * using a device with empty read-only filesystem.
+		 */
+		if (mount(NULL, tst_test->mntpoint, "tmpfs", MS_RDONLY, NULL)) {
+			tst_res(TINFO | TERRNO, "Can't mount tmpfs read-only"
+				" at %s, setting up a device instead\n",
+				tst_test->mntpoint);
+			tst_test->mount_device = 1;
+			tst_test->needs_device = 1;
+			tst_test->format_device = 1;
+			tst_test->mnt_flags = MS_RDONLY;
+		} else {
+			mntpoint_mounted = 1;
+		}
+	}
+
+	if (tst_test->needs_device && !mntpoint_mounted) {
 		tdev.dev = tst_acquire_device_(NULL, tst_test->dev_min_size);
 
 		if (!tdev.dev)
@@ -680,16 +754,9 @@
 		}
 
 		if (tst_test->mount_device) {
-
-			if (!tst_test->mntpoint) {
-				tst_brk(TBROK,
-					"tst_test->mntpoint must be set!");
-			}
-
-			SAFE_MKDIR(tst_test->mntpoint, 0777);
 			SAFE_MOUNT(tdev.dev, tst_test->mntpoint, tdev.fs_type,
 				   tst_test->mnt_flags, tst_test->mnt_data);
-			device_mounted = 1;
+			mntpoint_mounted = 1;
 		}
 	}
 
@@ -710,7 +777,7 @@
 
 static void do_cleanup(void)
 {
-	if (device_mounted)
+	if (mntpoint_mounted)
 		tst_umount(tst_test->mntpoint);
 
 	if (tst_test->needs_device && tdev.dev)
@@ -805,32 +872,52 @@
 
 static pid_t test_pid;
 
+
+static volatile sig_atomic_t sigkill_retries;
+
+#define WRITE_MSG(msg) do { \
+	if (write(2, msg, sizeof(msg) - 1)) { \
+		/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 */ \
+	} \
+} while (0)
+
 static void alarm_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
+	WRITE_MSG("Test timeouted, sending SIGKILL!\n");
 	kill(-test_pid, SIGKILL);
+	alarm(5);
+
+	if (++sigkill_retries > 10) {
+		WRITE_MSG("Cannot kill test processes!\n");
+		WRITE_MSG("Congratulation, likely test hit a kernel bug.\n");
+		WRITE_MSG("Exitting uncleanly...\n");
+		_exit(TFAIL);
+	}
 }
 
 static void heartbeat_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
 	alarm(results->timeout);
+	sigkill_retries = 0;
 }
 
-#define SIGINT_MSG "Sending SIGKILL to test process...\n"
-
 static void sigint_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
 	if (test_pid > 0) {
-		if (write(2, SIGINT_MSG, sizeof(SIGINT_MSG) - 1)) {
-			/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 */
-		}
+		WRITE_MSG("Sending SIGKILL to test process...\n");
 		kill(-test_pid, SIGKILL);
 	}
 }
 
-void tst_set_timeout(unsigned int timeout)
+void tst_set_timeout(int timeout)
 {
 	char *mul = getenv("LTP_TIMEOUT_MUL");
 
+	if (timeout == -1) {
+		tst_res(TINFO, "Timeout per run is disabled");
+		return;
+	}
+
 	results->timeout = timeout;
 
 	if (mul) {
@@ -858,10 +945,11 @@
 
 	lib_pid = getpid();
 	tst_test = self;
-	TCID = tst_test->tid;
 
 	do_setup(argc, argv);
 
+	TCID = tst_test->tid;
+
 	SAFE_SIGNAL(SIGALRM, alarm_handler);
 	SAFE_SIGNAL(SIGUSR1, heartbeat_handler);
 
diff --git a/lib/tst_timer.c b/lib/tst_timer.c
index bd3f277..afdb441 100644
--- a/lib/tst_timer.c
+++ b/lib/tst_timer.c
@@ -25,6 +25,7 @@
 
 #include "test.h"
 #include "tst_timer.h"
+#include "tst_clocks.h"
 #include "lapi/posix_clocks.h"
 
 static struct timespec start_time, stop_time;
@@ -56,7 +57,7 @@
 
 void tst_timer_check(clockid_t clk_id)
 {
-	if (clock_gettime(clk_id, &start_time)) {
+	if (tst_clock_gettime(clk_id, &start_time)) {
 		if (errno == EINVAL) {
 			tst_brkm(TCONF, NULL,
 			         "Clock id %s(%u) not supported by kernel",
@@ -64,7 +65,7 @@
 			return;
 		}
 
-		tst_brkm(TBROK | TERRNO, NULL, "clock_gettime() failed");
+		tst_brkm(TBROK | TERRNO, NULL, "tst_clock_gettime() failed");
 	}
 }
 
@@ -72,14 +73,14 @@
 {
 	clock_id = clk_id;
 
-	if (clock_gettime(clock_id, &start_time))
-		tst_resm(TWARN | TERRNO, "clock_gettime() failed");
+	if (tst_clock_gettime(clock_id, &start_time))
+		tst_resm(TWARN | TERRNO, "tst_clock_gettime() failed");
 }
 
 void tst_timer_stop(void)
 {
-	if (clock_gettime(clock_id, &stop_time))
-		tst_resm(TWARN | TERRNO, "clock_gettime() failed");
+	if (tst_clock_gettime(clock_id, &stop_time))
+		tst_resm(TWARN | TERRNO, "tst_clock_gettime() failed");
 }
 
 struct timespec tst_timer_elapsed(void)
diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
new file mode 100644
index 0000000..cd4ebca
--- /dev/null
+++ b/lib/tst_timer_test.c
@@ -0,0 +1,476 @@
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/prctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+#include "tst_clocks.h"
+#include "tst_timer_test.h"
+
+#define MAX_SAMPLES 500
+
+static const char *scall;
+static void (*setup)(void);
+static void (*cleanup)(void);
+static int (*sample)(int clk_id, long long usec);
+static struct tst_test *test;
+
+static long long *samples;
+static unsigned int cur_sample;
+static unsigned int monotonic_resolution;
+static unsigned int timerslack;
+
+static char *print_frequency_plot;
+static char *file_name;
+static char *str_sleep_time;
+static char *str_sample_cnt;
+static int sleep_time = -1;
+static int sample_cnt;
+
+static void print_line(char c, int len)
+{
+	while (len-- > 0)
+		fputc(c, stderr);
+}
+
+static unsigned int ceilu(float f)
+{
+	if (f - (int)f > 0)
+		return (unsigned int)f + 1;
+
+	return (unsigned int)f;
+}
+
+static unsigned int flooru(float f)
+{
+	return (unsigned int)f;
+}
+
+static float bucket_len(unsigned int bucket, unsigned int max_bucket,
+		        unsigned int cols)
+{
+	return 1.00 * bucket * cols / max_bucket;
+}
+
+static const char *table_heading = " Time: us ";
+
+/*
+ * Line Header: '10023 | '
+ */
+static unsigned int header_len(long long max_sample)
+{
+	unsigned int l = 1;
+
+	while (max_sample/=10)
+		l++;
+
+	return MAX(strlen(table_heading) + 2, l + 3);
+}
+
+static void frequency_plot(void)
+{
+	unsigned int cols = 80;
+	unsigned int rows = 20;
+	unsigned int i, buckets[rows];
+	long long max_sample = samples[0];
+	long long min_sample = samples[cur_sample-1];
+	unsigned int line_header_len = header_len(max_sample);
+	unsigned int plot_line_len = cols - line_header_len;
+	unsigned int bucket_size;
+
+	memset(buckets, 0, sizeof(buckets));
+
+	/*
+	 * We work with discrete data buckets smaller than 1 does not make
+	 * sense as well as it's a good idea to keep buckets integer sized
+	 * to avoid scaling artifacts.
+	 */
+	bucket_size = MAX(1u, ceilu(1.00 * (max_sample - min_sample)/(rows-1)));
+
+	for (i = 0; i < cur_sample; i++) {
+		unsigned int bucket;
+		bucket = flooru(1.00 * (samples[i] - min_sample)/bucket_size);
+		buckets[bucket]++;
+	}
+
+	unsigned int max_bucket = buckets[0];
+	for (i = 1; i < rows; i++)
+		max_bucket = MAX(max_bucket, buckets[i]);
+
+	fprintf(stderr, "\n%*s| Frequency\n", line_header_len - 2, table_heading);
+
+	print_line('-', cols);
+	fputc('\n', stderr);
+
+	unsigned int l, r;
+
+	for (l = 0; l < rows; l++) {
+		if (buckets[l])
+			break;
+	}
+
+	for (r = rows-1; r > l; r--) {
+		if (buckets[r])
+			break;
+	}
+
+	for (i = l; i <= r; i++) {
+		float len = bucket_len(buckets[i], max_bucket, plot_line_len);
+
+		fprintf(stderr, "%*lli | ",
+			line_header_len - 3, min_sample + bucket_size*i);
+		print_line('*', len);
+
+		if ((len - (int)len) >= 0.5)
+			fputc('+', stderr);
+		else if ((len - (int)len) >= 0.25)
+			fputc('-', stderr);
+		else if (len < 0.25 && buckets[i])
+			fputc('.', stderr);
+
+		fputc('\n', stderr);
+	}
+
+	print_line('-', cols);
+	fputc('\n', stderr);
+
+	float scale = 1.00 * plot_line_len / max_bucket;
+
+	fprintf(stderr,
+		"%*uus | 1 sample = %.5f '*', %.5f '+', %.5f '-', non-zero '.'\n",
+		line_header_len - 5, bucket_size, scale, scale * 2, scale * 4);
+
+	fputc('\n', stderr);
+}
+
+void tst_timer_sample(void)
+{
+	samples[cur_sample++] = tst_timer_elapsed_us();
+}
+
+static int cmp(const void *a, const void *b)
+{
+	const long long *aa = a, *bb = b;
+
+	return *aa < *bb;
+}
+
+/*
+ * The threshold per one syscall is computed as a sum of:
+ *
+ *  400 us                 - accomodates for context switches, process
+ *                           migrations between CPUs on SMP, etc.
+ *  2*monotonic_resolution - accomodates for granurality of the CLOCK_MONOTONIC
+ *  slack_per_scall        - max of 0.1% of the sleep capped on 100ms or
+ *                           current->timer_slack_ns, which is slack allowed
+ *                           in kernel
+ *
+ *  The formula	for slack_per_scall applies to select() and *poll*() syscalls,
+ *  the futex and *nanosleep() use only the timer_slack_ns, so we are a bit
+ *  less strict here that we could be for these two for longer sleep times...
+ *
+ * We also allow for outliners, i.e. add some number to the threshold in case
+ * that the number of iteration is small. For large enoung number of iterations
+ * outliners are discarded and averaged out.
+ */
+static long long compute_threshold(long long requested_us,
+				   unsigned int nsamples)
+{
+	unsigned int slack_per_scall = MIN(100000, requested_us / 1000);
+
+	slack_per_scall = MAX(slack_per_scall, timerslack);
+
+	return (400 + 2 * monotonic_resolution + slack_per_scall) * nsamples
+		+ 3000/nsamples;
+}
+
+/*
+ * Returns number of samples to discard.
+ *
+ * We set it to either at least 1 if number of samples > 1 or 5%.
+ */
+static unsigned int compute_discard(unsigned int nsamples)
+{
+	if (nsamples == 1)
+		return 0;
+
+	return MAX(1u, nsamples / 20);
+}
+
+static void write_to_file(void)
+{
+	unsigned int i;
+	FILE *f;
+
+	if (!file_name)
+		return;
+
+	f = fopen(file_name, "w");
+
+	if (!f) {
+		tst_res(TWARN | TERRNO,
+			"Failed to open '%s'", file_name);
+		return;
+	}
+
+	for (i = 0; i < cur_sample; i++)
+		fprintf(f, "%lli\n", samples[i]);
+
+	if (fclose(f)) {
+		tst_res(TWARN | TERRNO,
+			"Failed to close file '%s'", file_name);
+	}
+}
+
+
+/*
+ * Timer testing function.
+ *
+ * What we do here is:
+ *
+ * * Take nsamples measurements of the timer function, the function
+ *   to be sampled is defined in the the actual test.
+ *
+ * * We sort the array of samples, then:
+ *
+ *   - look for outliners which are samples where the sleep time has exceeded
+ *     requested sleep time by an order of magnitude and, at the same time, are
+ *     greater than clock resolution multiplied by three.
+ *
+ *   - check for samples where the call has woken up too early which is a plain
+ *     old bug
+ *
+ *   - then we compute truncated mean and compare that with the requested sleep
+ *     time increased by a threshold
+ */
+void do_timer_test(long long usec, unsigned int nsamples)
+{
+	long long trunc_mean, median;
+	unsigned int discard = compute_discard(nsamples);
+	unsigned int keep_samples = nsamples - discard;
+	long long threshold = compute_threshold(usec, keep_samples);
+	int i;
+	int failed = 0;
+
+	tst_res(TINFO,
+		"%s sleeping for %llius %u iterations, threshold %.2fus",
+		scall, usec, nsamples, 1.00 * threshold / (keep_samples));
+
+	cur_sample = 0;
+	for (i = 0; i < (int)nsamples; i++) {
+		if (sample(CLOCK_MONOTONIC, usec)) {
+			tst_res(TINFO, "sampling function failed, exitting");
+			return;
+		}
+	}
+
+	qsort(samples, nsamples, sizeof(samples[0]), cmp);
+
+	write_to_file();
+
+	for (i = 0; samples[i] > 10 * usec && i < (int)nsamples; i++) {
+		if (samples[i] <= 3 * monotonic_resolution)
+			break;
+	}
+
+	if (i > 0) {
+		tst_res(TINFO, "Found %i outliners in [%lli,%lli] range",
+			i, samples[0], samples[i-1]);
+	}
+
+	for (i = nsamples - 1; samples[i] < usec && i > -1; i--);
+
+	if (i < (int)nsamples - 1) {
+		tst_res(TFAIL, "%s woken up early %u times range: [%lli,%lli]",
+			scall, nsamples - 1 - i,
+			samples[i+1], samples[nsamples-1]);
+		failed = 1;
+	}
+
+	median = samples[nsamples/2];
+
+	trunc_mean = 0;
+
+	for (i = discard; i < (int)nsamples; i++)
+		trunc_mean += samples[i];
+
+	tst_res(TINFO,
+		"min %llius, max %llius, median %llius, trunc mean %.2fus (discarded %u)",
+		samples[nsamples-1], samples[0], median,
+		1.00 * trunc_mean / keep_samples, discard);
+
+	if (trunc_mean > (nsamples - discard) * usec + threshold) {
+		tst_res(TFAIL, "%s slept for too long", scall);
+
+		if (!print_frequency_plot)
+			frequency_plot();
+
+		failed = 1;
+	}
+
+	if (print_frequency_plot)
+		frequency_plot();
+
+	if (!failed)
+		tst_res(TPASS, "Measured times are within thresholds");
+}
+
+static void parse_timer_opts(void);
+
+static int set_latency(void)
+{
+        int fd, latency = 0;
+
+        fd = open("/dev/cpu_dma_latency", O_WRONLY);
+        if (fd < 0)
+                return fd;
+
+        return write(fd, &latency, sizeof(latency));
+}
+
+static void timer_setup(void)
+{
+	struct timespec t;
+	int ret;
+
+	tst_clock_getres(CLOCK_MONOTONIC, &t);
+
+	tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec);
+
+	monotonic_resolution = t.tv_nsec / 1000;
+	timerslack = 50;
+
+#ifdef PR_GET_TIMERSLACK
+	ret = prctl(PR_GET_TIMERSLACK);
+	if (ret < 0) {
+		tst_res(TINFO, "prctl(PR_GET_TIMERSLACK) = -1, using %uus",
+			timerslack);
+	} else {
+		timerslack = ret / 1000;
+		tst_res(TINFO, "prctl(PR_GET_TIMERSLACK) = %ius", timerslack);
+	}
+#else
+	tst_res(TINFO, "PR_GET_TIMERSLACK not defined, using %uus",
+		timerslack);
+#endif /* PR_GET_TIMERSLACK */
+
+	parse_timer_opts();
+
+	samples = SAFE_MALLOC(sizeof(long long) * MAX(MAX_SAMPLES, sample_cnt));
+
+	if (set_latency() < 0)
+		tst_res(TINFO, "Failed to set zero latency constraint: %m");
+
+	if (setup)
+		setup();
+}
+
+static void timer_cleanup(void)
+{
+	free(samples);
+
+	if (cleanup)
+		cleanup();
+}
+
+static struct tst_timer_tcase {
+	long long usec;
+	unsigned int samples;
+} tcases[] = {
+	{1000,  500},
+	{2000,  500},
+	{5000,  300},
+	{10000, 100},
+	{25000,  50},
+	{100000, 10},
+	{1000000, 2},
+};
+
+static void timer_test_fn(unsigned int n)
+{
+	do_timer_test(tcases[n].usec, tcases[n].samples);
+}
+
+static void single_timer_test(void)
+{
+	do_timer_test(sleep_time, sample_cnt);
+}
+
+static struct tst_option options[] = {
+	{"p",  &print_frequency_plot, "-p       Print frequency plot"},
+	{"s:", &str_sleep_time, "-s us    Sleep time"},
+	{"n:", &str_sample_cnt, "-n uint  Number of samples to take"},
+	{"f:", &file_name, "-f fname Write measured samples into a file"},
+	{NULL, NULL, NULL}
+};
+
+static void parse_timer_opts(void)
+{
+	if (str_sleep_time) {
+		if (tst_parse_int(str_sleep_time, &sleep_time, 0, INT_MAX)) {
+			tst_brk(TBROK,
+				"Invalid sleep time '%s'", str_sleep_time);
+		}
+	}
+
+	if (str_sample_cnt) {
+		if (tst_parse_int(str_sample_cnt, &sample_cnt, 1, INT_MAX)) {
+			tst_brk(TBROK,
+				"Invalid sample count '%s'", str_sample_cnt);
+		}
+	}
+
+	if (str_sleep_time || str_sample_cnt) {
+		if (sleep_time < 0)
+			sleep_time = 10000;
+
+		if (!sample_cnt)
+			sample_cnt = 500;
+
+		long long timeout = sleep_time * sample_cnt / 1000000;
+
+		tst_set_timeout(timeout + timeout/10);
+
+		test->test_all = single_timer_test;
+		test->test = NULL;
+		test->tcnt = 0;
+	}
+}
+
+struct tst_test *tst_timer_test_setup(struct tst_test *timer_test)
+{
+	setup = timer_test->setup;
+	cleanup = timer_test->cleanup;
+	scall = timer_test->tid;
+	sample = timer_test->sample;
+
+	timer_test->tid = NULL;
+	timer_test->setup = timer_setup;
+	timer_test->cleanup = timer_cleanup;
+	timer_test->test = timer_test_fn;
+	timer_test->tcnt = ARRAY_SIZE(tcases);
+	timer_test->sample = NULL;
+	timer_test->options = options;
+
+	test = timer_test;
+
+	return timer_test;
+}
diff --git a/m4/ltp-mmsghdr.m4 b/m4/ltp-mmsghdr.m4
new file mode 100644
index 0000000..0552218
--- /dev/null
+++ b/m4/ltp-mmsghdr.m4
@@ -0,0 +1,22 @@
+dnl Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([LTP_CHECK_MMSGHDR],[
+AC_CHECK_TYPES([struct mmsghdr],,,[
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/socket.h>
+])
+])
diff --git a/m4/ltp-uname.m4 b/m4/ltp-uname.m4
new file mode 100644
index 0000000..5a30022
--- /dev/null
+++ b/m4/ltp-uname.m4
@@ -0,0 +1,20 @@
+dnl Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([LTP_CHECK_UNAME_DOMAINNAME],[
+AC_CHECK_MEMBERS([struct utsname.domainname],,,[
+#define _GNU_SOURCE
+#include <sys/utsname.h>
+])])
diff --git a/m4/ltp-x_tables.m4 b/m4/ltp-x_tables.m4
new file mode 100644
index 0000000..cd6a600
--- /dev/null
+++ b/m4/ltp-x_tables.m4
@@ -0,0 +1,24 @@
+dnl Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([LTP_CHECK_X_TABLES],[
+AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <limits.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+])
+])
diff --git a/pan/ltp-pan.c b/pan/ltp-pan.c
index 1614c70..a2bb9b7 100644
--- a/pan/ltp-pan.c
+++ b/pan/ltp-pan.c
@@ -53,6 +53,7 @@
 
 #include <sys/param.h>
 #include <sys/stat.h>
+#include <stdarg.h>
 #include <sys/times.h>
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -97,7 +98,7 @@
 
 static pid_t run_child(struct coll_entry *colle, struct tag_pgrp *active,
 		       int quiet_mode, int *failcnt, int fmt_print,
-		       FILE * logfile);
+		       FILE * logfile, int no_kmsg);
 static char *slurp(char *file);
 static struct collection *get_collection(char *file, int optind, int argc,
 					 char **argv);
@@ -106,7 +107,7 @@
 		      int keep_active, FILE * logfile, FILE * failcmdfile,
 		      FILE *tconfcmdfile, struct orphan_pgrp *orphans,
 		      int fmt_print, int *failcnt, int *tconfcnt,
-		      int quiet_mode);
+		      int quiet_mode, int no_kmsg);
 static void propagate_signal(struct tag_pgrp *running, int keep_active,
 			     struct orphan_pgrp *orphans);
 static void dump_coll(struct collection *coll);
@@ -116,7 +117,7 @@
 static void check_orphans(struct orphan_pgrp *orphans, int sig);
 
 static void copy_buffered_output(struct tag_pgrp *running);
-static void write_test_start(struct tag_pgrp *running);
+static void write_test_start(struct tag_pgrp *running, int no_kmsg);
 static void write_test_end(struct tag_pgrp *running, const char *init_status,
 			   time_t exit_time, char *term_type, int stat_loc,
 			   int term_id, struct tms *tms1, struct tms *tms2);
@@ -180,12 +181,13 @@
 	int track_exit_stats = 0;	/* exit non-zero if any test exits non-zero */
 	int fmt_print = 0;	/* enables formatted printing of logfiles. */
 	int quiet_mode = 0;	/* supresses test start and test end tags. */
+	int no_kmsg = 0;	/* don't log into /dev/kmsg */
 	int c;
 	pid_t cpid;
 	struct sigaction sa;
 
 	while ((c =
-		getopt(argc, argv, "AO:Sa:C:T:d:ef:hl:n:o:pqr:s:t:x:y"))
+		getopt(argc, argv, "AO:Sa:C:QT:d:ef:hl:n:o:pqr:s:t:x:y"))
 		       != -1) {
 		switch (c) {
 		case 'A':	/* all-stop flag */
@@ -204,6 +206,9 @@
 		case 'C':	/* name of the file where all failed commands will be */
 			failcmdfilename = strdup(optarg);
 			break;
+		case 'Q':
+			no_kmsg = 1;
+			break;
 		case 'T':
 			/*
 			 * test cases that are not fully tested will be recorded
@@ -222,7 +227,7 @@
 			break;
 		case 'h':	/* help */
 			fprintf(stdout,
-				"Usage: pan -n name [ -SyAehpq ] [ -s starts ]"
+				"Usage: pan -n name [ -SyAehpqQ ] [ -s starts ]"
 				" [-t time[s|m|h|d] [ -x nactive ] [ -l logfile ]\n\t"
 				"[ -a active-file ] [ -f command-file ] "
 				"[ -C fail-command-file ] "
@@ -537,7 +542,7 @@
 
 			cpid =
 			    run_child(coll->ary[c], running + i, quiet_mode,
-				      &failcnt, fmt_print, logfile);
+				      &failcnt, fmt_print, logfile, no_kmsg);
 			if (cpid != -1)
 				++num_active;
 			if ((cpid != -1 || sequential) && starts > 0)
@@ -586,7 +591,7 @@
 
 		err = check_pids(running, &num_active, keep_active, logfile,
 				 failcmdfile, tconfcmdfile, orphans, fmt_print,
-				 &failcnt, &tconfcnt, quiet_mode);
+				 &failcnt, &tconfcnt, quiet_mode, no_kmsg);
 		if (Debug & Drunning) {
 			pids_running(running, keep_active);
 			orphans_running(orphans);
@@ -704,7 +709,7 @@
 check_pids(struct tag_pgrp *running, int *num_active, int keep_active,
 	   FILE *logfile, FILE *failcmdfile, FILE *tconfcmdfile,
 	   struct orphan_pgrp *orphans, int fmt_print, int *failcnt,
-	   int *tconfcnt, int quiet_mode)
+	   int *tconfcnt, int quiet_mode, int no_kmsg)
 {
 	int w;
 	pid_t cpid;
@@ -847,7 +852,7 @@
 
 				if (test_out_dir) {
 					if (!quiet_mode)
-						write_test_start(running + i);
+						write_test_start(running + i, no_kmsg);
 					copy_buffered_output(running + i);
 					unlink(running[i].output);
 				}
@@ -893,7 +898,7 @@
 
 static pid_t
 run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode,
-	  int *failcnt, int fmt_print, FILE * logfile)
+	  int *failcnt, int fmt_print, FILE * logfile, int no_kmsg)
 {
 	ssize_t errlen;
 	int cpid;
@@ -945,9 +950,8 @@
 	time(&active->mystime);
 	active->cmd = colle;
 
-	if (!test_out_dir)
-		if (!quiet_mode)
-			write_test_start(active);
+	if (!test_out_dir && !quiet_mode)
+		write_test_start(active, no_kmsg);
 
 	fflush(NULL);
 
@@ -1109,7 +1113,6 @@
 		}
 
 		if (!quiet_mode) {
-			//write_test_start(active, errbuf);
 			write_test_end(active, errbuf, end_time, termtype,
 				       status, termid, &notime, &notime);
 		}
@@ -1352,7 +1355,24 @@
 	}
 }
 
-static void write_test_start(struct tag_pgrp *running)
+static void write_kmsg(const char *fmt, ...)
+{
+	FILE *kmsg;
+	va_list ap;
+
+	if ((kmsg = fopen("/dev/kmsg", "r+")) == NULL) {
+		fprintf(stderr, "Error %s: (%d) opening /dev/kmsg\n",
+				strerror(errno), errno);
+		exit(1);
+	}
+
+	va_start(ap, fmt);
+	vfprintf(kmsg, fmt, ap);
+	va_end(ap);
+	fclose(kmsg);
+}
+
+static void write_test_start(struct tag_pgrp *running, int no_kmsg)
 {
 	if (!strcmp(reporttype, "rts")) {
 
@@ -1362,6 +1382,14 @@
 		     running->cmd->cmdline, "", "exit", "<<<test_output>>>");
 	}
 	fflush(stdout);
+	if (no_kmsg)
+		return;
+
+	if (strcmp(running->cmd->name, running->cmd->cmdline))
+		write_kmsg("LTP: starting %s (%s)\n", running->cmd->name,
+			   running->cmd->cmdline);
+	else
+		write_kmsg("LTP: starting %s\n", running->cmd->name);
 }
 
 static void
diff --git a/runltp b/runltp
index f081805..8e40d67 100755
--- a/runltp
+++ b/runltp
@@ -110,7 +110,7 @@
     usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -T TCONFCMDFILE ]
     [ -d TMPDIR ] [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ]
     [ -g HTMLFILE] [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
-    -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
+    -N -n [ -o OUTPUTFILE ] -p -q -Q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
     -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B LTP_DEV_FS_TYPE]
 	[ -F LOOPS,PERCENTAGE ] [ -z BIG_DEVICE ] [-Z  LTP_BIG_DEV_FS_TYPE]
 
@@ -151,7 +151,9 @@
     -n              Run LTP with network traffic in background.
     -o OUTPUTFILE   Redirect test output to a file.
     -p              Human readable format logfiles.
-    -q              Print less verbose output to screen.
+    -q              Print less verbose output to screen. This implies
+                    not logging start of the test in kernel log.
+    -Q              Don't log start of test in kernel log.
     -r LTPROOT      Fully qualified path where testsuite is installed.
     -R              Randomize test order.
     -s PATTERN      Only run test cases which match PATTERN.
@@ -182,8 +184,8 @@
 
 main()
 {
-    local CMDFILES=""
-    local PRETTY_PRT=""
+    local CMDFILES=
+    local PRETTY_PRT=
     local ALT_DIR_OUT=0
     local ALT_DIR_RES=0
     local ALT_HTML_OUT=0
@@ -191,36 +193,37 @@
     local ALT_DMESG_OUT=0
     local RUN_NETEST=0
     local RUN_REPEATED=0
-    local QUIET_MODE=""
+    local QUIET_MODE=
+    local NO_KMSG=
     local NETPIPE=0
     local GENLOAD=0
     local MEMSIZE=0
-    local DURATION=""
-    local CMDFILEADDR=""
-    local FAILCMDFILE=""
-    local TCONFCMDFILE=""
-    local INJECT_KERNEL_FAULT=""
-    local INJECT_KERNEL_FAULT_PERCENTAGE=""
-    local INJECT_FAULT_LOOPS_PER_TEST=""
-    local VALGRIND_CHECK=""
-    local VALGRIND_CHECK_TYPE=""
-    local LOGFILE_NAME=""
-    local LOGFILE=""
-    local OUTPUTFILE_NAME=""
-    local OUTPUTFILE=""
-    local HTMLFILE_NAME=""
-    local HTMLFILE=""
-    local DMESG_DIR=""
-    local EMAIL_TO=""
-    local TAG_RESTRICT_STRING=""
-    local PAN_COMMAND=""
+    local DURATION=
+    local CMDFILEADDR=
+    local FAILCMDFILE=
+    local TCONFCMDFILE=
+    local INJECT_KERNEL_FAULT=
+    local INJECT_KERNEL_FAULT_PERCENTAGE=
+    local INJECT_FAULT_LOOPS_PER_TEST=
+    local VALGRIND_CHECK=
+    local VALGRIND_CHECK_TYPE=
+    local LOGFILE_NAME=
+    local LOGFILE=
+    local OUTPUTFILE_NAME=
+    local OUTPUTFILE=
+    local HTMLFILE_NAME=
+    local HTMLFILE=
+    local DMESG_DIR=
+    local EMAIL_TO=
+    local TAG_RESTRICT_STRING=
+    local PAN_COMMAND=
     local RANDOMRUN=0
     local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%m_%d-%Hh_%Mm_%Ss"`
     local scenfile=
 
     version_date=$(cat "$LTPROOT/Version")
 
-    while getopts a:c:C:T:d:D:f:F:ehi:I:K:g:l:m:M:Nno:pqr:Rs:S:t:T:w:x:b:B:z:Z: arg
+    while getopts a:b:B:c:C:T:d:D:ef:F:g:hi:I:K:l:m:M:No:pqQr:Rs:S:t:T:w:x:z:Z: arg
     do  case $arg in
         a)  EMAIL_TO=$OPTARG
             ALT_EMAIL_OUT=1;;
@@ -393,10 +396,6 @@
 
         N)  RUN_NETEST=1;;
 
-        n)
-            $LTPROOT/testcases/bin/netpipe.sh
-            NETPIPE=1;;
-
         o)  OUTPUTFILE_NAME="$OPTARG"
             case $OPTARG in
             /*)
@@ -406,9 +405,11 @@
                 ALT_DIR_OUT=1 ;;
             esac ;;
 
-        p)  PRETTY_PRT=" -p ";;
+        p)  PRETTY_PRT="-p";;
 
-        q)  QUIET_MODE=" -q ";;
+        q)  QUIET_MODE="-q";;
+
+        Q)  NO_KMSG="-Q";;
 
         r)  LTPROOT=$OPTARG;;
 
@@ -455,7 +456,7 @@
        LOGFILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
        LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
        ALT_DIR_RES=1
-       PRETTY_PRT=" -p "
+       PRETTY_PRT="-p"
     fi
 
     ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
@@ -749,7 +750,7 @@
     fi
 
     [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
-    PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
+    PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -S $INSTANCES $DURATION -a $$ \
     -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE"
     echo "COMMAND:    $PAN_COMMAND"
     if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
@@ -845,7 +846,7 @@
 	fi
     # Some tests need to run inside the "bin" directory.
     cd "${LTPROOT}/testcases/bin"
-    "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE
+    "${LTPROOT}/bin/ltp-pan" $QUIET_MODE $NO_KMSG -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE
 
     if [ $? -eq 0 ]; then
       echo "INFO: ltp-pan reported all tests PASS"
diff --git a/runtest/commands b/runtest/commands
index 682deda..00ae0d2 100644
--- a/runtest/commands
+++ b/runtest/commands
@@ -3,13 +3,13 @@
 ld01 ld01
 ldd01 ldd01
 nm01 nm01
-file01 file_test.sh
+file01 file01.sh
 tar01  tar_tests.sh
 cron cron_tests.sh
 logrotate export TCdat=$LTPROOT/testcases/bin; logrotate_tests.sh
 mail export TCdat=$LTPROOT/testcases/bin; mail_tests.sh
 cpio01 cpio_tests.sh
-unzip01 unzip_tests.sh
+unzip01 unzip01.sh
 gzip01 gzip_tests.sh
 cp01 cp_tests.sh
 ln01 ln_tests.sh
@@ -42,3 +42,4 @@
 insmod01 insmod01.sh
 wc01 wc01.sh
 keyctl01 keyctl01.sh
+gdb01 gdb01.sh
diff --git a/runtest/controllers b/runtest/controllers
index b904e05..2c43d0b 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -1,6 +1,7 @@
 #DESCRIPTION:Resource Management testing
 cgroup		cgroup_regression_test.sh
 memcg_regression	memcg_regression_test.sh
+memcg_test_3	memcg_test_3
 memcg_failcnt memcg_failcnt.sh
 memcg_force_empty memcg_force_empty.sh
 memcg_limit_in_bytes memcg_limit_in_bytes.sh
diff --git a/runtest/cve b/runtest/cve
new file mode 100644
index 0000000..8c140b5
--- /dev/null
+++ b/runtest/cve
@@ -0,0 +1,20 @@
+# Tests which check for vulnerabilities by CVE number
+cve-2011-0999 thp01 -I 120
+cve-2011-2183 ksm05 -I 10
+cve-2011-2496 vma03
+cve-2012-0957 cve-2012-0957
+cve-2014-0196 cve-2014-0196
+cve-2015-0235 gethostbyname_r01
+cve-2015-7550 keyctl02
+cve-2016-4470 keyctl01.sh
+cve-2016-4997 cve-2016-4997
+cve-2016-5195 dirtyc0w
+cve-2016-7042 cve-2016-7042
+cve-2016-7117 cve-2016-7117
+cve-2016-10044 cve-2016-10044
+cve-2017-2618 cve-2017-2618
+cve-2017-2671 cve-2017-2671
+cve-2017-5669 cve-2017-5669
+cve-2017-6951 cve-2017-6951
+cve-2017-7472 keyctl04
+cve-2017-1000364 stack_clash
diff --git a/runtest/dio b/runtest/dio
index a26e001..185cd57 100644
--- a/runtest/dio
+++ b/runtest/dio
@@ -40,8 +40,8 @@
 dio28 diotest6 -b 8192 -o 1024000 -i 1000 -v 200
 
 ### Run the tests with more children
-dio29 diotest3 -b 65536 -n 100 -i 1000 -o 1024000
-dio30 diotest6 -b 65536 -n 100 -i 1000 -o 1024000
+dio29 diotest3 -b 65536 -n 100 -i 100 -o 1024000
+dio30 diotest6 -b 65536 -n 100 -i 100 -o 1024000
 #
 # RAW DEVICE TEST SECTION
 #   DEV1 and DEV2 should be exported prior to execution or
diff --git a/runtest/ltplite b/runtest/ltplite
index 0c2e5be..5418495 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -407,14 +407,7 @@
 
 lseek01 lseek01
 lseek02 lseek02
-lseek03 lseek03
-lseek04 lseek04
-lseek05 lseek05
-lseek06 lseek06
 lseek07 lseek07
-lseek08 lseek08
-lseek09 lseek09
-lseek10 lseek10
 lseek11 lseek11
 
 lstat01A symlink01 -T lstat01
@@ -828,7 +821,6 @@
 
 shmat01 shmat01
 shmat02 shmat02
-shmat03 shmat03
 
 shmctl01 shmctl01
 shmctl02 shmctl02
@@ -1028,7 +1020,6 @@
 waitpid13 waitpid13
 
 write01 write01
-write02 write02
 write03 write03
 write04 write04
 write05 write05
diff --git a/runtest/mm b/runtest/mm
index 24620a5..76d2335 100644
--- a/runtest/mm
+++ b/runtest/mm
@@ -89,6 +89,7 @@
 vma02 vma02
 vma03 vma03
 vma04 vma04
+vma05 vma05.sh
 
 overcommit_memory01 overcommit_memory
 overcommit_memory02 overcommit_memory -R 0
diff --git a/runtest/net.features b/runtest/net.features
index 6de9a9e..7f2c889 100644
--- a/runtest/net.features
+++ b/runtest/net.features
@@ -11,6 +11,12 @@
 busy_poll03 busy_poll03.sh
 busy_poll03_ipv6 busy_poll03.sh -6
 
+dccp01 dccp01.sh
+dccp01_ipv6 dccp01.sh -6
+
+sctp01 sctp01.sh
+sctp01_ipv6 sctp01.sh -6
+
 tcp_fastopen tcp_fastopen_run.sh
 tcp_fastopen6 tcp_fastopen_run.sh -6
 
diff --git a/runtest/net_stress.ipsec_icmp b/runtest/net_stress.ipsec_icmp
index 374d44b..9c9a4ab 100644
--- a/runtest/net_stress.ipsec_icmp
+++ b/runtest/net_stress.ipsec_icmp
@@ -52,6 +52,7 @@
 icmp4-uni-basic23 icmp-uni-basic.sh -A rfc4543_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
 icmp4-uni-basic24 icmp-uni-basic.sh -A rfc4543_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
 icmp4-uni-basic25 icmp-uni-basic.sh -A rfc4543_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic26 icmp-uni-basic.sh -p esp -m beet -s "10 100 1000 10000 65470"
 
 icmp6-uni-basic01 icmp-uni-basic.sh -6 -s "10 100 1000 10000 65527"
 icmp6-uni-basic02 icmp-uni-basic.sh -6 -p ah -m transport -s "10 100 1000 10000 65503"
@@ -78,6 +79,7 @@
 icmp6-uni-basic23 icmp-uni-basic.sh -6 -A rfc4543_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
 icmp6-uni-basic24 icmp-uni-basic.sh -6 -A rfc4543_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
 icmp6-uni-basic25 icmp-uni-basic.sh -6 -A rfc4543_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic26 icmp-uni-basic.sh -6 -p esp -m beet -s "10 100 1000 10000 65490"
 
 icmp4-uni-vti01 icmp-uni-vti.sh -p ah -a sha256 -m tunnel -S fffffffe -k 1 -s "10 100 1000 10000 65463"
 icmp4-uni-vti02 icmp-uni-vti.sh -p esp -a sha512 -e des -m tunnel -S fffffffe -k 2 -s "10 100 1000 10000 65450"
diff --git a/runtest/net_stress.ipsec_tcp b/runtest/net_stress.ipsec_tcp
index 1a34f87..9b1a615 100644
--- a/runtest/net_stress.ipsec_tcp
+++ b/runtest/net_stress.ipsec_tcp
@@ -33,6 +33,7 @@
 tcp4_ipsec33 tcp_ipsec.sh -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65535"
 tcp4_ipsec34 tcp_ipsec.sh -p esp -a rmd160 -e serpent -m transport -s "100 1000 65535"
 tcp4_ipsec35 tcp_ipsec.sh -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65535"
+tcp4_ipsec36 tcp_ipsec.sh -p esp -m beet -s "100 1000 65535"
 
 tcp6_ipsec01 tcp_ipsec.sh -6 -s "100 1000 65535"
 tcp6_ipsec02 tcp_ipsec.sh -6 -p ah -m transport -s "100 1000 65535"
@@ -69,3 +70,40 @@
 tcp6_ipsec33 tcp_ipsec.sh -6 -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65535"
 tcp6_ipsec34 tcp_ipsec.sh -6 -p esp -a rmd160 -e serpent -m transport -s "100 1000 65535"
 tcp6_ipsec35 tcp_ipsec.sh -6 -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65535"
+tcp6_ipsec36 tcp_ipsec.sh -6 -p esp -m beet -s "100 1000 65535"
+
+tcp4_ipsec_vti01 tcp_ipsec_vti.sh -p ah -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti02 tcp_ipsec_vti.sh -p esp -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti03 tcp_ipsec_vti.sh -p comp -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti04 tcp_ipsec_vti.sh -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti05 tcp_ipsec_vti.sh -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti06 tcp_ipsec_vti.sh -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti07 tcp_ipsec_vti.sh -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti08 tcp_ipsec_vti.sh -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti09 tcp_ipsec_vti.sh -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti10 tcp_ipsec_vti.sh -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti11 tcp_ipsec_vti.sh -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti12 tcp_ipsec_vti.sh -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti13 tcp_ipsec_vti.sh -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti14 tcp_ipsec_vti.sh -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti15 tcp_ipsec_vti.sh -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti16 tcp_ipsec_vti.sh -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65535"
+tcp4_ipsec_vti17 tcp_ipsec_vti.sh -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65535"
+
+tcp6_ipsec_vti01 tcp_ipsec_vti.sh -6 -p ah -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti02 tcp_ipsec_vti.sh -6 -p esp -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti03 tcp_ipsec_vti.sh -6 -p comp -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti04 tcp_ipsec_vti.sh -6 -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti05 tcp_ipsec_vti.sh -6 -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti06 tcp_ipsec_vti.sh -6 -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti07 tcp_ipsec_vti.sh -6 -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti08 tcp_ipsec_vti.sh -6 -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti09 tcp_ipsec_vti.sh -6 -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti10 tcp_ipsec_vti.sh -6 -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti11 tcp_ipsec_vti.sh -6 -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti12 tcp_ipsec_vti.sh -6 -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti13 tcp_ipsec_vti.sh -6 -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti14 tcp_ipsec_vti.sh -6 -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti15 tcp_ipsec_vti.sh -6 -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti16 tcp_ipsec_vti.sh -6 -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65535"
+tcp6_ipsec_vti17 tcp_ipsec_vti.sh -6 -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65535"
diff --git a/runtest/net_stress.ipsec_udp b/runtest/net_stress.ipsec_udp
index cfabb22..3f529ea 100644
--- a/runtest/net_stress.ipsec_udp
+++ b/runtest/net_stress.ipsec_udp
@@ -33,6 +33,7 @@
 udp4_ipsec33 udp_ipsec.sh -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65426"
 udp4_ipsec34 udp_ipsec.sh -p esp -a rmd160 -e serpent -m transport -s "100 1000 65446"
 udp4_ipsec35 udp_ipsec.sh -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65426"
+udp4_ipsec36 udp_ipsec.sh -p esp -m beet -s "100 1000 65446"
 
 udp6_ipsec01 udp_ipsec.sh -6 -s "100 1000 65527"
 udp6_ipsec02 udp_ipsec.sh -6 -p ah -m transport -s "100 1000 65503"
@@ -69,3 +70,40 @@
 udp6_ipsec33 udp_ipsec.sh -6 -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65527"
 udp6_ipsec34 udp_ipsec.sh -6 -p esp -a rmd160 -e serpent -m transport -s "100 1000 65478"
 udp6_ipsec35 udp_ipsec.sh -6 -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65527"
+udp6_ipsec36 udp_ipsec.sh -6 -p esp -m beet -s "100 1000 65478"
+
+udp4_ipsec_vti01 udp_ipsec_vti.sh -p ah -m tunnel -s "100 1000 65463"
+udp4_ipsec_vti02 udp_ipsec_vti.sh -p esp -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti03 udp_ipsec_vti.sh -p comp -m tunnel -s "100 1000 65000"
+udp4_ipsec_vti04 udp_ipsec_vti.sh -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti05 udp_ipsec_vti.sh -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti06 udp_ipsec_vti.sh -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti07 udp_ipsec_vti.sh -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti08 udp_ipsec_vti.sh -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti09 udp_ipsec_vti.sh -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti10 udp_ipsec_vti.sh -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti11 udp_ipsec_vti.sh -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti12 udp_ipsec_vti.sh -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti13 udp_ipsec_vti.sh -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65450"
+udp4_ipsec_vti14 udp_ipsec_vti.sh -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65426"
+udp4_ipsec_vti15 udp_ipsec_vti.sh -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65426"
+udp4_ipsec_vti16 udp_ipsec_vti.sh -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65426"
+udp4_ipsec_vti17 udp_ipsec_vti.sh -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65426"
+
+udp6_ipsec_vti01 udp_ipsec_vti.sh -6 -p ah -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti02 udp_ipsec_vti.sh -6 -p esp -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti03 udp_ipsec_vti.sh -6 -p comp -m tunnel -s "100 1000 65000"
+udp6_ipsec_vti04 udp_ipsec_vti.sh -6 -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti05 udp_ipsec_vti.sh -6 -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti06 udp_ipsec_vti.sh -6 -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti07 udp_ipsec_vti.sh -6 -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti08 udp_ipsec_vti.sh -6 -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti09 udp_ipsec_vti.sh -6 -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti10 udp_ipsec_vti.sh -6 -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti11 udp_ipsec_vti.sh -6 -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti12 udp_ipsec_vti.sh -6 -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti13 udp_ipsec_vti.sh -6 -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti14 udp_ipsec_vti.sh -6 -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti15 udp_ipsec_vti.sh -6 -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti16 udp_ipsec_vti.sh -6 -p esp -a sha512 -e camellia -m tunnel -s "100 1000 65527"
+udp6_ipsec_vti17 udp_ipsec_vti.sh -6 -p esp -a rmd160 -e serpent -m tunnel -s "100 1000 65527"
diff --git a/runtest/net_stress.multicast b/runtest/net_stress.multicast
index 445b08f..d2288df 100644
--- a/runtest/net_stress.multicast
+++ b/runtest/net_stress.multicast
@@ -2,10 +2,10 @@
 # Stress test for TCP/IP protocol stack (Multicast)
 #
 
-mcast4-grpope01 mcast4-grpope01
-mcast4-grpope02 mcast4-grpope02
-mcast4-grpope03 mcast4-grpope03
-mcast4-grpope04 mcast4-grpope04
+mcast4-group-single-socket mcast-group-single-socket
+mcast4-group-multiple-socket mcast-group-multiple-socket
+mcast4-group-same-group mcast-group-same-group
+mcast4-group-source-filter mcast-group-source-filter
 mcast4-pktfld01 mcast4-pktfld01
 mcast4-pktfld02 mcast4-pktfld02
 mcast4-queryfld01 mcast4-queryfld01
@@ -15,10 +15,10 @@
 mcast4-queryfld05 mcast4-queryfld05
 mcast4-queryfld06 mcast4-queryfld06
 
-mcast6-grpope01 mcast6-grpope01
-mcast6-grpope02 mcast6-grpope02
-mcast6-grpope03 mcast6-grpope03
-mcast6-grpope04 mcast6-grpope04
+mcast6-group-single-socket mcast-group-single-socket -6
+mcast6-group-multiple-socket mcast-group-multiple-socket -6
+mcast6-group-same-group mcast-group-same-group -6
+mcast6-group-source-filter mcast-group-source-filter -6
 mcast6-pktfld01 mcast6-pktfld01
 mcast6-pktfld02 mcast6-pktfld02
 mcast6-queryfld01 mcast6-queryfld01
diff --git a/runtest/quickhit b/runtest/quickhit
index c286add..2a42769 100644
--- a/runtest/quickhit
+++ b/runtest/quickhit
@@ -171,14 +171,9 @@
 link05 link05
 # multi links (EMLINK) negative test
 lseek01 lseek01
-# Basic test for lseek(2)
 lseek02 lseek02
-# Negative test for lseek(2)
-lseek03 lseek03
-# Negative test for lseek(2) whence
-lseek04 lseek04
-# Negative test for lseek(2) of a fifo
-lseek05 lseek05
+lseek07 lseek07
+lseek11 lseek11
 # Negative test for lseek(2) of a pipe
 lstat02 lstat02
 # Basic test for lstat(2)
diff --git a/runtest/sched b/runtest/sched
index 89398df..774d11f 100644
--- a/runtest/sched
+++ b/runtest/sched
@@ -16,3 +16,5 @@
 sched_cli_serv run_sched_cliserv.sh
 # Run this stress test for 2 minutes
 sched_stress sched_stress.sh
+
+autogroup01 autogroup01
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index bd84752..242b696 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -333,14 +333,7 @@
 
 lseek01 lseek01
 lseek02 lseek02
-lseek03 lseek03
-lseek04 lseek04
-lseek05 lseek05
-lseek06 lseek06
 lseek07 lseek07
-lseek08 lseek08
-lseek09 lseek09
-lseek10 lseek10
 lseek11 lseek11
 
 lstat01A symlink01 -T lstat01
@@ -718,7 +711,6 @@
 
 shmat01 shmat01
 shmat02 shmat02
-shmat03 shmat03
 
 shmctl02 shmctl02
 shmctl03 shmctl03
@@ -888,7 +880,6 @@
 waitpid13 waitpid13
 
 write01 write01
-write02 write02
 write03 write03
 write04 write04
 write05 write05
diff --git a/runtest/syscalls b/runtest/syscalls
index 5909456..f2b2cbc 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -74,6 +74,7 @@
 
 clock_getres01 clock_getres01
 clock_nanosleep01 clock_nanosleep01
+clock_nanosleep02 clock_nanosleep02
 clock_nanosleep2_01 clock_nanosleep2_01
 
 clone01 clone01
@@ -84,6 +85,7 @@
 clone06 clone06
 clone07 clone07
 clone08 clone08
+clone09 clone09
 
 close01 close01
 close02 close02
@@ -267,6 +269,10 @@
 fcntl33_64 fcntl33_64
 fcntl34 fcntl34
 fcntl34_64 fcntl34_64
+fcntl35 fcntl35
+fcntl35_64 fcntl35_64
+fcntl36 fcntl36
+fcntl36_64 fcntl36_64
 
 fdatasync01 fdatasync01
 fdatasync02 fdatasync02
@@ -430,6 +436,7 @@
 getsockname01 getsockname01
 
 getsockopt01 getsockopt01
+getsockopt02 getsockopt02
 
 gettid01 gettid01
 
@@ -473,6 +480,8 @@
 fanotify04 fanotify04
 fanotify05 fanotify05
 fanotify06 fanotify06
+fanotify07 fanotify07
+fanotify08 fanotify08
 
 ioperm01 ioperm01
 ioperm02 ioperm02
@@ -489,6 +498,8 @@
 keyctl01 keyctl01
 keyctl02 keyctl02
 keyctl03 keyctl03
+keyctl04 keyctl04
+keyctl05 keyctl05
 
 kcmp01 kcmp01
 kcmp02 kcmp02
@@ -546,14 +557,7 @@
 
 lseek01 lseek01
 lseek02 lseek02
-lseek03 lseek03
-lseek04 lseek04
-lseek05 lseek05
-lseek06 lseek06
 lseek07 lseek07
-lseek08 lseek08
-lseek09 lseek09
-lseek10 lseek10
 lseek11 lseek11
 
 lstat01A symlink01 -T lstat01
@@ -707,6 +711,7 @@
 msync01 msync01
 msync02 msync02
 msync03 msync03
+msync04 msync04
 
 munlock01 munlock01
 munlock02 munlock02
@@ -919,6 +924,7 @@
 
 request_key01 request_key01
 request_key02 request_key02
+cve-2017-6951 cve-2017-6951
 
 rmdir01 rmdir01
 rmdir02 rmdir02
@@ -1143,6 +1149,7 @@
 setsid01 setsid01
 
 setsockopt01 setsockopt01
+cve-2016-4997 cve-2016-4997
 
 settimeofday01 settimeofday01
 settimeofday02 settimeofday02
@@ -1162,7 +1169,7 @@
 
 shmat01 shmat01
 shmat02 shmat02
-shmat03 shmat03
+cve-2017-5669 cve-2017-5669
 
 shmctl01 shmctl01
 shmctl02 shmctl02
@@ -1222,8 +1229,10 @@
 sockioctl01 sockioctl01
 
 splice01 splice01
-splice02 seq 1 20000 | splice02 splice02-temp
+splice02 seq 1 20000 | splice02
 splice03 splice03
+splice04 splice04
+splice05 splice05
 
 tee01 tee01
 tee02 tee02
@@ -1354,6 +1363,7 @@
 uname01 uname01
 uname02 uname02
 uname03 uname03
+cve-2012-0957 cve-2012-0957
 
 unlink01 symlink01 -T unlink01
 unlink05 unlink05
@@ -1430,7 +1440,6 @@
 waitid02 waitid02
 
 write01 write01
-write02 write02
 write03 write03
 write04 write04
 write05 write05
@@ -1458,3 +1467,5 @@
 
 memfd_create01 memfd_create01
 memfd_create02 memfd_create02
+
+copy_file_range01 copy_file_range01
diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc
index 91060b9..de32c6b 100644
--- a/runtest/syscalls-ipc
+++ b/runtest/syscalls-ipc
@@ -52,7 +52,6 @@
 
 shmat01 shmat01
 shmat02 shmat02
-shmat03 shmat03
 
 shmctl01 shmctl01
 shmctl02 shmctl02
diff --git a/runtest/tracing b/runtest/tracing
index 9f8d5c8..8285eeb 100644
--- a/runtest/tracing
+++ b/runtest/tracing
@@ -2,3 +2,4 @@
 ftrace_regression01	ftrace_regression01.sh
 ftrace_regression02	ftrace_regression02.sh
 ftrace-stress-test	ftrace_stress_test.sh 90
+dynamic_debug01		dynamic_debug01.sh
diff --git a/scenario_groups/default b/scenario_groups/default
index b0d7701..5658a61 100644
--- a/scenario_groups/default
+++ b/scenario_groups/default
@@ -32,3 +32,4 @@
 cpuhotplug
 net.ipv6_lib
 input
+cve
diff --git a/testcases/commands/ar/ar01 b/testcases/commands/ar/ar01
index e27cd04..ddab2e0 100644
--- a/testcases/commands/ar/ar01
+++ b/testcases/commands/ar/ar01
@@ -22,7 +22,6 @@
 #
 # This is a basic ar command test.
 #
-TST_ID="ar01"
 TST_CNT=17
 TST_TESTFUNC=test
 TST_NEEDS_TMPDIR=1
@@ -278,9 +277,9 @@
 	file1_mtime2=$(ar -tv lib.a | grep file1.in)
 
 	if [ "$file0_mtime1" = "$file0_mtime2" ]; then
-		tst_res TFAIL "ar updated modified file0 (-u)"
+		tst_res TFAIL "ar haven't updated modified file0 (-u)"
 	else
-		tst_res TPASS "ar haven't updated modified file0 (-u)"
+		tst_res TPASS "ar updated modified file0 (-u)"
 	fi
 
 	if [ "$file1_mtime1" = "$file1_mtime2" ]; then
diff --git a/testcases/commands/cp/cp_tests.sh b/testcases/commands/cp/cp_tests.sh
index b04b9dd..30bb183 100755
--- a/testcases/commands/cp/cp_tests.sh
+++ b/testcases/commands/cp/cp_tests.sh
@@ -23,7 +23,6 @@
 #
 # Tests basic cp functionality
 #
-TST_ID="ln01"
 TST_CNT=5
 TST_TESTFUNC=do_test
 TST_SETUP=setup
diff --git a/testcases/commands/cpio/cpio_tests.sh b/testcases/commands/cpio/cpio_tests.sh
index 261194d..9ebfb10 100755
--- a/testcases/commands/cpio/cpio_tests.sh
+++ b/testcases/commands/cpio/cpio_tests.sh
@@ -23,7 +23,6 @@
 #
 # Test basic functionality of cpio command
 #
-TST_ID="cpio01"
 TST_TESTFUNC=cpio_test
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_CMDS="cpio"
diff --git a/testcases/commands/cron/cron_tests.sh b/testcases/commands/cron/cron_tests.sh
index b76f0b6..47614f9 100644
--- a/testcases/commands/cron/cron_tests.sh
+++ b/testcases/commands/cron/cron_tests.sh
@@ -19,7 +19,6 @@
 #
 # Author: Manoj Iyer <manjo@mail.utexas.edu>
 
-TST_ID="cron_tests01"
 TST_CNT=3
 TST_TESTFUNC=do_test
 TST_NEEDS_TMPDIR=1
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index 739ec93..0552327 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -16,7 +16,6 @@
 # Test df command with some basic options.
 #
 
-TST_ID="df01"
 TST_CNT=12
 TST_SETUP=setup
 TST_CLEANUP=cleanup
diff --git a/testcases/commands/du/du01.sh b/testcases/commands/du/du01.sh
index 2fe23b3..ed1df56 100755
--- a/testcases/commands/du/du01.sh
+++ b/testcases/commands/du/du01.sh
@@ -20,7 +20,6 @@
 # Test du command with some basic options.
 #
 
-TST_ID="du01"
 TST_CNT=23
 TST_SETUP=setup
 TST_TESTFUNC=do_test
diff --git a/testcases/commands/eject/eject-tests.sh b/testcases/commands/eject/eject-tests.sh
index e9971b5..c1dcd58 100755
--- a/testcases/commands/eject/eject-tests.sh
+++ b/testcases/commands/eject/eject-tests.sh
@@ -24,7 +24,6 @@
 # Tests basic functionality of eject command.
 #
 
-TST_ID="eject01"
 TST_CNT=4
 TST_SETUP=setup
 TST_CLEANUP=cleanup
diff --git a/testcases/commands/file/Makefile b/testcases/commands/file/Makefile
index e6257a1..776db32 100644
--- a/testcases/commands/file/Makefile
+++ b/testcases/commands/file/Makefile
@@ -24,6 +24,6 @@
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= file_test.sh
+INSTALL_TARGETS		:= file01.sh
 
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/file/file_test.sh b/testcases/commands/file/file01.sh
similarity index 94%
rename from testcases/commands/file/file_test.sh
rename to testcases/commands/file/file01.sh
index ed4792a..e04b32e 100755
--- a/testcases/commands/file/file_test.sh
+++ b/testcases/commands/file/file01.sh
@@ -24,7 +24,6 @@
 # testing if the file command can recognize some of the commonly
 # used file formats like, tar, tar.gz, rpm, C, ASCII, ELF etc.
 #
-TST_ID="file01"
 TST_CNT=20
 TST_SETUP=setup
 TST_TESTFUNC=do_test
@@ -89,11 +88,12 @@
 			    "[pP]ython script text executable";;
 	 9) file_test in.m4 "M4 macro processor script, ASCII text" \
 			    "ASCII M4 macro language pre-processor text";;
-	10) file_test in "ELF .*-bit $TEST_ARCH executable, .*";;
+	10) file_test in "ELF .*-bit $TEST_ARCH executable, .*" \
+			 "ELF .*-bit $TEST_ARCH shared object, .*";;
 	11) file_test in.ar "current ar archive";;
 	12) file_test in.tar "tar archive";;
-    	13) file_test in.tar.gz "gzip compressed data, .*";;
-    	14) file_test in.tar.bz2 "bzip2 compressed data, .*";;
+	13) file_test in.tar.gz "gzip compressed data, .*";;
+	14) file_test in.tar.bz2 "bzip2 compressed data, .*";;
 	15) file_test in.src.rpm "RPM v3 src" "RPM v3.0 src";;
 	16) file_test in.jpg "JPEG image data";;
 	17) file_test in.png "PNG image data";;
diff --git a/testcases/commands/gdb/Makefile b/testcases/commands/gdb/Makefile
new file mode 100644
index 0000000..1ebbf65
--- /dev/null
+++ b/testcases/commands/gdb/Makefile
@@ -0,0 +1,26 @@
+#
+#    misc/gdb test suite Makefile.
+#
+#    Copyright (C) 2017 Red Hat, Inc.
+#
+#    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, see <http://www.gnu.org/licenses/>.
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/gdb/gdb01.sh b/testcases/commands/gdb/gdb01.sh
new file mode 100755
index 0000000..e3a5b51
--- /dev/null
+++ b/testcases/commands/gdb/gdb01.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Copyright (C) 2017 Red Hat, Inc.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+#
+
+# Test description: See if gdb can successfully attach to a process and
+#                   this process exits normally.
+
+# Usage
+# ./gdb01.sh
+
+TST_TESTFUNC=simple_test
+TST_NEEDS_CMDS="gdb /bin/cat"
+
+. tst_test.sh
+
+simple_test()
+{
+	gdb /bin/cat -ex "run /etc/passwd" -ex quit < /dev/null
+	RC=$?
+	if [ $RC -eq 0 ] ; then
+		tst_res TPASS "gdb attached to process and completed run"
+	else
+		tst_res TFAIL "gdb test failed with" $RC
+	fi
+}
+
+tst_run
diff --git a/testcases/commands/gzip/gzip_tests.sh b/testcases/commands/gzip/gzip_tests.sh
index 1cd5275..05ecb6f 100755
--- a/testcases/commands/gzip/gzip_tests.sh
+++ b/testcases/commands/gzip/gzip_tests.sh
@@ -28,7 +28,6 @@
 #			    uncompress all the files available.
 #
 
-TST_ID="gzip"
 TST_CNT=2
 TST_TESTFUNC=test
 TST_NEEDS_TMPDIR=1
diff --git a/testcases/commands/insmod/insmod01.sh b/testcases/commands/insmod/insmod01.sh
index 532f802..a7835f9 100755
--- a/testcases/commands/insmod/insmod01.sh
+++ b/testcases/commands/insmod/insmod01.sh
@@ -16,7 +16,6 @@
 # Test the basic functionality of insmod command.
 #
 
-TST_ID="insmod01"
 TST_CLEANUP=cleanup
 TST_TESTFUNC=do_test
 TST_NEEDS_ROOT=1
diff --git a/testcases/commands/keyctl/keyctl01.sh b/testcases/commands/keyctl/keyctl01.sh
index 076a130..650e7f4 100644
--- a/testcases/commands/keyctl/keyctl01.sh
+++ b/testcases/commands/keyctl/keyctl01.sh
@@ -26,7 +26,6 @@
 #   KEYS: potential uninitialized variable
 #
 
-TST_ID="keyctl01"
 TST_SETUP=setup
 TST_CLEANUP=cleanup
 TST_TESTFUNC=do_test
@@ -35,11 +34,38 @@
 TST_NEEDS_CMDS="keyctl"
 . tst_test.sh
 
+check_keyctl()
+{
+	local nosup
+	for op in $@; do
+		nosup=0
+
+		if ! keyctl 2>&1 | grep -q "keyctl $op"; then
+			nosup=1
+		fi
+
+		if [ "$op" = "request2" ]; then
+			local key=`keyctl request2 user debug:foo bar`
+			if [ $? -ne 0 ]; then
+				nosup=1
+			fi
+		fi
+
+		if [ "$op" = "unlink" ]; then
+			if ! keyctl unlink $key @s; then
+				nosup=1
+			fi
+		fi
+
+		if [ $nosup -ne 0 ]; then
+			tst_brk TCONF "keyctl operation $op not supported"
+		fi
+	done
+}
+
 setup()
 {
-	if tst_kvcmp -le 2.6.33; then
-		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
-	fi
+	check_keyctl negate request2 show unlink
 
 	PATH_KEYSTAT="/proc/key-users"
 	PATH_KEYQUOTA="/proc/sys/kernel/keys/root_maxbytes"
@@ -62,19 +88,26 @@
 
 do_test()
 {
+	local quota_excd=0
 	local maxkeysz=$((ORIG_KEYSZ + 100))
 
-	while true
+	while [ $maxkeysz -ge 0 ]
 	do
 		echo $maxkeysz >$PATH_KEYQUOTA
 
 		keyctl request2 user debug:fred negate @t >temp 2>&1
 		grep -q -E "quota exceeded" temp
 		if [ $? -eq 0 ]; then
+			quota_excd=1
 			break
 		fi
 
 		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -z "$key" ]; then
+			key=`keyctl show | \
+				awk -F ':' '/inaccessible/ {print $1}'`
+		fi
+
 		if [ -n "$key" ]; then
 			keyctl unlink $key @s >/dev/null
 			tst_sleep 50ms
@@ -83,6 +116,10 @@
 		((maxkeysz -= 4))
 	done
 
+	if [ $quota_excd -eq 0 ]; then
+		tst_res TWARN "Failed to trigger the quota excess"
+	fi
+
 	tst_res TPASS "Bug not reproduced"
 }
 
diff --git a/testcases/commands/ld/ld01 b/testcases/commands/ld/ld01
index 3ff1d09..f24f6f9 100755
--- a/testcases/commands/ld/ld01
+++ b/testcases/commands/ld/ld01
@@ -25,7 +25,6 @@
 CC=${CC:=gcc}
 LD=${LD:=ld}
 
-TST_ID="ld01"
 TST_CNT=5
 TST_TESTFUNC=test
 TST_SETUP=setup
diff --git a/testcases/commands/ldd/ldd01 b/testcases/commands/ldd/ldd01
index ebd7492..cf2aac3 100755
--- a/testcases/commands/ldd/ldd01
+++ b/testcases/commands/ldd/ldd01
@@ -27,7 +27,6 @@
 #     -Ported
 #---------------------------------------------------------------------------
 
-TST_ID=ldd01
 TST_CNT=2
 TST_SETUP=setup
 TST_TESTFUNC=test
diff --git a/testcases/commands/ln/ln_tests.sh b/testcases/commands/ln/ln_tests.sh
index 5d9335a..bc48bed 100755
--- a/testcases/commands/ln/ln_tests.sh
+++ b/testcases/commands/ln/ln_tests.sh
@@ -23,7 +23,6 @@
 #
 # Basic test for ln
 #
-TST_ID="ln01"
 TST_CNT=6
 TST_TESTFUNC=do_test
 TST_SETUP=setup
diff --git a/testcases/commands/lsmod/lsmod01.sh b/testcases/commands/lsmod/lsmod01.sh
index e31c43d..132a446 100755
--- a/testcases/commands/lsmod/lsmod01.sh
+++ b/testcases/commands/lsmod/lsmod01.sh
@@ -15,7 +15,6 @@
 #
 # Test the basic functionality of lsmod command.
 #
-TST_ID="lsmod01"
 TST_TESTFUNC=lsmod_test
 TST_NEEDS_TMPDIR=1
 TST_NEEDS_CMDS="lsmod"
diff --git a/testcases/commands/mkdir/mkdir_tests.sh b/testcases/commands/mkdir/mkdir_tests.sh
index a182e24..990162b 100755
--- a/testcases/commands/mkdir/mkdir_tests.sh
+++ b/testcases/commands/mkdir/mkdir_tests.sh
@@ -22,7 +22,6 @@
 #
 # Basic mkdir tests
 #
-TST_ID="mkdir01"
 TST_CNT=3
 TST_SETUP=setup
 TST_TESTFUNC=test
diff --git a/testcases/commands/mkfs/mkfs01.sh b/testcases/commands/mkfs/mkfs01.sh
index 72dc1bd..cf7ccb6 100755
--- a/testcases/commands/mkfs/mkfs01.sh
+++ b/testcases/commands/mkfs/mkfs01.sh
@@ -16,7 +16,6 @@
 # Test mkfs command with some basic options.
 #
 
-TST_ID="mkfs01"
 TST_CNT=5
 TST_SETUP=setup
 TST_TESTFUNC=test
@@ -95,7 +94,7 @@
 	# 1k-block size should be devided by this argument for ntfs verification.
 	if [ "$1" = "ntfs" ]; then
 		local rate=1024/512
-		if [ $blocknum -lt "$(($2/rate*9/10))" ]; then
+		if [ $blocknum -lt "$(($2/$rate*9/10))" ]; then
 			return 1
 		fi
 	else
diff --git a/testcases/commands/mkswap/mkswap01.sh b/testcases/commands/mkswap/mkswap01.sh
index f6d19ec..1c01c86 100755
--- a/testcases/commands/mkswap/mkswap01.sh
+++ b/testcases/commands/mkswap/mkswap01.sh
@@ -16,7 +16,6 @@
 # Test mkswap command with some basic options.
 #
 
-TST_ID="mkswap01"
 TST_CNT=10
 TST_SETUP=setup
 TST_TESTFUNC=do_test
diff --git a/testcases/commands/mv/mv_tests.sh b/testcases/commands/mv/mv_tests.sh
index 85d7991..ed55066 100755
--- a/testcases/commands/mv/mv_tests.sh
+++ b/testcases/commands/mv/mv_tests.sh
@@ -27,7 +27,6 @@
 #		  move file1 to file2 and backup the file2.
 #
 
-TST_ID=mv01
 TST_CNT=2
 TST_SETUP=setup
 TST_TESTFUNC=test
diff --git a/testcases/commands/nm/nm01 b/testcases/commands/nm/nm01
index 5255049..39d5c9a 100755
--- a/testcases/commands/nm/nm01
+++ b/testcases/commands/nm/nm01
@@ -24,7 +24,6 @@
 #
 NM=${NM:=nm}
 
-TST_ID="nm01"
 TST_CNT=7
 TST_TESTFUNC=test
 TST_SETUP=setup
diff --git a/testcases/commands/su/su01_s1 b/testcases/commands/su/su01_s1
index fd2e485..313207b 100755
--- a/testcases/commands/su/su01_s1
+++ b/testcases/commands/su/su01_s1
@@ -135,7 +135,6 @@
   }
 }
 
-catch close
 # capture result code
 set codes [wait]
 set pid [lindex $codes 0]
@@ -152,7 +151,6 @@
 		}
 	}
 	expect eof
-	catch close
 	wait
 
 	set test_env_var [exec cat $TEST_ENV_FILE]
@@ -198,7 +196,6 @@
   }
 }
 
-catch close
 # capture result code
 set codes [wait]
 set pid [lindex $codes 0]
@@ -237,7 +234,6 @@
   }
 }
 
-catch close
 # capture result code
 set codes [wait]
 set pid [lindex $codes 0]
@@ -292,7 +288,6 @@
   }
 }
 
-catch close
 # capture result code
 set codes [wait]
 set pid [lindex $codes 0]
@@ -325,7 +320,6 @@
   }
 }
 
-catch close
 # capture result code
 set codes [wait]
 set pid [lindex $codes 0]
@@ -384,7 +378,6 @@
   }
 }
 
-catch close
 # capture result code
 set codes [wait]
 set pid [lindex $codes 0]
@@ -447,7 +440,6 @@
   }
 }
 
-catch close
 # capture result code
 set codes [wait]
 set pid [lindex $codes 0]
@@ -481,7 +473,6 @@
   }
 }
 
-catch close
 } else {
 
 	send_user "TEST:  su to user1 with the user1 password expired. (FAILED),see more next line.\n"
diff --git a/testcases/commands/tar/tar_tests.sh b/testcases/commands/tar/tar_tests.sh
index b67bcf1..7ac18a4 100755
--- a/testcases/commands/tar/tar_tests.sh
+++ b/testcases/commands/tar/tar_tests.sh
@@ -24,7 +24,6 @@
 # Creates, lists and extracts an plain, gzip and bzip tar archive.
 #
 
-TST_ID="tar01"
 TST_CNT=6
 TST_TESTFUNC=do_test
 TST_NEEDS_TMPDIR=1
diff --git a/testcases/commands/unzip/Makefile b/testcases/commands/unzip/Makefile
index fdebbce..72ac803 100644
--- a/testcases/commands/unzip/Makefile
+++ b/testcases/commands/unzip/Makefile
@@ -24,6 +24,6 @@
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= unzip_tests.sh
+INSTALL_TARGETS		:= unzip01.sh
 
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/unzip/unzip_tests.sh b/testcases/commands/unzip/unzip01.sh
similarity index 99%
rename from testcases/commands/unzip/unzip_tests.sh
rename to testcases/commands/unzip/unzip01.sh
index f67b5da..532afc0 100755
--- a/testcases/commands/unzip/unzip_tests.sh
+++ b/testcases/commands/unzip/unzip01.sh
@@ -24,7 +24,6 @@
 # Tests basic functionality of unzip command.
 #
 
-TST_ID="unzip01"
 TST_SETUP=setup
 TST_TESTFUNC=do_test
 TST_NEEDS_TMPDIR=1
diff --git a/testcases/commands/wc/wc01.sh b/testcases/commands/wc/wc01.sh
index 2272dcb..e72819c 100755
--- a/testcases/commands/wc/wc01.sh
+++ b/testcases/commands/wc/wc01.sh
@@ -16,7 +16,6 @@
 # Test wc command with some basic options.
 #
 
-TST_ID="wc01"
 TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=do_test
diff --git a/testcases/commands/which/which01.sh b/testcases/commands/which/which01.sh
index eb87095..72c14fe 100755
--- a/testcases/commands/which/which01.sh
+++ b/testcases/commands/which/which01.sh
@@ -16,7 +16,6 @@
 # Test which command with some basic options.
 #
 
-TST_ID="which01"
 TST_CNT=10
 TST_SETUP=setup
 TST_TESTFUNC=do_test
diff --git a/testcases/cve/.gitignore b/testcases/cve/.gitignore
new file mode 100644
index 0000000..f76c398
--- /dev/null
+++ b/testcases/cve/.gitignore
@@ -0,0 +1,11 @@
+cve-2012-0957
+cve-2014-0196
+cve-2016-4997
+cve-2016-7042
+cve-2016-7117
+cve-2016-10044
+cve-2017-2618
+cve-2017-2671
+cve-2017-6951
+cve-2017-5669
+stack_clash
diff --git a/testcases/cve/Makefile b/testcases/cve/Makefile
new file mode 100644
index 0000000..0905fd9
--- /dev/null
+++ b/testcases/cve/Makefile
@@ -0,0 +1,33 @@
+# Copyright (c) 2017 Linux Test Project
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+top_srcdir		?= ../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+CFLAGS			+= -D_GNU_SOURCE
+
+cve-2016-7042:	LDLIBS += $(KEYUTILS_LIBS)
+
+cve-2016-7117:	CFLAGS += -pthread
+cve-2016-7117:	LDLIBS += -lrt
+
+cve-2014-0196:  CFLAGS += -pthread
+cve-2014-0196:  LDLIBS += -lrt -lutil
+
+cve-2017-2671:	CFLAGS += -pthread
+cve-2017-2671:	LDLIBS += -lrt
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/cve/cve-2012-0957.c b/testcases/cve/cve-2012-0957.c
new file mode 100644
index 0000000..096f49f
--- /dev/null
+++ b/testcases/cve/cve-2012-0957.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ * Copyright (c) 2012, Kees Cook <keescook@chromium.org>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Check that memory after the string terminator in all the utsname fields has
+ * been zeroed. cve-2012-0957 leaked kernel memory through the release field
+ * when the UNAME26 personality was set.
+ *
+ * Thanks to Kees Cook for the original proof of concept:
+ * http://www.securityfocus.com/bid/55855/info
+ */
+
+#include <string.h>
+#include <sys/utsname.h>
+#include "tst_test.h"
+#include "lapi/personality.h"
+
+static int check_field(char *bytes, size_t length, char *field)
+{
+	size_t i = strlen(bytes) + 1;
+
+	for (; i < length; i++) {
+		if (bytes[i]) {
+			tst_res(TFAIL, "Bytes leaked in %s!", field);
+			return 1;
+		}
+	}
+	return 0;
+}
+
+
+static void try_leak_bytes(void)
+{
+	struct utsname buf;
+
+	if (uname(&buf))
+		tst_brk(TBROK | TERRNO, "Call to uname failed");
+
+#define CHECK_FIELD(field_name) \
+	(check_field(buf.field_name, ARRAY_SIZE(buf.field_name), #field_name))
+
+	if (!(CHECK_FIELD(release) |
+	    CHECK_FIELD(sysname) |
+	    CHECK_FIELD(nodename) |
+	    CHECK_FIELD(version) |
+	    CHECK_FIELD(machine) |
+#ifdef HAVE_STRUCT_UTSNAME_DOMAINNAME
+	    CHECK_FIELD(domainname) |
+#endif
+		    0)) {
+		tst_res(TPASS, "All fields zeroed after string terminator");
+	}
+#undef CHECK_FIELD
+}
+
+static void run(unsigned int test_nr)
+{
+	if (!test_nr) {
+		tst_res(TINFO, "Calling uname with default personality");
+		try_leak_bytes();
+	} else {
+		SAFE_PERSONALITY(PER_LINUX | UNAME26);
+		tst_res(TINFO, "Calling uname with UNAME26 personality");
+		try_leak_bytes();
+	}
+}
+
+static struct tst_test test = {
+	.test = run,
+	.tcnt = 2,
+};
diff --git a/testcases/cve/cve-2014-0196.c b/testcases/cve/cve-2014-0196.c
new file mode 100644
index 0000000..4e2b3f5
--- /dev/null
+++ b/testcases/cve/cve-2014-0196.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ * Original POC by Matthew Daley <mattd@bugfuzz.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * This test attempts to cause a buffer overflow using the race condition
+ * described in CVE-2014-0196. If the test is successful in causing an
+ * overflow it will most likely result in an immediate Oops, restart or
+ * freeze. However if it overwrites memory not accessed during the test then
+ * it could happen at a later time or not at all which is more likely if SLAB
+ * randomization has been implemented. However as it currently stands, the test
+ * usually crashes as soon as the delay has been calibrated.
+ *
+ * To maximise the chances of the buffer overflow doing immediate detectable
+ * damage the SLAB filler sockets and ioctls from the original exploit POC
+ * have been kept even though they are not strictly necessary to reproduce the
+ * bug.
+ *
+ * Further details:
+ * see linux commit 4291086b1f081b869c6d79e5b7441633dc3ace00
+ * privilege escalation POC https://www.exploit-db.com/exploits/33516/
+ */
+
+#include <pty.h>
+#include <stdio.h>
+#include <string.h>
+#include <termios.h>
+#include <limits.h>
+
+#include "tst_test.h"
+#include "tst_timer.h"
+#include "tst_safe_pthread.h"
+
+#include "tst_fuzzy_sync.h"
+
+#define ONEOFF_ALLOCS 200
+#define RUN_ALLOCS    30
+#define ATTEMPTS      0x7000
+#define BUFLEN        512
+
+static int master_fd, slave_fd;
+static int filler_ptys[ONEOFF_ALLOCS * 2];
+static int target_ptys[RUN_ALLOCS * 2];
+static char buf[BUFLEN];
+
+static struct tst_fzsync_pair fzsync_pair = TST_FZSYNC_PAIR_INIT;
+
+static void create_pty(int *amaster, int *aslave)
+{
+	if (openpty(amaster, aslave, NULL, NULL, NULL) == -1)
+		tst_brk(TBROK | TERRNO, "pty creation failed");
+}
+
+static void setup(void)
+{
+	int i;
+
+	fzsync_pair.delay_inc = 100;
+	for (i = 0; i < ONEOFF_ALLOCS; i++) {
+		create_pty(&filler_ptys[i],
+			   &filler_ptys[i + ONEOFF_ALLOCS]);
+	}
+}
+
+static void *overwrite_thread_fn(void *p)
+{
+	tst_fzsync_delay_b(&fzsync_pair);
+	tst_fzsync_time_b(&fzsync_pair);
+
+	SAFE_WRITE(0, slave_fd, buf, BUFLEN - 1);
+	SAFE_WRITE(0, slave_fd, buf, BUFLEN - 1);
+	SAFE_WRITE(0, slave_fd, buf, BUFLEN);
+
+	return p;
+}
+
+static void run(void)
+{
+	struct termios t;
+	pthread_t overwrite_thread;
+	int i, j;
+
+	tst_res(TINFO, "Attempting to overflow into a tty_struct...");
+
+	for (i = 0; i < ATTEMPTS; i++) {
+		create_pty(&master_fd, &slave_fd);
+
+		for (j = 0; j < RUN_ALLOCS; j++)
+			create_pty(&target_ptys[j],
+				   &target_ptys[j + RUN_ALLOCS]);
+		SAFE_CLOSE(target_ptys[RUN_ALLOCS / 2]);
+		SAFE_CLOSE(target_ptys[RUN_ALLOCS / 2 + RUN_ALLOCS]);
+
+		SAFE_WRITE(0, slave_fd, buf, 1);
+
+		tcgetattr(master_fd, &t);
+		t.c_oflag &= ~OPOST;
+		t.c_lflag |= ECHO;
+		tcsetattr(master_fd, TCSANOW, &t);
+
+		SAFE_PTHREAD_CREATE(&overwrite_thread, NULL,
+				    overwrite_thread_fn, NULL);
+
+		tst_fzsync_delay_a(&fzsync_pair);
+		tst_fzsync_time_a(&fzsync_pair);
+		SAFE_WRITE(0, master_fd, "A", 1);
+
+		SAFE_PTHREAD_JOIN(overwrite_thread, NULL);
+
+		tst_fzsync_pair_update(i, &fzsync_pair);
+
+		if (!(i & 0x1FFF))
+			tst_fzsync_pair_info(&fzsync_pair);
+
+		for (j = 0; j < RUN_ALLOCS; j++) {
+			if (j == RUN_ALLOCS / 2)
+				continue;
+
+			ioctl(target_ptys[j], 0xdeadbeef);
+			ioctl(target_ptys[j + RUN_ALLOCS], 0xdeadbeef);
+			SAFE_CLOSE(target_ptys[j]);
+			SAFE_CLOSE(target_ptys[j + RUN_ALLOCS]);
+		}
+
+		ioctl(master_fd, 0xdeadbeef);
+		ioctl(slave_fd, 0xdeadbeef);
+		SAFE_CLOSE(master_fd);
+		SAFE_CLOSE(slave_fd);
+	}
+
+	tst_res(TPASS, "Nothing bad happened, probably.");
+}
+
+static void cleanup(void)
+{
+	int i;
+
+	for (i = 0; i < ONEOFF_ALLOCS * 2; i++)
+		close(filler_ptys[i]);
+	close(master_fd);
+	close(slave_fd);
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+};
diff --git a/testcases/cve/cve-2016-10044.c b/testcases/cve/cve-2016-10044.c
new file mode 100644
index 0000000..7928d27
--- /dev/null
+++ b/testcases/cve/cve-2016-10044.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ * Copyright (c) 2016 Jan Horn <jann@thejh.net>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Test for CVE-2016-10044, which was fixed in commit
+ * 22f6b4d34fcf039c aio: mark AIO pseudo-fs noexec.
+ *
+ * The test checks that we can not implicitly mark AIO mappings as
+ * executable using the READ_IMPLIES_EXEC personality.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include "lapi/syscalls.h"
+#include "lapi/personality.h"
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+
+static FILE *f;
+
+static void cleanup(void)
+{
+	if (f)
+		SAFE_FCLOSE(f);
+}
+
+static void run(void)
+{
+	uint64_t ctx = 0;
+	char perms[8], line[BUFSIZ];
+
+	SAFE_PERSONALITY(READ_IMPLIES_EXEC);
+	if (tst_syscall(__NR_io_setup, 1, &ctx))
+		tst_brk(TBROK | TERRNO, "Failed to create AIO context");
+
+	f = SAFE_FOPEN("/proc/self/maps", "r");
+	while (fgets(line, BUFSIZ, f) != NULL) {
+		if (strstr(line, "/[aio]") != NULL)
+			goto found_mapping;
+	}
+	tst_brk(TBROK, "Could not find mapping in /proc/self/maps");
+
+found_mapping:
+	if (sscanf(line, "%*x-%*x %s7", perms) < 0)
+		tst_brk(TBROK, "failed to find permission string in %s", line);
+	if (strchr(perms, (int)'x'))
+		tst_res(TFAIL, "AIO mapping is executable: %s!", perms);
+	else
+		tst_res(TPASS, "AIO mapping is not executable: %s", perms);
+
+	SAFE_FCLOSE(f);
+	f = NULL;
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.cleanup = cleanup,
+	.min_kver = "2.6.8",
+};
diff --git a/testcases/cve/cve-2016-4997.c b/testcases/cve/cve-2016-4997.c
new file mode 100644
index 0000000..2d99865
--- /dev/null
+++ b/testcases/cve/cve-2016-4997.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ * Based on repro-compatReleaseEntry.c by NCC group
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Test for CVE-2016-4997
+ *
+ * For a full explanation of how the vulnerability works see:
+ * https://github.com/nccgroup/TriforceLinuxSyscallFuzzer/tree/master/crash_reports/report_compatIpt
+ *
+ * The original vulnerability was present in the 32-bit compatibility system
+ * call, so the test should be compiled with -m32 and run on a 64-bit kernel.
+ * For simplicities sake the test requests root privliges instead of creating
+ * a user namespace.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <limits.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+
+#include "tst_test.h"
+#include "tst_safe_net.h"
+#include "tst_kernel.h"
+
+#define TOO_SMALL_OFFSET 74
+#define OFFSET_OVERWRITE 0xFFFF
+#define NEXT_OFFSET (sizeof(struct ipt_entry)		\
+		     + sizeof(struct xt_entry_match)	\
+		     + sizeof(struct xt_entry_target))
+#define PADDING (OFFSET_OVERWRITE - NEXT_OFFSET)
+
+#ifndef HAVE_STRUCT_XT_ENTRY_MATCH
+struct xt_entry_match {
+	union {
+		struct {
+			uint16_t match_size;
+			char name[29];
+			uint8_t revision;
+		} user;
+		struct {
+			uint16_t match_size;
+			void *match;
+		} kernel;
+		uint16_t match_size;
+	} u;
+	unsigned char data[0];
+};
+#endif
+
+#ifndef HAVE_STRUCT_XT_ENTRY_TARGET
+struct xt_entry_target {
+	union {
+		struct {
+			uint16_t target_size;
+			char name[29];
+			uint8_t revision;
+		} user;
+		struct {
+			uint16_t target_size;
+			void *target;
+		} kernel;
+		uint16_t target_size;
+	} u;
+	unsigned char data[0];
+};
+#endif
+
+struct payload {
+	struct ipt_replace repl;
+	struct ipt_entry ent;
+	struct xt_entry_match match;
+	struct xt_entry_target targ;
+	char padding[PADDING];
+	struct xt_entry_target targ2;
+};
+
+static void setup(void)
+{
+	if (tst_kernel_bits() == 32 || sizeof(long) > 4)
+		tst_res(TCONF,
+			"The vulnerability was only present in 32-bit compat mode");
+}
+
+static void run(void)
+{
+	int ret, sock_fd;
+	struct payload p = { 0 };
+
+	sock_fd = SAFE_SOCKET(AF_INET, SOCK_DGRAM, 0);
+
+	strncpy(p.match.u.user.name, "icmp", sizeof(p.match.u.user.name));
+	p.match.u.match_size = OFFSET_OVERWRITE;
+
+	p.ent.next_offset = NEXT_OFFSET;
+	p.ent.target_offset = TOO_SMALL_OFFSET;
+
+	p.repl.num_entries = 2;
+	p.repl.num_counters = 1;
+	p.repl.size = sizeof(struct payload);
+	p.repl.valid_hooks = 0;
+
+	ret = setsockopt(sock_fd, SOL_IP, IPT_SO_SET_REPLACE,
+			 &p, sizeof(struct payload));
+	tst_res(TPASS | TERRNO, "We didn't cause a crash, setsockopt returned %d", ret);
+}
+
+static struct tst_test test = {
+	.min_kver = "2.6.32",
+	.setup = setup,
+	.test_all = run,
+	.needs_root = 1,
+};
diff --git a/testcases/cve/cve-2016-7042.c b/testcases/cve/cve-2016-7042.c
new file mode 100644
index 0000000..8719eba
--- /dev/null
+++ b/testcases/cve/cve-2016-7042.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2017 Fujitsu Ltd.
+ * Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Test for CVE-2016-7042, this regression test can crash the buggy kernel
+ * when the stack-protector is enabled, and the bug was fixed in:
+ *
+ *  commit 03dab869b7b239c4e013ec82aea22e181e441cfc
+ *  Author: David Howells <dhowells@redhat.com>
+ *  Date:   Wed Oct 26 15:01:54 2016 +0100
+ *
+ *  KEYS: Fix short sprintf buffer in /proc/keys show function
+ */
+
+#include <errno.h>
+#include <stdio.h>
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+
+#define PATH_KEYS	"/proc/keys"
+
+static key_serial_t key;
+static int fd;
+
+static void do_test(void)
+{
+	char buf[BUFSIZ];
+
+	key = add_key("user", "ltptestkey", "a", 1, KEY_SPEC_SESSION_KEYRING);
+	if (key == -1)
+		tst_brk(TBROK, "Failed to add key");
+
+	if (keyctl(KEYCTL_UPDATE, key, "b", 1))
+		tst_brk(TBROK, "Failed to update key");
+
+	fd = SAFE_OPEN(PATH_KEYS, O_RDONLY);
+
+	tst_res(TINFO, "Attempting to crash the system");
+
+	SAFE_READ(0, fd, buf, BUFSIZ);
+
+	tst_res(TPASS, "Bug not reproduced");
+
+	SAFE_CLOSE(fd);
+
+	if (keyctl(KEYCTL_UNLINK, key, KEY_SPEC_SESSION_KEYRING))
+		tst_brk(TBROK, "Failed to unlink key");
+	key = 0;
+}
+
+static void setup(void)
+{
+	if (access(PATH_KEYS, F_OK))
+		tst_brk(TCONF, "%s does not exist", PATH_KEYS);
+}
+
+static void cleanup(void)
+{
+	if (key > 0 && keyctl(KEYCTL_UNLINK, key, KEY_SPEC_SESSION_KEYRING))
+		tst_res(TWARN, "Failed to unlink key");
+
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = do_test,
+};
diff --git a/testcases/cve/cve-2016-7117.c b/testcases/cve/cve-2016-7117.c
new file mode 100644
index 0000000..deb6677
--- /dev/null
+++ b/testcases/cve/cve-2016-7117.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * CVE-2016-7117
+ *
+ * This tests for a use after free caused by a race between recvmmsg() and
+ * close(). The exit path for recvmmsg() in (a2e2725541f: net: Introduce
+ * recvmmsg socket syscall) called fput() on the active file descriptor before
+ * checking the error state and setting the socket's error field.
+ *
+ * If one or more messages are received by recvmmsg() followed by one which
+ * fails, the socket's error field will be set. If just after recvmmsg() calls
+ * fput(), a call to close() is made on the same file descriptor there is a
+ * race between close() releasing the socket object and recvmmsg() setting its
+ * error field.
+ *
+ * fput() does not release a file descriptor's resources (e.g. a socket)
+ * immediatly, it queues them to be released just before a system call returns
+ * to user land. So the close() system call must call fput() after it is
+ * called in recvmmsg(), exit and release the resources all before the socket
+ * error is set.
+ *
+ * Usually if the vulnerability is present the test will be killed with a
+ * kernel null pointer exception. However this is not guaranteed to happen
+ * every time.
+ *
+ * The following was used for reference
+ * https://blog.lizzie.io/notes-about-cve-2016-7117.html
+ */
+
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/syscall.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "tst_test.h"
+#include "tst_safe_net.h"
+#include "tst_safe_pthread.h"
+#include "tst_timer.h"
+#include "tst_fuzzy_sync.h"
+
+/* The bug was present in the kernel before recvmmsg was exposed by glibc */
+#include "lapi/syscalls.h"
+
+#include "config.h"
+
+#define MSG "abcdefghijklmnop"
+#define RECV_TIMEOUT 1
+#define ATTEMPTS 0x1FFFFF
+
+#ifndef HAVE_STRUCT_MMSGHDR
+struct mmsghdr {
+	struct msghdr msg_hdr;
+	unsigned int msg_len;
+};
+#endif
+
+static int socket_fds[2];
+static struct mmsghdr msghdrs[2] = {
+	{
+		.msg_hdr = {
+			.msg_iov = &(struct iovec) {
+				.iov_len = sizeof(MSG),
+			},
+			.msg_iovlen = 1
+		}
+	},
+	{
+		.msg_hdr = {
+			.msg_iov = &(struct iovec) {
+				.iov_base = (void *)(0xbadadd),
+				.iov_len = ~0,
+			},
+			.msg_iovlen = 1
+		}
+	}
+};
+static char rbuf[sizeof(MSG)];
+static struct timespec timeout = { .tv_sec = RECV_TIMEOUT };
+static struct tst_fzsync_pair fzsync_pair = TST_FZSYNC_PAIR_INIT;
+
+static void cleanup(void)
+{
+	close(socket_fds[0]);
+	close(socket_fds[1]);
+}
+
+static void *send_and_close(void *arg)
+{
+	send(socket_fds[0], MSG, sizeof(MSG), 0);
+	send(socket_fds[0], MSG, sizeof(MSG), 0);
+
+	tst_fzsync_delay_b(&fzsync_pair);
+
+	close(socket_fds[0]);
+	close(socket_fds[1]);
+	tst_fzsync_time_b(&fzsync_pair);
+
+	return arg;
+}
+
+static void run(void)
+{
+	pthread_t pt_send;
+	int i, stat, too_early_count = 0;
+
+	msghdrs[0].msg_hdr.msg_iov->iov_base = (void *)&rbuf;
+
+	for (i = 1; i < ATTEMPTS; i++) {
+		if (socketpair(AF_LOCAL, SOCK_DGRAM, 0, socket_fds))
+			tst_brk(TBROK | TERRNO, "Socket creation failed");
+
+		SAFE_PTHREAD_CREATE(&pt_send, 0, send_and_close, 0);
+
+		tst_fzsync_delay_a(&fzsync_pair);
+
+		stat = tst_syscall(__NR_recvmmsg,
+				   socket_fds[1], msghdrs, 2, 0, &timeout);
+		tst_fzsync_time_a(&fzsync_pair);
+		if (stat < 0 && errno == EBADF)
+			too_early_count++;
+		else if (stat == 0)
+			tst_res(TWARN, "No messages received, should be one");
+		else if (stat < 0)
+			tst_res(TWARN | TERRNO, "recvmmsg failed unexpectedly");
+
+		SAFE_PTHREAD_JOIN(pt_send, 0);
+
+		tst_fzsync_pair_update(i, &fzsync_pair);
+		if (!(i & 0x7FFFF)) {
+			tst_res(TINFO, "Too early: %.1f%%",
+				100 * too_early_count / (float)i);
+			tst_fzsync_pair_info(&fzsync_pair);
+		}
+	}
+
+	tst_res(TPASS, "Nothing happened after %d attempts", ATTEMPTS);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.cleanup = cleanup,
+	.min_kver = "2.6.33",
+};
diff --git a/testcases/cve/cve-2017-2618.c b/testcases/cve/cve-2017-2618.c
new file mode 100644
index 0000000..e6b30e8
--- /dev/null
+++ b/testcases/cve/cve-2017-2618.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017 Fujitsu Ltd.
+ * Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Test for CVE-2017-2618, this regression test can crash
+ * the buggy kernel, and the bug was fixed in:
+ *
+ *  commit 0c461cb727d146c9ef2d3e86214f498b78b7d125
+ *  Author: Stephen Smalley <sds@tycho.nsa.gov>
+ *  Date:   Tue Jan 31 11:54:04 2017 -0500
+ *
+ *  selinux: fix off-by-one in setprocattr
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "tst_test.h"
+
+#define LOOPS	100
+#define PATH_ATTRFS	"/proc/self/attr/fscreate"
+
+static void do_test(void)
+{
+	int i, fd;
+
+	for (i = 0; i < LOOPS; i++) {
+		if (!SAFE_FORK()) {
+			fd = SAFE_OPEN(PATH_ATTRFS, O_WRONLY);
+			write(fd, "\n", 1);
+			SAFE_CLOSE(fd);
+			exit(0);
+		}
+
+		tst_reap_children();
+	}
+
+	tst_res(TPASS, "Bug not reproduced");
+}
+
+static struct tst_test test = {
+	.forks_child = 1,
+	.test_all = do_test,
+};
diff --git a/testcases/cve/cve-2017-2671.c b/testcases/cve/cve-2017-2671.c
new file mode 100644
index 0000000..77744db
--- /dev/null
+++ b/testcases/cve/cve-2017-2671.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ * Original POC by Daniel Jiang
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Test for CVE-2017-2671 faulty locking on ping socket
+ *
+ * When sys_connect() is called with sockaddr.sin_family set to AF_UNSPEC on a
+ * ping socket; __udp_disconnect() gets called, which in turn calls the buggy
+ * function ping_unhashed(). This function does not obtain a rwlock before
+ * checking if the socket is hashed allowing the socket data to be pulled from
+ * underneath it in the time between calling sk_hashed() and gaining the write
+ * lock.
+ *
+ * Fixed in commit 43a6684519ab0a6c52024b5e25322476cabad893
+ *
+ * This test repeatedly 'connects' a ping socket correctly then calls
+ * connect() with AF_UNSPEC in two seperate threads to trigger the race
+ * condition. If the bug is present, then the test will most likely crash the
+ * system.
+ *
+ * The test requests root privileges so that it can ensure ping sockets are
+ * enabled. On distributions (including Android) where ping sockets are
+ * enabled by default, root privileges are not required.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+
+#include "tst_test.h"
+#include "tst_safe_net.h"
+#include "tst_safe_pthread.h"
+
+#include "tst_fuzzy_sync.h"
+
+#define ATTEMPTS 0xFFFF
+#define PING_SYSCTL_PATH "/proc/sys/net/ipv4/ping_group_range"
+
+static int sockfd;
+static unsigned int ping_min_grp, ping_max_grp;
+static struct tst_fzsync_pair fzsync_pair = TST_FZSYNC_PAIR_INIT;
+static struct sockaddr_in iaddr, uaddr;
+
+static void setup(void)
+{
+	iaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+	uaddr = iaddr;
+	iaddr.sin_family = AF_INET;
+	uaddr.sin_family = AF_UNSPEC;
+	fzsync_pair.delay_inc = 1;
+
+	if (access(PING_SYSCTL_PATH, F_OK))
+		tst_brk(TCONF, "socket() does not support IPPROTO_ICMP");
+
+	SAFE_FILE_SCANF(PING_SYSCTL_PATH, "%u %u",
+			&ping_min_grp, &ping_max_grp);
+	SAFE_FILE_PRINTF(PING_SYSCTL_PATH, "0 0");
+
+	sockfd = SAFE_SOCKET(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
+	tst_res(TINFO, "Created ping socket, attempting to race...");
+}
+
+static void cleanup(void)
+{
+	if (sockfd > 0)
+		SAFE_CLOSE(sockfd);
+	if (ping_min_grp | ping_max_grp)
+		SAFE_FILE_PRINTF(PING_SYSCTL_PATH, "%u %u",
+				 ping_min_grp, ping_max_grp);
+}
+
+static void *connect_b(void * param LTP_ATTRIBUTE_UNUSED)
+{
+	tst_fzsync_delay_b(&fzsync_pair);
+	connect(sockfd, (struct sockaddr *)&uaddr, sizeof(uaddr));
+	tst_fzsync_time_b(&fzsync_pair);
+
+	return 0;
+}
+
+static void run(void)
+{
+	pthread_t thrd;
+	int i;
+
+	for (i = 0; i < ATTEMPTS; i++) {
+		SAFE_CONNECT(sockfd,
+			     (struct sockaddr *)&iaddr, sizeof(iaddr));
+		SAFE_PTHREAD_CREATE(&thrd, 0, connect_b, 0);
+
+		tst_fzsync_delay_a(&fzsync_pair);
+		connect(sockfd, (struct sockaddr *)&uaddr, sizeof(uaddr));
+		tst_fzsync_time_a(&fzsync_pair);
+
+		SAFE_PTHREAD_JOIN(thrd, 0);
+		tst_fzsync_pair_update(i, &fzsync_pair);
+
+		if (!(i & 0x7FFF))
+			tst_fzsync_pair_info(&fzsync_pair);
+	}
+
+	tst_res(TPASS, "We didn't crash");
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.test_all = run,
+	.cleanup = cleanup,
+	.needs_root = 1,
+};
diff --git a/testcases/cve/cve-2017-5669.c b/testcases/cve/cve-2017-5669.c
new file mode 100644
index 0000000..1ca5983
--- /dev/null
+++ b/testcases/cve/cve-2017-5669.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ * Copyright (c) 2017 Fujitsu Ltd. (Xiao Yang <yangx.jy@cn.fujitsu.com>)
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Test for CVE-2017-5669 which allows us to map the nil page using shmat.
+ *
+ * When the bug is present shmat(..., (void *)1, SHM_RND) will round address
+ * 0x1 down to zero and give us the (nil/null) page. With the current bug fix
+ * in place, shmat it will return EINVAL instead. We also check to see if the
+ * returned address is outside the nil page in case an alternative fix has
+ * been applied.
+ *
+ * In any case we manage to map some memory we also try to write to it. This
+ * is just to see if we get an access error or some other unexpected behaviour.
+ *
+ * See commit 95e91b831f (ipc/shm: Fix shmat mmap nil-page protection)
+ */
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+
+static int shm_id;
+static void *shm_addr;
+
+static void setup(void)
+{
+	shm_id = SAFE_SHMGET(IPC_PRIVATE, getpagesize(), 0777);
+}
+
+static void cleanup(void)
+{
+	if (shm_addr)
+		SAFE_SHMDT(shm_addr);
+
+	if (shm_id)
+		SAFE_SHMCTL(shm_id, IPC_RMID, 0);
+}
+
+static void run(void)
+{
+	tst_res(TINFO, "Attempting to attach shared memory to null page");
+	shm_addr = shmat(shm_id, ((void *)1), SHM_RND);
+	if (shm_addr == (void *)-1) {
+		shm_addr = NULL;
+		if (errno == EINVAL) {
+			tst_res(TPASS, "shmat returned EINVAL");
+			return;
+		}
+		tst_brk(TBROK | TERRNO,
+			"The bug was not triggered, but the shmat error is unexpected");
+	}
+
+	tst_res(TINFO, "Mapped shared memory to %p", shm_addr);
+
+	if (!((size_t)shm_addr & (~0U << 16)))
+		tst_res(TFAIL,
+			"We have mapped a VM address within the first 64Kb");
+	else
+		tst_res(TPASS,
+			"The kernel assigned a different VM address");
+
+	tst_res(TINFO,
+		"Touching shared memory to see if anything strange happens");
+	((char *)shm_addr)[0] = 'P';
+
+	SAFE_SHMDT(shm_addr);
+	shm_addr = NULL;
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+};
diff --git a/testcases/cve/cve-2017-6951.c b/testcases/cve/cve-2017-6951.c
new file mode 100644
index 0000000..028e25f
--- /dev/null
+++ b/testcases/cve/cve-2017-6951.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Richard Palethorpe <rpalethorpe@suse.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Test for CVE-2016-6951, original reproducer can be found here:
+ * http://www.spinics.net/lists/keyrings/msg01845.html
+ *
+ * request_key() is not in glibc, so we just use the syscall directly instead
+ * of linking to keyutils.
+ */
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+
+#define ATTEMPTS 0x100
+
+static void run(void)
+{
+	int i;
+
+	tst_res(TINFO, "Requesting dead key");
+	for (i = 0; i < ATTEMPTS; i++)
+		tst_syscall(__NR_request_key, "dead", "abc", "abc", 0, 0, 0);
+
+	tst_res(TPASS, "No crash after %d attempts", ATTEMPTS);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+};
diff --git a/testcases/cve/stack_clash.c b/testcases/cve/stack_clash.c
new file mode 100644
index 0000000..49c45ef
--- /dev/null
+++ b/testcases/cve/stack_clash.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2017 Pavel Boldin <pboldin@cloudlinux.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Adapted from code by Michal Hocko.
+ */
+
+/* This is a regression test of the Stack Clash [1] vulnerability. This tests
+ * that there is at least 256 PAGE_SIZE of stack guard gap which is considered
+ * hard to hop above. Code adapted from the Novell's bugzilla [2].
+ *
+ * The code `mmap(2)`s region close to the stack end. The code then allocates
+ * memory on stack until it hits guard page and SIGSEGV or SIGBUS is generated
+ * by the kernel. The signal handler checks that fault address is further than
+ * THRESHOLD from the mmapped area.
+ *
+ * We read /proc/self/maps to examine exact top of the stack and `mmap(2)`
+ * our region exactly GAP_PAGES * PAGE_SIZE away. We read /proc/cmdline to
+ * see if a different stack_guard_gap size is configured. We set stack limit
+ * to infinity and preallocate REQ_STACK_SIZE bytes of stack so that no calls
+ * after `mmap` are moving stack further.
+ *
+ * [1] https://blog.qualys.com/securitylabs/2017/06/19/the-stack-clash
+ * [2] https://bugzilla.novell.com/show_bug.cgi?id=CVE-2017-1000364
+ */
+
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <alloca.h>
+#include <signal.h>
+#include <stdlib.h>
+
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+
+static unsigned long page_size;
+static unsigned long page_mask;
+static unsigned long GAP_PAGES = 256;
+static unsigned long THRESHOLD;
+static int STACK_GROWSDOWN;
+
+#define SIGNAL_STACK_SIZE	(1UL<<20)
+#define FRAME_SIZE		1024
+#define REQ_STACK_SIZE		(1024 * 1024)
+
+#define EXIT_TESTBROKE		TBROK
+
+void exhaust_stack_into_sigsegv(void)
+{
+	volatile char * ptr = alloca(FRAME_SIZE - sizeof(long));
+	*ptr = '\0';
+	exhaust_stack_into_sigsegv();
+}
+
+#define MAPPED_LEN page_size
+static unsigned long mapped_addr;
+
+void segv_handler(int sig, siginfo_t *info, void *data LTP_ATTRIBUTE_UNUSED)
+{
+	unsigned long fault_addr = (unsigned long)info->si_addr;
+	unsigned long mmap_end = mapped_addr + MAPPED_LEN;
+	ssize_t diff;
+
+	if (sig != SIGSEGV && sig != SIGBUS)
+		return;
+
+	if (STACK_GROWSDOWN)
+		diff = fault_addr - mmap_end;
+	else
+		diff = mapped_addr - fault_addr;
+
+	tst_res(TINFO,
+		"mmap = [%lx, %lx), addr = %lx, diff = %zx, THRESHOLD = %lx",
+		mapped_addr, mmap_end, fault_addr, diff, THRESHOLD);
+	if (diff < 0 || (unsigned long)diff < THRESHOLD)
+		_exit(EXIT_FAILURE);
+	else
+		_exit(EXIT_SUCCESS);
+}
+
+unsigned long read_stack_addr_from_proc(unsigned long *stack_size)
+{
+	FILE *fh;
+	char buf[1024];
+	unsigned long stack_top = -1UL, start, end;
+
+	fh = SAFE_FOPEN("/proc/self/maps", "r");
+
+	while (!feof(fh)) {
+		if (fgets(buf, sizeof(buf), fh) == NULL) {
+			tst_brk(TBROK | TERRNO, "fgets");
+			goto out;
+		}
+
+		if (!strstr(buf, "[stack"))
+			continue;
+
+		if (sscanf(buf, "%lx-%lx", &start, &end) != 2) {
+			tst_brk(TBROK | TERRNO, "sscanf");
+			goto out;
+		}
+
+		*stack_size = end - start;
+
+		if (STACK_GROWSDOWN)
+			stack_top = start;
+		else
+			stack_top = end;
+		break;
+	}
+
+out:
+	SAFE_FCLOSE(fh);
+	return stack_top;
+}
+
+void dump_proc_self_maps(void)
+{
+	static char buf[64];
+	static const char *cmd[] = {"cat", buf, NULL};
+	sprintf(buf, "/proc/%d/maps", getpid());
+	tst_run_cmd(cmd, NULL, NULL, 0);
+}
+
+void preallocate_stack(unsigned long required)
+{
+	volatile char *garbage;
+
+	garbage = alloca(required);
+	garbage[0] = garbage[required - 1] = '\0';
+}
+
+void do_child(void)
+{
+	unsigned long stack_addr, stack_size;
+	stack_t signal_stack;
+	struct sigaction segv_sig = {.sa_sigaction = segv_handler, .sa_flags = SA_ONSTACK|SA_SIGINFO};
+	void *map;
+	unsigned long gap = GAP_PAGES * page_size;
+	struct rlimit rlimit;
+
+	rlimit.rlim_cur = rlimit.rlim_max = RLIM_INFINITY;
+	SAFE_SETRLIMIT(RLIMIT_STACK, &rlimit);
+
+	preallocate_stack(REQ_STACK_SIZE);
+
+	stack_addr = read_stack_addr_from_proc(&stack_size);
+	if (stack_addr == -1UL) {
+		tst_brk(TBROK, "can't read stack top from /proc/self/maps");
+		return;
+	}
+
+	if (STACK_GROWSDOWN)
+		mapped_addr = stack_addr - gap - MAPPED_LEN;
+	else
+		mapped_addr = stack_addr + gap;
+
+	mapped_addr &= page_mask;
+	map = SAFE_MMAP((void *)mapped_addr, MAPPED_LEN,
+			PROT_READ|PROT_WRITE,
+			MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
+	tst_res(TINFO, "Stack:0x%lx+0x%lx mmap:%p+0x%lx",
+		stack_addr, stack_size, map, MAPPED_LEN);
+
+	signal_stack.ss_sp = SAFE_MALLOC(SIGNAL_STACK_SIZE);
+	signal_stack.ss_size = SIGNAL_STACK_SIZE;
+	signal_stack.ss_flags = 0;
+	if (sigaltstack(&signal_stack, NULL) == -1) {
+		tst_brk(TBROK | TERRNO, "sigaltstack");
+		return;
+	}
+	if (sigaction(SIGSEGV, &segv_sig, NULL) == -1 ||
+	    sigaction(SIGBUS,  &segv_sig, NULL) == -1) {
+		tst_brk(TBROK | TERRNO, "sigaction");
+		return;
+	}
+
+#ifdef DEBUG
+	dump_proc_self_maps();
+#endif
+
+	exhaust_stack_into_sigsegv();
+}
+
+void setup(void)
+{
+	char buf[4096], *p;
+
+	page_size = sysconf(_SC_PAGESIZE);
+	page_mask = ~(page_size - 1);
+
+	buf[4095] = '\0';
+	SAFE_FILE_SCANF("/proc/cmdline", "%4095[^\n]", buf);
+
+	if ((p = strstr(buf, "stack_guard_gap=")) != NULL) {
+		if (sscanf(p, "stack_guard_gap=%ld", &GAP_PAGES) != 1) {
+			tst_brk(TBROK | TERRNO, "sscanf");
+			return;
+		}
+		tst_res(TINFO, "stack_guard_gap = %ld", GAP_PAGES);
+	}
+
+	THRESHOLD = (GAP_PAGES - 1) * page_size;
+
+	{
+		volatile int *a = alloca(128);
+
+		{
+			volatile int *b = alloca(128);
+
+			STACK_GROWSDOWN = a > b;
+			tst_res(TINFO, "STACK_GROWSDOWN = %d == %p > %p", STACK_GROWSDOWN, a, b);
+		}
+	}
+}
+
+void stack_clash_test(void)
+{
+	int status;
+	pid_t pid;
+
+	pid = SAFE_FORK();
+	if (!pid) {
+		do_child();
+		exit(EXIT_TESTBROKE);
+		return;
+	}
+
+	SAFE_WAITPID(pid, &status, 0);
+
+	if (WIFEXITED(status)) {
+		switch (WEXITSTATUS(status)) {
+		case EXIT_FAILURE:
+			tst_res(TFAIL, "stack is too close to the mmaped area");
+			return;
+		case EXIT_SUCCESS:
+			tst_res(TPASS, "stack is far enough from mmaped area");
+			return;
+		default:
+		case EXIT_TESTBROKE:
+			break;
+		}
+	}
+
+	tst_brk(TBROK, "child did not exit gracefully");
+}
+
+static struct tst_test test = {
+	.forks_child = 1,
+	.needs_root = 1,
+	.setup = setup,
+	.test_all = stack_clash_test,
+};
diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile
index 4dd1129..11aae96 100644
--- a/testcases/kernel/Makefile
+++ b/testcases/kernel/Makefile
@@ -66,15 +66,4 @@
 				sched security timers
 endif
 
-MAKE_DEPS		:= include/linux_syscall_numbers.h
-
-include:
-	mkdir -p "$@"
-
-linux-syscall-numbers-clean:: include
-	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
-
-include/linux_syscall_numbers.h: include
-	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" all
-
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/containers/libclone/libclone.h b/testcases/kernel/containers/libclone/libclone.h
index 70d52e0..b8740f1 100644
--- a/testcases/kernel/containers/libclone/libclone.h
+++ b/testcases/kernel/containers/libclone/libclone.h
@@ -26,7 +26,7 @@
 #include <libgen.h>
 #include <sys/syscall.h>
 #include <signal.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "test.h"
 #include "lapi/namespaces_constants.h"
 
diff --git a/testcases/kernel/containers/mqns/mqns_helper.h b/testcases/kernel/containers/mqns/mqns_helper.h
index 1c7132b..605378d 100644
--- a/testcases/kernel/containers/mqns/mqns_helper.h
+++ b/testcases/kernel/containers/mqns/mqns_helper.h
@@ -21,7 +21,7 @@
 #include <sys/types.h>
 #include <mqueue.h>
 #include "../libclone/libclone.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 #include "test.h"
 
diff --git a/testcases/kernel/containers/netns/netns_helper.h b/testcases/kernel/containers/netns/netns_helper.h
index 7df6dcb..8b87645 100644
--- a/testcases/kernel/containers/netns/netns_helper.h
+++ b/testcases/kernel/containers/netns/netns_helper.h
@@ -24,7 +24,7 @@
 #include <sched.h>
 #include "config.h"
 #include "libclone.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "test.h"
 #include "safe_macros.h"
 
diff --git a/testcases/kernel/containers/netns/netns_helper.sh b/testcases/kernel/containers/netns/netns_helper.sh
index 77d30bf..a95cdf2 100755
--- a/testcases/kernel/containers/netns/netns_helper.sh
+++ b/testcases/kernel/containers/netns/netns_helper.sh
@@ -63,8 +63,8 @@
 
 tst_check_iproute()
 {
-	local cur_ipver=`ip -V`
-	local spe_ipver=$1
+	local cur_ipver="$(ip -V)"
+	local spe_ipver="$1"
 
 	cur_ipver=${cur_ipver##*s}
 
diff --git a/testcases/kernel/containers/pidns/pidns30.c b/testcases/kernel/containers/pidns/pidns30.c
index 849240c..5781b24 100644
--- a/testcases/kernel/containers/pidns/pidns30.c
+++ b/testcases/kernel/containers/pidns/pidns30.c
@@ -51,7 +51,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <mqueue.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "pidns_helper.h"
 #include "test.h"
 
diff --git a/testcases/kernel/containers/pidns/pidns31.c b/testcases/kernel/containers/pidns/pidns31.c
index aaf0c0f..935b635 100644
--- a/testcases/kernel/containers/pidns/pidns31.c
+++ b/testcases/kernel/containers/pidns/pidns31.c
@@ -53,7 +53,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <mqueue.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "pidns_helper.h"
 #include "test.h"
 
diff --git a/testcases/kernel/containers/share/ns_exec.c b/testcases/kernel/containers/share/ns_exec.c
index ddf1382..c492165 100644
--- a/testcases/kernel/containers/share/ns_exec.c
+++ b/testcases/kernel/containers/share/ns_exec.c
@@ -30,7 +30,7 @@
 #include <string.h>
 #include <errno.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/namespaces_constants.h"
 #include "ns_common.h"
 
diff --git a/testcases/kernel/containers/share/setns_check.c b/testcases/kernel/containers/share/setns_check.c
index 7ba891c..75aad17 100644
--- a/testcases/kernel/containers/share/setns_check.c
+++ b/testcases/kernel/containers/share/setns_check.c
@@ -19,7 +19,7 @@
  */
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "setns_check";
 
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
index 2c8dfd3..907881c 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
@@ -93,7 +93,8 @@
     tst_tmpdir
     TST_CLEANUP=cleanup
 
-    mount_point=`grep -w $subsystem /proc/mounts | cut -f 2 | cut -d " " -f2`
+    mount_point=`grep -w $subsystem /proc/mounts | grep -w "cgroup" | \
+	cut -f 2 | cut -d " " -f2`
 
     if [ -z "$mount_point" ]; then
         try_umount=1
diff --git a/testcases/kernel/controllers/cpuacct/cpuacct.sh b/testcases/kernel/controllers/cpuacct/cpuacct.sh
index 6d3778c..edd4a98 100755
--- a/testcases/kernel/controllers/cpuacct/cpuacct.sh
+++ b/testcases/kernel/controllers/cpuacct/cpuacct.sh
@@ -35,7 +35,6 @@
 # 2) Check that sum ltp_test/subgroup*/cpuacct.usage = ltp_test/cpuacct.usage
 #
 
-TST_ID="cpuacct"
 TST_SETUP=setup
 TST_CLEANUP=cleanup
 TST_TESTFUNC=do_test
diff --git a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh
index 992b8f2..70e7203 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh
@@ -181,7 +181,6 @@
 		do
 			base_op_test "$CPUSET/$filename" "$flags" "$result"
 		done <<- EOF
-			NULL	0
 			0	0
 			1	1
 			-1	WRITE_ERROR
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/libbitmask.c b/testcases/kernel/controllers/cpuset/cpuset_lib/libbitmask.c
index 57faf78..dbae375 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/libbitmask.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/libbitmask.c
@@ -28,6 +28,7 @@
 #include <stdint.h>
 
 #include "bitmask.h"
+#include "tst_minmax.h"
 
 struct bitmask {
 	unsigned int size;
@@ -112,7 +113,6 @@
 
 #define HEXCHUNKSZ 32		/* hex binary format shows 32 bits per chunk */
 #define HEXCHARSZ 8		/* hex ascii format has up to 8 chars per chunk */
-#define max(a,b) ((a) > (b) ? (a) : (b))
 
 /*
  * Write hex word representation of bmp to buf, 32 bits per
@@ -139,7 +139,7 @@
 
 		for (bit = HEXCHUNKSZ - 1; bit >= 0; bit--)
 			val = val << 1 | _getbit(bmp, chunk * HEXCHUNKSZ + bit);
-		cnt += snprintf(buf + cnt, max(buflen - cnt, 0), "%s%0*x",
+		cnt += snprintf(buf + cnt, MAX(buflen - cnt, 0), "%s%0*x",
 				sep, HEXCHARSZ, val);
 		sep = ",";
 	}
@@ -158,12 +158,12 @@
 static inline int emit(char *buf, int buflen, int rbot, int rtop, int len)
 {
 	if (len > 0)
-		len += snprintf(buf + len, max(buflen - len, 0), ",");
+		len += snprintf(buf + len, MAX(buflen - len, 0), ",");
 	if (rbot == rtop)
-		len += snprintf(buf + len, max(buflen - len, 0), "%d", rbot);
+		len += snprintf(buf + len, MAX(buflen - len, 0), "%d", rbot);
 	else
 		len +=
-		    snprintf(buf + len, max(buflen - len, 0), "%d-%d", rbot,
+		    snprintf(buf + len, MAX(buflen - len, 0), "%d-%d", rbot,
 			     rtop);
 	return len;
 }
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c b/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c
index 83ff5cd..b382896 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c
@@ -48,7 +48,7 @@
 #include "cpuset.h"
 #include "common.h"
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "config.h"
 #if HAVE_LINUX_MEMPOLICY_H
 #include <linux/mempolicy.h>
@@ -138,9 +138,6 @@
 /* The primary source for the cpunodemap[] is available below here. */
 static const char *sysdevices = "/sys/devices/system";
 
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
 /* small buffer size - for reading boolean flags or map file (1 or 2 ints) */
 #define SMALL_BUFSZ 16
 
@@ -2499,7 +2496,7 @@
 		if (secs_loop < 10)
 			secs_loop++;
 
-		secs_loop = min(secs_left, secs_loop);
+		secs_loop = MIN(secs_left, secs_loop);
 	}
 
 took_too_long:
@@ -3484,39 +3481,39 @@
 	int n = 0;
 
 	if (cp->cpu_exclusive)
-		n += snprintf(buf + n, max(buflen - n, 0), "cpu_exclusive\n");
+		n += snprintf(buf + n, MAX(buflen - n, 0), "cpu_exclusive\n");
 
 	if (cp->mem_exclusive)
-		n += snprintf(buf + n, max(buflen - n, 0), "mem_exclusive\n");
+		n += snprintf(buf + n, MAX(buflen - n, 0), "mem_exclusive\n");
 
 	if (cp->notify_on_release)
-		n += snprintf(buf + n, max(buflen - n, 0),
+		n += snprintf(buf + n, MAX(buflen - n, 0),
 			      "notify_on_release\n");
 
 	if (cp->memory_pressure_enabled)
-		n += snprintf(buf + n, max(buflen - n, 0),
+		n += snprintf(buf + n, MAX(buflen - n, 0),
 			      "memory_pressure_enabled\n");
 
 	if (cp->memory_migrate)
-		n += snprintf(buf + n, max(buflen - n, 0), "memory_migrate\n");
+		n += snprintf(buf + n, MAX(buflen - n, 0), "memory_migrate\n");
 
 	if (cp->memory_spread_page)
-		n += snprintf(buf + n, max(buflen - n, 0),
+		n += snprintf(buf + n, MAX(buflen - n, 0),
 			      "memory_spread_page\n");
 
 	if (cp->memory_spread_slab)
-		n += snprintf(buf + n, max(buflen - n, 0),
+		n += snprintf(buf + n, MAX(buflen - n, 0),
 			      "memory_spread_slab\n");
 
 	if ((tmp = sprint_mask_buf(cp->cpus)) == NULL)
 		return -1;
-	n += snprintf(buf + n, max(buflen - n, 0), "cpus %s\n", tmp);
+	n += snprintf(buf + n, MAX(buflen - n, 0), "cpus %s\n", tmp);
 	free(tmp);
 	tmp = NULL;
 
 	if ((tmp = sprint_mask_buf(cp->mems)) == NULL)
 		return -1;
-	n += snprintf(buf + n, max(buflen - n, 0), "mems %s\n", tmp);
+	n += snprintf(buf + n, MAX(buflen - n, 0), "mems %s\n", tmp);
 	free(tmp);
 	tmp = NULL;
 
diff --git a/testcases/kernel/controllers/memcg/.gitignore b/testcases/kernel/controllers/memcg/.gitignore
index 8730251..c0b6d07 100644
--- a/testcases/kernel/controllers/memcg/.gitignore
+++ b/testcases/kernel/controllers/memcg/.gitignore
@@ -2,5 +2,6 @@
 /functional/memcg_process
 /regression/memcg_test_1
 /regression/memcg_test_2
+/regression/memcg_test_3
 /regression/memcg_test_4
 /stress/memcg_process_stress
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index b785fe3..d4724c3 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -506,7 +506,7 @@
 	# while there are distributions (RHEL7U0Beta for example) that sets
 	# it to 1.
 	orig_memory_use_hierarchy=$(cat /dev/memcg/memory.use_hierarchy)
-	if [ -z "orig_memory_use_hierarchy" ];then
+	if [ -z "$orig_memory_use_hierarchy" ];then
 		tst_resm TINFO "cat /dev/memcg/memory.use_hierarchy failed"
 	elif [ "$orig_memory_use_hierarchy" = "0" ];then
 		orig_memory_use_hierarchy=""
diff --git a/testcases/kernel/controllers/memcg/regression/memcg_test_3.c b/testcases/kernel/controllers/memcg/regression/memcg_test_3.c
new file mode 100644
index 0000000..994d87b
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/regression/memcg_test_3.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2017 Fujitsu Ltd.
+ *  Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This is a regression test for a crash caused by memcg function
+ * reentrant on RHEL6.  When doing rmdir(), a pending signal can
+ * interrupt the execution and lead to cgroup_clear_css_refs()
+ * being entered repeatedly, this results in a BUG_ON().
+ *
+ * This bug was introduced by following RHEL6 patch on 2.6.32-488.el6:
+ *
+ *  [mm] memcg: fix race condition between memcg teardown and swapin
+ *  Link: https://bugzilla.redhat.com/show_bug.cgi?id=1001197
+ *  Patch: ftp://partners.redhat.com/1c5d859a/de6aafa8185ed8fd934f2debc72b79eb/kernel-individual-patch/rhel6/v2.6.32-to-kernel-2.6.32-488.el6.tar.bz2
+ *         31675-mm-memcg-fix-race-condition-between-memcg-teardown-.patch
+ *
+ * This test can crash the buggy kernel on RHEL6.6GA, and the bug
+ * was fixed by following patch on 2.6.32-536.el6:
+ *
+ *  [mm] memcg: fix crash in re-entrant cgroup_clear_css_refs()
+ *  Link: https://bugzilla.redhat.com/show_bug.cgi?id=1168185
+ *  Patch: ftp://partners.redhat.com/1c5d859a/de6aafa8185ed8fd934f2debc72b79eb/kernel-individual-patch/rhel6/v2.6.32-to-kernel-2.6.32-536.el6.tar.bz2
+ *         35944-mm-memcg-fix-crash-in-re-entrant-cgroup_clear_css_r.patch
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+#include "tst_test.h"
+
+#define MNTPOINT	"memcg"
+#define SUBDIR	"memcg/testdir"
+
+static int mount_flag;
+static volatile int sigcounter;
+
+static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
+{
+	sigcounter++;
+}
+
+static void do_child(void)
+{
+	while (1)
+		SAFE_KILL(getppid(), SIGUSR1);
+
+	exit(0);
+}
+
+static void do_test(void)
+{
+	pid_t cpid;
+
+	SAFE_SIGNAL(SIGUSR1, sighandler);
+
+	cpid = SAFE_FORK();
+	if (cpid == 0)
+		do_child();
+
+	while (sigcounter < 50000) {
+		if (access(SUBDIR, F_OK))
+			SAFE_MKDIR(SUBDIR, 0644);
+		rmdir(SUBDIR);
+	}
+
+	SAFE_KILL(cpid, SIGKILL);
+	SAFE_WAIT(NULL);
+
+	tst_res(TPASS, "Bug not reproduced");
+}
+
+static void setup(void)
+{
+	int ret;
+
+	SAFE_MKDIR(MNTPOINT, 0644);
+
+	ret = mount("memcg", MNTPOINT, "cgroup", 0, "memory");
+	if (ret) {
+		if (errno == ENOENT)
+			tst_brk(TCONF | TERRNO, "memcg not supported");
+
+		tst_brk(TCONF | TERRNO, "mounting memcg failed");
+	}
+	mount_flag = 1;
+}
+
+static void cleanup(void)
+{
+	if (!access(SUBDIR, F_OK))
+		SAFE_RMDIR(SUBDIR);
+
+	if (mount_flag)
+		tst_umount(MNTPOINT);
+}
+
+static struct tst_test test = {
+	.tid = "memcg_test_3",
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.forks_child = 1,
+	.min_kver = "2.6.24",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = do_test,
+};
diff --git a/testcases/kernel/controllers/pids/pids.sh b/testcases/kernel/controllers/pids/pids.sh
index eda29cb..e2385a1 100755
--- a/testcases/kernel/controllers/pids/pids.sh
+++ b/testcases/kernel/controllers/pids/pids.sh
@@ -26,7 +26,6 @@
 # Usage
 # ./pids.sh caseno max
 #
-TST_ID="pids"
 TST_CLEANUP=cleanup
 TST_SETUP=setup
 TST_TESTFUNC=do_test
diff --git a/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c b/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c
index 0cc6411..4ab6b83 100644
--- a/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c
+++ b/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c
@@ -46,6 +46,7 @@
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/sysmacros.h>
 #include <sys/types.h>
 #include <linux/kernel.h>
 #include <unistd.h>
diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index 64284d5..82e9f12 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -32,6 +32,16 @@
 # Number of items must be equal to 'dev_num' parameter.
 zram_max_streams="2 3 5 8"
 
+FS_SIZE="402653184"
+FS_TYPE="btrfs"
+
+RAM_SIZE=$(awk '/MemTotal:/ {print $2}' /proc/meminfo)
+if [ "$RAM_SIZE" -lt 1048576 ]; then
+	tst_res TINFO "Not enough space for Btrfs"
+	FS_SIZE="26214400"
+	FS_TYPE="ext2"
+fi
+
 # The zram sysfs node 'disksize' value can be either in bytes,
 # or you can use mem suffixes. But in some old kernels, mem
 # suffixes are not supported, for example, in RHEL6.6GA's kernel
@@ -39,9 +49,9 @@
 # not support mem suffixes, in some newer kernels, they use
 # memparse() which supports mem suffixes. So here we just use
 # bytes to make sure everything works correctly.
-zram_sizes="26214400 26214400 26214400 41943040" # 25MB, 40MB for btrfs
-zram_mem_limits="25M 25M 25M 40M"
-zram_filesystems="ext3 ext4 xfs btrfs"
+zram_sizes="26214400 26214400 26214400 $FS_SIZE"
+zram_mem_limits="25M 25M 25M $((FS_SIZE/1024/1024))M"
+zram_filesystems="ext3 ext4 xfs $FS_TYPE"
 zram_algs="lzo lzo lzo lzo"
 
 TST_CLEANUP="zram_cleanup"
@@ -91,7 +101,6 @@
 zram_set_memlimit
 zram_makefs
 zram_mount
-
 zram_fill_fs
 
 tst_exit
diff --git a/testcases/kernel/fs/Makefile b/testcases/kernel/fs/Makefile
index d843b48..caa2c2d 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 9ee7e1d..0000000
--- 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 6461a6f..0000000
--- 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 1bea383..0000000
--- 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, &region,
-				       &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,
-					&region, &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 657484f..0000000
--- 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 7b4123f..0000000
--- 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,
-				       &region, &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,
-				       &region, &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,
-				       &region, &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,
-					&region, &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 62f1877..0000000
--- 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 dc0dbda..0000000
--- 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 d30e0c0..0000000
--- 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 8f6b4b3..0000000
--- 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 adc4681..0000000
--- 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 6713225..0000000
--- 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 7d95104..0000000
--- 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 e59629d..0000000
--- 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 34031b5..0000000
--- 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 46925fe..0000000
--- 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 3a57c2e..0000000
--- 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 daddc9a..0000000
--- 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 75be0f4..0000000
--- 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 639cf56..0000000
--- 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 9f10376..0000000
--- 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 8bfd429..0000000
--- 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 889d626..0000000
--- 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 bfd89f5..0000000
--- 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(&regbuf, 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,
-				       &regbuf, &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, &regbuf,
-					   &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(&regbuf, 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,
-				       &regbuf, &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, &regbuf,
-					   &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(&regbuf, 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,
-				       &regbuf, &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, &regbuf, &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(&regbuf, 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,
-				       &regbuf, &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, &regbuf, &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(&regbuf, 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,
-				       &regbuf, &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(&regbuf, 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,
-				       &regbuf, &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, &regbuf,
-					   (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(&regbuf, 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,
-				       &regbuf, &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, &regbuf,
-					   &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(&regbuf, 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,
-				       &regbuf, &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, &regbuf,
-					   &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(&regbuf, 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, &regbuf, &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(&regbuf, 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, &regbuf, &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, &regbuf, &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(&regbufin, 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,
-				       &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 1)\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
-					    (&regbufin, &regbufout,
-					     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);
-		}
-	}
-
-	/*
-	 * 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
-					    (&regbufin, &regbufout,
-					     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 1b6ab48..0000000
--- 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, &regbuf,
-					   &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, &regbuf,
-					   &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, &regbuf, &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,
-					   &regbuf, &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, &regbuf, &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(&regbuf, 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,
-					   &regbuf,
-					   (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(&regbuf, 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, &regbuf,
-					   &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(&regbuf, 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, &regbuf,
-					   &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(&regbuf, 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,
-					   &regbuf, &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(&regbuf, 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,
-					   &regbuf, &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(&regbuf, 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,
-					   &regbuf, &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 1604f01..0000000
--- 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 95d506c..0000000
--- 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 7fb3e55..0000000
--- 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 dd57160..0000000
--- 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 dd877cb..0000000
--- 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);
-}
diff --git a/testcases/kernel/fs/doio/growfiles.c b/testcases/kernel/fs/doio/growfiles.c
index bbad230..02df1b2 100644
--- a/testcases/kernel/fs/doio/growfiles.c
+++ b/testcases/kernel/fs/doio/growfiles.c
@@ -2756,10 +2756,7 @@
 
 		rd_cnt = 0;
 		while (rd_cnt < fsize) {
-			if (fsize - rd_cnt > MAX_FC_READ)
-				rd_size = MAX_FC_READ;
-			else
-				rd_size = fsize - rd_cnt;
+			rd_size = MIN(MAX_FC_READ, fsize - rd_cnt);
 
 #if NEWIO
 			ret = lio_read_buffer(fd, io_type, buf, rd_size,
diff --git a/testcases/kernel/fs/ftest/ftest01.c b/testcases/kernel/fs/ftest/ftest01.c
index f4fcd60..2dfc92a 100644
--- a/testcases/kernel/fs/ftest/ftest01.c
+++ b/testcases/kernel/fs/ftest/ftest01.c
@@ -52,6 +52,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
diff --git a/testcases/kernel/fs/ftest/ftest05.c b/testcases/kernel/fs/ftest/ftest05.c
index fe3145c..da15c97 100644
--- a/testcases/kernel/fs/ftest/ftest05.c
+++ b/testcases/kernel/fs/ftest/ftest05.c
@@ -61,6 +61,7 @@
 #include <signal.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <sys/param.h>
 #include "test.h"
 #include "libftest.h"
 
diff --git a/testcases/kernel/fs/inode/inode02.c b/testcases/kernel/fs/inode/inode02.c
index 0e42085..78495ec 100644
--- a/testcases/kernel/fs/inode/inode02.c
+++ b/testcases/kernel/fs/inode/inode02.c
@@ -346,10 +346,7 @@
 
 	ch_ret_val = check();
 
-	if (gen_ret_val > ch_ret_val)
-		exit_val = ch_ret_val;
-	else
-		exit_val = gen_ret_val;
+	exit_val = MIN(ch_ret_val, gen_ret_val);
 
 	status = fclose(list_stream);
 	if (status != 0) {
diff --git a/testcases/kernel/fs/iso9660/isofs.sh b/testcases/kernel/fs/iso9660/isofs.sh
index f59bbde..0710303 100755
--- a/testcases/kernel/fs/iso9660/isofs.sh
+++ b/testcases/kernel/fs/iso9660/isofs.sh
@@ -102,6 +102,8 @@
 # Make ISO9660 file system with different options.
 # Mount the ISO9660 file system with different mount options.
 
+tst_check_cmds mkisofs
+
 for mkisofs_opt in \
 	" " \
 	"-J" \
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
index 32a35ad..59c8324 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
@@ -36,6 +36,12 @@
 do_clean()
 {
 	pid_is_valid ${SAR_PID} && kill_pid ${SAR_PID}
+	online_cpu "$CPU_TO_TEST"
+}
+
+get_field()
+{
+	echo "$1" | awk "{print \$$2}"
 }
 
 while getopts c:l:d: OPTION; do
@@ -77,6 +83,8 @@
 
 TST_CLEANUP=do_clean
 
+LOG_FILE="$TMP/log_$$"
+
 until [ $LOOP_COUNT -gt $HOTPLUG05_LOOPS ]; do
 
 	# Start up SAR and give it a couple cycles to run
@@ -86,42 +94,48 @@
 	# after that use "sar 1" instead of. Use 'ps -C sar' to check.
 	if ps -C sar >/dev/null 2>&1; then
 		pkill sar
-		sar -P ALL 1 0 > $TMP/log_$$ &
+		sar -P "$CPU_TO_TEST" 1 0 > "$LOG_FILE" &
 	else
-		sar -P ALL 1 > $TMP/log_$$ &
+		sar -P "$CPU_TO_TEST" 1 > "$LOG_FILE" &
 	fi
 	sleep 2
 	SAR_PID=$!
 
-	# Verify that SAR has correctly listed the missing CPU
-	while ! awk '{print $8}' $TMP/log_$$ | grep -i "^0.00"; do
-		tst_brkm TBROK "CPU${CPU_TO_TEST} Not Found on SAR!"
-	done
-	time=`date +%X`
-	sleep .5
-
-	# Verify that at least some of the CPUs are offline
-	NUMBER_CPU_OFF=$(grep "$time" $TMP/log_$$ | awk '{print $8}' \
-		|grep -i "^0.00" | wc -l)
-	if [ ${NUMBER_CPU_OFF} -eq 0 ]; then
-		tst_brkm TBROK "no CPUs found offline"
+	# Since the CPU is offline, SAR should display all the 6 fields
+	# of CPU statistics as '0.00'
+	offline_status=$(tail -n 1 "$LOG_FILE")
+	if [ -z "$offline_status" ]; then
+		tst_brkm TBROK "SAR output file is empty"
 	fi
 
+	for i in $(seq 3 8); do
+		field=$(get_field "$offline_status" "$i")
+		if [ "$field" != "0.00" ]; then
+			tst_brkm TBROK "Field $i is '$field', '0.00' expected"
+		fi
+	done
+
 	# Online the CPU
 	if ! online_cpu ${CPU_TO_TEST}; then
-		tst_brkm TBROK "CPU${CPU_TO_TEST} cannot be onlined line"
+		tst_brkm TBROK "CPU${CPU_TO_TEST} cannot be onlined"
 	fi
 
 	sleep 2
-	time=$(date +%T)
-	sleep .5
 
 	# Check that SAR registered the change in CPU online/offline states
-	NEW_NUMBER_CPU_OFF=$(grep "$time" $TMP/log_$$|awk '{print $8}' \
-		| grep -i "^0.00"| wc -l)
-	NUMBER_CPU_OFF=$((NUMBER_CPU_OFF-1))
-	if [ "$NUMBER_CPU_OFF" != "$NEW_NUMBER_CPU_OFF" ]; then
-		tst_resm TFAIL "no change in number of offline CPUs was found."
+	online_status=$(tail -n 1 "$LOG_FILE")
+	check_passed=0
+	for i in $(seq 3 8); do
+		field_online=$(get_field "$online_status" "$i")
+
+		if [ "$field_online" != "0.00" ]; then
+			check_passed=1
+			break
+		fi
+	done
+
+	if [ $check_passed -eq 0 ]; then
+		tst_resm TFAIL "No change in the CPU statistics"
 		tst_exit
 	fi
 
@@ -132,6 +146,6 @@
 
 done
 
-tst_resm TPASS "CPU was found after turned on."
+tst_resm TPASS "SAR updated statistics after the CPU was turned on."
 
 tst_exit
diff --git a/testcases/kernel/hotplug/memory_hotplug/segment.c b/testcases/kernel/hotplug/memory_hotplug/segment.c
index c79cf43..62ccd81 100644
--- a/testcases/kernel/hotplug/memory_hotplug/segment.c
+++ b/testcases/kernel/hotplug/memory_hotplug/segment.c
@@ -588,13 +588,13 @@
 		puts(segment_header);
 
 	if (segp->seg_start != MAP_FAILED) {
-		printf("%c 0x%p 0x%012lx 0x%012lx  %s  %s %s\n",
+		printf("%c 0x%p 0x%012zx 0x%012lx  %s  %s %s\n",
 		       seg_type[segp->seg_type],
 		       segp->seg_start,
 		       segp->seg_length,
 		       segp->seg_offset, protection, share, name);
 	} else {
-		printf("%c *** not-mapped *** 0x%012lx 0x%012lx  %s  %s %s\n",
+		printf("%c *** not-mapped *** 0x%012zx 0x%012lx  %s  %s %s\n",
 		       seg_type[segp->seg_type],
 		       segp->seg_length,
 		       segp->seg_offset, protection, share, name);
@@ -943,7 +943,7 @@
 		node = get_node(apage);
 		if (node < 0) {
 			fprintf(stderr, "\n%s:  "
-				"failed to get node for segment %s, offset 0x%lx\n",
+				"failed to get node for segment %s, offset 0x%x\n",
 				gcp->program_name, name, SEG_OFFSET(segp,
 								    apage));
 			return SEG_ERR;
diff --git a/testcases/kernel/include/.gitignore b/testcases/kernel/include/.gitignore
deleted file mode 100644
index dae4c8c..0000000
--- a/testcases/kernel/include/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-linux_syscall_numbers.h
diff --git a/testcases/kernel/include/Makefile b/testcases/kernel/include/Makefile
deleted file mode 100644
index d6e7175..0000000
--- a/testcases/kernel/include/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-#    kernel test suite include Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
-#
-#    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.
-#
-# Ngie Cooper, July 2009
-#
-
-top_srcdir		?= ../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_DIR		:= $(includedir)
-
-MAKE_TARGETS		:= linux_syscall_numbers.h
-
-linux_syscall_numbers.h: $(abs_srcdir)/regen.sh $(wildcard $(abs_srcdir)/*.in)
-	@touch linux_syscall_numbers.h
-	$(SHELL) "$<"
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/direct_io/diotest6.c b/testcases/kernel/io/direct_io/diotest6.c
index 00c2bab..a06e6b8 100644
--- a/testcases/kernel/io/direct_io/diotest6.c
+++ b/testcases/kernel/io/direct_io/diotest6.c
@@ -129,7 +129,7 @@
 		}
 		n = writev(fd_w, iov_w, nvector);
 		if (n < (bufsize * nvector)) {
-			tst_resm(TFAIL | TERRNO, "writev failed, ret = %ld", n);
+			tst_resm(TFAIL | TERRNO, "writev failed, ret = %zd", n);
 			goto err;
 		}
 		if (action == READ_DIRECT) {
@@ -147,7 +147,7 @@
 		}
 		n = readv(fd_r, iov_r, nvector);
 		if (n < (bufsize * nvector)) {
-			tst_resm(TFAIL | TERRNO, "readv failed, ret = %ld", n);
+			tst_resm(TFAIL | TERRNO, "readv failed, ret = %zd", n);
 			goto err;
 		}
 		if (vbufcmp(iov_w, iov_r, nvector) != 0) {
diff --git a/testcases/kernel/ipc/pipeio/pipeio.c b/testcases/kernel/ipc/pipeio/pipeio.c
index 8426fb0..5aa082f 100644
--- a/testcases/kernel/ipc/pipeio/pipeio.c
+++ b/testcases/kernel/ipc/pipeio/pipeio.c
@@ -494,7 +494,7 @@
 	semctl(sem_id, 0, IPC_RMID);
 
 	if (!unpipe)
-		SAFE_UNLINK(NULL, pname);
+		unlink(pname);
 
 	tst_rmdir();
 }
diff --git a/testcases/kernel/lib/numa_helper.c b/testcases/kernel/lib/numa_helper.c
index 7cee703..dd080ee 100644
--- a/testcases/kernel/lib/numa_helper.c
+++ b/testcases/kernel/lib/numa_helper.c
@@ -34,7 +34,7 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "numa_helper.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 unsigned long get_max_node(void)
 {
@@ -65,7 +65,7 @@
 	struct stat st;
 
 	memset(nodemask, 0, nodemask_size);
-	for (i = 0; i < max_node; i++) {
+	for (i = 0; i < (int)max_node; i++) {
 		sprintf(fn, "/sys/devices/system/node/node%d", i);
 		if (stat(fn, &st) == 0)
 			nodemask_set(nodemask, i);
@@ -100,7 +100,7 @@
 	 * old libnuma/kernel don't have MPOL_F_MEMS_ALLOWED, so let's assume
 	 * that we can use any node with memory > 0
 	 */
-	for (i = 0; i < max_node; i++) {
+	for (i = 0; i < (int)max_node; i++) {
 		if (!nodemask_isset(nodemask, i))
 			continue;
 		if (numa_node_size64(i, NULL) <= 0)
@@ -112,7 +112,7 @@
 
 static int cpumask_has_cpus(char *cpumask, size_t len)
 {
-	int j;
+	unsigned int j;
 	for (j = 0; j < len; j++)
 		if (cpumask[j] == '\0')
 			return 0;
@@ -131,7 +131,7 @@
 	size_t len;
 	int i, ret;
 
-	for (i = 0; i < max_node; i++) {
+	for (i = 0; i < (int)max_node; i++) {
 		if (!nodemask_isset(nodemask, i))
 			continue;
 		sprintf(fn, "/sys/devices/system/node/node%d/cpumap", i);
@@ -200,7 +200,7 @@
 		if ((flag & NH_CPUS) == NH_CPUS)
 			filter_nodemask_cpu(nodemask, max_node);
 
-		for (i = 0; i < max_node; i++) {
+		for (i = 0; i < (int)max_node; i++) {
 			if (nodemask_isset(nodemask, i)) {
 				if (nodes)
 					(*nodes)[*num_nodes] = i;
diff --git a/testcases/kernel/logging/kmsg/kmsg01.c b/testcases/kernel/logging/kmsg/kmsg01.c
index 5fd3e8b..b207045 100644
--- a/testcases/kernel/logging/kmsg/kmsg01.c
+++ b/testcases/kernel/logging/kmsg/kmsg01.c
@@ -43,9 +43,8 @@
 #include <string.h>
 #include <unistd.h>
 #include "config.h"
-#include "test.h"
-#include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
+#include "lapi/syscalls.h"
 
 #define MSG_PREFIX "LTP kmsg01 "
 #define MAX_MSGSIZE 4096
@@ -54,9 +53,6 @@
 #define NUM_OVERWRITE_MSGS 1024
 #define READ_TIMEOUT 5
 
-char *TCID = "kmsg01";
-static void setup(void);
-static void cleanup(void);
 
 /*
  * inject_msg - write message to /dev/kmsg
@@ -71,9 +67,9 @@
 	int f;
 	f = open("/dev/kmsg", O_WRONLY);
 	if (f < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "failed to open /dev/kmsg");
+		tst_brk(TBROK | TERRNO, "failed to open /dev/kmsg");
 	TEST(write(f, msg, strlen(msg)));
-	SAFE_CLOSE(cleanup, f);
+	SAFE_CLOSE(f);
 	errno = TEST_ERRNO;
 	return TEST_RETURN;
 }
@@ -99,7 +95,7 @@
 	if (fd < 0) {
 		f = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
 		if (f < 0)
-			tst_brkm(TBROK, cleanup, "failed to open /dev/kmsg");
+			tst_brk(TBROK, "failed to open /dev/kmsg");
 	} else {
 		f = fd;
 	}
@@ -114,8 +110,7 @@
 				/* current message was overwritten */
 				continue;
 			else
-				tst_brkm(TBROK|TTERRNO, cleanup,
-					"failed to read /dev/kmsg");
+				tst_brk(TBROK|TTERRNO, "err reading /dev/kmsg");
 		} else if (TEST_RETURN < bufsize) {
 			/* lines from kmsg are not NULL terminated */
 			msg[TEST_RETURN] = '\0';
@@ -128,7 +123,7 @@
 		}
 	}
 	if (fd < 0)
-		SAFE_CLOSE(cleanup, f);
+		SAFE_CLOSE(f);
 
 	if (msg_found)
 		return 0;
@@ -175,7 +170,7 @@
 	ret = select(fd + 1, &read_fds, 0, 0, &timeout);
 	switch (ret) {
 	case -1:
-		tst_brkm(TBROK|TERRNO, cleanup, "select failed");
+		tst_brk(TBROK|TERRNO, "select failed");
 	case 0:
 		/* select timed out */
 		return -2;
@@ -203,19 +198,19 @@
 	char msg[MAX_MSGSIZE];
 
 	if (pipe(pipefd) != 0)
-		tst_brkm(TBROK|TERRNO, cleanup, "pipe failed");
+		tst_brk(TBROK|TERRNO, "pipe failed");
 
 	child = fork();
 	switch (child) {
 	case -1:
-		tst_brkm(TBROK|TERRNO, cleanup, "failed to fork");
+		tst_brk(TBROK|TERRNO, "failed to fork");
 	case 0:
 		/* child does all the reading and keeps writing to
 		 * pipe to let parent know that it didn't block */
 		close(pipefd[0]);
 		while (1) {
 			if (write(pipefd[1], "", 1) == -1)
-				tst_brkm(TBROK|TERRNO, NULL, "write to pipe");
+				tst_brk(TBROK|TERRNO, "write to pipe");
 			TEST(read(fd, msg, MAX_MSGSIZE));
 			if (TEST_RETURN == 0)
 				break;
@@ -228,19 +223,19 @@
 		close(pipefd[1]);
 		exit(ret);
 	}
-	SAFE_CLOSE(cleanup, pipefd[1]);
+	SAFE_CLOSE(pipefd[1]);
 
 	/* parent reads pipe until it reaches eof or until read times out */
 	do {
 		TEST(timed_read(pipefd[0], timeout_sec));
 	} while (TEST_RETURN > 0);
-	SAFE_CLOSE(cleanup, pipefd[0]);
+	SAFE_CLOSE(pipefd[0]);
 
 	/* child is blocked, kill it */
 	if (TEST_RETURN == -2)
 		kill(child, SIGTERM);
 	if (waitpid(child, &status, 0) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+		tst_brk(TBROK | TERRNO, "waitpid");
 	if (WIFEXITED(status)) {
 		if (WEXITSTATUS(status) == 0) {
 			return 0;
@@ -256,35 +251,35 @@
 {
 	int fd;
 
-	tst_resm(TINFO, "TEST: nonblock read");
+	tst_res(TINFO, "TEST: nonblock read");
 	fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
 	if (fd < 0)
-		tst_brkm(TBROK|TERRNO, cleanup, "failed to open /dev/kmsg");
+		tst_brk(TBROK|TERRNO, "failed to open /dev/kmsg");
 
 	TEST(timed_read_kmsg(fd, READ_TIMEOUT));
 	if (TEST_RETURN == -1 && TEST_ERRNO == EAGAIN)
-		tst_resm(TPASS, "non-block read returned EAGAIN");
+		tst_res(TPASS, "non-block read returned EAGAIN");
 	else
-		tst_resm(TFAIL|TTERRNO, "non-block read returned: %ld",
+		tst_res(TFAIL|TTERRNO, "non-block read returned: %ld",
 			TEST_RETURN);
-	SAFE_CLOSE(cleanup, fd);
+	SAFE_CLOSE(fd);
 }
 
 static void test_read_block(void)
 {
 	int fd;
 
-	tst_resm(TINFO, "TEST: blocking read");
+	tst_res(TINFO, "TEST: blocking read");
 	fd = open("/dev/kmsg", O_RDONLY);
 	if (fd < 0)
-		tst_brkm(TBROK|TERRNO, cleanup, "failed to open /dev/kmsg");
+		tst_brk(TBROK|TERRNO, "failed to open /dev/kmsg");
 
 	TEST(timed_read_kmsg(fd, READ_TIMEOUT));
 	if (TEST_RETURN == -2)
-		tst_resm(TPASS, "read blocked");
+		tst_res(TPASS, "read blocked");
 	else
-		tst_resm(TFAIL|TTERRNO, "read returned: %ld", TEST_RETURN);
-	SAFE_CLOSE(cleanup, fd);
+		tst_res(TFAIL|TTERRNO, "read returned: %ld", TEST_RETURN);
+	SAFE_CLOSE(fd);
 }
 
 static void test_partial_read(void)
@@ -292,17 +287,17 @@
 	char msg[MAX_MSGSIZE];
 	int fd;
 
-	tst_resm(TINFO, "TEST: partial read");
+	tst_res(TINFO, "TEST: partial read");
 	fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
 	if (fd < 0)
-		tst_brkm(TBROK|TERRNO, cleanup, "failed to open /dev/kmsg");
+		tst_brk(TBROK|TERRNO, "failed to open /dev/kmsg");
 
 	TEST(read(fd, msg, 1));
 	if (TEST_RETURN < 0)
-		tst_resm(TPASS|TTERRNO, "read failed as expected");
+		tst_res(TPASS|TTERRNO, "read failed as expected");
 	else
-		tst_resm(TFAIL, "read returned: %ld", TEST_RETURN);
-	SAFE_CLOSE(cleanup, fd);
+		tst_res(TFAIL, "read returned: %ld", TEST_RETURN);
+	SAFE_CLOSE(fd);
 }
 
 static void test_inject(void)
@@ -312,8 +307,9 @@
 	unsigned long prefix, seqno, seqno_last = 0;
 	int i, facility, prio;
 
-	tst_resm(TINFO, "TEST: injected messages appear in /dev/kmsg");
+	tst_res(TINFO, "TEST: injected messages appear in /dev/kmsg");
 
+	srand(time(NULL));
 	/* test all combinations of prio 0-7, facility 0-15 */
 	for (i = 0; i < 127; i++) {
 		prio = (i & 7);
@@ -323,23 +319,23 @@
 		sprintf(imsg_prefixed, "<%d>%s", i, imsg);
 
 		if (inject_msg(imsg_prefixed) == -1) {
-			tst_resm(TFAIL|TERRNO, "inject failed");
+			tst_res(TFAIL|TERRNO, "inject failed");
 			return;
 		}
 
 		/* check that message appears in log */
 		if (find_msg(-1, imsg, tmp, sizeof(tmp), 0) == -1) {
-			tst_resm(TFAIL, "failed to find: %s", imsg);
+			tst_res(TFAIL, "failed to find: %s", imsg);
 			return;
 		}
 
 		/* check that facility is not 0 (LOG_KERN). */
 		if (get_msg_fields(tmp, &prefix, &seqno) != 0) {
-			tst_resm(TFAIL, "failed to parse seqid: %s", tmp);
+			tst_res(TFAIL, "failed to parse seqid: %s", tmp);
 			return;
 		}
 		if (prefix >> 3 == 0) {
-			tst_resm(TFAIL, "facility 0 found: %s", tmp);
+			tst_res(TFAIL, "facility 0 found: %s", tmp);
 			return;
 		}
 
@@ -347,14 +343,14 @@
 		if (seqno > seqno_last) {
 			seqno_last = seqno;
 		} else {
-			tst_resm(TFAIL, "seqno doesn't grow: %lu, "
+			tst_res(TFAIL, "seqno doesn't grow: %lu, "
 				"last: %lu", seqno, seqno_last);
 			return;
 		}
 	}
 
-	tst_resm(TPASS, "injected messages found in log");
-	tst_resm(TPASS, "sequence numbers grow as expected");
+	tst_res(TPASS, "injected messages found in log");
+	tst_res(TPASS, "sequence numbers grow as expected");
 }
 
 static void test_read_returns_first_message(void)
@@ -368,30 +364,29 @@
 	 * If this read fails with EPIPE, first message was overwritten and
 	 * we should retry the whole test. If it still fails after
 	 * NUM_READ_RETRY attempts, report TWARN */
-	tst_resm(TINFO, "TEST: mult. readers will get same first message");
+	tst_res(TINFO, "TEST: mult. readers will get same first message");
 	while (j) {
 		fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
 		if (fd < 0)
-			tst_brkm(TBROK|TERRNO, cleanup,
-				"failed to open /dev/kmsg");
+			tst_brk(TBROK|TERRNO, "failed to open /dev/kmsg");
 
 		for (i = 0; i < NUM_READ_MSGS; i++) {
 			if (find_msg(-1, "", msg, sizeof(msg), 1) != 0)
-				tst_resm(TFAIL, "failed to find any message");
+				tst_res(TFAIL, "failed to find any message");
 			if (get_msg_fields(msg, NULL, &seqno[i]) != 0)
-				tst_resm(TFAIL, "failed to parse seqid: %s",
+				tst_res(TFAIL, "failed to parse seqid: %s",
 					msg);
 		}
 
 		TEST(read(fd, msg, sizeof(msg)));
-		SAFE_CLOSE(cleanup, fd);
+		SAFE_CLOSE(fd);
 		if (TEST_RETURN != -1)
 			break;
 
 		if (TEST_ERRNO == EPIPE)
-			tst_resm(TINFO, "msg overwritten, retrying");
+			tst_res(TINFO, "msg overwritten, retrying");
 		else
-			tst_resm(TFAIL|TTERRNO, "read failed");
+			tst_res(TFAIL|TTERRNO, "read failed");
 
 		/* give a moment to whoever overwrote first message to finish */
 		usleep(100000);
@@ -399,7 +394,7 @@
 	}
 
 	if (!j) {
-		tst_resm(TWARN, "exceeded: %d attempts", NUM_READ_RETRY);
+		tst_res(TWARN, "exceeded: %d attempts", NUM_READ_RETRY);
 		return;
 	}
 
@@ -407,11 +402,11 @@
 		if (seqno[i] != seqno[i + 1])
 			msgs_match = 0;
 	if (msgs_match) {
-		tst_resm(TPASS, "all readers got same message on first read");
+		tst_res(TPASS, "all readers got same message on first read");
 	} else {
-		tst_resm(TFAIL, "readers got different messages");
+		tst_res(TFAIL, "readers got different messages");
 		for (i = 0; i < NUM_READ_MSGS; i++)
-			tst_resm(TINFO, "msg%d: %lu\n", i, seqno[i]);
+			tst_res(TINFO, "msg%d: %lu\n", i, seqno[i]);
 	}
 }
 
@@ -424,53 +419,52 @@
 
 	/* Keep injecting messages until we overwrite first one.
 	 * We know first message is overwritten when its seqno changes */
-	tst_resm(TINFO, "TEST: read returns EPIPE when messages get "
+	tst_res(TINFO, "TEST: read returns EPIPE when messages get "
 		"overwritten");
 	fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
 	if (fd < 0)
-		tst_brkm(TBROK|TERRNO, cleanup, "failed to open /dev/kmsg");
+		tst_brk(TBROK|TERRNO, "failed to open /dev/kmsg");
 
 	if (find_msg(-1, "", msg, sizeof(msg), 1) == 0
 		&& get_msg_fields(msg, NULL, &first_seqno) == 0) {
-		tst_resm(TINFO, "first seqno: %lu", first_seqno);
+		tst_res(TINFO, "first seqno: %lu", first_seqno);
 	} else {
-		tst_brkm(TBROK, cleanup, "failed to get first seq. number");
+		tst_brk(TBROK, "failed to get first seq. number");
 	}
 
 	while (1) {
 		if (find_msg(-1, "", msg, sizeof(msg), 1) != 0
 				|| get_msg_fields(msg, NULL, &seqno) != 0) {
-			tst_resm(TFAIL, "failed to get first seq. number");
+			tst_res(TFAIL, "failed to get first seq. number");
 			break;
 		}
 		if (first_seqno != seqno) {
 			/* first message was overwritten */
-			tst_resm(TINFO, "first seqno now: %lu", seqno);
+			tst_res(TINFO, "first seqno now: %lu", seqno);
 			break;
 		}
 		for (i = 0; i < NUM_OVERWRITE_MSGS; i++) {
 			if (inject_msg(filler_str) == -1)
-				tst_brkm(TBROK|TERRNO, cleanup,
-					"failed write to /dev/kmsg");
+				tst_brk(TBROK|TERRNO, "err write to /dev/kmsg");
 		}
 	}
 
 	/* first message is overwritten, so this next read should fail */
 	TEST(read(fd, msg, sizeof(msg)));
 	if (TEST_RETURN == -1 && TEST_ERRNO == EPIPE)
-		tst_resm(TPASS, "read failed with EPIPE as expected");
+		tst_res(TPASS, "read failed with EPIPE as expected");
 	else
-		tst_resm(TFAIL|TTERRNO, "read returned: %ld", TEST_RETURN);
+		tst_res(TFAIL|TTERRNO, "read returned: %ld", TEST_RETURN);
 
 	/* seek position is updated to the next available record */
-	tst_resm(TINFO, "TEST: Subsequent reads() will return available "
+	tst_res(TINFO, "TEST: Subsequent reads() will return available "
 		"records again");
 	if (find_msg(fd, "", msg, sizeof(msg), 1) != 0)
-		tst_resm(TFAIL|TTERRNO, "read returned: %ld", TEST_RETURN);
+		tst_res(TFAIL|TTERRNO, "read returned: %ld", TEST_RETURN);
 	else
-		tst_resm(TPASS, "after EPIPE read returned next record");
+		tst_res(TPASS, "after EPIPE read returned next record");
 
-	SAFE_CLOSE(cleanup, fd);
+	SAFE_CLOSE(fd);
 }
 
 static int read_msg_seqno(int fd, unsigned long *seqno)
@@ -478,16 +472,14 @@
 	char msg[MAX_MSGSIZE];
 
 	TEST(read(fd, msg, sizeof(msg)));
-	if (TEST_RETURN == -1 && TEST_ERRNO != EPIPE) {
-		tst_brkm(TBROK|TTERRNO, cleanup,
-			"failed to read /dev/kmsg");
-	}
+	if (TEST_RETURN == -1 && TEST_ERRNO != EPIPE)
+		tst_brk(TBROK|TTERRNO, "failed to read /dev/kmsg");
 
 	if (TEST_ERRNO == EPIPE)
 		return -1;
 
 	if (get_msg_fields(msg, NULL, seqno) != 0) {
-		tst_resm(TFAIL, "failed to parse seqid: %s", msg);
+		tst_res(TFAIL, "failed to parse seqid: %s", msg);
 		return -1;
 	}
 
@@ -502,7 +494,7 @@
 	int ret = 0;
 
 	/* 1. read() after SEEK_SET 0 returns same (first) message */
-	tst_resm(TINFO, "TEST: seek SEEK_SET 0");
+	tst_res(TINFO, "TEST: seek SEEK_SET 0");
 
 	for (j = 0; j < NUM_READ_RETRY && !ret; j++) {
 		/*
@@ -520,14 +512,14 @@
 		 * first entry in buffer got overwritten. If so,
 		 * we'll have to repeat the test.
 		 */
-		fd = SAFE_OPEN(cleanup, "/dev/kmsg", O_RDONLY | O_NONBLOCK);
-		fd2 = SAFE_OPEN(cleanup, "/dev/kmsg", O_RDONLY | O_NONBLOCK);
+		fd = SAFE_OPEN("/dev/kmsg", O_RDONLY | O_NONBLOCK);
+		fd2 = SAFE_OPEN("/dev/kmsg", O_RDONLY | O_NONBLOCK);
 
 		if (read_msg_seqno(fd, &seqno[0]))
 			goto close_fds;
 
 		if (lseek(fd, 0, SEEK_SET) == -1) {
-			tst_resm(TFAIL|TERRNO, "SEEK_SET 0 failed");
+			tst_res(TFAIL|TERRNO, "SEEK_SET 0 failed");
 			ret = -1;
 			goto close_fds;
 		}
@@ -540,79 +532,62 @@
 
 		ret = 1;
 close_fds:
-		SAFE_CLOSE(cleanup, fd);
-		SAFE_CLOSE(cleanup, fd2);
+		SAFE_CLOSE(fd);
+		SAFE_CLOSE(fd2);
 	}
 
 	if (j == NUM_READ_RETRY) {
-		tst_resm(TWARN, "exceeded: %d attempts", NUM_READ_RETRY);
+		tst_res(TWARN, "exceeded: %d attempts", NUM_READ_RETRY);
 	} else if (ret > 0) {
 		if (seqno[0] != seqno[1]) {
-			tst_resm(TFAIL, "SEEK_SET 0, %lu != %lu",
+			tst_res(TFAIL, "SEEK_SET 0, %lu != %lu",
 				seqno[0], seqno[1]);
 		} else {
-			tst_resm(TPASS, "SEEK_SET 0");
+			tst_res(TPASS, "SEEK_SET 0");
 		}
 	}
 
 	/* 2. messages after SEEK_END 0 shouldn't contain MSG_PREFIX */
-	fd = SAFE_OPEN(cleanup, "/dev/kmsg", O_RDONLY | O_NONBLOCK);
-	tst_resm(TINFO, "TEST: seek SEEK_END 0");
+	fd = SAFE_OPEN("/dev/kmsg", O_RDONLY | O_NONBLOCK);
+	tst_res(TINFO, "TEST: seek SEEK_END 0");
 	if (lseek(fd, 0, SEEK_END) == -1)
-		tst_resm(TFAIL|TERRNO, "lseek SEEK_END 0 failed");
+		tst_res(TFAIL|TERRNO, "lseek SEEK_END 0 failed");
 	if (find_msg(fd, MSG_PREFIX, msg, sizeof(msg), 0) != 0)
-		tst_resm(TPASS, "SEEK_END 0");
+		tst_res(TPASS, "SEEK_END 0");
 	else
-		tst_resm(TFAIL, "SEEK_END 0 found: %s", msg);
+		tst_res(TFAIL, "SEEK_END 0 found: %s", msg);
 
 #ifdef SEEK_DATA
 	/* 3. messages after SEEK_DATA 0 shouldn't contain MSG_PREFIX */
-	tst_resm(TINFO, "TEST: seek SEEK_DATA 0");
+	tst_res(TINFO, "TEST: seek SEEK_DATA 0");
 
 	/* clear ring buffer */
-	if (ltp_syscall(__NR_syslog, 5, NULL, 0) == -1)
-		tst_brkm(TBROK|TERRNO, cleanup, "syslog clear failed");
+	if (tst_syscall(__NR_syslog, 5, NULL, 0) == -1)
+		tst_brk(TBROK|TERRNO, "syslog clear failed");
 	if (lseek(fd, 0, SEEK_DATA) == -1)
-		tst_resm(TFAIL|TERRNO, "lseek SEEK_DATA 0 failed");
+		tst_res(TFAIL|TERRNO, "lseek SEEK_DATA 0 failed");
 	if (find_msg(fd, MSG_PREFIX, msg, sizeof(msg), 0) != 0)
-		tst_resm(TPASS, "SEEK_DATA 0");
+		tst_res(TPASS, "SEEK_DATA 0");
 	else
-		tst_resm(TFAIL, "SEEK_DATA 0 found: %s", msg);
+		tst_res(TFAIL, "SEEK_DATA 0 found: %s", msg);
 #endif
-	SAFE_CLOSE(cleanup, fd);
+	SAFE_CLOSE(fd);
 }
 
-int main(int argc, char *argv[])
+static void test_kmsg(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* run test_inject first so log isn't empty for other tests */
-		test_inject();
-		test_read_nonblock();
-		test_read_block();
-		test_partial_read();
-		test_read_returns_first_message();
-		test_messages_overwritten();
-		test_seek();
-	}
-	cleanup();
-	tst_exit();
+	/* run test_inject first so log isn't empty for other tests */
+	test_inject();
+	test_read_nonblock();
+	test_read_block();
+	test_partial_read();
+	test_read_returns_first_message();
+	test_messages_overwritten();
+	test_seek();
 }
 
-static void setup(void)
-{
-	tst_require_root();
-	if (tst_kvercmp(3, 5, 0) < 0)
-		tst_brkm(TCONF, NULL, "This test requires kernel"
-			" >= 3.5.0");
-	srand(getpid());
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.test_all = test_kmsg,
+	.min_kver = "3.5.0"
+};
diff --git a/testcases/kernel/mem/.gitignore b/testcases/kernel/mem/.gitignore
index 5170119..ce21ca7 100644
--- a/testcases/kernel/mem/.gitignore
+++ b/testcases/kernel/mem/.gitignore
@@ -72,5 +72,6 @@
 /vma/vma02
 /vma/vma03
 /vma/vma04
+/vma/vma05_vdso
 /vmtests/data_space
 /vmtests/stack_space
diff --git a/testcases/kernel/mem/cpuset/cpuset01.c b/testcases/kernel/mem/cpuset/cpuset01.c
index 558420f..e10124c 100644
--- a/testcases/kernel/mem/cpuset/cpuset01.c
+++ b/testcases/kernel/mem/cpuset/cpuset01.c
@@ -1,4 +1,16 @@
 /*
+ * Copyright (C) 2010-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
  * Out Of Memory when changing cpuset's mems on NUMA. There was a
  * problem reported upstream that the allocator may see an empty
  * nodemask when changing cpuset's mems.
@@ -6,55 +18,18 @@
  * http://lkml.org/lkml/2010/5/4/79
  * http://lkml.org/lkml/2010/5/4/80
  * This test is based on the reproducers for the above issue.
- *
- * Copyright (C) 2010  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
  */
+
 #include "config.h"
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
+#include <stdio.h>
 #include <sys/wait.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <math.h>
 #if HAVE_NUMAIF_H
 #include <numaif.h>
 #endif
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
 
-#include "test.h"
 #include "mem.h"
 #include "numa_helper.h"
 
-char *TCID = "cpuset01";
-int TST_TOTAL = 1;
-
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 volatile int end;
@@ -62,32 +37,13 @@
 static int nnodes;
 static long ncpus;
 
-static void testcpuset(void);
 static void sighandler(int signo LTP_ATTRIBUTE_UNUSED);
 static int mem_hog(void);
 static int mem_hog_cpuset(int ntasks);
 static long count_cpu(void);
 
-int main(int argc, char *argv[])
+static void test_cpuset(void)
 {
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	ncpus = count_cpu();
-	if (get_allowed_nodes_arr(NH_MEMS | NH_CPUS, &nnodes, &nodes) < 0)
-		tst_brkm(TBROK | TERRNO, NULL, "get_allowed_nodes_arr");
-	if (nnodes <= 1)
-		tst_brkm(TCONF, NULL, "requires a NUMA system.");
-
-	setup();
-	testcpuset();
-	cleanup();
-	tst_exit();
-}
-
-static void testcpuset(void)
-{
-	int lc;
 	int child, i, status;
 	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
 	char mems[BUFSIZ], buf[BUFSIZ];
@@ -96,49 +52,46 @@
 	write_cpuset_files(CPATH_NEW, "cpus", buf);
 	read_cpuset_files(CPATH, "mems", mems);
 	write_cpuset_files(CPATH_NEW, "mems", mems);
-	SAFE_FILE_PRINTF(cleanup, CPATH_NEW "/tasks", "%d", getpid());
+	SAFE_FILE_PRINTF(CPATH_NEW "/tasks", "%d", getpid());
 
-	switch (child = fork()) {
-	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
-	case 0:
+	child = SAFE_FORK();
+	if (child == 0) {
 		for (i = 0; i < nnodes; i++) {
 			if (nodes[i] >= MAXNODES)
 				continue;
 			set_node(nmask, nodes[i]);
 		}
 		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "set_mempolicy");
+			tst_brk(TBROK | TERRNO, "set_mempolicy");
 		exit(mem_hog_cpuset(ncpus > 1 ? ncpus : 1));
 	}
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		snprintf(buf, BUFSIZ, "%d", nodes[0]);
-		write_cpuset_files(CPATH_NEW, "mems", buf);
-		snprintf(buf, BUFSIZ, "%d", nodes[1]);
-		write_cpuset_files(CPATH_NEW, "mems", buf);
-	}
+
+	snprintf(buf, BUFSIZ, "%d", nodes[0]);
+	write_cpuset_files(CPATH_NEW, "mems", buf);
+	snprintf(buf, BUFSIZ, "%d", nodes[1]);
+	write_cpuset_files(CPATH_NEW, "mems", buf);
 
 	if (waitpid(child, &status, WUNTRACED | WCONTINUED) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
-	if (WEXITSTATUS(status) != 0)
-		tst_resm(TFAIL, "child exit status is %d", WEXITSTATUS(status));
+		tst_brk(TBROK | TERRNO, "waitpid");
+	if (WEXITSTATUS(status) != 0) {
+		tst_res(TFAIL, "child exit status is %d", WEXITSTATUS(status));
+		return;
+	}
+
+	tst_res(TPASS, "cpuset test pass");
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-
-	if (tst_kvercmp(2, 6, 32) < 0)
-		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
 	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
+	ncpus = count_cpu();
+	if (get_allowed_nodes_arr(NH_MEMS | NH_CPUS, &nnodes, &nodes) < 0)
+		tst_brk(TBROK | TERRNO, "get_allowed_nodes_arr");
+	if (nnodes <= 1)
+		tst_brk(TCONF, "requires a NUMA system.");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	umount_mem(CPATH, CPATH_NEW);
 }
@@ -156,41 +109,34 @@
 
 	pagesize = getpagesize();
 	while (!end) {
-		addr = mmap(NULL, pagesize * 10, PROT_READ | PROT_WRITE,
+		addr = SAFE_MMAP(NULL, pagesize * 10, PROT_READ | PROT_WRITE,
 			    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-		if (addr == MAP_FAILED) {
-			ret = 1;
-			tst_resm(TFAIL | TERRNO, "mmap");
-			break;
-		}
 		memset(addr, 0xF7, pagesize * 10);
-		munmap(addr, pagesize * 10);
+		SAFE_MUNMAP(addr, pagesize * 10);
 	}
 	return ret;
 }
 
 static int mem_hog_cpuset(int ntasks)
 {
-	int i, lc, status, ret = 0;
+	int i, status, ret = 0;
 	struct sigaction sa;
 	pid_t *pids;
 
 	if (ntasks <= 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "ntasks is small.");
+		tst_brk(TBROK | TERRNO, "ntasks is small.");
 	sa.sa_handler = sighandler;
 	if (sigemptyset(&sa.sa_mask) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "sigemptyset");
+		tst_brk(TBROK | TERRNO, "sigemptyset");
 	sa.sa_flags = 0;
 	if (sigaction(SIGUSR1, &sa, NULL) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "sigaction");
+		tst_brk(TBROK | TERRNO, "sigaction");
 
-	pids = malloc(sizeof(pid_t) * ntasks);
-	if (pids == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "malloc");
+	pids = SAFE_MALLOC(sizeof(pid_t) * ntasks);
 	for (i = 0; i < ntasks; i++) {
 		switch (pids[i] = fork()) {
 		case -1:
-			tst_resm(TFAIL | TERRNO, "fork %d", pids[i]);
+			tst_res(TFAIL | TERRNO, "fork %d", pids[i]);
 			ret = 1;
 			break;
 		case 0:
@@ -200,22 +146,22 @@
 			break;
 		}
 	}
-	for (lc = 0; TEST_LOOPING(lc); lc++) ;
+
 	while (i--) {
 		if (kill(pids[i], SIGUSR1) == -1) {
-			tst_resm(TFAIL | TERRNO, "kill %d", pids[i]);
+			tst_res(TFAIL | TERRNO, "kill %d", pids[i]);
 			ret = 1;
 		}
 	}
 	while (waitpid(-1, &status, WUNTRACED | WCONTINUED) > 0) {
 		if (WIFEXITED(status)) {
 			if (WEXITSTATUS(status) != 0) {
-				tst_resm(TFAIL, "child exit status is %d",
+				tst_res(TFAIL, "child exit status is %d",
 					 WEXITSTATUS(status));
 				ret = 1;
 			}
 		} else if (WIFSIGNALED(status)) {
-			tst_resm(TFAIL, "child caught signal %d",
+			tst_res(TFAIL, "child caught signal %d",
 				 WTERMSIG(status));
 			ret = 1;
 		}
@@ -233,9 +179,14 @@
 	return ncpus;
 }
 
+static struct tst_test test = {
+	.needs_root = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_cpuset,
+	.min_kver = "2.6.32",
+};
+
 #else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
index da8bdb1..d56fbfa 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
@@ -1,20 +1,16 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
@@ -27,143 +23,86 @@
  *  mmap() should succeed returning the address of the hugetlb mapped region.
  *  The number of free huge pages should decrease.
  *
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Pause for SIGUSR1 if option specified.
- *   Create temporary directory.
- *
  * Test:
  *  Loop if the proper options are given.
  *  Execute system call
  *  Check return code, if system call failed (return=-1)
  *  Log the errno and Issue a FAIL message.
- * Cleanup:
- *  Print timing stats if options given
- *  Delete the temporary directory created.
  *
  * HISTORY
  *  04/2004 Written by Robbie Williamson
  */
 
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
 
-#include "test.h"
-#include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
+#include "hugetlb.h"
 
-static char TEMPFILE[MAXPATHLEN];
+static struct tst_option options[] = {
+	{"H:", &Hopt,   "-H   /..  Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
+	{NULL, NULL, NULL}
+};
 
-char *TCID = "hugemmap01";
-int TST_TOTAL = 1;
 static long *addr;
-static int fildes;
-static char *Hopt;
+static int  fildes;
 static long beforetest;
 static long aftertest;
 static long hugepagesmapped;
 static long hugepages = 128;
+static char TEMPFILE[MAXPATHLEN];
 
-static void help(void);
-
-int main(int ac, char **av)
+static void test_hugemmap(void)
 {
-	int lc;
-	int Hflag = 0;
 	long page_sz = 0;
-	int sflag = 0;
 
-	option_t options[] = {
-		{"H:", &Hflag, &Hopt},
-		{"s:", &sflag, &nr_opt},
-		{NULL, NULL, NULL}
-	};
+	fildes = SAFE_OPEN(TEMPFILE, O_RDWR | O_CREAT, 0666);
 
-	tst_parse_opts(ac, av, options, &help);
+	beforetest = SAFE_READ_MEMINFO("HugePages_Free:");
 
-	if (!Hflag) {
-		tst_tmpdir();
-		Hopt = tst_get_tmpdir();
-	}
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
+	page_sz = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
-	setup();
+	addr = mmap(NULL, page_sz, PROT_READ | PROT_WRITE,
+			MAP_SHARED, fildes, 0);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* Creat a temporary file used for mapping */
-		fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666);
-		if (fildes < 0)
-			tst_brkm(TFAIL | TERRNO, cleanup, "open %s failed",
-				 TEMPFILE);
+	if (addr == MAP_FAILED) {
+		tst_res(TFAIL | TERRNO, "mmap() Failed on %s",
+				TEMPFILE);
+	} else {
+		tst_res(TPASS, "call succeeded");
 
-		tst_count = 0;
-
-		/* Note the number of free huge pages BEFORE testing */
-		beforetest = read_meminfo("HugePages_Free:");
-
-		/* Note the size of huge page size BEFORE testing */
-		page_sz = read_meminfo("Hugepagesize:") * 1024;
-
-		addr = mmap(NULL, page_sz, PROT_READ | PROT_WRITE,
-			    MAP_SHARED, fildes, 0);
-		if (addr == MAP_FAILED) {
-			tst_resm(TFAIL | TERRNO, "mmap() Failed on %s",
-				 TEMPFILE);
-			close(fildes);
-			continue;
-		} else {
-			close(fildes);
-			tst_resm(TPASS, "call succeeded");
-			/* force to allocate page and change HugePages_Free */
-			*(int *)addr = 0;
-		}
-
-		/*
-		 * Make sure the number of free huge pages
-		 * AFTER testing decreased
-		 */
-		aftertest = read_meminfo("HugePages_Free:");
+		/* force to allocate page and change HugePages_Free */
+		*(int *)addr = 0;
+		/* Make sure the number of free huge pages AFTER testing decreased */
+		aftertest = SAFE_READ_MEMINFO("HugePages_Free:");
 		hugepagesmapped = beforetest - aftertest;
 		if (hugepagesmapped < 1)
-			tst_resm(TWARN, "Number of HUGEPAGES_FREE stayed the"
-				 " same. Okay if multiple copies running due"
-				 " to test collision.");
-
-		/* Clean up things in case we are looping */
-		/* Unmap the mapped memory */
-		if (munmap(addr, page_sz) != 0)
-			tst_brkm(TFAIL | TERRNO, NULL, "munmap failed");
-
-		close(fildes);
+			tst_res(TWARN, "Number of HUGEPAGES_FREE stayed the"
+					" same. Okay if multiple copies running due"
+					" to test collision.");
+		munmap(addr, page_sz);
 	}
 
-	cleanup();
-	tst_exit();
+	close(fildes);
 }
 
 void setup(void)
 {
-	TEST_PAUSE;
-	tst_require_root();
 	check_hugepage();
-	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
-		tst_brkm(TBROK | TERRNO, NULL, "mount failed on %s", Hopt);
-
 	orig_hugepages = get_sys_tune("nr_hugepages");
+
+	if (!Hopt)
+		Hopt = tst_get_tmpdir();
+	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
+		tst_brk(TBROK | TERRNO, "mount failed on %s", Hopt);
+
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 	set_sys_tune("nr_hugepages", hugepages, 1);
+
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
 }
 
@@ -173,11 +112,13 @@
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
 
 	umount(Hopt);
-	tst_rmdir();
 }
 
-static void help(void)
-{
-	printf("    -H /..  Location of hugetlbfs, i.e. -H /var/hugetlbfs\n");
-	printf("    -s num  Set the number of the been allocated hugepages\n");
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugemmap,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
index d31609d..8614248 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
@@ -1,20 +1,16 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
@@ -39,181 +35,136 @@
  *  04/2004 Written by Robbie Williamson
  */
 
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
 
-#include "test.h"
-#include "safe_macros.h"
 #include "mem.h"
 #include "hugetlb.h"
 
 #define LOW_ADDR       0x80000000
 #define LOW_ADDR2      0x90000000
 
+static struct tst_option options[] = {
+	{"H:", &Hopt,   "-H   /..  Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
+	{NULL, NULL, NULL}
+};
+
 static char TEMPFILE[MAXPATHLEN];
 
-char *TCID = "hugemmap02";
-int TST_TOTAL = 1;
 static unsigned long *addr;
 static unsigned long *addr2;
 static unsigned long low_addr = LOW_ADDR;
 static unsigned long low_addr2 = LOW_ADDR2;
 static unsigned long *addrlist[5];
-static int i;
 static int fildes;
 static int nfildes;
-static char *Hopt;
 static long hugepages = 128;
 
-static void help(void);
-
-int main(int ac, char **av)
+static void test_hugemmap(void)
 {
-	int lc;
-	int Hflag = 0;
+	int i;
 	long page_sz, map_sz;
-	int sflag = 0;
-
-	option_t options[] = {
-		{"H:", &Hflag, &Hopt},
-		{"s:", &sflag, &nr_opt},
-		{NULL, NULL, NULL}
-	};
-
-	tst_parse_opts(ac, av, options, &help);
-
-	check_hugepage();
-
-	if (!Hflag) {
-		tst_tmpdir();
-		Hopt = tst_get_tmpdir();
-	}
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
 
 	page_sz = getpagesize();
-	map_sz = read_meminfo("Hugepagesize:") * 1024 * 2;
+	map_sz = SAFE_READ_MEMINFO("Hugepagesize:") * 1024 * 2;
 
-	setup();
+	fildes = SAFE_OPEN(TEMPFILE, O_RDWR | O_CREAT, 0666);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* Creat a temporary file used for huge mapping */
-		fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666);
-		if (fildes < 0)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "opening %s failed", TEMPFILE);
+	nfildes = SAFE_OPEN("/dev/zero", O_RDONLY, 0666);
 
-		/* Creat a file used for normal mapping */
-		nfildes = open("/dev/zero", O_RDONLY, 0666);
-		if (nfildes < 0)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "opening /dev/zero failed");
-
-		tst_count = 0;
-
-		/*
-		 * Call mmap on /dev/zero 5 times
-		 */
-		for (i = 0; i < 5; i++) {
-			addr = mmap(0, 256 * 1024 * 1024, PROT_READ,
-				    MAP_SHARED, nfildes, 0);
-			addrlist[i] = addr;
-		}
-
-		while (range_is_mapped(cleanup, low_addr, low_addr + map_sz) == 1) {
-			low_addr = low_addr + 0x10000000;
-
-			if (low_addr < LOW_ADDR)
-				tst_brkm(TBROK | TERRNO, cleanup,
-						"no empty region to use");
-		}
-		/* mmap using normal pages and a low memory address */
-		addr = mmap((void *)low_addr, page_sz, PROT_READ,
-			    MAP_SHARED | MAP_FIXED, nfildes, 0);
-		if (addr == MAP_FAILED)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "mmap failed on nfildes");
-
-		while (range_is_mapped(cleanup, low_addr2, low_addr2 + map_sz) == 1) {
-			low_addr2 = low_addr2 + 0x10000000;
-
-			if (low_addr2 < LOW_ADDR2)
-				tst_brkm(TBROK | TERRNO, cleanup,
-						"no empty region to use");
-		}
-		/* Attempt to mmap a huge page into a low memory address */
-		addr2 = mmap((void *)low_addr2, map_sz, PROT_READ | PROT_WRITE,
-			     MAP_SHARED, fildes, 0);
-#if __WORDSIZE == 64		/* 64-bit process */
-		if (addr2 == MAP_FAILED) {
-			tst_resm(TFAIL | TERRNO, "huge mmap failed unexpectedly"
-				 " with %s (64-bit)", TEMPFILE);
-		} else {
-			tst_resm(TPASS, "huge mmap succeeded (64-bit)");
-		}
-#else /* 32-bit process */
-		if (addr2 == MAP_FAILED)
-			tst_resm(TFAIL | TERRNO, "huge mmap failed unexpectedly"
-				 " with %s (32-bit)", TEMPFILE);
-		else if (addr2 > 0) {
-			tst_resm(TCONF,
-				 "huge mmap failed to test the scenario");
-		} else if (addr == 0)
-			tst_resm(TPASS, "huge mmap succeeded (32-bit)");
-#endif
-
-		/* Clean up things in case we are looping */
-		for (i = 0; i < 5; i++) {
-			if (munmap(addrlist[i], 256 * 1024 * 1024) == -1)
-				tst_resm(TBROK | TERRNO,
-					 "munmap of addrlist[%d] failed", i);
-		}
-
-		if (munmap(addr2, map_sz) == -1)
-			tst_brkm(TFAIL | TERRNO, NULL, "huge munmap failed");
-		if (munmap(addr, page_sz) == -1)
-			tst_brkm(TFAIL | TERRNO, NULL, "munmap failed");
-
-		close(nfildes);
-		close(fildes);
+	for (i = 0; i < 5; i++) {
+		addr = mmap(0, 256 * 1024 * 1024, PROT_READ,
+				MAP_SHARED, nfildes, 0);
+		addrlist[i] = addr;
 	}
 
-	cleanup();
-	tst_exit();
+	while (range_is_mapped(low_addr, low_addr + map_sz) == 1) {
+		low_addr = low_addr + 0x10000000;
+
+		if (low_addr < LOW_ADDR)
+			tst_brk(TBROK | TERRNO, "no empty region to use");
+	}
+	/* mmap using normal pages and a low memory address */
+	addr = mmap((void *)low_addr, page_sz, PROT_READ,
+			MAP_SHARED | MAP_FIXED, nfildes, 0);
+	if (addr == MAP_FAILED)
+		tst_brk(TBROK | TERRNO, "mmap failed on nfildes");
+
+	while (range_is_mapped(low_addr2, low_addr2 + map_sz) == 1) {
+		low_addr2 = low_addr2 + 0x10000000;
+
+		if (low_addr2 < LOW_ADDR2)
+			tst_brk(TBROK | TERRNO, "no empty region to use");
+	}
+	/* Attempt to mmap a huge page into a low memory address */
+	addr2 = mmap((void *)low_addr2, map_sz, PROT_READ | PROT_WRITE,
+			MAP_SHARED, fildes, 0);
+#if __WORDSIZE == 64 /* 64-bit process */
+	if (addr2 == MAP_FAILED) {
+		tst_res(TFAIL | TERRNO, "huge mmap failed unexpectedly"
+				" with %s (64-bit)", TEMPFILE);
+	} else {
+		tst_res(TPASS, "huge mmap succeeded (64-bit)");
+	}
+#else /* 32-bit process */
+	if (addr2 == MAP_FAILED)
+		tst_res(TFAIL | TERRNO, "huge mmap failed unexpectedly"
+				" with %s (32-bit)", TEMPFILE);
+	else if (addr2 > 0) {
+		tst_res(TCONF,
+				"huge mmap failed to test the scenario");
+	} else if (addr == 0)
+		tst_res(TPASS, "huge mmap succeeded (32-bit)");
+#endif
+
+	for (i = 0; i < 5; i++) {
+		if (munmap(addrlist[i], 256 * 1024 * 1024) == -1)
+			tst_res(TFAIL | TERRNO,
+					"munmap of addrlist[%d] failed", i);
+	}
+
+	if (munmap(addr2, map_sz) == -1)
+		tst_res(TFAIL | TERRNO, "huge munmap failed");
+	if (munmap(addr, page_sz) == -1)
+		tst_res(TFAIL | TERRNO, "munmap failed");
+
+	close(nfildes);
+	close(fildes);
 }
 
-void setup(void)
+static void setup(void)
 {
-	TEST_PAUSE;
-	tst_require_root();
-	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
-		tst_brkm(TBROK | TERRNO, NULL, "mount failed on %s", Hopt);
+	check_hugepage();
 	orig_hugepages = get_sys_tune("nr_hugepages");
+
+	if (!Hopt)
+		Hopt = tst_get_tmpdir();
+	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
+		tst_brk(TBROK | TERRNO, "mount failed on %s", Hopt);
+
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 	set_sys_tune("nr_hugepages", hugepages, 1);
+
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	unlink(TEMPFILE);
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
 
 	umount(Hopt);
-	tst_rmdir();
 }
 
-static void help(void)
-{
-	printf("  -H /..  Location of hugetlbfs, i.e. -H /var/hugetlbfs\n");
-	printf("  -s num  Set the number of the been allocated hugepages\n");
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugemmap,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
index e1f2986..f6d51a5 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
@@ -1,20 +1,16 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
@@ -28,47 +24,32 @@
  *  mmap() should succeed returning the address of the hugetlb mapped region.
  *  The number of free huge pages should decrease.
  *
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Pause for SIGUSR1 if option specified.
- *   Create temporary directory.
- *
  * Test:
  *  Loop if the proper options are given.
  *  Execute system call
  *  Check return code, if system call failed (return=-1)
  *  Log the errno and Issue a FAIL message.
- * Cleanup:
- *  Print timing stats if options given
- *  Delete the temporary directory created.
  *
  * HISTORY
  *  04/2004 Written by Robbie Williamson
  */
 
-#include <sys/types.h>
-#include <sys/mman.h>
 #include <sys/mount.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <limits.h>
+#include <sys/param.h>
 
-#include "test.h"
-#include "safe_macros.h"
 #include "mem.h"
 #include "hugetlb.h"
 
+static struct tst_option options[] = {
+	{"H:", &Hopt,   "-H   /..  Location of hugetlbfs, i.e.  -H /var/hugetlbfs"},
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
+	{NULL, NULL, NULL}
+};
+
 static char TEMPFILE[MAXPATHLEN];
 
-char *TCID = "hugemmap04";
-int TST_TOTAL = 1;
 static long *addr;
 static long long mapsize;
 static int fildes;
@@ -77,108 +58,68 @@
 static long aftertest;
 static long hugepagesmapped;
 static long hugepages = 128;
-static char *Hopt;
 
-static void help(void);
-
-int main(int ac, char **av)
+static void test_hugemmap(void)
 {
-	int lc;
-	int Hflag = 0;
-	int sflag = 0;
 	int huge_pagesize = 0;
 
-	option_t options[] = {
-		{"H:", &Hflag, &Hopt},
-		{"s:", &sflag, &nr_opt},
-		{NULL, NULL, NULL}
-	};
+	/* Creat a temporary file used for huge mapping */
+	fildes = SAFE_OPEN(TEMPFILE, O_RDWR | O_CREAT, 0666);
 
-	tst_parse_opts(ac, av, options, &help);
+	freepages = SAFE_READ_MEMINFO("HugePages_Free:");
+	beforetest = freepages;
 
-	if (!Hflag) {
-		tst_tmpdir();
-		Hopt = tst_get_tmpdir();
-	}
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* Creat a temporary file used for huge mapping */
-		fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666);
-		if (fildes < 0)
-			tst_brkm(TFAIL | TERRNO, cleanup, "open %s failed",
-				 TEMPFILE);
-
-		tst_count = 0;
-
-		/* Note the number of free huge pages BEFORE testing */
-		freepages = read_meminfo("HugePages_Free:");
-		beforetest = freepages;
-
-		/* Note the size of huge page size BEFORE testing */
-		huge_pagesize = read_meminfo("Hugepagesize:");
-		tst_resm(TINFO, "Size of huge pages is %d KB", huge_pagesize);
+	huge_pagesize = SAFE_READ_MEMINFO("Hugepagesize:");
+	tst_res(TINFO, "Size of huge pages is %d KB", huge_pagesize);
 
 #if __WORDSIZE == 32
-		tst_resm(TINFO, "Total amount of free huge pages is %d",
-			 freepages);
-		tst_resm(TINFO, "Max number allowed for 1 mmap file in"
-			 " 32-bits is 128");
-		if (freepages > 128)
-			freepages = 128;
+	tst_res(TINFO, "Total amount of free huge pages is %d",
+			freepages);
+	tst_res(TINFO, "Max number allowed for 1 mmap file in"
+			" 32-bits is 128");
+	if (freepages > 128)
+		freepages = 128;
 #endif
-		mapsize = (long long)freepages *huge_pagesize * 1024;
-		addr = mmap(NULL, mapsize, PROT_READ | PROT_WRITE,
-			    MAP_SHARED, fildes, 0);
-		sleep(2);
-		if (addr == MAP_FAILED) {
-			tst_resm(TFAIL | TERRNO, "mmap() Failed on %s",
-				 TEMPFILE);
-			close(fildes);
-			continue;
-		} else {
-			tst_resm(TPASS,
-				 "Succeeded mapping file using %ld pages",
-				 freepages);
-			/* force to allocate page and change HugePages_Free */
-			*(int *)addr = 0;
-		}
+	mapsize = (long long)freepages * huge_pagesize * 1024;
+	addr = mmap(NULL, mapsize, PROT_READ | PROT_WRITE,
+			MAP_SHARED, fildes, 0);
+	if (addr == MAP_FAILED) {
+		tst_res(TFAIL | TERRNO, "mmap() Failed on %s",
+				TEMPFILE);
+	} else {
+		tst_res(TPASS,
+				"Succeeded mapping file using %ld pages",
+				freepages);
 
-		/*
-		 * Make sure the number of free huge pages
-		 * AFTER testing decreased
-		 */
-		aftertest = read_meminfo("HugePages_Free:");
+		/* force to allocate page and change HugePages_Free */
+		*(int *)addr = 0;
+		/* Make sure the number of free huge pages AFTER testing decreased */
+		aftertest = SAFE_READ_MEMINFO("HugePages_Free:");
 		hugepagesmapped = beforetest - aftertest;
 		if (hugepagesmapped < 1)
-			tst_resm(TWARN, "Number of HUGEPAGES_FREE stayed the"
-				 " same. Okay if multiple copies running due"
-				 " to test collision.");
-
-		/* Clean up things in case we are looping */
-		/* Unmap the mapped memory */
-		if (munmap(addr, mapsize) != 0)
-			tst_brkm(TFAIL | TERRNO, NULL, "munmap failed");
-
-		close(fildes);
+			tst_res(TWARN, "Number of HUGEPAGES_FREE stayed the"
+					" same. Okay if multiple copies running due"
+					" to test collision.");
 	}
 
-	cleanup();
-	tst_exit();
+	munmap(addr, mapsize);
+	close(fildes);
 }
 
 void setup(void)
 {
-	TEST_PAUSE;
-	tst_require_root();
 	check_hugepage();
-	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
-		tst_brkm(TBROK | TERRNO, NULL, "mount failed on %s", Hopt);
 	orig_hugepages = get_sys_tune("nr_hugepages");
+
+	if (!Hopt)
+		Hopt = tst_get_tmpdir();
+	if (mount("none", Hopt, "hugetlbfs", 0, NULL) < 0)
+		tst_brk(TBROK | TERRNO, "mount failed on %s", Hopt);
+
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 	set_sys_tune("nr_hugepages", hugepages, 1);
+
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", Hopt, getpid());
 }
 
@@ -188,10 +129,13 @@
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
 
 	umount(Hopt);
-	tst_rmdir();
 }
 
-static void help(void)
-{
-	printf("  -H /..  Location of hugetlbfs, i.e. -H /var/hugetlbfs\n");
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugemmap,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c
index b127566..c73a975 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c
@@ -1,6 +1,19 @@
 /*
+ * Copyright (C) 2010-2017  Red Hat, Inc.
+ *
+ * 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.
  * overcommit hugetlbfs and check the statistics.
  *
+ * Description:
+ *
  * hugetlbfs allows to overcommit hugepages and there are tunables in
  * sysfs and procfs. The test here want to ensure it is possible to
  * overcommit by either mmap or shared memory. Also ensure those
@@ -11,54 +24,25 @@
  * Finally, it reads and writes every page. There are command options to
  * choose either to manage hugepages from sysfs or procfs, and reserve
  * them by mmap or shmget.
- *
- * Copyright (C) 2010  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
  */
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/mount.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
+
 #include <string.h>
-#include <ctype.h>
-#include "test.h"
+#include <unistd.h>
+#include <stdio.h>
+#include "mem.h"
 #include "hugetlb.h"
+#include "tst_safe_sysv_ipc.h"
+#include "tst_test.h"
 
 #define PROTECTION		(PROT_READ | PROT_WRITE)
 #define PATH_MEMINFO		"/proc/meminfo"
 
-char path_sys_sz[BUFSIZ];
-char path_sys_sz_over[BUFSIZ];
-char path_sys_sz_free[BUFSIZ];
-char path_sys_sz_resv[BUFSIZ];
-char path_sys_sz_surp[BUFSIZ];
-char path_sys_sz_huge[BUFSIZ];
+static char path_sys_sz[BUFSIZ];
+static char path_sys_sz_over[BUFSIZ];
+static char path_sys_sz_free[BUFSIZ];
+static char path_sys_sz_resv[BUFSIZ];
+static char path_sys_sz_surp[BUFSIZ];
+static char path_sys_sz_huge[BUFSIZ];
 
 #define PATH_PROC_VM		"/proc/sys/vm/"
 #define PATH_PROC_OVER		PATH_PROC_VM "nr_overcommit_hugepages"
@@ -80,419 +64,249 @@
 #define SHM_HUGETLB 04000
 #endif
 
-char *TCID = "hugemmap05";
-int TST_TOTAL = 1, tst_count;
-static char nr_hugepages[BUFSIZ], nr_overcommit_hugepages[BUFSIZ];
-static char buf[BUFSIZ], line[BUFSIZ], path[BUFSIZ], pathover[BUFSIZ];
-static char shmmax[BUFSIZ];
-static char *opt_allocstr;
-static int hugepagesize;	/* in Bytes */
-static int opt_sysfs, opt_alloc;
-static int shmid = -1;
-static int restore_shmmax;
-static size_t size = 128, length = 384;
-static option_t options[] = {
-	{"s", &opt_sysfs, NULL},
-	{"m", &shmid, NULL},
-	{"a:", &opt_alloc, &opt_allocstr},
+#define MOUNT_DIR "hugemmap05"
+#define TEST_FILE MOUNT_DIR "/file"
+
+static unsigned long long shmmax;
+static char *path, *pathover;
+static int key = -1, shmid = -1, fd = -1;
+static int mounted, restore_shmmax, restore_nr_hgpgs, restore_overcomm_hgpgs;
+static long hugepagesize, nr_hugepages, nr_overcommit_hugepages;
+static long size = 128, length = 384;
+
+char *opt_sysfs;
+char *opt_alloc;
+char *opt_shmid;
+static struct tst_option options[] = {
+	{"s",  &opt_sysfs, "-s        Setup hugepages from sysfs"},
+	{"m",  &opt_shmid, "-m        Reserve hugepages by shmget"},
+	{"a:", &opt_alloc, "-a        Number of overcommint hugepages"},
 	{NULL, NULL, NULL}
 };
 
-static void setup(void);
-static void cleanup(void);
-static void overcommit(void);
-static void write_bytes(void *addr);
-static void read_bytes(void *addr);
-static int lookup(char *line, char *pattern);
-static void usage(void);
-static int checkproc(FILE * fp, char *string, int value);
-static int checksys(char *path, char *pattern, int value);
-static void init_hugepagesize(void);
+static void check_wr_bytes(void *addr);
+static int checkproc(long act_val, char *string, long exp_val);
+static int checksys(char *path, char *pattern, long exp_val);
 static void init_sys_sz_paths(void);
 
-int main(int argc, char *argv[])
-{
-	int lc;
-
-	init_hugepagesize();
-	init_sys_sz_paths();
-
-	tst_parse_opts(argc, argv, options, usage);
-	if (opt_sysfs) {
-		strncpy(path, path_sys_sz_huge, strlen(path_sys_sz_huge) + 1);
-		strncpy(pathover, path_sys_sz_over,
-			strlen(path_sys_sz_over) + 1);
-	} else {
-		strncpy(path, PATH_PROC_HUGE, strlen(PATH_PROC_HUGE) + 1);
-		strncpy(pathover, PATH_PROC_OVER, strlen(PATH_PROC_OVER) + 1);
-	}
-	if (opt_alloc) {
-		size = atoi(opt_allocstr);
-		length = (int)(size + size * 0.5) * 2;
-	}
-	setup();
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		overcommit();
-	}
-	cleanup();
-	tst_exit();
-}
-
-static void overcommit(void)
+static void test_overcommit(void)
 {
 	void *addr = NULL, *shmaddr = NULL;
-	int fd = -1, key = -1;
-	char s[BUFSIZ];
-	FILE *fp;
 
-	if (shmid != -1) {
-		/* Use /proc/meminfo to generate an IPC key. */
-		key = ftok(PATH_MEMINFO, strlen(PATH_MEMINFO));
-		if (key == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "ftok");
-		shmid = shmget(key, (long)(length / 2 * hugepagesize),
-			       SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W);
-		if (shmid == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "shmget");
+	if (opt_shmid) {
+		shmid = SAFE_SHMGET(key, (length / 2 * hugepagesize),
+				 SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W);
 	} else {
-		/* XXX (garrcoop): memory leak. */
-		snprintf(s, BUFSIZ, "%s/hugemmap05/file", tst_get_tmpdir());
-		fd = open(s, O_CREAT | O_RDWR, 0755);
-		if (fd == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "open");
-		addr = mmap(ADDR, (long)(length / 2 * hugepagesize), PROTECTION,
-			    FLAGS, fd, 0);
-		if (addr == MAP_FAILED) {
-			close(fd);
-			tst_brkm(TBROK | TERRNO, cleanup, "mmap");
-		}
+		fd = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR, 0755);
+		addr = SAFE_MMAP(ADDR, (length / 2 * hugepagesize),
+				 PROTECTION, FLAGS, fd, 0);
 	}
 
 	if (opt_sysfs) {
-		tst_resm(TINFO, "check sysfs before allocation.");
-		if (checksys(path_sys_sz_huge, "HugePages_Total",
-			     length / 2) != 0)
+		tst_res(TINFO, "check sysfs before allocation.");
+		if (checksys(path_sys_sz_huge, "HugePages_Total", length / 2))
 			return;
-		if (checksys(path_sys_sz_free, "HugePages_Free",
-			     length / 2) != 0)
+		if (checksys(path_sys_sz_free, "HugePages_Free", length / 2))
 			return;
 		if (checksys(path_sys_sz_surp, "HugePages_Surp",
-			     length / 2 - size) != 0)
+			     length / 2 - size))
 			return;
-		if (checksys(path_sys_sz_resv, "HugePages_Rsvd",
-			     length / 2) != 0)
+		if (checksys(path_sys_sz_resv, "HugePages_Rsvd", length / 2))
 			return;
 	} else {
-		tst_resm(TINFO, "check /proc/meminfo before allocation.");
-		fp = fopen(PATH_MEMINFO, "r");
-		if (fp == NULL)
-			tst_brkm(TBROK | TERRNO, cleanup, "fopen");
-		if (checkproc(fp, "HugePages_Total", length / 2) != 0)
+		tst_res(TINFO, "check /proc/meminfo before allocation.");
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Total:"),
+			      "HugePages_Total", length / 2))
 			return;
-		if (checkproc(fp, "HugePages_Free", length / 2) != 0)
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Free:"),
+			      "HugePages_Free", length / 2))
 			return;
-		if (checkproc(fp, "HugePages_Surp", length / 2 - size) != 0)
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Surp:"),
+			      "HugePages_Surp", length / 2 - size))
 			return;
-		if (checkproc(fp, "HugePages_Rsvd", length / 2) != 0)
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Rsvd:"),
+			      "HugePages_Rsvd", length / 2))
 			return;
-		fclose(fp);
 	}
-	if (shmid != -1) {
-		tst_resm(TINFO, "shmid: 0x%x", shmid);
-		shmaddr = shmat(shmid, ADDR, SHMAT_FLAGS);
-		if (shmaddr == (void *)-1)
-			tst_brkm(TBROK | TERRNO, cleanup, "shmat");
-		write_bytes(shmaddr);
-		read_bytes(shmaddr);
+
+	if (opt_shmid) {
+		tst_res(TINFO, "shmid: 0x%x", shmid);
+		shmaddr = SAFE_SHMAT(shmid, ADDR, SHMAT_FLAGS);
+		check_wr_bytes(shmaddr);
 	} else {
-		write_bytes(addr);
-		read_bytes(addr);
+		check_wr_bytes(addr);
 	}
+
 	if (opt_sysfs) {
-		tst_resm(TINFO, "check sysfs.");
-		if (checksys(path_sys_sz_huge, "HugePages_Total",
-			     length / 2) != 0)
+		tst_res(TINFO, "check sysfs.");
+		if (checksys(path_sys_sz_huge, "HugePages_Total", length / 2))
 			return;
-		if (checksys(path_sys_sz_free, "HugePages_Free", 0)
-		    != 0)
+		if (checksys(path_sys_sz_free, "HugePages_Free", 0))
 			return;
 		if (checksys(path_sys_sz_surp, "HugePages_Surp",
-			     length / 2 - size) != 0)
+			     length / 2 - size))
 			return;
-		if (checksys(path_sys_sz_resv, "HugePages_Rsvd", 0)
-		    != 0)
+		if (checksys(path_sys_sz_resv, "HugePages_Rsvd", 0))
 			return;
 	} else {
-		tst_resm(TINFO, "check /proc/meminfo.");
-		fp = fopen(PATH_MEMINFO, "r");
-		if (fp == NULL)
-			tst_brkm(TBROK | TERRNO, cleanup, "fopen");
-		if (checkproc(fp, "HugePages_Total", length / 2) != 0)
+		tst_res(TINFO, "check /proc/meminfo.");
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Total:"),
+			      "HugePages_Total", length / 2))
 			return;
-		if (checkproc(fp, "HugePages_Free", 0) != 0)
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Free:"),
+			      "HugePages_Free", 0))
 			return;
-		if (checkproc(fp, "HugePages_Surp", length / 2 - size) != 0)
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Surp:"),
+			      "HugePages_Surp", length / 2 - size))
 			return;
-		if (checkproc(fp, "HugePages_Rsvd", 0) != 0)
+		if (checkproc(SAFE_READ_MEMINFO("HugePages_Rsvd:"),
+			      "HugePages_Rsvd", 0))
 			return;
-		fclose(fp);
 	}
-	if (shmid != -1) {
-		if (shmdt(shmaddr) != 0)
-			tst_brkm(TBROK | TERRNO, cleanup, "shmdt");
+
+	if (opt_shmid) {
+		SAFE_SHMDT(shmaddr);
+		SAFE_SHMCTL(shmid, IPC_RMID, NULL);
 	} else {
-		munmap(addr, (long)(length / 2 * hugepagesize));
-		close(fd);
-		unlink(s);
+		SAFE_MUNMAP(addr, (length / 2 * hugepagesize));
+		SAFE_CLOSE(fd);
+		SAFE_UNLINK(TEST_FILE);
 	}
+
+	tst_res(TPASS, "hugepages overcommit test pass");
 }
 
 static void cleanup(void)
 {
-	int fd;
+	if (opt_shmid && shmid != -1)
+		SAFE_SHMCTL(shmid, IPC_RMID, NULL);
 
-	if (restore_shmmax) {
-		fd = open(PATH_SHMMAX, O_WRONLY);
-		if (fd == -1)
-			tst_resm(TWARN | TERRNO, "open");
-		if (write(fd, shmmax, strlen(shmmax)) != (ssize_t)strlen(shmmax))
-			tst_resm(TWARN | TERRNO, "write");
-		close(fd);
+	if (!opt_shmid && fd != -1) {
+		SAFE_CLOSE(fd);
+		SAFE_UNLINK(TEST_FILE);
 	}
-	fd = open(path, O_WRONLY);
-	if (fd == -1)
-		tst_resm(TWARN | TERRNO, "open");
-	tst_resm(TINFO, "restore nr_hugepages to %s.", nr_hugepages);
-	if (write(fd, nr_hugepages,
-		  strlen(nr_hugepages)) != (ssize_t)strlen(nr_hugepages))
-		tst_resm(TWARN | TERRNO, "write");
-	close(fd);
 
-	fd = open(pathover, O_WRONLY);
-	if (fd == -1)
-		tst_resm(TWARN | TERRNO, "open");
-	tst_resm(TINFO, "restore nr_overcommit_hugepages to %s.",
-		 nr_overcommit_hugepages);
-	if (write(fd, nr_overcommit_hugepages, strlen(nr_overcommit_hugepages))
-	    != (ssize_t)strlen(nr_overcommit_hugepages))
-		tst_resm(TWARN | TERRNO, "write");
-	close(fd);
+	if (mounted)
+		tst_umount(MOUNT_DIR);
 
-	/* XXX (garrcoop): memory leak. */
-	snprintf(buf, BUFSIZ, "%s/hugemmap05", tst_get_tmpdir());
-	if (umount(buf) == -1)
-		tst_resm(TWARN | TERRNO, "umount");
-	if (shmid != -1) {
-		tst_resm(TINFO, "shmdt cleaning");
-		shmctl(shmid, IPC_RMID, NULL);
+	if (restore_nr_hgpgs) {
+		tst_res(TINFO, "restore nr_hugepages to %ld.", nr_hugepages);
+		SAFE_FILE_PRINTF(path, "%ld", nr_hugepages);
 	}
-	tst_rmdir();
+
+	if (restore_shmmax)
+		SAFE_FILE_PRINTF(PATH_SHMMAX, "%llu", shmmax);
+
+	if (restore_overcomm_hgpgs) {
+		tst_res(TINFO, "restore nr_overcommit_hugepages to %ld.",
+			nr_overcommit_hugepages);
+		SAFE_FILE_PRINTF(pathover, "%ld", nr_overcommit_hugepages);
+	}
 }
 
 static void setup(void)
 {
-	FILE *fp;
-	int fd;
-	struct stat stat_buf;
-
-	tst_require_root();
-
-	if (stat(pathover, &stat_buf) == -1) {
-		if (errno == ENOENT || errno == ENOTDIR)
-			tst_brkm(TCONF, NULL,
-				 "file %s does not exist in the system",
-				 pathover);
-	}
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-	tst_tmpdir();
-
-	if (shmid != -1) {
-		fp = fopen(PATH_SHMMAX, "r");
-		if (fp == NULL)
-			tst_brkm(TBROK | TERRNO, cleanup, "fopen");
-		if (fgets(shmmax, BUFSIZ, fp) == NULL)
-			tst_brkm(TBROK | TERRNO, cleanup, "fgets");
-		fclose(fp);
-
-		if (atol(shmmax) < (long)(length / 2 * hugepagesize)) {
-			restore_shmmax = 1;
-			fd = open(PATH_SHMMAX, O_RDWR);
-			if (fd == -1)
-				tst_brkm(TBROK | TERRNO, cleanup, "open");
-			snprintf(buf, BUFSIZ, "%ld",
-				 (long)(length / 2 * hugepagesize));
-			if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "failed to change shmmax.");
-		}
-	}
-	fp = fopen(path, "r+");
-	if (fp == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fopen");
-	if (fgets(nr_hugepages, BUFSIZ, fp) == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fgets");
-	fclose(fp);
-	/* Remove trailing newline. */
-	nr_hugepages[strlen(nr_hugepages) - 1] = '\0';
-	tst_resm(TINFO, "original nr_hugepages is %s", nr_hugepages);
-
-	fd = open(path, O_RDWR);
-	if (fd == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "open");
-	/* Reset. */
-	if (write(fd, "0", 1) != 1)
-		tst_brkm(TBROK | TERRNO, cleanup, "write");
-	if (lseek(fd, 0, SEEK_SET) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "lseek");
-	snprintf(buf, BUFSIZ, "%zd", size);
-	if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "failed to change nr_hugepages.");
-	close(fd);
-
-	fp = fopen(pathover, "r+");
-	if (fp == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fopen");
-	if (fgets(nr_overcommit_hugepages, BUFSIZ, fp) == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fgets");
-	fclose(fp);
-	nr_overcommit_hugepages[strlen(nr_overcommit_hugepages) - 1] = '\0';
-	tst_resm(TINFO, "original nr_overcommit_hugepages is %s",
-		 nr_overcommit_hugepages);
-
-	fd = open(pathover, O_RDWR);
-	if (fd == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "open");
-	/* Reset. */
-	if (write(fd, "0", 1) != 1)
-		tst_brkm(TBROK | TERRNO, cleanup, "write");
-	if (lseek(fd, 0, SEEK_SET) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "lseek");
-	snprintf(buf, BUFSIZ, "%zd", size);
-	if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "failed to change nr_hugepages.");
-	close(fd);
-
-	/* XXX (garrcoop): memory leak. */
-	snprintf(buf, BUFSIZ, "%s/hugemmap05", tst_get_tmpdir());
-	if (mkdir(buf, 0700) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "mkdir");
-	if (mount(NULL, buf, "hugetlbfs", 0, NULL) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "mount");
-}
-
-static void write_bytes(void *addr)
-{
-	long i;
-
-	for (i = 0; i < (long)(length / 2 * hugepagesize); i++)
-		((char *)addr)[i] = '\a';
-}
-
-static void read_bytes(void *addr)
-{
-	long i;
-
-	tst_resm(TINFO, "First hex is %x", *((unsigned int *)addr));
-	for (i = 0; i < (long)(length / 2 * hugepagesize); i++) {
-		if (((char *)addr)[i] != '\a') {
-			tst_resm(TFAIL, "mismatch at %ld", i);
-			break;
-		}
-	}
-}
-
-/* Lookup a pattern and get the value from file */
-static int lookup(char *line, char *pattern)
-{
-	char buf2[BUFSIZ];
-
-	/* empty line */
-	if (line[0] == '\0')
-		return 0;
-
-	snprintf(buf2, BUFSIZ, "%s: %%s", pattern);
-	if (sscanf(line, buf2, buf) != 1)
-		return 0;
-
-	return 1;
-}
-
-static void usage(void)
-{
-	printf("  -s      Setup hugepages from sysfs\n");
-	printf("  -m      Reserve hugepages by shmget\n");
-	printf("  -a      Number of overcommint hugepages\n");
-}
-
-static int checksys(char *path, char *string, int value)
-{
-	FILE *fp;
-
-	fp = fopen(path, "r");
-	if (fp == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fopen");
-	if (fgets(buf, BUFSIZ, fp) == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fgets");
-	tst_resm(TINFO, "%s is %d.", string, atoi(buf));
-	if (atoi(buf) != value) {
-		tst_resm(TFAIL, "%s is not %d but %d.", string, value,
-			 atoi(buf));
-		fclose(fp);
-		return 1;
-	}
-	fclose(fp);
-	return 0;
-}
-
-static int checkproc(FILE * fp, char *pattern, int value)
-{
-	memset(buf, -1, BUFSIZ);
-	rewind(fp);
-	while (fgets(line, BUFSIZ, fp) != NULL)
-		if (lookup(line, pattern))
-			break;
-
-	tst_resm(TINFO, "%s is %d.", pattern, atoi(buf));
-	if (atoi(buf) != value) {
-		tst_resm(TFAIL, "%s is not %d but %d.", pattern, value,
-			 atoi(buf));
-		return 1;
-	}
-	return 0;
-}
-
-static void init_hugepagesize(void)
-{
-	FILE *fp;
-
+	hugepagesize = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 	check_hugepage();
-	memset(buf, -1, BUFSIZ);
-	fp = fopen(PATH_MEMINFO, "r");
-	if (fp == NULL)
-		tst_brkm(TBROK, NULL, "can't open %s", PATH_MEMINFO);
-	while (fgets(line, BUFSIZ, fp) != NULL) {
-		if (lookup(line, "Hugepagesize")) {
-			tst_resm(TINFO, "Hugepagesize is %s kB", buf);
-			hugepagesize = atoi(buf) * 1024;
-			fclose(fp);
-			return;
+	init_sys_sz_paths();
+
+	if (opt_sysfs) {
+		path = path_sys_sz_huge;
+		pathover = path_sys_sz_over;
+	} else {
+		path = PATH_PROC_HUGE;
+		pathover = PATH_PROC_OVER;
+	}
+
+	if (opt_alloc) {
+		size = atoi(opt_alloc);
+		length = (size + size * 0.5) * 2;
+	}
+
+	if (opt_shmid) {
+		SAFE_FILE_SCANF(PATH_SHMMAX, "%llu", &shmmax);
+		if (shmmax < (unsigned long long)(length / 2 * hugepagesize)) {
+			restore_shmmax = 1;
+			SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld",
+					(length / 2 * hugepagesize));
 		}
 	}
-	tst_brkm(TBROK, NULL, "get Hugepagesize failed.");
+
+	SAFE_FILE_SCANF(path, "%ld", &nr_hugepages);
+	tst_res(TINFO, "original nr_hugepages is %ld", nr_hugepages);
+
+	/* Reset. */
+	SAFE_FILE_PRINTF(path, "%ld", size);
+	restore_nr_hgpgs = 1;
+
+	if (access(pathover, F_OK)) {
+		tst_brk(TCONF, "file %s does not exist in the system",
+			pathover);
+	}
+
+	SAFE_FILE_SCANF(pathover, "%ld", &nr_overcommit_hugepages);
+	tst_res(TINFO, "original nr_overcommit_hugepages is %ld",
+		nr_overcommit_hugepages);
+
+	/* Reset. */
+	SAFE_FILE_PRINTF(pathover, "%ld", size);
+	restore_overcomm_hgpgs = 1;
+
+	SAFE_MKDIR(MOUNT_DIR, 0700);
+	SAFE_MOUNT(NULL, MOUNT_DIR, "hugetlbfs", 0, NULL);
+	mounted = 1;
+
+	if (opt_shmid) {
+		/* Use /proc/meminfo to generate an IPC key. */
+		key = ftok(PATH_MEMINFO, strlen(PATH_MEMINFO));
+		if (key == -1)
+			tst_brk(TBROK | TERRNO, "ftok");
+	}
 }
 
-/*
- * It's not easy to #define tunable file paths via sysfs,
- * use function init_hugepagesize and global variable instead.
- */
+static void check_wr_bytes(void *addr)
+{
+	long i;
+
+	memset((char *)addr, '\a', (length / 2 * hugepagesize));
+
+	tst_res(TINFO, "First hex is %x", *((unsigned int *)addr));
+	for (i = 0; i < (length / 2 * hugepagesize); i++) {
+		if (((char *)addr)[i] != '\a') {
+			tst_res(TFAIL, "mismatch at %ld", i);
+			break;
+		}
+	}
+}
+
+static int checksys(char *path, char *string, long exp_val)
+{
+	long act_val;
+
+	SAFE_FILE_SCANF(path, "%ld", &act_val);
+	tst_res(TINFO, "%s is %ld.", string, act_val);
+	if (act_val != exp_val) {
+		tst_res(TFAIL, "%s is not %ld but %ld.", string, exp_val,
+			act_val);
+		return 1;
+	}
+	return 0;
+}
+
+static int checkproc(long act_val, char *pattern, long exp_val)
+{
+	tst_res(TINFO, "%s is %ld.", pattern, act_val);
+	if (act_val != exp_val) {
+		tst_res(TFAIL, "%s is not %ld but %ld.",
+			pattern, exp_val, act_val);
+		return 1;
+	}
+	return 0;
+}
+
 static void init_sys_sz_paths(void)
 {
-	sprintf(path_sys_sz, "/sys/kernel/mm/hugepages/hugepages-%dkB",
+	sprintf(path_sys_sz, "/sys/kernel/mm/hugepages/hugepages-%ldkB",
 		hugepagesize / 1024);
 	sprintf(path_sys_sz_over, "%s/nr_overcommit_hugepages", path_sys_sz);
 	sprintf(path_sys_sz_free, "%s/free_hugepages", path_sys_sz);
@@ -500,3 +314,12 @@
 	sprintf(path_sys_sz_surp, "%s/surplus_hugepages", path_sys_sz);
 	sprintf(path_sys_sz_huge, "%s/nr_hugepages", path_sys_sz);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_overcommit,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c
index b061d5a..40caf81 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap06.c
@@ -1,18 +1,15 @@
 /*
- *  Copyright (c) 2015 Red Hat, Inc.
+ * Copyright (c) 2015-2017 Red Hat, Inc.
  *
- * This program is free software: you can redistribute it and/or modify
+ * This program is free software;  you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
+ * 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, see <http://www.gnu.org/licenses/>.
+ * 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.
  */
 
 /*
@@ -36,22 +33,12 @@
  */
 
 #define _GNU_SOURCE
-#include <errno.h>
 #include <pthread.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "test.h"
 #include "mem.h"
 #include "hugetlb.h"
 #include "lapi/mmap.h"
 
-char *TCID = "hugemmap06";
-int TST_TOTAL = 5;
-
 static long hpage_size;
 static long hugepages;
 
@@ -61,37 +48,29 @@
 };
 
 #define ARSZ 50
+#define LOOP 5
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
 	check_hugepage();
 
-	/* MAP_HUGETLB check */
-	if ((tst_kvercmp(2, 6, 32)) < 0) {
-		tst_brkm(TCONF, NULL, "This test can only run on kernels "
-			"that are 2.6.32 or higher");
-	}
-
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 	orig_hugepages = get_sys_tune("nr_hugepages");
 
-	hugepages = (ARSZ + 1) * TST_TOTAL;
+	hugepages = (ARSZ + 1) * LOOP;
 
-	if (hugepages * read_meminfo("Hugepagesize:") > read_meminfo("MemTotal:"))
-		tst_brkm(TCONF, NULL, "System RAM is not enough to test.");
+	if (hugepages * SAFE_READ_MEMINFO("Hugepagesize:") > SAFE_READ_MEMINFO("MemTotal:"))
+		tst_brk(TCONF, "System RAM is not enough to test.");
 
 	set_sys_tune("nr_hugepages", hugepages, 1);
-
-	TEST_PAUSE;
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
 }
 
-void *thr(void *arg)
+static void *thr(void *arg)
 {
 	struct mp *mmap_sz = arg;
 	int i, lim, a, b, c;
@@ -108,7 +87,7 @@
 	return NULL;
 }
 
-void do_mmap(void)
+static void do_mmap(unsigned int j LTP_ATTRIBUTE_UNUSED)
 {
 	int i, sz = ARSZ + 1;
 	void *addr, *new_addr;
@@ -122,11 +101,11 @@
 
 	if (addr == MAP_FAILED) {
 		if (errno == ENOMEM) {
-			tst_brkm(TCONF, cleanup,
+			tst_brk(TCONF,
 				"Cannot allocate hugepage, memory too fragmented?");
 		}
 
-		tst_brkm(TBROK | TERRNO, cleanup, "Cannot allocate hugepage");
+		tst_brk(TBROK | TERRNO, "Cannot allocate hugepage");
 	}
 
 	for (i = 0; i < ARSZ; ++i, --sz) {
@@ -135,7 +114,7 @@
 
 		TEST(pthread_create(&tid[i], NULL, thr, &mmap_sz[i]));
 		if (TEST_RETURN)
-			tst_brkm(TBROK | TRERRNO, cleanup,
+			tst_brk(TBROK | TRERRNO,
 					"pthread_create failed");
 
 		new_addr = mmap(addr, (sz - 1) * hpage_size,
@@ -144,7 +123,7 @@
 				-1, 0);
 
 		if (new_addr == MAP_FAILED)
-			tst_brkm(TFAIL | TERRNO, cleanup, "mmap failed");
+			tst_brk(TFAIL | TERRNO, "mmap failed");
 
 		addr = new_addr;
 	}
@@ -152,31 +131,22 @@
 	for (i = 0; i < ARSZ; ++i) {
 		TEST(pthread_join(tid[i], NULL));
 		if (TEST_RETURN)
-			tst_brkm(TBROK | TRERRNO, cleanup,
+			tst_brk(TBROK | TRERRNO,
 					"pthread_join failed");
 	}
 
 	if (munmap(addr, sz * hpage_size) == -1)
-		tst_brkm(TFAIL | TERRNO, cleanup, "huge munmap failed");
+		tst_brk(TFAIL | TERRNO, "huge munmap failed");
+
+	tst_res(TPASS, "No regression found.");
 }
 
-int main(int ac, char **av)
-{
-	int lc, i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++)
-			do_mmap();
-
-		tst_resm(TPASS, "No regression found.");
-	}
-
-	cleanup();
-	tst_exit();
-}
+static struct tst_test test = {
+	.min_kver = "2.6.32",
+	.needs_root = 1,
+	.tcnt = LOOP,
+	.needs_tmpdir = 1,
+	.test = do_mmap,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
index cfb4d72..a0867a8 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c
@@ -1,26 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ * Copyright (c) Linux Test Project, 2001-2017
  *
- *   Copyright (c) International Business Machines  Corp., 2001
+ * 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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmat01.c
- *
  * DESCRIPTION
  *	hugeshmat01 - test that shmat() works correctly
  *
@@ -39,107 +32,75 @@
  *			issue a FAIL message
  *	call cleanup
  *
- * USAGE:  <for command-line>
- *  hugeshmat01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	none
  */
 
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
+#include "hugetlb.h"
 
-char *TCID = "hugeshmat01";
-int TST_TOTAL = 3;
-
-#define CASE0		10	/* values to write into the shared */
-#define CASE1		20	/* memory location.                */
+#define CASE0 10 /* values to write into the shared */
+#define CASE1 20 /* memory location.                */
 
 static size_t shm_size;
 static int shm_id_1 = -1;
 static void *addr;
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-struct test_case_t {
+static struct tcase {
 	int *shmid;
 	void *addr;
 	int flags;
-} TC[] = {
+} tcases[] = {
 	/* a straight forward read/write attach */
-	{
-	&shm_id_1, 0, 0},
-	    /*
-	     * an attach using non aligned memory
-	     * -1 will be replaced with an unaligned addr
-	     */
-	{
-	&shm_id_1, (void *)-1, SHM_RND},
-	    /* a read only attach */
-	{
-	&shm_id_1, 0, SHM_RDONLY}
+	{&shm_id_1, 0, 0},
+	/*
+	 * an attach using non aligned memory
+	 * -1 will be replaced with an unaligned addr
+	 */
+	{&shm_id_1, (void *)-1, SHM_RND},
+	/* a read only attach */
+	{&shm_id_1, 0, SHM_RDONLY}
 };
 
-static void check_functionality(int i);
+static void check_functionality(unsigned int i);
 
-int main(int ac, char **av)
+static void verify_hugeshmat(unsigned int i)
 {
-	int lc, i;
+	struct tcase *tc = &tcases[i];
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			addr = shmat(*(TC[i].shmid), TC[i].addr, TC[i].flags);
-			if (addr == (void *)-1) {
-				tst_brkm(TFAIL | TERRNO, cleanup, "shmat");
-			} else {
-				check_functionality(i);
-			}
-
-			/*
-			 * addr in TC[0] will be used to generate an unaligned
-			 * address for TC[1]
-			 */
-			if (i == 0 && addr != (void *)-1)
-				TC[1].addr = (void *)(((unsigned long)addr &
-						       ~(SHMLBA - 1)) + SHMLBA -
-						      1);
-			if (shmdt(addr) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup, "shmdt");
-		}
+	addr = shmat(*(tc->shmid), tc->addr, tc->flags);
+	if (addr == (void *)-1) {
+		tst_brk(TFAIL | TERRNO, "shmat");
+	} else {
+		check_functionality(i);
 	}
-	cleanup();
-	tst_exit();
+
+	/*
+	 * addr in tcases[0] will be used to generate an unaligned
+	 * address for tcases[1]
+	 */
+	if (i == 0 && addr != (void *)-1)
+		tc[1].addr = (void *)(((unsigned long)addr &
+					~(SHMLBA - 1)) + SHMLBA - 1);
+	if (shmdt(addr) == -1)
+		tst_brk(TBROK | TERRNO, "shmdt");
 }
 
 /*
  * check_functionality - check various conditions to make sure they
  *			 are correct.
  */
-static void check_functionality(int i)
+static void check_functionality(unsigned int i)
 {
 	void *orig_add;
 	int *shared;
@@ -149,17 +110,17 @@
 
 	/* stat the shared memory ID */
 	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmctl");
+		tst_brk(TBROK | TERRNO, "shmctl");
 
 	/* check the number of attaches */
 	if (buf.shm_nattch != 1) {
-		tst_resm(TFAIL, "# of attaches is incorrect");
+		tst_res(TFAIL, "# of attaches is incorrect");
 		return;
 	}
 
 	/* check the size of the segment */
 	if (buf.shm_segsz != shm_size) {
-		tst_resm(TFAIL, "segment size is incorrect");
+		tst_res(TFAIL, "segment size is incorrect");
 		return;
 	}
 
@@ -182,9 +143,9 @@
 		 * specified in the man page.
 		 */
 		*shared = CASE1;
-		orig_add = addr + ((unsigned long)TC[i].addr % SHMLBA);
-		if (orig_add != TC[i].addr) {
-			tst_resm(TFAIL, "shared memory address is not "
+		orig_add = addr + ((unsigned long)tcases[i].addr % SHMLBA);
+		if (orig_add != tcases[i].addr) {
+			tst_res(TFAIL, "shared memory address is not "
 				 "correct");
 			return;
 		}
@@ -196,43 +157,48 @@
 		 * because shared memory is persistent.
 		 */
 		if (*shared != CASE1) {
-			tst_resm(TFAIL, "shared memory value isn't correct");
+			tst_res(TFAIL, "shared memory value isn't correct");
 			return;
 		}
 		break;
 	}
-	tst_resm(TPASS, "conditions and functionality are correct");
+	tst_res(TPASS, "conditions and functionality are correct");
 }
 
-void setup(void)
+static void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 	shm_id_1 = shmget(shmkey++, shm_size,
 			  SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
 	if (shm_id_1 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget");
+		tst_brk(TBROK | TERRNO, "shmget");
 
-	TEST_PAUSE;
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_hugeshmat,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c
index e644178..f45151d 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c
@@ -1,26 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmat02.c
- *
  * DESCRIPTION
  *	hugeshmat02 - check for EINVAL and EACCES errors with hugetlb
  *
@@ -33,15 +26,6 @@
  *	    issue a FAIL message
  *	call cleanup
  *
- * USAGE:  <for command-line>
- *  hugeshmat02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated By Robbie Williamson
@@ -51,12 +35,10 @@
  */
 
 #include <pwd.h>
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
-
-char *TCID = "hugeshmat02";
-int TST_TOTAL = 2;
+#include "hugetlb.h"
 
 #if __WORDSIZE == 64
 #define NADDR	0x10000000eef	/* a 64bit non alligned address value */
@@ -70,88 +52,79 @@
 static void *addr;
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-struct test_case_t {
+struct tcase {
 	int *shmid;
 	void *addr;
 	int error;
-} TC[] = {
+} tcases[] = {
 	/* EINVAL - the shared memory ID is not valid */
-	{
-	&shm_id_1, NULL, EINVAL},
-	    /* EINVAL - the address is not page aligned and SHM_RND is not given */
-	{
-&shm_id_2, (void *)NADDR, EINVAL},};
+	{&shm_id_1, NULL, EINVAL},
+	/* EINVAL - the address is not page aligned and SHM_RND is not given */
+	{&shm_id_2, (void *)NADDR, EINVAL}
+};
 
-int main(int ac, char **av)
+static void verify_hugeshmat(unsigned int i)
 {
-	int lc, i;
+	struct tcase *tc = &tcases[i];
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			addr = shmat(*(TC[i].shmid), TC[i].addr, 0);
-			if (addr != (void *)-1) {
-				tst_resm(TFAIL, "shmat suceeded unexpectedly");
-				continue;
-			}
-			if (errno == TC[i].error)
-				tst_resm(TPASS | TERRNO, "shmat failed as "
-					 "expected");
-			else
-				tst_resm(TFAIL | TERRNO, "shmat failed "
-					 "unexpectedly - expect errno=%d, "
-					 "got", TC[i].error);
-		}
+	addr = shmat(*(tc->shmid), tc->addr, 0);
+	if (addr != (void *)-1) {
+		tst_res(TFAIL, "shmat suceeded unexpectedly");
+		return;
 	}
-	cleanup();
-	tst_exit();
+
+	if (errno == tc->error) {
+		tst_res(TPASS | TERRNO, "shmat failed as "
+				"expected");
+	} else {
+		tst_res(TFAIL | TERRNO, "shmat failed "
+				"unexpectedly - expect errno=%d, "
+				"got", tc->error);
+	}
 }
 
 void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 
 	/* create a shared memory resource with read and write permissions */
 	/* also post increment the shmkey for the next shmget call */
 	shm_id_2 = shmget(shmkey++, shm_size,
 			  SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
 	if (shm_id_2 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget");
-
-	TEST_PAUSE;
+		tst_brk(TBROK | TERRNO, "shmget");
 }
 
 void cleanup(void)
 {
 	rm_shm(shm_id_2);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_hugeshmat,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c
index a0cea9a..f628710 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c
@@ -1,26 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmat03.c
- *
  * DESCRIPTION
  *	hugeshmat03 - test for EACCES error
  *
@@ -40,15 +33,6 @@
  *	  wait for child to exit
  *	  remove the shared memory segment
  *
- * USAGE:  <for command-line>
- *  hugeshmat03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
@@ -57,12 +41,10 @@
  *	test must be run at root
  */
 
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
-
-char *TCID = "hugeshmat03";
-int TST_TOTAL = 1;
+#include "hugetlb.h"
 
 static size_t shm_size;
 static int shm_id_1 = -1;
@@ -71,92 +53,75 @@
 static char *ltp_user = "nobody";
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-static void do_child(void);
-
-int main(int ac, char **av)
+static void verify_hugeshmat(void)
 {
 	int status;
 	pid_t pid;
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	switch (pid = fork()) {
-	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
+	switch (pid = SAFE_FORK()) {
 	case 0:
 		if (setuid(ltp_uid) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "setuid");
-		do_child();
-		tst_exit();
-	default:
-		if (waitpid(pid, &status, 0) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
-	}
-	cleanup();
-	tst_exit();
-}
-
-static void do_child(void)
-{
-	int lc;
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+			tst_brk(TBROK | TERRNO, "setuid");
 
 		addr = shmat(shm_id_1, NULL, 0);
 		if (addr != (void *)-1) {
-			tst_resm(TFAIL, "shmat succeeded unexpectedly");
-			continue;
+			tst_res(TFAIL, "shmat succeeded unexpectedly");
+			return;
 		}
-		if (errno == EACCES)
-			tst_resm(TPASS | TERRNO, "shmat failed as expected");
-		else
-			tst_resm(TFAIL | TERRNO, "shmat failed unexpectedly "
-				 "- expect errno=EACCES, got");
+		if (errno == EACCES) {
+			tst_res(TPASS | TERRNO, "shmat failed as expected");
+		} else {
+			tst_res(TFAIL | TERRNO, "shmat failed unexpectedly "
+					"- expect errno=EACCES, got");
+		}
+		break;
+	default:
+		if (waitpid(pid, &status, 0) == -1)
+			tst_brk(TBROK | TERRNO, "waitpid");
 	}
 }
 
-void setup(void)
+static void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 	shm_id_1 = shmget(shmkey, shm_size,
 			  SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
 	if (shm_id_1 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget");
+		tst_brk(TBROK | TERRNO, "shmget");
 
-	ltp_uid = getuserid(cleanup, ltp_user);
-
-	TEST_PAUSE;
+	ltp_uid = getuserid(ltp_user);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.test_all = verify_hugeshmat,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
index 7a71747..1411af6 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
@@ -1,20 +1,15 @@
 /*
- *   Copyright (c) Linux Test Project, 2014
+ * Copyright (c) Linux Test Project, 2014-2017
  *
- *   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 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 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.
  */
 
 /*
@@ -35,26 +30,12 @@
  * 	test must be run at root
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/shm.h>
-#include <sys/wait.h>
-
-#include "test.h"
 #include "mem.h"
 #include "hugetlb.h"
 
 #define SIZE	(1024 * 1024 * 1024)
 #define BOUNDARY (1024 * 1024 * 1024)
 
-char *TCID = "hugeshmat04";
-int TST_TOTAL = 3;
-
 static long huge_free;
 static long huge_free2;
 static long hugepages;
@@ -62,36 +43,19 @@
 
 static void shared_hugepage(void);
 
-int main(int ac, char **av)
+static void test_hugeshmat(unsigned int i LTP_ATTRIBUTE_UNUSED)
 {
-	int lc, i;
+	huge_free = SAFE_READ_MEMINFO("HugePages_Free:");
+	shared_hugepage();
+	huge_free2 = SAFE_READ_MEMINFO("HugePages_Free:");
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			huge_free = read_meminfo("HugePages_Free:");
-			shared_hugepage();
-			huge_free2 = read_meminfo("HugePages_Free:");
-
-			if (huge_free2 != huge_free)
-				tst_brkm(TFAIL, cleanup,
-				"Test failed. Hugepage leak inspection.");
-			else
-				tst_resm(TPASS, "No regression found.");
-		}
-	}
-
-	cleanup();
-	tst_exit();
+	if (huge_free2 != huge_free)
+		tst_brk(TFAIL, "Test failed. Hugepage leak inspection.");
+	else
+		tst_res(TPASS, "No regression found.");
 }
 
-void shared_hugepage(void)
+static void shared_hugepage(void)
 {
 	pid_t pid;
 	int status, shmid;
@@ -100,56 +64,59 @@
 
 	shmid = shmget(IPC_PRIVATE, size, SHM_HUGETLB | IPC_CREAT | 0777);
 	if (shmid < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget");
+		tst_brk(TBROK | TERRNO, "shmget");
 
 	buf = shmat(shmid, (void *)BOUNDARY, SHM_RND | 0777);
 	if (buf == (void *)-1) {
 		shmctl(shmid, IPC_RMID, NULL);
-		tst_brkm(TBROK | TERRNO, cleanup, "shmat");
+		tst_brk(TBROK | TERRNO, "shmat");
 	}
 
 	memset(buf, 2, size);
-	pid = fork();
-
+	pid = SAFE_FORK();
 	if (pid == 0)
 		exit(1);
-	else if (pid < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
 
 	wait(&status);
 	shmdt(buf);
 	shmctl(shmid, IPC_RMID, NULL);
 }
 
-void setup(void)
+static void setup(void)
 {
 	long mem_total, hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-
-	mem_total = read_meminfo("MemTotal:");
-	SAFE_FILE_SCANF(NULL, PATH_SHMMAX, "%ld", &orig_shmmax);
-	SAFE_FILE_PRINTF(NULL, PATH_SHMMAX, "%ld", (long)SIZE);
-	SAFE_FILE_SCANF(NULL, PATH_SHMMAX, "%ld", &new_shmmax);
+	mem_total = SAFE_READ_MEMINFO("MemTotal:");
+	SAFE_FILE_SCANF(PATH_SHMMAX, "%ld", &orig_shmmax);
+	SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", (long)SIZE);
+	SAFE_FILE_SCANF(PATH_SHMMAX, "%ld", &new_shmmax);
 
 	if (mem_total < 2L*1024*1024)
-		tst_brkm(TCONF,	NULL, "Needed > 2GB RAM, have: %ld", mem_total);
+		tst_brk(TCONF,	"Needed > 2GB RAM, have: %ld", mem_total);
 
 	if (new_shmmax < SIZE)
-		tst_brkm(TCONF,	NULL, "shmmax too low, have: %ld", new_shmmax);
+		tst_brk(TCONF,	"shmmax too low, have: %ld", new_shmmax);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	hugepages = (orig_hugepages * hpage_size + SIZE) / hpage_size;
 	set_sys_tune("nr_hugepages", hugepages, 1);
-
-	TEST_PAUSE;
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-	SAFE_FILE_PRINTF(NULL, PATH_SHMMAX, "%ld", orig_shmmax);
+	SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", orig_shmmax);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.needs_tmpdir = 1,
+	.tcnt = 3,
+	.test = test_hugeshmat,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c
index 8c17f21..d86d7f9 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat05.c
@@ -1,18 +1,15 @@
 /*
- * Copyright (c) 2015 Red Hat, Inc.
+ * Copyright (c) 2015-2017 Red Hat, Inc.
  *
- * This program is free software: you can redistribute it and/or modify
+ * This program is free software;  you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
+ * 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, see <http://www.gnu.org/licenses/>.
+ * 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.
  */
 
 /*
@@ -39,21 +36,9 @@
  *
  */
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-
-#include "test.h"
 #include "mem.h"
 #include "hugetlb.h"
 
-char *TCID = "hugeshmat05";
-int TST_TOTAL = 1;
-
 static long page_size;
 static long hpage_size;
 static long hugepages;
@@ -62,17 +47,13 @@
 
 void setup(void)
 {
-	tst_require_root();
 	check_hugepage();
-
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	page_size = getpagesize();
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	hugepages = N + 1;
 	set_sys_tune("nr_hugepages", hugepages, 1);
-
-	TEST_PAUSE;
 }
 
 void cleanup(void)
@@ -87,35 +68,30 @@
 
 	shmid = shmget(IPC_PRIVATE, size, 0600 | IPC_CREAT | SHM_HUGETLB);
 	if (shmid < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget failed");
+		tst_brk(TBROK | TERRNO, "shmget failed");
 
 	shmaddr = shmat(shmid, 0, 0);
 	if (shmaddr == (char *)-1) {
 		shmctl(shmid, IPC_RMID, NULL);
-		tst_brkm(TFAIL | TERRNO, cleanup,
+		tst_brk(TFAIL | TERRNO,
 			 "Bug: shared memory attach failure.");
 	}
 
 	shmaddr[0] = 1;
-	tst_resm(TINFO, "allocated %d huge bytes", size);
+	tst_res(TINFO, "allocated %d huge bytes", size);
 
 	if (shmdt((const void *)shmaddr) != 0) {
 		shmctl(shmid, IPC_RMID, NULL);
-		tst_brkm(TFAIL | TERRNO, cleanup, "Detach failure.");
+		tst_brk(TFAIL | TERRNO, "Detach failure.");
 	}
 
 	shmctl(shmid, IPC_RMID, NULL);
 }
 
-int main(int ac, char **av)
+static void test_hugeshmat(void)
 {
-	int lc;
 	unsigned int i;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
 	const int tst_sizes[] = {
 		N * hpage_size - page_size,
 		N * hpage_size - page_size - 1,
@@ -123,15 +99,16 @@
 		hpage_size + 1
 	};
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+	for (i = 0; i < ARRAY_SIZE(tst_sizes); ++i)
+		shm_test(tst_sizes[i]);
 
-		for (i = 0; i < ARRAY_SIZE(tst_sizes); ++i)
-			shm_test(tst_sizes[i]);
-
-		tst_resm(TPASS, "No regression found.");
-	}
-
-	cleanup();
-	tst_exit();
+	tst_res(TPASS, "No regression found.");
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.test_all = test_hugeshmat,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
index a54077a..0e37b8f 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c
@@ -1,27 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmctl01.c
- *
  * DESCRIPTION
  *	hugeshmctl01 - test the IPC_STAT, IPC_SET and IPC_RMID commands as
  *		   they are used with shmctl()
@@ -44,31 +36,15 @@
  *	    issue a PASS message
  *	call cleanup
  *
- * USAGE:  <for command-line>
- *  hugeshmctl01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	none
  */
 
-#include "test.h"
-#include "safe_macros.h"
+#include <limits.h>
 #include "mem.h"
 #include "hugetlb.h"
 
-char *TCID = "hugeshmctl01";
-int TST_TOTAL = 4;
-
 #define FIRST		0
 #define SECOND		1
 #define N_ATTACH	4
@@ -92,67 +68,54 @@
 static void *set_shmat(void);
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-struct test_case_t {
+struct tcase {
 	int cmd;
 	void (*func_test) (void);
 	void (*func_setup) (void);
-} TC[] = {
-	{
-	IPC_STAT, func_stat, stat_setup}, {
-	IPC_STAT, func_stat, stat_setup}, {
-	IPC_SET, func_set, set_setup}, {
-	IPC_RMID, func_rmid, NULL}
+} tcases[] = {
+	{IPC_STAT, func_stat, stat_setup},
+	{IPC_STAT, func_stat, stat_setup},
+	{IPC_SET,  func_set,  set_setup},
+	{IPC_RMID, func_rmid, NULL}
 };
 
-int main(int ac, char **av)
+static void test_hugeshmctl(void)
 {
-	int lc, i;
+	unsigned int i;
 
-	tst_parse_opts(ac, av, options, NULL);
+	/* initialize stat_time */
+	stat_time = FIRST;
 
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
+	/*
+	 * Create a shared memory segment with read and write
+	 * permissions.  Do this here instead of in setup()
+	 * so that looping (-i) will work correctly.
+	 */
+	shm_id_1 = shmget(shmkey, shm_size,
+			SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
+	if (shm_id_1 == -1)
+		tst_brk(TBROK | TERRNO, "shmget #main");
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		/* initialize stat_time */
-		stat_time = FIRST;
-
+	for (i = 0; i < ARRAY_SIZE(tcases); i++) {
 		/*
-		 * Create a shared memory segment with read and write
-		 * permissions.  Do this here instead of in setup()
-		 * so that looping (-i) will work correctly.
+		 * if needed, set up any required conditions by
+		 * calling the appropriate setup function
 		 */
-		shm_id_1 = shmget(shmkey, shm_size,
-				  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
-		if (shm_id_1 == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "shmget #main");
+		if (tcases[i].func_setup != NULL)
+			(*tcases[i].func_setup) ();
 
-		for (i = 0; i < TST_TOTAL; i++) {
-			/*
-			 * if needed, set up any required conditions by
-			 * calling the appropriate setup function
-			 */
-			if (TC[i].func_setup != NULL)
-				(*TC[i].func_setup) ();
-
-			if (shmctl(shm_id_1, TC[i].cmd, &buf) == -1) {
-				tst_resm(TFAIL | TERRNO, "shmctl #main");
-				continue;
-			}
-			(*TC[i].func_test) ();
+		if (shmctl(shm_id_1, tcases[i].cmd, &buf) == -1) {
+			tst_res(TFAIL | TERRNO, "shmctl #main");
+			continue;
 		}
+		(*tcases[i].func_test) ();
 	}
-	cleanup();
-	tst_exit();
 }
 
 /*
@@ -166,7 +129,7 @@
 
 	rval = shmat(shm_id_1, 0, 0);
 	if (rval == (void *)-1)
-		tst_brkm(TBROK | TERRNO, cleanup, "set shmat");
+		tst_brk(TBROK | TERRNO, "set shmat");
 
 	return rval;
 }
@@ -182,7 +145,15 @@
 	void *test;
 	pid_t pid;
 	sigset_t newmask, oldmask;
+	struct sigaction sa;
 
+	memset (&sa, '\0', sizeof(sa));
+	sa.sa_handler = sighandler;
+	sa.sa_flags = 0;
+	TEST(sigaction(SIGUSR1, &sa, NULL));
+	if (TEST_RETURN == -1)
+		tst_brk(TBROK | TRERRNO,
+				"SIGSEGV signal setup failed");
 	/*
 	 * The first time through, let the children attach the memory.
 	 * The second time through, attach the memory first and let
@@ -210,12 +181,10 @@
 	sigemptyset(&newmask);
 	sigaddset(&newmask, SIGUSR1);
 	if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "block SIGUSR1 error");
+		tst_brk(TBROK | TERRNO, "block SIGUSR1 error");
 
 	for (i = 0; i < N_ATTACH; i++) {
-		switch (pid = fork()) {
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork");
+		switch (pid = SAFE_FORK()) {
 		case 0:
 			test = (stat_time == FIRST) ? set_shmat() : set_shared;
 
@@ -229,19 +198,19 @@
 			 */
 			rval = sigsuspend(&oldmask);
 			if (rval != -1)
-				tst_brkm(TBROK | TERRNO, cleanup, "sigsuspend");
+				tst_brk(TBROK | TERRNO, "sigsuspend");
 
 			/*
 			 * don't have to block SIGUSR1 any more,
 			 * recover the mask
 			 */
 			if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
-				tst_brkm(TBROK | TERRNO, cleanup,
+				tst_brk(TBROK | TERRNO,
 					 "child sigprocmask");
 
 			/* now we're back - detach the memory and exit */
 			if (shmdt(test) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
+				tst_brk(TBROK | TERRNO,
 					 "shmdt in stat_setup()");
 			exit(0);
 		default:
@@ -252,7 +221,7 @@
 
 	/* parent doesn't have to block SIGUSR1, recover the mask */
 	if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
-		tst_brkm(TBROK, cleanup, "parent sigprocmask");
+		tst_brk(TBROK, "parent sigprocmask");
 
 	usleep(250000);
 }
@@ -270,12 +239,12 @@
 	pid = getpid();
 
 	if (buf.shm_cpid != pid) {
-		tst_resm(TFAIL, "creator pid is incorrect");
+		tst_res(TFAIL, "creator pid is incorrect");
 		goto fail;
 	}
 
 	if (buf.shm_segsz != shm_size) {
-		tst_resm(TFAIL, "segment size is incorrect");
+		tst_res(TFAIL, "segment size is incorrect");
 		goto fail;
 	}
 
@@ -286,18 +255,18 @@
 	 * that memory so the attaches equal N_ATTACH + stat_time (1).
 	 */
 	if (buf.shm_nattch != N_ATTACH + stat_time) {
-		tst_resm(TFAIL, "# of attaches is incorrect - %lu",
+		tst_res(TFAIL, "# of attaches is incorrect - %lu",
 			 (unsigned long)buf.shm_nattch);
 		goto fail;
 	}
 
 	/* use MODE_MASK to make sure we are comparing the last 9 bits */
 	if ((buf.shm_perm.mode & MODE_MASK) != ((SHM_RW) & MODE_MASK)) {
-		tst_resm(TFAIL, "segment mode is incorrect");
+		tst_res(TFAIL, "segment mode is incorrect");
 		goto fail;
 	}
 
-	tst_resm(TPASS, "pid, size, # of attaches and mode are correct "
+	tst_res(TPASS, "pid, size, # of attaches and mode are correct "
 		 "- pass #%d", stat_time);
 
 fail:
@@ -319,15 +288,21 @@
 	/* wake up the childern so they can detach the memory and exit */
 	for (i = 0; i < N_ATTACH; i++)
 		if (kill(pid_arr[i], SIGUSR1) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "kill with SIGUSR1");
+			tst_brk(TBROK | TERRNO, "kill with SIGUSR1");
 
 	/* remove the parent's shared memory the second time through */
 	if (stat_time == SECOND)
 		if (shmdt(set_shared) == -1)
-			tst_resm(TBROK | TERRNO, "shmdt in stat_cleanup()");
+			tst_res(TBROK | TERRNO, "shmdt in stat_cleanup()");
 	stat_time++;
 }
 
+static void sighandler(int sig)
+{
+	if (sig != SIGUSR1)
+		tst_res(TFAIL, "received unexpected signal %d", sig);
+}
+
 /*
  * set_setup() - set up for the IPC_SET command with shmctl()
  */
@@ -347,21 +322,21 @@
 {
 	/* first stat the shared memory to get the new data */
 	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
-		tst_resm(TBROK | TERRNO, "shmctl in func_set()");
+		tst_res(TBROK | TERRNO, "shmctl in func_set()");
 		return;
 	}
 
 	if ((buf.shm_perm.mode & MODE_MASK) != ((SHM_RW | NEWMODE) & MODE_MASK)) {
-		tst_resm(TFAIL, "new mode is incorrect");
+		tst_res(TFAIL, "new mode is incorrect");
 		return;
 	}
 
 	if (save_time >= buf.shm_ctime) {
-		tst_resm(TFAIL, "change time is incorrect");
+		tst_res(TFAIL, "change time is incorrect");
 		return;
 	}
 
-	tst_resm(TPASS, "new mode and change time are correct");
+	tst_res(TPASS, "new mode and change time are correct");
 }
 
 /*
@@ -371,48 +346,46 @@
 {
 	/* Do another shmctl() - we should get EINVAL */
 	if (shmctl(shm_id_1, IPC_STAT, &buf) != -1)
-		tst_brkm(TBROK, cleanup, "shmctl in func_rmid() "
+		tst_brk(TBROK, "shmctl in func_rmid() "
 			 "succeeded unexpectedly");
 	if (errno != EINVAL)
-		tst_resm(TFAIL | TERRNO, "shmctl in func_rmid() failed "
+		tst_res(TFAIL | TERRNO, "shmctl in func_rmid() failed "
 			 "unexpectedly - expect errno=EINVAL, got");
 	else
-		tst_resm(TPASS, "shmctl in func_rmid() failed as expected, "
+		tst_res(TPASS, "shmctl in func_rmid() failed as expected, "
 			 "shared memory appears to be removed");
 	shm_id_1 = -1;
 }
 
-static void sighandler(int sig)
-{
-	if (sig != SIGUSR1)
-		tst_resm(TFAIL, "received unexpected signal %d", sig);
-}
-
 void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(FORK, sighandler, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
-
-	TEST_PAUSE;
+	shmkey = getipckey();
 }
 
 void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugeshmctl,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
index f5ae366..6079d99 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c
@@ -1,26 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmctl02.c
- *
  * DESCRIPTION
  *	hugeshmctl02 - check for EACCES, EFAULT and EINVAL errors
  *
@@ -35,32 +28,16 @@
  *	    issue a FAIL message
  *	call cleanup
  *
- * USAGE:  <for command-line>
- *  hugeshmctl02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	none
  */
 
 #include <pwd.h>
-#include "test.h"
-#include "safe_macros.h"
+#include <limits.h>
 #include "mem.h"
 #include "hugetlb.h"
 
-char *TCID = "hugeshmctl02";
-int TST_TOTAL = 4;
-
 static size_t shm_size;
 static int shm_id_1 = -1;
 static int shm_id_2 = -1;
@@ -68,101 +45,90 @@
 static struct shmid_ds buf;
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-struct test_case_t {
+struct tcase {
 	int *shmid;
 	int cmd;
 	struct shmid_ds *sbuf;
 	int error;
-} TC[] = {
+} tcases[] = {
 	/* EFAULT - IPC_SET & buf isn't valid */
-	{
-	&shm_id_2, IPC_SET, (struct shmid_ds *)-1, EFAULT},
-	    /* EFAULT - IPC_STAT & buf isn't valid */
-	{
-	&shm_id_2, IPC_STAT, (struct shmid_ds *)-1, EFAULT},
-	    /* EINVAL - the shmid is not valid */
-	{
-	&shm_id_3, IPC_STAT, &buf, EINVAL},
-	    /* EINVAL - the command is not valid */
-	{
-&shm_id_2, -1, &buf, EINVAL},};
+	{&shm_id_2, IPC_SET, (struct shmid_ds *)-1, EFAULT},
+	/* EFAULT - IPC_STAT & buf isn't valid */
+	{&shm_id_2, IPC_STAT, (struct shmid_ds *)-1, EFAULT},
+	/* EINVAL - the shmid is not valid */
+	{&shm_id_3, IPC_STAT, &buf, EINVAL},
+	/* EINVAL - the command is not valid */
+	{&shm_id_2, -1, &buf, EINVAL},
+};
 
-int main(int ac, char **av)
+static void test_hugeshmctl(void)
 {
-	int lc, i;
+	unsigned int i;
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].sbuf));
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "shmctl succeeded "
-					 "unexpectedly");
-				continue;
-			}
-			if (TEST_ERRNO == TC[i].error)
-				tst_resm(TPASS | TTERRNO, "shmctl failed "
-					 "as expected");
-			else
-				tst_resm(TFAIL | TTERRNO, "shmctl failed "
-					 "unexpectedly - expect errno = "
-					 "%d, got", TC[i].error);
+	for (i = 0; i < ARRAY_SIZE(tcases); i++) {
+		TEST(shmctl(*(tcases[i].shmid), tcases[i].cmd, tcases[i].sbuf));
+		if (TEST_RETURN != -1) {
+			tst_res(TFAIL, "shmctl succeeded "
+					"unexpectedly");
+			continue;
+		}
+		if (TEST_ERRNO == tcases[i].error) {
+			tst_res(TPASS | TTERRNO, "shmctl failed "
+					"as expected");
+		} else {
+			tst_res(TFAIL | TTERRNO, "shmctl failed "
+					"unexpectedly - expect errno = "
+					"%d, got", tcases[i].error);
 		}
 	}
-	cleanup();
-	tst_exit();
 }
 
-void setup(void)
+static void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 
 	/* create a shared memory segment without read or write permissions */
 	shm_id_1 = shmget(shmkey, shm_size, SHM_HUGETLB | IPC_CREAT | IPC_EXCL);
 	if (shm_id_1 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget #1");
+		tst_brk(TBROK | TERRNO, "shmget #1");
 
 	/* create a shared memory segment with read and write permissions */
 	shm_id_2 = shmget(shmkey + 1, shm_size,
 			  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
 	if (shm_id_2 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget #2");
-
-	TEST_PAUSE;
+		tst_brk(TBROK | TERRNO, "shmget #2");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	rm_shm(shm_id_1);
 	rm_shm(shm_id_2);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugeshmctl,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c
index bb2b7e7..19df79f 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c
@@ -1,26 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmctl03.c
- *
  * DESCRIPTION
  *	hugeshmctl03 - check for EACCES, and EPERM errors
  *
@@ -41,15 +34,6 @@
  *	  wait for child to exit
  *	  remove the large shared memory segment
  *
- * USAGE:  <for command-line>
- *  hugeshmctl03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
@@ -60,14 +44,10 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
-#include "test.h"
-#include "safe_macros.h"
+#include <limits.h>
 #include "mem.h"
 #include "hugetlb.h"
 
-char *TCID = "hugeshmctl03";
-int TST_TOTAL = 3;
-
 static size_t shm_size;
 static int shm_id_1 = -1;
 static struct shmid_ds buf;
@@ -75,80 +55,64 @@
 static char *ltp_user = "nobody";
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-struct test_case_t {
+struct tcase {
 	int *shmid;
 	int cmd;
 	struct shmid_ds *sbuf;
 	int error;
-} TC[] = {
+} tcases[] = {
 	/* EACCES - child has no read permission for segment */
-	{
-	&shm_id_1, IPC_STAT, &buf, EACCES},
-	    /* EPERM - IPC_SET - child doesn't have permission to change segment */
-	{
-	&shm_id_1, IPC_SET, &buf, EPERM},
-	    /* EPERM - IPC_RMID - child can not remove the segment */
-	{
-&shm_id_1, IPC_RMID, &buf, EPERM},};
+	{&shm_id_1, IPC_STAT, &buf, EACCES},
+	/* EPERM - IPC_SET - child doesn't have permission to change segment */
+	{&shm_id_1, IPC_SET, &buf, EPERM},
+	/* EPERM - IPC_RMID - child can not remove the segment */
+	{&shm_id_1, IPC_RMID, &buf, EPERM},
+};
 
 static void do_child(void);
 
-int main(int ac, char **av)
+static void test_hugeshmctl(void)
 {
 	pid_t pid;
 	int status;
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	switch (pid = fork()) {
-	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
+	switch (pid = SAFE_FORK()) {
 	case 0:
-		/* set  the user ID of the child to the non root user */
+		/* set the user ID of the child to the non root user */
 		if (setuid(ltp_uid) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "setuid");
+			tst_brk(TBROK | TERRNO, "setuid");
 		do_child();
-		tst_exit();
+		exit(0);
 	default:
 		if (waitpid(pid, &status, 0) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+			tst_brk(TBROK | TERRNO, "waitpid");
 	}
-	cleanup();
-	tst_exit();
 }
 
 static void do_child(void)
 {
-	int i, lc;
+	unsigned int i;
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].sbuf));
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "shmctl succeeded "
-					 "unexpectedly");
-				continue;
-			}
-			if (TEST_ERRNO == TC[i].error)
-				tst_resm(TPASS | TTERRNO, "shmctl failed "
-					 "as expected");
-			else
-				tst_resm(TFAIL | TTERRNO, "shmctl failed "
-					 "unexpectedly - expect errno = "
-					 "%d, got", TC[i].error);
+	for (i = 0; i < ARRAY_SIZE(tcases); i++) {
+		TEST(shmctl(*(tcases[i].shmid), tcases[i].cmd, tcases[i].sbuf));
+		if (TEST_RETURN != -1) {
+			tst_res(TFAIL, "shmctl succeeded "
+					"unexpectedly");
+			continue;
 		}
+		if (TEST_ERRNO == tcases[i].error)
+			tst_res(TPASS | TTERRNO, "shmctl failed "
+					"as expected");
+		else
+			tst_res(TFAIL | TTERRNO, "shmctl failed "
+					"unexpectedly - expect errno = "
+					"%d, got", tcases[i].error);
 	}
 }
 
@@ -156,34 +120,38 @@
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 	shm_id_1 = shmget(shmkey, shm_size,
 			  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
 	if (shm_id_1 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget");
+		tst_brk(TBROK | TERRNO, "shmget");
 
 	/* get the userid for a non root user */
-	ltp_uid = getuserid(cleanup, ltp_user);
-
-	TEST_PAUSE;
+	ltp_uid = getuserid(ltp_user);
 }
 
 void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.needs_tmpdir = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugeshmctl,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c b/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c
index 0ebcca6..796d6df 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c
@@ -1,26 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmdt01.c
- *
  * DESCRIPTION
  *	hugeshmdt01 - check that largr shared memory is detached correctly
  *
@@ -41,29 +34,16 @@
  *			issue a FAIL message
  *	call cleanup
  *
- * USAGE:  <for command-line>
- *  hugeshmdt01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	none
  */
 
 #include <setjmp.h>
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
-
-char *TCID = "hugeshmdt01";
-int TST_TOTAL = 1;
+#include "hugetlb.h"
 
 static size_t shm_size;
 static int shm_id_1 = -1;
@@ -73,54 +53,43 @@
 static sigjmp_buf env;
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
 static void check_functionality(void);
 static void sighandler(int sig);
 
-int main(int ac, char **av)
+static void hugeshmdt_test(void)
 {
-	int lc;
+	struct sigaction sa;
 
-	tst_parse_opts(ac, av, options, NULL);
+	sa.sa_handler = sighandler;
+	sigaction(SIGSEGV, &sa, NULL);
 
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
+	if (shmdt(shared) == -1)
+		tst_res(TFAIL | TERRNO, "shmdt");
+	else
+		check_functionality();
 
-	setup();
+	/* reattach the shared memory segment in case we are looping */
+	shared = shmat(shm_id_1, 0, 0);
+	if (shared == (void *)-1)
+		tst_brk(TBROK | TERRNO, "shmat #2: reattach");
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		if (shmdt(shared) == -1) {
-			tst_resm(TFAIL | TERRNO, "shmdt");
-		} else {
-			check_functionality();
-		}
-
-		/* reattach the shared memory segment in case we are looping */
-		shared = shmat(shm_id_1, 0, 0);
-		if (shared == (void *)-1)
-			tst_brkm(TBROK | TERRNO, cleanup, "shmat #2: reattach");
-
-		/* also reset pass */
-		pass = 0;
-	}
-	cleanup();
-	tst_exit();
+	/* also reset pass */
+	pass = 0;
 }
 
 static void check_functionality(void)
 {
 	/* stat the shared memory segment */
 	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmctl");
+		tst_brk(TBROK | TERRNO, "shmctl");
 
 	if (buf.shm_nattch != 0) {
-		tst_resm(TFAIL, "# of attaches is incorrect");
+		tst_res(TFAIL, "# of attaches is incorrect");
 		return;
 	}
 
@@ -142,9 +111,9 @@
 		*shared = 2;
 
 	if (pass)
-		tst_resm(TPASS, "huge shared memory detached correctly");
+		tst_res(TPASS, "huge shared memory detached correctly");
 	else
-		tst_resm(TFAIL, "huge shared memory was not detached "
+		tst_res(TFAIL, "huge shared memory was not detached "
 			 "correctly");
 }
 
@@ -156,7 +125,7 @@
 		pass = 1;
 		siglongjmp(env, 1);
 	} else {
-		tst_brkm(TBROK, cleanup, "unexpected signal received: %d", sig);
+		tst_brk(TBROK, "unexpected signal received: %d", sig);
 	}
 }
 
@@ -164,41 +133,43 @@
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(NOFORK, sighandler, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 
 	/* create a shared memory resource with read and write permissions */
 	shm_id_1 = shmget(shmkey, shm_size,
 			  SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
 	if (shm_id_1 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget");
+		tst_brk(TBROK | TERRNO, "shmget");
 
 	/* attach the shared memory segment */
 	shared = shmat(shm_id_1, 0, 0);
 	if (shared == (void *)-1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmat #1");
+		tst_brk(TBROK | TERRNO, "shmat #1");
 
 	/* give a value to the shared memory integer */
 	*shared = 4;
-
-	TEST_PAUSE;
 }
 
 void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = hugeshmdt_test,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
index 2367c4d..ac3a1f0 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
@@ -1,168 +1,101 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmget01.c
- *
  * DESCRIPTION
  *	hugeshmget01 - test that shmget() correctly creates a large
  *			shared memory segment
  *
- * ALGORITHM
- *	loop if that option was specified
- *	use the TEST() macro to call shmget()
- *	check the return code
- *	  if failure, issue a FAIL message.
- *	otherwise,
- *	  if doing functionality testing
- *		stat the shared memory resource
- *		check the size, creator pid and mode
- *		if correct,
- *			issue a PASS message
- *		otherwise
- *			issue a FAIL message
- *	  else issue a PASS message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  shmget01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	none
  */
 
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
-
-char *TCID = "hugeshmget01";
-int TST_TOTAL = 1;
+#include "hugetlb.h"
 
 static size_t shm_size;
 static int shm_id_1 = -1;
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-int main(int ac, char **av)
+static void test_hugeshmget(void)
 {
-	int lc;
 	struct shmid_ds buf;
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		shm_id_1 = shmget(shmkey, shm_size,
-				  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
-		if (shm_id_1 == -1) {
-			tst_resm(TFAIL | TERRNO, "shmget");
-		} else {
-			/* do a STAT and check some info */
-			if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
-				tst_resm(TBROK | TERRNO,
-					 "shmctl(IPC_STAT)");
-				continue;
-			}
-			/* check the seqment size */
-			if (buf.shm_segsz != shm_size) {
-				tst_resm(TFAIL, "seqment size is not "
-					 "correct");
-				continue;
-			}
-			/* check the pid of the creator */
-			if (buf.shm_cpid != getpid()) {
-				tst_resm(TFAIL, "creator pid is not "
-					 "correct");
-				continue;
-			}
-			/*
-			 * check the mode of the seqment
-			 * mask out all but the lower 9 bits
-			 */
-			if ((buf.shm_perm.mode & MODE_MASK) !=
-			    ((SHM_RW) & MODE_MASK)) {
-				tst_resm(TFAIL, "segment mode is not "
-					 "correct");
-				continue;
-			}
-			/* if we get here, everything looks good */
-			tst_resm(TPASS, "size, pid & mode are correct");
-		}
-
-		/*
-		 * clean up things in case we are looping
-		 */
-		if (shmctl(shm_id_1, IPC_RMID, NULL) == -1)
-			tst_resm(TBROK | TERRNO, "shmctl(IPC_RMID)");
-		else
-			shm_id_1 = -1;
+	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
+		tst_res(TFAIL | TERRNO,	"shmctl(IPC_STAT)");
+		return;
 	}
-	cleanup();
-	tst_exit();
+
+	if (buf.shm_segsz != shm_size) {
+		tst_res(TFAIL, "seqment size is not correct");
+		return;
+	}
+
+	if (buf.shm_cpid != getpid()) {
+		tst_res(TFAIL, "creator pid is not correct");
+		return;
+	}
+
+	if ((buf.shm_perm.mode & MODE_MASK) != ((SHM_RW) & MODE_MASK)) {
+		tst_res(TFAIL, "segment mode is not correct");
+		return;
+	}
+
+	tst_res(TPASS, "size, pid & mode are correct");
 }
 
-void setup(void)
+static void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 
-	TEST_PAUSE;
+	shm_id_1 = shmget(shmkey, shm_size,
+			SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
+	if (shm_id_1 == -1)
+		tst_brk(TBROK | TERRNO, "shmget");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugeshmget,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
index 5f2cb31..7db8b4e 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
@@ -1,62 +1,31 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmget02.c
- *
  * DESCRIPTION
  *	hugeshmget02 - check for ENOENT, EEXIST and EINVAL errors
  *
- * ALGORITHM
- *	create a large shared memory segment with read & write permissions
- *	loop if that option was specified
- *	  call shmget() using five different invalid cases
- *	  check the errno value
- *	    issue a PASS message if we get ENOENT, EEXIST or EINVAL
- *	  otherwise, the tests fails
- *	    issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  hugeshmget02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	none
  */
-
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
-#include "mem.h"
 
-char *TCID = "hugeshmget02";
-int TST_TOTAL = 4;
+#include "mem.h"
+#include "hugetlb.h"
 
 static size_t shm_size;
 static int shm_id_1 = -1;
@@ -64,105 +33,88 @@
 static key_t shmkey2;
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-struct test_case_t {
+static struct tcase {
 	int *skey;
 	int size_coe;
 	int flags;
 	int error;
-} TC[] = {
+} tcases[] = {
 	/* EINVAL - size is 0 */
-	{
-	&shmkey2, 0, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EINVAL},
-	    /* EINVAL - size is larger than created segment */
-	{
-	&shmkey, 2, SHM_HUGETLB | SHM_RW, EINVAL},
-	    /* EEXIST - the segment exists and IPC_CREAT | IPC_EXCL is given */
-	{
-	&shmkey, 1, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EEXIST},
-	    /* ENOENT - no segment exists for the key and IPC_CREAT is not given */
-	    /* use shm_nonexistend_key (-1) as the key */
-	{
-	&shm_nonexistent_key, 1, SHM_HUGETLB | SHM_RW, ENOENT}
+	{&shmkey2, 0, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EINVAL},
+	/* EINVAL - size is larger than created segment */
+	{&shmkey, 2, SHM_HUGETLB | SHM_RW, EINVAL},
+	/* EEXIST - the segment exists and IPC_CREAT | IPC_EXCL is given */
+	{&shmkey, 1, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EEXIST},
+	/* ENOENT - no segment exists for the key and IPC_CREAT is not given */
+	/* use shm_nonexistend_key (-1) as the key */
+	{&shm_nonexistent_key, 1, SHM_HUGETLB | SHM_RW, ENOENT}
 };
 
-int main(int ac, char **av)
+static void test_hugeshmget(unsigned int i)
 {
-	int lc, i;
 	int shm_id_2 = -1;
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			/* If this key is existent, just remove it */
-			if (*TC[i].skey == -1) {
-				shm_id_2 = shmget(*(TC[i].skey), 0, 0);
-				if (shm_id_2 != -1)
-					shmctl(shm_id_2, IPC_RMID, NULL);
-			}
-
-			TEST(shmget(*(TC[i].skey), TC[i].size_coe * shm_size,
-				    TC[i].flags));
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "shmget succeeded "
-					 "unexpectedly");
-				continue;
-			}
-			if (TEST_ERRNO == TC[i].error)
-				tst_resm(TPASS | TTERRNO, "shmget failed "
-					 "as expected");
-			else
-				tst_resm(TFAIL | TTERRNO, "shmget failed "
-					 "unexpectedly - expect errno=%d, "
-					 "got", TC[i].error);
-		}
+	if (*tcases[i].skey == -1) {
+		shm_id_2 = shmget(*(tcases[i].skey), 0, 0);
+		if (shm_id_2 != -1)
+			shmctl(shm_id_2, IPC_RMID, NULL);
 	}
-	cleanup();
-	tst_exit();
+
+	TEST(shmget(*(tcases[i].skey), tcases[i].size_coe * shm_size,
+					tcases[i].flags));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "shmget succeeded unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO != tcases[i].error) {
+		tst_res(TFAIL | TTERRNO,
+			"shmget failed unexpectedly, expected %s",
+			tst_strerrno(tcases[i].error));
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "shmget failed as expected");
 }
 
 void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
 
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 	shmkey2 = shmkey + 1;
 	shm_id_1 = shmget(shmkey, shm_size, IPC_CREAT | IPC_EXCL | SHM_RW);
 	if (shm_id_1 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget #setup");
-
-	TEST_PAUSE;
+		tst_brk(TBROK | TERRNO, "shmget #setup");
 }
 
 void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = test_hugeshmget,
+	.tcnt = ARRAY_SIZE(tcases),
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
index 402313a..f485b0d 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
@@ -1,63 +1,31 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmget03.c
- *
  * DESCRIPTION
  *	hugeshmget03 - test for ENOSPC error
  *
- * ALGORITHM
- *	create large shared memory segments in a loop until reaching
- *		the system limit
- *	loop if that option was specified
- *	  attempt to create yet another shared memory segment
- *	  check the errno value
- *	    issue a PASS message if we get ENOSPC
- *	  otherwise, the tests fails
- *	    issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  hugeshmget03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	none
  */
 
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
-
-char *TCID = "hugeshmget03";
-int TST_TOTAL = 1;
+#include "hugetlb.h"
 
 /*
  * The MAXIDS value is somewhat arbitrary and may need to be increased
@@ -73,57 +41,41 @@
 
 static long hugepages = 128;
 static long orig_shmmni;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
-int main(int ac, char **av)
+static void test_hugeshmget(void)
 {
-	int lc;
-
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		TEST(shmget(IPC_PRIVATE, shm_size,
-			    SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW));
-		if (TEST_RETURN != -1) {
-			tst_resm(TFAIL, "shmget succeeded unexpectedly");
-			continue;
-		}
-		if (TEST_ERRNO == ENOSPC)
-			tst_resm(TPASS | TTERRNO, "shmget failed as expected");
-		else
-			tst_resm(TFAIL | TTERRNO, "shmget failed unexpectedly "
-				 "- expect errno=ENOSPC, got");
+	TEST(shmget(IPC_PRIVATE, shm_size,
+				SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "shmget succeeded unexpectedly");
+		return;
 	}
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO == ENOSPC)
+		tst_res(TPASS | TTERRNO, "shmget failed as expected");
+	else
+		tst_res(TFAIL | TTERRNO, "shmget failed unexpectedly "
+				"- expect errno=ENOSPC, got");
 }
 
-void setup(void)
+static void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
-	SAFE_FILE_SCANF(NULL, PATH_SHMMNI, "%ld", &orig_shmmni);
+	SAFE_FILE_SCANF(PATH_SHMMNI, "%ld", &orig_shmmni);
 
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	SAFE_FILE_PRINTF(NULL, PATH_SHMMNI, "%ld", hugepages / 2);
+	SAFE_FILE_PRINTF(PATH_SHMMNI, "%ld", hugepages / 2);
 
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 	shm_size = hpage_size;
 
 	/*
@@ -136,7 +88,7 @@
 	while (shm_id_1 != -1) {
 		shm_id_arr[num_shms++] = shm_id_1;
 		if (num_shms == MAXIDS)
-			tst_brkm(TBROK, cleanup, "The maximum number of "
+			tst_brk(TBROK, "The maximum number of "
 				 "shared memory ID's has been reached. "
 				 "Please increase the MAXIDS value in "
 				 "the test.");
@@ -144,12 +96,10 @@
 				  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
 	}
 	if (errno != ENOSPC)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget #setup");
-
-	TEST_PAUSE;
+		tst_brk(TBROK | TERRNO, "shmget #setup");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	int i;
 
@@ -158,6 +108,12 @@
 
 	FILE_PRINTF(PATH_SHMMNI, "%ld", orig_shmmni);
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugeshmget,
+};
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
index 1a96c3c..b8aee07 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
@@ -1,71 +1,33 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2004
+ * Copyright (c) Linux Test Project, 2004-2017
  *
- *   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 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 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.
  */
 
 /*
- * NAME
- *	hugeshmget05.c
- *
  * DESCRIPTION
  *	hugeshmget05 - test for EACCES error
  *
- * ALGORITHM
- *	create a large shared memory segment with root only read & write
- *		permissions
- *	fork a child process
- *	if child
- *	  set the ID of the child process to that of "nobody"
- *	  loop if that option was specified
- *	    call shmget() using the TEST() macro
- *	    check the errno value
- *	      issue a PASS message if we get EACCES
- *	    otherwise, the tests fails
- *	      issue a FAIL message
- *	  call cleanup
- *	if parent
- *	  wait for child to exit
- *	  remove the shared memory segment
- *
- * USAGE:  <for command-line>
- *  hugeshmget05 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *	04/2004 - Updated by Robbie Williamson
- *
- * RESTRICTIONS
- *	test must be run at root
  */
 
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <limits.h>
 #include "hugetlb.h"
-#include "safe_macros.h"
 #include "mem.h"
-
-char *TCID = "hugeshmget05";
-int TST_TOTAL = 1;
+#include "hugetlb.h"
 
 static size_t shm_size;
 static int shm_id_1 = -1;
@@ -73,95 +35,82 @@
 static char *ltp_user = "nobody";
 
 static long hugepages = 128;
-static option_t options[] = {
-	{"s:", &sflag, &nr_opt},
+static struct tst_option options[] = {
+	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
 };
 
 static void do_child(void);
 
-int main(int ac, char **av)
+static void test_hugeshmget(void)
 {
 	pid_t pid;
 	int status;
 
-	tst_parse_opts(ac, av, options, NULL);
-
-	if (sflag)
-		hugepages = SAFE_STRTOL(NULL, nr_opt, 0, LONG_MAX);
-
-	setup();
-
 	switch (pid = fork()) {
 	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
+		tst_brk(TBROK | TERRNO, "fork");
 	case 0:
 		/* set the user ID of the child to the non root user */
 		if (setuid(ltp_uid) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "setuid");
+			tst_brk(TBROK | TERRNO, "setuid");
 		do_child();
-		tst_exit();
+		exit(0);
 	default:
 		/* wait for the child to return */
 		if (waitpid(pid, &status, 0) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+			tst_brk(TBROK | TERRNO, "waitpid");
 	}
-	cleanup();
-	tst_exit();
 }
 
 static void do_child(void)
 {
-	int lc;
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		TEST(shmget(shmkey, shm_size, SHM_HUGETLB | SHM_RW));
-		if (TEST_RETURN != -1) {
-			tst_resm(TFAIL, "shmget succeeded unexpectedly");
-			continue;
-		}
-		if (TEST_ERRNO == EACCES)
-			tst_resm(TPASS | TTERRNO, "shmget failed as expected");
-		else
-			tst_resm(TFAIL | TTERRNO, "shmget failed unexpectedly "
-				 "- expect errno=EACCES, got");
+	TEST(shmget(shmkey, shm_size, SHM_HUGETLB | SHM_RW));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "shmget succeeded unexpectedly");
+		return;
 	}
+	if (TEST_ERRNO == EACCES)
+		tst_res(TPASS | TTERRNO, "shmget failed as expected");
+	else
+		tst_res(TFAIL | TTERRNO, "shmget failed unexpectedly "
+				"- expect errno=EACCES, got");
 }
 
 void setup(void)
 {
 	long hpage_size;
 
-	tst_require_root();
 	check_hugepage();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	tst_tmpdir();
+	if (nr_opt)
+		hugepages = SAFE_STRTOL(nr_opt, 0, LONG_MAX);
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
 	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 
 	shm_size = hpage_size * hugepages / 2;
 	update_shm_size(&shm_size);
-	shmkey = getipckey(cleanup);
+	shmkey = getipckey();
 	shm_id_1 = shmget(shmkey, shm_size,
 			  SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
 	if (shm_id_1 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget #setup");
+		tst_brk(TBROK | TERRNO, "shmget #setup");
 
 	/* get the userid for a non-root user */
-	ltp_uid = getuserid(cleanup, ltp_user);
-
-	TEST_PAUSE;
+	ltp_uid = getuserid(ltp_user);
 }
 
 void cleanup(void)
 {
 	rm_shm(shm_id_1);
-
 	set_sys_tune("nr_hugepages", orig_hugepages, 0);
-
-	tst_rmdir();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_hugeshmget,
+};
diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.c b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
index 4a9d489..7afc7d4 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.c
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
@@ -32,6 +32,7 @@
  *	rm_shm()
  */
 
+#define TST_NO_DEFAULT_MAIN
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
@@ -42,14 +43,14 @@
 void check_hugepage(void)
 {
 	if (access(PATH_HUGEPAGES, F_OK))
-		tst_brkm(TCONF, NULL, "Huge page is not supported.");
+		tst_brk(TCONF, "Huge page is not supported.");
 }
 
 /*
  * getipckey() - generates and returns a message key used by the "get"
  *		 calls to create an IPC resource.
  */
-int getipckey(void (*cleanup_fn) (void))
+int getipckey(void)
 {
 	const char a = 'a';
 	int ascii_a = (int)a;
@@ -60,7 +61,7 @@
 
 	curdir = getcwd(curdir, size);
 	if (curdir == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "getcwd(curdir)");
+		tst_brk(TBROK | TERRNO, "getcwd(curdir)");
 
 	/*
 	 * Get a Sys V IPC key
@@ -79,7 +80,7 @@
 
 	ipc_key = ftok(curdir, ascii_a + random() % 26);
 	if (ipc_key == -1)
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "ftok");
+		tst_brk(TBROK | TERRNO, __func__);
 
 	return ipc_key;
 }
@@ -87,13 +88,13 @@
 /*
  * getuserid() - return the integer value for the "user" id
  */
-int getuserid(void (*cleanup_fn) (void), char *user)
+int getuserid(char *user)
 {
 	struct passwd *ent;
 
 	ent = getpwnam(user);
 	if (ent == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "getpwnam");
+		tst_brk(TBROK | TERRNO, "getpwnam");
 
 	return ent->pw_uid;
 }
@@ -110,8 +111,8 @@
 	 * check for # of attaches ?
 	 */
 	if (shmctl(shm_id, IPC_RMID, NULL) == -1) {
-		tst_resm(TINFO, "WARNING: shared memory deletion failed.");
-		tst_resm(TINFO, "This could lead to IPC resource problems.");
-		tst_resm(TINFO, "id = %d", shm_id);
+		tst_res(TINFO, "WARNING: shared memory deletion failed.");
+		tst_res(TINFO, "This could lead to IPC resource problems.");
+		tst_res(TINFO, "id = %d", shm_id);
 	}
 }
diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.h b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
index 6b5c61e..c6d2016 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.h
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
@@ -24,11 +24,13 @@
 #ifndef __HUGETLB_H
 #define __HUGETLB_H
 
+#include <stdlib.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 #include <errno.h>
 #include <sys/wait.h>
-#include "test.h"
+#include "tst_test.h"
+#include "old_tmpdir.h"
 
 #define SHM_RD	0400
 #define SHM_WR	0200
@@ -49,12 +51,12 @@
 
 void check_hugepage(void);
 
-int getipckey(void (*cleanup_fn) (void));
-int getuserid(void (*cleanup_fn) (void), char *user);
+int getipckey(void);
+int getuserid(char *user);
 void rm_shm(int shm_id);
 
 char *nr_opt;
-int sflag;
+char *Hopt;
 long orig_hugepages;
 
 #endif /* hugetlb.h */
diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
index f9522a5..287f8b3 100644
--- a/testcases/kernel/mem/include/mem.h
+++ b/testcases/kernel/mem/include/mem.h
@@ -1,7 +1,7 @@
 #ifndef _MEM_H
 #define _MEM_H
 #include "config.h"
-#include "test.h"
+#include "tst_test.h"
 
 #if defined(__powerpc__) || defined(__powerpc64__)
 #define MAXNODES		256
@@ -44,6 +44,7 @@
 
 #define PATH_KSM		"/sys/kernel/mm/ksm/"
 
+void create_same_memory(int size, int num, int unit);
 void save_max_page_sharing(void);
 void restore_max_page_sharing(void);
 void test_ksm_merge_across_nodes(unsigned long nr_pages);
@@ -58,11 +59,6 @@
 #define PATH_SHMMAX		"/proc/sys/kernel/shmmax"
 
 void write_memcg(void);
-void create_same_memory(int size, int num, int unit);
-int  opt_num, opt_size, opt_unit;
-char *opt_numstr, *opt_sizestr, *opt_unitstr;
-void check_ksm_options(int *size, int *num, int *unit);
-void ksm_usage(void);
 
 /* cpuset/memcg */
 
@@ -84,16 +80,13 @@
 void umount_mem(char *path, char *path_new);
 
 /* shared */
-unsigned int get_a_numa_node(void (*cleanup_fn)(void));
+unsigned int get_a_numa_node(void);
 int  path_exist(const char *path, ...);
-long read_meminfo(char *item);
 void set_sys_tune(char *sys_file, long tune, int check);
 long get_sys_tune(char *sys_file);
-void cleanup(void);
-void setup(void);
 
 void update_shm_size(size_t *shm_size);
 
 /* MMAP */
-int range_is_mapped(void (*cleanup_fn) (void), unsigned long low, unsigned long high);
+int range_is_mapped(unsigned long low, unsigned long high);
 #endif
diff --git a/testcases/kernel/mem/ksm/ksm01.c b/testcases/kernel/mem/ksm/ksm01.c
index 824881c..ce96983 100644
--- a/testcases/kernel/mem/ksm/ksm01.c
+++ b/testcases/kernel/mem/ksm/ksm01.c
@@ -1,4 +1,16 @@
 /*
+ * Copyright (C) 2010-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
  * Kernel Samepage Merging (KSM)
  *
  * Basic tests were to start several programs with same and different
@@ -31,28 +43,6 @@
  * - Change run setting to 2 - unmerging.
  * - Check ksm statistics and verify the content.
  * - Change run setting to 0 - stop.
- *
- * Copyright (C) 2010  Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
  */
 
 #include <sys/types.h>
@@ -66,48 +56,23 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "test.h"
 #include "mem.h"
+#include "ksm_common.h"
 
-char *TCID = "ksm01";
-int TST_TOTAL = 1;
-
-static int merge_across_nodes;
-
-option_t ksm_options[] = {
-	{"n:", &opt_num, &opt_numstr},
-	{"s:", &opt_size, &opt_sizestr},
-	{"u:", &opt_unit, &opt_unitstr},
-	{NULL, NULL, NULL}
-};
-
-int main(int argc, char *argv[])
+static void verify_ksm(void)
 {
-	int lc;
-	int size = 128, num = 3, unit = 1;
-
-	tst_parse_opts(argc, argv, ksm_options, ksm_usage);
-	setup();
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		check_ksm_options(&size, &num, &unit);
-		create_same_memory(size, num, unit);
-	}
-	cleanup();
-	tst_exit();
+	create_same_memory(size, num, unit);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-
-	if (tst_kvercmp(2, 6, 32) < 0)
-		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
 	if (access(PATH_KSM, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "KSM configuration is not enabled");
+		tst_brk(TCONF, "KSM configuration is not enabled");
 
 	save_max_page_sharing();
 
+	parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);
+
 	/*
 	 * kernel commit 90bd6fd introduced a new KSM sysfs knob
 	 * /sys/kernel/mm/ksm/merge_across_nodes, setting it to '0'
@@ -116,16 +81,13 @@
 	 * it is enabled before testing.
 	 */
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0) {
-		SAFE_FILE_SCANF(NULL, PATH_KSM "merge_across_nodes",
+		SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",
 				"%d", &merge_across_nodes);
-		SAFE_FILE_PRINTF(NULL, PATH_KSM "merge_across_nodes", "1");
+		SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1");
 	}
-
-	tst_sig(FORK, DEF_HANDLER, NULL);
-	TEST_PAUSE;
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
 		FILE_PRINTF(PATH_KSM "merge_across_nodes",
@@ -133,3 +95,13 @@
 
 	restore_max_page_sharing();
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.options = ksm_options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_ksm,
+	.min_kver = "2.6.32",
+};
diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c
index 6274f8a..6fe75d3 100644
--- a/testcases/kernel/mem/ksm/ksm02.c
+++ b/testcases/kernel/mem/ksm/ksm02.c
@@ -1,5 +1,17 @@
 /*
- * Kernel Samepage Merging (KSM) for NUMA
+ * Copyright (C) 2010-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Kernel Samepage Merging (KSM)
  *
  * Basic tests were to start several programs with same and different
  * memory contents and ensure only to merge the ones with the same
@@ -31,28 +43,6 @@
  * - Change run setting to 2 - unmerging.
  * - Check ksm statistics and verify the content.
  * - Change run setting to 0 - stop.
- *
- * Copyright (C) 2010  Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
  */
 
 #include "config.h"
@@ -66,60 +56,34 @@
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
-#include "test.h"
 #include "mem.h"
-
-char *TCID = "ksm02";
-int TST_TOTAL = 1;
-
-static int merge_across_nodes;
+#include "ksm_common.h"
 
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
-option_t ksm_options[] = {
-	{"n:", &opt_num, &opt_numstr},
-	{"s:", &opt_size, &opt_sizestr},
-	{"u:", &opt_unit, &opt_unitstr},
-	{NULL, NULL, NULL}
-};
 
-int main(int argc, char *argv[])
+static void verify_ksm(void)
 {
-	int lc;
-	int size = 128, num = 3, unit = 1;
 	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
 	unsigned int node;
 
-	tst_parse_opts(argc, argv, ksm_options, ksm_usage);
-
-	node = get_a_numa_node(tst_exit);
+	node = get_a_numa_node();
 	set_node(nmask, node);
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		check_ksm_options(&size, &num, &unit);
-
-		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) {
-			if (errno != ENOSYS)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "set_mempolicy");
-			else
-				tst_brkm(TCONF, cleanup,
-					 "set_mempolicy syscall is not "
-					 "implemented on your system.");
-		}
-		create_same_memory(size, num, unit);
-
-		write_cpusets(node);
-		create_same_memory(size, num, unit);
+	if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) {
+		if (errno != ENOSYS)
+			tst_brk(TBROK | TERRNO, "set_mempolicy");
+		else
+			tst_brk(TCONF, "set_mempolicy syscall is not "
+				 "implemented on your system.");
 	}
-	cleanup();
-	tst_exit();
+	create_same_memory(size, num, unit);
+
+	write_cpusets(node);
+	create_same_memory(size, num, unit);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
 		FILE_PRINTF(PATH_KSM "merge_across_nodes",
@@ -130,30 +94,33 @@
 	umount_mem(CPATH, CPATH_NEW);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-
-	if (tst_kvercmp(2, 6, 32) < 0)
-		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
 	if (access(PATH_KSM, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "KSM configuration is not enabled");
+		tst_brk(TCONF, "KSM configuration is not enabled");
 	save_max_page_sharing();
 
+	parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);
+
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0) {
-		SAFE_FILE_SCANF(NULL, PATH_KSM "merge_across_nodes",
+		SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",
 				"%d", &merge_across_nodes);
-		SAFE_FILE_PRINTF(NULL, PATH_KSM "merge_across_nodes", "1");
+		SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1");
 	}
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
 	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
 }
 
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.options = ksm_options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_ksm,
+	.min_kver = "2.6.32",
+};
+
 #else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/ksm/ksm03.c b/testcases/kernel/mem/ksm/ksm03.c
index 979222a..51cc923 100644
--- a/testcases/kernel/mem/ksm/ksm03.c
+++ b/testcases/kernel/mem/ksm/ksm03.c
@@ -1,4 +1,16 @@
 /*
+ * Copyright (C) 2010-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
  * Kernel Samepage Merging (KSM) for Memory Resource Controller
  *
  * Basic tests were to start several programs with same and different
@@ -31,28 +43,6 @@
  * - Change run setting to 2 - unmerging.
  * - Check ksm statistics and verify the content.
  * - Change run setting to 0 - stop.
- *
- * Copyright (C) 2010  Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
  */
 
 #include <sys/types.h>
@@ -66,61 +56,32 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "test.h"
 #include "mem.h"
+#include "ksm_common.h"
 
-char *TCID = "ksm03";
-int TST_TOTAL = 1;
-
-static int merge_across_nodes;
-
-option_t ksm_options[] = {
-	{"n:", &opt_num, &opt_numstr},
-	{"s:", &opt_size, &opt_sizestr},
-	{"u:", &opt_unit, &opt_unitstr},
-	{NULL, NULL, NULL}
-};
-
-int main(int argc, char *argv[])
+static void verify_ksm(void)
 {
-	int lc;
-	int size = 128, num = 3, unit = 1;
-
-	tst_parse_opts(argc, argv, ksm_options, ksm_usage);
-	setup();
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		check_ksm_options(&size, &num, &unit);
-		write_memcg();
-		create_same_memory(size, num, unit);
-	}
-	cleanup();
-	tst_exit();
+	write_memcg();
+	create_same_memory(size, num, unit);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-
-	if (tst_kvercmp(2, 6, 32) < 0)
-		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
 	if (access(PATH_KSM, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "KSM configuration is not enabled");
+		tst_brk(TCONF, "KSM configuration is not enabled");
 
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0) {
-		SAFE_FILE_SCANF(NULL, PATH_KSM "merge_across_nodes",
+		SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",
 				"%d", &merge_across_nodes);
-		SAFE_FILE_PRINTF(NULL, PATH_KSM "merge_across_nodes", "1");
+		SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1");
 	}
 
 	save_max_page_sharing();
-
+	parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);
 	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
-	tst_sig(FORK, DEF_HANDLER, NULL);
-	TEST_PAUSE;
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
 		FILE_PRINTF(PATH_KSM "merge_across_nodes",
@@ -130,3 +91,13 @@
 
 	umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.options = ksm_options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_ksm,
+	.min_kver = "2.6.32",
+};
diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c
index 4beeed6..1c8bf20 100644
--- a/testcases/kernel/mem/ksm/ksm04.c
+++ b/testcases/kernel/mem/ksm/ksm04.c
@@ -1,4 +1,16 @@
 /*
+ * Copyright (C) 2010-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
  * Kernel Samepage Merging (KSM) for Memory Resource Controller and NUMA
  *
  * Basic tests were to start several programs with same and different
@@ -31,28 +43,6 @@
  * - Change run setting to 2 - unmerging.
  * - Check ksm statistics and verify the content.
  * - Change run setting to 0 - stop.
- *
- * Copyright (C) 2010  Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
  */
 
 #include "config.h"
@@ -66,62 +56,36 @@
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
-#include "test.h"
 #include "mem.h"
-
-char *TCID = "ksm04";
-int TST_TOTAL = 1;
-
-static int merge_across_nodes;
+#include "ksm_common.h"
 
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
-option_t ksm_options[] = {
-	{"n:", &opt_num, &opt_numstr},
-	{"s:", &opt_size, &opt_sizestr},
-	{"u:", &opt_unit, &opt_unitstr},
-	{NULL, NULL, NULL}
-};
 
-int main(int argc, char *argv[])
+static void verify_ksm(void)
 {
-	int lc;
-	int size = 128, num = 3, unit = 1;
 	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
 	unsigned int node;
 
-	tst_parse_opts(argc, argv, ksm_options, ksm_usage);
-
-	node = get_a_numa_node(tst_exit);
+	node = get_a_numa_node();
 	set_node(nmask, node);
 
-	setup();
+	write_memcg();
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		check_ksm_options(&size, &num, &unit);
-
-		write_memcg();
-
-		if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) {
-			if (errno != ENOSYS)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "set_mempolicy");
-			else
-				tst_brkm(TCONF, cleanup,
-					 "set_mempolicy syscall is not "
-					 "implemented on your system.");
-		}
-		create_same_memory(size, num, unit);
-
-		write_cpusets(node);
-		create_same_memory(size, num, unit);
+	if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) {
+		if (errno != ENOSYS)
+			tst_brk(TBROK | TERRNO, "set_mempolicy");
+		else
+			tst_brk(TCONF, "set_mempolicy syscall is not "
+					"implemented on your system.");
 	}
-	cleanup();
-	tst_exit();
+	create_same_memory(size, num, unit);
+
+	write_cpusets(node);
+	create_same_memory(size, num, unit);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0)
 		FILE_PRINTF(PATH_KSM "merge_across_nodes",
@@ -133,32 +97,34 @@
 	umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-
-	if (tst_kvercmp(2, 6, 32) < 0)
-		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required");
 	if (access(PATH_KSM, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "KSM configuration is not enabled");
+		tst_brk(TCONF, "KSM configuration is not enabled");
 
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == 0) {
-		SAFE_FILE_SCANF(NULL, PATH_KSM "merge_across_nodes",
+		SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",
 				"%d", &merge_across_nodes);
-		SAFE_FILE_PRINTF(NULL, PATH_KSM "merge_across_nodes", "1");
+		SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1");
 	}
 
 	save_max_page_sharing();
+	parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
 	mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW);
 	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
 }
 
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.options = ksm_options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_ksm,
+	.min_kver = "2.6.32",
+};
+
 #else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/ksm/ksm05.c b/testcases/kernel/mem/ksm/ksm05.c
index 59b2683..f3bfbf4 100644
--- a/testcases/kernel/mem/ksm/ksm05.c
+++ b/testcases/kernel/mem/ksm/ksm05.c
@@ -1,4 +1,16 @@
 /*
+ * Copyright (C) 2011-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
  * KSM - NULL pointer dereference in ksm_do_scan() (CVE-2011-2183)
  *
  * This is a testcase from upstream commit:
@@ -29,94 +41,50 @@
  * *) ksm and ksmtuned daemons need to be disabled. Otherwise, it could
  *    distrub the testing as they also change some ksm tunables depends
  *    on current workloads.
- *
- * Copyright (C) 2011  Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
  */
 
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
 #include <sys/wait.h>
-#include <errno.h>
-#include <fcntl.h>
 #include <signal.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include "test.h"
+#include <errno.h>
+#include "tst_test.h"
 #include "mem.h"
 
-char *TCID = "ksm05";
-int TST_TOTAL = 1;
-
 #ifdef HAVE_MADV_MERGEABLE
 
 static int ksm_run_orig;
-
 static void sighandler(int sig);
 
-int main(int argc, char *argv[])
+static void test_ksm(void)
 {
-	int lc, status, ret;
+	int status;
 	long ps;
 	pid_t pid;
 	void *ptr;
+	struct sigaction sa;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	memset (&sa, '\0', sizeof(sa));
+	sa.sa_handler = sighandler;
+	sa.sa_flags = 0;
+	TEST(sigaction(SIGSEGV, &sa, NULL));
+	if (TEST_RETURN == -1)
+		tst_brk(TBROK | TRERRNO,
+				"SIGSEGV signal setup failed");
 
 	ps = sysconf(_SC_PAGESIZE);
-	setup();
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		switch (pid = fork()) {
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork");
-		case 0:
-			ret = posix_memalign(&ptr, ps, ps);
-			if (ret) {
-				tst_brkm(TBROK, cleanup, "posix_memalign(): %s",
-				         tst_strerrno(ret));
-			}
-			if (madvise(ptr, ps, MADV_MERGEABLE) < 0)
-				tst_brkm(TBROK | TERRNO, cleanup, "madvise");
-			*(char *)NULL = 0;	/* SIGSEGV occurs as expected. */
-			exit(0);
-		default:
-			break;
-		}
-		if (waitpid(pid, &status, WUNTRACED | WCONTINUED) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
-		if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
-			tst_brkm(TBROK, cleanup,
-				 "invalid signal received: %d", status);
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		ptr = SAFE_MEMALIGN(ps, ps);
+		if (madvise(ptr, ps, MADV_MERGEABLE) < 0)
+			tst_brk(TBROK | TERRNO, "madvise");
+		*(char *)NULL = 0;	/* SIGSEGV occurs as expected. */
 	}
+	SAFE_WAITPID(pid, &status, WUNTRACED | WCONTINUED);
+	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+		tst_brk(TBROK, "invalid signal received: %d", status);
 
-	tst_resm(TPASS, "still alive.");
-	cleanup();
-	tst_exit();
+	tst_res(TPASS, "still alive.");
 }
 
 static void sighandler(int sig)
@@ -124,35 +92,33 @@
 	_exit((sig == SIGSEGV) ? 0 : sig);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-
-	if (tst_kvercmp(2, 6, 32) < 0)
-		tst_brkm(TCONF, NULL, "2.6.32 or greater kernel required.");
-
 	if (access(PATH_KSM, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "KSM configuration is not enabled");
-
-	tst_sig(FORK, sighandler, cleanup);
-
-	TEST_PAUSE;
+		tst_brk(TCONF, "KSM configuration is not enabled");
 
 	/* save original /sys/kernel/mm/ksm/run value */
-	SAFE_FILE_SCANF(NULL, PATH_KSM "run", "%d", &ksm_run_orig);
+	SAFE_FILE_SCANF(PATH_KSM "run", "%d", &ksm_run_orig);
 
 	/* echo 1 > /sys/kernel/mm/ksm/run */
-	SAFE_FILE_PRINTF(NULL, PATH_KSM "run", "1");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "1");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	/* restore /sys/kernel/mm/ksm/run value */
 	FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_ksm,
+	.min_kver = "2.6.32",
+};
+
 #else
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no MADV_MERGEABLE found.");
-}
+	TST_TEST_TCONF("no MADV_MERGEABLE found.");
 #endif
diff --git a/testcases/kernel/mem/ksm/ksm06.c b/testcases/kernel/mem/ksm/ksm06.c
index 2092746..334a048 100644
--- a/testcases/kernel/mem/ksm/ksm06.c
+++ b/testcases/kernel/mem/ksm/ksm06.c
@@ -1,25 +1,15 @@
 /*
- * Copyright (C) 2013 Linux Test Project
+ * Copyright (C) 2013-2017  Red Hat, Inc.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * 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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * 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.
  */
 
 /*
@@ -35,6 +25,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <limits.h>
 #include <errno.h>
 #include <fcntl.h>
 #if HAVE_NUMAIF_H
@@ -43,93 +34,77 @@
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <limits.h>
 #include "numa_helper.h"
-#include "test.h"
-#include "safe_macros.h"
 #include "mem.h"
 
-char *TCID = "ksm06";
-int TST_TOTAL = 1;
-
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 
-static int run;
-static int sleep_millisecs;
-static int merge_across_nodes;
-static int n_flag;
+static int run = -1;
+static int sleep_millisecs = -1;
+static int merge_across_nodes = -1;
 static unsigned long nr_pages;
 
 static char *n_opt;
-option_t options[] = {
-	{ "n:", &n_flag, &n_opt },
-	{ NULL, NULL, NULL }
+static struct tst_option ksm_options[] = {
+	{"n:", &n_opt,  "-n x    Allocate x pages memory per node"},
+	{NULL, NULL, NULL}
 };
-static void usage(void);
 
-int main(int argc, char *argv[])
+static void test_ksm(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, options, &usage);
-
-	if (n_flag)
-		nr_pages = SAFE_STRTOUL(NULL, n_opt, 0, ULONG_MAX);
+	if (n_opt)
+		nr_pages = SAFE_STRTOUL(n_opt, 0, ULONG_MAX);
 	else
 		nr_pages = 100;
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		test_ksm_merge_across_nodes(nr_pages);
-	}
-
-	cleanup();
-	tst_exit();
+	test_ksm_merge_across_nodes(nr_pages);
 }
 
-void setup(void)
+static void setup(void)
 {
 	if (access(PATH_KSM "merge_across_nodes", F_OK) == -1)
-		tst_brkm(TCONF, NULL, "no merge_across_nodes sysfs knob");
-
-	if (!is_numa(NULL, NH_MEMS, 2))
-		tst_brkm(TCONF, NULL, "The case needs a NUMA system.");
-
-	/* save the current value */
-	SAFE_FILE_SCANF(NULL, PATH_KSM "run", "%d", &run);
-	SAFE_FILE_SCANF(NULL, PATH_KSM "merge_across_nodes",
-			"%d", &merge_across_nodes);
-	SAFE_FILE_SCANF(NULL, PATH_KSM "sleep_millisecs",
-			"%d", &sleep_millisecs);
+		tst_brk(TCONF, "no merge_across_nodes sysfs knob");
 
 	save_max_page_sharing();
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
+	if (!is_numa(NULL, NH_MEMS, 2))
+		tst_brk(TCONF, "The case needs a NUMA system.");
+
+	/* save the current value */
+	SAFE_FILE_SCANF(PATH_KSM "run", "%d", &run);
+	SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",
+			"%d", &merge_across_nodes);
+	SAFE_FILE_SCANF(PATH_KSM "sleep_millisecs",
+			"%d", &sleep_millisecs);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	FILE_PRINTF(PATH_KSM "merge_across_nodes",
-			 "%d", merge_across_nodes);
-	FILE_PRINTF(PATH_KSM "sleep_millisecs",
-			 "%d", sleep_millisecs);
-	FILE_PRINTF(PATH_KSM "run", "%d", run);
+	if (merge_across_nodes != -1) {
+		FILE_PRINTF(PATH_KSM "merge_across_nodes",
+			    "%d", merge_across_nodes);
+	}
+
+	if (sleep_millisecs != -1)
+		FILE_PRINTF(PATH_KSM "sleep_millisecs", "%d", sleep_millisecs);
+
+	if (run != -1)
+		FILE_PRINTF(PATH_KSM "run", "%d", run);
 
 	restore_max_page_sharing();
 }
 
-static void usage(void)
-{
-	printf("  -n x    Allocate x pages memory per node\n");
-}
+static struct tst_test test = {
+	.tid = "ksm06",
+	.needs_root = 1,
+	.options = ksm_options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_ksm,
+};
 
 #else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/ksm/ksm_common.h b/testcases/kernel/mem/ksm/ksm_common.h
new file mode 100644
index 0000000..6a682d0
--- /dev/null
+++ b/testcases/kernel/mem/ksm/ksm_common.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017  Red Hat, Inc.
+ *
+ * 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.
+ */
+
+ /*
+  * Parse the ksm0* test options in funcion parse_ksm_options().
+  */
+
+#include "tst_test.h"
+
+int merge_across_nodes;
+
+int size = 128, num = 3, unit = 1;
+char *opt_sizestr, *opt_numstr, *opt_unitstr;
+
+struct tst_option ksm_options[] = {
+	{"n:", &opt_numstr,  "-n       Number of processes"},
+	{"s:", &opt_sizestr, "-s       Memory allocation size in MB"},
+	{"u:", &opt_unitstr, "-u       Memory allocation unit in MB"},
+	{NULL, NULL, NULL}
+};
+
+static inline void parse_ksm_options(char *str_size, int *size,
+		char *str_num, int *num, char *str_unit, int *unit)
+{
+	if(tst_parse_int(str_size, size, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid size '%s'", str_size);
+
+	if(tst_parse_int(str_num, num, 3, INT_MAX))
+		tst_brk(TBROK, "Invalid num '%s'", str_num);
+
+	if(tst_parse_int(str_unit, unit, 1, *size))
+		tst_brk(TBROK, "Invalid unit '%s'", str_unit);
+	if (*size % *unit != 0)
+		tst_brk(TBROK,
+				"the remainder of division of size by unit is "
+				"not zero.");
+}
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 7e403b5..f4d12e0 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -1,9 +1,12 @@
+#define TST_NO_DEFAULT_MAIN
+
 #include "config.h"
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
+#include <sys/param.h>
 #include <errno.h>
 #include <fcntl.h>
 #if HAVE_NUMA_H
@@ -16,10 +19,9 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <unistd.h>
 
-#include "test.h"
-#include "safe_macros.h"
 #include "mem.h"
 #include "numa_helper.h"
 
@@ -31,7 +33,7 @@
 	long i, pagesz = getpagesize();
 	int loop = 10;
 
-	tst_resm(TINFO, "thread (%lx), allocating %ld bytes.",
+	tst_res(TINFO, "thread (%lx), allocating %ld bytes.",
 		(unsigned long) pthread_self(), length);
 
 	s = mmap(NULL, length, PROT_READ | PROT_WRITE,
@@ -80,7 +82,7 @@
 
 	th = malloc(sizeof(pthread_t) * threads);
 	if (!th) {
-		tst_resm(TINFO | TERRNO, "malloc");
+		tst_res(TINFO | TERRNO, "malloc");
 		goto out;
 	}
 
@@ -88,7 +90,7 @@
 		TEST(pthread_create(&th[i], NULL, child_alloc_thread,
 			(void *)((long)testcase)));
 		if (TEST_RETURN) {
-			tst_resm(TINFO | TRERRNO, "pthread_create");
+			tst_res(TINFO | TRERRNO, "pthread_create");
 			/*
 			 * Keep going if thread other than first fails to
 			 * spawn due to lack of resources.
@@ -125,13 +127,7 @@
 	pid_t pid;
 	int status, threads;
 
-	switch (pid = fork()) {
-	case -1:
-		if (errno == retcode) {
-			tst_resm(TPASS | TERRNO, "fork");
-			return;
-		}
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
+	switch (pid = SAFE_FORK()) {
 	case 0:
 		threads = MAX(1, tst_ncpus() - 1);
 		child_alloc(testcase, lite, threads);
@@ -139,31 +135,30 @@
 		break;
 	}
 
-	tst_resm(TINFO, "expected victim is %d.", pid);
-	if (waitpid(-1, &status, 0) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+	tst_res(TINFO, "expected victim is %d.", pid);
+	SAFE_WAITPID(-1, &status, 0);
 
 	if (WIFSIGNALED(status)) {
 		if (allow_sigkill && WTERMSIG(status) == SIGKILL) {
-			tst_resm(TPASS, "victim signalled: (%d) %s",
+			tst_res(TPASS, "victim signalled: (%d) %s",
 				SIGKILL,
 				tst_strsig(SIGKILL));
 		} else {
-			tst_resm(TFAIL, "victim signalled: (%d) %s",
+			tst_res(TFAIL, "victim signalled: (%d) %s",
 				WTERMSIG(status),
 				tst_strsig(WTERMSIG(status)));
 		}
 	} else if (WIFEXITED(status)) {
 		if (WEXITSTATUS(status) == retcode) {
-			tst_resm(TPASS, "victim retcode: (%d) %s",
+			tst_res(TPASS, "victim retcode: (%d) %s",
 				retcode, strerror(retcode));
 		} else {
-			tst_resm(TFAIL, "victim unexpectedly ended with "
+			tst_res(TFAIL, "victim unexpectedly ended with "
 				"retcode: %d, expected: %d",
 				WEXITSTATUS(status), retcode);
 		}
 	} else {
-		tst_resm(TFAIL, "victim unexpectedly ended");
+		tst_res(TFAIL, "victim unexpectedly ended");
 	}
 }
 
@@ -178,10 +173,9 @@
 	if (mempolicy) {
 		ret = get_allowed_nodes_arr(NH_MEMS|NH_CPUS, &num_nodes, &nodes);
 		if (ret != 0)
-			tst_brkm(TBROK|TERRNO, cleanup,
-				 "get_allowed_nodes_arr");
+			tst_brk(TBROK|TERRNO, "get_allowed_nodes_arr");
 		if (num_nodes < 2) {
-			tst_resm(TINFO, "mempolicy need NUMA system support");
+			tst_res(TINFO, "mempolicy need NUMA system support");
 			free(nodes);
 			return;
 		}
@@ -193,7 +187,7 @@
 		case MPOL_INTERLEAVE:
 		case MPOL_PREFERRED:
 			if (num_nodes == 2) {
-				tst_resm(TINFO, "The mempolicy need "
+				tst_res(TINFO, "The mempolicy need "
 					 "more than 2 numa nodes");
 				free(nodes);
 				return;
@@ -204,10 +198,10 @@
 			}
 			break;
 		default:
-			tst_brkm(TBROK|TERRNO, cleanup, "Bad mempolicy mode");
+			tst_brk(TBROK|TERRNO, "Bad mempolicy mode");
 		}
 		if (set_mempolicy(mempolicy, nmask, MAXNODES) == -1)
-			tst_brkm(TBROK|TERRNO, cleanup, "set_mempolicy");
+			tst_brk(TBROK|TERRNO, "set_mempolicy");
 	}
 #endif
 }
@@ -218,10 +212,10 @@
 
 	set_global_mempolicy(mempolicy);
 
-	tst_resm(TINFO, "start normal OOM testing.");
+	tst_res(TINFO, "start normal OOM testing.");
 	oom(NORMAL, lite, retcode, allow_sigkill);
 
-	tst_resm(TINFO, "start OOM testing for mlocked pages.");
+	tst_res(TINFO, "start OOM testing for mlocked pages.");
 	oom(MLOCK, lite, retcode, allow_sigkill);
 
 	/*
@@ -229,14 +223,14 @@
 	 * run to run, which isn't reliable for oom03 cgroup test.
 	 */
 	if (access(PATH_KSM, F_OK) == -1 || lite == 1) {
-		tst_resm(TINFO, "KSM is not configed or lite == 1, "
+		tst_res(TINFO, "KSM is not configed or lite == 1, "
 			 "skip OOM test for KSM pags");
 	} else {
-		tst_resm(TINFO, "start OOM testing for KSM pages.");
-		SAFE_FILE_SCANF(cleanup, PATH_KSM "run", "%d", &ksm_run_orig);
-		SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");
+		tst_res(TINFO, "start OOM testing for KSM pages.");
+		SAFE_FILE_SCANF(PATH_KSM "run", "%d", &ksm_run_orig);
+		SAFE_FILE_PRINTF(PATH_KSM "run", "1");
 		oom(KSM, lite, retcode, allow_sigkill);
-		SAFE_FILE_PRINTF(cleanup,PATH_KSM "run", "%d", ksm_run_orig);
+		SAFE_FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
 	}
 }
 
@@ -247,8 +241,8 @@
 void save_max_page_sharing(void)
 {
 	if (access(PATH_KSM "max_page_sharing", F_OK) == 0)
-	        SAFE_FILE_SCANF(NULL, PATH_KSM "max_page_sharing",
-	                        "%d", &max_page_sharing);
+		SAFE_FILE_SCANF(PATH_KSM "max_page_sharing",
+				"%d", &max_page_sharing);
 }
 
 void restore_max_page_sharing(void)
@@ -264,61 +258,47 @@
 	long actual_val;
 
 	snprintf(fullpath, BUFSIZ, PATH_KSM "%s", path);
-	SAFE_FILE_SCANF(cleanup, fullpath, "%ld", &actual_val);
+	SAFE_FILE_SCANF(fullpath, "%ld", &actual_val);
 
-	tst_resm(TINFO, "%s is %ld.", path, actual_val);
 	if (actual_val != value)
-		tst_resm(TFAIL, "%s is not %ld.", path, value);
+		tst_res(TFAIL, "%s is not %ld but %ld.", path, value,
+			actual_val);
+	else
+		tst_res(TPASS, "%s is %ld.", path, actual_val);
 }
 
-static void wait_ksmd_done(void)
+static void wait_ksmd_full_scan(void)
 {
-	long pages_shared, pages_sharing, pages_volatile, pages_unshared;
-	long old_pages_shared = 0, old_pages_sharing = 0;
-	long old_pages_volatile = 0, old_pages_unshared = 0;
-	int changing = 1, count = 0;
+	unsigned long full_scans, at_least_one_full_scan;
+	int count = 0;
 
-	while (changing) {
-		sleep(10);
+	SAFE_FILE_SCANF(PATH_KSM "full_scans", "%lu", &full_scans);
+	/*
+	 * The current scan is already in progress so we can't guarantee that
+	 * the get_user_pages() is called on every existing rmap_item if we
+	 * only waited for the remaining part of the scan.
+	 *
+	 * The actual merging happens after the unstable tree has been built so
+	 * we need to wait at least two full scans to guarantee merging, hence
+	 * wait full_scans to increment by 3 so that at least two full scans
+	 * will run.
+	 */
+	at_least_one_full_scan = full_scans + 3;
+	while (full_scans < at_least_one_full_scan) {
+		sleep(1);
 		count++;
-
-		SAFE_FILE_SCANF(cleanup, PATH_KSM "pages_shared",
-				"%ld", &pages_shared);
-
-		SAFE_FILE_SCANF(cleanup, PATH_KSM "pages_sharing",
-				"%ld", &pages_sharing);
-
-		SAFE_FILE_SCANF(cleanup, PATH_KSM "pages_volatile",
-				"%ld", &pages_volatile);
-
-		SAFE_FILE_SCANF(cleanup, PATH_KSM "pages_unshared",
-				"%ld", &pages_unshared);
-
-		if (pages_shared != old_pages_shared ||
-		    pages_sharing != old_pages_sharing ||
-		    pages_volatile != old_pages_volatile ||
-		    pages_unshared != old_pages_unshared) {
-			old_pages_shared = pages_shared;
-			old_pages_sharing = pages_sharing;
-			old_pages_volatile = pages_volatile;
-			old_pages_unshared = pages_unshared;
-		} else {
-			changing = 0;
-		}
+		SAFE_FILE_SCANF(PATH_KSM "full_scans", "%lu", &full_scans);
 	}
 
-	tst_resm(TINFO, "ksm daemon takes %ds to scan all mergeable pages",
-		 count * 10);
+	tst_res(TINFO, "ksm daemon takes %ds to run two full scans",
+		count);
 }
 
-static void group_check(int run, int pages_shared, int pages_sharing,
-			 int pages_volatile, int pages_unshared,
-			 int sleep_millisecs, int pages_to_scan)
+static void final_group_check(int run, int pages_shared, int pages_sharing,
+			  int pages_volatile, int pages_unshared,
+			  int sleep_millisecs, int pages_to_scan)
 {
-	/* wait for ksm daemon to scan all mergeable pages. */
-	wait_ksmd_done();
-
-	tst_resm(TINFO, "check!");
+	tst_res(TINFO, "check!");
 	check("run", run);
 	check("pages_shared", pages_shared);
 	check("pages_sharing", pages_sharing);
@@ -328,24 +308,38 @@
 	check("pages_to_scan", pages_to_scan);
 }
 
+static void group_check(int run, int pages_shared, int pages_sharing,
+			int pages_volatile, int pages_unshared,
+			int sleep_millisecs, int pages_to_scan)
+{
+	if (run != 1) {
+		tst_res(TFAIL, "group_check run is not 1, %d.", run);
+	} else {
+		/* wait for ksm daemon to scan all mergeable pages. */
+		wait_ksmd_full_scan();
+	}
+
+	final_group_check(run, pages_shared, pages_sharing,
+			  pages_volatile, pages_unshared,
+			  sleep_millisecs, pages_to_scan);
+}
+
 static void verify(char **memory, char value, int proc,
 		    int start, int end, int start2, int end2)
 {
 	int i, j;
 	void *s = NULL;
 
-	s = malloc((end - start) * (end2 - start2));
-	if (s == NULL)
-		tst_brkm(TBROK | TERRNO, tst_exit, "malloc");
+	s = SAFE_MALLOC((end - start) * (end2 - start2));
 
-	tst_resm(TINFO, "child %d verifies memory content.", proc);
+	tst_res(TINFO, "child %d verifies memory content.", proc);
 	memset(s, value, (end - start) * (end2 - start2));
 	if (memcmp(memory[start], s, (end - start) * (end2 - start2))
 	    != 0)
 		for (j = start; j < end; j++)
 			for (i = start2; i < end2; i++)
 				if (memory[j][i] != value)
-					tst_resm(TFAIL, "child %d has %c at "
+					tst_res(TFAIL, "child %d has %c at "
 						 "%d,%d,%d.",
 						 proc, memory[j][i], proc,
 						 j, i);
@@ -354,9 +348,9 @@
 
 void write_memcg(void)
 {
-	SAFE_FILE_PRINTF(NULL, MEMCG_LIMIT, "%ld", TESTMEM);
+	SAFE_FILE_PRINTF(MEMCG_LIMIT, "%ld", TESTMEM);
 
-	SAFE_FILE_PRINTF(NULL, MEMCG_PATH_NEW "/tasks", "%d", getpid());
+	SAFE_FILE_PRINTF(MEMCG_PATH_NEW "/tasks", "%d", getpid());
 }
 
 struct ksm_merge_data {
@@ -370,14 +364,14 @@
 	int i = 0, j;
 	int unit = size / total_unit;
 
-	tst_resm(TINFO, "child %d continues...", child_num);
+	tst_res(TINFO, "child %d continues...", child_num);
 
 	if (ksm_merge_data.mergeable_size == size * MB) {
-		tst_resm(TINFO, "child %d allocates %d MB filled with '%c'",
+		tst_res(TINFO, "child %d allocates %d MB filled with '%c'",
 			child_num, size, ksm_merge_data.data);
 
 	} else {
-		tst_resm(TINFO, "child %d allocates %d MB filled with '%c'"
+		tst_res(TINFO, "child %d allocates %d MB filled with '%c'"
 				" except one page with 'e'",
 				child_num, size, ksm_merge_data.data);
 	}
@@ -404,21 +398,19 @@
 	total_unit = size / unit;
 
 	/* Apply for the space for memory */
-	memory = malloc(total_unit * sizeof(char *));
+	memory = SAFE_MALLOC(total_unit * sizeof(char *));
 	for (j = 0; j < total_unit; j++) {
-		memory[j] = mmap(NULL, unit * MB, PROT_READ|PROT_WRITE,
+		memory[j] = SAFE_MMAP(NULL, unit * MB, PROT_READ|PROT_WRITE,
 			MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-		if (memory[j] == MAP_FAILED)
-			tst_brkm(TBROK|TERRNO, tst_exit, "mmap");
 #ifdef HAVE_MADV_MERGEABLE
 		if (madvise(memory[j], unit * MB, MADV_MERGEABLE) == -1)
-			tst_brkm(TBROK|TERRNO, tst_exit, "madvise");
+			tst_brk(TBROK|TERRNO, "madvise");
 #endif
 	}
 
-	tst_resm(TINFO, "child %d stops.", child_num);
+	tst_res(TINFO, "child %d stops.", child_num);
 	if (raise(SIGSTOP) == -1)
-		tst_brkm(TBROK|TERRNO, tst_exit, "kill");
+		tst_brk(TBROK|TERRNO, "kill");
 	fflush(stdout);
 
 	for (j = 0; j < 4; j++) {
@@ -428,9 +420,9 @@
 
 		fflush(stdout);
 
-		tst_resm(TINFO, "child %d stops.", child_num);
+		tst_res(TINFO, "child %d stops.", child_num);
 		if (raise(SIGSTOP) == -1)
-			tst_brkm(TBROK|TERRNO, tst_exit, "kill");
+			tst_brk(TBROK|TERRNO, "kill");
 
 		if (ksm_merge_data[j].mergeable_size < size * MB) {
 			verify(memory, 'e', child_num, total_unit - 1,
@@ -443,19 +435,18 @@
 		}
 	}
 
-	tst_resm(TINFO, "child %d finished.", child_num);
+	tst_res(TINFO, "child %d finished.", child_num);
 }
 
 static void stop_ksm_children(int *child, int num)
 {
 	int k, status;
 
-	tst_resm(TINFO, "wait for all children to stop.");
+	tst_res(TINFO, "wait for all children to stop.");
 	for (k = 0; k < num; k++) {
-		if (waitpid(child[k], &status, WUNTRACED) == -1)
-			tst_brkm(TBROK|TERRNO, cleanup, "waitpid");
+		SAFE_WAITPID(child[k], &status, WUNTRACED);
 		if (!WIFSTOPPED(status))
-			tst_brkm(TBROK, cleanup, "child %d was not stopped", k);
+			tst_brk(TBROK, "child %d was not stopped", k);
 	}
 }
 
@@ -463,11 +454,10 @@
 {
 	int k;
 
-	tst_resm(TINFO, "resume all children.");
-	for (k = 0; k < num; k++) {
-		if (kill(child[k], SIGCONT) == -1)
-			tst_brkm(TBROK|TERRNO, cleanup, "kill child[%d]", k);
-	}
+	tst_res(TINFO, "resume all children.");
+	for (k = 0; k < num; k++)
+		SAFE_KILL(child[k], SIGCONT);
+
 	fflush(stdout);
 }
 
@@ -501,15 +491,11 @@
 		}
 	}
 
-	child = malloc(num * sizeof(int));
-	if (child == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "malloc");
+	child = SAFE_MALLOC(num * sizeof(int));
 
 	for (i = 0; i < num; i++) {
 		fflush(stdout);
-		switch (child[i] = fork()) {
-		case -1:
-			tst_brkm(TBROK|TERRNO, cleanup, "fork");
+		switch (child[i] = SAFE_FORK()) {
 		case 0:
 			if (i == 0) {
 				create_ksm_child(i, size, unit, ksm_data0);
@@ -529,45 +515,42 @@
 
 	stop_ksm_children(child, num);
 
-	tst_resm(TINFO, "KSM merging...");
+	tst_res(TINFO, "KSM merging...");
 	if (access(PATH_KSM "max_page_sharing", F_OK) == 0)
-		SAFE_FILE_PRINTF(cleanup, PATH_KSM "max_page_sharing",
-				"%ld", size * pages * num);
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "pages_to_scan", "%ld",
-			 size * pages * num);
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "sleep_millisecs", "0");
+		SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing", "%ld", size * pages * num);
+	SAFE_FILE_PRINTF(PATH_KSM "run", "1");
+	SAFE_FILE_PRINTF(PATH_KSM "pages_to_scan", "%ld", size * pages * num);
+	SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0");
 
 	resume_ksm_children(child, num);
+	stop_ksm_children(child, num);
 	group_check(1, 2, size * num * pages - 2, 0, 0, 0, size * pages * num);
 
-	stop_ksm_children(child, num);
 	resume_ksm_children(child, num);
+	stop_ksm_children(child, num);
 	group_check(1, 3, size * num * pages - 3, 0, 0, 0, size * pages * num);
 
-	stop_ksm_children(child, num);
 	resume_ksm_children(child, num);
+	stop_ksm_children(child, num);
 	group_check(1, 1, size * num * pages - 1, 0, 0, 0, size * pages * num);
 
-	stop_ksm_children(child, num);
 	resume_ksm_children(child, num);
+	stop_ksm_children(child, num);
 	group_check(1, 1, size * num * pages - 2, 0, 1, 0, size * pages * num);
 
-	stop_ksm_children(child, num);
-
-	tst_resm(TINFO, "KSM unmerging...");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "2");
+	tst_res(TINFO, "KSM unmerging...");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "2");
 
 	resume_ksm_children(child, num);
-	group_check(2, 0, 0, 0, 0, 0, size * pages * num);
+	final_group_check(2, 0, 0, 0, 0, 0, size * pages * num);
 
-	tst_resm(TINFO, "stop KSM.");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "0");
-	group_check(0, 0, 0, 0, 0, 0, size * pages * num);
+	tst_res(TINFO, "stop KSM.");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "0");
+	final_group_check(0, 0, 0, 0, 0, 0, size * pages * num);
 
-	while (waitpid(-1, &status, WUNTRACED | WCONTINUED) > 0)
+	while (waitpid(-1, &status, 0) > 0)
 		if (WEXITSTATUS(status) != 0)
-			tst_resm(TFAIL, "child exit status is %d",
+			tst_res(TFAIL, "child exit status is %d",
 				 WEXITSTATUS(status));
 }
 
@@ -586,9 +569,9 @@
 
 	ret = get_allowed_nodes_arr(NH_MEMS|NH_CPUS, &num_nodes, &nodes);
 	if (ret != 0)
-		tst_brkm(TBROK|TERRNO, cleanup, "get_allowed_nodes_arr");
+		tst_brk(TBROK|TERRNO, "get_allowed_nodes_arr");
 	if (num_nodes < 2) {
-		tst_resm(TINFO, "need NUMA system support");
+		tst_res(TINFO, "need NUMA system support");
 		free(nodes);
 		return;
 	}
@@ -596,15 +579,13 @@
 	pagesize = sysconf(_SC_PAGE_SIZE);
 	length = nr_pages * pagesize;
 
-	memory = malloc(num_nodes * sizeof(char *));
+	memory = SAFE_MALLOC(num_nodes * sizeof(char *));
 	for (i = 0; i < num_nodes; i++) {
-		memory[i] = mmap(NULL, length, PROT_READ|PROT_WRITE,
+		memory[i] = SAFE_MMAP(NULL, length, PROT_READ|PROT_WRITE,
 			    MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-		if (memory[i] == MAP_FAILED)
-			tst_brkm(TBROK|TERRNO, tst_exit, "mmap");
 #ifdef HAVE_MADV_MERGEABLE
 		if (madvise(memory[i], length, MADV_MERGEABLE) == -1)
-			tst_brkm(TBROK|TERRNO, tst_exit, "madvise");
+			tst_brk(TBROK|TERRNO, "madvise");
 #endif
 
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
@@ -617,17 +598,17 @@
 		 */
 		ret = mbind(memory[i], length, MPOL_BIND, nmask, MAXNODES, 0);
 		if (ret == -1)
-			tst_brkm(TBROK|TERRNO, tst_exit, "mbind");
+			tst_brk(TBROK|TERRNO, "mbind");
 #endif
 
 		memset(memory[i], 10, length);
 	}
 
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "sleep_millisecs", "0");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "pages_to_scan", "%ld",
+	SAFE_FILE_PRINTF(PATH_KSM "sleep_millisecs", "0");
+	SAFE_FILE_PRINTF(PATH_KSM "pages_to_scan", "%ld",
 			 nr_pages * num_nodes);
 	if (access(PATH_KSM "max_page_sharing", F_OK) == 0)
-		SAFE_FILE_PRINTF(cleanup, PATH_KSM "max_page_sharing",
+		SAFE_FILE_PRINTF(PATH_KSM "max_page_sharing",
 			"%ld", nr_pages * num_nodes);
 	/*
 	 * merge_across_nodes setting can be changed only when there
@@ -635,56 +616,21 @@
 	 * pages first, then to 1 after changing merge_across_nodes,
 	 * to remerge according to the new setting.
 	 */
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "2");
-	wait_ksmd_done();
-	tst_resm(TINFO, "Start to test KSM with merge_across_nodes=1");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "merge_across_nodes", "1");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "2");
+	tst_res(TINFO, "Start to test KSM with merge_across_nodes=1");
+	SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "1");
 	group_check(1, 1, nr_pages * num_nodes - 1, 0, 0, 0,
 		    nr_pages * num_nodes);
 
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "2");
-	wait_ksmd_done();
-	tst_resm(TINFO, "Start to test KSM with merge_across_nodes=0");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "merge_across_nodes", "0");
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "1");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "2");
+	tst_res(TINFO, "Start to test KSM with merge_across_nodes=0");
+	SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "0");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "1");
 	group_check(1, num_nodes, nr_pages * num_nodes - num_nodes,
 		    0, 0, 0, nr_pages * num_nodes);
 
-	SAFE_FILE_PRINTF(cleanup, PATH_KSM "run", "2");
-	wait_ksmd_done();
-}
-
-void check_ksm_options(int *size, int *num, int *unit)
-{
-	if (opt_size) {
-		*size = atoi(opt_sizestr);
-		if (*size < 1)
-			tst_brkm(TBROK, cleanup, "size cannot be less than 1.");
-	}
-	if (opt_unit) {
-		*unit = atoi(opt_unitstr);
-		if (*unit > *size)
-			tst_brkm(TBROK, cleanup,
-				 "unit cannot be greater than size.");
-		if (*size % *unit != 0)
-			tst_brkm(TBROK, cleanup,
-				 "the remainder of division of size by unit is "
-				 "not zero.");
-	}
-	if (opt_num) {
-		*num = atoi(opt_numstr);
-		if (*num < 3)
-			tst_brkm(TBROK, cleanup,
-				 "process number cannot be less 3.");
-	}
-}
-
-void ksm_usage(void)
-{
-	printf("  -n      Number of processes\n");
-	printf("  -s      Memory allocation size in MB\n");
-	printf("  -u      Memory allocation unit in MB\n");
+	SAFE_FILE_PRINTF(PATH_KSM "run", "2");
 }
 
 /* THP */
@@ -712,7 +658,7 @@
 			 * be taken offline
 			 */
 			if (path_exist(path1)) {
-				SAFE_FILE_SCANF(cleanup, path1, "%ld", &online);
+				SAFE_FILE_SCANF(path1, "%ld", &online);
 				if (online == 0)
 					continue;
 			}
@@ -742,13 +688,12 @@
 				 prefix, filename);
 			fd = open(path, O_RDONLY);
 			if (fd == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "open %s", path);
+				tst_brk(TBROK | TERRNO, "open %s", path);
 		} else
-			tst_brkm(TBROK | TERRNO, cleanup, "open %s", path);
+			tst_brk(TBROK | TERRNO, "open %s", path);
 	}
 	if (read(fd, retbuf, BUFSIZ) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "read %s", path);
+		tst_brk(TBROK | TERRNO, "read %s", path);
 	close(fd);
 }
 
@@ -770,13 +715,11 @@
 				 prefix, filename);
 			fd = open(path, O_WRONLY);
 			if (fd == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "open %s", path);
+				tst_brk(TBROK | TERRNO, "open %s", path);
 		} else
-			tst_brkm(TBROK | TERRNO, cleanup, "open %s", path);
+			tst_brk(TBROK | TERRNO, "open %s", path);
 	}
-	if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
-		tst_brkm(TBROK | TERRNO, cleanup, "write %s", path);
+	SAFE_WRITE(1, fd, buf, strlen(buf));
 	close(fd);
 }
 
@@ -797,12 +740,12 @@
 	if (strlen(cpus) != 0) {
 		write_cpuset_files(CPATH_NEW, "cpus", cpus);
 	} else {
-		tst_resm(TINFO, "No CPUs in the node%ld; "
+		tst_res(TINFO, "No CPUs in the node%ld; "
 				"using only CPU0", nd);
 		write_cpuset_files(CPATH_NEW, "cpus", "0");
 	}
 
-	SAFE_FILE_PRINTF(NULL, CPATH_NEW "/tasks", "%d", getpid());
+	SAFE_FILE_PRINTF(CPATH_NEW "/tasks", "%d", getpid());
 }
 
 void umount_mem(char *path, char *path_new)
@@ -815,53 +758,51 @@
 	sprintf(s, "%s/tasks", path);
 	fd = open(s, O_WRONLY);
 	if (fd == -1)
-		tst_resm(TWARN | TERRNO, "open %s", s);
+		tst_res(TWARN | TERRNO, "open %s", s);
 
 	snprintf(s_new, BUFSIZ, "%s/tasks", path_new);
 	fp = fopen(s_new, "r");
 	if (fp == NULL)
-		tst_resm(TWARN | TERRNO, "fopen %s", s_new);
+		tst_res(TWARN | TERRNO, "fopen %s", s_new);
 	if ((fd != -1) && (fp != NULL)) {
 		while (fgets(value, BUFSIZ, fp) != NULL)
 			if (write(fd, value, strlen(value) - 1)
 			    != (ssize_t)strlen(value) - 1)
-				tst_resm(TWARN | TERRNO, "write %s", s);
+				tst_res(TWARN | TERRNO, "write %s", s);
 	}
 	if (fd != -1)
 		close(fd);
 	if (fp != NULL)
 		fclose(fp);
 	if (rmdir(path_new) == -1)
-		tst_resm(TWARN | TERRNO, "rmdir %s", path_new);
+		tst_res(TWARN | TERRNO, "rmdir %s", path_new);
 	if (umount(path) == -1)
-		tst_resm(TWARN | TERRNO, "umount %s", path);
+		tst_res(TWARN | TERRNO, "umount %s", path);
 	if (rmdir(path) == -1)
-		tst_resm(TWARN | TERRNO, "rmdir %s", path);
+		tst_res(TWARN | TERRNO, "rmdir %s", path);
 }
 
 void mount_mem(char *name, char *fs, char *options, char *path, char *path_new)
 {
-	if (mkdir(path, 0777) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "mkdir %s", path);
+	SAFE_MKDIR(path, 0777);
 	if (mount(name, path, fs, 0, options) == -1) {
 		if (errno == ENODEV) {
 			if (rmdir(path) == -1)
-				tst_resm(TWARN | TERRNO, "rmdir %s failed",
+				tst_res(TWARN | TERRNO, "rmdir %s failed",
 					 path);
-			tst_brkm(TCONF, NULL,
+			tst_brk(TCONF,
 				 "file system %s is not configured in kernel",
 				 fs);
 		}
-		tst_brkm(TBROK | TERRNO, cleanup, "mount %s", path);
+		tst_brk(TBROK | TERRNO, "mount %s", path);
 	}
-	if (mkdir(path_new, 0777) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "mkdir %s", path_new);
+	SAFE_MKDIR(path_new, 0777);
 }
 
 /* shared */
 
 /* Warning: *DO NOT* use this function in child */
-unsigned int get_a_numa_node(void (*cleanup_fn) (void))
+unsigned int get_a_numa_node(void)
 {
 	unsigned int nd1, nd2;
 	int ret;
@@ -871,24 +812,26 @@
 	case 0:
 		break;
 	case -3:
-		tst_brkm(TCONF, cleanup_fn, "requires a NUMA system.");
+		tst_brk(TCONF, "requires a NUMA system.");
 	default:
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "1st get_allowed_nodes");
+		tst_brk(TBROK | TERRNO, "1st get_allowed_nodes");
 	}
 
 	ret = get_allowed_nodes(NH_MEMS | NH_CPUS, 1, &nd1);
 	switch (ret) {
 	case 0:
-		tst_resm(TINFO, "get node%u.", nd1);
+		tst_res(TINFO, "get node%u.", nd1);
 		return nd1;
 	case -3:
-		tst_brkm(TCONF, cleanup_fn, "requires a NUMA system that has "
+		tst_brk(TCONF, "requires a NUMA system that has "
 			 "at least one node with both memory and CPU "
 			 "available.");
 	default:
-		break;
+		tst_brk(TBROK | TERRNO, "2nd get_allowed_nodes");
 	}
-	tst_brkm(TBROK | TERRNO, cleanup_fn, "2nd get_allowed_nodes");
+
+	/* not reached */
+	abort();
 }
 
 int path_exist(const char *path, ...)
@@ -903,44 +846,20 @@
 	return access(pathbuf, F_OK) == 0;
 }
 
-long read_meminfo(char *item)
-{
-	FILE *fp;
-	char line[BUFSIZ], buf[BUFSIZ];
-	long val;
-
-	fp = fopen(PATH_MEMINFO, "r");
-	if (fp == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fopen %s", PATH_MEMINFO);
-
-	while (fgets(line, BUFSIZ, fp) != NULL) {
-		if (sscanf(line, "%64s %ld", buf, &val) == 2)
-			if (strcmp(buf, item) == 0) {
-				fclose(fp);
-				return val;
-			}
-		continue;
-	}
-	fclose(fp);
-
-	tst_brkm(TBROK, cleanup, "cannot find \"%s\" in %s",
-		 item, PATH_MEMINFO);
-}
-
 void set_sys_tune(char *sys_file, long tune, int check)
 {
 	long val;
 	char path[BUFSIZ];
 
-	tst_resm(TINFO, "set %s to %ld", sys_file, tune);
+	tst_res(TINFO, "set %s to %ld", sys_file, tune);
 
 	snprintf(path, BUFSIZ, PATH_SYSVM "%s", sys_file);
-	SAFE_FILE_PRINTF(NULL, path, "%ld", tune);
+	SAFE_FILE_PRINTF(path, "%ld", tune);
 
 	if (check) {
 		val = get_sys_tune(sys_file);
 		if (val != tune)
-			tst_brkm(TBROK, cleanup, "%s = %ld, but expect %ld",
+			tst_brk(TBROK, "%s = %ld, but expect %ld",
 				 sys_file, val, tune);
 	}
 }
@@ -951,7 +870,7 @@
 	long tune;
 
 	snprintf(path, BUFSIZ, PATH_SYSVM "%s", sys_file);
-	SAFE_FILE_SCANF(NULL, path, "%ld", &tune);
+	SAFE_FILE_SCANF(path, "%ld", &tune);
 
 	return tune;
 }
@@ -960,20 +879,20 @@
 {
 	size_t shmmax;
 
-	SAFE_FILE_SCANF(cleanup, PATH_SHMMAX, "%ld", &shmmax);
+	SAFE_FILE_SCANF(PATH_SHMMAX, "%zu", &shmmax);
 	if (*shm_size > shmmax) {
-		tst_resm(TINFO, "Set shm_size to shmmax: %ld", shmmax);
+		tst_res(TINFO, "Set shm_size to shmmax: %zu", shmmax);
 		*shm_size = shmmax;
 	}
 }
 
-int range_is_mapped(void (*cleanup_fn) (void), unsigned long low, unsigned long high)
+int range_is_mapped(unsigned long low, unsigned long high)
 {
 	FILE *fp;
 
 	fp = fopen("/proc/self/maps", "r");
 	if (fp == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "Failed to open /proc/self/maps.");
+		tst_brk(TBROK | TERRNO, "Failed to open /proc/self/maps.");
 
 	while (!feof(fp)) {
 		unsigned long start, end;
@@ -982,7 +901,7 @@
 		ret = fscanf(fp, "%lx-%lx %*[^\n]\n", &start, &end);
 		if (ret != 2) {
 			fclose(fp);
-			tst_brkm(TBROK | TERRNO, cleanup_fn, "Couldn't parse /proc/self/maps line.");
+			tst_brk(TBROK | TERRNO, "Couldn't parse /proc/self/maps line.");
 		}
 
 		if ((start >= low) && (start < high)) {
diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index 81566f2..d2df612 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -131,7 +131,6 @@
 unsigned dosync = 0;
 unsigned do_offset = 0;
 unsigned pattern = 0;
-char filename[64];
 
 int main(int argc, char *argv[])
 {
@@ -159,6 +158,7 @@
 #else /* LARGE_FILE */
 	off_t bytes_left;
 #endif /* LARGE_FILE */
+	const char *filename = "mmapstress01.out";
 
 	progname = *argv;
 	tst_tmpdir();
@@ -228,8 +228,7 @@
 	}
 
 	(void)time(&t);
-	//(void)printf("%s: Started %s", argv[0], ctime(&t)); LTP Port
-	(void)sprintf(filename, "%sout.%d", progname, getpid());
+
 	seed = initrand();
 	pattern = seed & 0xff;
 
diff --git a/testcases/kernel/mem/mmapstress/mmapstress04.c b/testcases/kernel/mem/mmapstress/mmapstress04.c
index 3c4749f..3925f48 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress04.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress04.c
@@ -120,7 +120,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "mmapstress04",
 	.needs_tmpdir = 1,
 	.test_all = mmapstress04,
 	.setup = setup,
diff --git a/testcases/kernel/mem/mmapstress/mmapstress10.c b/testcases/kernel/mem/mmapstress/mmapstress10.c
index d3ee865..482933b 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress10.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress10.c
@@ -148,7 +148,7 @@
 unsigned dosync = 0;
 unsigned do_offset = 0;
 unsigned pattern = 0;
-char filename[64];
+static const char *filename = "mmapstress10.out";
 
 void clean_mapper(int sig);
 void clean_writer(int sig);
@@ -270,9 +270,7 @@
 		anyfail();
 	}
 	(void)time(&t);
-	//(void)printf("%s: Started %s", argv[0], ctime(&t)); LTP Port
 
-	(void)sprintf(filename, "%sout.%d", progname, getpid());
 	seed = initrand();
 	pattern = seed & 0xff;
 
diff --git a/testcases/kernel/mem/mtest01/mtest01.c b/testcases/kernel/mem/mtest01/mtest01.c
index 6225d7d..ca9073a 100644
--- a/testcases/kernel/mem/mtest01/mtest01.c
+++ b/testcases/kernel/mem/mtest01/mtest01.c
@@ -250,10 +250,7 @@
 			pid_list[i] = pid;
 		}
 	}
-	if (maxbytes > THREE_GB)
-		alloc_bytes = THREE_GB;
-	else
-		alloc_bytes = maxbytes;
+	alloc_bytes = MIN(THREE_GB, maxbytes);
 #endif
 
 	if (pid == 0) {
diff --git a/testcases/kernel/mem/mtest05/mmstress.c b/testcases/kernel/mem/mtest05/mmstress.c
index 5f3897b..4d8efdb 100644
--- a/testcases/kernel/mem/mtest05/mmstress.c
+++ b/testcases/kernel/mem/mtest05/mmstress.c
@@ -121,7 +121,6 @@
 #define FAILED       (-1)	/* return status for all funcs indicating failure   */
 #define SUCCESS      0		/* return status for all routines indicating success */
 
-#define MAXTEST      6		/* total number of testcase in this program          */
 #define BRKSZ        512*1024	/* program data space allocation value          */
 
 static volatile int wait_thread;	/* used to wake up sleeping threads    */
@@ -632,7 +631,8 @@
 int main(int argc, char **argv)
 {
 	static char *version_info = "mmstress V1.00 04/17/2001";
-	int ch, i;
+	int ch;
+	unsigned int i;
 	int test_num = 0;
 	int test_time = 0;
 	int run_once = TRUE;
@@ -706,15 +706,15 @@
 
 	do {
 		if (!test_num) {
-			for (i = 0; i < MAXTEST; i++)
+			for (i = 0; i < ARRAY_SIZE(test_ptr); i++)
 				run_test(i);
 		} else {
-			if (test_num >= MAXTEST) {
+			if (test_num > (int)ARRAY_SIZE(test_ptr)) {
 				tst_brkm(TBROK, NULL, "Invalid test number %i",
 					 test_num);
 			}
 
-			run_test(test_num);
+			run_test(test_num-1);
 		}
 	} while (!run_once);
 
diff --git a/testcases/kernel/mem/mtest06/mmap3.c b/testcases/kernel/mem/mtest06/mmap3.c
index d572720..d314ff8 100644
--- a/testcases/kernel/mem/mtest06/mmap3.c
+++ b/testcases/kernel/mem/mtest06/mmap3.c
@@ -205,7 +205,6 @@
 };
 
 static struct tst_test test = {
-	.tid = "mmap3",
 	.options = options,
 	.needs_tmpdir = 1,
 	.setup = setup,
diff --git a/testcases/kernel/mem/mtest06/shmat1.c b/testcases/kernel/mem/mtest06/shmat1.c
index 0d6d7a4..8756430 100644
--- a/testcases/kernel/mem/mtest06/shmat1.c
+++ b/testcases/kernel/mem/mtest06/shmat1.c
@@ -109,7 +109,7 @@
 /*									      */
 /******************************************************************************/
 static void sig_handler(int signal,	/* signal number, set to handle SIGALRM       */
-			int code, struct ucontext *ut)
+			int code, ucontext_t *ut)
 {				/* contains pointer to sigcontext structure   */
 #ifdef __i386__
 	unsigned long except;	/* exception type.                            */
diff --git a/testcases/kernel/mem/oom/oom01.c b/testcases/kernel/mem/oom/oom01.c
index e39394b..3d05860 100644
--- a/testcases/kernel/mem/oom/oom01.c
+++ b/testcases/kernel/mem/oom/oom01.c
@@ -7,27 +7,19 @@
  * behaviours. It simply increase the memory consumption 3G each time
  * until all the available memory is consumed and OOM is triggered.
  *
- * Copyright (C) 2010  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2010-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * 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.
  */
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
@@ -35,53 +27,42 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include "test.h"
 #include "mem.h"
 
-char *TCID = "oom01";
-int TST_TOTAL = 1;
-
-int main(int argc, char *argv[])
+static void verify_oom(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 #if __WORDSIZE == 32
-	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
+	tst_brk(TCONF, "test is not designed for 32-bit system.");
 #endif
 
-	setup();
+	/* we expect mmap to fail before OOM is hit */
+	set_sys_tune("overcommit_memory", 2, 1);
+	oom(NORMAL, 0, ENOMEM, 0);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+	/* with overcommit_memory set to 0 or 1 there's no
+	 * guarantee that mmap fails before OOM */
+	set_sys_tune("overcommit_memory", 0, 1);
+	oom(NORMAL, 0, ENOMEM, 1);
 
-		/* we expect mmap to fail before OOM is hit */
-		set_sys_tune("overcommit_memory", 2, 1);
-		oom(NORMAL, 0, ENOMEM, 0);
-
-		/* with overcommit_memory set to 0 or 1 there's no
-		 * guarantee that mmap fails before OOM */
-		set_sys_tune("overcommit_memory", 0, 1);
-		oom(NORMAL, 0, ENOMEM, 1);
-
-		set_sys_tune("overcommit_memory", 1, 1);
-		testoom(0, 0, ENOMEM, 1);
-	}
-	cleanup();
-	tst_exit();
+	set_sys_tune("overcommit_memory", 1, 1);
+	testoom(0, 0, ENOMEM, 1);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
 	overcommit = get_sys_tune("overcommit_memory");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", overcommit, 0);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.timeout = -1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_oom,
+};
diff --git a/testcases/kernel/mem/oom/oom02.c b/testcases/kernel/mem/oom/oom02.c
index 8bbb18a..3434a34 100644
--- a/testcases/kernel/mem/oom/oom02.c
+++ b/testcases/kernel/mem/oom/oom02.c
@@ -7,26 +7,17 @@
  * behaviours. It simply increase the memory consumption 3G each time
  * until all the available memory is consumed and OOM is triggered.
  *
- * Copyright (C) 2010  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2010-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * 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.
  */
 
 #include "config.h"
@@ -36,64 +27,50 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include "numa_helper.h"
-#include "test.h"
 #include "mem.h"
 
-char *TCID = "oom02";
-int TST_TOTAL = 1;
-
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 
-int main(int argc, char *argv[])
+static void verify_oom(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 #if __WORDSIZE == 32
-	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
+	tst_brk(TCONF, "test is not designed for 32-bit system.");
 #endif
 
-	setup();
+	tst_res(TINFO, "OOM on MPOL_BIND mempolicy...");
+	testoom(MPOL_BIND, 0, ENOMEM, 1);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+	tst_res(TINFO, "OOM on MPOL_INTERLEAVE mempolicy...");
+	testoom(MPOL_INTERLEAVE, 0, ENOMEM, 1);
 
-		tst_resm(TINFO, "OOM on MPOL_BIND mempolicy...");
-		testoom(MPOL_BIND, 0, ENOMEM, 1);
-
-		tst_resm(TINFO, "OOM on MPOL_INTERLEAVE mempolicy...");
-		testoom(MPOL_INTERLEAVE, 0, ENOMEM, 1);
-
-		tst_resm(TINFO, "OOM on MPOL_PREFERRED mempolicy...");
-		testoom(MPOL_PREFERRED, 0, ENOMEM, 1);
-	}
-	cleanup();
-	tst_exit();
+	tst_res(TINFO, "OOM on MPOL_PREFERRED mempolicy...");
+	testoom(MPOL_PREFERRED, 0, ENOMEM, 1);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
 	if (!is_numa(NULL, NH_MEMS, 2))
-		tst_brkm(TCONF, NULL, "The case need a NUMA system.");
+		tst_brk(TCONF, "The case need a NUMA system.");
 
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", overcommit, 0);
 }
 
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.timeout = -1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_oom,
+};
+
 #else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/oom/oom03.c b/testcases/kernel/mem/oom/oom03.c
index 879fdae..f883bc0 100644
--- a/testcases/kernel/mem/oom/oom03.c
+++ b/testcases/kernel/mem/oom/oom03.c
@@ -7,107 +7,83 @@
  * behaviours. It simply increase the memory consumption 3G each time
  * until all the available memory is consumed and OOM is triggered.
  *
- * Copyright (C) 2010  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2010-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * 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.
  */
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include "numa_helper.h"
-#include "test.h"
 #include "mem.h"
 
-char *TCID = "oom03";
-int TST_TOTAL = 1;
-
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 
-int main(int argc, char *argv[])
+static void verify_oom(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 #if __WORDSIZE == 32
-	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
+	tst_brk(TCONF, "test is not designed for 32-bit system.");
 #endif
 
-	setup();
+	SAFE_FILE_PRINTF(MEMCG_PATH_NEW "/tasks", "%d", getpid());
+	SAFE_FILE_PRINTF(MEMCG_LIMIT, "%ld", TESTMEM);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+	testoom(0, 0, ENOMEM, 1);
 
-		SAFE_FILE_PRINTF(cleanup, MEMCG_PATH_NEW "/tasks",
-				 "%d", getpid());
-		SAFE_FILE_PRINTF(cleanup, MEMCG_LIMIT, "%ld", TESTMEM);
-
-		testoom(0, 0, ENOMEM, 1);
-
-		if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
-			if (errno == ENOENT)
-				tst_resm(TCONF,
-					 "memcg swap accounting is disabled");
-			else
-				tst_brkm(TBROK | TERRNO, cleanup, "access");
-		} else {
-			SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT,
-					 "%ld", TESTMEM);
-			testoom(0, 1, ENOMEM, 1);
-		}
-
-		/* OOM for MEMCG with mempolicy */
-		if (is_numa(cleanup, NH_MEMS, 2)) {
-			tst_resm(TINFO, "OOM on MEMCG & mempolicy...");
-			testoom(MPOL_BIND, 0, ENOMEM, 1);
-			testoom(MPOL_INTERLEAVE, 0, ENOMEM, 1);
-			testoom(MPOL_PREFERRED, 0, ENOMEM, 1);
-		}
+	if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
+		if (errno == ENOENT)
+			tst_res(TCONF,
+				"memcg swap accounting is disabled");
+		else
+			tst_brk(TBROK | TERRNO, "access");
+	} else {
+		SAFE_FILE_PRINTF(MEMCG_SW_LIMIT, "%ld", TESTMEM);
+		testoom(0, 1, ENOMEM, 1);
 	}
-	cleanup();
-	tst_exit();
+
+	/* OOM for MEMCG with mempolicy */
+	if (is_numa(NULL, NH_MEMS, 2)) {
+		tst_res(TINFO, "OOM on MEMCG & mempolicy...");
+		testoom(MPOL_BIND, 0, ENOMEM, 1);
+		testoom(MPOL_INTERLEAVE, 0, ENOMEM, 1);
+		testoom(MPOL_PREFERRED, 0, ENOMEM, 1);
+	}
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
 	mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", overcommit, 0);
 	umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 }
 
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.timeout = -1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_oom,
+};
+
 #else
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/oom/oom04.c b/testcases/kernel/mem/oom/oom04.c
index 4829d95..e4e70e2 100644
--- a/testcases/kernel/mem/oom/oom04.c
+++ b/testcases/kernel/mem/oom/oom04.c
@@ -7,26 +7,17 @@
  * behaviours. It simply increase the memory consumption 3G each time
  * until all the available memory is consumed and OOM is triggered.
  *
- * Copyright (C) 2010  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2010-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * 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.
  */
 
 #include "config.h"
@@ -36,59 +27,38 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include "numa_helper.h"
-#include "test.h"
 #include "mem.h"
 
-char *TCID = "oom04";
-int TST_TOTAL = 1;
-
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 
-int main(int argc, char *argv[])
+static void verify_oom(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 #if __WORDSIZE == 32
-	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
+	tst_brk(TCONF, "test is not designed for 32-bit system.");
 #endif
 
-	setup();
+	tst_res(TINFO, "OOM on CPUSET...");
+	testoom(0, 0, ENOMEM, 1);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		tst_resm(TINFO, "OOM on CPUSET...");
+	if (is_numa(NULL, NH_MEMS, 2)) {
+		/*
+		 * Under NUMA system, the migration of cpuset's memory
+		 * is in charge of cpuset.memory_migrate, we can write
+		 * 1 to cpuset.memory_migrate to enable the migration.
+		 */
+		write_cpuset_files(CPATH_NEW, "memory_migrate", "1");
+		tst_res(TINFO, "OOM on CPUSET with mem migrate:");
 		testoom(0, 0, ENOMEM, 1);
-
-		if (is_numa(cleanup, NH_MEMS, 2)) {
-			/*
-			 * Under NUMA system, the migration of cpuset's memory
-			 * is in charge of cpuset.memory_migrate, we can write
-			 * 1 to cpuset.memory_migrate to enable the migration.
-			 */
-			write_cpuset_files(CPATH_NEW,
-					   "memory_migrate", "1");
-			tst_resm(TINFO, "OOM on CPUSET with mem migrate:");
-			testoom(0, 0, ENOMEM, 1);
-		}
 	}
-	cleanup();
-	tst_exit();
 }
 
-void setup(void)
+static void setup(void)
 {
 	int memnode, ret;
 
-	tst_require_root();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
 	if (!is_numa(NULL, NH_MEMS, 1))
-		tst_brkm(TCONF, NULL, "requires NUMA with at least 1 node");
+		tst_brk(TCONF, "requires NUMA with at least 1 node");
 
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
@@ -103,20 +73,26 @@
 	 */
 	ret = get_allowed_nodes(NH_MEMS, 1, &memnode);
 	if (ret < 0)
-		tst_brkm(TBROK, cleanup, "Failed to get a memory node "
-				      "using get_allowed_nodes()");
+		tst_brk(TBROK, "Failed to get a memory node "
+			      "using get_allowed_nodes()");
 	write_cpusets(memnode);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", overcommit, 0);
 	umount_mem(CPATH, CPATH_NEW);
 }
 
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.timeout = -1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_oom,
+};
+
 #else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/oom/oom05.c b/testcases/kernel/mem/oom/oom05.c
index ccf456f..bdf5d19 100644
--- a/testcases/kernel/mem/oom/oom05.c
+++ b/testcases/kernel/mem/oom/oom05.c
@@ -7,26 +7,17 @@
  * behaviours. It simply increase the memory consumption 3G each time
  * until all the available memory is consumed and OOM is triggered.
  *
- * Copyright (C) 2013  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2013-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * 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.
  */
 
 #include "config.h"
@@ -36,82 +27,61 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include "numa_helper.h"
-#include "test.h"
 #include "mem.h"
 
-char *TCID = "oom05";
-int TST_TOTAL = 1;
-
 #if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
 	&& HAVE_MPOL_CONSTANTS
 
-int main(int argc, char *argv[])
+static void verify_oom(void)
 {
-	int lc;
 	int swap_acc_on = 1;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 #if __WORDSIZE == 32
-	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
+	tst_brk(TCONF, "test is not designed for 32-bit system.");
 #endif
 
-	setup();
+	tst_res(TINFO, "OOM on CPUSET & MEMCG...");
+	testoom(0, 0, ENOMEM, 1);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		tst_resm(TINFO, "OOM on CPUSET & MEMCG...");
+	/*
+	 * Under NUMA system, the migration of cpuset's memory
+	 * is in charge of cpuset.memory_migrate, we can write
+	 * 1 to cpuset.memory_migrate to enable the migration.
+	 */
+	if (is_numa(NULL, NH_MEMS, 2)) {
+		write_cpuset_files(CPATH_NEW, "memory_migrate", "1");
+		tst_res(TINFO, "OOM on CPUSET & MEMCG with "
+				"cpuset.memory_migrate=1");
 		testoom(0, 0, ENOMEM, 1);
-
-		/*
-		 * Under NUMA system, the migration of cpuset's memory
-		 * is in charge of cpuset.memory_migrate, we can write
-		 * 1 to cpuset.memory_migrate to enable the migration.
-		 */
-		if (is_numa(cleanup, NH_MEMS, 2)) {
-			write_cpuset_files(CPATH_NEW, "memory_migrate", "1");
-			tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
-					"cpuset.memory_migrate=1");
-			testoom(0, 0, ENOMEM, 1);
-		}
-
-		if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
-			if (errno == ENOENT) {
-				tst_resm(TCONF,
-					 "memcg swap accounting is disabled");
-				swap_acc_on = 0;
-			} else
-				tst_brkm(TBROK|TERRNO, cleanup, "access");
-		}
-
-		if (swap_acc_on) {
-			tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
-					"special memswap limitation:");
-			SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT, "%ld", TESTMEM);
-			testoom(0, 0, ENOMEM, 1);
-
-			tst_resm(TINFO, "OOM on CPUSET & MEMCG with "
-					"disabled memswap limitation:");
-			SAFE_FILE_PRINTF(cleanup, MEMCG_SW_LIMIT, "-1");
-			testoom(0, 0, ENOMEM, 1);
-		}
 	}
 
-	cleanup();
-	tst_exit();
+	if (access(MEMCG_SW_LIMIT, F_OK) == -1) {
+		if (errno == ENOENT) {
+			tst_res(TCONF, "memcg swap accounting is disabled");
+			swap_acc_on = 0;
+		} else
+			tst_brk(TBROK|TERRNO, "access");
+	}
+
+	if (swap_acc_on) {
+		tst_res(TINFO, "OOM on CPUSET & MEMCG with "
+				"special memswap limitation:");
+		SAFE_FILE_PRINTF(MEMCG_SW_LIMIT, "%ld", TESTMEM);
+		testoom(0, 0, ENOMEM, 1);
+
+		tst_res(TINFO, "OOM on CPUSET & MEMCG with "
+				"disabled memswap limitation:");
+		SAFE_FILE_PRINTF(MEMCG_SW_LIMIT, "-1");
+		testoom(0, 0, ENOMEM, 1);
+	}
 }
 
 void setup(void)
 {
 	int ret, memnode;
 
-	tst_require_root();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
 	if (!is_numa(NULL, NH_MEMS, 1))
-		tst_brkm(TCONF, NULL, "requires NUMA with at least 1 node");
+		tst_brk(TCONF, "requires NUMA with at least 1 node");
 
 	overcommit = get_sys_tune("overcommit_memory");
 	set_sys_tune("overcommit_memory", 1, 1);
@@ -128,8 +98,8 @@
 	 */
 	ret = get_allowed_nodes(NH_MEMS, 1, &memnode);
 	if (ret < 0)
-		tst_brkm(TBROK, cleanup, "Failed to get a memory node "
-				      "using get_allowed_nodes()");
+		tst_brk(TBROK, "Failed to get a memory node "
+			      "using get_allowed_nodes()");
 	write_cpusets(memnode);
 }
 
@@ -140,9 +110,15 @@
 	umount_mem(MEMCG_PATH, MEMCG_PATH_NEW);
 }
 
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.timeout = -1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_oom,
+};
+
 #else /* no NUMA */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
-}
+	TST_TEST_TCONF("no NUMA development packages installed.");
 #endif
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index 171edb3..5610806 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -1,24 +1,15 @@
 /*
- * Copyright (C) 2012  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2012-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * 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.
  */
 /*
  * swapping01 - first time swap use results in heavy swapping
@@ -53,12 +44,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "test.h"
 #include "mem.h"
 
-char *TCID = "swapping01";
-int TST_TOTAL = 1;
-
 /* allow swapping 1 * phy_mem in maximum */
 #define COE_DELTA       1
 /* will try to alloc 1.3 * phy_mem */
@@ -74,54 +61,40 @@
 static long mem_over_max;
 static pid_t pid;
 
-int main(int argc, char *argv[])
+static void test_swapping(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 #if __WORDSIZE == 32
-	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
+	tst_brk(TCONF, "test is not designed for 32-bit system.");
 #endif
 
-	setup();
+	init_meminfo();
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		init_meminfo();
-
-		switch (pid = fork()) {
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork");
+	switch (pid = SAFE_FORK()) {
 		case 0:
 			do_alloc();
 			exit(0);
 		default:
 			check_swapping();
-		}
 	}
-	cleanup();
-	tst_exit();
 }
 
 static void init_meminfo(void)
 {
-	swap_free_init = read_meminfo("SwapFree:");
-	if (FILE_LINES_SCANF(cleanup, "/proc/meminfo", "MemAvailable: %ld",
+	swap_free_init = SAFE_READ_MEMINFO("SwapFree:");
+	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
 		&mem_available_init)) {
-		mem_available_init = read_meminfo("MemFree:")
-			+ read_meminfo("Cached:");
+		mem_available_init = SAFE_READ_MEMINFO("MemFree:")
+			+ SAFE_READ_MEMINFO("Cached:");
 	}
 	mem_over = mem_available_init * COE_SLIGHT_OVER;
 	mem_over_max = mem_available_init * COE_DELTA;
 
 	/* at least 10MB available physical memory needed */
 	if (mem_available_init < 10240)
-		tst_brkm(TCONF, cleanup, "Not enough available mem to test.");
+		tst_brk(TCONF, "Not enough available mem to test.");
 
 	if (swap_free_init < mem_over_max)
-		tst_brkm(TCONF, cleanup, "Not enough swap space to test.");
+		tst_brk(TCONF, "Not enough swap space to test.");
 }
 
 static void do_alloc(void)
@@ -129,17 +102,15 @@
 	long mem_count;
 	void *s;
 
-	tst_resm(TINFO, "available physical memory: %ld MB",
+	tst_res(TINFO, "available physical memory: %ld MB",
 		mem_available_init / 1024);
 	mem_count = mem_available_init + mem_over;
-	tst_resm(TINFO, "try to allocate: %ld MB", mem_count / 1024);
-	s = malloc(mem_count * 1024);
-	if (s == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "malloc");
+	tst_res(TINFO, "try to allocate: %ld MB", mem_count / 1024);
+	s = SAFE_MALLOC(mem_count * 1024);
 	memset(s, 1, mem_count * 1024);
-	tst_resm(TINFO, "memory allocated: %ld MB", mem_count / 1024);
+	tst_res(TINFO, "memory allocated: %ld MB", mem_count / 1024);
 	if (raise(SIGSTOP) == -1)
-		tst_brkm(TBROK | TERRNO, tst_exit, "kill");
+		tst_brk(TBROK | TERRNO, "kill");
 	free(s);
 }
 
@@ -150,44 +121,39 @@
 
 	/* wait child stop */
 	if (waitpid(pid, &status, WUNTRACED) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+		tst_brk(TBROK | TERRNO, "waitpid");
 	if (!WIFSTOPPED(status))
-		tst_brkm(TBROK, cleanup, "child was not stopped.");
+		tst_brk(TBROK, "child was not stopped.");
 
 	/* Still occupying memory, loop for a while */
 	i = 0;
 	while (i < 10) {
-		swap_free_now = read_meminfo("SwapFree:");
+		swap_free_now = SAFE_READ_MEMINFO("SwapFree:");
 		sleep(1);
-		if (abs(swap_free_now - read_meminfo("SwapFree:")) < 512)
+		if (abs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:")) < 512)
 			break;
 
 		i++;
 	}
 
-	swap_free_now = read_meminfo("SwapFree:");
+	swap_free_now = SAFE_READ_MEMINFO("SwapFree:");
 	swapped = swap_free_init - swap_free_now;
 	if (swapped > mem_over_max) {
 		kill(pid, SIGCONT);
-		tst_brkm(TFAIL, cleanup, "heavy swapping detected: "
+		tst_brk(TFAIL, "heavy swapping detected: "
 				"%ld MB swapped.", swapped / 1024);
 	}
 
-	tst_resm(TPASS, "no heavy swapping detected, %ld MB swapped.",
+	tst_res(TPASS, "no heavy swapping detected, %ld MB swapped.",
 		 swapped / 1024);
 	kill(pid, SIGCONT);
 	/* wait child exit */
 	if (waitpid(pid, &status, 0) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+		tst_brk(TBROK | TERRNO, "waitpid");
 }
 
-void setup(void)
-{
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.test_all = test_swapping,
+};
diff --git a/testcases/kernel/mem/thp/thp01.c b/testcases/kernel/mem/thp/thp01.c
index e1eaa50..2f2bb2b 100644
--- a/testcases/kernel/mem/thp/thp01.c
+++ b/testcases/kernel/mem/thp/thp01.c
@@ -1,4 +1,19 @@
 /*
+ * Copyright (C) 2011-2017  Red Hat, Inc.
+ *
+ * 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.
+ */
+
+/* Description:
+ *
  * This is a reproducer of CVE-2011-0999, which fixed by mainline commit
  * a7d6e4ecdb7648478ddec76d30d87d03d6e22b31:
  *
@@ -14,106 +29,122 @@
  * last sysfs file: /sys/devices/system/cpu/cpu23/cache/index2/shared_cpu_map
  * ....
  *
- * Copyright (C) 2011  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * Due to commit da029c11e6b1 which reduced the stack size considerably, we
+ * now perform a binary search to find the largest possible argument we can
+ * use. Only the first iteration of the test performs the search; subsequent
+ * iterations use the result of the search which is stored in some shared
+ * memory.
  */
 
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/resource.h>
 #include <sys/wait.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <unistd.h>
-#include "test.h"
+#include "tst_test.h"
+#include "mem.h"
+#include "tst_minmax.h"
 
-char *TCID = "thp01";
-int TST_TOTAL = 1;
+#define ARGS_SZ	(256 * 32)
 
-#define ARRAY_SZ	256
+static struct bisection {
+	long left;
+	long right;
+	long mid;
+} *bst;
 
-static int ps;
-static long length;
-static char *array[ARRAY_SZ];
+static char *args[ARGS_SZ];
 static char *arg;
-static struct rlimit rl = {
-	.rlim_cur = RLIM_INFINITY,
-	.rlim_max = RLIM_INFINITY,
-};
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int argc, char **argv)
+static void thp_test(void)
 {
-	int i, lc, st;
-	pid_t pid;
+	long prev_left;
+	int pid;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	while (bst->right - bst->left > 1) {
+		pid_t pid = SAFE_FORK();
 
-	setup();
+		if (!pid) {
+			/* We set mid to left assuming exec will succeed. If
+			 * exec fails with E2BIG (and thus returns) then we
+			 * restore left and set right to mid instead.
+			 */
+			prev_left = bst->left;
+			bst->mid = (bst->left + bst->right) / 2;
+			bst->left = bst->mid;
+			args[bst->mid] = NULL;
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		switch (pid = fork()) {
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork");
-		case 0:
-			memset(arg, 'c', length - 1);
-			arg[length - 1] = '\0';
-			array[0] = "true";
-			for (i = 1; i < ARRAY_SZ - 1; i++)
-				array[i] = arg;
-			array[ARRAY_SZ - 1] = NULL;
-			if (setrlimit(RLIMIT_STACK, &rl) == -1) {
-				perror("setrlimit");
-				exit(1);
-			}
-			if (execvp("true", array) == -1) {
-				perror("execvp");
-				exit(1);
-			}
-		default:
-			if (waitpid(pid, &st, 0) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
-			if (!WIFEXITED(st) || WEXITSTATUS(st) != 0)
-				tst_brkm(TBROK, cleanup,
-					 "child exited abnormally");
+			TEST(execvp("true", args));
+			if (TEST_ERRNO != E2BIG)
+				tst_brk(TBROK | TTERRNO, "execvp(\"true\", ...)");
+			bst->left = prev_left;
+			bst->right = bst->mid;
+			exit(0);
 		}
+
+		tst_reap_children();
+		tst_res(TINFO, "left: %ld, right: %ld, mid: %ld",
+			bst->left, bst->right, bst->mid);
 	}
-	tst_resm(TPASS, "system didn't crash, pass.");
-	cleanup();
-	tst_exit();
+
+	/* We end with mid == right or mid == left where right - left =
+	 * 1. Regardless we must use left because right is only set to values
+	 * which are too large.
+	 */
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		args[bst->left] = NULL;
+		TEST(execvp("true", args));
+		if (TEST_ERRNO != E2BIG)
+			tst_brk(TBROK | TTERRNO, "execvp(\"true\", ...)");
+		exit(0);
+	}
+	tst_reap_children();
+
+	tst_res(TPASS, "system didn't crash.");
 }
 
 static void setup(void)
 {
-	ps = sysconf(_SC_PAGESIZE);
-	length = 32 * ps;
-	arg = malloc(length);
-	if (arg == NULL)
-		tst_brkm(TBROK | TERRNO, NULL, "malloc");
+	struct rlimit rl = {
+		.rlim_cur = RLIM_INFINITY,
+		.rlim_max = RLIM_INFINITY,
+	};
+	int i;
+	long arg_len, arg_count;
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
+	bst = SAFE_MMAP(NULL, sizeof(*bst),
+			   PROT_READ | PROT_WRITE,
+			   MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+	bst->left = 0;
+	bst->right = ARGS_SZ;
+
+	arg_len = sysconf(_SC_PAGESIZE);
+	arg = SAFE_MALLOC(arg_len);
+	memset(arg, 'c', arg_len - 1);
+	arg[arg_len - 1] = '\0';
+
+	args[0] = "true";
+	arg_count = ARGS_SZ;
+	tst_res(TINFO, "Using %ld args of size %ld", arg_count, arg_len);
+	for (i = 1; i < arg_count; i++)
+		args[i] = arg;
+
+	SAFE_SETRLIMIT(RLIMIT_STACK, &rl);
 }
 
 static void cleanup(void)
 {
+	free(arg);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = thp_test,
+};
diff --git a/testcases/kernel/mem/thp/thp02.c b/testcases/kernel/mem/thp/thp02.c
index eb919aa..acc70e2 100644
--- a/testcases/kernel/mem/thp/thp02.c
+++ b/testcases/kernel/mem/thp/thp02.c
@@ -1,26 +1,18 @@
 /*
- * Copyright (C) 2011  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2011-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * thp02 - detect mremap bug when THP is enabled.
+ * 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.
+ */
+
+/* thp02 - detect mremap bug when THP is enabled.
  *
  * There was a bug in mremap THP support, sometimes crash happened
  * due to the following reason according to developers:
@@ -52,48 +44,20 @@
 #include <unistd.h>
 #include "mem.h"
 
-char *TCID = "thp02";
-int TST_TOTAL = 1;
-
 #ifdef HAVE_MREMAP_FIXED
 static int ps;
 static long hps, size;
 static void *p, *p2, *p3, *p4;
 
-static void do_mremap(void);
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		do_mremap();
-	}
-	tst_resm(TPASS, "Still alive.");
-
-	cleanup();
-	tst_exit();
-
-}
-
 static void do_mremap(void)
 {
 	int i;
 	void *old_addr, *new_addr;
 
 	for (i = 0; i < 4; i++) {
-		if (posix_memalign(&p, hps, size))
-			tst_brkm(TBROK | TERRNO, cleanup, "memalign p");
-		if (posix_memalign(&p2, hps, size))
-			tst_brkm(TBROK | TERRNO, cleanup, "memalign p2");
-		if (posix_memalign(&p3, hps, size))
-			tst_brkm(TBROK | TERRNO, cleanup, "memalign p3");
+		p = SAFE_MEMALIGN(hps, size);
+		p2 = SAFE_MEMALIGN(hps, size);
+		p3 = SAFE_MEMALIGN(hps, size);
 
 		memset(p, 0xff, size);
 		memset(p2, 0xff, size);
@@ -108,37 +72,35 @@
 		 */
 		old_addr = p + ps * (i >> 1);
 		new_addr = p3 + ps * (i & 1);
-		tst_resm(TINFO, "mremap %p to %p", old_addr, new_addr);
+		tst_res(TINFO, "mremap %p to %p", old_addr, new_addr);
 
 		p4 = mremap(old_addr, size - ps, size - ps,
 			    MREMAP_FIXED | MREMAP_MAYMOVE, new_addr);
 		if (p4 == MAP_FAILED)
-			tst_brkm(TBROK | TERRNO, cleanup, "mremap");
+			tst_brk(TBROK | TERRNO, "mremap");
 		if (memcmp(p4, p2, size - ps))
-			tst_brkm(TBROK, cleanup, "mremap bug");
+			tst_brk(TBROK, "mremap bug");
 	}
+
+	tst_res(TPASS, "Still alive.");
 }
 
-void setup(void)
+static void setup(void)
 {
 	if (access(PATH_THP, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "THP not enabled in kernel?");
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
+		tst_brk(TCONF, "THP not enabled in kernel?");
 
 	ps = sysconf(_SC_PAGESIZE);
-	hps = read_meminfo("Hugepagesize:") * 1024;
+	hps = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
 	size = hps * 4;
 }
 
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.needs_root = 1,
+	.setup = setup,
+	.test_all = do_mremap,
+};
 
 #else
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "MREMAP_FIXED not present in <sys/mman.h>");
-}
+	TST_TEST_TCONF("MREMAP_FIXED not present in <sys/mman.h>");
 #endif /* HAVE_MREMAP_FIXED */
diff --git a/testcases/kernel/mem/thp/thp03.c b/testcases/kernel/mem/thp/thp03.c
index 6b0f829..19db449 100644
--- a/testcases/kernel/mem/thp/thp03.c
+++ b/testcases/kernel/mem/thp/thp03.c
@@ -1,26 +1,18 @@
 /*
- * Copyright (C) 2012  Red Hat, Inc.
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2012-2017  Red Hat, Inc.
  *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * thp03 - Case for spliting unaligned memory.
+ * 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.
+ */
+
+/* thp03 - Case for spliting unaligned memory.
  *       - System will panic if failed.
  *
  * Modified form a reproducer for
@@ -46,13 +38,7 @@
 #include <string.h>
 #include <errno.h>
 #include "mem.h"
-#include "safe_macros.h"
-#include "test.h"
-
-char *TCID = "thp03";
-int TST_TOTAL = 1;
-
-#ifdef MADV_MERGEABLE
+#include "lapi/mmap.h"
 
 static void thp_test(void);
 
@@ -60,78 +46,50 @@
 static long unaligned_size;
 static long page_size;
 
-int main(int argc, char **argv)
-{
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		thp_test();
-	}
-	tst_resm(TPASS, "system didn't crash, pass.");
-	cleanup();
-	tst_exit();
-}
-
 static void thp_test(void)
 {
 	void *p;
 
-	p = mmap(NULL, unaligned_size, PROT_READ | PROT_WRITE,
+	p = SAFE_MMAP(NULL, unaligned_size, PROT_READ | PROT_WRITE,
 		 MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
-	if (p == MAP_FAILED)
-		tst_brkm(TBROK | TERRNO, cleanup, "mmap");
 
 	memset(p, 0x00, unaligned_size);
 	if (mprotect(p, unaligned_size, PROT_NONE) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "mprotect");
+		tst_brk(TBROK | TERRNO, "mprotect");
 
 	if (madvise(p + hugepage_size, page_size, MADV_MERGEABLE) == -1) {
 		if (errno == EINVAL) {
-			tst_brkm(TCONF, cleanup,
+			tst_brk(TCONF,
 			         "MADV_MERGEABLE is not enabled/supported");
 		} else {
-			tst_brkm(TBROK | TERRNO, cleanup, "madvise");
+			tst_brk(TBROK | TERRNO, "madvise");
 		}
 	}
 
-	switch (fork()) {
-	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
+	switch (SAFE_FORK()) {
 	case 0:
 		exit(0);
 	default:
-		if (waitpid(-1, NULL, 0) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+		SAFE_WAITPID(-1, NULL, 0);
 	}
+
+	tst_res(TPASS, "system didn't crash, pass.");
+	munmap(p, unaligned_size);
 }
 
-void setup(void)
+static void setup(void)
 {
 	if (access(PATH_THP, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "THP not enabled in kernel?");
+		tst_brk(TCONF, "THP not enabled in kernel?");
 
-	hugepage_size = read_meminfo("Hugepagesize:") * KB;
+	hugepage_size = SAFE_READ_MEMINFO("Hugepagesize:") * KB;
 	unaligned_size = hugepage_size * 4 - 1;
-	page_size = SAFE_SYSCONF(NULL, _SC_PAGESIZE);
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
+	page_size = SAFE_SYSCONF(_SC_PAGESIZE);
 }
 
-void cleanup(void)
-{
-}
-
-#else
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "Kernel doesn't support MADV_MERGEABLE"
-		 " or you need to update your glibc-headers");
-}
-#endif
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.test_all = thp_test,
+};
diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c
index 75a5098..e47543d 100644
--- a/testcases/kernel/mem/tunable/max_map_count.c
+++ b/testcases/kernel/mem/tunable/max_map_count.c
@@ -1,4 +1,18 @@
 /*
+ * Copyright (C) 2012-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Description:
+ *
  * The program is designed to test max_map_count tunable file
  *
  * The kernel Documentation say that:
@@ -24,35 +38,9 @@
  * ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0   [vsyscall]
  *
  * so we ignore this line during /proc/[pid]/maps reading.
- *
- * ********************************************************************
- * Copyright (C) 2012 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * ********************************************************************
  */
+
 #define _GNU_SOURCE
-#include <sys/types.h>
-#include <sys/mman.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -60,47 +48,19 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/utsname.h>
-#include "test.h"
 #include "mem.h"
 
 #define MAP_COUNT_DEFAULT	1024
 #define MAX_MAP_COUNT		65536L
 
-char *TCID = "max_map_count";
-int TST_TOTAL = 1;
-
 static long old_max_map_count;
 static long old_overcommit;
 static struct utsname un;
 
-static long count_maps(pid_t pid);
-static void max_map_count_test(void);
-
-int main(int argc, char *argv[])
+static void setup(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		max_map_count_test();
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-void setup(void)
-{
-	tst_require_root();
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
 	if (access(PATH_SYSVM "max_map_count", F_OK) != 0)
-		tst_brkm(TBROK | TERRNO, NULL,
+		tst_brk(TBROK | TERRNO,
 			 "Can't support to test max_map_count");
 
 	old_max_map_count = get_sys_tune("max_map_count");
@@ -108,10 +68,10 @@
 	set_sys_tune("overcommit_memory", 2, 1);
 
 	if (uname(&un) != 0)
-		tst_brkm(TBROK | TERRNO, NULL, "uname error");
+		tst_brk(TBROK | TERRNO, "uname error");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", old_overcommit, 0);
 	set_sys_tune("max_map_count", old_max_map_count, 0);
@@ -162,7 +122,7 @@
 	snprintf(buf, BUFSIZ, "/proc/%d/maps", pid);
 	fp = fopen(buf, "r");
 	if (fp == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "fopen %s", buf);
+		tst_brk(TBROK | TERRNO, "fopen %s", buf);
 	while (getline(&line, &len, fp) != -1) {
 		/* exclude vdso and vsyscall */
 		if (filter_map(line))
@@ -200,7 +160,7 @@
 	 *    step 1) will be used first.
 	 * Hope OOM-killer can be more stable oneday.
 	 */
-	memfree = read_meminfo("CommitLimit:") - read_meminfo("Committed_AS:");
+	memfree = SAFE_READ_MEMINFO("CommitLimit:") - SAFE_READ_MEMINFO("Committed_AS:");
 	/* 64 used as a bias to make sure no overflow happen */
 	max_iters = memfree / sysconf(_SC_PAGESIZE) * 1024 - 64;
 	if (max_iters > MAX_MAP_COUNT)
@@ -210,24 +170,21 @@
 	while (max_maps <= max_iters) {
 		set_sys_tune("max_map_count", max_maps, 1);
 
-		switch (pid = tst_fork()) {
-		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork");
+		switch (pid = SAFE_FORK()) {
 		case 0:
 			while (mmap(NULL, 1, PROT_READ,
 				    MAP_SHARED | MAP_ANONYMOUS, -1, 0)
 			       != MAP_FAILED) ;
 			if (raise(SIGSTOP) != 0)
-				tst_brkm(TBROK | TERRNO, tst_exit, "raise");
+				tst_brk(TBROK | TERRNO, "raise");
 			exit(0);
 		default:
 			break;
 		}
 		/* wait child done mmap and stop */
-		if (waitpid(pid, &status, WUNTRACED) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+		SAFE_WAITPID(pid, &status, WUNTRACED);
 		if (!WIFSTOPPED(status))
-			tst_brkm(TBROK, cleanup, "child did not stopped");
+			tst_brk(TBROK, "child did not stopped");
 
 		map_count = count_maps(pid);
 		/* Note max_maps will be exceeded by one for
@@ -236,18 +193,25 @@
 		 * writing this COMMENT!
 		*/
 		if (map_count == (max_maps + 1))
-			tst_resm(TPASS, "%ld map entries in total "
+			tst_res(TPASS, "%ld map entries in total "
 				 "as expected.", max_maps);
 		else
-			tst_resm(TFAIL, "%ld map entries in total, but "
+			tst_res(TFAIL, "%ld map entries in total, but "
 				 "expected %ld entries", map_count, max_maps);
 
 		/* make child continue to exit */
-		if (kill(pid, SIGCONT) != 0)
-			tst_brkm(TBROK | TERRNO, cleanup, "kill");
-		if (waitpid(pid, &status, 0) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+		SAFE_KILL(pid, SIGCONT);
+		SAFE_WAITPID(pid, &status, 0);
 
 		max_maps = max_maps << 1;
 	}
 }
+
+static struct tst_test test = {
+	.tid = "max_map_count",
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = max_map_count_test,
+};
diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c
index 493c37e..9875345 100644
--- a/testcases/kernel/mem/tunable/min_free_kbytes.c
+++ b/testcases/kernel/mem/tunable/min_free_kbytes.c
@@ -1,4 +1,18 @@
 /*
+ * Copyright (C) 2012-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Description:
+ *
  * The case is designed to test min_free_kbytes tunable.
  *
  * The tune is used to control free memory, and system always
@@ -12,49 +26,19 @@
  * a) default min_free_kbytes with all overcommit memory policy
  * b) 2x default value with all overcommit memory policy
  * c) 5% of MemFree or %2 MemTotal with all overcommit memory policy
- *
- ********************************************************************
- * Copyright (C) 2012 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * ********************************************************************
  */
 
-#include <sys/types.h>
-#include <sys/mman.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "test.h"
 #include "mem.h"
 
 #define MAP_SIZE (1UL<<20)
 
 volatile int end;
-char *TCID = "min_free_kbytes";
-int TST_TOTAL = 1;
 static unsigned long default_tune;
 static unsigned long orig_overcommit;
 static unsigned long total_mem;
@@ -64,50 +48,37 @@
 static void check_monitor(void);
 static void sighandler(int signo LTP_ATTRIBUTE_UNUSED);
 
-int main(int argc, char *argv[])
+static void min_free_kbytes_test(void)
 {
-	int lc, pid, status;
+	int pid, status;
 	struct sigaction sa;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 	sa.sa_handler = sighandler;
 	if (sigemptyset(&sa.sa_mask) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "sigemptyset");
+		tst_brk(TBROK | TERRNO, "sigemptyset");
 	sa.sa_flags = 0;
 	if (sigaction(SIGUSR1, &sa, NULL) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "sigaction");
+		tst_brk(TBROK | TERRNO, "sigaction");
 
-	setup();
-
-	switch (pid = fork()) {
-	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork");
-
-	case 0:
+	pid = SAFE_FORK();
+	if (pid == 0) {
 		/* startup the check monitor */
 		check_monitor();
 		exit(0);
 	}
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+	test_tune(2);
+	test_tune(0);
+	test_tune(1);
 
-		test_tune(2);
-		test_tune(0);
-		test_tune(1);
-	}
+	SAFE_KILL(pid, SIGUSR1);
+	SAFE_WAITPID(pid, &status, WUNTRACED | WCONTINUED);
 
-	if (kill(pid, SIGUSR1) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "kill %d", pid);
-	if (waitpid(pid, &status, WUNTRACED | WCONTINUED) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
 	if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
-		tst_resm(TFAIL,
+		tst_res(TFAIL,
 			 "check_monitor child exit with status: %d", status);
 
-	cleanup();
-	tst_exit();
+	tst_res(TPASS, "min_free_kbytes test pass");
 }
 
 static void test_tune(unsigned long overcommit_policy)
@@ -128,8 +99,8 @@
 			set_sys_tune("min_free_kbytes", 2 * default_tune, 1);
 			/* case3 */
 		} else {
-			memfree = read_meminfo("MemFree:");
-			memtotal = read_meminfo("MemTotal:");
+			memfree = SAFE_READ_MEMINFO("MemFree:");
+			memtotal = SAFE_READ_MEMINFO("MemTotal:");
 			tune = memfree / 20;
 			if (tune > (memtotal / 50))
 				tune = memtotal / 50;
@@ -140,18 +111,17 @@
 		fflush(stdout);
 		switch (pid[i] = fork()) {
 		case -1:
-			tst_brkm(TBROK | TERRNO, cleanup, "fork");
+			tst_brk(TBROK | TERRNO, "fork");
 		case 0:
 			ret = eatup_mem(overcommit_policy);
 			exit(ret);
 		}
 
-		if (waitpid(pid[i], &status, WUNTRACED | WCONTINUED) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
+		SAFE_WAITPID(pid[i], &status, WUNTRACED | WCONTINUED);
 
 		if (overcommit_policy == 2) {
 			if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
-				tst_resm(TFAIL,
+				tst_res(TFAIL,
 					 "child unexpectedly failed: %d",
 					 status);
 		} else if (overcommit_policy == 1) {
@@ -160,25 +130,25 @@
 			{
 				if (total_mem < 3145728UL)
 #endif
-					tst_resm(TFAIL,
+					tst_res(TFAIL,
 						 "child unexpectedly failed: %d",
 						 status);
 #if __WORDSIZE == 32
 				/* in 32-bit system, a process allocate about 3Gb memory at most */
 				else
-					tst_resm(TINFO, "Child can't allocate "
+					tst_res(TINFO, "Child can't allocate "
 						 ">3Gb memory in 32bit system");
 			}
 #endif
 		} else {
 			if (WIFEXITED(status)) {
 				if (WEXITSTATUS(status) != 0) {
-					tst_resm(TFAIL, "child unexpectedly "
+					tst_res(TFAIL, "child unexpectedly "
 						 "failed: %d", status);
 				}
 			} else if (!WIFSIGNALED(status) ||
 				   WTERMSIG(status) != SIGKILL) {
-				tst_resm(TFAIL,
+				tst_res(TFAIL,
 					 "child unexpectedly failed: %d",
 					 status);
 			}
@@ -192,7 +162,7 @@
 	unsigned long memfree;
 	void *addrs;
 
-	memfree = read_meminfo("MemFree:");
+	memfree = SAFE_READ_MEMINFO("MemFree:");
 	printf("memfree is %lu kB before eatup mem\n", memfree);
 	while (1) {
 		addrs = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE,
@@ -206,7 +176,7 @@
 		}
 		memset(addrs, 1, MAP_SIZE);
 	}
-	memfree = read_meminfo("MemFree:");
+	memfree = SAFE_READ_MEMINFO("MemFree:");
 	printf("memfree is %lu kB after eatup mem\n", memfree);
 
 	return ret;
@@ -218,13 +188,13 @@
 	unsigned long memfree;
 
 	while (end) {
-		memfree = read_meminfo("MemFree:");
+		memfree = SAFE_READ_MEMINFO("MemFree:");
 		tune = get_sys_tune("min_free_kbytes");
 
 		if (memfree < tune) {
-			tst_resm(TINFO, "MemFree is %lu kB, "
+			tst_res(TINFO, "MemFree is %lu kB, "
 				 "min_free_kbytes is %lu kB", memfree, tune);
-			tst_resm(TFAIL, "MemFree < min_free_kbytes");
+			tst_res(TFAIL, "MemFree < min_free_kbytes");
 		}
 
 		sleep(2);
@@ -236,25 +206,30 @@
 	end = 1;
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
 	if (get_sys_tune("panic_on_oom")) {
-		tst_brkm(TCONF, NULL,
+		tst_brk(TCONF,
 			"panic_on_oom is set, disable it to run these testcases");
 	}
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
-
-	total_mem = read_meminfo("MemTotal:") + read_meminfo("SwapTotal:");
+	total_mem = SAFE_READ_MEMINFO("MemTotal:") + SAFE_READ_MEMINFO("SwapTotal:");
 
 	default_tune = get_sys_tune("min_free_kbytes");
 	orig_overcommit = get_sys_tune("overcommit_memory");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("min_free_kbytes", default_tune, 0);
 	set_sys_tune("overcommit_memory", orig_overcommit, 0);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.timeout = -1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = min_free_kbytes_test,
+};
diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c
index 79a3034..984448b 100644
--- a/testcases/kernel/mem/tunable/overcommit_memory.c
+++ b/testcases/kernel/mem/tunable/overcommit_memory.c
@@ -1,4 +1,18 @@
 /*
+ * Copyright (C) 2012-2017  Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Descriptions:
+ *
  * There are two tunables overcommit_memory and overcommit_ratio under
  * /proc/sys/vm/, which can control memory overcommitment.
  *
@@ -49,45 +63,24 @@
  * References:
  * - Documentation/sysctl/vm.txt
  * - Documentation/vm/overcommit-accounting
- *
- * ********************************************************************
- * Copyright (C) 2012 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * ********************************************************************
  */
 
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "test.h"
-#include "safe_macros.h"
+#include <limits.h>
 #include "mem.h"
 
 #define DEFAULT_OVER_RATIO	50L
 #define EXPECT_PASS		0
 #define EXPECT_FAIL		1
 
-char *TCID = "overcommit_memory";
+static char *R_opt;
+static struct tst_option options[] = {
+	{"R:", &R_opt, "  -R n    Percentage of overcommitting memory"},
+	{NULL, NULL, NULL}
+};
+
 static long old_overcommit_memory;
 static long old_overcommit_ratio;
 static long overcommit_ratio;
@@ -95,102 +88,64 @@
 static long free_total;
 static long commit_limit;
 static long commit_left;
-static int R_flag;
-static char *R_opt;
-option_t options[] = {
-	{"R:", &R_flag, &R_opt},
-	{NULL, NULL, NULL}
-};
 
-static void overcommit_memory_test(void);
 static int heavy_malloc(long size);
 static void alloc_and_check(long size, int expect_result);
-static void usage(void);
 static void update_mem(void);
 
-int main(int argc, char *argv[])
-{
-	int lc;
-
-	tst_parse_opts(argc, argv, options, &usage);
-
-#if __WORDSIZE == 32
-	tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
-#endif
-
-	if (R_flag)
-		overcommit_ratio = SAFE_STRTOL(NULL, R_opt, 0, LONG_MAX);
-	else
-		overcommit_ratio = DEFAULT_OVER_RATIO;
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		overcommit_memory_test();
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-void setup(void)
+static void setup(void)
 {
 	long mem_total, swap_total;
 	struct rlimit lim;
 
-	tst_require_root();
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
 	if (access(PATH_SYSVM "overcommit_memory", F_OK) == -1 ||
 	    access(PATH_SYSVM "overcommit_ratio", F_OK) == -1)
-		tst_brkm(TCONF, NULL, "The system "
+		tst_brk(TCONF, "The system "
 			 "can't support to test %s", TCID);
 
+	if (R_opt)
+		overcommit_ratio = SAFE_STRTOL(R_opt, 0, LONG_MAX);
+	else
+		overcommit_ratio = DEFAULT_OVER_RATIO;
+
 	old_overcommit_memory = get_sys_tune("overcommit_memory");
 	old_overcommit_ratio = get_sys_tune("overcommit_ratio");
 
-	mem_total = read_meminfo("MemTotal:");
-	tst_resm(TINFO, "MemTotal is %ld kB", mem_total);
-	swap_total = read_meminfo("SwapTotal:");
-	tst_resm(TINFO, "SwapTotal is %ld kB", swap_total);
+	mem_total = SAFE_READ_MEMINFO("MemTotal:");
+	tst_res(TINFO, "MemTotal is %ld kB", mem_total);
+	swap_total = SAFE_READ_MEMINFO("SwapTotal:");
+	tst_res(TINFO, "SwapTotal is %ld kB", swap_total);
 	sum_total = mem_total + swap_total;
 
-	commit_limit = read_meminfo("CommitLimit:");
-	tst_resm(TINFO, "CommitLimit is %ld kB", commit_limit);
+	commit_limit = SAFE_READ_MEMINFO("CommitLimit:");
+	tst_res(TINFO, "CommitLimit is %ld kB", commit_limit);
 
-	SAFE_GETRLIMIT(NULL, RLIMIT_AS, &lim);
+	SAFE_GETRLIMIT(RLIMIT_AS, &lim);
 
 	if (lim.rlim_cur != RLIM_INFINITY) {
 		lim.rlim_cur = RLIM_INFINITY;
 		lim.rlim_max = RLIM_INFINITY;
 
-		tst_resm(TINFO, "Increasing RLIM_AS to INFINITY");
+		tst_res(TINFO, "Increasing RLIM_AS to INFINITY");
 
-		SAFE_SETRLIMIT(NULL, RLIMIT_AS, &lim);
+		SAFE_SETRLIMIT(RLIMIT_AS, &lim);
 	}
 
 	set_sys_tune("overcommit_ratio", overcommit_ratio, 1);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
 	set_sys_tune("overcommit_memory", old_overcommit_memory, 0);
 	set_sys_tune("overcommit_ratio", old_overcommit_ratio, 0);
 }
 
-static void usage(void)
-{
-	printf("  -R n    Percentage of overcommitting memory\n");
-}
-
 static void overcommit_memory_test(void)
 {
+
+#if __WORDSIZE == 32
+	tst_brk(TCONF, "test is not designed for 32-bit system.");
+#endif
 	/* start to test overcommit_memory=2 */
 	set_sys_tune("overcommit_memory", 2, 1);
 
@@ -224,11 +179,11 @@
 
 	p = malloc(size * KB);
 	if (p != NULL) {
-		tst_resm(TINFO, "malloc %ld kB successfully", size);
+		tst_res(TINFO, "malloc %ld kB successfully", size);
 		free(p);
 		return 0;
 	} else {
-		tst_resm(TINFO, "malloc %ld kB failed", size);
+		tst_res(TINFO, "malloc %ld kB failed", size);
 		return 1;
 	}
 }
@@ -243,18 +198,18 @@
 	switch (expect_result) {
 	case EXPECT_PASS:
 		if (result == 0)
-			tst_resm(TPASS, "alloc passed as expected");
+			tst_res(TPASS, "alloc passed as expected");
 		else
-			tst_resm(TFAIL, "alloc failed, expected to pass");
+			tst_res(TFAIL, "alloc failed, expected to pass");
 		break;
 	case EXPECT_FAIL:
 		if (result != 0)
-			tst_resm(TPASS, "alloc failed as expected");
+			tst_res(TPASS, "alloc failed as expected");
 		else
-			tst_resm(TFAIL, "alloc passed, expected to fail");
+			tst_res(TFAIL, "alloc passed, expected to fail");
 		break;
 	default:
-		tst_brkm(TBROK, cleanup, "Invaild numbler parameter: %d",
+		tst_brk(TBROK, "Invaild numbler parameter: %d",
 			 expect_result);
 	}
 }
@@ -264,20 +219,28 @@
 	long mem_free, swap_free;
 	long committed;
 
-	mem_free = read_meminfo("MemFree:");
-	swap_free = read_meminfo("SwapFree:");
+	mem_free = SAFE_READ_MEMINFO("MemFree:");
+	swap_free = SAFE_READ_MEMINFO("SwapFree:");
 	free_total = mem_free + swap_free;
-	commit_limit = read_meminfo("CommitLimit:");
+	commit_limit = SAFE_READ_MEMINFO("CommitLimit:");
 
 	if (get_sys_tune("overcommit_memory") == 2) {
-		committed = read_meminfo("Committed_AS:");
+		committed = SAFE_READ_MEMINFO("Committed_AS:");
 		commit_left = commit_limit - committed;
 
 		if (commit_left < 0) {
-			tst_resm(TINFO, "CommitLimit is %ld, Committed_AS"
+			tst_res(TINFO, "CommitLimit is %ld, Committed_AS"
 				 " is %ld", commit_limit, committed);
-			tst_brkm(TBROK, cleanup, "Unexpected error: "
+			tst_brk(TBROK, "Unexpected error: "
 				 "CommitLimit < Committed_AS");
 		}
 	}
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.options = options,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = overcommit_memory_test,
+};
diff --git a/testcases/kernel/mem/vma/Makefile b/testcases/kernel/mem/vma/Makefile
index b323dbf..3a4e2b4 100644
--- a/testcases/kernel/mem/vma/Makefile
+++ b/testcases/kernel/mem/vma/Makefile
@@ -19,6 +19,11 @@
 
 top_srcdir              ?= ../../../..
 
+vma05_vdso: CFLAGS+=-ggdb3
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
+
+INSTALL_TARGETS		:= vma05.sh
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/vma/vma02.c b/testcases/kernel/mem/vma/vma02.c
index d3c436a..ae35b2a 100644
--- a/testcases/kernel/mem/vma/vma02.c
+++ b/testcases/kernel/mem/vma/vma02.c
@@ -41,6 +41,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <limits.h>
 #include "test.h"
 #include "safe_macros.h"
 #include "numa_helper.h"
diff --git a/testcases/kernel/mem/vma/vma04.c b/testcases/kernel/mem/vma/vma04.c
index f4f3809..5e2cc91 100644
--- a/testcases/kernel/mem/vma/vma04.c
+++ b/testcases/kernel/mem/vma/vma04.c
@@ -45,6 +45,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <limits.h>
 #include "test.h"
 #include "safe_macros.h"
 #include "numa_helper.h"
diff --git a/testcases/kernel/mem/vma/vma05.sh b/testcases/kernel/mem/vma/vma05.sh
new file mode 100755
index 0000000..d96d391
--- /dev/null
+++ b/testcases/kernel/mem/vma/vma05.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# Copyright (C) 2017 Red Hat, Inc.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
+# Test description: [regression] Check if the vsyscall and vdso VMA regions are
+#                   reported correctly.
+#
+#       While [vsyscall] is mostly deprecated with newer systems, there is
+#       still plenty of kernels compiled with CONFIG_LEGACY_VSYSCALL_NATIVE and
+#       CONFIG_LEGACY_VSYSCALL_EMULATE (see linux/arch/x86/Kconfig for option
+#       descriptions). First part of the test will check eligible kernels for
+#       regression for a bug fixed by commit 103efcd9aac1 (fix perms/range of
+#       vsyscall vma in /proc/*/maps).
+#
+#       Second part of test checks [vdso] VMA permissions (fixed with commits
+#       b6558c4a2378 (fix [vdso] page permissions) and e5b97dde514f (Add
+#       VM_ALWAYSDUMP)). As a consequence of this bug, VMAs were not included
+#       in core dumps which resulted in eg. incomplete backtraces and invalid
+#       core dump files created by gdb.
+
+# Usage
+# ./vma05.sh
+
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+TST_TESTFUNC=vma_report_check
+TST_NEEDS_ROOT=1
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="gdb"
+
+. tst_test.sh
+
+CORE_LIMIT=$(ulimit -c)
+CORE_PATTERN=$(cat /proc/sys/kernel/core_pattern)
+
+setup()
+{
+	ulimit -c unlimited
+	echo "core" > /proc/sys/kernel/core_pattern
+}
+
+cleanup()
+{
+	ulimit -c "$CORE_LIMIT"
+	echo "$CORE_PATTERN" > /proc/sys/kernel/core_pattern
+}
+
+vma_report_check()
+{
+	if [ $(uname -m) = "x86_64" ]; then
+		if LINE=$(grep "vsyscall" /proc/self/maps); then
+			RIGHT="ffffffffff600000-ffffffffff601000[[:space:]]r-xp"
+			if echo "$LINE" | grep -q "$RIGHT"; then
+				tst_res TPASS "[vsyscall] reported correctly"
+			else
+				tst_res TFAIL "[vsyscall] reporting wrong"
+			fi
+		fi
+	fi
+
+	rm -rf core*
+	{ vma05_vdso; } > /dev/null 2>&1
+	TRACE=$(gdb -silent -ex="thread apply all backtrace" -ex="quit"\
+		vma05_vdso ./core* 2> /dev/null)
+	if echo "$TRACE" | grep -qF "??"; then
+		tst_res TFAIL "[vdso] bug not patched"
+	else
+		tst_res TPASS "[vdso] backtrace complete"
+	fi
+}
+
+tst_run
diff --git a/testcases/kernel/mem/vma/vma05_vdso.c b/testcases/kernel/mem/vma/vma05_vdso.c
new file mode 100644
index 0000000..507de50
--- /dev/null
+++ b/testcases/kernel/mem/vma/vma05_vdso.c
@@ -0,0 +1,7 @@
+#include <signal.h>
+
+int main(void)
+{
+	raise(SIGSEGV);
+	return 0;
+}
diff --git a/testcases/kernel/module/delete_module/delete_module01.c b/testcases/kernel/module/delete_module/delete_module01.c
index da5b08b..a159de8 100644
--- a/testcases/kernel/module/delete_module/delete_module01.c
+++ b/testcases/kernel/module/delete_module/delete_module01.c
@@ -28,7 +28,7 @@
 #include "test.h"
 #include "old_module.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define MODULE_NAME	"dummy_del_mod"
 #define MODULE_NAME_KO	"dummy_del_mod.ko"
diff --git a/testcases/kernel/module/delete_module/delete_module02.c b/testcases/kernel/module/delete_module/delete_module02.c
index 0e60645..edfe638 100644
--- a/testcases/kernel/module/delete_module/delete_module02.c
+++ b/testcases/kernel/module/delete_module/delete_module02.c
@@ -42,7 +42,7 @@
 #include <sys/mman.h>
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define NULLMODNAME	""
 #define BASEMODNAME	"dummy"
diff --git a/testcases/kernel/module/delete_module/delete_module03.c b/testcases/kernel/module/delete_module/delete_module03.c
index cf58ded..cbf9ff6 100644
--- a/testcases/kernel/module/delete_module/delete_module03.c
+++ b/testcases/kernel/module/delete_module/delete_module03.c
@@ -28,7 +28,7 @@
 #include "test.h"
 #include "old_module.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define DUMMY_MOD		"dummy_del_mod"
 #define DUMMY_MOD_KO		"dummy_del_mod.ko"
diff --git a/testcases/kernel/numa/README b/testcases/kernel/numa/README
index 57b12f7..846d36d 100644
--- a/testcases/kernel/numa/README
+++ b/testcases/kernel/numa/README
@@ -54,6 +54,11 @@
 TestCase10:
 Verifieds the NUMA migratepages policy.
 
+TestCase11:
+Verifies the hugepage memory allocated from the node we specify.
+
+TestCase12:
+Verifies the preferred node policy with THP memory allocating from the node we specify.
 
 Pre-requisites
 ====================================================================================================================
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index f0f6139..fd3b4be 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -31,11 +31,12 @@
 #               Test #8: Verifies memhog                                     #
 #               Test #9: Verifies numa_node_size api                         #
 #               Test #10:Verifies Migratepages                               #
+#               Test #11:Verifies hugepage alloacted on specified node       #
+#               Test #12:Verifies THP memory allocated on preferred node     #
 #                                                                            #
 ##############################################################################
 
-TST_ID="numa01"
-TST_CNT=10
+TST_CNT=12
 TST_SETUP=setup
 TST_TESTFUNC=test
 TST_NEEDS_TMPDIR=1
@@ -55,7 +56,7 @@
 	local pid=$1
 	local node=$(($2 + 2))
 
-	echo $(numastat -p $pid |grep '^Total' |awk '{print $'$node'}')
+	echo $(numastat -p $pid |awk '/^Total/ {print $'$node'}')
 }
 
 wait_for_support_numa()
@@ -83,11 +84,7 @@
 {
 	export MB=$((1024*1024))
 	export PAGE_SIZE=$(getconf PAGE_SIZE)
-
-	# arguments to memory exercise program support_numa.c
-	ALLOC_1MB=1
-	SHARE_1MB=2
-	PAUSE=3
+	export HPAGE_SIZE=$(awk '/Hugepagesize:/ {print $2}' /proc/meminfo)
 
 	total_nodes=0
 
@@ -109,7 +106,7 @@
 	Mem_curr=0
 
 	for node in $nodes_list; do
-		numactl --cpunodebind=$node --membind=$node support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --membind=$node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -118,6 +115,7 @@
 		if [ $(echo "$Mem_curr < $MB" | bc) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA memory allocated in node$node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
 			return
 		fi
 
@@ -142,7 +140,7 @@
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -151,6 +149,7 @@
 		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA memory allocated in node$Preferred_node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
 			return
 		fi
 
@@ -177,7 +176,7 @@
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $SHARE_1MB &
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB_shared &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -186,6 +185,7 @@
 		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA share memory allocated in node$Preferred_node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
 			return
 		fi
 
@@ -203,7 +203,7 @@
 	# Memory will be allocated using round robin on nodes.
 	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-	numactl --interleave=all support_numa $ALLOC_1MB &
+	numactl --interleave=all support_numa alloc_1MB &
 	pid=$!
 
 	wait_for_support_numa $pid
@@ -214,6 +214,7 @@
 		if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA interleave memory allocated in node$node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
 			return
 		fi
 	done
@@ -229,7 +230,7 @@
 	# Memory will be allocated using round robin on nodes.
 	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-	numactl --interleave=all support_numa $SHARE_1MB &
+	numactl --interleave=all support_numa alloc_1MB_shared &
 	pid=$!
 
 	wait_for_support_numa $pid
@@ -240,6 +241,7 @@
 		if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA interleave share memory allocated in node$node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
 			return
 		fi
 	done
@@ -259,7 +261,7 @@
 	no_of_cpus=$(tst_ncpus)
 	# not sure whether cpu's can't be in odd number
 	run_on_cpu=$(($((no_of_cpus+1))/2))
-	numactl --physcpubind=$run_on_cpu support_numa $PAUSE & #just waits for sigint
+	numactl --physcpubind=$run_on_cpu support_numa pause & #just waits for sigint
 	pid=$!
 	var=`awk '{ print $2 }' /proc/$pid/stat`
 	while [ $var = '(numactl)' ]; do
@@ -287,7 +289,7 @@
 	Mem_curr=0
 
 	for node in $nodes_list; do
-		numactl --cpunodebind=$node --localalloc support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --localalloc support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -296,6 +298,7 @@
 		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA localnode memory allocated in node$node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
 			return
 		fi
 
@@ -312,20 +315,32 @@
 	# Memory will be allocated using round robin on nodes.
 	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-	numactl --interleave=all memhog -r1000000 1MB 2>&1 >/dev/null &
+	numactl --interleave=all memhog -r1000000 1MB 2>&1 >ltp_numa_test8.log &
 	pid=$!
 
+	local retries=20
+	while [ $retries -gt 0 ]; do
+
+		if grep -m1 -q '.' ltp_numa_test8.log; then
+			break
+		fi
+
+		retries=$((retries-1))
+		tst_sleep 50ms
+	done
+
 	for node in $nodes_list; do
 		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
 
 		if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA interleave memhog in node$node is less than expected"
+			kill -KILL $pid >/dev/null 2>&1
 			return
 		fi
 	done
 
-	kill -9 $pid >/dev/null 2>&1
+	kill -KILL $pid >/dev/null 2>&1
 	tst_res TPASS "NUMA MEMHOG policy"
 }
 
@@ -378,7 +393,7 @@
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --preferred=$node support_numa $ALLOC_1MB &
+		numactl --preferred=$node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -389,6 +404,7 @@
 		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
 			tst_res TFAIL \
 				"NUMA migratepages is not working fine"
+			kill -CONT $pid >/dev/null 2>&1
 			return
 		fi
 
@@ -399,4 +415,88 @@
 	tst_res TPASS "NUMA MIGRATEPAGES policy"
 }
 
+# Verification of hugepage memory allocated on a node
+test11()
+{
+	Mem_huge=0
+	Sys_node=/sys/devices/system/node
+
+	if [ ! -d "/sys/kernel/mm/hugepages/" ]; then
+		tst_res TCONF "hugepage is not supported"
+		return
+	fi
+
+	for node in $nodes_list; do
+		Ori_hpgs=$(cat ${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages)
+		New_hpgs=$((Ori_hpgs + 1))
+		echo $New_hpgs >${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages
+
+		Chk_hpgs=$(cat ${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages)
+		if [ "$Chk_hpgs" -ne "$New_hpgs" ]; then
+			tst_res TCONF "hugepage is not enough to test"
+			return
+		fi
+
+		numactl --cpunodebind=$node --membind=$node support_numa alloc_1huge_page &
+		pid=$!
+		wait_for_support_numa $pid
+
+		Mem_huge=$(echo $(numastat -p $pid |awk '/^Huge/ {print $'$((node+2))'}'))
+		Mem_huge=$((${Mem_huge%.*} * 1024))
+
+		if [ "$Mem_huge" -lt "$HPAGE_SIZE" ]; then
+			tst_res TFAIL \
+				"NUMA memory allocated in node$node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
+			echo $Ori_hpgs >${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages
+			return
+		fi
+
+		kill -CONT $pid >/dev/null 2>&1
+		echo $Ori_hpgs >${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages
+	done
+
+	tst_res TPASS "NUMA local node hugepage memory allocated"
+}
+
+# Verification of THP memory allocated on preferred node
+test12()
+{
+	Mem_curr=0
+
+	if ! grep -q '\[always\]' /sys/kernel/mm/transparent_hugepage/enabled; then
+		tst_res TCONF "THP is not supported/enabled"
+		return
+	fi
+
+	COUNTER=1
+	for node in $nodes_list; do
+
+		if [ $COUNTER -eq $total_nodes ]; then   #wrap up for last node
+			Preferred_node=$(echo $nodes_list | cut -d ' ' -f 1)
+		else
+			# always next node is preferred node
+			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
+		fi
+
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_2HPSZ_THP &
+		pid=$!
+
+		wait_for_support_numa $pid
+
+		Mem_curr=$(echo "$(extract_numastat_p $pid $Preferred_node) * 1024" |bc)
+		if [ $(echo "$Mem_curr < $HPAGE_SIZE * 2" |bc ) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA memory allocated in node$Preferred_node is less than expected"
+			kill -CONT $pid >/dev/null 2>&1
+			return
+		fi
+
+		COUNTER=$((COUNTER+1))
+		kill -CONT $pid >/dev/null 2>&1
+	done
+
+	tst_res TPASS "NUMA preferred node policy verified with THP enabled"
+}
+
 tst_run
diff --git a/testcases/kernel/numa/support_numa.c b/testcases/kernel/numa/support_numa.c
index eaf63e3..4e8be4c 100644
--- a/testcases/kernel/numa/support_numa.c
+++ b/testcases/kernel/numa/support_numa.c
@@ -22,7 +22,7 @@
 /*                                                                            */
 /* File:        support_numa.c                                                */
 /*                                                                            */
-/* Description: Allocates 1MB of memory and touches it to verify numa         */
+/* Description: Allocates memory and touches it to verify numa                */
 /*                                                                            */
 /* Author:      Sivakumar Chinnaiah  Sivakumar.C@in.ibm.com                   */
 /*                                                                            */
@@ -39,6 +39,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <fcntl.h>
+#include "lapi/mmap.h"
 
 /* Global Variables */
 #define MB (1<<20)
@@ -50,18 +51,46 @@
 static void help(void)
 {
 	printf("Input:	Describe input arguments to this program\n");
-	printf("	argv[1] == 1 then allocate 1MB of memory\n");
-	printf("	argv[1] == 2 then allocate 1MB of share memory\n");
-	printf("	argv[1] == 3 then pause the program to catch sigint\n");
+	printf("	argv[1] == \"alloc_1MB\" then allocate 1MB of memory\n");
+	printf("	argv[1] == \"alloc_1MB_shared\" then allocate 1MB of share memory\n");
+	printf("	argv[1] == \"alloc_2HPSZ_THP\" then allocate 2HUGE PAGE SIZE of THP memory\n");
+	printf("        argv[1] == \"alloc_1huge_page\" then allocate 1HUGE PAGE SIZE of memory\n");
+	printf("        argv[1] == \"pause\" then pause the program to catch sigint\n");
 	printf("Exit:	On failure - Exits with non-zero value\n");
 	printf("	On success - exits with 0 exit value\n");
 
 	exit(1);
 }
 
+static int read_hugepagesize(void)
+{
+	FILE *fp;
+	char line[BUFSIZ], buf[BUFSIZ];
+	int val;
+
+	fp = fopen("/proc/meminfo", "r");
+	if (fp == NULL) {
+		fprintf(stderr, "Failed to open /proc/meminfo");
+		return 0;
+	}
+
+	while (fgets(line, BUFSIZ, fp) != NULL) {
+		if (sscanf(line, "%64s %d", buf, &val) == 2)
+			if (strcmp(buf, "Hugepagesize:") == 0) {
+				fclose(fp);
+				return 1024 * val;
+			}
+	}
+
+	fclose(fp);
+	fprintf(stderr, "can't find \"%s\" in %s", "Hugepagesize:", "/proc/meminfo");
+
+	return 0;
+}
+
 int main(int argc, char *argv[])
 {
-	int i, fd, rc;
+	int i, fd, rc, hpsz;
 	char *buf = NULL;
 	struct stat sb;
 
@@ -70,8 +99,7 @@
 		exit(1);
 	}
 
-	switch (atoi(argv[1])) {
-	case 1:
+	if (!strcmp(argv[1], "alloc_1MB")) {
 		buf = malloc(MB);
 		if (!buf) {
 			fprintf(stderr, "Memory is not available\n");
@@ -85,8 +113,7 @@
 		raise(SIGSTOP);
 
 		free(buf);
-		break;
-	case 2:
+	} else if (!strcmp(argv[1], "alloc_1MB_shared")) {
 		fd = open(TEST_SFILE, O_RDWR | O_CREAT, 0666);
 		/* Writing 1MB of random data into this file [32 * 32768 = 1024 * 1024] */
 		for (i = 0; i < 32768; i++){
@@ -112,11 +139,46 @@
 		munmap(buf, sb.st_size);
 		close(fd);
 		remove(TEST_SFILE);
-		break;
-	case 3:
+	} else if (!strcmp(argv[1], "alloc_2HPSZ_THP")) {
+		ssize_t size = 2 * read_hugepagesize();
+		if (size == 0)
+			exit(1);
+
+		buf = mmap(NULL, size, PROT_READ | PROT_WRITE,
+				MAP_PRIVATE | MAP_ANONYMOUS,
+				-1, 0);
+		if (buf == MAP_FAILED) {
+			perror("mmap failed");
+			exit(1);
+		}
+
+		memset(buf, 'a', size);
+
 		raise(SIGSTOP);
-		break;
-	default:
+
+		munmap(buf, size);
+	} else if (!strcmp(argv[1], "alloc_1huge_page")) {
+		hpsz = read_hugepagesize();
+		if (hpsz == 0)
+			exit(1);
+
+		buf = mmap(NULL, hpsz, PROT_READ | PROT_WRITE,
+				MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
+				-1, 0);
+
+		if (buf == MAP_FAILED) {
+			perror("mmap failed");
+			exit(1);
+		}
+
+		memset(buf, 'a', hpsz);
+
+		raise(SIGSTOP);
+
+		munmap(buf, hpsz);
+	} else if (!strcmp(argv[1], "pause")) {
+		raise(SIGSTOP);
+	} else {
 		help();
 	}
 
diff --git a/testcases/kernel/sched/autogroup/.gitignore b/testcases/kernel/sched/autogroup/.gitignore
new file mode 100644
index 0000000..bcc7453
--- /dev/null
+++ b/testcases/kernel/sched/autogroup/.gitignore
@@ -0,0 +1 @@
+/autogroup01
diff --git a/testcases/kernel/sched/autogroup/Makefile b/testcases/kernel/sched/autogroup/Makefile
new file mode 100644
index 0000000..6cc7782
--- /dev/null
+++ b/testcases/kernel/sched/autogroup/Makefile
@@ -0,0 +1,23 @@
+#
+#  Copyright (c) 2017 Fujitsu Ltd.
+#  Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
+#
+#  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, see <http://www.gnu.org/licenses/>.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/autogroup/autogroup01.c b/testcases/kernel/sched/autogroup/autogroup01.c
new file mode 100644
index 0000000..9c4e911
--- /dev/null
+++ b/testcases/kernel/sched/autogroup/autogroup01.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017 Fujitsu Ltd.
+ * Ported: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This is a regression test about the race in autogroup, this test
+ * can crash the buggy kernel, and the bug has been fixed in:
+ *
+ *   commit 18f649ef344127ef6de23a5a4272dbe2fdb73dde
+ *   Author: Oleg Nesterov <oleg@redhat.com>
+ *   Date:   Mon Nov 14 19:46:09 2016 +0100
+ *
+ *   sched/autogroup: Fix autogroup_move_group() to never skip sched_move_task()
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "tst_test.h"
+
+#define LOOPS	1000
+#define PATH_AUTOGROUP	"/proc/sys/kernel/sched_autogroup_enabled"
+
+static int orig_autogroup = -1;
+
+static void do_test(void)
+{
+	int i;
+
+	if (!SAFE_FORK()) {
+		SAFE_FILE_PRINTF(PATH_AUTOGROUP, "%d", 1);
+		SAFE_SETSID();
+
+		if (SAFE_FORK())
+			pause();
+
+		SAFE_KILL(getppid(), SIGKILL);
+		usleep(1000);
+
+		// The child has gone, the grandchild runs with kref == 1
+		SAFE_FILE_PRINTF(PATH_AUTOGROUP, "%d", 0);
+		SAFE_SETSID();
+
+		// runs with the freed ag/tg
+		for (i = 0; i < LOOPS; i++)
+			usleep(10);
+
+		TST_CHECKPOINT_WAKE(0);
+
+		exit(0);
+	}
+
+	SAFE_WAIT(NULL); // destroy the child's ag/tg
+
+	TST_CHECKPOINT_WAIT(0);
+
+	tst_res(TPASS, "Bug not reproduced");
+}
+
+static void setup(void)
+{
+	if (access(PATH_AUTOGROUP, F_OK))
+		tst_brk(TCONF, "autogroup not supported");
+
+	SAFE_FILE_SCANF(PATH_AUTOGROUP, "%d", &orig_autogroup);
+}
+
+static void cleanup(void)
+{
+	if (orig_autogroup != -1)
+		SAFE_FILE_PRINTF(PATH_AUTOGROUP, "%d", orig_autogroup);
+}
+
+static struct tst_test test = {
+	.forks_child = 1,
+	.needs_root = 1,
+	.needs_checkpoints = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = do_test,
+};
diff --git a/testcases/kernel/security/dirtyc0w/dirtyc0w.c b/testcases/kernel/security/dirtyc0w/dirtyc0w.c
index fdf5d24..b8094ba 100644
--- a/testcases/kernel/security/dirtyc0w/dirtyc0w.c
+++ b/testcases/kernel/security/dirtyc0w/dirtyc0w.c
@@ -103,7 +103,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "dirtyc0w",
 	.needs_tmpdir = 1,
 	.forks_child = 1,
 	.needs_root = 1,
diff --git a/testcases/kernel/security/dirtyc0w/dirtyc0w_child.c b/testcases/kernel/security/dirtyc0w/dirtyc0w_child.c
index 5328a9b..49abdd6 100644
--- a/testcases/kernel/security/dirtyc0w/dirtyc0w_child.c
+++ b/testcases/kernel/security/dirtyc0w/dirtyc0w_child.c
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <pwd.h>
 
 #include "tst_safe_pthread.h"
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index d5985cd..32193e1 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -53,6 +53,7 @@
 /chroot/chroot04
 /clock_getres/clock_getres01
 /clock_nanosleep/clock_nanosleep01
+/clock_nanosleep/clock_nanosleep02
 /clock_nanosleep2/clock_nanosleep2_01
 /clone/clone01
 /clone/clone02
@@ -62,6 +63,7 @@
 /clone/clone06
 /clone/clone07
 /clone/clone08
+/clone/clone09
 /close/close01
 /close/close02
 /close/close08
@@ -230,6 +232,10 @@
 /fcntl/fcntl33_64
 /fcntl/fcntl34
 /fcntl/fcntl34_64
+/fcntl/fcntl35
+/fcntl/fcntl35_64
+/fcntl/fcntl36
+/fcntl/fcntl36_64
 /fdatasync/fdatasync01
 /fdatasync/fdatasync02
 /flistxattr/flistxattr01
@@ -358,6 +364,7 @@
 /getsid/getsid02
 /getsockname/getsockname01
 /getsockopt/getsockopt01
+/getsockopt/getsockopt02
 /gettid/gettid01
 /gettimeofday/gettimeofday01
 /gettimeofday/gettimeofday02
@@ -439,7 +446,6 @@
 /ipc/semop/semop05
 /ipc/shmat/shmat01
 /ipc/shmat/shmat02
-/ipc/shmat/shmat03
 /ipc/shmctl/shmctl01
 /ipc/shmctl/shmctl02
 /ipc/shmctl/shmctl03
@@ -454,6 +460,8 @@
 /keyctl/keyctl01
 /keyctl/keyctl02
 /keyctl/keyctl03
+/keyctl/keyctl04
+/keyctl/keyctl05
 /kcmp/kcmp01
 /kcmp/kcmp02
 /kcmp/kcmp03
@@ -498,14 +506,7 @@
 /llseek/llseek03
 /lseek/lseek01
 /lseek/lseek02
-/lseek/lseek03
-/lseek/lseek04
-/lseek/lseek05
-/lseek/lseek06
 /lseek/lseek07
-/lseek/lseek08
-/lseek/lseek09
-/lseek/lseek10
 /lseek/lseek11
 /lstat/lstat01
 /lstat/lstat01_64
@@ -616,6 +617,7 @@
 /msync/msync01
 /msync/msync02
 /msync/msync03
+/msync/msync04
 /munlock/munlock01
 /munlock/munlock02
 /munlockall/munlockall01
@@ -976,6 +978,8 @@
 /splice/splice01
 /splice/splice02
 /splice/splice03
+/splice/splice04
+/splice/splice05
 /ssetmask/ssetmask01
 /stat/stat01
 /stat/stat01_64
@@ -1106,7 +1110,6 @@
 /waitpid/waitpid12
 /waitpid/waitpid13
 /write/write01
-/write/write02
 /write/write03
 /write/write04
 /write/write05
@@ -1121,7 +1124,10 @@
 /fanotify/fanotify04
 /fanotify/fanotify05
 /fanotify/fanotify06
+/fanotify/fanotify07
+/fanotify/fanotify08
 /perf_event_open/perf_event_open01
 /perf_event_open/perf_event_open02
 /memfd_create/memfd_create01
 /memfd_create/memfd_create02
+/copy_file_range/copy_file_range01
diff --git a/testcases/kernel/syscalls/accept4/accept4_01.c b/testcases/kernel/syscalls/accept4/accept4_01.c
index a49b23c..dec4ef9 100644
--- a/testcases/kernel/syscalls/accept4/accept4_01.c
+++ b/testcases/kernel/syscalls/accept4/accept4_01.c
@@ -33,7 +33,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define PORT_NUM 33333
 
diff --git a/testcases/kernel/syscalls/access/access01.c b/testcases/kernel/syscalls/access/access01.c
index 25e13b7..7a92525 100644
--- a/testcases/kernel/syscalls/access/access01.c
+++ b/testcases/kernel/syscalls/access/access01.c
@@ -357,7 +357,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "access01",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/access/access02.c b/testcases/kernel/syscalls/access/access02.c
index dc6bfa2..78449ca 100644
--- a/testcases/kernel/syscalls/access/access02.c
+++ b/testcases/kernel/syscalls/access/access02.c
@@ -197,7 +197,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "access02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.needs_tmpdir = 1,
 	.needs_root = 1,
diff --git a/testcases/kernel/syscalls/access/access03.c b/testcases/kernel/syscalls/access/access03.c
index b9a96a0..bba3068 100644
--- a/testcases/kernel/syscalls/access/access03.c
+++ b/testcases/kernel/syscalls/access/access03.c
@@ -94,7 +94,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "access03",
 	.tcnt = ARRAY_SIZE(tcases),
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/access/access04.c b/testcases/kernel/syscalls/access/access04.c
index 820aab6..626e6df 100644
--- a/testcases/kernel/syscalls/access/access04.c
+++ b/testcases/kernel/syscalls/access/access04.c
@@ -121,14 +121,12 @@
 }
 
 static struct tst_test test = {
-	.tid = "access04",
 	.tcnt = ARRAY_SIZE(tcases),
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.forks_child = 1,
-	.mount_device = 1,
+	.needs_rofs = 1,
 	.mntpoint = MNT_POINT,
-	.mnt_flags = MS_RDONLY,
 	.setup = setup,
 	.test = verify_access,
 };
diff --git a/testcases/kernel/syscalls/add_key/Makefile b/testcases/kernel/syscalls/add_key/Makefile
index 2ef86f0..c3e9ac1 100644
--- a/testcases/kernel/syscalls/add_key/Makefile
+++ b/testcases/kernel/syscalls/add_key/Makefile
@@ -20,4 +20,6 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+LDLIBS  += $(KEYUTILS_LIBS)
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/add_key/add_key01.c b/testcases/kernel/syscalls/add_key/add_key01.c
index bb31451..6756702 100644
--- a/testcases/kernel/syscalls/add_key/add_key01.c
+++ b/testcases/kernel/syscalls/add_key/add_key01.c
@@ -24,31 +24,20 @@
  *	      Manas Kumar Nayak maknayak@in.ibm.com>
  */
 
-#include "config.h"
-#ifdef HAVE_LINUX_KEYCTL_H
-# include <linux/keyctl.h>
-#endif
+#include <errno.h>
+
 #include "tst_test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/keyctl.h"
 
 static void verify_add_key(void)
 {
-#ifdef HAVE_LINUX_KEYCTL_H
-
-	TEST(tst_syscall(__NR_add_key, "keyring", "wjkey", NULL, 0,
-	                 KEY_SPEC_THREAD_KEYRING));
-
+	TEST(add_key("keyring", "wjkey", NULL, 0, KEY_SPEC_THREAD_KEYRING));
 	if (TEST_RETURN == -1)
 		tst_res(TFAIL | TTERRNO, "add_key call failed");
 	else
 		tst_res(TPASS, "add_key call succeeded");
-
-#else
-	tst_brk(TCONF, "linux/keyctl.h was missing upon compilation.");
-#endif /* HAVE_LINUX_KEYCTL_H */
 }
 
 static struct tst_test test = {
-	.tid = "add_key01",
 	.test_all = verify_add_key,
 };
diff --git a/testcases/kernel/syscalls/add_key/add_key02.c b/testcases/kernel/syscalls/add_key/add_key02.c
index 58a5cca..ce46730 100644
--- a/testcases/kernel/syscalls/add_key/add_key02.c
+++ b/testcases/kernel/syscalls/add_key/add_key02.c
@@ -32,14 +32,11 @@
  * than dereferencing NULL.
  */
 
-#include "config.h"
-#ifdef HAVE_LINUX_KEYCTL_H
-# include <linux/keyctl.h>
-#endif
-#include "tst_test.h"
-#include "linux_syscall_numbers.h"
+#include <errno.h>
 
-#ifdef HAVE_LINUX_KEYCTL_H
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+
 struct tcase {
 	const char *type;
 	size_t plen;
@@ -56,14 +53,13 @@
 	{ "rxrpc",		64 },
 	{ "rxrpc_s",		 8 },
 	{ "user",		64 },
+	{ "logon",              64 },
 };
-#endif /* HAVE_LINUX_KEYCTL_H */
 
 static void verify_add_key(unsigned int i)
 {
-#ifdef HAVE_LINUX_KEYCTL_H
-	TEST(tst_syscall(__NR_add_key, tcases[i].type, "abc:def",
-			 NULL, tcases[i].plen, KEY_SPEC_PROCESS_KEYRING));
+	TEST(add_key(tcases[i].type,
+		"abc:def", NULL, tcases[i].plen, KEY_SPEC_PROCESS_KEYRING));
 
 	if (TEST_RETURN != -1) {
 		tst_res(TFAIL,
@@ -96,13 +92,9 @@
 
 	tst_res(TFAIL | TTERRNO, "unexpected error with key type '%s'",
 		tcases[i].type);
-#else
-	tst_brk(TCONF, "linux/keyctl.h was missing upon compilation.");
-#endif /* HAVE_LINUX_KEYCTL_H */
 }
 
 static struct tst_test test = {
-	.tid = "add_key02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_add_key,
 };
diff --git a/testcases/kernel/syscalls/alarm/alarm06.c b/testcases/kernel/syscalls/alarm/alarm06.c
index 8634128..b9e0f83 100644
--- a/testcases/kernel/syscalls/alarm/alarm06.c
+++ b/testcases/kernel/syscalls/alarm/alarm06.c
@@ -76,7 +76,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "alarm06",
 	.setup = setup,
 	.test_all = verify_alarm,
 };
diff --git a/testcases/kernel/syscalls/bdflush/bdflush01.c b/testcases/kernel/syscalls/bdflush/bdflush01.c
index a529ba9..1323cc4 100644
--- a/testcases/kernel/syscalls/bdflush/bdflush01.c
+++ b/testcases/kernel/syscalls/bdflush/bdflush01.c
@@ -83,7 +83,7 @@
 #include <sys/stat.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "bdflush01";
 int testno;
diff --git a/testcases/kernel/syscalls/brk/brk01.c b/testcases/kernel/syscalls/brk/brk01.c
index 3b38f1e..775bc15 100644
--- a/testcases/kernel/syscalls/brk/brk01.c
+++ b/testcases/kernel/syscalls/brk/brk01.c
@@ -179,10 +179,7 @@
 	 * never attempt to take more than a * 1/4 of memory (by single test)
 	 */
 
-	if (ulim_sz < usr_mem_sz)
-		max_size = ulim_sz;
-	else
-		max_size = usr_mem_sz;
+	max_size = MIN(ulim_sz, usr_mem_sz);
 
 	max_size = max_size / (2 * ncpus);
 
diff --git a/testcases/kernel/syscalls/cacheflush/cacheflush01.c b/testcases/kernel/syscalls/cacheflush/cacheflush01.c
index f9e0d1e..29cf201 100644
--- a/testcases/kernel/syscalls/cacheflush/cacheflush01.c
+++ b/testcases/kernel/syscalls/cacheflush/cacheflush01.c
@@ -45,7 +45,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if __NR_cacheflush != __LTP__NR_INVALID_SYSCALL
 #include <asm/cachectl.h>
diff --git a/testcases/kernel/syscalls/capget/capget01.c b/testcases/kernel/syscalls/capget/capget01.c
index d030422..8a2a892 100644
--- a/testcases/kernel/syscalls/capget/capget01.c
+++ b/testcases/kernel/syscalls/capget/capget01.c
@@ -65,7 +65,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #include <linux/capability.h>
 
diff --git a/testcases/kernel/syscalls/capget/capget02.c b/testcases/kernel/syscalls/capget/capget02.c
index 7a17279..e8d2377 100644
--- a/testcases/kernel/syscalls/capget/capget02.c
+++ b/testcases/kernel/syscalls/capget/capget02.c
@@ -74,7 +74,7 @@
 
 #include <errno.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 /**************************************************************************/
 /*                                                                        */
diff --git a/testcases/kernel/syscalls/capset/capset01.c b/testcases/kernel/syscalls/capset/capset01.c
index 517fd14..9c61773 100644
--- a/testcases/kernel/syscalls/capset/capset01.c
+++ b/testcases/kernel/syscalls/capset/capset01.c
@@ -69,7 +69,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 /**************************************************************************/
 /*                                                                        */
diff --git a/testcases/kernel/syscalls/capset/capset02.c b/testcases/kernel/syscalls/capset/capset02.c
index d08878e..381ab75 100644
--- a/testcases/kernel/syscalls/capset/capset02.c
+++ b/testcases/kernel/syscalls/capset/capset02.c
@@ -81,7 +81,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 /**************************************************************************/
 /*                                                                        */
diff --git a/testcases/kernel/syscalls/chdir/chdir03.c b/testcases/kernel/syscalls/chdir/chdir03.c
index aaca86d..aa07206 100644
--- a/testcases/kernel/syscalls/chdir/chdir03.c
+++ b/testcases/kernel/syscalls/chdir/chdir03.c
@@ -1,26 +1,23 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
  *
- *   Copyright (c) International Business Machines  Corp., 2001
+ * 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 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.
  *
- *   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
+ * 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
  */
 
 /*
- * NAME
- *	chdir03
- *
  * DESCRIPTION
  *	Testcase for testing that chdir(2) sets EACCES errno
  *
@@ -30,165 +27,65 @@
  *	3.	create another child process, sets its uid to ltpuser2
  *	4.	this child attempts to chdir(2) to the directory created in 2.
  *		and expects to get an EACCES.
- *
- * USAGE:  <for command-line>
- *  chdir03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS
- *	This test must be run as root.
  */
 
-#include <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
 #include <pwd.h>
 #include <errno.h>
-#include <sys/wait.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include "tst_test.h"
 
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "chdir03";
-int TST_TOTAL = 1;
-
-void setup(void);
-void cleanup(void);
-
-char good_dir[100];
+#define DIRNAME "chdir03_dir"
 
 static uid_t nobody_uid, bin_uid;
 
-int main(int ac, char **av)
+void verify_chdir(void)
 {
-	int lc;
+	pid_t pid;
 
-	pid_t pid, pid1;
-	int status;
+	pid = SAFE_FORK();
+	if (!pid) {
+		SAFE_SETUID(bin_uid);
 
-	tst_parse_opts(ac, av, NULL, NULL);
+		TEST(chdir(DIRNAME));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		if ((pid = FORK_OR_VFORK()) < 0) {
-			tst_brkm(TBROK, cleanup, "first fork failed");
+		if (TEST_RETURN != -1) {
+			tst_res(TFAIL, "chdir() succeeded unexpectedly");
+			return;
 		}
 
-		if (pid == 0) {
-			if (setreuid(nobody_uid, nobody_uid) != 0) {
-				perror("setreuid failed in child #1");
-				exit(1);
-			}
-			if (mkdir(good_dir, 00700) != 0) {
-				perror("mkdir failed in child #1");
-				exit(1);
-			}
-			exit(0);
+		if (TEST_ERRNO != EACCES) {
+			tst_res(TFAIL | TTERRNO,
+				"chdir() should fail with EACCES");
+			return;
 		}
-		wait(&status);
 
-		if ((pid1 = FORK_OR_VFORK()) < 0)
-			tst_brkm(TBROK, cleanup, "second fork failed");
-
-		if (pid1 == 0) {	/* second child */
-
-			int rval;
-
-			/*
-			 * set the child's ID to ltpuser2 using seteuid()
-			 * so that the ID can be changed back after the
-			 * TEST call is made.
-			 */
-			if (seteuid(bin_uid) != 0) {
-				perror("setreuid failed in child #2");
-				exit(1);
-			}
-
-			TEST(chdir(good_dir));
-
-			if (TEST_RETURN != -1) {
-				printf("call succeeded unexpectedly\n");
-				rval = 1;
-			} else if (TEST_ERRNO != EACCES) {
-				printf("didn't get EACCES as expected; got ");
-				rval = 1;
-			} else {
-				printf("got EACCES as expected\n");
-				rval = 0;
-			}
-			/* Only really required with vfork. */
-			if (seteuid(0) != 0) {
-				perror("seteuid(0) failed");
-				rval = 1;
-			}
-
-			exit(rval);
-
-		} else {
-			if (wait(&status) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "wait failed");
-			if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
-				tst_brkm(TBROK, cleanup,
-					 "child exited abnormally");
-			tst_resm(TPASS, "child reported success");
-		}
-		if (rmdir(good_dir) == -1) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "rmdir(%s) failed", good_dir);
-		}
+		tst_res(TPASS | TTERRNO, "chdir() failed expectedly");
 	}
-
-	cleanup();
-	tst_exit();
 }
 
 void setup(void)
 {
 	struct passwd *pw;
-	char *cur_dir = NULL;
+	pid_t pid;
 
-	tst_require_root();
-
-	pw = SAFE_GETPWNAM(NULL, "nobody");
+	pw = SAFE_GETPWNAM("nobody");
 	nobody_uid = pw->pw_uid;
-#ifndef ANDROID
-	pw = SAFE_GETPWNAM(NULL, "bin");
-#else
-	// user "bin" does not exist in Android kernel
-	pw = SAFE_GETPWNAM(NULL, "everybody");
-#endif
+	pw = SAFE_GETPWNAM("bin");
 	bin_uid = pw->pw_uid;
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	if ((cur_dir = getcwd(cur_dir, 0)) == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "getcwd failed");
-
-	sprintf(good_dir, "%s/%d", cur_dir, getpid());
+	pid = SAFE_FORK();
+	if (!pid) {
+		SAFE_SETEUID(nobody_uid);
+		SAFE_MKDIR(DIRNAME, 0700);
+		exit(0);
+	}
+	tst_reap_children();
 }
 
-void cleanup(void)
-{
-	tst_rmdir();
-
-}
+static struct tst_test test = {
+	.setup = setup,
+	.test_all = verify_chdir,
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1,
+};
diff --git a/testcases/kernel/syscalls/clock_getres/clock_getres01.c b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
index 91a30be..989683f 100644
--- a/testcases/kernel/syscalls/clock_getres/clock_getres01.c
+++ b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
@@ -80,7 +80,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "clock_getres01",
 	.test = do_test,
 	.tcnt = ARRAY_SIZE(tcase),
 };
diff --git a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
index f64378c..9ddc9a7 100644
--- a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
+++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
@@ -22,13 +22,11 @@
 
 #include <limits.h>
 
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "tst_sig_proc.h"
 #include "tst_timer.h"
 #include "tst_test.h"
 
-#define MAX_MSEC_DIFF   20
-
 static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
 {
 }
@@ -58,22 +56,6 @@
 
 static struct test_case tcase[] = {
 	{
-		.clk_id = CLOCK_REALTIME,
-		TYPE_NAME(NORMAL),
-		.flags = 0,
-		.rq = (struct timespec) {.tv_sec = 0, .tv_nsec = 500000000},
-		.exp_ret = 0,
-		.exp_err = 0,
-	},
-	{
-		.clk_id = CLOCK_MONOTONIC,
-		TYPE_NAME(NORMAL),
-		.flags = 0,
-		.rq = (struct timespec) {.tv_sec = 0, .tv_nsec = 500000000},
-		.exp_ret = 0,
-		.exp_err = 0,
-	},
-	{
 		TYPE_NAME(NORMAL),
 		.clk_id = CLOCK_REALTIME,
 		.flags = 0,
@@ -110,60 +92,45 @@
 void setup(void)
 {
 	SAFE_SIGNAL(SIGINT, sighandler);
-	tst_timer_check(CLOCK_MONOTONIC);
 }
 
 static void do_test(unsigned int i)
 {
 	struct test_case *tc = &tcase[i];
 	struct timespec rm = {0};
-	long long elapsed_ms, expect_ms, remain_ms = 0;
 	pid_t pid = 0;
 
 	tst_res(TINFO, "case %s", tc->desc);
 
-	/* setup */
 	if (tc->ttype == SEND_SIGINT)
 		pid = create_sig_proc(SIGINT, 40, 500000);
 
-	/* test */
-	tst_timer_start(CLOCK_MONOTONIC);
 	TEST(clock_nanosleep(tc->clk_id, tc->flags, &tc->rq, &rm));
-	tst_timer_stop();
-	elapsed_ms = tst_timer_elapsed_ms();
-	expect_ms = tst_timespec_to_ms(tc->rq);
 
-	if (tc->ttype == SEND_SIGINT) {
-		tst_res(TINFO, "remain time: %lds %ldns", rm.tv_sec, rm.tv_nsec);
-		remain_ms = tst_timespec_to_ms(rm);
-	}
-
-	/* cleanup */
 	if (pid) {
 		SAFE_KILL(pid, SIGTERM);
 		SAFE_WAIT(NULL);
 	}
 
-	/* result check */
-	if (!TEST_RETURN && (elapsed_ms < expect_ms - MAX_MSEC_DIFF
-		|| elapsed_ms > expect_ms + MAX_MSEC_DIFF)) {
+	if (tc->ttype == SEND_SIGINT) {
+		long long expect_ms = tst_timespec_to_ms(tc->rq);
+		long long remain_ms = tst_timespec_to_ms(rm);
 
-		tst_res(TFAIL| TTERRNO, "The clock_nanosleep() haven't slept correctly,"
-			" measured %lldms, expected %lldms +- %d",
-			elapsed_ms, expect_ms, MAX_MSEC_DIFF);
-		return;
-	}
+		tst_res(TINFO, "remain time: %lds %ldns", rm.tv_sec, rm.tv_nsec);
 
-	if (tc->ttype == SEND_SIGINT && !rm.tv_sec && !rm.tv_nsec) {
-		tst_res(TFAIL | TTERRNO, "The clock_nanosleep() haven't updated"
-			" timestamp with remaining time");
-		return;
-	}
+		if (!rm.tv_sec && !rm.tv_nsec) {
+			tst_res(TFAIL | TTERRNO,
+				"The clock_nanosleep() haven't updated"
+				" timestamp with remaining time");
+			return;
+		}
 
-	if (tc->ttype == SEND_SIGINT && remain_ms > expect_ms) {
-		tst_res(TFAIL| TTERRNO, "remaining time > requested time (%lld > %lld)",
-			remain_ms, expect_ms);
-		return;
+		if (remain_ms > expect_ms) {
+			tst_res(TFAIL| TTERRNO,
+				"remaining time > requested time (%lld > %lld)",
+				remain_ms, expect_ms);
+			return;
+		}
 	}
 
 	if (TEST_RETURN != tc->exp_ret) {
@@ -178,7 +145,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "clock_nanosleep01",
 	.tcnt = ARRAY_SIZE(tcase),
 	.test = do_test,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c
new file mode 100644
index 0000000..f114013
--- /dev/null
+++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * 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 Description:
+ *  clock_nanosleep() should return with value 0 and the process should be
+ *  suspended for time specified by timespec structure.
+ */
+
+#include <errno.h>
+#include "tst_timer_test.h"
+
+int sample_fn(int clk_id, long long usec)
+{
+	struct timespec t = tst_us_to_timespec(usec);
+
+	tst_timer_start(clk_id);
+	TEST(clock_nanosleep(clk_id, 0, &t, NULL));
+	tst_timer_stop();
+	tst_timer_sample();
+
+	if (TEST_RETURN != 0) {
+		tst_res(TFAIL | TERRNO,
+			"nanosleep() returned %li", TEST_RETURN);
+		return 1;
+	}
+
+	return 0;
+}
+
+static struct tst_test test = {
+	.tid = "nanosleep()",
+	.sample = sample_fn,
+};
diff --git a/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c b/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c
index 968a77d..3d8288c 100644
--- a/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c
+++ b/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c
@@ -26,7 +26,7 @@
 #include <sys/syscall.h>
 
 #include "tst_test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define NSEC_IN_SEC 1000000000
 
@@ -57,6 +57,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "clock_nanosleep2_01",
 	.test_all = verify_clock_nanosleep2,
 };
diff --git a/testcases/kernel/syscalls/clone/Makefile b/testcases/kernel/syscalls/clone/Makefile
index bd617d8..2ded37c 100644
--- a/testcases/kernel/syscalls/clone/Makefile
+++ b/testcases/kernel/syscalls/clone/Makefile
@@ -20,4 +20,6 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+CFLAGS += -Wl,-z,now
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/clone/clone02.c b/testcases/kernel/syscalls/clone/clone02.c
index 20442b3..3f61d22 100644
--- a/testcases/kernel/syscalls/clone/clone02.c
+++ b/testcases/kernel/syscalls/clone/clone02.c
@@ -270,8 +270,8 @@
 
 	if (test_VM() == 0 && test_FILES() == 0 && test_FS() == 0 &&
 	    test_SIG() == 0)
-		exit(0);
-	exit(1);
+		_exit(0);
+	_exit(1);
 }
 
 static int parent_test1(void)
diff --git a/testcases/kernel/syscalls/clone/clone05.c b/testcases/kernel/syscalls/clone/clone05.c
index a326209..494b772 100644
--- a/testcases/kernel/syscalls/clone/clone05.c
+++ b/testcases/kernel/syscalls/clone/clone05.c
@@ -99,5 +99,5 @@
 	}
 
 	child_exited = 1;
-	exit(1);
+	_exit(1);
 }
diff --git a/testcases/kernel/syscalls/clone/clone08.c b/testcases/kernel/syscalls/clone/clone08.c
index 4c71db4..58f9be0 100644
--- a/testcases/kernel/syscalls/clone/clone08.c
+++ b/testcases/kernel/syscalls/clone/clone08.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
  * Copyright (c) 2013 Fujitsu Ltd.
  * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
  *
@@ -15,39 +16,36 @@
  */
 
 #define _GNU_SOURCE
+#include <stdlib.h>
+#include <stdio.h>
 #include <errno.h>
 #include <sched.h>
 #include <sys/wait.h>
-#include "test.h"
-#include "clone_platform.h"
-#include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include <linux/futex.h>
 
-char *TCID = "clone08";
+#include "tst_test.h"
+#include "clone_platform.h"
+#include "lapi/syscalls.h"
 
 static pid_t ptid, ctid, tgid;
 static void *child_stack;
 
-static void setup(void);
-static void cleanup(void);
-
 static void test_clone_parent(int t);
-static int child_clone_parent(void);
+static int child_clone_parent(void *);
 static pid_t parent_ppid;
 
 static void test_clone_tid(int t);
-static int child_clone_child_settid(void);
-static int child_clone_parent_settid(void);
+static int child_clone_child_settid(void *);
+static int child_clone_parent_settid(void *);
 
 #ifdef CLONE_STOPPED
 static void test_clone_stopped(int t);
-static int child_clone_stopped(void);
+static int child_clone_stopped(void *);
 static int stopped_flag;
 #endif
 
 static void test_clone_thread(int t);
-static int child_clone_thread(void);
-static int tst_result;
+static int child_clone_thread(void *);
 
 /*
  * Children cloned with CLONE_VM should avoid using any functions that
@@ -61,7 +59,7 @@
 	char *name;
 	int flags;
 	void (*testfunc)(int);
-	int (*do_child)();
+	int (*do_child)(void *);
 } test_cases[] = {
 	{"CLONE_PARENT", CLONE_PARENT | SIGCHLD,
 	 test_clone_parent, child_clone_parent},
@@ -73,196 +71,124 @@
 	{"CLONE_STOPPED", CLONE_STOPPED | CLONE_VM | SIGCHLD,
 	 test_clone_stopped, child_clone_stopped},
 #endif
-	{"CLONE_THREAD", CLONE_THREAD | CLONE_SIGHAND | CLONE_VM | SIGCHLD,
+	{"CLONE_THREAD", CLONE_THREAD | CLONE_SIGHAND | CLONE_VM |
+	 CLONE_CHILD_CLEARTID | SIGCHLD,
 	 test_clone_thread, child_clone_thread},
 };
 
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-int main(int ac, char **av)
+static void do_test(unsigned int i)
 {
-	int i, lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		for (i = 0; i < TST_TOTAL; i++) {
-			tst_resm(TINFO, "running %s", test_cases[i].name);
-			test_cases[i].testfunc(i);
-		}
-	}
-	cleanup();
-	tst_exit();
+	tst_res(TINFO, "running %s", test_cases[i].name);
+	test_cases[i].testfunc(i);
 }
 
 static void setup(void)
 {
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	child_stack = SAFE_MALLOC(cleanup, CHILD_STACK_SIZE);
+	child_stack = SAFE_MALLOC(CHILD_STACK_SIZE);
 }
 
 static void cleanup(void)
 {
 	free(child_stack);
-
-	tst_rmdir();
 }
 
-static long clone_child(const struct test_case *t, int use_tst)
+static long clone_child(const struct test_case *t)
 {
 	TEST(ltp_clone7(t->flags, t->do_child, NULL, CHILD_STACK_SIZE,
 		child_stack, &ptid, NULL, &ctid));
 
 	if (TEST_RETURN == -1 && TTERRNO == ENOSYS)
-		tst_brkm(TCONF, cleanup, "clone does not support 7 args");
+		tst_brk(TCONF, "clone does not support 7 args");
 
-	if (TEST_RETURN == -1) {
-		if (use_tst) {
-			tst_brkm(TBROK | TTERRNO, cleanup, "%s clone() failed",
-				 t->name);
-		} else {
-			printf("%s clone() failed, errno: %d",
-			       t->name, TEST_ERRNO);
-			exit(1);
-		}
-	}
+	if (TEST_RETURN == -1)
+		tst_brk(TBROK | TTERRNO, "%s clone() failed", t->name);
+
 	return TEST_RETURN;
 }
 
-static int wait4child(pid_t child)
-{
-	int status;
-
-	if (waitpid(child, &status, 0) == -1)
-		tst_resm(TBROK|TERRNO, "waitpid");
-	if (WIFEXITED(status))
-		return WEXITSTATUS(status);
-	else
-		return status;
-}
-
 static void test_clone_parent(int t)
 {
-	int status;
 	pid_t child;
 
-	fflush(stdout);
-	child = FORK_OR_VFORK();
-	switch (child) {
-	case 0:
+	child = SAFE_FORK();
+	if (!child) {
 		parent_ppid = getppid();
-		clone_child(&test_cases[t], 0);
-		exit(0);
-	case -1:
-		tst_brkm(TBROK | TERRNO, NULL, "test_clone_parent fork");
-	default:
-		status = wait4child(child);
-		if (status == 0) {
-			/* wait for CLONE_PARENT child */
-			status = wait4child(-1);
-			if (status == 0) {
-				tst_resm(TPASS, "test %s", test_cases[t].name);
-			} else {
-				tst_resm(TFAIL, "test %s, status: %d",
-					 test_cases[t].name, status);
-			}
-		} else {
-			tst_resm(TFAIL, "test %s, status: %d",
-				 test_cases[t].name, status);
-		}
-	};
+		clone_child(&test_cases[t]);
+		_exit(0);
+	}
+	tst_reap_children();
 }
 
-static int child_clone_parent(void)
+static int child_clone_parent(void *arg LTP_ATTRIBUTE_UNUSED)
 {
-	if (parent_ppid == getppid())
-		exit(0);
-	printf("FAIL: getppid != parent_ppid (%d != %d)\n",
-	       parent_ppid, getppid());
-	exit(1);
+	if (parent_ppid == getppid()) {
+		tst_res(TPASS, "clone and forked child has the same parent");
+	} else {
+		tst_res(TFAIL, "getppid != parent_ppid (%d != %d)",
+			parent_ppid, getppid());
+	}
+	tst_syscall(__NR_exit, 0);
+	return 0;
 }
 
 static void test_clone_tid(int t)
 {
-	int status;
 	pid_t child;
 
-	child = clone_child(&test_cases[t], 1);
-	status = wait4child(child);
-	if (status == 0) {
-		tst_resm(TPASS, "test %s", test_cases[t].name);
-	} else {
-		tst_resm(TFAIL, "test %s, status: %d",
-			 test_cases[t].name, status);
-	}
+	child = clone_child(&test_cases[t]);
+	tst_reap_children();
 }
 
-static int child_clone_child_settid(void)
+static int child_clone_child_settid(void *arg LTP_ATTRIBUTE_UNUSED)
 {
-	if (ctid == ltp_syscall(__NR_getpid))
-		ltp_syscall(__NR_exit, 0);
-	printf("FAIL: ctid != getpid() (%d != %d)\n",
-	       ctid, getpid());
-	ltp_syscall(__NR_exit, 1);
+	if (ctid == tst_syscall(__NR_getpid))
+		tst_res(TPASS, "clone() correctly set ctid");
+	else
+		tst_res(TFAIL, "ctid != getpid() (%d != %d)", ctid, getpid());
+	tst_syscall(__NR_exit, 0);
 	return 0;
 }
 
-static int child_clone_parent_settid(void)
+static int child_clone_parent_settid(void *arg LTP_ATTRIBUTE_UNUSED)
 {
-	if (ptid == ltp_syscall(__NR_getpid))
-		ltp_syscall(__NR_exit, 0);
-	printf("FAIL: ptid != getpid() (%d != %d)\n",
-	       ptid, getpid());
-	ltp_syscall(__NR_exit, 1);
+	if (ptid == tst_syscall(__NR_getpid))
+		tst_res(TPASS, "clone() correctly set ptid");
+	else
+		tst_res(TFAIL, "ptid != getpid() (%d != %d)", ptid, getpid());
+	tst_syscall(__NR_exit, 0);
 	return 0;
 }
 
 #ifdef CLONE_STOPPED
 static void test_clone_stopped(int t)
 {
-	int i;
-	int status;
-	int flag;
 	pid_t child;
 
 	if (tst_kvercmp(2, 6, 38) >= 0) {
-		tst_resm(TINFO, "CLONE_STOPPED skipped for kernels >= 2.6.38");
+		tst_res(TCONF, "CLONE_STOPPED skipped for kernels >= 2.6.38");
 		return;
 	}
 
+	child = clone_child(&test_cases[t]);
+
+	TST_PROCESS_STATE_WAIT(child, 'T');
+
 	stopped_flag = 0;
-	child = clone_child(&test_cases[t], 1);
 
-	/* give the kernel scheduler chance to run the CLONE_STOPPED thread*/
-	for (i = 0; i < 100; i++) {
-		sched_yield();
-		usleep(1000);
-	}
+	SAFE_KILL(child, SIGCONT);
 
-	flag = stopped_flag;
-	if (kill(child, SIGCONT) != 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "kill SIGCONT failed");
+	tst_reap_children();
 
-	status = wait4child(child);
-	if (status == 0 && flag == 0) {
-		tst_resm(TPASS, "test %s", test_cases[t].name);
-	} else {
-		tst_resm(TFAIL, "test %s, status: %d, flag: %d",
-			 test_cases[t].name, status, flag);
-	}
+	if (stopped_flag == 1)
+		tst_res(TPASS, "clone stopped and resumed as expected");
+	else
+		tst_res(TFAIL, "clone not stopped, flag %d", stopped_flag);
 }
 
-static int child_clone_stopped(void)
+static int child_clone_stopped(void *arg LTP_ATTRIBUTE_UNUSED)
 {
 	stopped_flag = 1;
-	ltp_syscall(__NR_exit, 0);
+	tst_syscall(__NR_exit, 0);
 	return 0;
 }
 #endif
@@ -270,42 +196,41 @@
 static void test_clone_thread(int t)
 {
 	pid_t child;
-	int i, status;
 
-	fflush(stdout);
-	child = FORK_OR_VFORK();
-	switch (child) {
-	case 0:
-		tgid = ltp_syscall(__NR_getpid);
-		tst_result = -1;
-		clone_child(&test_cases[t], 0);
+	child = SAFE_FORK();
+	if (!child) {
+		struct timespec timeout = { 5 /* sec */, 0 };
 
-		for (i = 0; i < 5000; i++) {
-			sched_yield();
-			usleep(1000);
-			if (tst_result != -1)
-				break;
-		}
-		ltp_syscall(__NR_exit, tst_result);
-	case -1:
-		tst_brkm(TBROK | TERRNO, NULL, "test_clone_thread fork");
-	default:
-		status = wait4child(child);
-		if (status == 0) {
-			tst_resm(TPASS, "test %s", test_cases[t].name);
-		} else {
-			tst_resm(TFAIL, "test %s, status: %d",
-				 test_cases[t].name, status);
-		}
-	};
+		tgid = tst_syscall(__NR_getpid);
+		ctid = -1;
+
+		clone_child(&test_cases[t]);
+
+		if (syscall(SYS_futex, &ctid, FUTEX_WAIT, -1, &timeout))
+			tst_res(TFAIL | TERRNO, "futex failed");
+		else
+			tst_res(TPASS, "futex exit on ctid change");
+
+		_exit(0);
+	}
+
+	tst_reap_children();
 }
 
-static int child_clone_thread(void)
+static int child_clone_thread(void *arg LTP_ATTRIBUTE_UNUSED)
 {
-	if (tgid == ltp_syscall(__NR_getpid))
-		tst_result = TPASS;
+	if (tgid == tst_syscall(__NR_getpid))
+		tst_res(TPASS, "clone has the same thread id");
 	else
-		tst_result = TFAIL;
-	ltp_syscall(__NR_exit, 0);
+		tst_res(TFAIL, "clone's thread id not equal parent's id");
+	tst_syscall(__NR_exit, 0);
 	return 0;
 }
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(test_cases),
+	.test = do_test,
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1
+};
diff --git a/testcases/kernel/syscalls/clone/clone09.c b/testcases/kernel/syscalls/clone/clone09.c
new file mode 100644
index 0000000..a6ebdd7
--- /dev/null
+++ b/testcases/kernel/syscalls/clone/clone09.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+ *
+ * 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 would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define _GNU_SOURCE
+#include <sched.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "tst_test.h"
+#include "clone_platform.h"
+#include "lapi/syscalls.h"
+#include "lapi/namespaces_constants.h"
+
+static void *child_stack;
+static int sysctl_net = -1;
+static int sysctl_net_new = -1;
+static const char sysctl_path[] = "/proc/sys/net/ipv4/conf/lo/tag";
+static const char sysctl_path_def[] = "/proc/sys/net/ipv4/conf/default/tag";
+static int flags = CLONE_NEWNET | CLONE_VM | SIGCHLD;
+
+static void setup(void)
+{
+	child_stack = SAFE_MALLOC(CHILD_STACK_SIZE);
+}
+
+static void cleanup(void)
+{
+	if (sysctl_net != -1)
+		SAFE_FILE_PRINTF(sysctl_path, "%d", sysctl_net);
+
+	free(child_stack);
+}
+
+static int newnet(void *arg LTP_ATTRIBUTE_UNUSED)
+{
+	SAFE_FILE_SCANF(sysctl_path, "%d", &sysctl_net_new);
+	tst_syscall(__NR_exit, 0);
+	return 0;
+}
+
+static long clone_child(void)
+{
+	TEST(ltp_clone(flags, newnet, NULL, CHILD_STACK_SIZE, child_stack));
+
+	if (TEST_RETURN == -1 && TEST_ERRNO == EINVAL)
+		tst_brk(TCONF, "CONFIG_NET_NS was disabled");
+
+	if (TEST_RETURN == -1)
+		tst_brk(TBROK | TTERRNO, "clone(CLONE_NEWNET) failed");
+
+	return TEST_RETURN;
+}
+
+static void do_test(void)
+{
+	int def_val;
+
+	tst_res(TINFO, "create clone in a new netns with 'CLONE_NEWNET' flag");
+
+	SAFE_FILE_SCANF(sysctl_path, "%d", &sysctl_net);
+	SAFE_FILE_PRINTF(sysctl_path, "%d", sysctl_net + 1);
+
+	clone_child();
+	tst_reap_children();
+
+	if (sysctl_net_new == (sysctl_net + 1)) {
+		tst_res(TFAIL, "sysctl params equal: %s=%d",
+			sysctl_path, sysctl_net_new);
+	}
+
+	SAFE_FILE_SCANF(sysctl_path_def, "%d", &def_val);
+
+	if (sysctl_net_new != def_val) {
+		tst_res(TFAIL, "netns param init to non-default value %d",
+			sysctl_net_new);
+	}
+
+	/* restore previous value */
+	SAFE_FILE_PRINTF(sysctl_path, "%d", sysctl_net);
+
+	tst_res(TPASS, "sysctl params differ in new netns");
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.min_kver = "2.6.24",
+};
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 102bcd9..17f0a5d 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <limits.h>
 
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/cma/process_vm_writev02.c b/testcases/kernel/syscalls/cma/process_vm_writev02.c
index c37c02c..04cf6d1 100644
--- a/testcases/kernel/syscalls/cma/process_vm_writev02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_writev02.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <limits.h>
 
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/copy_file_range/Makefile b/testcases/kernel/syscalls/copy_file_range/Makefile
new file mode 100644
index 0000000..0143bde
--- /dev/null
+++ b/testcases/kernel/syscalls/copy_file_range/Makefile
@@ -0,0 +1,19 @@
+#
+#  Copyright (c) Linux Test Project, 2017
+#
+# 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.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
new file mode 100644
index 0000000..25c701f
--- /dev/null
+++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range01.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) Linux Test Project, 2017
+ *
+ * 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.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+#include "lapi/syscalls.h"
+
+#define TEST_FILE_1 "copy_file_range_ltp01.txt"
+#define TEST_FILE_2 "copy_file_range_ltp02.txt"
+#define STR "abcdefghijklmnopqrstuvwxyz12345\n"
+
+#define verbose 0
+
+static size_t *len_arr;
+static loff_t **off_arr;
+static int len_sz, off_sz;
+
+static void setup(void)
+{
+	int i, fd, page_size;
+
+	page_size = getpagesize();
+
+	fd = SAFE_OPEN(TEST_FILE_1, O_RDWR | O_CREAT, 0664);
+	/* Writing page_size * 4 of data into test file */
+	for (i = 0; i < (int)(page_size * 4); i++)
+		SAFE_WRITE(1, fd, STR, strlen(STR));
+	SAFE_CLOSE(fd);
+
+	len_sz = 4;
+	len_arr = malloc(sizeof(size_t) * len_sz);
+	len_arr[0] = 11;
+	len_arr[1] = page_size - 1;
+	len_arr[2] = page_size;
+	len_arr[3] = page_size + 1;
+
+	off_sz = 6;
+	off_arr = malloc(sizeof(loff_t *) * off_sz);
+	for (i = 1; i < off_sz; i++)
+		off_arr[i] = malloc(sizeof(loff_t));
+
+	off_arr[0] = NULL;
+	*off_arr[1] = 0;
+	*off_arr[2] = 17;
+	*off_arr[3] = page_size - 1;
+	*off_arr[4] = page_size;
+	*off_arr[5] = page_size + 1;
+}
+
+static int check_file_content(const char *fname1, const char *fname2,
+	loff_t *off1, loff_t *off2, size_t len)
+{
+	FILE *fp1, *fp2;
+	int ch1, ch2;
+	size_t count = 0;
+
+	fp1 = SAFE_FOPEN(fname1, "r");
+	if (off1 && fseek(fp1, *off1, SEEK_SET))
+		tst_brk(TBROK | TERRNO, "fseek() failed");
+
+	fp2 = SAFE_FOPEN(fname2, "r");
+	if (off2 && fseek(fp2, *off2, SEEK_SET))
+		tst_brk(TBROK | TERRNO, "fseek() failed");
+
+	do {
+		ch1 = getc(fp1);
+		ch2 = getc(fp2);
+		count++;
+	} while ((count < len) && (ch1 == ch2));
+
+	SAFE_FCLOSE(fp1);
+	SAFE_FCLOSE(fp2);
+
+	return !(ch1 == ch2);
+}
+
+static int check_file_offset(const char *m, int fd, loff_t len,
+	loff_t *off_ori, loff_t *off_after)
+{
+	int ret = 0;
+
+	if (off_ori) {
+		/* FD should stay untouched, and off_in/out is updated */
+		loff_t fd_off = SAFE_LSEEK(fd, 0, SEEK_CUR);
+
+		if (fd_off == 0) {
+			if (verbose)
+				tst_res(TPASS, "%s FD offset unchanged", m);
+		} else {
+			tst_res(TFAIL, "%s FD offset changed: %ld",
+				m, (long)fd_off);
+			ret = 1;
+		}
+
+		if (!off_after) {
+			tst_res(TFAIL, "%s offset is NULL", m);
+			ret = 1;
+		}
+
+		if ((off_after) && (*off_ori + len == *off_after)) {
+			if (verbose) {
+				tst_res(TPASS, "%s offset advanced as"
+					" expected: %ld", m, (long)*off_after);
+			}
+		} else {
+			tst_res(TFAIL, "%s offset unexpected value: %ld",
+				m, (long)*off_after);
+			ret = 1;
+		}
+	} else {
+		/* FD offset is advanced by len */
+		loff_t fd_off = SAFE_LSEEK(fd, 0, SEEK_CUR);
+
+		if (fd_off == len) {
+			if (verbose) {
+				tst_res(TPASS, "%s FD offset changed as"
+					" expected: %ld", m, (long)fd_off);
+			}
+		} else {
+			tst_res(TFAIL, "%s FD offset unexpected value: %ld",
+				m, (long)fd_off);
+			ret = 1;
+		}
+	}
+
+	return ret;
+}
+
+static void test_one(size_t len, loff_t *off_in, loff_t *off_out)
+{
+	size_t to_copy = len;
+	int fd_in, fd_out, ret;
+	loff_t *off_in_ori = off_in;
+	loff_t *off_out_ori = off_out;
+	loff_t off_in_copy;
+	loff_t off_out_copy;
+	char str_off_in[32], str_off_out[32];
+
+	if (off_in) {
+		off_in_copy = *off_in;
+		off_in = &off_in_copy;
+		sprintf(str_off_in, "%ld", (long)*off_in);
+	} else {
+		strcpy(str_off_in, "NULL");
+	}
+
+	if (off_out) {
+		off_out_copy = *off_out;
+		off_out = &off_out_copy;
+		sprintf(str_off_out, "%ld", (long)*off_out);
+	} else {
+		strcpy(str_off_out, "NULL");
+	}
+
+	fd_in = SAFE_OPEN(TEST_FILE_1, O_RDONLY);
+	fd_out = SAFE_OPEN(TEST_FILE_2, O_CREAT | O_WRONLY | O_TRUNC, 0644);
+
+	/*
+	 * copy_file_range() will return the number of bytes copied between
+	 * files. This could be less than the length originally requested.
+	 */
+	do {
+		TEST(tst_syscall(__NR_copy_file_range, fd_in, off_in, fd_out,
+			off_out, to_copy, 0));
+		if (TEST_RETURN == -1) {
+			tst_res(TFAIL | TTERRNO, "copy_file_range() failed");
+			SAFE_CLOSE(fd_in);
+			SAFE_CLOSE(fd_out);
+			return;
+		}
+
+		to_copy -= TEST_RETURN;
+	} while (to_copy > 0);
+
+	ret = check_file_content(TEST_FILE_1, TEST_FILE_2,
+		off_in_ori, off_out_ori, len);
+	if (ret)
+		tst_res(TFAIL, "file contents do not match");
+
+	ret |= check_file_offset("(in)", fd_in, len, off_in_ori, off_in);
+	ret |= check_file_offset("(out)", fd_out, len, off_out_ori, off_out);
+
+	tst_res(ret == 0 ? TPASS : TFAIL, "off_in: %s, off_out: %s, len: %ld",
+			str_off_in, str_off_out, (long)len);
+
+	SAFE_CLOSE(fd_in);
+	SAFE_CLOSE(fd_out);
+}
+
+static void copy_file_range_verify(void)
+{
+	int i, j, k;
+
+	for (i = 0; i < len_sz; i++)
+		for (j = 0; j < off_sz; j++)
+			for (k = 0; k < off_sz; k++)
+				test_one(len_arr[i], off_arr[j], off_arr[k]);
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.needs_tmpdir = 1,
+	.test_all = copy_file_range_verify,
+};
diff --git a/testcases/kernel/syscalls/creat/creat01.c b/testcases/kernel/syscalls/creat/creat01.c
index 1ca0968..6b70be2 100644
--- a/testcases/kernel/syscalls/creat/creat01.c
+++ b/testcases/kernel/syscalls/creat/creat01.c
@@ -36,12 +36,12 @@
 static char filename[40];
 static int fd;
 
-void setup(void)
+static void setup(void)
 {
 	sprintf(filename, "creat01.%d", getpid());
 }
 
-struct tcase {
+static struct tcase {
 	int mode;
 } tcases[] = {
 	{0644},
@@ -85,7 +85,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "creat01",
 	.tcnt = 2,
 	.test = verify_creat,
 	.needs_tmpdir = 1,
diff --git a/testcases/kernel/syscalls/creat/creat03.c b/testcases/kernel/syscalls/creat/creat03.c
index bb3cdf3..f095fb6 100644
--- a/testcases/kernel/syscalls/creat/creat03.c
+++ b/testcases/kernel/syscalls/creat/creat03.c
@@ -68,7 +68,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "creat03",
 	.test_all = verify_creat,
 	.needs_tmpdir = 1,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/creat/creat04.c b/testcases/kernel/syscalls/creat/creat04.c
index 37e430f..ebcaa17 100644
--- a/testcases/kernel/syscalls/creat/creat04.c
+++ b/testcases/kernel/syscalls/creat/creat04.c
@@ -68,7 +68,7 @@
 		child_fn(i);
 }
 
-void setup(void)
+static void setup(void)
 {
 	struct passwd *pw;
 	int fd;
@@ -82,7 +82,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "creat04",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_creat,
 	.needs_tmpdir = 1,
diff --git a/testcases/kernel/syscalls/creat/creat05.c b/testcases/kernel/syscalls/creat/creat05.c
index 5e1342e..154f1a2 100644
--- a/testcases/kernel/syscalls/creat/creat05.c
+++ b/testcases/kernel/syscalls/creat/creat05.c
@@ -87,7 +87,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "creat05",
 	.test_all = verify_creat,
 	.needs_tmpdir = 1,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/creat/creat06.c b/testcases/kernel/syscalls/creat/creat06.c
index db0850a..45642f0 100644
--- a/testcases/kernel/syscalls/creat/creat06.c
+++ b/testcases/kernel/syscalls/creat/creat06.c
@@ -162,13 +162,11 @@
 }
 
 static struct tst_test test = {
-	.tid = "creat06",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_creat,
 	.needs_root = 1,
+	.needs_rofs = 1,
 	.needs_tmpdir = 1,
-	.mount_device = 1,
 	.mntpoint = "mntpoint",
-	.mnt_flags = MS_RDONLY,
 	.setup = setup,
 };
diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
index dc40461..e1b2676 100644
--- a/testcases/kernel/syscalls/creat/creat07.c
+++ b/testcases/kernel/syscalls/creat/creat07.c
@@ -68,7 +68,6 @@
 };
 
 static struct tst_test test = {
-	.tid = "creat07",
 	.test_all = verify_creat,
 	.needs_checkpoints = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/dup3/dup3_01.c b/testcases/kernel/syscalls/dup3/dup3_01.c
index be3f4d8..6a44ec8 100644
--- a/testcases/kernel/syscalls/dup3/dup3_01.c
+++ b/testcases/kernel/syscalls/dup3/dup3_01.c
@@ -60,7 +60,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "dup3_01";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/syscalls/dup3/dup3_02.c b/testcases/kernel/syscalls/dup3/dup3_02.c
index f336904..e49ec35 100644
--- a/testcases/kernel/syscalls/dup3/dup3_02.c
+++ b/testcases/kernel/syscalls/dup3/dup3_02.c
@@ -35,7 +35,7 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 
 static void setup(void);
diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
index bd2d0e8..85f14c4 100644
--- a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
+++ b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c
@@ -32,7 +32,7 @@
 #include <sys/epoll.h>
 #include "tst_test.h"
 #include "lapi/epoll.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void verify_epoll_create1(void)
 {
@@ -62,7 +62,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "epoll_create1_01",
 	.min_kver = "2.6.27",
 	.test_all = verify_epoll_create1,
 };
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
index 6f3142f..f3599de 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
@@ -152,7 +152,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "epoll_ctl01",
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_epoll_ctl,
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
index 360ae47..fcbdcac 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
@@ -117,7 +117,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "epoll_ctl02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait.h b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait.h
index 572cedb..344ff20 100644
--- a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait.h
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait.h
@@ -22,7 +22,7 @@
 #include <sys/types.h>
 #include <signal.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_EPOLL_PWAIT)
 int epoll_pwait(int epfd, struct epoll_event *events, int maxevents,
diff --git a/testcases/kernel/syscalls/epoll_wait/epoll_wait01.c b/testcases/kernel/syscalls/epoll_wait/epoll_wait01.c
index 01c669a..6827e45 100644
--- a/testcases/kernel/syscalls/epoll_wait/epoll_wait01.c
+++ b/testcases/kernel/syscalls/epoll_wait/epoll_wait01.c
@@ -28,78 +28,14 @@
 #include <string.h>
 #include <errno.h>
 
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "epoll_wait01";
-int TST_TOTAL = 3;
+#include "tst_test.h"
 
 static int write_size, epfd, fds[2];
-static struct epoll_event epevs[2] = {
-	{.events = EPOLLIN},
-	{.events = EPOLLOUT},
-};
-
-static void setup(void);
-static int get_writesize(void);
-static void verify_epollout(void);
-static void verify_epollin(void);
-static void verify_epollio(void);
-static int has_event(struct epoll_event *, int, int, uint32_t);
-static void dump_epevs(struct epoll_event *, int);
-static void cleanup(void);
-
-int main(int ac, char **av)
-{
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		verify_epollout();
-		verify_epollin();
-		verify_epollio();
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	SAFE_PIPE(NULL, fds);
-
-	write_size = get_writesize();
-
-	epfd = epoll_create(3);
-	if (epfd == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "failed to create epoll instance");
-	}
-
-	epevs[0].data.fd = fds[0];
-	epevs[1].data.fd = fds[1];
-
-	if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[0], &epevs[0]) ||
-	    epoll_ctl(epfd, EPOLL_CTL_ADD, fds[1], &epevs[1])) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "failed to register epoll target");
-	}
-}
 
 static int get_writesize(void)
 {
 	int nfd, write_size = 0;
 	char buf[4096];
-
 	struct pollfd pfd[] = {
 		{.fd = fds[1], .events = POLLOUT},
 	};
@@ -107,143 +43,47 @@
 	memset(buf, 'a', sizeof(buf));
 
 	do {
-		write_size += SAFE_WRITE(cleanup, 0, fds[1], buf, sizeof(buf));
+		write_size += SAFE_WRITE(0, fds[1], buf, sizeof(buf));
 		nfd = poll(pfd, 1, 1);
 		if (nfd == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "poll failed");
+			tst_brk(TBROK | TERRNO, "poll() failed");
 	} while (nfd > 0);
 
 	char read_buf[write_size];
 
-	SAFE_READ(cleanup, 1, fds[0], read_buf, sizeof(read_buf));
+	SAFE_READ(1, fds[0], read_buf, sizeof(read_buf));
 
-	tst_resm(TINFO, "Pipe buffer size is %i bytes", write_size);
+	tst_res(TINFO, "Pipe buffer size is %i bytes", write_size);
 
 	return write_size;
 }
 
-static void verify_epollout(void)
+static void setup(void)
 {
-	struct epoll_event ret_evs = {.events = 0, .data.fd = 0};
+	static struct epoll_event epevs[2] = {
+		{.events = EPOLLIN},
+		{.events = EPOLLOUT},
+	};
 
-	TEST(epoll_wait(epfd, &ret_evs, 1, -1));
+	SAFE_PIPE(fds);
 
-	if (TEST_RETURN == -1) {
-		tst_resm(TFAIL | TTERRNO, "epoll_wait() epollout failed");
-		return;
+	epevs[0].data.fd = fds[0];
+	epevs[1].data.fd = fds[1];
+
+	write_size = get_writesize();
+
+	epfd = epoll_create(3);
+	if (epfd == -1)
+		tst_brk(TBROK | TERRNO, "epoll_create() failed");
+
+	if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[0], &epevs[0]) ||
+	    epoll_ctl(epfd, EPOLL_CTL_ADD, fds[1], &epevs[1])) {
+		tst_brk(TBROK | TERRNO, "epoll_ctl() failed");
 	}
-
-	if (TEST_RETURN != 1) {
-		tst_resm(TFAIL, "epoll_wait() returned %li, expected 1",
-			 TEST_RETURN);
-		return;
-	}
-
-	if (ret_evs.data.fd != fds[1]) {
-		tst_resm(TFAIL, "epoll.data.fd %i, expected %i",
-			 ret_evs.data.fd, fds[1]);
-		return;
-	}
-
-	if (ret_evs.events != EPOLLOUT) {
-		tst_resm(TFAIL, "epoll.events %x, expected EPOLLOUT %x",
-			 ret_evs.events, EPOLLOUT);
-		return;
-	}
-
-	tst_resm(TPASS, "epoll_wait() epollout");
-}
-
-static void verify_epollin(void)
-{
-	char write_buf[write_size];
-	char read_buf[sizeof(write_buf)];
-	struct epoll_event ret_evs = {.events = 0, .data.fd = 0};
-
-	memset(write_buf, 'a', sizeof(write_buf));
-
-	SAFE_WRITE(cleanup, 1, fds[1], write_buf, sizeof(write_buf));
-
-	TEST(epoll_wait(epfd, &ret_evs, 1, -1));
-
-	if (TEST_RETURN == -1) {
-		tst_resm(TFAIL | TTERRNO, "epoll_wait() epollin failed");
-		goto end;
-	}
-
-	if (TEST_RETURN != 1) {
-		tst_resm(TFAIL, "epoll_wait() returned %li, expected 1",
-			 TEST_RETURN);
-		goto end;
-	}
-
-	if (ret_evs.data.fd != fds[0]) {
-		tst_resm(TFAIL, "epoll.data.fd %i, expected %i",
-			 ret_evs.data.fd, fds[0]);
-		goto end;
-	}
-
-	if (ret_evs.events != EPOLLIN) {
-		tst_resm(TFAIL, "epoll.events %x, expected EPOLLIN %x",
-			 ret_evs.events, EPOLLIN);
-		goto end;
-	}
-
-	tst_resm(TPASS, "epoll_wait() epollin");
-
-end:
-	SAFE_READ(cleanup, 1, fds[0], read_buf, sizeof(write_buf));
-}
-
-static void verify_epollio(void)
-{
-	char write_buf[] = "Testing";
-	char read_buf[sizeof(write_buf)];
-	uint32_t events = EPOLLIN | EPOLLOUT;
-	struct epoll_event ret_evs[2];
-
-	SAFE_WRITE(cleanup, 1, fds[1], write_buf, sizeof(write_buf));
-
-	while (events) {
-		int events_matched = 0;
-
-		bzero(ret_evs, sizeof(ret_evs));
-		TEST(epoll_wait(epfd, ret_evs, 2, -1));
-
-		if (TEST_RETURN <= 0) {
-			tst_resm(TFAIL | TTERRNO, "epoll_wait() returned %li",
-				 TEST_RETURN);
-			goto end;
-		}
-
-		if ((events & EPOLLIN) &&
-		    has_event(ret_evs, 2, fds[0], EPOLLIN)) {
-			events_matched++;
-			events &= ~EPOLLIN;
-		}
-
-		if ((events & EPOLLOUT) &&
-		    has_event(ret_evs, 2, fds[1], EPOLLOUT)) {
-			events_matched++;
-			events &= ~EPOLLOUT;
-		}
-
-		if (TEST_RETURN != events_matched) {
-			tst_resm(TFAIL,
-				 "epoll_wait() returned unexpected events");
-			dump_epevs(ret_evs, 2);
-			goto end;
-		}
-	}
-
-	tst_resm(TPASS, "epoll_wait() epollio");
-
-end:
-	SAFE_READ(cleanup, 1, fds[0], read_buf, sizeof(write_buf));
 }
 
 static int has_event(struct epoll_event *epevs, int epevs_len,
-	int fd, uint32_t events)
+		     int fd, uint32_t events)
 {
 	int i;
 
@@ -260,19 +100,160 @@
 	int i;
 
 	for (i = 0; i < epevs_len; i++) {
-		tst_resm(TINFO, "epevs[%d]: epoll.data.fd %d, epoll.events %x",
-			 i, epevs[i].data.fd, epevs[i].events);
+		tst_res(TINFO, "epevs[%d]: epoll.data.fd %d, epoll.events %x",
+			i, epevs[i].data.fd, epevs[i].events);
 	}
 }
 
+static void verify_epollout(void)
+{
+	struct epoll_event ret_evs = {.events = 0, .data.fd = 0};
+
+	TEST(epoll_wait(epfd, &ret_evs, 1, -1));
+
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "epoll_wait() epollout failed");
+		return;
+	}
+
+	if (TEST_RETURN != 1) {
+		tst_res(TFAIL, "epoll_wait() returned %li, expected 1",
+			TEST_RETURN);
+		return;
+	}
+
+	if (ret_evs.data.fd != fds[1]) {
+		tst_res(TFAIL, "epoll.data.fd %i, expected %i",
+			ret_evs.data.fd, fds[1]);
+		return;
+	}
+
+	if (ret_evs.events != EPOLLOUT) {
+		tst_res(TFAIL, "epoll.events %x, expected EPOLLOUT %x",
+			ret_evs.events, EPOLLOUT);
+		return;
+	}
+
+	tst_res(TPASS, "epoll_wait() epollout");
+}
+
+static void verify_epollin(void)
+{
+	char write_buf[write_size];
+	char read_buf[sizeof(write_buf)];
+	struct epoll_event ret_evs = {.events = 0, .data.fd = 0};
+
+	memset(write_buf, 'a', sizeof(write_buf));
+
+	SAFE_WRITE(1, fds[1], write_buf, sizeof(write_buf));
+
+	TEST(epoll_wait(epfd, &ret_evs, 1, -1));
+
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "epoll_wait() epollin failed");
+		goto end;
+	}
+
+	if (TEST_RETURN != 1) {
+		tst_res(TFAIL, "epoll_wait() returned %li, expected 1",
+			TEST_RETURN);
+		goto end;
+	}
+
+	if (ret_evs.data.fd != fds[0]) {
+		tst_res(TFAIL, "epoll.data.fd %i, expected %i",
+			ret_evs.data.fd, fds[0]);
+		goto end;
+	}
+
+	if (ret_evs.events != EPOLLIN) {
+		tst_res(TFAIL, "epoll.events %x, expected EPOLLIN %x",
+			ret_evs.events, EPOLLIN);
+		goto end;
+	}
+
+	tst_res(TPASS, "epoll_wait() epollin");
+
+end:
+	SAFE_READ(1, fds[0], read_buf, sizeof(write_buf));
+}
+
+static void verify_epollio(void)
+{
+	char write_buf[] = "Testing";
+	char read_buf[sizeof(write_buf)];
+	uint32_t events = EPOLLIN | EPOLLOUT;
+	struct epoll_event ret_evs[2];
+
+	SAFE_WRITE(1, fds[1], write_buf, sizeof(write_buf));
+
+	while (events) {
+		int events_matched = 0;
+
+		bzero(ret_evs, sizeof(ret_evs));
+		TEST(epoll_wait(epfd, ret_evs, 2, -1));
+
+		if (TEST_RETURN <= 0) {
+			tst_res(TFAIL | TTERRNO, "epoll_wait() returned %li",
+				TEST_RETURN);
+			goto end;
+		}
+
+		if ((events & EPOLLIN) &&
+		    has_event(ret_evs, 2, fds[0], EPOLLIN)) {
+			events_matched++;
+			events &= ~EPOLLIN;
+		}
+
+		if ((events & EPOLLOUT) &&
+		    has_event(ret_evs, 2, fds[1], EPOLLOUT)) {
+			events_matched++;
+			events &= ~EPOLLOUT;
+		}
+
+		if (TEST_RETURN != events_matched) {
+			tst_res(TFAIL,
+				"epoll_wait() returned unexpected events");
+			dump_epevs(ret_evs, 2);
+			goto end;
+		}
+	}
+
+	tst_res(TPASS, "epoll_wait() epollio");
+
+end:
+	SAFE_READ(1, fds[0], read_buf, sizeof(write_buf));
+}
+
 static void cleanup(void)
 {
-	if (epfd > 0 && close(epfd))
-		tst_resm(TWARN | TERRNO, "failed to close epfd");
+	if (epfd > 0)
+		SAFE_CLOSE(epfd);
 
-	if (close(fds[0]))
-		tst_resm(TWARN | TERRNO, "failed to close fds[0]");
-
-	if (close(fds[1]))
-		tst_resm(TWARN | TERRNO, "failed to close fds[1]");
+	if (fds[0]) {
+		SAFE_CLOSE(fds[0]);
+		SAFE_CLOSE(fds[1]);
+	}
 }
+
+static void do_test(unsigned int n)
+{
+	switch (n) {
+	case 0:
+		verify_epollout();
+	break;
+	case 1:
+		verify_epollin();
+	break;
+	case 2:
+		verify_epollio();
+	break;
+	}
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = do_test,
+	.tcnt = 3,
+};
diff --git a/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c b/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c
index a32e82e..aa1bd0d 100644
--- a/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c
+++ b/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2016 Fujitsu Ltd.
- * Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
+ *  Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
  *
  * 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
@@ -17,7 +18,6 @@
  */
 
 /*
- * Description:
  *  Check that epoll_wait(2) timeouts correctly.
  */
 
@@ -25,121 +25,60 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "epoll_wait02";
-int TST_TOTAL = 1;
+#include "tst_timer_test.h"
 
 static int epfd, fds[2];
-static char *opt_sleep_ms;
 static struct epoll_event epevs[1] = {
-	{.events = EPOLLIN}
+       {.events = EPOLLIN}
 };
 
-static option_t opts[] = {
-	{"s:", NULL, &opt_sleep_ms},
-	{NULL, NULL, NULL}
-};
-
-static void setup(void);
-static void cleanup(void);
-static void help(void);
-
-int main(int ac, char **av)
+int sample_fn(int clk_id, long long usec)
 {
-	int lc, threshold;
-	long long elapsed_ms, sleep_ms = 100;
+	unsigned int sleep_ms = usec / 1000;
 
-	tst_parse_opts(ac, av, opts, help);
+	tst_timer_start(clk_id);
+	TEST(epoll_wait(epfd, epevs, 1, sleep_ms));
+	tst_timer_stop();
+	tst_timer_sample();
 
-	if (opt_sleep_ms) {
-		sleep_ms = atoll(opt_sleep_ms);
-
-		if (sleep_ms == 0) {
-			tst_brkm(TBROK, NULL,
-				 "Invalid timeout '%s'", opt_sleep_ms);
-		}
+	if (TEST_RETURN != 0) {
+		tst_res(TFAIL | TTERRNO,
+			"epoll_wait() returned %li", TEST_RETURN);
+		return 1;
 	}
 
-	threshold = sleep_ms / 100 + 10;
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		tst_timer_start(CLOCK_MONOTONIC);
-		TEST(epoll_wait(epfd, epevs, 1, sleep_ms));
-		tst_timer_stop();
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL | TTERRNO, "epoll_wait() failed");
-			continue;
-		}
-
-		if (TEST_RETURN != 0) {
-			tst_resm(TFAIL, "epoll_wait() returned %li, expected 0",
-				 TEST_RETURN);
-			continue;
-		}
-
-		elapsed_ms = tst_timer_elapsed_ms();
-
-		if (elapsed_ms < sleep_ms) {
-			tst_resm(TFAIL, "epoll_wait() woken up too early %llims, "
-				 "expected %llims", elapsed_ms, sleep_ms);
-			continue;
-		}
-
-		if (elapsed_ms - sleep_ms > threshold) {
-			tst_resm(TFAIL, "epoll_wait() slept too long %llims, "
-				 "expected %llims, threshold %i",
-				 elapsed_ms, sleep_ms, threshold);
-			continue;
-		}
-
-		tst_resm(TPASS, "epoll_wait() slept %llims, expected %llims, "
-			 "threshold %i", elapsed_ms, sleep_ms, threshold);
-	}
-
-	cleanup();
-	tst_exit();
+	return 0;
 }
 
 static void setup(void)
 {
-	tst_timer_check(CLOCK_MONOTONIC);
-
-	SAFE_PIPE(NULL, fds);
+	SAFE_PIPE(fds);
 
 	epfd = epoll_create(1);
-	if (epfd == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "failed to create epoll instance");
-	}
+	if (epfd == -1)
+		tst_brk(TBROK | TERRNO, "epoll_create()");
 
 	epevs[0].data.fd = fds[0];
 
-	if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[0], &epevs[0])) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "failed to register epoll target");
-	}
+	if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[0], &epevs[0]))
+		tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)");
 }
 
 static void cleanup(void)
 {
-	if (epfd > 0 && close(epfd))
-		tst_resm(TWARN | TERRNO, "failed to close epfd");
+	if (epfd > 0)
+		SAFE_CLOSE(epfd);
 
-	if (close(fds[0]))
-		tst_resm(TWARN | TERRNO, "close(fds[0]) failed");
+	if (fds[0] > 0)
+		SAFE_CLOSE(fds[0]);
 
-	if (close(fds[1]))
-		tst_resm(TWARN | TERRNO, "close(fds[1]) failed");
+	if (fds[1] > 0)
+		SAFE_CLOSE(fds[1]);
 }
 
-static void help(void)
-{
-	printf("  -s      epoll_wait() timeout length in ms\n");
-}
+static struct tst_test test = {
+	.tid = "epoll_wait()",
+	.sample = sample_fn,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/syscalls/eventfd/eventfd01.c b/testcases/kernel/syscalls/eventfd/eventfd01.c
index c622197..37cca7d 100644
--- a/testcases/kernel/syscalls/eventfd/eventfd01.c
+++ b/testcases/kernel/syscalls/eventfd/eventfd01.c
@@ -59,7 +59,7 @@
 
 #include "test.h"
 #define CLEANUP cleanup
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #ifdef HAVE_LIBAIO_H
 #include <libaio.h>
diff --git a/testcases/kernel/syscalls/eventfd2/eventfd2_01.c b/testcases/kernel/syscalls/eventfd2/eventfd2_01.c
index 96b1e14..a4af388 100644
--- a/testcases/kernel/syscalls/eventfd2/eventfd2_01.c
+++ b/testcases/kernel/syscalls/eventfd2/eventfd2_01.c
@@ -61,7 +61,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define EFD_CLOEXEC O_CLOEXEC
 
diff --git a/testcases/kernel/syscalls/eventfd2/eventfd2_02.c b/testcases/kernel/syscalls/eventfd2/eventfd2_02.c
index b2be520..151edb8 100644
--- a/testcases/kernel/syscalls/eventfd2/eventfd2_02.c
+++ b/testcases/kernel/syscalls/eventfd2/eventfd2_02.c
@@ -58,7 +58,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define EFD_NONBLOCK O_NONBLOCK
 
diff --git a/testcases/kernel/syscalls/eventfd2/eventfd2_03.c b/testcases/kernel/syscalls/eventfd2/eventfd2_03.c
index eb3d0e7..4c26b65 100644
--- a/testcases/kernel/syscalls/eventfd2/eventfd2_03.c
+++ b/testcases/kernel/syscalls/eventfd2/eventfd2_03.c
@@ -36,7 +36,7 @@
 #include <inttypes.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "eventfd2_03";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/syscalls/exit_group/exit_group01.c b/testcases/kernel/syscalls/exit_group/exit_group01.c
index 7873316..3726b06 100644
--- a/testcases/kernel/syscalls/exit_group/exit_group01.c
+++ b/testcases/kernel/syscalls/exit_group/exit_group01.c
@@ -25,7 +25,7 @@
 #include <sys/wait.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "exit_group01";
 int testno;
diff --git a/testcases/kernel/syscalls/faccessat/faccessat01.c b/testcases/kernel/syscalls/faccessat/faccessat01.c
index 622dfd3..807ab91 100644
--- a/testcases/kernel/syscalls/faccessat/faccessat01.c
+++ b/testcases/kernel/syscalls/faccessat/faccessat01.c
@@ -43,7 +43,7 @@
 #include <signal.h>
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TEST_CASES 6
 #ifndef AT_FDCWD
@@ -129,8 +129,8 @@
 	fds[0] = SAFE_OPEN(cleanup, pathname, O_DIRECTORY);
 	fds[1] = fds[4] = fds[0];
 
-	SAFE_FILE_PRINTF(cleanup, testfile, testfile);
-	SAFE_FILE_PRINTF(cleanup, testfile2, testfile2);
+	SAFE_FILE_PRINTF(cleanup, testfile, "%s", testfile);
+	SAFE_FILE_PRINTF(cleanup, testfile2, "%s", testfile2);
 
 	fds[2] = SAFE_OPEN(cleanup, testfile3, O_CREAT | O_RDWR, 0600);
 
diff --git a/testcases/kernel/syscalls/fadvise/posix_fadvise01.c b/testcases/kernel/syscalls/fadvise/posix_fadvise01.c
index 55fa62f..03b6546 100644
--- a/testcases/kernel/syscalls/fadvise/posix_fadvise01.c
+++ b/testcases/kernel/syscalls/fadvise/posix_fadvise01.c
@@ -43,7 +43,7 @@
 
 #include "test.h"
 
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #ifndef _FILE_OFFSET_BITS
 #define _FILE_OFFSET_BITS 32
 #endif
diff --git a/testcases/kernel/syscalls/fadvise/posix_fadvise02.c b/testcases/kernel/syscalls/fadvise/posix_fadvise02.c
index 73ca311..0b6b355 100644
--- a/testcases/kernel/syscalls/fadvise/posix_fadvise02.c
+++ b/testcases/kernel/syscalls/fadvise/posix_fadvise02.c
@@ -41,7 +41,7 @@
 #include <errno.h>
 #include "test.h"
 
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #ifndef _FILE_OFFSET_BITS
 #define _FILE_OFFSET_BITS 32
 #endif
diff --git a/testcases/kernel/syscalls/fadvise/posix_fadvise03.c b/testcases/kernel/syscalls/fadvise/posix_fadvise03.c
index 44646e7..26c21c0 100644
--- a/testcases/kernel/syscalls/fadvise/posix_fadvise03.c
+++ b/testcases/kernel/syscalls/fadvise/posix_fadvise03.c
@@ -42,7 +42,7 @@
 #include <limits.h>
 #include "test.h"
 
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #ifndef _FILE_OFFSET_BITS
 #define _FILE_OFFSET_BITS 32
 #endif
diff --git a/testcases/kernel/syscalls/fadvise/posix_fadvise04.c b/testcases/kernel/syscalls/fadvise/posix_fadvise04.c
index af33cf2..f466e6f 100644
--- a/testcases/kernel/syscalls/fadvise/posix_fadvise04.c
+++ b/testcases/kernel/syscalls/fadvise/posix_fadvise04.c
@@ -40,7 +40,7 @@
 #include <signal.h>
 #include <errno.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #ifndef _FILE_OFFSET_BITS
 #define _FILE_OFFSET_BITS 32
 #endif
diff --git a/testcases/kernel/syscalls/fallocate/fallocate02.c b/testcases/kernel/syscalls/fallocate/fallocate02.c
index bee0863..4840eaf 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate02.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate02.c
@@ -36,6 +36,7 @@
 #include <fcntl.h>
 #include <inttypes.h>
 #include <sys/utsname.h>
+#include <limits.h>
 
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index 518d05e..f5f7df2 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -39,7 +39,7 @@
 /* fanotify(7) wrappers */
 
 #include <stdint.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static int fanotify_init(unsigned int flags, unsigned int event_f_flags)
 {
diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
index 1df3a69..24fc214 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify01.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
@@ -35,13 +35,8 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
 #include "fanotify.h"
-#include "safe_macros.h"
-
-char *TCID = "fanotify01";
-int TST_TOTAL = 12;
 
 #if defined(HAVE_SYS_FANOTIFY_H)
 #include <sys/fanotify.h>
@@ -52,10 +47,9 @@
 /* reasonable guess as to size of 1024 events */
 #define EVENT_BUF_LEN        (EVENT_MAX * EVENT_SIZE)
 
-static void setup(void);
-static void cleanup(void);
-
 #define BUF_SIZE 256
+#define TST_TOTAL 12
+
 static char fname[BUF_SIZE];
 static char buf[BUF_SIZE];
 static int fd, fd_notify;
@@ -64,308 +58,282 @@
 
 static char event_buf[EVENT_BUF_LEN];
 
-int main(int ac, char **av)
+void test01(void)
 {
-	int lc;
+	int ret, len, i = 0, test_num = 0;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	int tst_count = 0;
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int ret, len, i = 0, test_num = 0;
-
-		tst_count = 0;
-
-		if (fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ACCESS | FAN_MODIFY |
-				    FAN_CLOSE | FAN_OPEN, AT_FDCWD, fname) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			    "fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | "
-			    "FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) "
-			    "failed", fd_notify, fname);
-		}
-
-		/*
-		 * generate sequence of events
-		 */
-		fd = SAFE_OPEN(cleanup, fname, O_RDONLY);
-		event_set[tst_count] = FAN_OPEN;
-		tst_count++;
-
-		SAFE_READ(cleanup, 0, fd, buf, BUF_SIZE);
-		event_set[tst_count] = FAN_ACCESS;
-		tst_count++;
-
-		SAFE_CLOSE(cleanup, fd);
-		event_set[tst_count] = FAN_CLOSE_NOWRITE;
-		tst_count++;
-
-		/*
-		 * Get list of events so far. We get events here to avoid
-		 * merging of following events with the previous ones.
-		 */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf, EVENT_BUF_LEN);
-		len = ret;
-
-		fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0700);
-		event_set[tst_count] = FAN_OPEN;
-		tst_count++;
-
-		SAFE_WRITE(cleanup, 1, fd, fname, strlen(fname));
-		event_set[tst_count] = FAN_MODIFY;
-		tst_count++;
-
-		SAFE_CLOSE(cleanup, fd);
-		event_set[tst_count] = FAN_CLOSE_WRITE;
-		tst_count++;
-
-		/*
-		 * get another list of events
-		 */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
-				EVENT_BUF_LEN - len);
-		len += ret;
-
-		/*
-		 * Ignore mask testing
-		 */
-
-		/* Ignore access events */
-		if (fanotify_mark(fd_notify,
-				    FAN_MARK_ADD | FAN_MARK_IGNORED_MASK,
-				    FAN_ACCESS, AT_FDCWD, fname) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			     "fanotify_mark (%d, FAN_MARK_ADD | "
-			     "FAN_MARK_IGNORED_MASK, FAN_ACCESS, "
-			     "AT_FDCWD, %s) failed", fd_notify, fname);
-		}
-
-		fd = SAFE_OPEN(cleanup, fname, O_RDWR);
-		event_set[tst_count] = FAN_OPEN;
-		tst_count++;
-
-		/* This event should be ignored */
-		SAFE_READ(cleanup, 0, fd, buf, BUF_SIZE);
-
-		/*
-		 * get another list of events to verify the last one got ignored
-		 */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
-				EVENT_BUF_LEN - len);
-		len += ret;
-
-		lseek(fd, 0, SEEK_SET);
-		/* Generate modify event to clear ignore mask */
-		SAFE_WRITE(cleanup, 1, fd, fname, 1);
-		event_set[tst_count] = FAN_MODIFY;
-		tst_count++;
-
-		/*
-		 * This event shouldn't be ignored because previous modification
-		 * should have removed the ignore mask
-		 */
-		SAFE_READ(cleanup, 0, fd, buf, BUF_SIZE);
-		event_set[tst_count] = FAN_ACCESS;
-		tst_count++;
-
-		SAFE_CLOSE(cleanup, fd);
-		event_set[tst_count] = FAN_CLOSE_WRITE;
-		tst_count++;
-
-		/* Read events to verify previous access was properly generated */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
-				EVENT_BUF_LEN - len);
-		len += ret;
-
-		/*
-		 * Now ignore open & close events regardless of file
-		 * modifications
-		 */
-		if (fanotify_mark(fd_notify,
-				    FAN_MARK_ADD | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY,
-				    FAN_OPEN | FAN_CLOSE, AT_FDCWD, fname) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			     "fanotify_mark (%d, FAN_MARK_ADD | "
-			     "FAN_MARK_IGNORED_MASK | "
-			     "FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | "
-			     "FAN_CLOSE, AT_FDCWD, %s) failed", fd_notify,
-			     fname);
-		}
-
-		/* This event should be ignored */
-		fd = SAFE_OPEN(cleanup, fname, O_RDWR);
-
-		SAFE_WRITE(cleanup, 1, fd, fname, 1);
-		event_set[tst_count] = FAN_MODIFY;
-		tst_count++;
-
-		/* This event should be still ignored */
-		SAFE_CLOSE(cleanup, fd);
-
-		/* This event should still be ignored */
-		fd = SAFE_OPEN(cleanup, fname, O_RDWR);
-
-		/* Read events to verify open & close were ignored */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
-				EVENT_BUF_LEN - len);
-		len += ret;
-
-		/* Now remove open and close from ignored mask */
-		if (fanotify_mark(fd_notify,
-				    FAN_MARK_REMOVE | FAN_MARK_IGNORED_MASK,
-				    FAN_OPEN | FAN_CLOSE, AT_FDCWD, fname) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			     "fanotify_mark (%d, FAN_MARK_REMOVE | "
-			     "FAN_MARK_IGNORED_MASK, FAN_OPEN | "
-			     "FAN_CLOSE, AT_FDCWD, %s) failed", fd_notify,
-			     fname);
-		}
-
-		SAFE_CLOSE(cleanup, fd);
-		event_set[tst_count] = FAN_CLOSE_WRITE;
-		tst_count++;
-
-		/* Read events to verify close was generated */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
-				EVENT_BUF_LEN - len);
-		len += ret;
-
-		if (TST_TOTAL != tst_count) {
-			tst_brkm(TBROK, cleanup,
-				 "TST_TOTAL (%d) and tst_count (%d) are not "
-				 "equal", TST_TOTAL, tst_count);
-		}
-		tst_count = 0;
-
-		/*
-		 * check events
-		 */
-		while (i < len) {
-			struct fanotify_event_metadata *event;
-
-			event = (struct fanotify_event_metadata *)&event_buf[i];
-			if (test_num >= TST_TOTAL) {
-				tst_resm(TFAIL,
-					 "get unnecessary event: mask=%llx "
-					 "pid=%u fd=%u",
-					 (unsigned long long)event->mask,
-					 (unsigned)event->pid, event->fd);
-			} else if (!(event->mask & event_set[test_num])) {
-				tst_resm(TFAIL,
-					 "get event: mask=%llx (expected %llx) "
-					 "pid=%u fd=%u",
-					 (unsigned long long)event->mask,
-					 event_set[test_num],
-					 (unsigned)event->pid, event->fd);
-			} else if (event->pid != getpid()) {
-				tst_resm(TFAIL,
-					 "get event: mask=%llx pid=%u "
-					 "(expected %u) fd=%u",
-					 (unsigned long long)event->mask,
-					 (unsigned)event->pid,
-					 (unsigned)getpid(),
-					 event->fd);
-			} else {
-				if (event->fd == -2)
-					goto pass;
-				ret = read(event->fd, buf, BUF_SIZE);
-				if (ret != strlen(fname)) {
-					tst_resm(TFAIL,
-						 "cannot read from returned fd "
-						 "of event: mask=%llx pid=%u "
-						 "fd=%u ret=%d (errno=%d)",
-						 (unsigned long long)event->mask,
-						 (unsigned)event->pid,
-						 event->fd, ret, errno);
-				} else if (memcmp(buf, fname, strlen(fname))) {
-					tst_resm(TFAIL,
-						 "wrong data read from returned fd "
-						 "of event: mask=%llx pid=%u "
-						 "fd=%u",
-						 (unsigned long long)event->mask,
-						 (unsigned)event->pid,
-						 event->fd);
-				} else {
-pass:
-					tst_resm(TPASS,
-					    "get event: mask=%llx pid=%u fd=%u",
-					    (unsigned long long)event->mask,
-					    (unsigned)event->pid, event->fd);
-				}
-			}
-			/*
-			 * We have verified the data now so close fd and
-			 * invalidate it so that we don't check it again
-			 * unnecessarily
-			 */
-			close(event->fd);
-			event->fd = -2;
-			event->mask &= ~event_set[test_num];
-			/* No events left in current mask? Go for next event */
-			if (event->mask == 0) {
-				i += event->event_len;
-			}
-			test_num++;
-		}
-		for (; test_num < TST_TOTAL; test_num++) {
-			tst_resm(TFAIL, "didn't get event: mask=%llx",
-				 event_set[test_num]);
-
-		}
-		/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
-		if (fanotify_mark(fd_notify, FAN_MARK_REMOVE, FAN_ACCESS | FAN_MODIFY |
-				    FAN_CLOSE | FAN_OPEN, AT_FDCWD, fname) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			    "fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | "
-			    "FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) "
-			    "failed", fd_notify, fname);
-		}
-
+	if (fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ACCESS | FAN_MODIFY |
+			    FAN_CLOSE | FAN_OPEN, AT_FDCWD, fname) < 0) {
+		tst_brk(TBROK | TERRNO,
+		    "fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | "
+		    "FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) "
+		    "failed", fd_notify, fname);
 	}
 
-	cleanup();
-	tst_exit();
+	/*
+	 * generate sequence of events
+	 */
+	fd = SAFE_OPEN(fname, O_RDONLY);
+	event_set[tst_count] = FAN_OPEN;
+	tst_count++;
+
+	SAFE_READ(0, fd, buf, BUF_SIZE);
+	event_set[tst_count] = FAN_ACCESS;
+	tst_count++;
+
+	SAFE_CLOSE(fd);
+	event_set[tst_count] = FAN_CLOSE_NOWRITE;
+	tst_count++;
+
+	/*
+	 * Get list of events so far. We get events here to avoid
+	 * merging of following events with the previous ones.
+	 */
+	ret = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
+	len = ret;
+
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
+	event_set[tst_count] = FAN_OPEN;
+	tst_count++;
+
+	SAFE_WRITE(1, fd, fname, strlen(fname));
+	event_set[tst_count] = FAN_MODIFY;
+	tst_count++;
+
+	SAFE_CLOSE(fd);
+	event_set[tst_count] = FAN_CLOSE_WRITE;
+	tst_count++;
+
+	/*
+	 * get another list of events
+	 */
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
+			EVENT_BUF_LEN - len);
+	len += ret;
+
+	/*
+	 * Ignore mask testing
+	 */
+
+	/* Ignore access events */
+	if (fanotify_mark(fd_notify,
+			    FAN_MARK_ADD | FAN_MARK_IGNORED_MASK,
+			    FAN_ACCESS, AT_FDCWD, fname) < 0) {
+		tst_brk(TBROK | TERRNO,
+		     "fanotify_mark (%d, FAN_MARK_ADD | "
+		     "FAN_MARK_IGNORED_MASK, FAN_ACCESS, "
+		     "AT_FDCWD, %s) failed", fd_notify, fname);
+	}
+
+	fd = SAFE_OPEN(fname, O_RDWR);
+	event_set[tst_count] = FAN_OPEN;
+	tst_count++;
+
+	/* This event should be ignored */
+	SAFE_READ(0, fd, buf, BUF_SIZE);
+
+	/*
+	 * get another list of events to verify the last one got ignored
+	 */
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
+			EVENT_BUF_LEN - len);
+	len += ret;
+
+	lseek(fd, 0, SEEK_SET);
+	/* Generate modify event to clear ignore mask */
+	SAFE_WRITE(1, fd, fname, 1);
+	event_set[tst_count] = FAN_MODIFY;
+	tst_count++;
+
+	/*
+	 * This event shouldn't be ignored because previous modification
+	 * should have removed the ignore mask
+	 */
+	SAFE_READ(0, fd, buf, BUF_SIZE);
+	event_set[tst_count] = FAN_ACCESS;
+	tst_count++;
+
+	SAFE_CLOSE(fd);
+	event_set[tst_count] = FAN_CLOSE_WRITE;
+	tst_count++;
+
+	/* Read events to verify previous access was properly generated */
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
+			EVENT_BUF_LEN - len);
+	len += ret;
+
+	/*
+	 * Now ignore open & close events regardless of file
+	 * modifications
+	 */
+	if (fanotify_mark(fd_notify,
+			    FAN_MARK_ADD | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY,
+			    FAN_OPEN | FAN_CLOSE, AT_FDCWD, fname) < 0) {
+		tst_brk(TBROK | TERRNO,
+		     "fanotify_mark (%d, FAN_MARK_ADD | "
+		     "FAN_MARK_IGNORED_MASK | "
+		     "FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | "
+		     "FAN_CLOSE, AT_FDCWD, %s) failed", fd_notify,
+		     fname);
+	}
+
+	/* This event should be ignored */
+	fd = SAFE_OPEN(fname, O_RDWR);
+
+	SAFE_WRITE(1, fd, fname, 1);
+	event_set[tst_count] = FAN_MODIFY;
+	tst_count++;
+
+	/* This event should be still ignored */
+	SAFE_CLOSE(fd);
+
+	/* This event should still be ignored */
+	fd = SAFE_OPEN(fname, O_RDWR);
+
+	/* Read events to verify open & close were ignored */
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
+			EVENT_BUF_LEN - len);
+	len += ret;
+
+	/* Now remove open and close from ignored mask */
+	if (fanotify_mark(fd_notify,
+			    FAN_MARK_REMOVE | FAN_MARK_IGNORED_MASK,
+			    FAN_OPEN | FAN_CLOSE, AT_FDCWD, fname) < 0) {
+		tst_brk(TBROK | TERRNO,
+		     "fanotify_mark (%d, FAN_MARK_REMOVE | "
+		     "FAN_MARK_IGNORED_MASK, FAN_OPEN | "
+		     "FAN_CLOSE, AT_FDCWD, %s) failed", fd_notify,
+		     fname);
+	}
+
+	SAFE_CLOSE(fd);
+	event_set[tst_count] = FAN_CLOSE_WRITE;
+	tst_count++;
+
+	/* Read events to verify close was generated */
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
+			EVENT_BUF_LEN - len);
+	len += ret;
+
+	if (TST_TOTAL != tst_count) {
+		tst_brk(TBROK,
+			 "TST_TOTAL (%d) and tst_count (%d) are not "
+			 "equal", TST_TOTAL, tst_count);
+	}
+	tst_count = 0;
+
+	/*
+	 * check events
+	 */
+	while (i < len) {
+		struct fanotify_event_metadata *event;
+
+		event = (struct fanotify_event_metadata *)&event_buf[i];
+		if (test_num >= TST_TOTAL) {
+			tst_res(TFAIL,
+				 "get unnecessary event: mask=%llx "
+				 "pid=%u fd=%u",
+				 (unsigned long long)event->mask,
+				 (unsigned)event->pid, event->fd);
+		} else if (!(event->mask & event_set[test_num])) {
+			tst_res(TFAIL,
+				 "get event: mask=%llx (expected %llx) "
+				 "pid=%u fd=%u",
+				 (unsigned long long)event->mask,
+				 event_set[test_num],
+				 (unsigned)event->pid, event->fd);
+		} else if (event->pid != getpid()) {
+			tst_res(TFAIL,
+				 "get event: mask=%llx pid=%u "
+				 "(expected %u) fd=%u",
+				 (unsigned long long)event->mask,
+				 (unsigned)event->pid,
+				 (unsigned)getpid(),
+				 event->fd);
+		} else {
+			if (event->fd == -2)
+				goto pass;
+			ret = read(event->fd, buf, BUF_SIZE);
+			if (ret != (int)strlen(fname)) {
+				tst_res(TFAIL,
+					 "cannot read from returned fd "
+					 "of event: mask=%llx pid=%u "
+					 "fd=%u ret=%d (errno=%d)",
+					 (unsigned long long)event->mask,
+					 (unsigned)event->pid,
+					 event->fd, ret, errno);
+			} else if (memcmp(buf, fname, strlen(fname))) {
+				tst_res(TFAIL,
+					 "wrong data read from returned fd "
+					 "of event: mask=%llx pid=%u "
+					 "fd=%u",
+					 (unsigned long long)event->mask,
+					 (unsigned)event->pid,
+					 event->fd);
+			} else {
+pass:
+				tst_res(TPASS,
+				    "get event: mask=%llx pid=%u fd=%u",
+				    (unsigned long long)event->mask,
+				    (unsigned)event->pid, event->fd);
+			}
+		}
+		/*
+		 * We have verified the data now so close fd and
+		 * invalidate it so that we don't check it again
+		 * unnecessarily
+		 */
+		close(event->fd);
+		event->fd = -2;
+		event->mask &= ~event_set[test_num];
+		/* No events left in current mask? Go for next event */
+		if (event->mask == 0) {
+			i += event->event_len;
+		}
+		test_num++;
+	}
+	for (; test_num < TST_TOTAL; test_num++) {
+		tst_res(TFAIL, "didn't get event: mask=%llx",
+			 event_set[test_num]);
+
+	}
+	/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
+	if (fanotify_mark(fd_notify, FAN_MARK_REMOVE, FAN_ACCESS | FAN_MODIFY |
+			    FAN_CLOSE | FAN_OPEN, AT_FDCWD, fname) < 0) {
+		tst_brk(TBROK | TERRNO,
+		    "fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | "
+		    "FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) "
+		    "failed", fd_notify, fname);
+	}
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
 	sprintf(fname, "tfile_%d", getpid());
-	fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0700);
-	SAFE_WRITE(cleanup, 1, fd, fname, 1);
-
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
+	SAFE_WRITE(1, fd, fname, 1);
 	/* close the file we have open */
-	SAFE_CLOSE(cleanup, fd);
+	SAFE_CLOSE(fd);
 
-	if ((fd_notify = fanotify_init(FAN_CLASS_NOTIF, O_RDONLY)) < 0) {
-		if (errno == ENOSYS) {
-			tst_brkm(TCONF, cleanup,
-				 "fanotify is not configured in this kernel.");
-		} else {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "fanotify_init failed");
-		}
-	}
+	fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
 }
 
 static void cleanup(void)
 {
-	if (fd_notify > 0 && close(fd_notify))
-		tst_resm(TWARN | TERRNO, "close(%d) failed", fd_notify);
-
-	tst_rmdir();
+	if (fd_notify > 0)
+		SAFE_CLOSE(fd_notify);
 }
 
+static struct tst_test test = {
+	.test_all = test01,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.needs_root = 1
+};
+
 #else
-
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "system doesn't have required fanotify support");
-}
-
+	TST_TEST_TCONF("system doesn't have required fanotify support");
 #endif
diff --git a/testcases/kernel/syscalls/fanotify/fanotify02.c b/testcases/kernel/syscalls/fanotify/fanotify02.c
index 5a48e65..5aae777 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify02.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify02.c
@@ -35,13 +35,8 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
 #include "fanotify.h"
-#include "safe_macros.h"
-
-char *TCID = "fanotify02";
-int TST_TOTAL = 8;
 
 #if defined(HAVE_SYS_FANOTIFY_H)
 #include <sys/fanotify.h>
@@ -52,10 +47,9 @@
 /* reasonable guess as to size of 1024 events */
 #define EVENT_BUF_LEN        (EVENT_MAX * EVENT_SIZE)
 
-static void setup(void);
-static void cleanup(void);
-
 #define BUF_SIZE 256
+#define TST_TOTAL 8
+
 static char fname[BUF_SIZE];
 static char buf[BUF_SIZE];
 static int fd, fd_notify;
@@ -64,197 +58,173 @@
 
 static char event_buf[EVENT_BUF_LEN];
 
-int main(int ac, char **av)
+void test01(void)
 {
-	int lc;
+	int ret, len, i = 0, test_num = 0;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	int tst_count = 0;
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int ret, len, i = 0, test_num = 0;
-
-		tst_count = 0;
-
-		if (fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ACCESS |
-				    FAN_MODIFY | FAN_CLOSE | FAN_OPEN |
-				    FAN_EVENT_ON_CHILD | FAN_ONDIR, AT_FDCWD,
-				  ".") < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			    "fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | "
-			    "FAN_MODIFY | FAN_CLOSE | FAN_OPEN | "
-			    "FAN_EVENT_ON_CHILD | FAN_ONDIR, AT_FDCWD, '.') "
-			    "failed", fd_notify);
-		}
-
-		/*
-		 * generate sequence of events
-		 */
-		fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0700);
-		event_set[tst_count] = FAN_OPEN;
-		tst_count++;
-
-		SAFE_WRITE(cleanup, 1, fd, fname, strlen(fname));
-		event_set[tst_count] = FAN_MODIFY;
-		tst_count++;
-
-		SAFE_CLOSE(cleanup, fd);
-		event_set[tst_count] = FAN_CLOSE_WRITE;
-		tst_count++;
-
-		/*
-		 * Get list of events so far. We get events here to avoid
-		 * merging of following events with the previous ones.
-		 */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf,
-				EVENT_BUF_LEN);
-		len = ret;
-
-		fd = SAFE_OPEN(cleanup, fname, O_RDONLY);
-		event_set[tst_count] = FAN_OPEN;
-		tst_count++;
-
-		SAFE_READ(cleanup, 0, fd, buf, BUF_SIZE);
-		event_set[tst_count] = FAN_ACCESS;
-		tst_count++;
-
-		SAFE_CLOSE(cleanup, fd);
-		event_set[tst_count] = FAN_CLOSE_NOWRITE;
-		tst_count++;
-
-		/*
-		 * get next events
-		 */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
-				EVENT_BUF_LEN - len);
-		len += ret;
-
-		/*
-		 * now remove child mark
-		 */
-		if (fanotify_mark(fd_notify, FAN_MARK_REMOVE,
-				    FAN_EVENT_ON_CHILD, AT_FDCWD, ".") < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			    "fanotify_mark (%d, FAN_MARK REMOVE, "
-			    "FAN_EVENT_ON_CHILD, AT_FDCWD, '.') failed",
-			    fd_notify);
-		}
-
-		/*
-		 * Do something to verify events didn't get generated
-		 */
-		fd = SAFE_OPEN(cleanup, fname, O_RDONLY);
-
-		SAFE_CLOSE(cleanup, fd);
-
-		fd = SAFE_OPEN(cleanup, ".", O_RDONLY | O_DIRECTORY);
-		event_set[tst_count] = FAN_OPEN;
-		tst_count++;
-
-		SAFE_CLOSE(cleanup, fd);
-		event_set[tst_count] = FAN_CLOSE_NOWRITE;
-		tst_count++;
-
-		/*
-		 * Check events got generated only for the directory
-		 */
-		ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
-				EVENT_BUF_LEN - len);
-		len += ret;
-
-		if (TST_TOTAL != tst_count) {
-			tst_brkm(TBROK, cleanup,
-				 "TST_TOTAL and tst_count are not equal");
-		}
-		tst_count = 0;
-
-		/*
-		 * check events
-		 */
-		while (i < len) {
-			struct fanotify_event_metadata *event;
-
-			event = (struct fanotify_event_metadata *)&event_buf[i];
-			if (test_num >= TST_TOTAL) {
-				tst_resm(TFAIL,
-					 "get unnecessary event: mask=%llx "
-					 "pid=%u fd=%u",
-					 (unsigned long long)event->mask,
-					 (unsigned)event->pid, event->fd);
-			} else if (!(event->mask & event_set[test_num])) {
-				tst_resm(TFAIL,
-					 "get event: mask=%llx (expected %llx) "
-					 "pid=%u fd=%u",
-					 (unsigned long long)event->mask,
-					 event_set[test_num],
-					 (unsigned)event->pid, event->fd);
-			} else if (event->pid != getpid()) {
-				tst_resm(TFAIL,
-					 "get event: mask=%llx pid=%u "
-					 "(expected %u) fd=%u",
-					 (unsigned long long)event->mask,
-					 (unsigned)event->pid,
-					 (unsigned)getpid(),
-					 event->fd);
-			} else {
-				tst_resm(TPASS,
-					    "get event: mask=%llx pid=%u fd=%u",
-					    (unsigned long long)event->mask,
-					    (unsigned)event->pid, event->fd);
-			}
-			event->mask &= ~event_set[test_num];
-			/* No events left in current mask? Go for next event */
-			if (event->mask == 0) {
-				i += event->event_len;
-				close(event->fd);
-			}
-			test_num++;
-		}
-		for (; test_num < TST_TOTAL; test_num++) {
-			tst_resm(TFAIL, "didn't get event: mask=%llx",
-				 event_set[test_num]);
-
-		}
+	if (fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ACCESS |
+			    FAN_MODIFY | FAN_CLOSE | FAN_OPEN |
+			    FAN_EVENT_ON_CHILD | FAN_ONDIR, AT_FDCWD,
+			  ".") < 0) {
+		tst_brk(TBROK | TERRNO,
+		    "fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | "
+		    "FAN_MODIFY | FAN_CLOSE | FAN_OPEN | "
+		    "FAN_EVENT_ON_CHILD | FAN_ONDIR, AT_FDCWD, '.') "
+		    "failed", fd_notify);
 	}
 
-	cleanup();
-	tst_exit();
+	/*
+	 * generate sequence of events
+	 */
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
+	event_set[tst_count] = FAN_OPEN;
+	tst_count++;
+
+	SAFE_WRITE(1, fd, fname, strlen(fname));
+	event_set[tst_count] = FAN_MODIFY;
+	tst_count++;
+
+	SAFE_CLOSE(fd);
+	event_set[tst_count] = FAN_CLOSE_WRITE;
+	tst_count++;
+
+	/*
+	 * Get list of events so far. We get events here to avoid
+	 * merging of following events with the previous ones.
+	 */
+	ret = SAFE_READ(0, fd_notify, event_buf,
+			EVENT_BUF_LEN);
+	len = ret;
+
+	fd = SAFE_OPEN(fname, O_RDONLY);
+	event_set[tst_count] = FAN_OPEN;
+	tst_count++;
+
+	SAFE_READ(0, fd, buf, BUF_SIZE);
+	event_set[tst_count] = FAN_ACCESS;
+	tst_count++;
+
+	SAFE_CLOSE(fd);
+	event_set[tst_count] = FAN_CLOSE_NOWRITE;
+	tst_count++;
+
+	/*
+	 * get next events
+	 */
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
+			EVENT_BUF_LEN - len);
+	len += ret;
+
+	/*
+	 * now remove child mark
+	 */
+	if (fanotify_mark(fd_notify, FAN_MARK_REMOVE,
+			    FAN_EVENT_ON_CHILD, AT_FDCWD, ".") < 0) {
+		tst_brk(TBROK | TERRNO,
+		    "fanotify_mark (%d, FAN_MARK REMOVE, "
+		    "FAN_EVENT_ON_CHILD, AT_FDCWD, '.') failed",
+		    fd_notify);
+	}
+
+	/*
+	 * Do something to verify events didn't get generated
+	 */
+	fd = SAFE_OPEN(fname, O_RDONLY);
+
+	SAFE_CLOSE(fd);
+
+	fd = SAFE_OPEN(".", O_RDONLY | O_DIRECTORY);
+	event_set[tst_count] = FAN_OPEN;
+	tst_count++;
+
+	SAFE_CLOSE(fd);
+	event_set[tst_count] = FAN_CLOSE_NOWRITE;
+	tst_count++;
+
+	/*
+	 * Check events got generated only for the directory
+	 */
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
+			EVENT_BUF_LEN - len);
+	len += ret;
+
+	if (TST_TOTAL != tst_count) {
+		tst_brk(TBROK,
+			 "TST_TOTAL and tst_count are not equal");
+	}
+	tst_count = 0;
+
+	/*
+	 * check events
+	 */
+	while (i < len) {
+		struct fanotify_event_metadata *event;
+
+		event = (struct fanotify_event_metadata *)&event_buf[i];
+		if (test_num >= TST_TOTAL) {
+			tst_res(TFAIL,
+				 "get unnecessary event: mask=%llx "
+				 "pid=%u fd=%u",
+				 (unsigned long long)event->mask,
+				 (unsigned)event->pid, event->fd);
+		} else if (!(event->mask & event_set[test_num])) {
+			tst_res(TFAIL,
+				 "get event: mask=%llx (expected %llx) "
+				 "pid=%u fd=%u",
+				 (unsigned long long)event->mask,
+				 event_set[test_num],
+				 (unsigned)event->pid, event->fd);
+		} else if (event->pid != getpid()) {
+			tst_res(TFAIL,
+				 "get event: mask=%llx pid=%u "
+				 "(expected %u) fd=%u",
+				 (unsigned long long)event->mask,
+				 (unsigned)event->pid,
+				 (unsigned)getpid(),
+				 event->fd);
+		} else {
+			tst_res(TPASS,
+				    "get event: mask=%llx pid=%u fd=%u",
+				    (unsigned long long)event->mask,
+				    (unsigned)event->pid, event->fd);
+		}
+		event->mask &= ~event_set[test_num];
+		/* No events left in current mask? Go for next event */
+		if (event->mask == 0) {
+			i += event->event_len;
+			close(event->fd);
+		}
+		test_num++;
+	}
+	for (; test_num < TST_TOTAL; test_num++) {
+		tst_res(TFAIL, "didn't get event: mask=%llx",
+			 event_set[test_num]);
+
+	}
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
 	sprintf(fname, "fname_%d", getpid());
-
-	if ((fd_notify = fanotify_init(FAN_CLASS_NOTIF, O_RDONLY)) < 0) {
-		if (errno == ENOSYS) {
-			tst_brkm(TCONF, cleanup,
-				 "fanotify is not configured in this kernel.");
-		} else {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "fanotify_init failed");
-		}
-	}
+	fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
 }
 
 static void cleanup(void)
 {
-	if (fd_notify > 0 && close(fd_notify))
-		tst_resm(TWARN | TERRNO, "close(%d) failed", fd_notify);
-
-	tst_rmdir();
+	if (fd_notify > 0)
+		SAFE_CLOSE(fd_notify);
 }
 
+static struct tst_test test = {
+	.test_all = test01,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.needs_root = 1
+};
+
 #else
-
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "system doesn't have required fanotify support");
-}
-
+	TST_TEST_TCONF("system doesn't have required fanotify support");
 #endif
diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c
index 4dc55c9..3a75ac2 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify03.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify03.c
@@ -38,13 +38,9 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/syscall.h>
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#include <stdlib.h>
+#include "tst_test.h"
 #include "fanotify.h"
-#include "safe_macros.h"
-
-char *TCID = "fanotify03";
-int TST_TOTAL = 3;
 
 #if defined(HAVE_SYS_FANOTIFY_H)
 #include <sys/fanotify.h>
@@ -55,10 +51,9 @@
 /* reasonable guess as to size of 1024 events */
 #define EVENT_BUF_LEN        (EVENT_MAX * EVENT_SIZE)
 
-static void setup(void);
-static void cleanup(void);
-
 #define BUF_SIZE 256
+#define TST_TOTAL 3
+
 static char fname[BUF_SIZE];
 static char buf[BUF_SIZE];
 static volatile int fd_notify;
@@ -92,6 +87,7 @@
 
 static void child_handler(int tmp)
 {
+	(void)tmp;
 	/*
 	 * Close notification fd so that we cannot block while reading
 	 * from it
@@ -109,18 +105,16 @@
 	child_action.sa_flags = SA_NOCLDSTOP;
 
 	if (sigaction(SIGCHLD, &child_action, NULL) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
+		tst_brk(TBROK | TERRNO,
 			 "sigaction(SIGCHLD, &child_action, NULL) failed");
 	}
 
-	switch (child_pid = fork()) {
-	case 0:
+	child_pid = SAFE_FORK();
+	if (child_pid == 0) {
 		/* Child will generate events now */
 		close(fd_notify);
 		generate_events();
 		exit(0);
-	case -1:
-		tst_brkm(TBROK | TERRNO, cleanup, "fork() failed");
 	}
 }
 
@@ -133,171 +127,148 @@
 	sigemptyset(&child_action.sa_mask);
 	child_action.sa_flags = SA_NOCLDSTOP;
 	if (sigaction(SIGCHLD, &child_action, NULL) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
+		tst_brk(TBROK | TERRNO,
 			 "sigaction(SIGCHLD, &child_action, NULL) failed");
 	}
 	if (waitpid(-1, &child_ret, 0) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
+		tst_brk(TBROK | TERRNO,
 				 "waitpid(-1, &child_ret, 0) failed");
 	}
 
 	if (WIFSIGNALED(child_ret)) {
-		tst_resm(TFAIL, "child exited due to signal %d",
+		tst_res(TFAIL, "child exited due to signal %d",
 			 WTERMSIG(child_ret));
 	} else if (WIFEXITED(child_ret)) {
 		if (WEXITSTATUS(child_ret) == 0)
-			tst_resm(TPASS, "child exited correctly");
+			tst_res(TPASS, "child exited correctly");
 		else
-			tst_resm(TFAIL, "child exited with status %d",
+			tst_res(TFAIL, "child exited with status %d",
 				 WEXITSTATUS(child_ret));
 	} else {
-		tst_resm(TFAIL, "child exited for unknown reason (status %d)",
+		tst_res(TFAIL, "child exited for unknown reason (status %d)",
 			 child_ret);
 	}
 }
 
-int main(int ac, char **av)
+void test01(void)
 {
-	int lc;
-	int fd_notify_backup = -1;
+	int tst_count, fd_notify_backup = -1;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	int ret, len = 0, i = 0, test_num = 0;
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int ret, len = 0, i = 0, test_num = 0;
-
-		if (fd_notify_backup == -1) {
-			fd_notify_backup = dup(fd_notify);
-			if (fd_notify_backup < 0)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "dup(%d) failed", fd_notify);
-		}
-		run_child();
-
-		tst_count = 0;
-
-		event_set[tst_count] = FAN_OPEN_PERM;
-		event_resp[tst_count++] = FAN_ALLOW;
-		event_set[tst_count] = FAN_ACCESS_PERM;
-		event_resp[tst_count++] = FAN_DENY;
-
-		/* tst_count + 1 is for checking child return value */
-		if (TST_TOTAL != tst_count + 1) {
-			tst_brkm(TBROK, cleanup,
-				 "TST_TOTAL and tst_count do not match");
-		}
-		tst_count = 0;
-
-		/*
-		 * check events
-		 */
-		while (test_num < TST_TOTAL && fd_notify != -1) {
-			struct fanotify_event_metadata *event;
-
-			if (i == len) {
-				/* Get more events */
-				ret = read(fd_notify, event_buf + len,
-					   EVENT_BUF_LEN - len);
-				if (fd_notify == -1)
-					break;
-				if (ret < 0) {
-					tst_brkm(TBROK, cleanup,
-						 "read(%d, buf, %zu) failed",
-						 fd_notify, EVENT_BUF_LEN);
-				}
-				len += ret;
-			}
-
-			event = (struct fanotify_event_metadata *)&event_buf[i];
-			if (!(event->mask & event_set[test_num])) {
-				tst_resm(TFAIL,
-					 "get event: mask=%llx (expected %llx) "
-					 "pid=%u fd=%u",
-					 (unsigned long long)event->mask,
-					 event_set[test_num],
-					 (unsigned)event->pid, event->fd);
-			} else if (event->pid != child_pid) {
-				tst_resm(TFAIL,
-					 "get event: mask=%llx pid=%u "
-					 "(expected %u) fd=%u",
-					 (unsigned long long)event->mask,
-					 (unsigned)event->pid,
-					 (unsigned)child_pid,
-					 event->fd);
-			} else {
-				tst_resm(TPASS,
-					    "get event: mask=%llx pid=%u fd=%u",
-					    (unsigned long long)event->mask,
-					    (unsigned)event->pid, event->fd);
-			}
-			/* Write response to permission event */
-			if (event_set[test_num] & FAN_ALL_PERM_EVENTS) {
-				struct fanotify_response resp;
-
-				resp.fd = event->fd;
-				resp.response = event_resp[test_num];
-				SAFE_WRITE(cleanup, 1, fd_notify, &resp,
-					   sizeof(resp));
-			}
-			event->mask &= ~event_set[test_num];
-			/* No events left in current mask? Go for next event */
-			if (event->mask == 0) {
-				i += event->event_len;
-				close(event->fd);
-			}
-			test_num++;
-		}
-		for (; test_num < TST_TOTAL - 1; test_num++) {
-			tst_resm(TFAIL, "didn't get event: mask=%llx",
-				 event_set[test_num]);
-
-		}
-		check_child();
-		/* We got SIGCHLD while running, resetup fd_notify */
-		if (fd_notify == -1) {
-			fd_notify = fd_notify_backup;
-			fd_notify_backup = -1;
-		}
+	if (fd_notify_backup == -1) {
+		fd_notify_backup = dup(fd_notify);
+		if (fd_notify_backup < 0)
+			tst_brk(TBROK | TERRNO,
+				 "dup(%d) failed", fd_notify);
 	}
+	run_child();
 
-	cleanup();
-	tst_exit();
+	tst_count = 0;
+
+	event_set[tst_count] = FAN_OPEN_PERM;
+	event_resp[tst_count++] = FAN_ALLOW;
+	event_set[tst_count] = FAN_ACCESS_PERM;
+	event_resp[tst_count++] = FAN_DENY;
+
+	/* tst_count + 1 is for checking child return value */
+	if (TST_TOTAL != tst_count + 1) {
+		tst_brk(TBROK,
+			 "TST_TOTAL and tst_count do not match");
+	}
+	tst_count = 0;
+
+	/*
+	 * check events
+	 */
+	while (test_num < TST_TOTAL && fd_notify != -1) {
+		struct fanotify_event_metadata *event;
+
+		if (i == len) {
+			/* Get more events */
+			ret = read(fd_notify, event_buf + len,
+				   EVENT_BUF_LEN - len);
+			if (fd_notify == -1)
+				break;
+			if (ret < 0) {
+				tst_brk(TBROK,
+					 "read(%d, buf, %zu) failed",
+					 fd_notify, EVENT_BUF_LEN);
+			}
+			len += ret;
+		}
+
+		event = (struct fanotify_event_metadata *)&event_buf[i];
+		if (!(event->mask & event_set[test_num])) {
+			tst_res(TFAIL,
+				 "get event: mask=%llx (expected %llx) "
+				 "pid=%u fd=%u",
+				 (unsigned long long)event->mask,
+				 event_set[test_num],
+				 (unsigned)event->pid, event->fd);
+		} else if (event->pid != child_pid) {
+			tst_res(TFAIL,
+				 "get event: mask=%llx pid=%u "
+				 "(expected %u) fd=%u",
+				 (unsigned long long)event->mask,
+				 (unsigned)event->pid,
+				 (unsigned)child_pid,
+				 event->fd);
+		} else {
+			tst_res(TPASS,
+				    "get event: mask=%llx pid=%u fd=%u",
+				    (unsigned long long)event->mask,
+				    (unsigned)event->pid, event->fd);
+		}
+		/* Write response to permission event */
+		if (event_set[test_num] & FAN_ALL_PERM_EVENTS) {
+			struct fanotify_response resp;
+
+			resp.fd = event->fd;
+			resp.response = event_resp[test_num];
+			SAFE_WRITE(1, fd_notify, &resp,
+				   sizeof(resp));
+		}
+		event->mask &= ~event_set[test_num];
+		/* No events left in current mask? Go for next event */
+		if (event->mask == 0) {
+			i += event->event_len;
+			close(event->fd);
+		}
+		test_num++;
+	}
+	for (; test_num < TST_TOTAL - 1; test_num++) {
+		tst_res(TFAIL, "didn't get event: mask=%llx",
+			 event_set[test_num]);
+
+	}
+	check_child();
+	/* We got SIGCHLD while running, resetup fd_notify */
+	if (fd_notify == -1) {
+		fd_notify = fd_notify_backup;
+		fd_notify_backup = -1;
+	}
 }
 
 static void setup(void)
 {
 	int fd;
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
 	sprintf(fname, "fname_%d", getpid());
-	fd = SAFE_OPEN(cleanup, fname, O_CREAT | O_RDWR, 0644);
-	SAFE_WRITE(cleanup, 1, fd, fname, 1);
-	SAFE_CLOSE(cleanup, fd);
+	fd = SAFE_OPEN(fname, O_CREAT | O_RDWR, 0644);
+	SAFE_WRITE(1, fd, fname, 1);
+	SAFE_CLOSE(fd);
 
-	if ((fd_notify = fanotify_init(FAN_CLASS_CONTENT, O_RDONLY)) < 0) {
-		if (errno == ENOSYS) {
-			tst_brkm(TCONF, cleanup,
-				 "fanotify is not configured in this kernel.");
-		} else {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "fanotify_init failed");
-		}
-	}
+	fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY);
 
 	if (fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ACCESS_PERM |
 			    FAN_OPEN_PERM, AT_FDCWD, fname) < 0) {
 		if (errno == EINVAL) {
-			tst_brkm(TCONF | TERRNO, cleanup,
+			tst_brk(TCONF | TERRNO,
 				 "CONFIG_FANOTIFY_ACCESS_PERMISSIONS not "
 				 "configured in kernel?");
 		} else {
-			tst_brkm(TBROK | TERRNO, cleanup,
+			tst_brk(TBROK | TERRNO,
 				 "fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS_PERM | "
 				 "FAN_OPEN_PERM, AT_FDCWD, %s) failed.", fd_notify, fname);
 		}
@@ -307,17 +278,19 @@
 
 static void cleanup(void)
 {
-	if (fd_notify > 0 && close(fd_notify))
-		tst_resm(TWARN | TERRNO, "close(%d) failed", fd_notify);
-
-	tst_rmdir();
+	if (fd_notify > 0)
+		SAFE_CLOSE(fd_notify);
 }
 
+static struct tst_test test = {
+	.test_all = test01,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.forks_child = 1,
+	.needs_root = 1
+};
+
 #else
-
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "system doesn't have required fanotify support");
-}
-
+	TST_TEST_TCONF("system doesn't have required fanotify support");
 #endif
diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
index bffa3e5..68f65da 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify04.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
@@ -36,13 +36,8 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
 #include "fanotify.h"
-#include "safe_macros.h"
-
-char *TCID = "fanotify04";
-int TST_TOTAL = 9;
 
 #if defined(HAVE_SYS_FANOTIFY_H)
 #include <sys/fanotify.h>
@@ -53,10 +48,9 @@
 /* reasonable guess as to size of 1024 events */
 #define EVENT_BUF_LEN        (EVENT_MAX * EVENT_SIZE)
 
-static void setup(void);
-static void cleanup(void);
-
 #define BUF_SIZE 256
+#define TST_TOTAL 9
+
 static char fname[BUF_SIZE];
 static char sname[BUF_SIZE];
 static char dir[BUF_SIZE];
@@ -84,11 +78,11 @@
 {
 	if (fanotify_mark(fd_notify, FAN_MARK_ADD | flag, FAN_OPEN, AT_FDCWD,
 			    file) != expect) {
-		tst_resm(TFAIL,
+		tst_res(TFAIL,
 		    "fanotify_mark (%d, FAN_MARK_ADD | %s, FAN_OPEN, AT_FDCWD, "
 		    "'%s') %s", fd_notify, flagstr, file, expect_str_fail(expect));
 	} else {
-		tst_resm(TPASS,
+		tst_res(TPASS,
 		    "fanotify_mark (%d, FAN_MARK_ADD | %s, FAN_OPEN, AT_FDCWD, "
 		    "'%s') %s", fd_notify, flagstr, file, expect_str_pass(expect));
 
@@ -101,7 +95,7 @@
 
 		if (fanotify_mark(fd_notify, FAN_MARK_REMOVE | flag,
 				    FAN_OPEN, AT_FDCWD, file) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
+			tst_brk(TBROK | TERRNO,
 			    "fanotify_mark (%d, FAN_MARK_REMOVE | %s, "
 			    "FAN_OPEN, AT_FDCWD, '%s') failed",
 			    fd_notify, flagstr, file);
@@ -111,24 +105,22 @@
 
 #define CHECK_MARK(file, flag, expect, func) check_mark(file, flag, #flag, expect, func)
 
-static void do_open(char *file, int flag, char *flagstr)
+static void do_open(char *file, int flag)
 {
 	int fd;
 
-	fd = SAFE_OPEN(cleanup, file, O_RDONLY | flag);
-	SAFE_CLOSE(cleanup, fd);
+	fd = SAFE_OPEN(file, O_RDONLY | flag);
+	SAFE_CLOSE(fd);
 }
 
-#define DO_OPEN(file, flag) do_open(file, flag, #flag)
-
 static void open_file(char *file)
 {
-	DO_OPEN(file, 0);
+	do_open(file, 0);
 }
 
 static void open_dir(char *file)
 {
-	DO_OPEN(file, O_DIRECTORY);
+	do_open(file, O_DIRECTORY);
 }
 
 static void verify_event(int mask)
@@ -138,38 +130,36 @@
 	struct stat st;
 
 	/* Read the event */
-	ret = SAFE_READ(cleanup, 0, fd_notify, event_buf + len,
+	ret = SAFE_READ(0, fd_notify, event_buf + len,
 			EVENT_BUF_LEN - len);
 	event = (struct fanotify_event_metadata *)&event_buf[len];
 	len += ret;
 
 	if (event->mask != FAN_OPEN) {
-		tst_resm(TFAIL, "got unexpected event %llx",
+		tst_res(TFAIL, "got unexpected event %llx",
 			 (unsigned long long)event->mask);
 	} else if (fstat(event->fd, &st) < 0) {
-		tst_resm(TFAIL, "failed to stat event->fd (%s)",
+		tst_res(TFAIL, "failed to stat event->fd (%s)",
 			 strerror(errno));
-	} else if ((st.st_mode & S_IFMT) != mask) {
-		tst_resm(TFAIL, "event->fd points to object of different type "
+	} else if ((int)(st.st_mode & S_IFMT) != mask) {
+		tst_res(TFAIL, "event->fd points to object of different type "
 			 "(%o != %o)", st.st_mode & S_IFMT, mask);
 	} else {
-		tst_resm(TPASS, "event generated properly for type %o", mask);
+		tst_res(TPASS, "event generated properly for type %o", mask);
 	}
 	close(event->fd);
 }
 
-static void do_open_test(char *file, int flag, char *flagstr, int mask)
+static void do_open_test(char *file, int flag, int mask)
 {
-	do_open(file, flag, flagstr);
+	do_open(file, flag);
 
 	verify_event(mask);
 }
 
-#define DO_OPEN_TEST(file, flag, mask) do_open_test(file, flag, #flag, mask)
-
 static void test_open_file(char *file)
 {
-	DO_OPEN_TEST(file, 0, S_IFREG);
+	do_open_test(file, 0, S_IFREG);
 }
 
 static void verify_no_event(void)
@@ -181,123 +171,100 @@
 		struct fanotify_event_metadata *event;
 
 		event = (struct fanotify_event_metadata *)&event_buf[len];
-		tst_resm(TFAIL, "seen unexpected event (mask %llx)",
+		tst_res(TFAIL, "seen unexpected event (mask %llx)",
 			 (unsigned long long)event->mask);
 		/* Cleanup fd from the event */
 		close(event->fd);
 	} else if (errno != EAGAIN) {
-		tst_resm(TFAIL | TERRNO, "read(%d, buf, %zu) failed", fd_notify,
+		tst_res(TFAIL | TERRNO, "read(%d, buf, %zu) failed", fd_notify,
 			 EVENT_BUF_LEN);
 	} else {
-		tst_resm(TPASS, "No event as expected");
+		tst_res(TPASS, "No event as expected");
 	}
 }
 
 static void test_open_symlink(char *file)
 {
 	/* Since mark is on a symlink, no event should be generated by opening a file */
-	DO_OPEN(file, 0);
+	do_open(file, 0);
 	verify_no_event();
 }
 
-int main(int ac, char **av)
+void test01(void)
 {
-	int lc;
+	/* Check ONLYDIR on a directory */
+	CHECK_MARK(".", FAN_MARK_ONLYDIR, 0, NULL);
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	/* Check ONLYDIR without a directory */
+	CHECK_MARK(fname, FAN_MARK_ONLYDIR, -1, NULL);
 
-	setup();
+	/* Check DONT_FOLLOW for a symlink */
+	CHECK_MARK(sname, FAN_MARK_DONT_FOLLOW, 0, test_open_symlink);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* Check ONLYDIR on a directory */
-		CHECK_MARK(".", FAN_MARK_ONLYDIR, 0, NULL);
+	/* Check without DONT_FOLLOW for a symlink */
+	CHECK_MARK(sname, 0, 0, test_open_file);
 
-		/* Check ONLYDIR without a directory */
-		CHECK_MARK(fname, FAN_MARK_ONLYDIR, -1, NULL);
-
-		/* Check DONT_FOLLOW for a symlink */
-		CHECK_MARK(sname, FAN_MARK_DONT_FOLLOW, 0, test_open_symlink);
-
-		/* Check without DONT_FOLLOW for a symlink */
-		CHECK_MARK(sname, 0, 0, test_open_file);
-
-		/* Verify FAN_MARK_FLUSH destroys all inode marks */
-		if (fanotify_mark(fd_notify, FAN_MARK_ADD,
-				    FAN_OPEN, AT_FDCWD, fname) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			    "fanotify_mark (%d, FAN_MARK_ADD, FAN_OPEN, "
-			    "AT_FDCWD, '%s') failed", fd_notify, fname);
-		}
-		if (fanotify_mark(fd_notify, FAN_MARK_ADD,
-				    FAN_OPEN | FAN_ONDIR, AT_FDCWD, dir) < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			    "fanotify_mark (%d, FAN_MARK_ADD, FAN_OPEN | "
-			    "FAN_ONDIR, AT_FDCWD, '%s') failed", fd_notify,
-			    dir);
-		}
-		open_file(fname);
-		verify_event(S_IFREG);
-		open_dir(dir);
-		verify_event(S_IFDIR);
-		if (fanotify_mark(fd_notify, FAN_MARK_FLUSH,
-				    0, AT_FDCWD, ".") < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-			    "fanotify_mark (%d, FAN_MARK_FLUSH, 0, "
-			    "AT_FDCWD, '.') failed", fd_notify);
-		}
-
-		open_dir(dir);
-		verify_no_event();
+	/* Verify FAN_MARK_FLUSH destroys all inode marks */
+	if (fanotify_mark(fd_notify, FAN_MARK_ADD,
+			    FAN_OPEN, AT_FDCWD, fname) < 0) {
+		tst_brk(TBROK | TERRNO,
+		    "fanotify_mark (%d, FAN_MARK_ADD, FAN_OPEN, "
+		    "AT_FDCWD, '%s') failed", fd_notify, fname);
+	}
+	if (fanotify_mark(fd_notify, FAN_MARK_ADD,
+			    FAN_OPEN | FAN_ONDIR, AT_FDCWD, dir) < 0) {
+		tst_brk(TBROK | TERRNO,
+		    "fanotify_mark (%d, FAN_MARK_ADD, FAN_OPEN | "
+		    "FAN_ONDIR, AT_FDCWD, '%s') failed", fd_notify,
+		    dir);
+	}
+	open_file(fname);
+	verify_event(S_IFREG);
+	open_dir(dir);
+	verify_event(S_IFDIR);
+	if (fanotify_mark(fd_notify, FAN_MARK_FLUSH,
+			    0, AT_FDCWD, ".") < 0) {
+		tst_brk(TBROK | TERRNO,
+		    "fanotify_mark (%d, FAN_MARK_FLUSH, 0, "
+		    "AT_FDCWD, '.') failed", fd_notify);
 	}
 
-	cleanup();
-	tst_exit();
+	open_dir(dir);
+	verify_no_event();
 }
 
 static void setup(void)
 {
 	int fd;
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
 	sprintf(fname, "fname_%d", getpid());
-	fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0644);
-	SAFE_CLOSE(cleanup, fd);
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0644);
+	SAFE_CLOSE(fd);
 
 	sprintf(sname, "symlink_%d", getpid());
-	SAFE_SYMLINK(cleanup, fname, sname);
+	SAFE_SYMLINK(fname, sname);
 
 	sprintf(dir, "dir_%d", getpid());
-	SAFE_MKDIR(cleanup, dir, 0755);
+	SAFE_MKDIR(dir, 0755);
 
-	if ((fd_notify = fanotify_init(FAN_CLASS_NOTIF | FAN_NONBLOCK,
-					 O_RDONLY)) < 0) {
-		if (errno == ENOSYS) {
-			tst_brkm(TCONF, cleanup,
-				 "fanotify is not configured in this kernel.");
-		} else {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "fanotify_init failed");
-		}
-	}
+	fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_NONBLOCK,
+			O_RDONLY);
 }
 
 static void cleanup(void)
 {
-	if (fd_notify > 0 && close(fd_notify))
-		tst_resm(TWARN | TERRNO, "close(%d) failed", fd_notify);
-
-	tst_rmdir();
+	if (fd_notify > 0)
+		SAFE_CLOSE(fd_notify);
 }
 
+static struct tst_test test = {
+	.test_all = test01,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.needs_root = 1
+};
+
 #else
-
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "system doesn't have required fanotify support");
-}
-
+	TST_TEST_TCONF("system doesn't have required fanotify support");
 #endif
diff --git a/testcases/kernel/syscalls/fanotify/fanotify05.c b/testcases/kernel/syscalls/fanotify/fanotify05.c
index 735b415..ec615e6 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify05.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify05.c
@@ -34,13 +34,8 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
 #include "fanotify.h"
-#include "safe_macros.h"
-
-char *TCID = "fanotify05";
-int TST_TOTAL = 1;
 
 #if defined(HAVE_SYS_FANOTIFY_H)
 #include <sys/fanotify.h>
@@ -48,110 +43,84 @@
 /* Currently this is fixed in kernel... */
 #define MAX_EVENTS 16384
 
-static void setup(void);
-static void cleanup(void);
-
 #define BUF_SIZE 256
 static char fname[BUF_SIZE];
 static int fd, fd_notify;
 
 struct fanotify_event_metadata event;
 
-int main(int ac, char **av)
+void test01(void)
 {
-	int lc, i;
+	int i;
 	int len;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/*
-		 * generate events
-		 */
-		for (i = 0; i < MAX_EVENTS + 1; i++) {
-			sprintf(fname, "fname_%d", i);
-			fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0644);
-			SAFE_CLOSE(cleanup, fd);
-		}
-
-		while (1) {
-			/*
-			 * get list on events
-			 */
-			len = read(fd_notify, &event, sizeof(event));
-			if (len < 0) {
-				if (errno == -EAGAIN) {
-					tst_resm(TFAIL, "Overflow event not "
-						 "generated!\n");
-					break;
-				}
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "read of notification event failed");
-				break;
-			}
-			if (event.fd != FAN_NOFD)
-				close(event.fd);
-
-			/*
-			 * check events
-			 */
-			if (event.mask != FAN_OPEN &&
-			    event.mask != FAN_Q_OVERFLOW) {
-				tst_resm(TFAIL,
-					 "get event: mask=%llx (expected %llx)"
-					 "pid=%u fd=%d",
-					 (unsigned long long)event.mask,
-					 (unsigned long long)FAN_OPEN,
-					 (unsigned)event.pid, event.fd);
-				break;
-			}
-			if (event.mask == FAN_Q_OVERFLOW) {
-				if (event.fd != FAN_NOFD) {
-					tst_resm(TFAIL,
-						 "invalid overflow event: "
-						 "mask=%llx pid=%u fd=%d",
-						 (unsigned long long)event.mask,
-						 (unsigned)event.pid,
-						 event.fd);
-					break;
-				}
-				tst_resm(TPASS,
-					 "get event: mask=%llx pid=%u fd=%d",
-					 (unsigned long long)event.mask,
-					 (unsigned)event.pid, event.fd);
-					break;
-			}
-		}
+	/*
+	 * generate events
+	 */
+	for (i = 0; i < MAX_EVENTS + 1; i++) {
+		sprintf(fname, "fname_%d", i);
+		fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0644);
+		SAFE_CLOSE(fd);
 	}
 
-	cleanup();
-	tst_exit();
+	while (1) {
+		/*
+		 * get list on events
+		 */
+		len = read(fd_notify, &event, sizeof(event));
+		if (len < 0) {
+			if (errno == -EAGAIN) {
+				tst_res(TFAIL, "Overflow event not "
+					 "generated!\n");
+				break;
+			}
+			tst_brk(TBROK | TERRNO,
+				 "read of notification event failed");
+			break;
+		}
+		if (event.fd != FAN_NOFD)
+			close(event.fd);
+
+		/*
+		 * check events
+		 */
+		if (event.mask != FAN_OPEN &&
+		    event.mask != FAN_Q_OVERFLOW) {
+			tst_res(TFAIL,
+				 "get event: mask=%llx (expected %llx)"
+				 "pid=%u fd=%d",
+				 (unsigned long long)event.mask,
+				 (unsigned long long)FAN_OPEN,
+				 (unsigned)event.pid, event.fd);
+			break;
+		}
+		if (event.mask == FAN_Q_OVERFLOW) {
+			if (event.fd != FAN_NOFD) {
+				tst_res(TFAIL,
+					 "invalid overflow event: "
+					 "mask=%llx pid=%u fd=%d",
+					 (unsigned long long)event.mask,
+					 (unsigned)event.pid,
+					 event.fd);
+				break;
+			}
+			tst_res(TPASS,
+				 "get event: mask=%llx pid=%u fd=%d",
+				 (unsigned long long)event.mask,
+				 (unsigned)event.pid, event.fd);
+				break;
+		}
+	}
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	fd_notify = fanotify_init(FAN_CLASS_NOTIF | FAN_NONBLOCK, O_RDONLY);
-	if (fd_notify < 0) {
-		if (errno == ENOSYS) {
-			tst_brkm(TCONF, cleanup,
-				 "fanotify is not configured in this kernel.");
-		} else {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "fanotify_init failed");
-		}
-	}
+	fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF | FAN_NONBLOCK,
+			O_RDONLY);
 
 	if (fanotify_mark(fd_notify, FAN_MARK_MOUNT | FAN_MARK_ADD, FAN_OPEN,
 			    AT_FDCWD, ".") < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
+		tst_brk(TBROK | TERRNO,
 			 "fanotify_mark (%d, FAN_MARK_MOUNT | FAN_MARK_ADD, "
 			 "FAN_OPEN, AT_FDCWD, \".\") failed",
 			 fd_notify);
@@ -160,17 +129,17 @@
 
 static void cleanup(void)
 {
-	if (fd_notify > 0 && close(fd_notify))
-		tst_resm(TWARN | TERRNO, "close(%d) failed", fd_notify);
-
-	tst_rmdir();
+	if (fd_notify > 0)
+		SAFE_CLOSE(fd_notify);
 }
 
+static struct tst_test test = {
+	.test_all = test01,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+};
 #else
-
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "system doesn't have required fanotify support");
-}
-
+	TST_TEST_TCONF("system doesn't have required fanotify support");
 #endif
diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
index cc20cc1..e63e457 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify06.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
@@ -34,6 +34,7 @@
  *
  *      fanotify: fix notification of groups with inode & mount marks
  */
+#define _GNU_SOURCE
 #include "config.h"
 
 #include <stdio.h>
@@ -44,12 +45,8 @@
 #include <string.h>
 #include <sys/mount.h>
 #include <sys/syscall.h>
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
 #include "fanotify.h"
-#include "safe_macros.h"
-
-char *TCID = "fanotify06";
 
 #if defined(HAVE_SYS_FANOTIFY_H)
 #include <sys/fanotify.h>
@@ -72,8 +69,6 @@
 
 #define GROUPS_PER_PRIO 3
 
-int TST_TOTAL = GROUPS_PER_PRIO * FANOTIFY_PRIORITIES;
-
 #define BUF_SIZE 256
 static char fname[BUF_SIZE];
 static int fd;
@@ -91,26 +86,17 @@
 
 	for (p = 0; p < FANOTIFY_PRIORITIES; p++) {
 		for (i = 0; i < GROUPS_PER_PRIO; i++) {
-			fd_notify[p][i] = fanotify_init(fanotify_prio[p] |
+			fd_notify[p][i] = SAFE_FANOTIFY_INIT(fanotify_prio[p] |
 							FAN_NONBLOCK,
 							O_RDONLY);
-			if (fd_notify[p][i] < 0) {
-				if (errno == ENOSYS) {
-					tst_brkm(TCONF, cleanup,
-						 "fanotify is not configured in"
-						 " this kernel.");
-				} else {
-					tst_brkm(TBROK | TERRNO, cleanup,
-						 "fanotify_init failed");
-				}
-			}
+
 			/* Add mount mark for each group */
 			ret = fanotify_mark(fd_notify[p][i],
 					    FAN_MARK_ADD | FAN_MARK_MOUNT,
 					    FAN_MODIFY,
 					    AT_FDCWD, ".");
 			if (ret < 0) {
-				tst_brkm(TBROK | TERRNO, cleanup,
+				tst_brk(TBROK | TERRNO,
 					 "fanotify_mark(%d, FAN_MARK_ADD | "
 					 "FAN_MARK_MOUNT, FAN_MODIFY, AT_FDCWD,"
 					 " '.') failed", fd_notify[p][i]);
@@ -124,7 +110,7 @@
 					    FAN_MARK_IGNORED_SURV_MODIFY,
 					    FAN_MODIFY, AT_FDCWD, fname);
 			if (ret < 0) {
-				tst_brkm(TBROK | TERRNO, cleanup,
+				tst_brk(TBROK | TERRNO,
 					 "fanotify_mark(%d, FAN_MARK_ADD | "
 					 "FAN_MARK_IGNORED_MASK | "
 					 "FAN_MARK_IGNORED_SURV_MODIFY, "
@@ -143,7 +129,7 @@
 		for (i = 0; i < GROUPS_PER_PRIO; i++) {
 			if (fd_notify[p][i] && fd_notify[p][i] != -1) {
 				if (close(fd_notify[p][i]) == -1)
-					tst_resm(TWARN, "close(%d) failed",
+					tst_res(TWARN, "close(%d) failed",
 						 fd_notify[p][i]);
 				fd_notify[p][i] = 0;
 			}
@@ -154,135 +140,117 @@
 static void verify_event(int group, struct fanotify_event_metadata *event)
 {
 	if (event->mask != FAN_MODIFY) {
-		tst_resm(TFAIL, "group %d get event: mask %llx (expected %llx) "
+		tst_res(TFAIL, "group %d get event: mask %llx (expected %llx) "
 			 "pid=%u fd=%u", group, (unsigned long long)event->mask,
 			 (unsigned long long)FAN_MODIFY,
 			 (unsigned)event->pid, event->fd);
 	} else if (event->pid != getpid()) {
-		tst_resm(TFAIL, "group %d get event: mask %llx pid=%u "
+		tst_res(TFAIL, "group %d get event: mask %llx pid=%u "
 			 "(expected %u) fd=%u", group,
 			 (unsigned long long)event->mask, (unsigned)event->pid,
 			 (unsigned)getpid(), event->fd);
 	} else {
-		tst_resm(TPASS, "group %d get event: mask %llx pid=%u fd=%u",
+		tst_res(TPASS, "group %d get event: mask %llx pid=%u fd=%u",
 			 group, (unsigned long long)event->mask,
 			 (unsigned)event->pid, event->fd);
 	}
 }
 
-int main(int ac, char **av)
+void test01(void)
 {
-	int lc;
+	int ret;
+	unsigned int p, i;
+	struct fanotify_event_metadata *event;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	create_fanotify_groups();
 
-	setup();
+	/*
+	 * generate sequence of events
+	 */
+	fd = SAFE_OPEN(fname, O_RDWR);
+	SAFE_WRITE(1, fd, fname, strlen(fname));
+	SAFE_CLOSE(fd);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int ret;
-		unsigned int p, i;
-		struct fanotify_event_metadata *event;
-
-		create_fanotify_groups();
-
-		/*
-		 * generate sequence of events
-		 */
-		fd = SAFE_OPEN(cleanup, fname, O_RDWR);
-		SAFE_WRITE(cleanup, 1, fd, fname, strlen(fname));
-		SAFE_CLOSE(cleanup, fd);
-
-		/* First verify all groups without ignore mask got the event */
-		for (i = 0; i < GROUPS_PER_PRIO; i++) {
-			ret = read(fd_notify[0][i], event_buf, EVENT_BUF_LEN);
-			if (ret < 0) {
-				if (errno == EAGAIN) {
-					tst_resm(TFAIL, "group %d did not get "
-						 "event", i);
-				}
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "reading fanotify events failed");
+	/* First verify all groups without ignore mask got the event */
+	for (i = 0; i < GROUPS_PER_PRIO; i++) {
+		ret = read(fd_notify[0][i], event_buf, EVENT_BUF_LEN);
+		if (ret < 0) {
+			if (errno == EAGAIN) {
+				tst_res(TFAIL, "group %d did not get "
+					 "event", i);
 			}
-			if (ret < (int)FAN_EVENT_METADATA_LEN) {
-				tst_brkm(TBROK, cleanup,
-					 "short read when reading fanotify "
-					 "events (%d < %d)", ret,
-					 (int)EVENT_BUF_LEN);
-			}
-			event = (struct fanotify_event_metadata *)event_buf;
-			if (ret > (int)event->event_len) {
-				tst_resm(TFAIL, "group %d got more than one "
-					 "event (%d > %d)", i, ret,
-					 event->event_len);
-			} else
-				verify_event(i, event);
-			close(event->fd);
+			tst_brk(TBROK | TERRNO,
+				 "reading fanotify events failed");
 		}
-		for (p = 1; p < FANOTIFY_PRIORITIES; p++) {
-			for (i = 0; i < GROUPS_PER_PRIO; i++) {
-				ret = read(fd_notify[p][i], event_buf, EVENT_BUF_LEN);
-				if (ret > 0) {
-					tst_resm(TFAIL, "group %d got event",
-						 p*GROUPS_PER_PRIO + i);
-				} else if (ret == 0) {
-					tst_brkm(TBROK, cleanup, "zero length "
-						 "read from fanotify fd");
-				} else if (errno != EAGAIN) {
-					tst_brkm(TBROK | TERRNO, cleanup,
-						 "reading fanotify events failed");
-				} else {
-					tst_resm(TPASS, "group %d got no event",
-						 p*GROUPS_PER_PRIO + i);
-				}
-			}
+		if (ret < (int)FAN_EVENT_METADATA_LEN) {
+			tst_brk(TBROK,
+				 "short read when reading fanotify "
+				 "events (%d < %d)", ret,
+				 (int)EVENT_BUF_LEN);
 		}
-		cleanup_fanotify_groups();
+		event = (struct fanotify_event_metadata *)event_buf;
+		if (ret > (int)event->event_len) {
+			tst_res(TFAIL, "group %d got more than one "
+				 "event (%d > %d)", i, ret,
+				 event->event_len);
+		} else
+			verify_event(i, event);
+		close(event->fd);
 	}
-
-	cleanup();
-	tst_exit();
+	for (p = 1; p < FANOTIFY_PRIORITIES; p++) {
+		for (i = 0; i < GROUPS_PER_PRIO; i++) {
+			ret = read(fd_notify[p][i], event_buf, EVENT_BUF_LEN);
+			if (ret > 0) {
+				tst_res(TFAIL, "group %d got event",
+					 p*GROUPS_PER_PRIO + i);
+			} else if (ret == 0) {
+				tst_brk(TBROK, "zero length "
+					 "read from fanotify fd");
+			} else if (errno != EAGAIN) {
+				tst_brk(TBROK | TERRNO,
+					 "reading fanotify events failed");
+			} else {
+				tst_res(TPASS, "group %d got no event",
+					 p*GROUPS_PER_PRIO + i);
+			}
+		}
+	}
+	cleanup_fanotify_groups();
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_require_root();
-	tst_tmpdir();
-
-	SAFE_MKDIR(cleanup, MOUNT_NAME, 0755);
-	SAFE_MOUNT(cleanup, MOUNT_NAME, MOUNT_NAME, NULL, MS_BIND, NULL);
+	SAFE_MKDIR(MOUNT_NAME, 0755);
+	SAFE_MOUNT(MOUNT_NAME, MOUNT_NAME, NULL, MS_BIND, NULL);
 	mount_created = 1;
-	SAFE_CHDIR(cleanup, MOUNT_NAME);
+	SAFE_CHDIR(MOUNT_NAME);
 
 	sprintf(fname, "tfile_%d", getpid());
-	fd = SAFE_OPEN(cleanup, fname, O_RDWR | O_CREAT, 0700);
-	SAFE_WRITE(cleanup, 1, fd, fname, 1);
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
+	SAFE_WRITE(1, fd, fname, 1);
 
 	/* close the file we have open */
-	SAFE_CLOSE(cleanup, fd);
+	SAFE_CLOSE(fd);
 }
 
 static void cleanup(void)
 {
 	cleanup_fanotify_groups();
 
-	if (chdir(tst_get_tmpdir()) < 0)
-		tst_brkm(TBROK, NULL, "chdir(tmpdir) failed");
+	SAFE_CHDIR("../");
 
 	if (mount_created && tst_umount(MOUNT_NAME) < 0)
-		tst_brkm(TBROK | TERRNO, NULL, "umount failed");
-
-	tst_rmdir();
+		tst_brk(TBROK | TERRNO, "umount failed");
 }
 
+static struct tst_test test = {
+	.test_all = test01,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.needs_root = 1
+};
+
 #else
-
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "system doesn't have required fanotify support");
-}
-
+	TST_TEST_TCONF("system doesn't have required fanotify support");
 #endif
diff --git a/testcases/kernel/syscalls/fanotify/fanotify07.c b/testcases/kernel/syscalls/fanotify/fanotify07.c
new file mode 100644
index 0000000..af95c39
--- /dev/null
+++ b/testcases/kernel/syscalls/fanotify/fanotify07.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2017 SUSE.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 or any later of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Started by Jan Kara <jack@suse.cz>
+ *
+ * DESCRIPTION
+ *     Check that fanotify permission events are handled properly on instance
+ *     destruction.
+ *
+ * Kernel crashes should be fixed by:
+ *  96d41019e3ac "fanotify: fix list corruption in fanotify_get_response()"
+ *
+ * Kernel hangs should be fixed by:
+ *  05f0e38724e8 "fanotify: Release SRCU lock when waiting for userspace response"
+ */
+#define _GNU_SOURCE
+#include "config.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/syscall.h>
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+#include "fanotify.h"
+
+#if defined(HAVE_SYS_FANOTIFY_H)
+#include <sys/fanotify.h>
+
+#define BUF_SIZE 256
+static char fname[BUF_SIZE];
+static char buf[BUF_SIZE];
+static volatile int fd_notify;
+
+/* Number of children we start */
+#define MAX_CHILDREN 16
+static pid_t child_pid[MAX_CHILDREN];
+
+/* Number of children we don't respond to before stopping */
+#define MAX_NOT_RESPONDED 4
+
+static void generate_events(void)
+{
+	int fd;
+
+	/*
+	 * generate sequence of events
+	 */
+	if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1)
+		exit(1);
+
+	/* Run until killed... */
+	while (1) {
+		lseek(fd, 0, SEEK_SET);
+		if (read(fd, buf, BUF_SIZE) == -1)
+			exit(3);
+	}
+}
+
+static void run_children(void)
+{
+	int i;
+
+	for (i = 0; i < MAX_CHILDREN; i++) {
+		child_pid[i] = SAFE_FORK();
+		if (!child_pid[i]) {
+			/* Child will generate events now */
+			close(fd_notify);
+			generate_events();
+			exit(0);
+		}
+	}
+}
+
+static int stop_children(void)
+{
+	int child_ret;
+	int i, ret = 0;
+
+	for (i = 0; i < MAX_CHILDREN; i++)
+		SAFE_KILL(child_pid[i], SIGKILL);
+
+	for (i = 0; i < MAX_CHILDREN; i++) {
+		SAFE_WAITPID(child_pid[i], &child_ret, 0);
+		if (!WIFSIGNALED(child_ret))
+			ret = 1;
+	}
+
+	return ret;
+}
+
+static int setup_instance(void)
+{
+	int fd;
+
+	fd = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY);
+
+	if (fanotify_mark(fd, FAN_MARK_ADD, FAN_ACCESS_PERM, AT_FDCWD,
+			  fname) < 0) {
+		close(fd);
+		if (errno == EINVAL) {
+			tst_brk(TCONF | TERRNO,
+				"CONFIG_FANOTIFY_ACCESS_PERMISSIONS not "
+				"configured in kernel?");
+		} else {
+			tst_brk(TBROK | TERRNO,
+				"fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS_PERM, "
+				"AT_FDCWD, %s) failed.", fd, fname);
+		}
+	}
+
+	return fd;
+}
+
+static void loose_fanotify_events(void)
+{
+	int not_responded = 0;
+
+	/*
+	 * check events
+	 */
+	while (not_responded < MAX_NOT_RESPONDED) {
+		struct fanotify_event_metadata event;
+		struct fanotify_response resp;
+
+		/* Get more events */
+		SAFE_READ(1, fd_notify, &event, sizeof(event));
+
+		if (event.mask != FAN_ACCESS_PERM) {
+			tst_res(TFAIL,
+				"get event: mask=%llx (expected %llx) "
+				"pid=%u fd=%u",
+				(unsigned long long)event.mask,
+				(unsigned long long)FAN_ACCESS_PERM,
+				(unsigned)event.pid, event.fd);
+			break;
+		}
+
+		/*
+		 * We respond to permission event with 95% percent
+		 * probability. */
+		if (random() % 100 > 5) {
+			/* Write response to permission event */
+			resp.fd = event.fd;
+			resp.response = FAN_ALLOW;
+			SAFE_WRITE(1, fd_notify, &resp, sizeof(resp));
+		} else {
+			not_responded++;
+		}
+		SAFE_CLOSE(event.fd);
+	}
+}
+
+static void test_fanotify(void)
+{
+	int newfd;
+	int ret;
+
+	fd_notify = setup_instance();
+	run_children();
+	loose_fanotify_events();
+
+	/*
+	 * Create and destroy another instance. This may hang if
+	 * unanswered fanotify events block notification subsystem.
+	 */
+	newfd = setup_instance();
+	if (close(newfd)) {
+		tst_brk(TBROK | TERRNO, "close(%d) failed", newfd);
+	}
+
+	tst_res(TPASS, "second instance destroyed successfully");
+
+	/*
+	 * Now destroy the fanotify instance while there are permission
+	 * events at various stages of processing. This may provoke
+	 * kernel hangs or crashes.
+	 */
+	SAFE_CLOSE(fd_notify);
+
+	ret = stop_children();
+	if (ret)
+		tst_res(TFAIL, "child exited for unexpected reason");
+	else
+		tst_res(TPASS, "all children exited successfully");
+}
+
+static void setup(void)
+{
+	sprintf(fname, "fname_%d", getpid());
+	SAFE_FILE_PRINTF(fname, "%s", fname);
+}
+
+static void cleanup(void)
+{
+	if (fd_notify > 0)
+		SAFE_CLOSE(fd_notify);
+}
+
+static struct tst_test test = {
+	.test_all = test_fanotify,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.forks_child = 1,
+	.needs_root = 1,
+};
+
+#else
+	TST_TEST_TCONF("system doesn't have required fanotify support");
+#endif
diff --git a/testcases/kernel/syscalls/fanotify/fanotify08.c b/testcases/kernel/syscalls/fanotify/fanotify08.c
new file mode 100644
index 0000000..dc916ec
--- /dev/null
+++ b/testcases/kernel/syscalls/fanotify/fanotify08.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017 RedHat.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Started by Xiong Zhou <xzhou@redhat.com>
+ *
+ * DESCRIPTION
+ *     Sanity check fanotify_init flag FAN_CLOEXEC by fcntl.
+ */
+#define _GNU_SOURCE
+#include "config.h"
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include "tst_test.h"
+#include "fanotify.h"
+
+#if defined(HAVE_SYS_FANOTIFY_H)
+#include <sys/fanotify.h>
+
+static int fd_notify;
+
+static void test_init_bit(unsigned int fan_bit,
+			unsigned int fd_bit, char *msg)
+{
+	int ret;
+
+	fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF|fan_bit, O_RDONLY);
+
+	ret = SAFE_FCNTL(fd_notify, F_GETFD);
+
+	if ((ret & FD_CLOEXEC) == fd_bit) {
+		tst_res(TPASS, msg);
+	} else {
+		tst_res(TFAIL, msg);
+	}
+
+	SAFE_CLOSE(fd_notify);
+}
+
+static void run(unsigned int i)
+{
+	switch (i) {
+	case 0:
+		test_init_bit(0, 0, "not set close_on_exec");
+		break;
+	case 1:
+		test_init_bit(FAN_CLOEXEC, FD_CLOEXEC, "set close_on_exec");
+		break;
+	}
+}
+
+static void cleanup(void)
+{
+	if (fd_notify > 0)
+		SAFE_CLOSE(fd_notify);
+}
+
+static struct tst_test test = {
+	.test = run,
+	.tcnt = 2,
+	.cleanup = cleanup,
+	.needs_root = 1,
+};
+
+#else
+	TST_TEST_TCONF("system doesn't have required fanotify support");
+#endif
diff --git a/testcases/kernel/syscalls/fchdir/fchdir03.c b/testcases/kernel/syscalls/fchdir/fchdir03.c
index a7c32c4..59685f8 100644
--- a/testcases/kernel/syscalls/fchdir/fchdir03.c
+++ b/testcases/kernel/syscalls/fchdir/fchdir03.c
@@ -1,27 +1,24 @@
 /*
- *
  * Copyright (C) Bull S.A. 2001
  * Copyright (c) International Business Machines  Corp., 2001
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
  *
- *   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 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.
+ * 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
+ * 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
  */
 
 /*
- * NAME
- *	fchdir03
- *
  * DESCRIPTION
  *	Testcase for testing that fchdir(2) sets EACCES errno
  *
@@ -31,147 +28,47 @@
  *	3.	this child opens the directory and gets a file descriptor
  *	4.	this child attempts to fchdir(2) to the directory created in 2.
  *		and expects to get an EACCES.
- *	5.	finally this child checks the return code,
- *		resets the process ID to root and calls cleanup.
- *
- * USAGE:  <for command-line>
- *  fchdir03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * HISTORY
- *	04/2002 Ported by Jacky Malcles
- *
- * RESTRICTIONS
- *	This test must be run as root.
  */
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <pwd.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
+#include "tst_test.h"
 
-#include "test.h"
-#include "safe_macros.h"
+#define DIRNAME "fchdir03_dir"
 
-char *TCID = "fchdir03";
-int TST_TOTAL = 1;
+static int fd;
 
-void setup(void);
-void cleanup(void);
-
-char good_dir[100];
-int fd;
-
-static uid_t nobody_uid;
-
-int main(int ac, char **av)
+void verify_fchdir(void)
 {
-	int lc;
+	TEST(fchdir(fd));
 
-	pid_t pid;
-	int status;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		if ((pid = FORK_OR_VFORK()) == -1)
-			tst_brkm(TBROK, cleanup, "fork failed");
-
-		if (pid == 0) {
-			/*
-			 * set the child's ID to ltpuser1 using seteuid()
-			 * so that the ID can be changed back after the
-			 * TEST call is made.
-			 */
-			if (seteuid(nobody_uid) != 0) {
-				perror("setreuid failed in child #1");
-				exit(1);
-			}
-			if (mkdir(good_dir, 00400) != 0) {
-				perror("mkdir failed in child #1");
-				exit(1);
-			}
-			if ((fd = open(good_dir, O_RDONLY)) == -1) {
-				perror("opening directory failed");
-			}
-
-			TEST(fchdir(fd));
-
-			if (TEST_RETURN != -1) {
-				printf("Call succeeded unexpectedly\n");
-				exit(1);
-			} else if (TEST_ERRNO != EACCES) {
-				printf("Expected %d - got %d\n",
-				       EACCES, TEST_ERRNO);
-				exit(1);
-			} else
-				printf("Got EACCES as expected\n");
-
-			/* reset the UID to root */
-			if (setuid(0) == -1)
-				perror("setuid(0) failed");
-
-		} else {
-			if (wait(&status) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "wait failed");
-			else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
-				tst_brkm(TBROK, cleanup,
-					 "child exited abnormally (wait status = "
-					 "%d", status);
-			else {
-				/* let the child carry on */
-				exit(0);
-			}
-		}
-
-		if (rmdir(good_dir) == -1)
-			tst_brkm(TBROK, cleanup, "rmdir failed");
-
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "fchdir() succeeded unexpectedly");
+		return;
 	}
-	cleanup();
 
-	tst_exit();
+	if (TEST_ERRNO != EACCES) {
+		tst_res(TFAIL | TTERRNO, "fchdir() should fail with EACCES");
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "fchdir() failed expectedly");
 }
 
 void setup(void)
 {
 	struct passwd *pw;
 
-	char *cur_dir = NULL;
+	pw = SAFE_GETPWNAM("nobody");
+	SAFE_SETEUID(pw->pw_uid);
+	SAFE_MKDIR(DIRNAME, 0400);
 
-	tst_require_root();
-
-	pw = SAFE_GETPWNAM(NULL, "nobody");
-	nobody_uid = pw->pw_uid;
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	if ((cur_dir = getcwd(cur_dir, 0)) == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "getcwd failed");
-
-	sprintf(good_dir, "%s.%d", cur_dir, getpid());
+	fd = SAFE_OPEN(DIRNAME, O_RDONLY);
 }
 
-void cleanup(void)
-{
-	tst_rmdir();
-}
+static struct tst_test test = {
+	.setup = setup,
+	.test_all = verify_fchdir,
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+};
diff --git a/testcases/kernel/syscalls/fchmodat/fchmodat01.c b/testcases/kernel/syscalls/fchmodat/fchmodat01.c
index 6bf66d8..369f80e 100644
--- a/testcases/kernel/syscalls/fchmodat/fchmodat01.c
+++ b/testcases/kernel/syscalls/fchmodat/fchmodat01.c
@@ -43,7 +43,7 @@
 #include <signal.h>
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TEST_CASES 6
 #ifndef AT_FDCWD
@@ -127,8 +127,8 @@
 	fds[0] = SAFE_OPEN(cleanup, pathname, O_DIRECTORY);
 	fds[1] = fds[4] = fds[0];
 
-	SAFE_FILE_PRINTF(cleanup, testfile, testfile);
-	SAFE_FILE_PRINTF(cleanup, testfile2, testfile2);
+	SAFE_FILE_PRINTF(cleanup, testfile, "%s", testfile);
+	SAFE_FILE_PRINTF(cleanup, testfile2, "%s", testfile2);
 
 	fds[2] = SAFE_OPEN(cleanup, testfile3, O_CREAT | O_RDWR, 0600);
 	fds[3] = 100;
diff --git a/testcases/kernel/syscalls/fchownat/fchownat.h b/testcases/kernel/syscalls/fchownat/fchownat.h
index 9040544..a95c26f 100644
--- a/testcases/kernel/syscalls/fchownat/fchownat.h
+++ b/testcases/kernel/syscalls/fchownat/fchownat.h
@@ -22,7 +22,7 @@
 
 #include <sys/types.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 
 #if !defined(HAVE_FCHOWNAT)
diff --git a/testcases/kernel/syscalls/fcntl/Makefile b/testcases/kernel/syscalls/fcntl/Makefile
index d78dd72..ae37214 100644
--- a/testcases/kernel/syscalls/fcntl/Makefile
+++ b/testcases/kernel/syscalls/fcntl/Makefile
@@ -24,6 +24,9 @@
 fcntl34: LDLIBS += -lpthread
 fcntl34_64: LDLIBS += -lpthread
 
+fcntl36: LDLIBS += -lpthread
+fcntl36_64: LDLIBS += -lpthread
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../utils/newer_64.mk
 
diff --git a/testcases/kernel/syscalls/fcntl/fcntl02.c b/testcases/kernel/syscalls/fcntl/fcntl02.c
index cffa921..d7a6c19 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl02.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl02.c
@@ -85,7 +85,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "fcntl02",
 	.needs_tmpdir = 1,
 	.test = verify_fcntl,
 	.tcnt = ARRAY_SIZE(min_fds),
diff --git a/testcases/kernel/syscalls/fcntl/fcntl03.c b/testcases/kernel/syscalls/fcntl/fcntl03.c
index cf2f8cf..fe1d112 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl03.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl03.c
@@ -74,7 +74,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "fcntl03",
 	.needs_tmpdir = 1,
 	.test_all = verify_fcntl,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/fcntl/fcntl04.c b/testcases/kernel/syscalls/fcntl/fcntl04.c
index cddc6c3..c00677c 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl04.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl04.c
@@ -80,7 +80,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "fcntl04",
 	.needs_tmpdir = 1,
 	.test_all = verify_fcntl,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/fcntl/fcntl31.c b/testcases/kernel/syscalls/fcntl/fcntl31.c
index 804d0ab..52b4932 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl31.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl31.c
@@ -35,7 +35,7 @@
 
 #include "test.h"
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 #include "lapi/fcntl.h"
 
diff --git a/testcases/kernel/syscalls/fcntl/fcntl34.c b/testcases/kernel/syscalls/fcntl/fcntl34.c
index 6b84249..c778db0 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl34.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl34.c
@@ -143,7 +143,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "fcntl34",
 	.min_kver = "3.15.0",
 	.needs_tmpdir = 1,
 	.test_all = test01,
diff --git a/testcases/kernel/syscalls/fcntl/fcntl35.c b/testcases/kernel/syscalls/fcntl/fcntl35.c
new file mode 100644
index 0000000..675da71
--- /dev/null
+++ b/testcases/kernel/syscalls/fcntl/fcntl35.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2017 Fujitsu Ltd.
+ * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.*
+ */
+
+/*
+ * Description:
+ * fcntl(2) manpage states that an unprivileged user could not set the
+ * pipe capacity above the limit in /proc/sys/fs/pipe-max-size.  However,
+ * an unprivileged user could create a pipe whose initial capacity exceeds
+ * the limit.  We add a regression test to check that pipe-max-size caps
+ * the initial allocation for a new pipe for unprivileged users, but not
+ * for privileged users.
+ *
+ * This kernel bug has been fixed by:
+ *
+ * commit 086e774a57fba4695f14383c0818994c0b31da7c
+ * Author: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
+ * Date:   Tue Oct 11 13:53:43 2016 -0700
+ *
+ * pipe: cap initial pipe capacity according to pipe-max-size limit
+ */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+
+#include "lapi/fcntl.h"
+#include "tst_test.h"
+
+static int pipe_max_unpriv;
+static int test_max_unpriv;
+static int test_max_priv;
+static struct passwd *pw;
+static struct tcase {
+	int *exp_sz;
+	int exp_usr;
+	char *des;
+} tcases[] = {
+	{&test_max_unpriv, 1, "an unprivileged user"},
+	{&test_max_priv, 0, "a privileged user"}
+};
+
+static void setup(void)
+{
+	test_max_unpriv = getpagesize();
+	test_max_priv = test_max_unpriv * 16;
+
+	if (!access("/proc/sys/fs/pipe-max-size", F_OK)) {
+		SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
+				&pipe_max_unpriv);
+		SAFE_FILE_PRINTF("/proc/sys/fs/pipe-max-size", "%d",
+				test_max_unpriv);
+	} else {
+		tst_brk(TCONF, "/proc/sys/fs/pipe-max-size doesn't exist");
+	}
+
+	pw = SAFE_GETPWNAM("nobody");
+}
+
+static void cleanup(void)
+{
+	SAFE_FILE_PRINTF("/proc/sys/fs/pipe-max-size", "%d", pipe_max_unpriv);
+}
+
+static int verify_pipe_size(int exp_pip_sz, char *desp)
+{
+	int get_size;
+	int fds[2];
+
+	SAFE_PIPE(fds);
+
+	get_size = fcntl(fds[1], F_GETPIPE_SZ);
+	if (get_size == -1) {
+		tst_res(TFAIL | TERRNO, "fcntl(2) with F_GETPIPE_SZ failed");
+		goto end;
+	}
+
+	if (get_size != exp_pip_sz) {
+		tst_res(TFAIL, "%s init the capacity of a pipe to %d "
+			"unexpectedly, expected %d", desp, get_size,
+			exp_pip_sz);
+	} else {
+		tst_res(TPASS, "%s init the capacity of a pipe to %d "
+			"successfully", desp, exp_pip_sz);
+	}
+
+end:
+	if (fds[0] > 0)
+		SAFE_CLOSE(fds[0]);
+
+	if (fds[1] > 0)
+		SAFE_CLOSE(fds[1]);
+
+	exit(0);
+}
+
+static void do_test(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	if (!SAFE_FORK()) {
+		if (tc->exp_usr)
+			SAFE_SETUID(pw->pw_uid);
+
+		verify_pipe_size(*tc->exp_sz, tc->des);
+	}
+
+	tst_reap_children();
+}
+
+static struct tst_test test = {
+	.min_kver = "2.6.35",
+	.needs_root = 1,
+	.forks_child = 1,
+	.tcnt = ARRAY_SIZE(tcases),
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = do_test
+};
diff --git a/testcases/kernel/syscalls/fcntl/fcntl36.c b/testcases/kernel/syscalls/fcntl/fcntl36.c
new file mode 100644
index 0000000..6f2eb6b
--- /dev/null
+++ b/testcases/kernel/syscalls/fcntl/fcntl36.c
@@ -0,0 +1,410 @@
+/*
+ * Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
+ *
+ * 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 would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Xiong Zhou <xzhou@redhat.com>
+ *
+ * This is testing OFD locks racing with POSIX locks:
+ *
+ *	OFD read  lock   vs   OFD   write lock
+ *	OFD read  lock   vs   POSIX write lock
+ *	OFD write lock   vs   POSIX write lock
+ *	OFD write lock   vs   POSIX read  lock
+ *	OFD write lock   vs   OFD   write lock
+ *
+ *	OFD   r/w locks vs POSIX write locks
+ *	OFD   r/w locks vs POSIX read locks
+ *
+ * For example:
+ *
+ *	Init an file with preset values.
+ *
+ *	Threads acquire OFD READ  locks to read  a 4k section start from 0;
+ *		checking data read back, there should not be any surprise
+ *		values and data should be consistent in a 1k block.
+ *
+ *	Threads acquire OFD WRITE locks to write a 4k section start from 1k,
+ *		writing different values in different threads.
+ *
+ *	Check file data after racing, there should not be any surprise values
+ *		and data should be consistent in a 1k block.
+ *
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sched.h>
+#include <errno.h>
+
+#include "lapi/fcntl.h"
+#include "tst_safe_pthread.h"
+#include "tst_test.h"
+
+static int thread_cnt;
+static int fail_flag = 0;
+static volatile int loop_flag = 1;
+static const int max_thread_cnt = 32;
+static const char fname[] = "tst_ofd_posix_locks";
+static const long write_size = 4096;
+static pthread_barrier_t barrier;
+
+struct param {
+	long offset;
+	long length;
+	long cnt;
+};
+
+static void setup(void)
+{
+	thread_cnt = tst_ncpus_conf() * 3;
+	if (thread_cnt > max_thread_cnt)
+		thread_cnt = max_thread_cnt;
+}
+
+/* OFD write lock writing data*/
+static void *fn_ofd_w(void *arg)
+{
+	struct param *pa = arg;
+	unsigned char buf[pa->length];
+	int fd = SAFE_OPEN(fname, O_RDWR);
+	long wt = pa->cnt;
+
+	struct flock64 lck = {
+		.l_whence = SEEK_SET,
+		.l_start  = pa->offset,
+		.l_len    = pa->length,
+		.l_pid    = 0,
+	};
+
+	while (loop_flag) {
+
+		memset(buf, wt, pa->length);
+
+		lck.l_type = F_WRLCK;
+		SAFE_FCNTL(fd, F_OFD_SETLKW, &lck);
+
+		SAFE_LSEEK(fd, pa->offset, SEEK_SET);
+		SAFE_WRITE(1, fd, buf, pa->length);
+
+		lck.l_type = F_UNLCK;
+		SAFE_FCNTL(fd, F_OFD_SETLKW, &lck);
+
+		wt++;
+		if (wt >= 255)
+			wt = pa->cnt;
+
+		sched_yield();
+	}
+
+	pthread_barrier_wait(&barrier);
+	SAFE_CLOSE(fd);
+	return NULL;
+}
+
+/* POSIX write lock writing data*/
+static void *fn_posix_w(void *arg)
+{
+	struct param *pa = arg;
+	unsigned char buf[pa->length];
+	int fd = SAFE_OPEN(fname, O_RDWR);
+	long wt = pa->cnt;
+
+	struct flock64 lck = {
+		.l_whence = SEEK_SET,
+		.l_start  = pa->offset,
+		.l_len    = pa->length,
+	};
+
+	while (loop_flag) {
+
+		memset(buf, wt, pa->length);
+
+		lck.l_type = F_WRLCK;
+		SAFE_FCNTL(fd, F_SETLKW, &lck);
+
+		SAFE_LSEEK(fd, pa->offset, SEEK_SET);
+		SAFE_WRITE(1, fd, buf, pa->length);
+
+		lck.l_type = F_UNLCK;
+		SAFE_FCNTL(fd, F_SETLKW, &lck);
+
+		wt++;
+		if (wt >= 255)
+			wt = pa->cnt;
+
+		sched_yield();
+	}
+
+	pthread_barrier_wait(&barrier);
+	SAFE_CLOSE(fd);
+	return NULL;
+}
+
+/* OFD read lock reading data*/
+static void *fn_ofd_r(void *arg)
+{
+	struct param *pa = arg;
+	unsigned char buf[pa->length];
+	int i;
+	int fd = SAFE_OPEN(fname, O_RDWR);
+
+	struct flock64 lck = {
+		.l_whence = SEEK_SET,
+		.l_start  = pa->offset,
+		.l_len    = pa->length,
+		.l_pid    = 0,
+	};
+
+	while (loop_flag) {
+
+		memset(buf, 0, pa->length);
+
+		lck.l_type = F_RDLCK;
+		SAFE_FCNTL(fd, F_OFD_SETLKW, &lck);
+
+		/* rlock acquired */
+		SAFE_LSEEK(fd, pa->offset, SEEK_SET);
+		SAFE_READ(1, fd, buf, pa->length);
+
+		/* Verifying data read */
+		for (i = 0; i < pa->length; i++) {
+
+			if (buf[i] < 1 || buf[i] > 254) {
+
+				tst_res(TFAIL, "Unexpected data "
+					"offset %ld value %d",
+					pa->offset + i, buf[i]);
+				fail_flag = 1;
+				break;
+			}
+
+			int j = (i / (pa->length/4)) * pa->length/4;
+
+			if (buf[i] != buf[j]) {
+
+				tst_res(TFAIL, "Unexpected data "
+					"offset %ld value %d",
+					pa->offset + i, buf[i]);
+				fail_flag = 1;
+				break;
+			}
+		}
+
+		lck.l_type = F_UNLCK;
+		SAFE_FCNTL(fd, F_OFD_SETLK, &lck);
+
+		sched_yield();
+	}
+
+	pthread_barrier_wait(&barrier);
+	SAFE_CLOSE(fd);
+	return NULL;
+}
+
+/* POSIX read lock reading data */
+static void *fn_posix_r(void *arg)
+{
+	struct param *pa = arg;
+	unsigned char buf[pa->length];
+	int i;
+	int fd = SAFE_OPEN(fname, O_RDWR);
+
+	struct flock64 lck = {
+		.l_whence = SEEK_SET,
+		.l_start  = pa->offset,
+		.l_len    = pa->length,
+	};
+
+	while (loop_flag) {
+
+		memset(buf, 0, pa->length);
+
+		lck.l_type = F_RDLCK;
+		SAFE_FCNTL(fd, F_SETLKW, &lck);
+
+		/* rlock acquired */
+		SAFE_LSEEK(fd, pa->offset, SEEK_SET);
+		SAFE_READ(1, fd, buf, pa->length);
+
+		/* Verifying data read */
+		for (i = 0; i < pa->length; i++) {
+
+			if (buf[i] < 1 || buf[i] > 254) {
+
+				tst_res(TFAIL, "Unexpected data "
+					"offset %ld value %d",
+					pa->offset + i, buf[i]);
+				fail_flag = 1;
+				break;
+			}
+
+			int j = (i / (pa->length/4)) * pa->length/4;
+
+			if (buf[i] != buf[j]) {
+
+				tst_res(TFAIL, "Unexpected data "
+					"offset %ld value %d",
+					pa->offset + i, buf[i]);
+				fail_flag = 1;
+				break;
+			}
+		}
+
+		lck.l_type = F_UNLCK;
+		SAFE_FCNTL(fd, F_SETLK, &lck);
+
+		sched_yield();
+	}
+
+	pthread_barrier_wait(&barrier);
+	SAFE_CLOSE(fd);
+	return NULL;
+}
+
+static void *fn_dummy(void *arg)
+{
+	arg = NULL;
+
+	pthread_barrier_wait(&barrier);
+	return arg;
+}
+
+/* Test different functions and verify data */
+static void test_fn(void *f0(void *), void *f1(void *),
+		    void *f2(void *), const char *msg)
+{
+	int i, k, fd;
+	pthread_t id0[thread_cnt];
+	pthread_t id1[thread_cnt];
+	pthread_t id2[thread_cnt];
+	struct param p0[thread_cnt];
+	struct param p1[thread_cnt];
+	struct param p2[thread_cnt];
+	unsigned char buf[write_size];
+
+	tst_res(TINFO, msg);
+
+	if (tst_fill_file(fname, 1, write_size, thread_cnt + 1))
+		tst_brk(TBROK, "Failed to create tst file");
+
+	if (pthread_barrier_init(&barrier, NULL, thread_cnt*3) != 0)
+		tst_brk(TBROK, "Failed to init pthread barrier");
+
+	for (i = 0; i < thread_cnt; i++) {
+
+		p0[i].offset = i * write_size;
+		p0[i].length = write_size;
+		p0[i].cnt = i + 2;
+
+		p1[i].offset = i * write_size + write_size / 4;
+		p1[i].length = write_size;
+		p1[i].cnt = i + 2;
+
+		p2[i].offset = i * write_size + write_size / 2;
+		p2[i].length = write_size;
+		p2[i].cnt = i + 2;
+	}
+
+	fail_flag = 0;
+	loop_flag = 1;
+
+	for (i = 0; i < thread_cnt; i++) {
+
+		SAFE_PTHREAD_CREATE(id0 + i, NULL, f0, (void *)&p0[i]);
+		SAFE_PTHREAD_CREATE(id1 + i, NULL, f1, (void *)&p1[i]);
+		SAFE_PTHREAD_CREATE(id2 + i, NULL, f2, (void *)&p2[i]);
+	}
+
+	sleep(1);
+	loop_flag = 0;
+
+	for (i = 0; i < thread_cnt; i++) {
+
+		SAFE_PTHREAD_JOIN(id0[i], NULL);
+		SAFE_PTHREAD_JOIN(id1[i], NULL);
+		SAFE_PTHREAD_JOIN(id2[i], NULL);
+	}
+
+	fd = SAFE_OPEN(fname, O_RDONLY);
+
+	for (i = 0; i < thread_cnt * 4; i++) {
+
+		SAFE_READ(1, fd, buf, write_size/4);
+
+		for (k = 0; k < write_size/4; k++) {
+
+			if (buf[k] < 2 || buf[k] > 254) {
+
+				if (i < 3 && buf[k] == 1)
+					continue;
+				tst_res(TFAIL, "Unexpected data "
+					"offset %ld value %d",
+					i * write_size / 4 + k, buf[k]);
+				SAFE_CLOSE(fd);
+				return;
+			}
+		}
+
+		for (k = 1; k < write_size/4; k++) {
+
+			if (buf[k] != buf[0]) {
+				tst_res(TFAIL, "Unexpected block read");
+				SAFE_CLOSE(fd);
+				return;
+			}
+		}
+	}
+
+	if (pthread_barrier_destroy(&barrier) != 0)
+		tst_brk(TBROK, "Failed to destroy pthread barrier");
+
+	SAFE_CLOSE(fd);
+	if (fail_flag == 0)
+		tst_res(TPASS, "Access between threads synchronized");
+}
+
+static struct tcase {
+	void *(*fn0)(void *);
+	void *(*fn1)(void *);
+	void *(*fn2)(void *);
+	const char *desc;
+} tcases[] = {
+	{fn_ofd_r, fn_ofd_w, fn_dummy, "OFD read lock vs OFD write lock"},
+	{fn_ofd_w, fn_posix_w, fn_dummy, "OFD write lock vs POSIX write lock"},
+	{fn_ofd_r, fn_posix_w, fn_dummy, "OFD read lock vs POSIX write lock"},
+	{fn_ofd_w, fn_posix_r, fn_dummy, "OFD write lock vs POSIX read lock"},
+	{fn_ofd_w, fn_ofd_w, fn_dummy, "OFD write lock vs OFD write lock"},
+	{fn_ofd_r, fn_ofd_w, fn_posix_w, "OFD r/w lock vs POSIX write lock"},
+	{fn_ofd_r, fn_ofd_w, fn_posix_r, "OFD r/w lock vs POSIX read lock"},
+};
+
+static void tests(unsigned int i)
+{
+	test_fn(tcases[i].fn0, tcases[i].fn1, tcases[i].fn2, tcases[i].desc);
+}
+
+static struct tst_test test = {
+	.min_kver = "3.15",
+	.needs_tmpdir = 1,
+	.test = tests,
+	.tcnt = ARRAY_SIZE(tcases),
+	.setup = setup
+};
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr01.c b/testcases/kernel/syscalls/flistxattr/flistxattr01.c
index 5fa4e7f..b287aab 100644
--- a/testcases/kernel/syscalls/flistxattr/flistxattr01.c
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr01.c
@@ -90,7 +90,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "flistxattr01",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test_all = verify_flistxattr,
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr02.c b/testcases/kernel/syscalls/flistxattr/flistxattr02.c
index 876d53a..9f85ee5 100644
--- a/testcases/kernel/syscalls/flistxattr/flistxattr02.c
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr02.c
@@ -92,7 +92,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "flistxattr02",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_flistxattr,
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr03.c b/testcases/kernel/syscalls/flistxattr/flistxattr03.c
index 0fcf0d8..14b68d4 100644
--- a/testcases/kernel/syscalls/flistxattr/flistxattr03.c
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr03.c
@@ -83,7 +83,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "flistxattr03",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_flistxattr,
diff --git a/testcases/kernel/syscalls/flock/flock01.c b/testcases/kernel/syscalls/flock/flock01.c
index a7ecba1..06d89e3 100644
--- a/testcases/kernel/syscalls/flock/flock01.c
+++ b/testcases/kernel/syscalls/flock/flock01.c
@@ -69,6 +69,7 @@
 #include <stdio.h>
 #include <sys/wait.h>
 #include <sys/file.h>
+#include <fcntl.h>
 #include "test.h"
 
 void setup(void);
@@ -153,7 +154,7 @@
 	sprintf(filename, "flock01.%d", getpid());
 
 	/* creating temporary file */
-	fd = creat(filename, 0644);
+	fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0644);
 	if (fd < 0)
 		tst_brkm(TBROK, tst_rmdir, "creating a new file failed");
 }
diff --git a/testcases/kernel/syscalls/flock/flock02.c b/testcases/kernel/syscalls/flock/flock02.c
index 971160d..9ddf729 100644
--- a/testcases/kernel/syscalls/flock/flock02.c
+++ b/testcases/kernel/syscalls/flock/flock02.c
@@ -75,6 +75,7 @@
 #include <sys/types.h>
 #include <sys/file.h>
 #include <sys/wait.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <stdio.h>
 #include "test.h"
@@ -150,7 +151,7 @@
 
 	sprintf(filename, "flock02.%d", getpid());
 
-	fd = creat(filename, 0666);
+	fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
 	if (fd < 0)
 		tst_brkm(TFAIL | TERRNO, cleanup, "creat failed");
 }
diff --git a/testcases/kernel/syscalls/flock/flock03.c b/testcases/kernel/syscalls/flock/flock03.c
index e53b3b7..420f509 100644
--- a/testcases/kernel/syscalls/flock/flock03.c
+++ b/testcases/kernel/syscalls/flock/flock03.c
@@ -181,7 +181,7 @@
 
 	TST_CHECKPOINT_INIT(tst_rmdir);
 
-	fd = creat(FILE_NAME, 0666);
+	fd = open(FILE_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666);
 	if (fd < 0) {
 		tst_resm(TBROK, "creating a new file failed");
 		cleanup();
diff --git a/testcases/kernel/syscalls/flock/flock04.c b/testcases/kernel/syscalls/flock/flock04.c
index 5dafaa4..87f1dfb 100644
--- a/testcases/kernel/syscalls/flock/flock04.c
+++ b/testcases/kernel/syscalls/flock/flock04.c
@@ -164,7 +164,7 @@
 
 	sprintf(filename, "flock04.%d", getpid());
 
-	fd = creat(filename, 0666);
+	fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
 	if (fd == -1)
 		tst_brkm(TFAIL, cleanup, "creating a new file failed");
 }
diff --git a/testcases/kernel/syscalls/flock/flock05.c b/testcases/kernel/syscalls/flock/flock05.c
index d9d3d00..13ae2f6 100644
--- a/testcases/kernel/syscalls/flock/flock05.c
+++ b/testcases/kernel/syscalls/flock/flock05.c
@@ -182,7 +182,7 @@
 	sprintf(filename, "flock05.%d", getpid());
 
 	/* creating temporary file */
-	fd = creat(filename, 0666);
+	fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
 	if (fd == -1) {
 		tst_resm(TFAIL, "creating a new file failed");
 
diff --git a/testcases/kernel/syscalls/flock/flock06.c b/testcases/kernel/syscalls/flock/flock06.c
index d9c1d2d..a35c8cf 100644
--- a/testcases/kernel/syscalls/flock/flock06.c
+++ b/testcases/kernel/syscalls/flock/flock06.c
@@ -158,7 +158,7 @@
 	sprintf(filename, "flock06.%d", getpid());
 
 	/* creating temporary file */
-	fd = creat(filename, 0666);
+	fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
 	if (fd < 0)
 		tst_brkm(TBROK, tst_rmdir, "creating a new file failed");
 	close(fd);
diff --git a/testcases/kernel/syscalls/fstat/fstat02.c b/testcases/kernel/syscalls/fstat/fstat02.c
index 03d29a2..21ef166 100644
--- a/testcases/kernel/syscalls/fstat/fstat02.c
+++ b/testcases/kernel/syscalls/fstat/fstat02.c
@@ -72,8 +72,8 @@
 	}
 
 	if (stat_buf.st_size != FILE_SIZE) {
-		tst_resm(TINFO, "stat_buf.st_size = %zu expected %i",
-		         stat_buf.st_size, FILE_SIZE);
+		tst_resm(TINFO, "stat_buf.st_size = %li expected %i",
+		         (long)stat_buf.st_size, FILE_SIZE);
 		fail++;
 	}
 
diff --git a/testcases/kernel/syscalls/fstatat/fstatat01.c b/testcases/kernel/syscalls/fstatat/fstatat01.c
index 840d7b6..b5fa837 100644
--- a/testcases/kernel/syscalls/fstatat/fstatat01.c
+++ b/testcases/kernel/syscalls/fstatat/fstatat01.c
@@ -35,7 +35,7 @@
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TEST_CASES 6
 #ifndef AT_FDCWD
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate04.c b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
index d4fe691..a1080be 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate04.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
@@ -154,8 +154,8 @@
 
 	if (sb.st_size != offset) {
 		tst_resm(TFAIL,
-			 "ftruncate() to %zu bytes succeded but fstat() reports size %zu",
-			 offset, sb.st_size);
+			 "ftruncate() to %li bytes succeded but fstat() reports size %li",
+			 (long)offset, (long)sb.st_size);
 		return;
 	}
 
diff --git a/testcases/kernel/syscalls/futex/futex_wait05.c b/testcases/kernel/syscalls/futex/futex_wait05.c
index 6b99ced..f6b0aa1 100644
--- a/testcases/kernel/syscalls/futex/futex_wait05.c
+++ b/testcases/kernel/syscalls/futex/futex_wait05.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz>
  *
  * Licensed under the GNU GPLv2 or later.
  * This program is free software;  you can redistribute it and/or modify
@@ -23,64 +23,35 @@
 
 #include <errno.h>
 
-#include "test.h"
+#include "tst_timer_test.h"
 #include "futextest.h"
 
-#define TRESHOLD_US 100000
-
-const char *TCID="futex_wait05";
-const int TST_TOTAL=1;
-
-static void verify_futex_wait(clock_t clk_id, int fflags)
+int sample_fn(int clk_id, long long usec)
 {
-	struct timespec to = {.tv_sec = 0, .tv_nsec = 100010000};
+	struct timespec to = tst_us_to_timespec(usec);
 	futex_t futex = FUTEX_INITIALIZER;
 
 	tst_timer_start(clk_id);
-	TEST(futex_wait(&futex, futex, &to, fflags));
+	TEST(futex_wait(&futex, futex, &to, 0));
 	tst_timer_stop();
+	tst_timer_sample();
 
 	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "futex_wait() returned %li, expected -1",
+		tst_res(TFAIL, "futex_wait() returned %li, expected -1",
 		         TEST_RETURN);
-		return;
+		return 1;
 	}
 
 	if (TEST_ERRNO != ETIMEDOUT) {
-
-		tst_resm(TFAIL | TTERRNO, "expected errno=%s",
-		         tst_strerrno(ETIMEDOUT));
-		return;
+		tst_res(TFAIL | TTERRNO, "expected errno=%s",
+		        tst_strerrno(ETIMEDOUT));
+		return 1;
 	}
 
-	if (tst_timespec_lt(tst_timer_elapsed(), to)) {
-		tst_resm(TFAIL,
-		         "futex_wait() woken up prematurely %llius, expected %llius",
-			 tst_timer_elapsed_us(), tst_timespec_to_us(to));
-		return;
-	}
-
-	if (tst_timespec_diff_us(tst_timer_elapsed(), to) > TRESHOLD_US) {
-		tst_resm(TFAIL,
-		         "futex_wait() waited too long %llius, expected %llius",
-			 tst_timer_elapsed_us(), tst_timespec_to_us(to));
-		return;
-	}
-
-	tst_resm(TPASS, "futex_wait() waited %llius, expected %llius",
-	         tst_timer_elapsed_us(), tst_timespec_to_us(to));
+	return 0;
 }
 
-int main(int argc, char *argv[])
-{
-	int lc;
-
-	tst_timer_check(CLOCK_MONOTONIC);
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		verify_futex_wait(CLOCK_MONOTONIC, 0);
-
-	tst_exit();
-}
+static struct tst_test test = {
+	.tid = "futex_wait()",
+	.sample = sample_fn,
+};
diff --git a/testcases/kernel/syscalls/futex/futex_wake01.c b/testcases/kernel/syscalls/futex/futex_wake01.c
index b5f1904..42ea6f6 100644
--- a/testcases/kernel/syscalls/futex/futex_wake01.c
+++ b/testcases/kernel/syscalls/futex/futex_wake01.c
@@ -21,6 +21,7 @@
   */
 
 #include <errno.h>
+#include <limits.h>
 
 #include "test.h"
 #include "futextest.h"
diff --git a/testcases/kernel/syscalls/futimesat/futimesat01.c b/testcases/kernel/syscalls/futimesat/futimesat01.c
index 514cfcf..e3b1011 100644
--- a/testcases/kernel/syscalls/futimesat/futimesat01.c
+++ b/testcases/kernel/syscalls/futimesat/futimesat01.c
@@ -34,7 +34,7 @@
 #include <signal.h>
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TEST_CASES 5
 #ifndef AT_FDCWD
diff --git a/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c b/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
index c96fb33..cca5028 100644
--- a/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
+++ b/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
@@ -58,7 +58,7 @@
 #include <numaif.h>
 #endif
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "include_j_h.h"
 #include "common_j_h.c"
 #include "numa_helper.h"
diff --git a/testcases/kernel/syscalls/get_robust_list/get_robust_list01.c b/testcases/kernel/syscalls/get_robust_list/get_robust_list01.c
index 2efed9a..6aa776f 100644
--- a/testcases/kernel/syscalls/get_robust_list/get_robust_list01.c
+++ b/testcases/kernel/syscalls/get_robust_list/get_robust_list01.c
@@ -51,7 +51,7 @@
 #include <stdlib.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "get_robust_list01";
 int TST_TOTAL = 5;
diff --git a/testcases/kernel/syscalls/getcwd/getcwd02.c b/testcases/kernel/syscalls/getcwd/getcwd02.c
index 213f8ea..54440bd 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd02.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd02.c
@@ -115,7 +115,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getcwd02",
 	.setup = setup,
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_getcwd
diff --git a/testcases/kernel/syscalls/getcwd/getcwd03.c b/testcases/kernel/syscalls/getcwd/getcwd03.c
index 4f8f872..2711a2d 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd03.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd03.c
@@ -98,7 +98,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getcwd03",
 	.needs_tmpdir = 1,
 	.setup = setup,
 	.test_all = verify_getcwd
diff --git a/testcases/kernel/syscalls/getcwd/getcwd04.c b/testcases/kernel/syscalls/getcwd/getcwd04.c
index 7e2ca23..ba8c358 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd04.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd04.c
@@ -107,7 +107,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getcwd04",
 	.setup = setup,
 	.test_all = verify_getcwd,
 	.needs_tmpdir = 1,
diff --git a/testcases/kernel/syscalls/getdents/getdents.h b/testcases/kernel/syscalls/getdents/getdents.h
index abea655..702b0bd 100644
--- a/testcases/kernel/syscalls/getdents/getdents.h
+++ b/testcases/kernel/syscalls/getdents/getdents.h
@@ -22,7 +22,7 @@
 
 #include <stdint.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 /*
  * See fs/compat.c struct compat_linux_dirent
diff --git a/testcases/kernel/syscalls/getpriority/getpriority01.c b/testcases/kernel/syscalls/getpriority/getpriority01.c
index 6edf39d..caf8573 100644
--- a/testcases/kernel/syscalls/getpriority/getpriority01.c
+++ b/testcases/kernel/syscalls/getpriority/getpriority01.c
@@ -63,7 +63,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getpriority01",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_getpriority,
 };
diff --git a/testcases/kernel/syscalls/getpriority/getpriority02.c b/testcases/kernel/syscalls/getpriority/getpriority02.c
index d577b2b..c2d3560 100644
--- a/testcases/kernel/syscalls/getpriority/getpriority02.c
+++ b/testcases/kernel/syscalls/getpriority/getpriority02.c
@@ -71,7 +71,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getpriority02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_getpriority,
 };
diff --git a/testcases/kernel/syscalls/getrandom/getrandom01.c b/testcases/kernel/syscalls/getrandom/getrandom01.c
index 7c7ed94..8bc0269 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom01.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom01.c
@@ -27,7 +27,7 @@
  */
 
 #include "lapi/getrandom.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "tst_test.h"
 
 static int modes[] = {0, GRND_RANDOM, GRND_NONBLOCK,
@@ -46,7 +46,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getrandom01",
 	.tcnt = ARRAY_SIZE(modes),
 	.test = verify_getrandom,
 };
diff --git a/testcases/kernel/syscalls/getrandom/getrandom02.c b/testcases/kernel/syscalls/getrandom/getrandom02.c
index ac20d79..cc7b0b8 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom02.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom02.c
@@ -28,7 +28,7 @@
  */
 
 #include "lapi/getrandom.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "tst_test.h"
 
 static int modes[] = { 0, GRND_RANDOM, GRND_NONBLOCK,
@@ -73,7 +73,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getrandom02",
 	.tcnt = ARRAY_SIZE(modes),
 	.test = verify_getrandom,
 };
diff --git a/testcases/kernel/syscalls/getrandom/getrandom03.c b/testcases/kernel/syscalls/getrandom/getrandom03.c
index e754ca3..55c2872 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom03.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom03.c
@@ -31,7 +31,7 @@
  */
 
 #include "lapi/getrandom.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "tst_test.h"
 
 #define MAX_SIZE 256
@@ -63,7 +63,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getrandom03",
 	.tcnt = ARRAY_SIZE(sizes),
 	.test = verify_getrandom,
 };
diff --git a/testcases/kernel/syscalls/getrandom/getrandom04.c b/testcases/kernel/syscalls/getrandom/getrandom04.c
index 0eae031..8a3faf9 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom04.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom04.c
@@ -32,7 +32,7 @@
 
 #include <sys/resource.h>
 #include "lapi/getrandom.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "tst_test.h"
 
 static void verify_getrandom(void)
@@ -55,6 +55,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "getrandom04",
 	.test_all = verify_getrandom,
 };
diff --git a/testcases/kernel/syscalls/getrusage/getrusage03_child.c b/testcases/kernel/syscalls/getrusage/getrusage03_child.c
index 24a6f33..972c38e4 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage03_child.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage03_child.c
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/getsockopt/getsockopt02.c b/testcases/kernel/syscalls/getsockopt/getsockopt02.c
new file mode 100644
index 0000000..edf9dd8
--- /dev/null
+++ b/testcases/kernel/syscalls/getsockopt/getsockopt02.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Test description: Test retrieving of peer credentials (SO_PEERCRED)
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <stdlib.h>
+#include "tst_test.h"
+
+static int socket_fd, accepted;
+static struct sockaddr_un sun;
+
+#define SOCKNAME	"testsocket"
+
+static void setup(void)
+{
+	sun.sun_family = AF_UNIX;
+	(void)strcpy(sun.sun_path, SOCKNAME);
+	socket_fd = SAFE_SOCKET(sun.sun_family, SOCK_STREAM, 0);
+	SAFE_BIND(socket_fd, (struct sockaddr *)&sun, sizeof(sun));
+	SAFE_LISTEN(socket_fd, SOMAXCONN);
+}
+
+static void fork_func(void)
+{
+	int fork_socket_fd = SAFE_SOCKET(sun.sun_family, SOCK_STREAM, 0);
+
+	SAFE_CONNECT(fork_socket_fd, (struct sockaddr *)&sun, sizeof(sun));
+	TST_CHECKPOINT_WAIT(0);
+	SAFE_CLOSE(fork_socket_fd);
+	exit(0);
+}
+
+static void test_function(void)
+{
+	pid_t fork_id;
+	struct ucred cred;
+	socklen_t cred_len = sizeof(cred);
+
+	fork_id = SAFE_FORK();
+	if (!fork_id)
+		fork_func();
+
+	accepted = accept(socket_fd, NULL, NULL);
+	if (accepted < 0) {
+		tst_res(TFAIL | TERRNO, "Error with accepting connection");
+		goto clean;
+	}
+	if (getsockopt(accepted, SOL_SOCKET,
+				SO_PEERCRED, &cred, &cred_len) < 0) {
+		tst_res(TFAIL | TERRNO, "Error while getting socket option");
+		goto clean;
+	}
+
+	if (fork_id != cred.pid)
+		tst_res(TFAIL, "Received wrong PID %d, expected %d",
+				cred.pid, getpid());
+	else
+		tst_res(TPASS, "Test passed");
+clean:
+	if (accepted >= 0)
+		SAFE_CLOSE(accepted);
+	TST_CHECKPOINT_WAKE(0);
+}
+
+static void cleanup(void)
+{
+	if (accepted >= 0)
+		SAFE_CLOSE(accepted);
+	if (socket_fd >= 0)
+		SAFE_CLOSE(socket_fd);
+}
+
+static struct tst_test test = {
+	.test_all = test_function,
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+};
diff --git a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
index 0ff001a..8c221a2 100644
--- a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
+++ b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
@@ -103,7 +103,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "gettimeofday02",
 	.setup = setup,
 	.options = options,
 	.test_all = verify_gettimeofday,
diff --git a/testcases/kernel/syscalls/getxattr/getxattr02.c b/testcases/kernel/syscalls/getxattr/getxattr02.c
index d10cb54..df75fb3 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr02.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr02.c
@@ -41,6 +41,7 @@
 #include "config.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/testcases/kernel/syscalls/getxattr/getxattr04.c b/testcases/kernel/syscalls/getxattr/getxattr04.c
index 625337d..1dcb14d 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr04.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr04.c
@@ -118,7 +118,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "getxattr04",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.mount_device = 1,
diff --git a/testcases/kernel/syscalls/inotify/inotify01.c b/testcases/kernel/syscalls/inotify/inotify01.c
index 58dfe14..7f08a8f 100644
--- a/testcases/kernel/syscalls/inotify/inotify01.c
+++ b/testcases/kernel/syscalls/inotify/inotify01.c
@@ -38,7 +38,7 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "inotify.h"
 
 #if defined(HAVE_SYS_INOTIFY_H)
diff --git a/testcases/kernel/syscalls/inotify/inotify02.c b/testcases/kernel/syscalls/inotify/inotify02.c
index fde104f..9913426 100644
--- a/testcases/kernel/syscalls/inotify/inotify02.c
+++ b/testcases/kernel/syscalls/inotify/inotify02.c
@@ -38,8 +38,9 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
+#include <limits.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "inotify.h"
 
 #if defined(HAVE_SYS_INOTIFY_H)
diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c
index d3007b0..ec2f5d2 100644
--- a/testcases/kernel/syscalls/inotify/inotify03.c
+++ b/testcases/kernel/syscalls/inotify/inotify03.c
@@ -42,7 +42,7 @@
 #include <sys/syscall.h>
 #include <signal.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "inotify.h"
 
 char *TCID = "inotify03";
diff --git a/testcases/kernel/syscalls/inotify/inotify04.c b/testcases/kernel/syscalls/inotify/inotify04.c
index 1a18341..87ef9c3 100644
--- a/testcases/kernel/syscalls/inotify/inotify04.c
+++ b/testcases/kernel/syscalls/inotify/inotify04.c
@@ -45,7 +45,7 @@
 #include <errno.h>
 #include <string.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "inotify.h"
 #include "safe_macros.h"
 
diff --git a/testcases/kernel/syscalls/inotify/inotify05.c b/testcases/kernel/syscalls/inotify/inotify05.c
index cd48f40..b526521 100644
--- a/testcases/kernel/syscalls/inotify/inotify05.c
+++ b/testcases/kernel/syscalls/inotify/inotify05.c
@@ -35,7 +35,7 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "inotify.h"
 #include "safe_macros.h"
 
diff --git a/testcases/kernel/syscalls/inotify/inotify06.c b/testcases/kernel/syscalls/inotify/inotify06.c
index 71f7596..7ac5794 100644
--- a/testcases/kernel/syscalls/inotify/inotify06.c
+++ b/testcases/kernel/syscalls/inotify/inotify06.c
@@ -42,7 +42,7 @@
 #include <sys/syscall.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "inotify.h"
 #include "safe_macros.h"
 
diff --git a/testcases/kernel/syscalls/inotify_init/inotify_init1_01.c b/testcases/kernel/syscalls/inotify_init/inotify_init1_01.c
index 45928f9..f1203a4 100644
--- a/testcases/kernel/syscalls/inotify_init/inotify_init1_01.c
+++ b/testcases/kernel/syscalls/inotify_init/inotify_init1_01.c
@@ -61,7 +61,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define IN_CLOEXEC O_CLOEXEC
 
diff --git a/testcases/kernel/syscalls/inotify_init/inotify_init1_02.c b/testcases/kernel/syscalls/inotify_init/inotify_init1_02.c
index 2d68eaa..b074214 100644
--- a/testcases/kernel/syscalls/inotify_init/inotify_init1_02.c
+++ b/testcases/kernel/syscalls/inotify_init/inotify_init1_02.c
@@ -58,7 +58,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define IN_NONBLOCK O_NONBLOCK
 
diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c b/testcases/kernel/syscalls/io_submit/io_submit01.c
index fd01e6e..9baf520 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit01.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
@@ -1,32 +1,27 @@
 /*
+ * Copyright (c) Crackerjack Project., 2007
+ * Copyright (c) 2011-2017 Cyril Hrubis <chrubis@suse.cz>
  *
- *   Copyright (c) Crackerjack Project., 2007
- *   Copyright (c) 2011 Cyril Hrubis <chrubis@suse.cz>
+ * 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 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.
  *
- *   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
+ * 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
  */
 
 /* Porting from Crackerjack to LTP is done
    by Masatake YAMATO <yamato@redhat.com> */
 
 #include "config.h"
-#include "test.h"
-
-char *TCID = "io_submit01";
-
-int TST_TOTAL = 3;
+#include "tst_test.h"
 
 #ifdef HAVE_LIBAIO_H
 #include <libaio.h>
@@ -34,167 +29,115 @@
 #include <string.h>
 #include <fcntl.h>
 
-#define TESTFILE	"testfile"
+static io_context_t ctx;
+static io_context_t invalid_ctx;
 
-static void cleanup(void)
-{
-	tst_rmdir();
-}
+static struct iocb iocb;
+static struct iocb *iocbs[] = {&iocb};
+
+static struct iocb inv_fd_iocb;
+static struct iocb *inv_fd_iocbs[] = {&inv_fd_iocb};
+
+static int rdonly_fd;
+static struct iocb rdonly_fd_iocb;
+static struct iocb *rdonly_fd_iocbs[] = {&rdonly_fd_iocb};
+
+static int wronly_fd;
+static struct iocb wronly_fd_iocb;
+static struct iocb *wronly_fd_iocbs[] = {&wronly_fd_iocb};
+
+static struct iocb zero_buf_iocb;
+static struct iocb *zero_buf_iocbs[] = {&zero_buf_iocb};
+
+static struct iocb *zero_iocbs[1];
+
+static char buf[100];
+
+static struct tcase {
+	io_context_t *ctx;
+	long nr;
+	struct iocb **iocbs;
+	int exp_errno;
+	const char *desc;
+} tcases[] = {
+	/* Invalid ctx */
+	{&invalid_ctx, 1, iocbs, -EINVAL, "invalid ctx"},
+	/* Invalid nr */
+	{&ctx, -1, iocbs, -EINVAL, "invalid nr"},
+	/* Invalid pointer */
+	{&ctx, 1, (void*)-1, -EFAULT, "invalid iocbpp pointer"},
+	{&ctx, 1, zero_iocbs, -EFAULT, "NULL iocb pointers"},
+	/* Invalid fd */
+	{&ctx, 1, inv_fd_iocbs, -EBADF, "invalid fd"},
+	{&ctx, 1, rdonly_fd_iocbs, -EBADF, "readonly fd for write"},
+	{&ctx, 1, wronly_fd_iocbs, -EBADF, "writeonly fd for read"},
+	/* No-op but should work fine */
+	{&ctx, 1, zero_buf_iocbs, 1, "zero buf size"},
+	{&ctx, 0, NULL, 0, "zero nr"},
+};
 
 static void setup(void)
 {
-	int fd;
+	int rval;
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	rval = io_setup(1, &ctx);
+	if (rval)
+		tst_brk(TBROK | TERRNO, "io_setup() returned %d", rval);
 
-	TEST_PAUSE;
+	io_prep_pread(&inv_fd_iocb, -1, buf, sizeof(buf), 0);
 
-	tst_tmpdir();
+	rdonly_fd = SAFE_OPEN("rdonly_file", O_RDONLY | O_CREAT, 0777);
+	io_prep_pwrite(&rdonly_fd_iocb, rdonly_fd, buf, sizeof(buf), 0);
 
-	fd = open(TESTFILE, O_CREAT | O_RDWR, 0755);
-	if (fd == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "open");
-	if (close(fd) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "close");
+	io_prep_pread(&zero_buf_iocb, rdonly_fd, buf, 0, 0);
+
+	wronly_fd = SAFE_OPEN("wronly_file", O_WRONLY | O_CREAT, 0777);
+	io_prep_pread(&wronly_fd_iocb, wronly_fd, buf, sizeof(buf), 0);
 }
 
-static void check_result(long exp, long act)
+static void cleanup(void)
 {
-	if (exp >= 0) {
-		if (act == exp)
-			tst_resm(TPASS, "expected success - "
-				 "returned value = %ld", act);
-		else
-			tst_resm(TFAIL, "unexpected failure - "
-				 "returned value = %ld : %s",
-				 act, strerror(-1 * act));
+	if (rdonly_fd > 0)
+		SAFE_CLOSE(rdonly_fd);
+
+	if (wronly_fd > 0)
+		SAFE_CLOSE(wronly_fd);
+}
+
+static const char *errno_name(int err)
+{
+	if (err <= 0)
+		return tst_strerrno(-err);
+
+	return "SUCCESS";
+}
+
+static void verify_io_submit(unsigned int n)
+{
+	struct tcase *t = &tcases[n];
+	int ret;
+
+	ret = io_submit(*t->ctx, t->nr, t->iocbs);
+
+	if (ret == t->exp_errno) {
+		tst_res(TPASS, "io_submit() with %s failed with %s",
+			t->desc, errno_name(t->exp_errno));
 		return;
 	}
 
-	/* if return value is expected to be < 0 */
-	if (act == exp)
-		tst_resm(TPASS, "expected failure - "
-			 "returned value = %ld : %s", act, strerror(-1 * act));
-	else if (act == 0)
-		tst_resm(TFAIL, "call succeeded unexpectedly");
-	else
-		tst_resm(TFAIL, "unexpected failure - "
-			 "returned value = %ld : %s, "
-			 "expected value = %ld : %s",
-			 act, strerror(-1 * act), exp, strerror(-1 * exp));
+	tst_res(TFAIL, "io_submit() returned %i(%s), expected %s(%i)",
+		ret, ret < 0 ? tst_strerrno(-ret) : "SUCCESS",
+		errno_name(t->exp_errno), t->exp_errno);
 }
 
-int main(int argc, char *argv[])
-{
-	int lc;
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_io_submit,
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+};
 
-	int rval, fd;
-	char buf[256];
-	struct iocb iocb;
-	struct iocb *iocbs[1];
-	io_context_t ctx;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		/* 1 - EINVAL */
-		/* 1.1 - EINVAL: invalid ctx */
-		memset(&ctx, 0, sizeof(ctx));
-		TEST(io_submit(ctx, 0, NULL));
-		check_result(-EINVAL, TEST_RETURN);
-
-		/* 1.2 - EINVAL: invalid nr */
-		rval = io_setup(1, &ctx);
-		if (rval != 0)
-			tst_brkm(TBROK, cleanup, "io_setup failed: %d", rval);
-		TEST(io_submit(ctx, -1, NULL));
-		check_result(-EINVAL, TEST_RETURN);
-
-		/* 1.3 - EINVAL: uninitialized iocb */
-		iocbs[0] = &iocb;
-
-		/* There are multiple checks we can hit with uninitialized
-		 * iocb, but with "random" data it's not 100%. Make sure we
-		 * fail eventually in opcode check. */
-		iocb.aio_lio_opcode = -1;
-
-		TEST(io_submit(ctx, 1, iocbs));
-		switch (TEST_RETURN) {
-		case -EINVAL:
-		case -EBADF:
-		case -EFAULT:
-			tst_resm(TPASS, "expected failure - "
-				 "returned value = %ld : %s",
-				 TEST_RETURN, strerror(-1 * TEST_RETURN));
-			break;
-		default:
-			tst_resm(TFAIL, "unexpected failure - "
-				 "returned value = %ld : %s, "
-				 "expected one of -EINVAL, -EBADF, -EFAULT",
-				 TEST_RETURN, strerror(-1 * TEST_RETURN));
-		}
-
-		/* 2 - EFAULT: iocb points to invalid data */
-		TEST(io_submit(ctx, 1, (struct iocb **)-1));
-		check_result(-EFAULT, TEST_RETURN);
-
-		/*
-		 * 3 - Special case EFAULT or EINVAL (indetermination)
-		 *
-		 * The errno depends on the per architecture implementation
-		 * of io_submit. On the architecture using compat_sys_io_submit
-		 * as its implementation, errno is set to -EINVAL.
-		 */
-		TEST(io_submit(ctx, -1, (struct iocb **)-1));
-		if (TEST_RETURN == 0)
-			tst_resm(TFAIL, "call succeeded unexpectedly");
-		else if (TEST_RETURN == -EFAULT || TEST_RETURN == -EINVAL)
-			tst_resm(TPASS, "expected failure - "
-				 "returned value = %ld : %s",
-				 TEST_RETURN, strerror(-1 * TEST_RETURN));
-		else
-			tst_resm(TFAIL, "unexpected failure - "
-				 "returned value = %ld : %s, "
-				 "expected = %d : %s or %d : %s",
-				 TEST_RETURN, strerror(-1 * TEST_RETURN),
-				 -EFAULT, strerror(EFAULT),
-				 -EINVAL, strerror(EINVAL));
-
-		/*
-		 * 4 - EBADF: fd in iocb is invalid
-		 */
-		io_prep_pread(&iocb, -1, buf, sizeof(buf), 0);
-		iocbs[0] = &iocb;
-		TEST(io_submit(ctx, 1, iocbs));
-		check_result(-EBADF, TEST_RETURN);
-
-		/* 5 - Positive test: nr == 0 */
-		TEST(io_submit(ctx, 0, NULL));
-		check_result(0, TEST_RETURN);
-
-		/* 6 - Positive test: valid fd */
-		fd = open(TESTFILE, O_RDONLY);
-		if (fd == -1)
-			tst_resm(TBROK | TERRNO, "open");
-		io_prep_pread(&iocb, fd, buf, sizeof(buf), 0);
-		iocbs[0] = &iocb;
-		TEST(io_submit(ctx, 1, iocbs));
-		check_result(1, TEST_RETURN);
-		if (close(fd) == -1)
-			tst_resm(TBROK | TERRNO, "close");
-
-	}
-	cleanup();
-
-	tst_exit();
-}
 #else
-int main(int argc, char *argv[])
-{
-	tst_brkm(TCONF, NULL, "System doesn't support execution of the test");
-}
+	TST_TEST_TCONF("libaio.h was mission upon compilation");
 #endif
diff --git a/testcases/kernel/syscalls/ioctl/ioctl04.c b/testcases/kernel/syscalls/ioctl/ioctl04.c
index 8f78247..89e89ec 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl04.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl04.c
@@ -93,7 +93,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "ioctl04",
 	.needs_tmpdir = 1,
 	.format_device = 1,
 	.needs_root = 1,
diff --git a/testcases/kernel/syscalls/ioctl/ioctl05.c b/testcases/kernel/syscalls/ioctl/ioctl05.c
index d1b44f1..459efdb 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl05.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl05.c
@@ -78,7 +78,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "ioctl05",
 	.needs_device = 1,
 	.needs_root = 1,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/ioctl/ioctl06.c b/testcases/kernel/syscalls/ioctl/ioctl06.c
index 642283a..6fc6443 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl06.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl06.c
@@ -64,7 +64,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "ioctl06",
 	.needs_root = 1,
 	.needs_device = 1,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.c b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.c
index 8ea421f..0369add 100644
--- a/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.c
+++ b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.c
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/shm.h>
 
 #define	TST_NO_DEFAULT_MAIN
 
@@ -79,3 +81,30 @@
 
 	return used_queues;
 }
+
+void *probe_free_addr(const char *file, const int lineno)
+{
+	void *addr;
+	int shm_id = -1;
+	key_t probe_key = 0;
+
+	probe_key = GETIPCKEY();
+
+	shm_id = shmget(probe_key, SHMLBA * 2, SHM_RW | IPC_CREAT | IPC_EXCL);
+	if (shm_id == -1)
+		tst_brk(TBROK, "probe: shmget() failed at %s:%d", file, lineno);
+
+	addr = shmat(shm_id, NULL, 0);
+	if (addr == (void *) -1)
+		tst_brk(TBROK, "probe: shmat() failed at %s:%d", file, lineno);
+
+	if (shmdt(addr) == -1)
+		tst_brk(TBROK, "probe: shmdt() failed at %s:%d", file, lineno);
+
+	if (shmctl(shm_id, IPC_RMID, NULL) == -1)
+		tst_brk(TBROK, "probe: shmctl() failed at %s:%d", file, lineno);
+
+	addr = (void *)(((unsigned long)(addr) + (SHMLBA - 1)) & ~(SHMLBA - 1));
+
+	return addr;
+}
diff --git a/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.h b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.h
index 39148be..660be80 100644
--- a/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.h
+++ b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.h
@@ -50,4 +50,8 @@
 #define GET_USED_QUEUES() \
 	get_used_queues(__FILE__, __LINE__)
 
+void *probe_free_addr(const char *file, const int lineno);
+#define PROBE_FREE_ADDR() \
+	probe_free_addr(__FILE__, __LINE__)
+
 #endif /* newlibipc.h */
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget01.c b/testcases/kernel/syscalls/ipc/msgget/msgget01.c
index 8e058c5..3d1010f 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget01.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget01.c
@@ -71,7 +71,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "msgget01",
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_msgget,
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget02.c b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
index 9cf1314..acf4b38 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget02.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
@@ -109,7 +109,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "msgget02",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget03.c b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
index 97911f9..f7e5ace 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget03.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
@@ -88,7 +88,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "msgget03",
 	.needs_tmpdir = 1,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
index d605fca..6036c64 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
@@ -70,7 +70,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "msgsnd01",
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_msgsnd,
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
index 5632079..2232b0e 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
@@ -122,7 +122,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "msgsnd02",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
index 032c870..d817254 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
@@ -114,7 +114,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "msgsnd05",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
index ce7f046..25fce0a 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
@@ -88,7 +88,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "msgsnd06",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/ipc/shmat/Makefile b/testcases/kernel/syscalls/ipc/shmat/Makefile
index f467389..f9ee8d2 100644
--- a/testcases/kernel/syscalls/ipc/shmat/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmat/Makefile
@@ -19,5 +19,5 @@
 top_srcdir              ?= ../../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
+include $(abs_srcdir)/../Makefile2.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat01.c b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
index 6de1872..b46ba68 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat01.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat01.c
@@ -17,225 +17,160 @@
  */
 
 /*
- * NAME
- *	shmat01.c
- *
  * DESCRIPTION
- *	shmat01 - test that shmat() works correctly
  *
- * ALGORITHM
- *	create a shared memory resouce with read/write permissions
- *	loop if that option was specified
- *	call shmat() with the TEST() macro using three valid conditions
- *	check the return code
- *	  if failure, issue a FAIL message.
- *	otherwise,
- *	  if doing functionality testing
- *		check for the correct conditions after the call
- *		if correct,
- *			issue a PASS message
- *		otherwise
- *			issue a FAIL message
- *	call cleanup
+ * 1) shmat() chooses a suitable (unused) address when shmaddr is NULL.
+ * 2) shmat() attaches shm segment to the shmaddr when shmaddr is a
+ *    page-aligned address.
+ * 3) shmat() attaches shm segment to the address equal to shmaddr rounded
+ *    down to the nearest multiple of SHMLBA when shmaddr is a page-unaligned
+ *    address and shmflg is set to SHM_RND.
+ * 4) shmat() attaches shm segment to the shmaddr for reading when shmflg
+ *    is set to SHM_RDONLY.
  */
 
-#include "ipcshm.h"
-#include "shmat_common.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <stdint.h>
 
-#define CASE0		10
-#define CASE1		20
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-char *TCID = "shmat01";
-int TST_TOTAL = 4;
+#define ALIGN_DOWN(in_addr) ((void *)(((uintptr_t)in_addr / SHMLBA) * SHMLBA))
 
-int shm_id_1 = -1;
-
-/*
- * By probing this address first, we can make
- * non-aligned addresses from it for different
- * architectures without explicitly code it.
- */
-void *base_addr;
-void *addr;
+static int shm_id = -1;
+static key_t shm_key;
+static void *null_addr;
+static void *aligned_addr;
+static void *unaligned_addr;
 
 static struct test_case_t {
-	int *shmid;
-	int offset;
-	int flags;
-	int getbase;
-} *TC;
+	void **shmaddr;
+	int flag;
+	int exp_status;
+	char *desp;
+} tcases[] = {
+	{&null_addr, 0, 0, "NULL address"},
+	{&aligned_addr, 0, 0, "aligned address"},
+	{&unaligned_addr, SHM_RND, 0, "unaligned address with SHM_RND"},
+	{&aligned_addr, SHM_RDONLY, SIGSEGV,
+	"aligned address with SHM_READONLY, and got SIGSEGV on write"}
+};
 
-static void check_functionality(int);
-
-int main(int argc, char *argv[])
+static void *expected_addr(void *in_addr, void *out_addr)
 {
-	int lc, i;
-	void *attchaddr;
+	if (!in_addr)
+		return out_addr;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			if (TC[i].getbase) {
-				base_addr = probe_free_addr();
-				attchaddr = base_addr + TC[i].offset;
-			} else {
-				attchaddr = NULL;
-			}
-
-			addr = shmat(*(TC[i].shmid), attchaddr, TC[i].flags);
-
-			TEST_ERRNO = errno;
-			if (addr == (void *)-1) {
-				tst_brkm(TFAIL | TTERRNO, cleanup,
-					 "shmat call failed");
-			} else {
-				check_functionality(i);
-			}
-
-			if (shmdt(addr) == -1)
-				tst_brkm(TBROK, cleanup,
-					 "Couldn't detach shared memory");
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
+	return ALIGN_DOWN(in_addr);
 }
 
-/*
- * check_functionality - check various conditions to make sure they
- *			 are correct.
- */
-static void check_functionality(int i)
+static void do_child(int *in_addr, int expect_crash)
 {
-	void *orig_add;
-	int *shared;
-	int fail = 0;
+	if (expect_crash) {
+		/*
+		 * Crash is expected, avoid dumping corefile.
+		 * 1 is a special value, that disables core-to-pipe.
+		 * At the same time it is small enough value for
+		 * core-to-file, so it skips creating cores as well.
+		*/
+		struct rlimit r;
+
+		r.rlim_cur = 1;
+		r.rlim_max = 1;
+		SAFE_SETRLIMIT(RLIMIT_CORE, &r);
+	}
+	*in_addr = 10;
+
+	exit(0);
+}
+
+static int expected_status(int status, int exp_status)
+{
+	if (!exp_status && WIFEXITED(status))
+		return 0;
+
+	if (exp_status && WIFSIGNALED(status) && WTERMSIG(status) == exp_status)
+		return 0;
+
+	return 1;
+}
+
+static void verify_shmat(unsigned int n)
+{
+	int *addr;
+	pid_t pid;
+	int status;
 	struct shmid_ds buf;
 
-	shared = (int *)addr;
+	struct test_case_t *tc = &tcases[n];
 
-	/* stat the shared memory ID */
-	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1)
-		tst_brkm(TBROK, cleanup, "couldn't stat shared memory");
+	addr = shmat(shm_id, *tc->shmaddr, tc->flag);
+	if (addr == (void *)-1) {
+		tst_res(TFAIL | TERRNO, "shmat() failed");
+		return;
+	}
 
-	/* check the number of attaches */
+	SAFE_SHMCTL(shm_id, IPC_STAT, &buf);
+
 	if (buf.shm_nattch != 1) {
-		tst_resm(TFAIL, "# of attaches is incorrect");
-		return;
+		tst_res(TFAIL, "number of attaches was incorrect");
+		goto end;
 	}
 
-	/* check the size of the segment */
 	if (buf.shm_segsz != INT_SIZE) {
-		tst_resm(TFAIL, "segment size is incorrect");
-		return;
+		tst_res(TFAIL, "segment size was incorrect");
+		goto end;
 	}
 
-	/* check for specific conditions depending on the type of attach */
-	switch (i) {
-	case 0:
-	case 1:
-		/*
-		 * Check the functionality of shmat by simply "writing"
-		 * a value to the shared memory space.
-		 * If this fails the program will get a SIGSEGV, dump
-		 * core and exit.
-		 */
-
-		*shared = CASE0;
-		break;
-	case 2:
-		/*
-		 * Check the functionality of shmat by writing a value
-		 * to the shared memory space and then checking that
-		 * the original address given was rounded down as
-		 * specified in the man page.
-		 */
-
-		*shared = CASE1;
-		orig_add = addr + ((unsigned long)TC[2].offset % SHMLBA);
-		if (orig_add != base_addr + TC[2].offset) {
-			tst_resm(TFAIL, "shared memory address is not "
-				 "correct");
-			fail = 1;
-		}
-		break;
-	case 3:
-		/*
-		 * This time the shared memory is read only.  Read the value
-		 * and check that it is equal to the value set in last case,
-		 * because shared memory is persistent.
-		 */
-
-		if (*shared != CASE1) {
-			tst_resm(TFAIL, "shared memory value isn't correct");
-			fail = 1;
-		}
-		break;
+	if (expected_addr(*tc->shmaddr, addr) != addr) {
+		tst_res(TFAIL,
+			"shared memory address %p is not correct, expected %p",
+			addr, expected_addr(*tc->shmaddr, addr));
+		goto end;
 	}
 
-	if (!fail)
-		tst_resm(TPASS, "conditions and functionality are correct");
+	pid = SAFE_FORK();
+	if (!pid)
+		do_child(addr, tc->exp_status == SIGSEGV);
+	else
+		SAFE_WAITPID(pid, &status, 0);
+
+	if (expected_status(status, tc->exp_status))
+		tst_res(TFAIL, "shmat() failed to attach %s", tc->desp);
+	else
+		tst_res(TPASS, "shmat() succeeded to attach %s", tc->desp);
+
+end:
+	SAFE_SHMDT(addr);
 }
 
-void setup(void)
+static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	aligned_addr = PROBE_FREE_ADDR();
+	unaligned_addr = aligned_addr + SHMLBA - 1;
 
-	TEST_PAUSE;
+	shm_key = GETIPCKEY();
 
-	TC = malloc(TST_TOTAL * sizeof(struct test_case_t));
-	if (TC == NULL)
-		tst_brkm(TFAIL | TERRNO, cleanup, "failed to allocate memory");
-
-	/* set NULL as attaching address*/
-	TC[0].shmid = &shm_id_1;
-	TC[0].offset = 0;
-	TC[0].flags = 0;
-	TC[0].getbase = 0;
-
-	/* a straight forward read/write attach */
-	TC[1].shmid = &shm_id_1;
-	TC[1].offset = 0;
-	TC[1].flags = 0;
-	TC[1].getbase = 1;
-
-	/* an attach using unaligned memory */
-	TC[2].shmid = &shm_id_1;
-	TC[2].offset = SHMLBA - 1;
-	TC[2].flags = SHM_RND;
-	TC[2].getbase = 1;
-
-	/* a read only attach */
-	TC[3].shmid = &shm_id_1;
-	TC[3].offset = 0;
-	TC[3].flags = SHM_RDONLY;
-	TC[3].getbase = 1;
-
-	tst_tmpdir();
-
-	shmkey = getipckey();
-
-	shm_id_1 = shmget(shmkey++, INT_SIZE, SHM_RW | IPC_CREAT | IPC_EXCL);
-	if (shm_id_1 == -1)
-		tst_brkm(TBROK, cleanup, "Failed to create shared memory "
-			 "resource 1 in setup()");
+	shm_id = SAFE_SHMGET(shm_key, INT_SIZE, SHM_RW | IPC_CREAT | IPC_EXCL);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	rm_shm(shm_id_1);
-
-	if (TC != NULL)
-		free(TC);
-
-	tst_rmdir();
+	if (shm_id != -1)
+		SAFE_SHMCTL(shm_id, IPC_RMID, NULL);
 }
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_shmat,
+	.tcnt = ARRAY_SIZE(tcases)
+};
diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat02.c b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
index d6355f7..046a940 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat02.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
@@ -1,189 +1,120 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
  *
- *   Copyright (c) International Business Machines  Corp., 2001
+ * 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 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.
  *
- *   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
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  */
 
 /*
- * NAME
- *	shmat02.c
- *
  * DESCRIPTION
- *	shmat02 - check for EINVAL and EACCES errors
  *
- * ALGORITHM
- *	loop if that option was specified
- *	  call shmat() using three invalid test cases
- *	  check the errno value
- *	    issue a PASS message if we get EINVAL or EACCES
- *	  otherwise, the tests fails
- *	    issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  shmat02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	03/2001 - Written by Wayne Boyer
- *
- *      27/02/2008 Renaud Lottiaux (Renaud.Lottiaux@kerlabs.com)
- *      - Fix concurrency issue. The second key used for this test could
- *        conflict with the key from another task.
- *
- * RESTRICTIONS
- *	Must be ran as non-root
+ * 1) shmat() fails and set errno to EINVAL when shmid is invalid.
+ * 2) shmat() fails and set errno to EINVAL when shmaddr is not page
+ *    aligned and SHM_RND is not given
+ * 3) shmat() fails and set errno to EACCES when the shm resource has
+ *    no read/write permission.
  */
 
-#include "ipcshm.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
 #include <pwd.h>
-#include "shmat_common.h"
 
-char *TCID = "shmat02";
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-int shm_id_1 = -1;
-int shm_id_2 = -1;
-int shm_id_3 = -1;
+static int shm_id1 = -1;
+static int shm_id2 = -1;
+static void *aligned_addr;
+static void *unaligned_addr;
+static key_t shm_key1;
+static struct passwd *pw;
 
-void *base_addr;		/* By probing this address first, we can make
-				 * non-aligned addresses from it for different
-				 * architectures without explicitly code it.
-				 */
-
-void *addr;			/* for result of shmat-call */
-
-struct test_case_t {
+static struct test_case_t {
 	int *shmid;
-	int offset;
-	int error;
+	void **shmaddr;
+	int exp_err;
+	int exp_user;
+} tcases[] = {
+	{&shm_id1, &aligned_addr, EINVAL, 0},
+	{&shm_id2, &unaligned_addr, EINVAL, 0},
+	{&shm_id2, &aligned_addr, EACCES, 1},
 };
 
-int TST_TOTAL = 3;
-
-static void setup_tc(int i, struct test_case_t *tc)
+static void verify_shmat(struct test_case_t *tc)
 {
+	void *addr;
 
-	struct test_case_t TC[] = {
-		/* EINVAL - the shared memory ID is not valid */
-		{&shm_id_1, 0, EINVAL},
-		/* EINVAL - the address is not page aligned and SHM_RND is not given */
-		{&shm_id_2, SHMLBA - 1, EINVAL},
-		/* EACCES - the shared memory resource has no read/write permission */
-		{&shm_id_3, 0, EACCES}
-	};
-
-	if (i > TST_TOTAL || i < 0)
+	addr = shmat(*tc->shmid, *tc->shmaddr, 0);
+	if (addr != (void *)-1) {
+		tst_res(TFAIL, "shmat() succeeded unexpectedly");
 		return;
-
-	*tc = TC[i];
-}
-
-int main(int ac, char **av)
-{
-	int lc;
-	int i;
-	struct test_case_t *tc;
-
-	tc = NULL;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	tc = malloc(sizeof(struct test_case_t));
-	if (tc == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "malloc failed");
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			setup_tc(i, tc);
-
-			base_addr = probe_free_addr();
-			errno = 0;
-			addr = shmat(*(tc->shmid), base_addr + tc->offset, 0);
-
-			if (addr != (void *)-1) {
-				tst_resm(TFAIL, "call succeeded unexpectedly");
-				continue;
-			}
-
-			if (errno == tc->error)
-				tst_resm(TPASS | TERRNO,
-					 "shmat failed as expected");
-			else
-				tst_resm(TFAIL,
-					 "shmat failed unexpectedly; expected: "
-					 "%d - %s", tc->error,
-					 strerror(tc->error));
-		}
 	}
 
-	cleanup();
-
-	tst_exit();
+	if (errno == tc->exp_err) {
+		tst_res(TPASS | TERRNO, "shmat() failed as expected");
+	} else {
+		tst_res(TFAIL | TERRNO, "shmat() failed unexpectedly,"
+			 "expected: %s", tst_strerrno(tc->exp_err));
+	}
 }
 
-void setup(void)
+static void do_shmat(unsigned int n)
 {
-	key_t shmkey2;
+	pid_t pid;
 
-	tst_require_root();
-	ltpuser = getpwnam(nobody_uid);
-	if (ltpuser == NULL)
-		tst_brkm(TBROK | TERRNO, NULL, "getpwnam failed");
-	if (setuid(ltpuser->pw_uid) == -1)
-		tst_brkm(TBROK | TERRNO, NULL, "setuid failed");
+	struct test_case_t *tc = &tcases[n];
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	shmkey = getipckey();
-
-	shm_id_2 = shmget(shmkey, INT_SIZE, SHM_RW | IPC_CREAT | IPC_EXCL);
-	if (shm_id_2 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget #1 failed");
-
-	/* Get an new IPC resource key. */
-	shmkey2 = getipckey();
-
-	/* create a shared memory resource without read and write permissions */
-	shm_id_3 = shmget(shmkey2, INT_SIZE, IPC_CREAT | IPC_EXCL);
-	if (shm_id_3 == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "shmget #2 failed");
+	if (!tc->exp_user) {
+		verify_shmat(tc);
+	} else {
+		pid = SAFE_FORK();
+		if (pid) {
+			tst_reap_children();
+		} else {
+			SAFE_SETUID(pw->pw_uid);
+			verify_shmat(tc);
+			exit(0);
+		}
+	}
 }
 
-void cleanup(void)
+static void setup(void)
 {
-	/* if they exist, remove the shared memory resources */
-	rm_shm(shm_id_2);
-	rm_shm(shm_id_3);
+	aligned_addr = PROBE_FREE_ADDR();
+	unaligned_addr = aligned_addr + SHMLBA - 1;
 
-	tst_rmdir();
+	shm_key1 = GETIPCKEY();
 
+	shm_id2 = SAFE_SHMGET(shm_key1, INT_SIZE, SHM_RW | IPC_CREAT | IPC_EXCL);
+
+	pw = SAFE_GETPWNAM("nobody");
 }
+
+static void cleanup(void)
+{
+	if (shm_id2 != -1)
+		SAFE_SHMCTL(shm_id2, IPC_RMID, NULL);
+}
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.forks_child = 1,
+	.test = do_shmat,
+	.tcnt = ARRAY_SIZE(tcases),
+	.setup = setup,
+	.cleanup = cleanup
+};
diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat03.c b/testcases/kernel/syscalls/ipc/shmat/shmat03.c
deleted file mode 100644
index 266ea1c..0000000
--- a/testcases/kernel/syscalls/ipc/shmat/shmat03.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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
- */
-
-/*
- * NAME
- *	shmat03.c
- *
- * DESCRIPTION
- *	shmat03 - test for EACCES error
- *
- * ALGORITHM
- *	create a shared memory segment with root only read & write permissions
- *	fork a child process
- *	if child
- *	  set the ID of the child process to that of "nobody"
- *	  loop if that option was specified
- *	    call shmat() using the TEST() macro
- *	    check the errno value
- *	      issue a PASS message if we get EACCES
- *	    otherwise, the tests fails
- *	      issue a FAIL message
- *	  call cleanup
- *	if parent
- *	  wait for child to exit
- *	  remove the shared memory segment
- *
- * USAGE:  <for command-line>
- *  shmat03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	03/2001 - Written by Wayne Boyer
- *
- * RESTRICTIONS
- *	test must be run at root
- */
-
-#include "ipcshm.h"
-
-char *TCID = "shmat03";
-int TST_TOTAL = 1;
-
-int shm_id_1 = -1;
-
-void *addr;			/* for result of shmat-call */
-
-uid_t ltp_uid;
-char *ltp_user = "nobody";
-
-static void do_child(void);
-
-int main(int ac, char **av)
-{
-	int pid;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global setup */
-
-	pid = FORK_OR_VFORK();
-	if (pid == -1)
-		tst_brkm(TBROK, cleanup, "could not fork");
-
-	if (pid == 0) {		/* child */
-		/* set the user ID of the child to the non root user */
-		if (setuid(ltp_uid) == -1) {
-			perror("setuid() failed");
-			exit(1);
-		}
-
-		do_child();
-
-	} else {		/* parent */
-		/* wait for the child to return */
-		if (waitpid(pid, NULL, 0) == -1)
-			tst_brkm(TBROK, cleanup, "waitpid failed");
-
-		/* if it exists, remove the shared memory resource */
-		rm_shm(shm_id_1);
-
-		tst_rmdir();
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-/*
- * do_child - make the TEST call as the child process
- */
-static void do_child(void)
-{
-	int lc;
-
-	/* The following loop checks looping state if -i option given */
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		/*
-		 * use TEST macro to make the call
-		 */
-		errno = 0;
-		addr = shmat(shm_id_1, NULL, 0);
-		TEST_ERRNO = errno;
-
-		if (addr != (char *)-1) {
-			tst_resm(TFAIL, "call succeeded unexpectedly");
-			continue;
-		}
-
-		switch (TEST_ERRNO) {
-		case EACCES:
-			tst_resm(TPASS | TTERRNO, "expected failure");
-			break;
-		default:
-			tst_resm(TFAIL | TTERRNO,
-				 "call failed with an unexpected error");
-			break;
-		}
-	}
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-	tst_require_root();
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	/*
-	 * Create a temporary directory and cd into it.
-	 * This helps to ensure that a unique msgkey is created.
-	 * See ../lib/libipc.c for more information.
-	 */
-	tst_tmpdir();
-
-	/* get an IPC resource key */
-	shmkey = getipckey();
-
-	/* create a shared memory segment with read and write permissions */
-	shm_id_1 = shmget(shmkey, SHM_SIZE, SHM_RW | IPC_CREAT | IPC_EXCL);
-	if (shm_id_1 == -1)
-		tst_brkm(TBROK, cleanup, "Failed to create shared memory "
-			 "segment in setup");
-
-	/* get the userid for a non root user */
-	ltp_uid = getuserid(ltp_user);
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- *		or premature exit.
- */
-void cleanup(void)
-{
-
-}
diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat_common.h b/testcases/kernel/syscalls/ipc/shmat/shmat_common.h
deleted file mode 100644
index 06cf5ab..0000000
--- a/testcases/kernel/syscalls/ipc/shmat/shmat_common.h
+++ /dev/null
@@ -1,33 +0,0 @@
-static key_t probe_key;
-
-void *probe_free_addr(void)
-{
-	void *p;
-	int ret;
-	int shm_id = -1;
-
-	if (probe_key == 0)
-		probe_key = getipckey();
-
-	/* create a shared memory resource with read and write permissions
-	 * We align this to SHMLBA so we should allocate at least
-	 * SHMLBA*2 in case SHMLBA > page_size. */
-	shm_id = shmget(probe_key, SHMLBA*2, SHM_RW | IPC_CREAT | IPC_EXCL);
-	if (shm_id == -1)
-		tst_brkm(TBROK, cleanup, "probe: shmget failed");
-
-	/* Probe an available linear address for attachment */
-	p = shmat(shm_id, NULL, 0);
-	if (p == (void *)-1)
-		tst_brkm(TBROK, cleanup, "probe: shmat failed");
-	ret = shmdt(p);
-	if (ret == -1)
-		tst_brkm(TBROK, cleanup, "probe: shmdt failed");
-
-	rm_shm(shm_id);
-
-	/* some architectures (e.g. parisc) are strange, so better always
-	 * align to next SHMLBA address. */
-	p = (void *)(((unsigned long)(p) + (SHMLBA - 1)) & ~(SHMLBA - 1));
-	return p;
-}
diff --git a/testcases/kernel/syscalls/kcmp/Makefile b/testcases/kernel/syscalls/kcmp/Makefile
index 083a071..cb8a3de 100644
--- a/testcases/kernel/syscalls/kcmp/Makefile
+++ b/testcases/kernel/syscalls/kcmp/Makefile
@@ -21,4 +21,6 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+CFLAGS += -Wl,-z,now
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/kcmp/kcmp.h b/testcases/kernel/syscalls/kcmp/kcmp.h
index ab50d4b..59371fc 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp.h
+++ b/testcases/kernel/syscalls/kcmp/kcmp.h
@@ -21,7 +21,7 @@
 
 #include <sys/types.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_ENUM_KCMP_TYPE)
 
diff --git a/testcases/kernel/syscalls/kcmp/kcmp01.c b/testcases/kernel/syscalls/kcmp/kcmp01.c
index 0aa4da6..1143ad6 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp01.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp01.c
@@ -111,7 +111,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "kcmp01",
 	.tcnt = ARRAY_SIZE(test_cases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/kcmp/kcmp02.c b/testcases/kernel/syscalls/kcmp/kcmp02.c
index ad0b09d..33f132f 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp02.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp02.c
@@ -103,7 +103,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "kcmp02",
 	.tcnt = ARRAY_SIZE(test_cases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
index d64ea2c..b6ca40c 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp03.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
@@ -95,7 +95,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "kcmp03",
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/keyctl/Makefile b/testcases/kernel/syscalls/keyctl/Makefile
index bb3d3a4..9ccb357 100644
--- a/testcases/kernel/syscalls/keyctl/Makefile
+++ b/testcases/kernel/syscalls/keyctl/Makefile
@@ -18,9 +18,9 @@
 
 top_srcdir		?= ../../../..
 
-keyctl02: LDLIBS	+=-lpthread $(KEYUTILS_LIBS)
-keyctl03: LDLIBS	+=$(KEYUTILS_LIBS)
-
 include $(top_srcdir)/include/mk/testcases.mk
 
+LDLIBS	+= $(KEYUTILS_LIBS)
+keyctl02: LDLIBS	+= -lpthread
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/keyctl/keyctl01.c b/testcases/kernel/syscalls/keyctl/keyctl01.c
index 30503ff..5719d55 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl01.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl01.c
@@ -1,121 +1,65 @@
-/******************************************************************************
- * Copyright (c) Crackerjack Project., 2007				      *
- *									      *
- * 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           *
- *                                                                            *
- ******************************************************************************/
+/*
+ * Copyright (c) Crackerjack Project., 2007
+ * Copyright (c) 2017 Fujitsu Ltd.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
 /*
  * Description: This tests the keyctl() syscall
  *		Manipulate the kernel's key management facility
  *
- * History:     Porting from Crackerjack to LTP is done by
- *	      Manas Kumar Nayak maknayak@in.ibm.com>
+ * Ported by Manas Kumar Nayak maknayak@in.ibm.com>
+ * Modified by Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  */
 
-#include "config.h"
-#include <sys/types.h>
 #include <errno.h>
-#include <limits.h>
-#include <stdio.h>
 #include <stdint.h>
-#ifdef HAVE_LINUX_KEYCTL_H
-# include <linux/keyctl.h>
-#endif
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
+#include "lapi/keyctl.h"
 
-char *TCID = "keyctl01";
-int testno;
-int TST_TOTAL = 2;
-
-#ifdef HAVE_LINUX_KEYCTL_H
-
-static void cleanup(void)
+static void do_test(void)
 {
-	tst_rmdir();
-}
+	key_serial_t key;
 
-static void setup(void)
-{
-	TEST_PAUSE;
-	tst_tmpdir();
-}
+	TEST(keyctl(KEYCTL_GET_KEYRING_ID, KEY_SPEC_USER_SESSION_KEYRING));
+	if (TEST_RETURN != -1)
+		tst_res(TPASS, "KEYCTL_GET_KEYRING_ID succeeded");
+	else
+		tst_res(TFAIL | TTERRNO, "KEYCTL_GET_KEYRING_ID failed");
 
-int main(int ac, char **av)
-{
-	int ret;
-	int lc;
-	int32_t ne_key;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (testno = 1; testno < TST_TOTAL; ++testno) {
-
-			/* Call keyctl() and ask for a keyring's ID. */
-			ret = ltp_syscall(__NR_keyctl, KEYCTL_GET_KEYRING_ID,
-				      KEY_SPEC_USER_SESSION_KEYRING);
-			if (ret != -1) {
-				tst_resm(TPASS,
-					 "KEYCTL_GET_KEYRING_ID succeeded");
-			} else {
-				tst_resm(TFAIL | TERRNO,
-					 "KEYCTL_GET_KEYRING_ID");
-			}
-
-			for (ne_key = INT32_MAX; ne_key > INT32_MIN; ne_key--) {
-				ret = ltp_syscall(__NR_keyctl, KEYCTL_READ,
-					ne_key);
-				if (ret == -1 && errno == ENOKEY)
-					break;
-			}
-
-			/* Call keyctl. */
-			ret = ltp_syscall(__NR_keyctl, KEYCTL_REVOKE, ne_key);
-			if (ret != -1) {
-				tst_resm(TFAIL | TERRNO,
-					 "KEYCTL_REVOKE succeeded unexpectedly");
-			} else {
-				/* Check for the correct error num. */
-				if (errno == ENOKEY) {
-					tst_resm(TPASS | TERRNO,
-						 "KEYCTL_REVOKE got expected "
-						 "errno");
-				} else {
-					tst_resm(TFAIL | TERRNO,
-						 "KEYCTL_REVOKE got unexpected "
-						 "errno");
-				}
-
-			}
-
-		}
-
+	for (key = INT32_MAX; key > INT32_MIN; key--) {
+		TEST(keyctl(KEYCTL_READ, key));
+		if (TEST_RETURN == -1 && TEST_ERRNO == ENOKEY)
+			break;
 	}
-	cleanup();
-	tst_exit();
+
+	TEST(keyctl(KEYCTL_REVOKE, key));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "KEYCTL_REVOKE succeeded unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO != ENOKEY) {
+		tst_res(TFAIL | TTERRNO, "KEYCTL_REVOKE failed unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "KEYCTL_REVOKE failed as expected");
 }
-#else
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "keyctl syscall support not available on system");
-}
-#endif /* HAVE_LINUX_KEYCTL_H */
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
diff --git a/testcases/kernel/syscalls/keyctl/keyctl02.c b/testcases/kernel/syscalls/keyctl/keyctl02.c
index aa98822..515da96 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl02.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl02.c
@@ -35,17 +35,13 @@
  *  KEYS: Fix race between read and revoke
  */
 
-#include "config.h"
 #include <errno.h>
 #include <pthread.h>
 #include <sys/types.h>
-#ifdef HAVE_KEYUTILS_H
-# include <keyutils.h>
-#endif
+
 #include "tst_safe_pthread.h"
 #include "tst_test.h"
-
-#ifdef HAVE_KEYUTILS_H
+#include "lapi/keyctl.h"
 
 #define LOOPS	20000
 #define PATH_KEY_COUNT_QUOTA	"/proc/sys/kernel/keys/root_maxkeys"
@@ -114,13 +110,8 @@
 }
 
 static struct tst_test test = {
-	.tid = "keyctl02",
 	.needs_root = 1,
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = do_test,
 };
-
-#else
-	TST_TEST_TCONF("keyutils.h does not exist");
-#endif /* HAVE_KEYUTILS_H */
diff --git a/testcases/kernel/syscalls/keyctl/keyctl03.c b/testcases/kernel/syscalls/keyctl/keyctl03.c
index 83d5dcb..5c066f7 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl03.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl03.c
@@ -28,15 +28,11 @@
  *        an uninstantiated keyring
  */
 
-#include "config.h"
 #include <errno.h>
 #include <sys/types.h>
-#ifdef HAVE_KEYUTILS_H
-# include <keyutils.h>
-#endif
-#include "tst_test.h"
 
-#ifdef HAVE_KEYUTILS_H
+#include "tst_test.h"
+#include "lapi/keyctl.h"
 
 static void do_test(void)
 {
@@ -56,10 +52,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "keyctl03",
 	.test_all = do_test,
 };
-
-#else
-	TST_TEST_TCONF("keyutils.h does not exist");
-#endif /* HAVE_KEYUTILS_H */
diff --git a/testcases/kernel/syscalls/keyctl/keyctl04.c b/testcases/kernel/syscalls/keyctl/keyctl04.c
new file mode 100644
index 0000000..be9ceeb
--- /dev/null
+++ b/testcases/kernel/syscalls/keyctl/keyctl04.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Google, Inc.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Regression test for commit c9f838d104fe ("KEYS: fix
+ * keyctl_set_reqkey_keyring() to not leak thread keyrings"), a.k.a.
+ * CVE-2017-7472.  This bug could be used to exhaust kernel memory, though it
+ * would take a while to do that and it would grind the test suite to a halt.
+ * Instead we do a quick check for whether the existing thread keyring is
+ * replaced when the default request-key destination is set to the thread
+ * keyring.  It shouldn't be, but before the fix it was (and the old thread
+ * keyring was leaked).
+ */
+
+#include <errno.h>
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+
+static void do_test(void)
+{
+	key_serial_t tid_keyring;
+
+	TEST(keyctl(KEYCTL_GET_KEYRING_ID, KEY_SPEC_THREAD_KEYRING, 1));
+	if (TEST_RETURN < 0)
+		tst_brk(TBROK | TTERRNO, "failed to create thread keyring");
+	tid_keyring = TEST_RETURN;
+
+	TEST(keyctl(KEYCTL_SET_REQKEY_KEYRING, KEY_REQKEY_DEFL_THREAD_KEYRING));
+	if (TEST_RETURN < 0)
+		tst_brk(TBROK | TTERRNO, "failed to set reqkey keyring");
+
+	TEST(keyctl(KEYCTL_GET_KEYRING_ID, KEY_SPEC_THREAD_KEYRING, 0));
+	if (TEST_RETURN < 0)
+		tst_brk(TBROK | TTERRNO, "failed to get thread keyring ID");
+	if (TEST_RETURN == tid_keyring)
+		tst_res(TPASS, "thread keyring was not leaked");
+	else
+		tst_res(TFAIL, "thread keyring was leaked!");
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
diff --git a/testcases/kernel/syscalls/keyctl/keyctl05.c b/testcases/kernel/syscalls/keyctl/keyctl05.c
new file mode 100644
index 0000000..9ba6120
--- /dev/null
+++ b/testcases/kernel/syscalls/keyctl/keyctl05.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2017 Google, Inc.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Regression test for commit 63a0b0509e70 ("KEYS: fix freeing uninitialized
+ * memory in key_update()").  Try to reproduce the crash in two different ways:
+ *
+ * 1. Try to update a key of a type that has a ->preparse() method but not an
+ *    ->update() method.  Examples are the "asymmetric" and "dns_resolver" key
+ *    types.  It crashes reliably for the "asymmetric" key type, since the
+ *    "asymmetric" key type's ->free_preparse() method will dereference a
+ *    pointer in the uninitialized memory, whereas other key types often just
+ *    free a pointer which tends be NULL in practice, depending on how the stack
+ *    is laid out.  However, to actually be able to add an "asymmetric" key, we
+ *    need a specially-formatted payload and several kernel config options.  We
+ *    do try it, but for completeness we also try the "dns_resolver" key type
+ *    (though that's not guaranteed to be available either).
+ *
+ * 2. Race keyctl_update() with another task removing write permission from the
+ *    key using keyctl_setperm().  This can cause a crash with almost any key
+ *    type.  "user" is a good one to try, since it's always available if
+ *    keyrings are supported at all.  However, depending on how the stack is
+ *    laid out the crash may not actually occur.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include "tst_test.h"
+#include "lapi/keyctl.h"
+
+#define KEY_POS_WRITE	0x04000000
+#define KEY_POS_ALL	0x3f000000
+
+/*
+ * A valid payload for the "asymmetric" key type.  This is an x509 certificate
+ * in DER format, generated using:
+ *
+ *	openssl req -x509 -newkey rsa:512 -batch -nodes -outform der \
+ *		| ~/linux/scripts/bin2c
+ */
+static const char x509_cert[] =
+	"\x30\x82\x01\xd3\x30\x82\x01\x7d\xa0\x03\x02\x01\x02\x02\x09\x00"
+	"\x92\x2a\x76\xff\x0c\x00\xfb\x9a\x30\x0d\x06\x09\x2a\x86\x48\x86"
+	"\xf7\x0d\x01\x01\x0b\x05\x00\x30\x45\x31\x0b\x30\x09\x06\x03\x55"
+	"\x04\x06\x13\x02\x41\x55\x31\x13\x30\x11\x06\x03\x55\x04\x08\x0c"
+	"\x0a\x53\x6f\x6d\x65\x2d\x53\x74\x61\x74\x65\x31\x21\x30\x1f\x06"
+	"\x03\x55\x04\x0a\x0c\x18\x49\x6e\x74\x65\x72\x6e\x65\x74\x20\x57"
+	"\x69\x64\x67\x69\x74\x73\x20\x50\x74\x79\x20\x4c\x74\x64\x30\x1e"
+	"\x17\x0d\x31\x37\x30\x37\x32\x38\x32\x31\x34\x31\x33\x34\x5a\x17"
+	"\x0d\x31\x37\x30\x38\x32\x37\x32\x31\x34\x31\x33\x34\x5a\x30\x45"
+	"\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x41\x55\x31\x13\x30"
+	"\x11\x06\x03\x55\x04\x08\x0c\x0a\x53\x6f\x6d\x65\x2d\x53\x74\x61"
+	"\x74\x65\x31\x21\x30\x1f\x06\x03\x55\x04\x0a\x0c\x18\x49\x6e\x74"
+	"\x65\x72\x6e\x65\x74\x20\x57\x69\x64\x67\x69\x74\x73\x20\x50\x74"
+	"\x79\x20\x4c\x74\x64\x30\x5c\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7"
+	"\x0d\x01\x01\x01\x05\x00\x03\x4b\x00\x30\x48\x02\x41\x00\xde\x0b"
+	"\x1c\x24\xe2\x0d\xf8\x17\xf2\xc3\x6f\xc9\x72\x3e\x9d\xb0\x2d\x47"
+	"\xe4\xc4\x85\x87\xed\xde\x06\xe3\xf3\xe9\x4c\x35\x6c\xe4\xcb\x0e"
+	"\x44\x28\x23\x66\x76\xec\x4e\xdf\x10\x93\x92\x1e\x52\xfb\xdf\x5c"
+	"\x08\xe7\x24\x04\x66\xe3\x06\x05\x27\x56\xfb\x3e\x91\x31\x02\x03"
+	"\x01\x00\x01\xa3\x50\x30\x4e\x30\x1d\x06\x03\x55\x1d\x0e\x04\x16"
+	"\x04\x14\x6f\x39\x3a\x46\xdf\x29\x63\xde\x54\x7b\x6c\x31\x06\xd0"
+	"\x9f\x36\x16\xfb\x9c\xbf\x30\x1f\x06\x03\x55\x1d\x23\x04\x18\x30"
+	"\x16\x80\x14\x6f\x39\x3a\x46\xdf\x29\x63\xde\x54\x7b\x6c\x31\x06"
+	"\xd0\x9f\x36\x16\xfb\x9c\xbf\x30\x0c\x06\x03\x55\x1d\x13\x04\x05"
+	"\x30\x03\x01\x01\xff\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01"
+	"\x01\x0b\x05\x00\x03\x41\x00\x73\xf0\x4b\x62\x56\xed\xf0\x8b\x7e"
+	"\xc4\x75\x78\x98\xa2\x7a\x6e\x75\x1f\xde\x9b\xa0\xbe\x1a\x1f\x86"
+	"\x44\x13\xcd\x45\x06\x7f\x86\xde\xf6\x36\x4e\xb6\x15\xfa\xf5\xb0"
+	"\x34\xd2\x5e\x0b\xb3\x2c\x03\x5a\x5a\x28\x97\x5e\x7b\xdf\x63\x75"
+	"\x83\x8d\x69\xda\xd6\x59\xbd"
+	;
+
+static void new_session_keyring(void)
+{
+	TEST(keyctl(KEYCTL_JOIN_SESSION_KEYRING, NULL));
+	if (TEST_RETURN < 0)
+		tst_brk(TBROK | TTERRNO, "failed to join new session keyring");
+}
+
+static void test_update_nonupdatable(const char *type,
+				     const void *payload, size_t plen)
+{
+	key_serial_t keyid;
+
+	new_session_keyring();
+
+	TEST(add_key(type, "desc", payload, plen, KEY_SPEC_SESSION_KEYRING));
+	if (TEST_RETURN < 0) {
+		if (TEST_ERRNO == ENODEV) {
+			tst_res(TCONF, "kernel doesn't support key type '%s'",
+				type);
+			return;
+		}
+		if (TEST_ERRNO == EBADMSG && !strcmp(type, "asymmetric")) {
+			tst_res(TCONF, "kernel is missing x509 cert parser "
+				"(CONFIG_X509_CERTIFICATE_PARSER)");
+			return;
+		}
+		if (TEST_ERRNO == ENOENT && !strcmp(type, "asymmetric")) {
+			tst_res(TCONF, "kernel is missing crypto algorithms "
+				"needed to parse x509 cert (CONFIG_CRYPTO_RSA "
+				"and/or CONFIG_CRYPTO_SHA256)");
+			return;
+		}
+		tst_res(TBROK | TTERRNO, "unexpected error adding '%s' key",
+			type);
+		return;
+	}
+	keyid = TEST_RETURN;
+
+	/*
+	 * Non-updatable keys don't start with write permission, so we must
+	 * explicitly grant it.
+	 */
+	TEST(keyctl(KEYCTL_SETPERM, keyid, KEY_POS_ALL));
+	if (TEST_RETURN != 0) {
+		tst_res(TBROK | TTERRNO,
+			"failed to grant write permission to '%s' key", type);
+		return;
+	}
+
+	tst_res(TINFO, "Try to update the '%s' key...", type);
+	TEST(keyctl(KEYCTL_UPDATE, keyid, payload, plen));
+	if (TEST_RETURN == 0) {
+		tst_res(TBROK,
+			"updating '%s' key unexpectedly succeeded", type);
+		return;
+	}
+	if (TEST_ERRNO != EOPNOTSUPP) {
+		tst_res(TBROK | TTERRNO,
+			"updating '%s' key unexpectedly failed", type);
+		return;
+	}
+	tst_res(TPASS, "updating '%s' key expectedly failed with EOPNOTSUPP",
+		type);
+}
+
+/*
+ * Try to update a key, racing with removing write permission.
+ * This may crash buggy kernels.
+ */
+static void test_update_setperm_race(void)
+{
+	static const char payload[] = "payload";
+	key_serial_t keyid;
+	int i;
+
+	new_session_keyring();
+
+	TEST(add_key("user", "desc", payload, sizeof(payload),
+		KEY_SPEC_SESSION_KEYRING));
+	if (TEST_RETURN < 0) {
+		tst_res(TBROK | TTERRNO, "failed to add 'user' key");
+		return;
+	}
+	keyid = TEST_RETURN;
+
+	if (SAFE_FORK() == 0) {
+		uint32_t perm = KEY_POS_ALL;
+
+		for (i = 0; i < 10000; i++) {
+			perm ^= KEY_POS_WRITE;
+			TEST(keyctl(KEYCTL_SETPERM, keyid, perm));
+			if (TEST_RETURN != 0)
+				tst_brk(TBROK | TTERRNO, "setperm failed");
+		}
+		exit(0);
+	}
+
+	tst_res(TINFO, "Try to update the 'user' key...");
+	for (i = 0; i < 10000; i++) {
+		TEST(keyctl(KEYCTL_UPDATE, keyid, payload, sizeof(payload)));
+		if (TEST_RETURN != 0 && TEST_ERRNO != EACCES) {
+			tst_res(TBROK | TTERRNO, "failed to update 'user' key");
+			return;
+		}
+	}
+	tst_reap_children();
+	tst_res(TPASS, "didn't crash while racing to update 'user' key");
+}
+
+static void do_test(unsigned int i)
+{
+	/* two 0 bytes is accepted as a dns_resolver key payload */
+	static char zeroes[2];
+
+	switch (i) {
+	case 0:
+		test_update_nonupdatable("asymmetric",
+					 x509_cert, sizeof(x509_cert));
+		break;
+	case 1:
+		test_update_nonupdatable("dns_resolver",
+					 zeroes, sizeof(zeroes));
+		break;
+	case 2:
+		test_update_setperm_race();
+		break;
+	}
+}
+
+static struct tst_test test = {
+	.tcnt = 3,
+	.test = do_test,
+	.forks_child = 1,
+};
diff --git a/testcases/kernel/syscalls/lgetxattr/lgetxattr01.c b/testcases/kernel/syscalls/lgetxattr/lgetxattr01.c
index 4a12f0a..301d532 100644
--- a/testcases/kernel/syscalls/lgetxattr/lgetxattr01.c
+++ b/testcases/kernel/syscalls/lgetxattr/lgetxattr01.c
@@ -105,7 +105,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "lgetxattr01",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test_all = verify_lgetxattr,
diff --git a/testcases/kernel/syscalls/lgetxattr/lgetxattr02.c b/testcases/kernel/syscalls/lgetxattr/lgetxattr02.c
index e50bd94..ebc28f2 100644
--- a/testcases/kernel/syscalls/lgetxattr/lgetxattr02.c
+++ b/testcases/kernel/syscalls/lgetxattr/lgetxattr02.c
@@ -95,7 +95,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "lgetxattr02",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_lgetxattr,
diff --git a/testcases/kernel/syscalls/linkat/linkat01.c b/testcases/kernel/syscalls/linkat/linkat01.c
index 6772a6b..cde0910 100644
--- a/testcases/kernel/syscalls/linkat/linkat01.c
+++ b/testcases/kernel/syscalls/linkat/linkat01.c
@@ -56,7 +56,7 @@
 #include <inttypes.h>
 #include <limits.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 
 #ifndef AT_FDCWD
diff --git a/testcases/kernel/syscalls/linkat/linkat02.c b/testcases/kernel/syscalls/linkat/linkat02.c
index 6766b5a..292d9f5 100644
--- a/testcases/kernel/syscalls/linkat/linkat02.c
+++ b/testcases/kernel/syscalls/linkat/linkat02.c
@@ -31,7 +31,7 @@
 #include <sys/mount.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 #include "lapi/fcntl.h"
 
diff --git a/testcases/kernel/syscalls/listxattr/listxattr01.c b/testcases/kernel/syscalls/listxattr/listxattr01.c
index 7ab3c1f..e2820ca 100644
--- a/testcases/kernel/syscalls/listxattr/listxattr01.c
+++ b/testcases/kernel/syscalls/listxattr/listxattr01.c
@@ -83,7 +83,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "listxattr01",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test_all = verify_listxattr,
diff --git a/testcases/kernel/syscalls/listxattr/listxattr02.c b/testcases/kernel/syscalls/listxattr/listxattr02.c
index fa73532..998689a 100644
--- a/testcases/kernel/syscalls/listxattr/listxattr02.c
+++ b/testcases/kernel/syscalls/listxattr/listxattr02.c
@@ -96,7 +96,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "listxattr02",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_listxattr,
diff --git a/testcases/kernel/syscalls/listxattr/listxattr03.c b/testcases/kernel/syscalls/listxattr/listxattr03.c
index 5536084..9dc7ad7 100644
--- a/testcases/kernel/syscalls/listxattr/listxattr03.c
+++ b/testcases/kernel/syscalls/listxattr/listxattr03.c
@@ -78,7 +78,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "listxattr03",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_listxattr,
diff --git a/testcases/kernel/syscalls/llistxattr/llistxattr01.c b/testcases/kernel/syscalls/llistxattr/llistxattr01.c
index 0176893..f997e0c 100644
--- a/testcases/kernel/syscalls/llistxattr/llistxattr01.c
+++ b/testcases/kernel/syscalls/llistxattr/llistxattr01.c
@@ -93,7 +93,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "llistxattr01",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test_all = verify_llistxattr,
diff --git a/testcases/kernel/syscalls/llistxattr/llistxattr02.c b/testcases/kernel/syscalls/llistxattr/llistxattr02.c
index 06b15d1..468ff98 100644
--- a/testcases/kernel/syscalls/llistxattr/llistxattr02.c
+++ b/testcases/kernel/syscalls/llistxattr/llistxattr02.c
@@ -97,7 +97,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "llistxattr02",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_llistxattr,
diff --git a/testcases/kernel/syscalls/llistxattr/llistxattr03.c b/testcases/kernel/syscalls/llistxattr/llistxattr03.c
index 6a1cb6b..91bb3f4 100644
--- a/testcases/kernel/syscalls/llistxattr/llistxattr03.c
+++ b/testcases/kernel/syscalls/llistxattr/llistxattr03.c
@@ -77,7 +77,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "llistxattr03",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_llistxattr,
diff --git a/testcases/kernel/syscalls/lseek/lseek01.c b/testcases/kernel/syscalls/lseek/lseek01.c
index a5f8524..2e1c36e 100644
--- a/testcases/kernel/syscalls/lseek/lseek01.c
+++ b/testcases/kernel/syscalls/lseek/lseek01.c
@@ -1,219 +1,102 @@
 /*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) International Business Machines  Corp., 2001
+ * 06/2017 modified by Xiao Yang <yangx.jy@cn.fujitsu.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
- *
+ * You should have received a copy of the GNU General Public License
+ * along with this program;  if not, see <http://www.gnu.org/licenses/>.
  */
-/* $Id: lseek01.c,v 1.5 2009/11/02 13:57:17 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: lseek01
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for lseek(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 3
- *
- *    WALL CLOCK TIME	: 1
- *
- *    CPU TYPES		: ALL
- *
- *    AUTHOR		: William Roske
- *
- *    CO-PILOT		: Dave Fenner
- *
- *    DATE STARTED	: 03/30/92
- *
- *    INITIAL RELEASE	: UNICOS 7.0
- *
- *    TEST CASES
- *
- * 	1.) lseek(2) returns...(See Description)
- *
- *    INPUT SPECIFICATIONS
- * 	The standard options for system call tests are accepted.
- *	(See the parse_opts(3) man page).
- *
- *    OUTPUT SPECIFICATIONS
- *$
- *    DURATION
- * 	Terminates - with frequency and infinite modes.
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    RESOURCES
- * 	None
- *
- *    ENVIRONMENTAL NEEDS
- *      No run-time environmental needs.
- *
- *    SPECIAL PROCEDURAL REQUIREMENTS
- * 	None
- *
- *    INTERCASE DEPENDENCIES
- * 	None
- *
- *    DETAILED DESCRIPTION
- *	This is a Phase I test for the lseek(2) system call.  It is intended
- *	to provide a limited exposure of the system call, for now.  It
- *	should/will be extended when full functional tests are written for
- *	lseek(2).
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
-#include <sys/types.h>
-#include <fcntl.h>
+/*
+ * Description:
+ *  lseek() succeeds to set the specified offset according to whence
+ *  and read valid data from this location.
+ */
+
 #include <errno.h>
 #include <string.h>
-#include <signal.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include "test.h"
+#include "tst_test.h"
 
-void setup();
-void cleanup();
+#define WRITE_STR "abcdefg"
+#define TFILE "tfile"
 
-char *TCID = "lseek01";
-int TST_TOTAL = 3;
+static int fd;
+static struct tcase {
+	off_t off;
+	int whence;
+	char *wname;
+	off_t exp_off;
+	ssize_t exp_size;
+	char *exp_data;
+} tcases[] = {
+	{4, SEEK_SET, "SEEK_SET", 4, 3, "efg"},
+	{-2, SEEK_CUR, "SEEK_CUR", 5, 2, "fg"},
+	{-4, SEEK_END, "SEEK_END", 3, 4, "defg"},
+	{0, SEEK_END, "SEEK_END", 7, 0, NULL},
+};
 
-char Fname[255];
-int Fd;
-
-int Whence[] = { SEEK_SET, SEEK_CUR, SEEK_END, -1 };
-
-int main(int ac, char **av)
+static void verify_lseek(unsigned int n)
 {
-	int lc;
+	char read_buf[64];
+	struct tcase *tc = &tcases[n];
 
-	int ind;
-	int offset;
+	// reset the offset to end of file
+	SAFE_READ(0, fd, read_buf, sizeof(read_buf));
 
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
-	tst_parse_opts(ac, av, NULL, NULL);
+	memset(read_buf, 0, sizeof(read_buf));
 
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
-	setup();
-
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		offset = (lc % 100) * 4096;	/* max size is 100 blocks */
-
-		for (ind = 0; Whence[ind] >= 0; ind++) {
-
-			/*
-			 *  Call lseek(2)
-			 */
-			TEST(lseek(Fd, (long)offset, Whence[ind]));
-
-			/* check return code */
-			if (TEST_RETURN == -1) {
-				tst_resm(TFAIL,
-					 "lseek(%s, %d, 0) Failed, errno=%d : %s",
-					 Fname, offset, TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TPASS,
-					 "lseek(%s, %d, %d) returned %ld",
-					 Fname, offset, Whence[ind],
-					 TEST_RETURN);
-			}
-		}
-
+	TEST(lseek(fd, tc->off, tc->whence));
+	if (TEST_RETURN == (off_t) -1) {
+		tst_res(TFAIL | TTERRNO, "lseek(%s, %ld, %s) failed", TFILE,
+			tc->off, tc->wname);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
-}
+	if (TEST_RETURN != tc->exp_off) {
+		tst_res(TFAIL, "lseek(%s, %ld, %s) returned %ld, expected %ld",
+			TFILE, tc->off, tc->wname, TEST_RETURN, tc->exp_off);
+		return;
+	}
 
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
-{
+	SAFE_READ(1, fd, read_buf, tc->exp_size);
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	sprintf(Fname, "tfile_%d", getpid());
-	if ((Fd = open(Fname, O_RDWR | O_CREAT, 0700)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
-			 Fname, errno, strerror(errno));
+	if (tc->exp_data && strcmp(read_buf, tc->exp_data)) {
+		tst_res(TFAIL, "lseek(%s, %ld, %s) read incorrect data",
+			TFILE, tc->off, tc->wname);
+	} else {
+		tst_res(TPASS, "lseek(%s, %ld, %s) read correct data",
+			TFILE, tc->off, tc->wname);
 	}
 }
 
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void setup(void)
 {
+	fd = SAFE_OPEN(TFILE, O_RDWR | O_CREAT, 0644);
 
-	/* close the file we have open */
-	if (close(Fd) == -1) {
-		tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", Fname, errno,
-			 strerror(errno));
-	}
-
-	tst_rmdir();
-
+	SAFE_WRITE(1, fd, WRITE_STR, sizeof(WRITE_STR) - 1);
 }
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_lseek,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/lseek/lseek02.c b/testcases/kernel/syscalls/lseek/lseek02.c
index 0efc691..66c7bee 100644
--- a/testcases/kernel/syscalls/lseek/lseek02.c
+++ b/testcases/kernel/syscalls/lseek/lseek02.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ * 06/2017 modified by Xiao Yang <yangx.jy@cn.fujitsu.com>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -17,189 +18,107 @@
  * other software, or any other product whatsoever.
  *
  * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
- *
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
-/* $Id: lseek02.c,v 1.5 2009/10/26 14:55:48 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: lseek02
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Negative test for lseek(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    WALL CLOCK TIME	: 1
- *
- *    CPU TYPES		: ALL
- *
- *    AUTHOR		: Richard Logan
- *
- *    CO-PILOT		: William Roske
- *
- *    DATE STARTED	: 04/25/94
- *
- *    INITIAL RELEASE	: UNICOS 7.0
- *
- *    TEST CASES
- *
- * 	1.) lseek(2) returns...(See Description)
- *
- *    INPUT SPECIFICATIONS
- * 	The standard options for system call tests are accepted.
- *	(See the parse_opts(3) man page).
- *
- *    OUTPUT SPECIFICATIONS
- *$
- *    DURATION
- * 	Terminates - with frequency and infinite modes.
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    RESOURCES
- * 	None
- *
- *    ENVIRONMENTAL NEEDS
- *      No run-time environmental needs.
- *
- *    SPECIAL PROCEDURAL REQUIREMENTS
- * 	None
- *
- *    INTERCASE DEPENDENCIES
- * 	None
- *
- *    DETAILED DESCRIPTION
- *	This is a Phase I test for the lseek(2) system call.  It is intended
- *	to provide a limited exposure of the system call, for now.  It
- *	should/will be extended when full functional tests are written for
- *	lseek(2).
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
-#include <sys/types.h>
-#include <fcntl.h>
+/*
+ * DESCRIPTION
+ * 1) lseek(2) fails and sets errno to EBADF when fd is invalid.
+ * 2) lseek(2) fails ans sets errno to EINVAL when whence is invalid.
+ * 3) lseek(2) fails and sets errno to ESPIPE when fd is associated
+ *    with a pipe or FIFO.
+ */
+
 #include <errno.h>
-#include <string.h>
-#include <signal.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include "test.h"
+#include <stdio.h>
+#include <sys/stat.h>
+#include "tst_test.h"
 
-void setup();
-void cleanup();
+#define TFILE "tfile"
+#define TFIFO1 "tfifo1"
+#define TFIFO2 "tfifo2"
 
-char *TCID = "lseek02";
-int TST_TOTAL = 1;
+static int bad_fd = -1;
+static int fd, pfd1, pfd2;
+static int pfds[2];
 
-char fname[255];
-int fd;
+static struct tcase {
+	int *fd;
+	int whence;
+	int exp_err;
+} tcases[] = {
+	{&bad_fd, SEEK_SET, EBADF},
+	{&bad_fd, SEEK_CUR, EBADF},
+	{&bad_fd, SEEK_END, EBADF},
+	{&fd, 5, EINVAL},
+	{&fd, -1, EINVAL},
+	{&fd, 7, EINVAL},
+	{&pfd1, SEEK_SET, ESPIPE},
+	{&pfd1, SEEK_CUR, ESPIPE},
+	{&pfd1, SEEK_END, ESPIPE},
+	{&pfds[0], SEEK_SET, ESPIPE},
+	{&pfds[0], SEEK_CUR, ESPIPE},
+	{&pfds[0], SEEK_END, ESPIPE},
+	{&pfd2, SEEK_SET, ESPIPE},
+	{&pfd2, SEEK_CUR, ESPIPE},
+	{&pfd2, SEEK_END, ESPIPE},
+};
 
-int Whence[] = { SEEK_SET, SEEK_CUR, SEEK_END, -1 };
-
-int main(int ac, char **av)
+static void verify_lseek(unsigned int n)
 {
-	int lc;
+	struct tcase *tc = &tcases[n];
 
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
-	tst_parse_opts(ac, av, NULL, NULL);
-
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
-	setup();
-
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 *  Call lseek(2)
-		 */
-		TEST(lseek(-1, (long)1, SEEK_SET));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			if (TEST_ERRNO == EBADF)
-
-				tst_resm(TPASS,
-					 "lseek(-1, 1, SEEK_SET) Failed, errno=%d : %s",
-					 TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			else
-				tst_resm(TFAIL,
-					 "lseek(-1, 1, SEEK_SET) Failed, errno=%d : %s, expected %d(EBADF)",
-					 TEST_ERRNO,
-					 strerror(TEST_ERRNO), EBADF);
-		} else {
-
-			tst_resm(TFAIL, "lseek(-1, 1, SEEK_SET) returned %ld",
-				 TEST_RETURN);
-		}
-
+	TEST(lseek(*tc->fd, (off_t) 1, tc->whence));
+	if (TEST_RETURN != (off_t) -1) {
+		tst_res(TFAIL, "lseek(%d, 1, %d) succeeded unexpectedly",
+			*tc->fd, tc->whence);
+			return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO == tc->exp_err) {
+		tst_res(TPASS | TTERRNO, "lseek(%d, 1, %d) failed as expected",
+			*tc->fd, tc->whence);
+	} else {
+		tst_res(TFAIL | TTERRNO, "lseek(%d, 1, %d) failed "
+			"unexpectedly, expected %s", *tc->fd, tc->whence,
+			tst_strerrno(tc->exp_err));
+	}
 }
 
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
+static void setup(void)
 {
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
+	fd = SAFE_OPEN(TFILE, O_RDWR | O_CREAT, 0777);
+	SAFE_MKFIFO(TFIFO1, 0777);
+	pfd1 = SAFE_OPEN(TFIFO1, O_RDWR, 0777);
+	SAFE_PIPE(pfds);
+	SAFE_MKNOD(TFIFO2, S_IFIFO | 0777, 0);
+	pfd2 = SAFE_OPEN(TFIFO2, O_RDWR, 0777);
 }
 
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 
-	tst_rmdir();
+	if (pfd1 > 0)
+		SAFE_CLOSE(pfd1);
 
+	if (pfds[0] > 0)
+		SAFE_CLOSE(pfds[0]);
+
+	if (pfds[1] > 0)
+		SAFE_CLOSE(pfds[1]);
+
+	if (pfd2 > 0)
+		SAFE_CLOSE(pfd2);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_lseek,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/lseek/lseek03.c b/testcases/kernel/syscalls/lseek/lseek03.c
deleted file mode 100644
index 02b94fb..0000000
--- a/testcases/kernel/syscalls/lseek/lseek03.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- * Copyright (c) 2011 Cyril Hrubis <chrubis@suse.cz>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
- *
- */
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include "test.h"
-
-static void setup(void);
-static void cleanup(void);
-
-static char fname[255];
-static int fd;
-static int whences[] = { 5, -1, 7 };
-
-char *TCID = "lseek03";
-int TST_TOTAL = ARRAY_SIZE(whences);
-
-int main(int ac, char **av)
-{
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int i;
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			/* Call lseek(2) */
-			TEST(lseek(fd, (off_t) 1, whences[i]));
-
-			if (TEST_RETURN == -1) {
-				if (TEST_ERRNO == EINVAL) {
-					tst_resm(TPASS,
-						 "lseek(%s, 1, %d) Failed, errno=%d : %s",
-						 fname, whences[i],
-						 TEST_ERRNO,
-						 strerror(TEST_ERRNO));
-				} else {
-					tst_resm(TFAIL,
-						 "lseek(%s, 1, %d) Failed, errno=%d %s, expected %d(EINVAL)",
-						 fname, whences[i],
-						 TEST_ERRNO,
-						 strerror(TEST_ERRNO),
-						 EINVAL);
-				}
-			} else {
-				tst_resm(TFAIL, "lseek(%s, 1, %d) returned %ld",
-					 fname, whences[i], TEST_RETURN);
-			}
-		}
-
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	sprintf(fname, "tfile_%d", getpid());
-
-	if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
-			 fname, errno, strerror(errno));
-	}
-}
-
-void cleanup(void)
-{
-	if (close(fd) == -1) {
-		tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno,
-			 strerror(errno));
-	}
-
-	tst_rmdir();
-}
diff --git a/testcases/kernel/syscalls/lseek/lseek04.c b/testcases/kernel/syscalls/lseek/lseek04.c
deleted file mode 100644
index 9d431f0..0000000
--- a/testcases/kernel/syscalls/lseek/lseek04.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
- *
- */
-/* $Id: lseek04.c,v 1.5 2009/10/26 14:55:48 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: lseek04
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Negative test for lseek(2) of a fifo
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    WALL CLOCK TIME	: 1
- *
- *    CPU TYPES		: ALL
- *
- *    AUTHOR		: Richard Logan
- *
- *    CO-PILOT		: William Roske
- *
- *    DATE STARTED	: 04/25/94
- *
- *    INITIAL RELEASE	: UNICOS 7.0
- *
- *    TEST CASES
- *
- * 	1.) lseek(2) returns...(See Description)
- *
- *    INPUT SPECIFICATIONS
- * 	The standard options for system call tests are accepted.
- *	(See the parse_opts(3) man page).
- *
- *    OUTPUT SPECIFICATIONS
- *$
- *    DURATION
- * 	Terminates - with frequency and infinite modes.
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    RESOURCES
- * 	None
- *
- *    ENVIRONMENTAL NEEDS
- *      No run-time environmental needs.
- *
- *    SPECIAL PROCEDURAL REQUIREMENTS
- * 	None
- *
- *    INTERCASE DEPENDENCIES
- * 	None
- *
- *    DETAILED DESCRIPTION
- *	This is a Phase I test for the lseek(2) system call.  It is intended
- *	to provide a limited exposure of the system call, for now.  It
- *	should/will be extended when full functional tests are written for
- *	lseek(2).
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include "test.h"
-
-void setup();
-void cleanup();
-
-char *TCID = "lseek04";
-int TST_TOTAL = 1;
-
-char Fname[255];
-int Fd;
-
-int main(int ac, char **av)
-{
-	int lc;
-
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
-	tst_parse_opts(ac, av, NULL, NULL);
-
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
-	setup();
-
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 *  Call lseek(2)
-		 */
-		TEST(lseek(Fd, (long)1, SEEK_SET));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			if (TEST_ERRNO == ESPIPE)
-				tst_resm(TPASS,
-					 "lseek(fifofd, 1, SEEK_SET) Failed, errno=%d : %s",
-					 TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			else
-				tst_resm(TFAIL,
-					 "lseek(fifofd, 1, SEEK_SET) Failed, errno=%d %s, expected %d(ESPIPE)",
-					 TEST_ERRNO,
-					 strerror(TEST_ERRNO), EINVAL);
-		} else {
-
-			tst_resm(TFAIL,
-				 "lseek(fifofd, 1, SEEK_SET) returned %ld",
-				 TEST_RETURN);
-		}
-
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	sprintf(Fname, "tfile_%d", getpid());
-	if (mkfifo(Fname, 0700) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "mkfifo(%s, 0700) Failed, errno=%d : %s",
-			 Fname, errno, strerror(errno));
-	}
-
-	if ((Fd = open(Fname, O_RDWR, 0777)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR, 0777) Failed, errno=%d : %s",
-			 Fname, errno, strerror(errno));
-	}
-}
-
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
-{
-
-	/* close the file we have open */
-	if (close(Fd) == -1) {
-		tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", Fname, errno,
-			 strerror(errno));
-	}
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/lseek/lseek05.c b/testcases/kernel/syscalls/lseek/lseek05.c
deleted file mode 100644
index 1eee03d..0000000
--- a/testcases/kernel/syscalls/lseek/lseek05.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
- *
- */
-/* $Id: lseek05.c,v 1.5 2009/10/26 14:55:48 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: lseek05
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Negative test for lseek(2) of a pipe
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    WALL CLOCK TIME	: 1
- *
- *    CPU TYPES		: ALL
- *
- *    AUTHOR		: Richard Logan
- *
- *    CO-PILOT		: William Roske
- *
- *    DATE STARTED	: 04/25/94
- *
- *    INITIAL RELEASE	: UNICOS 7.0
- *
- *    TEST CASES
- *
- * 	1.) lseek(2) returns...(See Description)
- *
- *    INPUT SPECIFICATIONS
- * 	The standard options for system call tests are accepted.
- *	(See the parse_opts(3) man page).
- *
- *    OUTPUT SPECIFICATIONS
- *$
- *    DURATION
- * 	Terminates - with frequency and infinite modes.
- *
- *    SIGNALS
- * 	Uses SIGUSR1 to pause before test if option set.
- * 	(See the parse_opts(3) man page).
- *
- *    RESOURCES
- * 	None
- *
- *    ENVIRONMENTAL NEEDS
- *      No run-time environmental needs.
- *
- *    SPECIAL PROCEDURAL REQUIREMENTS
- * 	None
- *
- *    INTERCASE DEPENDENCIES
- * 	None
- *
- *    DETAILED DESCRIPTION
- *	This is a Phase I test for the lseek(2) system call.  It is intended
- *	to provide a limited exposure of the system call, for now.  It
- *	should/will be extended when full functional tests are written for
- *	lseek(2).
- *
- * 	Setup:
- * 	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	 Loop if the proper options are given.
- * 	  Execute system call
- *	  Check return code, if system call failed (return=-1)
- *		Log the errno and Issue a FAIL message.
- *	  Otherwise, Issue a PASS message.
- *
- * 	Cleanup:
- * 	  Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include "test.h"
-
-void setup();
-void cleanup();
-
-char *TCID = "lseek05";
-int TST_TOTAL = 1;
-
-int Fd;
-
-/***********************************************************************
- * Main
- ***********************************************************************/
-int main(int ac, char **av)
-{
-	int lc;
-
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
-	tst_parse_opts(ac, av, NULL, NULL);
-
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
-	setup();
-
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 *  Call lseek(2)
-		 */
-		TEST(lseek(Fd, (long)1, SEEK_SET));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			if (TEST_ERRNO == ESPIPE)
-				tst_resm(TPASS,
-					 "lseek(pipefd, 1, SEEK_SET) Failed, errno=%d : %s",
-					 TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			else
-				tst_resm(TFAIL,
-					 "lseek(pipefd, 1, SEEK_SET) Failed, errno=%d %s, expected %d(ESPIPE)",
-					 TEST_ERRNO,
-					 strerror(TEST_ERRNO), EINVAL);
-		} else {
-
-			tst_resm(TFAIL,
-				 "lseek(pipefd, 1, SEEK_SET) returned %ld",
-				 TEST_RETURN);
-		}
-
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
-{
-	int fds[2];
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	if (pipe(fds) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "pipe(&fds) Failed, errno=%d : %s", errno,
-			 strerror(errno));
-	}
-	Fd = fds[0];
-
-}
-
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
-{
-
-	/* close the file we have open */
-	if (close(Fd) == -1) {
-		tst_resm(TWARN, "close(%d) Failed, errno=%d : %s", Fd, errno,
-			 strerror(errno));
-	}
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/lseek/lseek06.c b/testcases/kernel/syscalls/lseek/lseek06.c
deleted file mode 100644
index 056eb40..0000000
--- a/testcases/kernel/syscalls/lseek/lseek06.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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 Name: lseek06
- *
- * Test Description:
- *  Verify that, lseek() call succeeds to set the file pointer position
- *  to less  than  or equal to the file size, when a file is opened for
- *  read or write.
- *
- * Expected Result:
- *  lseek() should return the offset from the beginning of the file measured
- *  in bytes. Also check if able to read valid data from this location.
- * $
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Pause for SIGUSR1 if option specified.
- *   Create temporary directory.
- *
- *  Test:
- *   Loop if the proper options are given.
- *   Execute system call
- *   Check return code, if system call failed (return=-1)
- *   	Log the errno and Issue a FAIL message.
- *   Otherwise,
- *   	Verify the Functionality of system call
- *      if successful,
- *      	Issue Functionality-Pass message.
- *      Otherwise,
- *		Issue Functionality-Fail message.
- *  Cleanup:
- *   Print errno log and/or timing stats if options given
- *   Delete the temporary directory created.
- *
- * Usage:  <for command-line>
- *  lseek06 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS:
- *  None.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <signal.h>
-
-#include "test.h"
-
-#define OFFSET		4
-#define TEMP_FILE	"tmp_file"
-#define FILE_MODE	S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
-
-char *TCID = "lseek06";
-int TST_TOTAL = 1;
-int fildes;			/* file handle for temp file */
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
-{
-	int lc;
-	char read_buf[1];	/* data read from temp. file */
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Invoke lseek(2) to move the read/write file
-		 * pointer/handle by OFFSET bytes.
-		 */
-		TEST(lseek(fildes, OFFSET, SEEK_SET));
-
-		if (TEST_RETURN == (off_t) - 1) {
-			tst_resm(TFAIL, "lseek on (%s) Failed, errno=%d : %s",
-				 TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
-		/*
-		 * Check if the return value from lseek(2)
-		 * is equal to the specified OFFSET value.
-		 */
-		if (TEST_RETURN != OFFSET) {
-			tst_resm(TFAIL, "lseek() returned incorrect "
-				 "value %ld, expected %d",
-				 TEST_RETURN, OFFSET);
-			continue;
-		}
-		/*
-		 * The return value is good, now check data.
-		 * Read the data byte from this location.
-		 */
-		if (read(fildes, &read_buf, sizeof(read_buf)) < 0) {
-			tst_brkm(TFAIL, cleanup, "read() failed "
-				 "on %s, error=%d", TEMP_FILE, errno);
-		} else {
-			/*
-			 * Check if read byte is the expected character.
-			 * For pos 4 ---> 'e'
-			 */
-			if (read_buf[0] != 'e') {
-				tst_resm(TFAIL, "Incorrect data read "
-					 "from file %s", TEMP_FILE);
-			} else {
-				tst_resm(TPASS, "Functionality "
-					 "of lseek() on %s "
-					 "successful", TEMP_FILE);
-			}
-		}
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- *	     Create a temporary directory and change directory to it.
- *	     Create a test file under temporary directory and write some
- *	     data into it.
- */
-void setup(void)
-{
-	char write_buf[BUFSIZ];	/* buffer to hold data */
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	/* Get the data to be written to temporary file */
-	strcpy(write_buf, "abcdefg");
-
-	/* Creat/open a temporary file under above directory */
-	if ((fildes = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s",
-			 TEMP_FILE, FILE_MODE, errno, strerror(errno));
-	}
-
-	/* Write data into temporary file */
-	if (write(fildes, write_buf, strlen(write_buf)) != strlen(write_buf)) {
-		tst_brkm(TBROK, cleanup, "write(2) on %s Failed, errno=%d : %s",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- *	       Remove the test directory and testfile created in the setup.
- */
-void cleanup(void)
-{
-
-	/* Close the temporary file created */
-	if (close(fildes) < 0) {
-		tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/lseek/lseek07.c b/testcases/kernel/syscalls/lseek/lseek07.c
index 6dfcab5..b46856b 100644
--- a/testcases/kernel/syscalls/lseek/lseek07.c
+++ b/testcases/kernel/syscalls/lseek/lseek07.c
@@ -1,253 +1,110 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ * 06/2017 modified by Xiao Yang <yangx.jy@cn.fujitsu.com>
  *
- *   Copyright (c) International Business Machines  Corp., 2001
+ * 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 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.
  *
- *   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
+ * You should have received a copy of the GNU General Public License
+ * along with this program;  if not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
- * Test Name: lseek07
- *
- * Test Description:
- *  Verify that, lseek() call succeeds to set the file pointer position
- *  to more than the file size, when a file is opened for reading/writing.
- *
- * Expected Result:
- *  lseek() should return n+1, where n is the size of the file.
- *  Also when some data is written into this file it should start
- *  from that offset.
- *
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Pause for SIGUSR1 if option specified.
- *   Create temporary directory.
- *
- *  Test:
- *   Loop if the proper options are given.
- *   Execute system call
- *   Check return code, if system call failed (return=-1)
- *   	Log the errno and Issue a FAIL message.
- *   Otherwise,
- *   	Verify the Functionality of system call
- *      if successful,
- *      	Issue Functionality-Pass message.
- *      Otherwise,
- *		Issue Functionality-Fail message.
- *  Cleanup:
- *   Print errno log and/or timing stats if options given
- *   Delete the temporary directory created.
- *
- * Usage:  <for command-line>
- *  lseek07 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS:
- *  None.
+ * Description:
+ * lseek() succeeds to set the specified offset according to whence
+ * and write valid data from this location.
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <utime.h>
 #include <string.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <inttypes.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "tst_test.h"
 
-#include "test.h"
+#define TFILE1 "tfile1"
+#define TFILE2 "tfile2"
+#define WR_STR1 "abcdefg"
+#define WR_STR2 "ijk"
 
-#define TEMP_FILE	"tmp_file"
-#define FILE_MODE	S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
+static int fd1, fd2;
+static struct tcase {
+	int *fd;
+	char *fname;
+	off_t off;
+	off_t exp_off;
+	int exp_size;
+	char *exp_data;
+} tcases[] = {
+	{&fd1, TFILE1, 7, 7, 10, "abcdefgijk"},
+	{&fd2, TFILE2, 2, 2, 7, "abijkfg"},
+};
 
-char *TCID = "lseek07";
-int TST_TOTAL = 1;
-int fildes;			/* file handle for temp file */
-size_t file_size;		/* size of temporary file */
-char write_buf1[BUFSIZ];	/* buffer to hold data */
-char write_buf2[BUFSIZ];	/* buffer to hold data */
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
+static void verify_lseek(unsigned int n)
 {
-	int lc;
-	char read_buf[BUFSIZ];	/* data read from temp. file */
-	off_t offset;		/* byte position in temporary file */
+	char read_buf[64];
+	struct tcase *tc = &tcases[n];
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	memset(read_buf, 0, sizeof(read_buf));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/* Set the offset position */
-		offset = file_size + (lc * strlen(write_buf2));
-
-		/*
-		 * Invoke lseek(2) to move the write file
-		 * pointer/handle by the specified offset value.
-		 */
-		TEST(lseek(fildes, offset, SEEK_SET));
-
-		if (TEST_RETURN == (off_t) - 1) {
-			tst_resm(TFAIL | TTERRNO, "lseek on (%s) failed",
-				 TEMP_FILE);
-			continue;
-		}
-		/*
-		 * Check if the return value from lseek(2)
-		 * is equal to the specified offset value.
-		 */
-		if (TEST_RETURN != offset) {
-			tst_resm(TFAIL, "lseek() returned "
-				 "incorrect value %ld, expected "
-				 "%" PRId64, TEST_RETURN,
-				 (int64_t) offset);
-			continue;
-		}
-		/*
-		 * The return value is okay, now write some data at
-		 * the current offset position.
-		 */
-		if (write(fildes, write_buf2, strlen(write_buf2)) !=
-		    strlen(write_buf2)) {
-			tst_brkm(TFAIL | TERRNO, cleanup,
-				 "write() failed to write additional data");
-		}
-
-		/*
-		 * Now close the file and open it again
-		 * and read all of the data.
-		 */
-		if (close(fildes) < 0) {
-			tst_brkm(TFAIL, cleanup, "close() on %s Failed,"
-				 " errno = %d", TEMP_FILE, errno);
-		}
-
-		/* Open the file again in read/write mode */
-		if ((fildes = open(TEMP_FILE, O_RDWR)) < 0) {
-			tst_brkm(TFAIL, cleanup, "Could not open the "
-				 "%s readonly, error = %d",
-				 TEMP_FILE, errno);
-		}
-
-		/*
-		 * Now read all of the data.  The size should be the
-		 * offset + strlen(write_buf2).
-		 */
-		if (read(fildes, &read_buf, (offset +
-					     strlen(write_buf2))) < 0) {
-			tst_brkm(TFAIL, cleanup, "read() failed on %s, "
-				 "error=%d", TEMP_FILE, errno);
-		} else {
-			/*
-			 * Check data read is the complete data and not
-			 * the only portion written.
-			 */
-			if ((strncmp(read_buf, write_buf1,
-				     strlen(write_buf1))) != 0) {
-				tst_brkm(TFAIL, cleanup,
-					 "Incorrect data read #1 from "
-					 "file %s", TEMP_FILE);
-			}
-			if ((strncmp(&read_buf[offset], write_buf2,
-				     strlen(write_buf2))) != 0) {
-				tst_brkm(TFAIL, cleanup,
-					 "Incorrect data read #2 from "
-					 "file %s", TEMP_FILE);
-			}
-			tst_resm(TPASS, "Functionality of "
-				 "lseek() on %s successful", TEMP_FILE);
-		}
+	TEST(lseek(*tc->fd, tc->off, SEEK_SET));
+	if (TEST_RETURN == (off_t) -1) {
+		tst_res(TFAIL | TTERRNO, "lseek(%s, %ld, SEEK_SET) failed",
+			tc->fname, tc->off);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_RETURN != tc->exp_off) {
+		tst_res(TFAIL, "lseek(%s, %ld, SEEK_SET) returned %ld, expected %ld",
+			tc->fname, tc->off, TEST_RETURN, tc->exp_off);
+		return;
+	}
+
+	SAFE_WRITE(1, *tc->fd, WR_STR2, sizeof(WR_STR2) - 1);
+
+	SAFE_CLOSE(*tc->fd);
+
+	*tc->fd = SAFE_OPEN(tc->fname, O_RDWR);
+
+	SAFE_READ(1, *tc->fd, read_buf, tc->exp_size);
+
+	if (strcmp(read_buf, tc->exp_data)) {
+		tst_res(TFAIL, "lseek(%s, %ld, SEEK_SET) wrote incorrect data %s",
+			tc->fname, tc->off, read_buf);
+	} else {
+		tst_res(TPASS, "lseek(%s, %ld, SEEK_SET) wrote correct data %s",
+			tc->fname, tc->off, read_buf);
+	}
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- *	     Create a temporary directory and change directory to it.
- *	     Create a test file under temporary directory and write some
- *	     data into it.
- *	     Get the size of the file using fstat().
- */
-void setup(void)
+static void setup(void)
 {
-	struct stat stat_buf;	/* struct buffer for stat(2) */
+	fd1 = SAFE_OPEN(TFILE1, O_RDWR | O_CREAT, 0644);
+	fd2 = SAFE_OPEN(TFILE2, O_RDWR | O_CREAT, 0644);
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	/* Get the data to be written to temporary file */
-	strcpy(write_buf1, "abcdefg");
-	strcpy(write_buf2, "ijk");
-
-	/* Creat/open a temporary file for writing under above directory */
-	if ((fildes = open(TEMP_FILE, O_WRONLY | O_CREAT, FILE_MODE)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_WRONLY|O_CREAT, %#o) Failed, errno=%d :%s",
-			 TEMP_FILE, FILE_MODE, errno, strerror(errno));
-	}
-
-	/* Write data into temporary file */
-	if (write(fildes, write_buf1, strlen(write_buf1)) != strlen(write_buf1)) {
-		tst_brkm(TBROK, cleanup, "write(2) on %s Failed, errno=%d : %s",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	/* Get the size of the temporary file after writing data */
-	if (fstat(fildes, &stat_buf) < 0) {
-		tst_brkm(TBROK, cleanup, "fstat() on %s Failed, errno=%d : %s",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	file_size = stat_buf.st_size;
+	SAFE_WRITE(1, fd1, WR_STR1, sizeof(WR_STR1) - 1);
+	SAFE_WRITE(1, fd2, WR_STR1, sizeof(WR_STR1) - 1);
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- *	       Remove the test directory and testfile created in the setup.
- */
-void cleanup(void)
+static void cleanup(void)
 {
+	if (fd1 > 0)
+		SAFE_CLOSE(fd1);
 
-	/* Close the temporary file created */
-	if (close(fildes) < 0) {
-		tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	tst_rmdir();
-
+	if (fd2 > 0)
+		SAFE_CLOSE(fd2);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_lseek,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/lseek/lseek08.c b/testcases/kernel/syscalls/lseek/lseek08.c
deleted file mode 100644
index 49e787a..0000000
--- a/testcases/kernel/syscalls/lseek/lseek08.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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 Name: lseek08
- *
- * Test Description:
- *  Verify that, lseek() call succeeds to set the file pointer position
- *  to the end of the file when 'whence' value set to SEEK_END and any
- *  attempts to read from that position should fail.
- *
- * Expected Result:
- *  lseek() should return the offset which is set to the file size measured
- *  in bytes. read() attempt should fail with -1 return value.
- * $
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Create temporary directory.
- *   Pause for SIGUSR1 if option specified.
- *
- *  Test:
- *   Loop if the proper options are given.
- *   Execute system call
- *   Check return code, if system call failed (return=-1)
- *   	Log the errno and Issue a FAIL message.
- *   Otherwise,
- *   	Verify the Functionality of system call
- *      if successful,
- *      	Issue Functionality-Pass message.
- *      Otherwise,
- *		Issue Functionality-Fail message.
- *  Cleanup:
- *   Print errno log and/or timing stats if options given
- *   Delete the temporary directory created.
- *
- * Usage:  <for command-line>
- *  lseek08 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS:
- *  None.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <signal.h>
-
-#include "test.h"
-
-#define TEMP_FILE	"tmp_file"
-#define FILE_MODE	S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
-
-char *TCID = "lseek08";
-int TST_TOTAL = 1;
-int fildes;			/* file handle for temp file */
-size_t file_size;		/* size of the temporary file */
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
-{
-	int lc;
-	char read_buf[1];	/* data read from temp. file */
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Invoke lseek(2) to move the read/write file
-		 * pointer/handle to the END of the file.
-		 */
-		TEST(lseek(fildes, 0, SEEK_END));
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL | TTERRNO,
-				 "lseek of %s failed", TEMP_FILE);
-			continue;
-		}
-		/*
-		 * Check if the return value from lseek(2)
-		 * is equal to the file_size.
-		 */
-		if (TEST_RETURN != file_size) {
-			tst_resm(TFAIL, "lseek() returned incorrect "
-				 "value %ld, expected %zu",
-				 TEST_RETURN, file_size);
-			continue;
-		}
-		/*
-		 * The return value is okay, now attempt to read data
-		 * from the file.  This should fail as the file pointer
-		 * should be pointing to END OF FILE.
-		 */
-		read_buf[0] = '\0';
-		if (read(fildes, &read_buf, sizeof(read_buf)) > 0) {
-			tst_resm(TFAIL, "read() successful on %s",
-				 TEMP_FILE);
-		} else {
-			tst_resm(TPASS, "Functionality of lseek() on "
-				 "%s successful", TEMP_FILE);
-		}
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- *	     Create a temporary directory and change directory to it.
- *	     Create a test file under temporary directory and write some
- *	     data into it.
- *	     Get the size of the file using fstat().
- */
-void setup(void)
-{
-	struct stat stat_buf;	/* struct. buffer for stat(2) */
-	char write_buf[BUFSIZ];	/* buffer to hold data */
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	/* Get the data to be written to temporary file */
-	strcpy(write_buf, "abcdefg\n");
-
-	/* Creat/open a temporary file under above directory */
-	if ((fildes = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) failed",
-			 TEMP_FILE, FILE_MODE);
-	}
-
-	/* Write data into temporary file */
-	if (write(fildes, write_buf, strlen(write_buf)) <= 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "writing to %s failed", TEMP_FILE);
-	}
-
-	/* Get the size of the file using fstat */
-	if (fstat(fildes, &stat_buf) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "fstat of %s failed", TEMP_FILE);
-	}
-
-	file_size = stat_buf.st_size;
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- *	       Remove the test directory and testfile created in the setup.
- */
-void cleanup(void)
-{
-
-	/* Close the temporary file created */
-	if (close(fildes) < 0) {
-		tst_brkm(TFAIL, NULL,
-			 "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/lseek/lseek09.c b/testcases/kernel/syscalls/lseek/lseek09.c
deleted file mode 100644
index 38b1234..0000000
--- a/testcases/kernel/syscalls/lseek/lseek09.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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 Name: lseek09
- *
- * Test Description:
- *  Verify that, lseek() call succeeds to set the file pointer position
- *  to the current specified location, when 'whence' value is set to
- *  SEEK_CUR and the data read from the specified location should match
- *  the expected data.
- *
- * Expected Result:
- *  lseek() should return the specified offset from the beginning of the file
- *  measured in bytes. The data read from this location should match the
- *  expected data.
- *$
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Create temporary directory.
- *   Pause for SIGUSR1 if option specified.
- *
- *  Test:
- *   Loop if the proper options are given.
- *   Execute system call
- *   Check return code, if system call failed (return=-1)
- *   	Log the errno and Issue a FAIL message.
- *   Otherwise,
- *   	Verify the Functionality of system call
- *      if successful,
- *      	Issue Functionality-Pass message.
- *      Otherwise,
- *		Issue Functionality-Fail message.
- *  Cleanup:
- *   Print errno log and/or timing stats if options given
- *   Delete the temporary directory created.
- *
- * Usage:  <for command-line>
- *  lseek09 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS:
- *  None.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <signal.h>
-
-#include "test.h"
-
-#define TEMP_FILE	"tmp_file"
-#define FILE_MODE	S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
-
-char *TCID = "lseek09";
-int TST_TOTAL = 1;
-int fildes;			/* file handle for temp file */
-size_t file_size;		/* total size of file after data write */
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
-{
-	int lc;
-	char read_buf[BUFSIZ];	/* data read from temp. file */
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Invoke lseek(2) to set the file
-		 * pointer/handle from the current location
-		 * of the file descriptor + specified offset.
-		 */
-		TEST(lseek(fildes, 1, SEEK_CUR));
-
-		if (TEST_RETURN == (off_t) - 1) {
-			tst_resm(TFAIL, "lseek on (%s) Failed, errno=%d : %s",
-				 TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
-		/*
-		 * Check if the return value from lseek(2) is equal
-		 * to the 3 positions from the beginning of the file.
-		 * ie, 2 positions from lseek() in the setup +
-		 * 1 position from above above.
-		 */
-		if (TEST_RETURN != 3) {
-			tst_resm(TFAIL, "lseek() returned incorrect "
-				 "value %ld, expected 4", TEST_RETURN);
-			continue;
-		}
-		/*
-		 * Read the data byte from this location.
-		 */
-		memset(read_buf, 0, sizeof(read_buf));
-		if (read(fildes, &read_buf, (file_size - 3)) < 0) {
-			tst_brkm(TFAIL, cleanup,
-				 "read() failed on %s, error=%d",
-				 TEMP_FILE, errno);
-		} else {
-			/*
-			 * Check if read data contains
-			 * expected characters
-			 * From pos 4 ---> 'defg'.
-			 */
-			if (strcmp(read_buf, "defg")) {
-				tst_resm(TFAIL, "Incorrect data read "
-					 "from file %s", TEMP_FILE);
-			} else {
-				tst_resm(TPASS, "Functionality of "
-					 "lseek() on %s successful",
-					 TEMP_FILE);
-			}
-		}
-
-		/* reset file pointer in case we are looping */
-		if (lseek(fildes, 2, SEEK_SET) == -1) {
-			tst_brkm(TBROK, cleanup, "lseek failed - could not "
-				 "reset file pointer");
-		}
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- *	     Create a temporary directory and change directory to it.
- *	     Create a test file under temporary directory and write some
- *	     data into it.
- *	     Get the size of the file using fstat().
- */
-void setup(void)
-{
-	struct stat stat_buf;	/* buffer to hold stat info. */
-	char write_buf[BUFSIZ];	/* buffer to hold data */
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	/* Get the data to be written to temporary file */
-	strcpy(write_buf, "abcdefg");
-
-	/* Creat/open a temporary file under above directory */
-	if ((fildes = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s",
-			 TEMP_FILE, FILE_MODE, errno, strerror(errno));
-	}
-
-	/* Write data into temporary file */
-	if (write(fildes, write_buf, strlen(write_buf)) <= 0) {
-		tst_brkm(TBROK, cleanup, "write(2) on %s Failed, errno=%d : %s",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	/* Get the temporary file information */
-	if (fstat(fildes, &stat_buf) < 0) {
-		tst_brkm(TBROK, cleanup, "fstat(2) on %s Failed, errno=%d : %s",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	file_size = stat_buf.st_size;
-
-	/*
-	 * Reset the file pointer position to the specified offset
-	 * from the beginning of the file.
-	 */
-	if (lseek(fildes, 2, SEEK_SET) != 2) {
-		tst_brkm(TBROK, cleanup,
-			 "lseek() fails to set file ptr. to specified offset");
-	}
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- *	       Remove the test directory and testfile created in the setup.
- */
-void cleanup(void)
-{
-
-	/* Close the temporary file created */
-	if (close(fildes) < 0) {
-		tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE, errno, strerror(errno));
-	}
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/lseek/lseek10.c b/testcases/kernel/syscalls/lseek/lseek10.c
deleted file mode 100644
index 7ee25af..0000000
--- a/testcases/kernel/syscalls/lseek/lseek10.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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 Name: lseek10
- *
- * Test Description:
- *  Verify that,
- *  1. lseek() returns -1 and sets errno to ESPIPE, if the file handle of
- *     the specified file is associated with a pipe, socket, or  FIFO.
- *  2. lseek() returns -1 and sets errno to EINVAL, if the 'Whence' argument
- *     is not a proper value.
- *  3. lseek() returns -1 and sets errno to EBADF, if the file handle of
- *     the specified file is not valid.
- *
- * Expected Result:
- *  lseek() should fail with return value -1 and set expected errno.
- *
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Create temporary directory.
- *   Pause for SIGUSR1 if option specified.
- *
- *  Test:
- *   Loop if the proper options are given.
- *   Execute system call
- *   Check return code, if system call failed (return=-1)
- *   	if errno set == expected errno
- *   		Issue sys call fails with expected return value and errno.
- *   	Otherwise,
- *		Issue sys call fails with unexpected errno.
- *   Otherwise,
- *	Issue sys call returns unexpected value.
- *
- *  Cleanup:
- *   Print errno log and/or timing stats if options given
- *   Delete the temporary directory(s)/file(s) created.
- *
- * Usage:  <for command-line>
- *  lseek10 [-c n] [-e] [-i n] [-I x] [-p x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS:
- *  None.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <signal.h>
-
-#include "test.h"
-
-#define TEMP_FILE1	"tmp_file1"
-#define TEMP_FILE2	"tmp_file2"
-#define TEMP_FILE3	"tmp_file3"
-#define FILE_MODE	S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
-#define PIPE_MODE	S_IFIFO | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
-#define SEEK_TOP	10
-
-char *TCID = "lseek10";
-int TST_TOTAL = 3;
-
-int no_setup();
-int setup1();			/* setup function to test lseek() for ESPIPE */
-int setup2();			/* setup function to test lseek() for EINVAL */
-int setup3();			/* setup function to test lseek() for EBADF */
-
-int fd1;			/* file handle for testfile1  */
-int fd2;			/* file handle for testfile2  */
-int fd3;			/* file handle for testfile3  */
-
-struct test_case_t {		/* test case struct. to hold ref. test cond's */
-	int fd;
-	int Whence;
-	char *desc;
-	int exp_errno;
-	int (*setupfunc) ();
-} Test_cases[] = {
-	{
-	1, SEEK_SET, "'fd' associated with a pipe/fifo", ESPIPE, setup1}, {
-	2, SEEK_TOP, "'whence' argument is not valid", EINVAL, setup2}, {
-	3, SEEK_SET, "'fd' is not an open file descriptor", EBADF, setup3},
-	{
-	0, 0, NULL, 0, no_setup}
-};
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
-{
-	int lc;
-	int fildes;		/* file handle for testfile */
-	int whence;		/* position of file handle in the file */
-	char *test_desc;	/* test specific error message */
-	int ind;		/* counter to test different test conditions */
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (ind = 0; Test_cases[ind].desc != NULL; ind++) {
-			fildes = Test_cases[ind].fd;
-			test_desc = Test_cases[ind].desc;
-			whence = Test_cases[ind].Whence;
-
-			/* Assign the 'fd' values appropriatly */
-			if (fildes == 1) {
-				fildes = fd1;
-			} else if (fildes == 2) {
-				fildes = fd2;
-			} else {
-				fildes = fd3;
-			}
-			/*
-			 * Invoke lseek(2) to test different test conditions.
-			 * Verify that it fails with -1 return value and
-			 * sets appropriate errno.
-			 */
-			TEST(lseek(fildes, 0, whence));
-
-			if (TEST_RETURN != (off_t) - 1) {
-				tst_resm(TFAIL,
-					 "lseek() returned %ld, expected "
-					 "-1, errno:%d", TEST_RETURN,
-					 Test_cases[ind].exp_errno);
-				continue;
-			}
-			if (TEST_ERRNO == Test_cases[ind].exp_errno) {
-				tst_resm(TPASS, "lseek() fails, %s, errno:%d",
-					 test_desc, TEST_ERRNO);
-			} else {
-				tst_resm(TFAIL, "lseek() fails, %s, errno:%d, "
-					 "expected errno:%d", test_desc,
-					 TEST_ERRNO, Test_cases[ind].exp_errno);
-			}
-		}
-	}
-
-	cleanup();
-	tst_exit();
-
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- *	     Create a temporary directory and change directory to it.
- *	     Invoke individual test setup functions according to the order
- *	     set in test struct. definition.
- */
-void setup(void)
-{
-	int ind;
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	/* call individual setup functions */
-	for (ind = 0; Test_cases[ind].desc != NULL; ind++) {
-		Test_cases[ind].setupfunc();
-	}
-}
-
-/*
- * no_setup() - This is a dummy function which simply returns 0.
- */
-int no_setup(void)
-{
-	return 0;
-}
-
-/*
- * setup1() - setup function for a test condition for which lseek(2)
- *	      returns -1 and sets errno to ESPIPE.
- *	      Creat a named pipe/fifo using mknod() and open it for
- *	      reading/writing.
- *	      This function returns 0 on success.
- */
-int setup1(void)
-{
-	/* Creat a named pipe/fifo using mknod() */
-	if (mknod(TEMP_FILE1, PIPE_MODE, 0) < 0) {
-		tst_brkm(TBROK, cleanup,
-			 "mknod(%s, %#o, 0) Failed, errno=%d :%s",
-			 TEMP_FILE1, FILE_MODE, errno, strerror(errno));
-	}
-
-	/* Open the named pipe/fifo for reading/writing */
-	if ((fd1 = open(TEMP_FILE1, O_RDWR)) < 0) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR) Failed, errno=%d, :%s",
-			 TEMP_FILE1, errno, strerror(errno));
-	}
-
-	return 0;
-}
-
-/*
- * setup2() - setup function for a test condition for which lseek(2)
- *	      returns -1 and sets errno to EINVAL.
- *	      Creat a temporary file for reading/writing and write some data
- *	      into it.
- *	      This function returns 0 on success.
- */
-int setup2(void)
-{
-	char write_buff[BUFSIZ];	/* buffer to hold data */
-
-	/* Get the data to be written to temporary file */
-	strcpy(write_buff, "abcdefg");
-
-	/* Creat/open a temporary file under above directory */
-	if ((fd2 = open(TEMP_FILE2, O_RDWR | O_CREAT, FILE_MODE)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s",
-			 TEMP_FILE2, FILE_MODE, errno, strerror(errno));
-	}
-
-	/* Write data into temporary file */
-	if (write(fd2, write_buff, sizeof(write_buff)) <= 0) {
-		tst_brkm(TBROK, cleanup,
-			 "write(2) on %s Failed, errno=%d : %s",
-			 TEMP_FILE2, errno, strerror(errno));
-	}
-
-	return 0;
-}
-
-/*
- * setup3() - setup function for a test condition for which lseek(2)
- *	      returns -1 and sets errno to EBADF.
- *	      Creat a temporary file for reading/writing and close it.
- *	      This function returns 0 on success.
- */
-int setup3(void)
-{
-	/* Creat/open a temporary file under above directory */
-	if ((fd3 = open(TEMP_FILE3, O_RDWR | O_CREAT, FILE_MODE)) == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s",
-			 TEMP_FILE3, FILE_MODE, errno, strerror(errno));
-	}
-
-	/* Close the temporary file created above */
-	if (close(fd3) < 0) {
-		tst_brkm(TBROK, cleanup,
-			 "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE3, errno, strerror(errno));
-	}
-
-	return 0;
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- *	       Remove the test directory and testfile(s) created in the setup.
- */
-void cleanup(void)
-{
-
-	/* Close the temporary file(s) created in setup1/setup2 */
-	if (close(fd1) < 0) {
-		tst_brkm(TFAIL, NULL,
-			 "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE1, errno, strerror(errno));
-	}
-	if (close(fd2) < 0) {
-		tst_brkm(TFAIL, NULL,
-			 "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE2, errno, strerror(errno));
-	}
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/lseek/lseek11.c b/testcases/kernel/syscalls/lseek/lseek11.c
index 4c5bb00..54d5da6 100644
--- a/testcases/kernel/syscalls/lseek/lseek11.c
+++ b/testcases/kernel/syscalls/lseek/lseek11.c
@@ -119,7 +119,7 @@
 		SAFE_FSYNC(fd);
 		pos = lseek(fd, 0, SEEK_DATA);
 		if (pos == -1) {
-			if (errno == EINVAL) {
+			if (errno == EINVAL || errno == EOPNOTSUPP) {
 				tst_brk(TCONF | TERRNO, "SEEK_DATA "
 					"and SEEK_HOLE not implemented");
 			}
@@ -229,7 +229,6 @@
 }
 
 static struct tst_test test = {
-	.tid          = "lseek11",
 	.tcnt         = ARRAY_SIZE(tparams),
 	.test         = test_lseek,
 	.setup        = setup,
diff --git a/testcases/kernel/syscalls/madvise/madvise01.c b/testcases/kernel/syscalls/madvise/madvise01.c
index 4ec3ef2..4b18a21 100644
--- a/testcases/kernel/syscalls/madvise/madvise01.c
+++ b/testcases/kernel/syscalls/madvise/madvise01.c
@@ -120,7 +120,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "madvise01",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_madvise,
 	.needs_tmpdir = 1,
diff --git a/testcases/kernel/syscalls/madvise/madvise02.c b/testcases/kernel/syscalls/madvise/madvise02.c
index 592536d..b773efd 100644
--- a/testcases/kernel/syscalls/madvise/madvise02.c
+++ b/testcases/kernel/syscalls/madvise/madvise02.c
@@ -180,7 +180,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "madvise02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = advice_test,
 	.needs_tmpdir = 1,
diff --git a/testcases/kernel/syscalls/madvise/madvise05.c b/testcases/kernel/syscalls/madvise/madvise05.c
index 4f8718f..23dacbd 100644
--- a/testcases/kernel/syscalls/madvise/madvise05.c
+++ b/testcases/kernel/syscalls/madvise/madvise05.c
@@ -55,7 +55,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "madvise05",
 	.min_kver = "3.9.0",
 	.test_all = verify_madvise,
 };
diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c
index 9b3e1f0..7b178a2 100644
--- a/testcases/kernel/syscalls/madvise/madvise06.c
+++ b/testcases/kernel/syscalls/madvise/madvise06.c
@@ -179,7 +179,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "madvise06",
 	.test_all = test_advice_willneed,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/madvise/madvise07.c b/testcases/kernel/syscalls/madvise/madvise07.c
index 80586a1..ef9aa4a 100644
--- a/testcases/kernel/syscalls/madvise/madvise07.c
+++ b/testcases/kernel/syscalls/madvise/madvise07.c
@@ -16,21 +16,23 @@
  */
 
 /*
- * Check that accessing memory marked with MADV_HWPOISON results in SIGBUS.
+ * Check that accessing a page marked with MADV_HWPOISON results in SIGBUS.
  *
  * Test flow: create child process,
- *	      map memory,
- *	      mark memory with MADV_HWPOISON inside child process,
+ *	      map and write to memory,
+ *	      mark memory with MADV_HWPOISON,
  *	      access memory,
  *	      if SIGBUS is delivered to child the test passes else it fails
  *
- * When MAP_PRIVATE is set (without MAP_POPULATE) madvise() may error with
- * EBUSY on the first attempt and succeed on the second, but without poisoning
- * any memory. A private mapping is only populated with pages once it is
- * accessed and poisoning an unmapped VM range is essentially undefined
- * behaviour. However madvise() itself causes the address to be mapped to the
- * zero page. If/when the zero page can be poisoned then the test may pass
- * without any error. For now we just consider it a configuration failure.
+ * If the underlying page type of the memory we have mapped does not support
+ * poisoning then the test will fail. We try to map and write to the memory in
+ * such a way that by the time madvise is called the virtual memory address
+ * points to a supported page. However there may be some rare circumstances
+ * where the test produces the wrong result because we have somehow obtained
+ * an unsupported page. In such cases madvise will probably return success,
+ * but no SIGBUS will be produced.
+ *
+ * For more information see <linux source>/Documentation/vm/hwpoison.txt.
  */
 
 #include <stdlib.h>
@@ -40,54 +42,32 @@
 #include <unistd.h>
 #include <signal.h>
 #include <errno.h>
+#include <string.h>
 
 #include "tst_test.h"
 #include "lapi/mmap.h"
 
-static int maptypes[] = {
-	MAP_PRIVATE,
-	MAP_PRIVATE | MAP_POPULATE,
-	MAP_SHARED
-};
-
-static char *mapname(int maptype)
-{
-	switch (maptype) {
-	case MAP_PRIVATE: return "MAP_SHARED";
-	case MAP_PRIVATE | MAP_POPULATE: return "MAP_PRIVATE | MAP_POPULATE";
-	case MAP_SHARED: return "MAP_SHARED";
-	default:
-		tst_res(TWARN, "Unknown map type: %d", maptype);
-	}
-	return "Unknown";
-}
-
-static void run_child(int maptype)
+static void run_child(void)
 {
 	const size_t msize = getpagesize();
 	void *mem = NULL;
-	int first_attempt = 1;
 
 	tst_res(TINFO,
-		"mmap(..., MAP_ANONYMOUS | %s, ...)", mapname(maptype));
+		"mmap(0, %zu, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)",
+		msize);
 	mem = SAFE_MMAP(NULL,
 			msize,
 			PROT_READ | PROT_WRITE,
-			MAP_ANONYMOUS | maptype,
+			MAP_ANONYMOUS | MAP_PRIVATE,
 			-1,
 			0);
+	memset(mem, 'L', msize);
 
-do_madvise:
 	tst_res(TINFO, "madvise(%p, %zu, MADV_HWPOISON)", mem, msize);
 	if (madvise(mem, msize, MADV_HWPOISON) == -1) {
 		if (errno == EINVAL) {
 			tst_res(TCONF | TERRNO,
 				"CONFIG_MEMORY_FAILURE probably not set in kconfig");
-		} else if (errno == EBUSY && maptype == MAP_PRIVATE) {
-			tst_res(TCONF,
-				"Madvise failed with EBUSY");
-			if (first_attempt--)
-				goto do_madvise;
 		} else {
 			tst_res(TFAIL | TERRNO, "Could not poison memory");
 		}
@@ -96,40 +76,29 @@
 
 	*((char *)mem) = 'd';
 
-	if (maptype == MAP_PRIVATE) {
-		tst_res(TCONF,
-			"Zero page poisoning is probably not implemented");
-	} else {
-		tst_res(TFAIL,
-			"Did not receive SIGBUS after accessing %s memory marked with MADV_HWPOISON",
-			mapname(maptype));
-	}
+	tst_res(TFAIL, "Did not receive SIGBUS on accessing poisoned page");
 }
 
-static void run(unsigned int n)
+static void run(void)
 {
 	int status;
 	pid_t pid;
 
 	pid = SAFE_FORK();
 	if (pid == 0) {
-		run_child(maptypes[n]);
+		run_child();
 		exit(0);
 	}
 
 	SAFE_WAITPID(pid, &status, 0);
 	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGBUS)
-		tst_res(TPASS,
-			"madvise(..., MADV_HWPOISON) on %s memory",
-			mapname(maptypes[n]));
+		tst_res(TPASS, "Received SIGBUS after accessing poisoned page");
 	else if (WIFEXITED(status) && WEXITSTATUS(status) == TBROK)
 		tst_res(TBROK, "Child exited abnormally");
 }
 
 static struct tst_test test = {
-	.tid = "madvise07",
-	.test = run,
-	.tcnt = ARRAY_SIZE(maptypes),
+	.test_all = run,
 	.min_kver = "2.6.31",
 	.needs_root = 1,
 	.forks_child = 1
diff --git a/testcases/kernel/syscalls/madvise/madvise08.c b/testcases/kernel/syscalls/madvise/madvise08.c
index 4825b99..a6fd967 100644
--- a/testcases/kernel/syscalls/madvise/madvise08.c
+++ b/testcases/kernel/syscalls/madvise/madvise08.c
@@ -226,7 +226,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "madvise08",
 	.test = run,
 	.tcnt = 2,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/madvise/madvise09.c b/testcases/kernel/syscalls/madvise/madvise09.c
index 38a101f..7ad76f7 100644
--- a/testcases/kernel/syscalls/madvise/madvise09.c
+++ b/testcases/kernel/syscalls/madvise/madvise09.c
@@ -331,7 +331,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "madvise09",
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = run,
diff --git a/testcases/kernel/syscalls/mbind/mbind01.c b/testcases/kernel/syscalls/mbind/mbind01.c
index aeefd28..be54706 100644
--- a/testcases/kernel/syscalls/mbind/mbind01.c
+++ b/testcases/kernel/syscalls/mbind/mbind01.c
@@ -1,317 +1,238 @@
-/******************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007-2008			      */
-/* Author(s):	Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,		      */
-/*		Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,		      */
-/*		Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>		      */
-/*									      */
-/* 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:	mbind01.c						      */
-/*									      */
-/* Description: This tests the mbind() syscall				      */
-/*									      */
-/* Usage:	<for command-line>					      */
-/* mbind01 [-c n] [-e][-i n] [-I x] [-p x] [-t]				      */
-/*	where,	-c n : Run n copies concurrently.			      */
-/*		-e   : Turn on errno logging.				      */
-/*		-i n : Execute test n times.				      */
-/*		-I x : Execute test for x seconds.			      */
-/*		-P x : Pause for x seconds between iterations.		      */
-/*		-t   : Turn on syscall timing.				      */
-/*									      */
-/* Total Tests: 1							      */
-/*									      */
-/* Test Name:	mbind01							      */
-/* History:	Porting from Crackerjack to LTP is done by		      */
-/*		Manas Kumar Nayak maknayak@in.ibm.com>			      */
-/******************************************************************************/
+/*
+ * Copyright (c) Crackerjack Project., 2007-2008, Hitachi, Ltd
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * Authors:
+ * Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
+ * Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
+ * Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
+ *
+ * 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 would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
 
-#include "config.h"
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
 #include <errno.h>
-#include <getopt.h>
-#include <libgen.h>
-#if HAVE_NUMA_H
-#include <numa.h>
-#endif
-#if HAVE_NUMAIF_H
-#include <numaif.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
-#include "include_j_h.h"
 #include "numa_helper.h"
+#include "tst_test.h"
 
-char *TCID = "mbind01";
-int TST_TOTAL = 2;
+#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
+	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H && \
-	HAVE_MPOL_CONSTANTS
+#define MEM_LENGTH (4 * 1024 * 1024)
 
-#define MEM_LENGTH	      (4 * 1024 * 1024)
+#define UNKNOWN_POLICY -1
 
-static int testno;
+#define POLICY_DESC(x) .policy = x, .desc = #x
+#define POLICY_DESC_TEXT(x, y) .policy = x, .desc = #x" ("y")"
 
-enum test_type {
-	NORMAL,
-	INVALID_POINTER,
-};
+static struct bitmask *nodemask, *getnodemask, *empty_nodemask;
 
-enum from_node {
-	NONE,
-	SELF,
-};
+static void test_default(unsigned int i, char *p);
+static void test_none(unsigned int i, char *p);
+static void test_invalid_nodemask(unsigned int i, char *p);
 
 struct test_case {
-	int ttype;
 	int policy;
-	int from_node;
+	const char *desc;
 	unsigned flags;
 	int ret;
 	int err;
+	void (*test)(unsigned int, char *);
+	struct bitmask **exp_nodemask;
 };
 
-/* Test cases
- *
- *   test status of errors on man page
- *
- *   EFAULT	v (detect unmapped hole or invalid pointer)
- *   EINVAL	v (invalid arguments)
- *   ENOMEM	can't check because it's difficult to create no-memory
- *   EIO	can't check because we don't have N-node NUMA system
- *		(only we can do is simulate 1-node NUMA)
- */
 static struct test_case tcase[] = {
-	{			/* case00 */
-	 .policy = MPOL_DEFAULT,
-	 .from_node = NONE,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			/* case01 */
-	 .policy = MPOL_DEFAULT,
-	 .from_node = SELF,	/* target exists */
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			/* case02 */
-	 .policy = MPOL_BIND,
-	 .from_node = NONE,	/* no target */
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			/* case03 */
-	 .policy = MPOL_BIND,
-	 .from_node = SELF,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			/* case04 */
-	 .policy = MPOL_INTERLEAVE,
-	 .from_node = NONE,	/* no target */
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			/* case05 */
-	 .policy = MPOL_INTERLEAVE,
-	 .from_node = SELF,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			/* case06 */
-	 .policy = MPOL_PREFERRED,
-	 .from_node = NONE,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			/* case07 */
-	 .policy = MPOL_PREFERRED,
-	 .from_node = SELF,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			/* case08 */
-	 .policy = -1,		/* unknown policy */
-	 .from_node = NONE,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			/* case09 */
-	 .policy = MPOL_DEFAULT,
-	 .from_node = NONE,
-	 .flags = -1,		/* invalid flags */
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			/* case10 */
-	 .ttype = INVALID_POINTER,
-	 .policy = MPOL_PREFERRED,
-	 .from_node = SELF,
-	 .ret = -1,
-	 .err = EFAULT,
-	 },
+	{
+		POLICY_DESC(MPOL_DEFAULT),
+		.ret = 0,
+		.err = 0,
+		.test = test_none,
+		.exp_nodemask = &empty_nodemask,
+	},
+	{
+		POLICY_DESC_TEXT(MPOL_DEFAULT, "target exists"),
+		.ret = -1,
+		.err = EINVAL,
+		.test = test_default,
+	},
+	{
+		POLICY_DESC_TEXT(MPOL_BIND, "no target"),
+		.ret = -1,
+		.err = EINVAL,
+		.test = test_none,
+	},
+	{
+		POLICY_DESC(MPOL_BIND),
+		.ret = 0,
+		.err = 0,
+		.test = test_default,
+		.exp_nodemask = &nodemask,
+	},
+	{
+		POLICY_DESC_TEXT(MPOL_INTERLEAVE, "no target"),
+		.ret = -1,
+		.err = EINVAL,
+		.test = test_none,
+	},
+	{
+		POLICY_DESC(MPOL_INTERLEAVE),
+		.ret = 0,
+		.err = 0,
+		.test = test_default,
+		.exp_nodemask = &nodemask,
+	},
+	{
+		POLICY_DESC_TEXT(MPOL_PREFERRED, "no target"),
+		.ret = 0,
+		.err = 0,
+		.test = test_none,
+	},
+	{
+		POLICY_DESC(MPOL_PREFERRED),
+		.ret = 0,
+		.err = 0,
+		.test = test_default,
+		.exp_nodemask = &nodemask,
+	},
+	{
+		POLICY_DESC(UNKNOWN_POLICY),
+		.ret = -1,
+		.err = EINVAL,
+		.test = test_none,
+	},
+	{
+		POLICY_DESC_TEXT(MPOL_DEFAULT, "invalid flags"),
+		.flags = -1,
+		.ret = -1,
+		.err = EINVAL,
+		.test = test_none,
+	},
+	{
+		POLICY_DESC_TEXT(MPOL_PREFERRED, "invalid nodemask"),
+		.ret = -1,
+		.err = EFAULT,
+		.test = test_invalid_nodemask,
+	},
 };
 
-static int do_test(struct test_case *tc);
-static void setup(void);
-static void cleanup(void);
-
-int main(int argc, char **argv)
+static void test_default(unsigned int i, char *p)
 {
-	int lc, i, ret;
+	struct test_case *tc = &tcase[i];
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-	testno = (int)(sizeof(tcase) / sizeof(tcase[0]));
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		tst_count = 0;
-		for (i = 0; i < testno; i++) {
-			tst_resm(TINFO, "(case%02d) START", i);
-			ret = do_test(&tcase[i]);
-			tst_resm((ret == 0 ? TPASS : TFAIL | TERRNO),
-				 "(case%02d) END", i);
-		}
-	}
-	cleanup();
-	tst_exit();
+	TEST(mbind(p, MEM_LENGTH, tc->policy, nodemask->maskp,
+		   nodemask->size, tc->flags));
 }
 
-static int do_test(struct test_case *tc)
+static void test_none(unsigned int i, char *p)
 {
-	int ret, err, result, cmp_ok = 1;
-	int policy;
-	char *p = NULL;
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-	nodemask_t *nodemask, *getnodemask;
-#else
-	struct bitmask *nodemask = numa_allocate_nodemask();
-	struct bitmask *getnodemask = numa_allocate_nodemask();
-#endif
-	unsigned long maxnode = NUMA_NUM_NODES;
-	unsigned long len = MEM_LENGTH;
-	unsigned long *invalid_nodemask;
-	int test_node = -1;
+	struct test_case *tc = &tcase[i];
 
-	ret = get_allowed_nodes(NH_MEMS, 1, &test_node);
-	if (ret < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "get_allowed_nodes: %d", ret);
+	TEST(mbind(p, MEM_LENGTH, tc->policy, NULL, 0, tc->flags));
+}
 
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-	nodemask = malloc(sizeof(nodemask_t));
-	nodemask_zero(nodemask);
-	nodemask_set(nodemask, test_node);
-	getnodemask = malloc(sizeof(nodemask_t));
-	nodemask_zero(getnodemask);
-#else
-	numa_bitmask_setbit(nodemask, test_node);
-#endif
-	p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
-		 0, 0);
-	if (p == MAP_FAILED)
-		tst_brkm(TBROK | TERRNO, cleanup, "mmap");
+static void test_invalid_nodemask(unsigned int i, char *p)
+{
+	struct test_case *tc = &tcase[i];
 
-	if (tc->ttype == INVALID_POINTER)
-		invalid_nodemask = (unsigned long *)0xc0000000;
-
-	errno = 0;
-	if (tc->from_node == NONE)
-		TEST(ret = ltp_syscall(__NR_mbind, p, len, tc->policy,
-				   NULL, 0, tc->flags));
-	else if (tc->ttype == INVALID_POINTER)
-		TEST(ret = ltp_syscall(__NR_mbind, p, len, tc->policy,
-				   invalid_nodemask, maxnode, tc->flags));
-	else
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-		TEST(ret = ltp_syscall(__NR_mbind, p, len, tc->policy,
-				   nodemask, maxnode, tc->flags));
-#else
-		TEST(ret = ltp_syscall(__NR_mbind, p, len, tc->policy,
-				   nodemask->maskp, nodemask->size, tc->flags));
-#endif
-
-	err = TEST_ERRNO;
-	if (ret < 0)
-		goto TEST_END;
-
-	/* Check policy of the allocated memory */
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-	TEST(ltp_syscall(__NR_get_mempolicy, &policy, getnodemask,
-		     maxnode, p, MPOL_F_ADDR));
-#else
-	TEST(ltp_syscall(__NR_get_mempolicy, &policy, getnodemask->maskp,
-		     getnodemask->size, p, MPOL_F_ADDR));
-#endif
-	if (TEST_RETURN < 0) {
-		tst_resm(TFAIL | TERRNO, "get_mempolicy failed");
-		return -1;
-	}
-
-	/* If policy == MPOL_DEFAULT, get_mempolicy doesn't return nodemask */
-	if (tc->policy == MPOL_DEFAULT)
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-		nodemask_zero(nodemask);
-#else
-		numa_bitmask_clearall(nodemask);
-#endif
-
-	if ((tc->policy == MPOL_PREFERRED) && (tc->from_node == NONE))
-		cmp_ok = (tc->policy == policy);
-	else
-		cmp_ok = ((tc->policy == policy) &&
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-			  nodemask_equal(nodemask, getnodemask));
-#else
-			  numa_bitmask_equal(nodemask, getnodemask));
-#endif
-TEST_END:
-	result = ((err != tc->err) || (!cmp_ok));
-	PRINT_RESULT_CMP(0, tc->ret, tc->err, ret, err, cmp_ok);
-	return result;
+	/* use invalid nodemask (64 MiB after heap) */
+	TEST(mbind(p, MEM_LENGTH, tc->policy, sbrk(0) + 64*1024*1024,
+		   NUMA_NUM_NODES, tc->flags));
 }
 
 static void setup(void)
 {
-	/* check syscall availability */
-	ltp_syscall(__NR_mbind, NULL, 0, 0, NULL, 0, 0);
-
 	if (!is_numa(NULL, NH_MEMS, 1))
-		tst_brkm(TCONF, NULL, "requires NUMA with at least 1 node");
-
-	TEST_PAUSE;
-	tst_tmpdir();
+		tst_brk(TCONF, "requires NUMA with at least 1 node");
+	empty_nodemask = numa_allocate_nodemask();
 }
 
-static void cleanup(void)
+static void setup_node(void)
 {
-	tst_rmdir();
+	int test_node = -1;
+
+	if (get_allowed_nodes(NH_MEMS, 1, &test_node) < 0)
+		tst_brk(TBROK | TERRNO, "get_allowed_nodes failed");
+
+	nodemask = numa_allocate_nodemask();
+	getnodemask = numa_allocate_nodemask();
+	numa_bitmask_setbit(nodemask, test_node);
 }
-#else /* no NUMA */
-int main(void)
+
+static void do_test(unsigned int i)
 {
-	tst_brkm(TCONF, NULL, "System doesn't have required numa support");
+	struct test_case *tc = &tcase[i];
+	int policy, fail = 0;
+	char *p = NULL;
+
+	tst_res(TINFO, "case %s", tc->desc);
+
+	setup_node();
+
+	p = mmap(NULL, MEM_LENGTH, PROT_READ | PROT_WRITE, MAP_PRIVATE |
+			 MAP_ANONYMOUS, 0, 0);
+	if (p == MAP_FAILED)
+		tst_brk(TBROK | TERRNO, "mmap");
+
+	tc->test(i, p);
+
+	if (TEST_RETURN >= 0) {
+		/* Check policy of the allocated memory */
+		TEST(get_mempolicy(&policy, getnodemask->maskp,
+				   getnodemask->size, p, MPOL_F_ADDR));
+		if (TEST_RETURN < 0) {
+			tst_res(TFAIL | TTERRNO, "get_mempolicy failed");
+			return;
+		}
+		if (tc->policy != policy) {
+			tst_res(TFAIL, "Wrong policy: %d, expected: %d",
+				tc->policy, policy);
+			fail = 1;
+		}
+		if (tc->exp_nodemask) {
+			struct bitmask *exp_mask = *(tc->exp_nodemask);
+
+			if (!numa_bitmask_equal(exp_mask, getnodemask)) {
+				tst_res(TFAIL, "masks are not equal");
+				tst_res_hexd(TINFO, exp_mask->maskp,
+					exp_mask->size / 8, "exp_mask: ");
+				tst_res_hexd(TINFO, getnodemask->maskp,
+					getnodemask->size / 8, "returned: ");
+				fail = 1;
+			}
+		}
+	}
+
+	if (TEST_RETURN != tc->ret) {
+		tst_res(TFAIL, "wrong return code: %ld, expected: %d",
+			TEST_RETURN, tc->ret);
+		fail = 1;
+	}
+	if (TEST_RETURN == -1 && TEST_ERRNO != tc->err) {
+		tst_res(TFAIL | TTERRNO, "expected errno: %s, got",
+			tst_strerrno(tc->err));
+		fail = 1;
+	}
+	if (!fail)
+		tst_res(TPASS, "Test passed");
 }
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcase),
+	.test = do_test,
+	.setup = setup,
+};
+
+#else /* libnuma >= 2 */
+TST_TEST_TCONF("test requires libnuma >= 2.");
 #endif
diff --git a/testcases/kernel/syscalls/memfd_create/memfd_create01.c b/testcases/kernel/syscalls/memfd_create/memfd_create01.c
index 04a5f4f..6a84899 100644
--- a/testcases/kernel/syscalls/memfd_create/memfd_create01.c
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create01.c
@@ -22,6 +22,7 @@
 
 #define _GNU_SOURCE
 
+#include <errno.h>
 #include "tst_test.h"
 #include "memfd_create_common.h"
 
@@ -259,11 +260,19 @@
 
 static void setup(void)
 {
-	ASSERT_HAVE_MEMFD_CREATE();
+	/*
+	 * For now, all tests in this file require MFD_ALLOW_SEALING flag
+	 * to be implemented, even though that flag isn't always set when
+	 * memfd is created. So don't check anything else and TCONF right away
+	 * is this flag is missing.
+	 */
+	if (!MFD_FLAGS_AVAILABLE(MFD_ALLOW_SEALING)) {
+		tst_brk(TCONF | TTERRNO,
+			"memfd_create(%u) not implemented", MFD_ALLOW_SEALING);
+	}
 }
 
 static struct tst_test test = {
-	.tid = "memfd_create01",
 	.test = verify_memfd_create,
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/memfd_create/memfd_create02.c b/testcases/kernel/syscalls/memfd_create/memfd_create02.c
index 1c56156..bc01e44 100644
--- a/testcases/kernel/syscalls/memfd_create/memfd_create02.c
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create02.c
@@ -31,6 +31,8 @@
 static char buf[2048];
 static char term_buf[2048];
 
+static int available_flags;
+
 static const struct tcase {
 	char *descr;
 	char *memfd_name;
@@ -62,7 +64,8 @@
 
 static void setup(void)
 {
-	ASSERT_HAVE_MEMFD_CREATE();
+
+	available_flags = GET_MFD_ALL_AVAILABLE_FLAGS();
 
 	memset(buf, 0xff, sizeof(buf));
 
@@ -73,8 +76,16 @@
 static void verify_memfd_create_errno(unsigned int n)
 {
 	const struct tcase *tc;
+	int needed_flags;
 
 	tc = &tcases[n];
+	needed_flags = tc->flags & FLAGS_ALL_MASK;
+
+	if ((available_flags & needed_flags) != needed_flags) {
+		tst_res(TCONF, "test '%s' skipped, flag not implemented",
+					tc->descr);
+		return;
+	}
 
 	TEST(sys_memfd_create(tc->memfd_name, tc->flags));
 	if (TEST_ERRNO != tc->memfd_create_exp_err)
@@ -87,7 +98,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "memfd_create02",
 	.test = verify_memfd_create_errno,
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/memfd_create/memfd_create_common.c b/testcases/kernel/syscalls/memfd_create/memfd_create_common.c
index 4cf3bd5..f22e3d3 100644
--- a/testcases/kernel/syscalls/memfd_create/memfd_create_common.c
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create_common.c
@@ -30,7 +30,7 @@
 #include "lapi/fcntl.h"
 #include "lapi/memfd.h"
 
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #include "memfd_create_common.h"
 
@@ -103,20 +103,44 @@
 		"ftruncate(%d, %ld) failed as expected", fd, length);
 }
 
-void assert_have_memfd_create(const char *filename, const int lineno)
+int get_mfd_all_available_flags(const char *filename, const int lineno)
 {
-	TEST(sys_memfd_create("dummy_call", 0));
+	unsigned int i;
+	int flag;
+	int flags2test[] = FLAGS_ALL_ARRAY_INITIALIZER;
+	int flags_available = 0;
+
+	if (!MFD_FLAGS_AVAILABLE(0)) {
+		tst_brk_(filename, lineno, TCONF,
+				"memfd_create(0) not implemented");
+	}
+
+	for (i = 0; i < ARRAY_SIZE(flags2test); i++) {
+		flag = flags2test[i];
+
+		if (MFD_FLAGS_AVAILABLE(flag))
+			flags_available |= flag;
+	}
+
+	return flags_available;
+}
+
+int mfd_flags_available(const char *filename, const int lineno,
+		unsigned int flags)
+{
+	TEST(sys_memfd_create("dummy_call", flags));
 	if (TEST_RETURN < 0) {
-		if (TEST_ERRNO == EINVAL) {
-			tst_brk_(filename, lineno, TCONF | TTERRNO,
-				"memfd_create() not implemented");
+		if (TEST_ERRNO != EINVAL) {
+			tst_brk_(filename, lineno, TBROK | TTERRNO,
+					"memfd_create() failed");
 		}
 
-		tst_brk_(filename, lineno, TBROK | TTERRNO,
-			"memfd_create() failed");
+		return 0;
 	}
 
 	SAFE_CLOSE(TEST_RETURN);
+
+	return 1;
 }
 
 int check_mfd_new(const char *filename, const int lineno,
@@ -163,8 +187,8 @@
 	p = safe_mmap(file, lineno, addr, length, prot, flags, fd, offset);
 
 	tst_res_(file, lineno, TPASS,
-		"mmap(%p, %zu, %i, %i, %i, %zi) succeeded", addr,
-		length, prot, flags, fd, offset);
+		"mmap(%p, %zu, %i, %i, %i, %li) succeeded", addr,
+		length, prot, flags, fd, (long)offset);
 
 	return p;
 }
@@ -175,22 +199,22 @@
 	if (mmap(addr, length, prot, flags, fd, offset) != MAP_FAILED) {
 		safe_munmap(file, lineno, NULL, addr, length);
 		tst_res_(file, lineno, TFAIL,
-			"mmap(%p, %zu, %i, %i, %i, %zi) succeeded unexpectedly",
-			addr, length, prot, flags, fd, offset);
+			"mmap(%p, %zu, %i, %i, %i, %li) succeeded unexpectedly",
+			addr, length, prot, flags, fd, (long)offset);
 
 		return;
 	}
 
 	tst_res_(file, lineno, TPASS | TERRNO,
-		"mmap(%p, %zu, %i, %i, %i, %zi) failed as expected",
-		addr, length, prot, flags, fd, offset);
+		"mmap(%p, %zu, %i, %i, %i, %li) failed as expected",
+		addr, length, prot, flags, fd, (long)offset);
 }
 
 void check_munmap(const char *file, const int lineno, void *p, size_t length)
 {
 	safe_munmap(file, lineno, NULL, p, length);
 
-	tst_res_(file, lineno, TPASS, "munmap(%p, %ld) succeeded", p, length);
+	tst_res_(file, lineno, TPASS, "munmap(%p, %zu) succeeded", p, length);
 }
 
 void check_mfd_has_seals(const char *file, const int lineno, int fd, int seals)
@@ -211,10 +235,10 @@
 {
 	if (mprotect(addr, length, prot) < 0) {
 		tst_brk_(file, lineno, TFAIL | TERRNO,
-			"mprotect(%p, %ld, %d) failed", addr, length, prot);
+			"mprotect(%p, %zu, %d) failed", addr, length, prot);
 	}
 
-	tst_res_(file, lineno, TPASS, "mprotect(%p, %ld, %d) succeeded", addr,
+	tst_res_(file, lineno, TPASS, "mprotect(%p, %zu, %d) succeeded", addr,
 		length, prot);
 }
 
@@ -289,7 +313,7 @@
 	void *p;
 
 	safe_read(filename, lineno, NULL, 1, fd, buf, sizeof(buf));
-	tst_res_(filename, lineno, TPASS, "read(%d, %s, %ld) succeeded", fd,
+	tst_res_(filename, lineno, TPASS, "read(%d, %s, %zu) succeeded", fd,
 		buf, sizeof(buf));
 
 	/* verify PROT_READ *is* allowed */
@@ -431,13 +455,13 @@
 
 	if (pwrite(fd, buf, sizeof(buf), 0) != sizeof(buf)) {
 		tst_res_(filename, lineno, TFAIL | TERRNO,
-			"pwrite(%d, %s, %ld, %d) failed",
+			"pwrite(%d, %s, %zu, %d) failed",
 			fd, buf, sizeof(buf), 0);
 
 		return;
 	}
 
-	tst_res_(filename, lineno, TPASS, "pwrite(%d, %s, %ld, %d) succeeded",
+	tst_res_(filename, lineno, TPASS, "pwrite(%d, %s, %zu, %d) succeeded",
 		fd, buf, sizeof(buf), 0);
 
 	check_mfd_size(filename, lineno, fd, MFD_DEF_SIZE * 8);
@@ -450,12 +474,12 @@
 
 	if (pwrite(fd, buf, sizeof(buf), 0) == sizeof(buf)) {
 		tst_res_(filename, lineno, TFAIL,
-			"pwrite(%d, %s, %ld, %d) didn't fail as expected",
+			"pwrite(%d, %s, %zu, %d) didn't fail as expected",
 			fd, buf, sizeof(buf), 0);
 
 		return;
 	}
 
-	tst_res_(filename, lineno, TPASS, "pwrite(%d, %s, %ld, %d) succeeded",
+	tst_res_(filename, lineno, TPASS, "pwrite(%d, %s, %zu, %d) succeeded",
 		fd, buf, sizeof(buf), 0);
 }
diff --git a/testcases/kernel/syscalls/memfd_create/memfd_create_common.h b/testcases/kernel/syscalls/memfd_create/memfd_create_common.h
index 6329ac3..60ad895 100644
--- a/testcases/kernel/syscalls/memfd_create/memfd_create_common.h
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create_common.h
@@ -20,10 +20,17 @@
 #include <lapi/fcntl.h>
 #include <lapi/memfd.h>
 
+/* change macros accordingly if any flags need to be added in the future */
+#define FLAGS_ALL_ARRAY_INITIALIZER {MFD_CLOEXEC, MFD_ALLOW_SEALING}
+#define FLAGS_ALL_MASK              (MFD_CLOEXEC | MFD_ALLOW_SEALING)
+
 #define MFD_DEF_SIZE 8192
 
-#define ASSERT_HAVE_MEMFD_CREATE() \
-	assert_have_memfd_create(__FILE__, __LINE__)
+#define GET_MFD_ALL_AVAILABLE_FLAGS() \
+	get_mfd_all_available_flags(__FILE__, __LINE__)
+
+#define MFD_FLAGS_AVAILABLE(flags) \
+	mfd_flags_available(__FILE__, __LINE__, (flags))
 
 #define CHECK_MFD_NEW(name, sz, flags) \
 	check_mfd_new(__FILE__, __LINE__, (name), (sz), (flags))
@@ -89,7 +96,11 @@
 #define CHECK_MFD_NON_GROWABLE_BY_WRITE(fd) \
 	check_mfd_non_growable_by_write(__FILE__, __LINE__, (fd))
 
-void assert_have_memfd_create(const char *filename, const int lineno);
+int mfd_flags_available(const char *filename, const int lineno,
+		unsigned int flags);
+
+int get_mfd_all_available_flags(const char *filename, const int lineno);
+
 int sys_memfd_create(const char *name, unsigned int flags);
 
 int check_fallocate(const char *filename, const int lineno, int fd,
diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages01.c b/testcases/kernel/syscalls/migrate_pages/migrate_pages01.c
index 4a972b3..88a3721 100644
--- a/testcases/kernel/syscalls/migrate_pages/migrate_pages01.c
+++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages01.c
@@ -44,7 +44,7 @@
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "numa_helper.h"
 #include "migrate_pages_common.h"
 
diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
index 2caa4e7..4b1126e 100644
--- a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
+++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
@@ -48,7 +48,7 @@
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "numa_helper.h"
 #include "migrate_pages_common.h"
 
diff --git a/testcases/kernel/syscalls/mknod/mknod01.c b/testcases/kernel/syscalls/mknod/mknod01.c
index c4da3a2..f79e5fa 100644
--- a/testcases/kernel/syscalls/mknod/mknod01.c
+++ b/testcases/kernel/syscalls/mknod/mknod01.c
@@ -39,6 +39,7 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/mknodat/mknodat.h b/testcases/kernel/syscalls/mknodat/mknodat.h
index ac14157..577d5ac 100644
--- a/testcases/kernel/syscalls/mknodat/mknodat.h
+++ b/testcases/kernel/syscalls/mknodat/mknodat.h
@@ -22,7 +22,7 @@
 #define MKNODAT_H
 
 #include <sys/types.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_MKNODAT)
 int mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev)
diff --git a/testcases/kernel/syscalls/mmap/mmap01.c b/testcases/kernel/syscalls/mmap/mmap01.c
index 41183d1..dc94baa 100644
--- a/testcases/kernel/syscalls/mmap/mmap01.c
+++ b/testcases/kernel/syscalls/mmap/mmap01.c
@@ -80,8 +80,8 @@
 		 * with write access.
 		 */
 		errno = 0;
-		addr = mmap(addr, page_sz, PROT_READ | PROT_WRITE,
-			    MAP_FILE | MAP_SHARED | MAP_FIXED, fildes, 0);
+		addr = mmap(NULL, page_sz, PROT_READ | PROT_WRITE,
+			    MAP_FILE | MAP_SHARED, fildes, 0);
 
 		/* Check for the return value of mmap() */
 		if (addr == MAP_FAILED) {
@@ -182,23 +182,6 @@
 		tst_brkm(TFAIL, cleanup, "calloc failed (dummy)");
 	}
 
-	/*
-	 * Initialize addr to align with the first segment boundary address
-	 * above the break address of the process.
-	 */
-	addr = (void *)(((intptr_t) sbrk(0) + (SHMLBA - 1)) & ~(SHMLBA - 1));
-
-	/* Set the break address of the process to the addr plus one
-	 * page size.
-	 */
-	if ((intptr_t) sbrk(SHMLBA + page_sz) == -1) {
-		tst_brkm(TFAIL | TERRNO, cleanup,
-			 "sbrk(SHMLBA + page_sz) failed");
-	}
-
-	/* Initialize one page region from addr with 'A' */
-	memset(addr, 'A', page_sz);
-
 	/* Create the command which will be executed in the test */
 	sprintf(cmd_buffer, "grep XYZ %s/%s > /dev/null", Path_name, TEMPFILE);
 }
diff --git a/testcases/kernel/syscalls/mmap/mmap12.c b/testcases/kernel/syscalls/mmap/mmap12.c
index 2b9c866..05ace6a 100644
--- a/testcases/kernel/syscalls/mmap/mmap12.c
+++ b/testcases/kernel/syscalls/mmap/mmap12.c
@@ -40,57 +40,17 @@
 #include <sys/mman.h>
 #include <sys/shm.h>
 
-#include "test.h"
+#include "tst_test.h"
 
 #define TEMPFILE        "mmapfile"
 #define PATHLEN         256
 #define MMAPSIZE        (1UL<<20)
 
-char *TCID = "mmap12";
-int TST_TOTAL = 1;
-
 static int fildes;
 static char *addr;
 
-static int page_check(void);
-static void setup(void);
-static void cleanup(void);
-
-int main(int argc, char *argv[])
+static void page_check(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		addr = mmap(NULL, MMAPSIZE, PROT_READ | PROT_WRITE,
-			    MAP_PRIVATE | MAP_POPULATE, fildes, 0);
-
-		if (addr == MAP_FAILED) {
-			tst_resm(TFAIL | TERRNO, "mmap of %s failed", TEMPFILE);
-			continue;
-		}
-
-		if (page_check())
-			tst_resm(TFAIL, "Not all pages are present");
-		else
-			tst_resm(TPASS, "Functionality of mmap() "
-						"successful");
-		if (munmap(addr, MMAPSIZE) != 0)
-			tst_brkm(TFAIL | TERRNO, NULL, "munmap failed");
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static int page_check(void)
-{
-	int ret;
 	int i = 1;
 	int flag = 0;
 	int pm;
@@ -110,28 +70,27 @@
 	pm = open("/proc/self/pagemap", O_RDONLY);
 	if (pm == -1) {
 		if ((errno == EPERM) && (geteuid() != 0)) {
-			tst_brkm(TCONF | TERRNO, NULL,
+			tst_res(TCONF | TERRNO,
 				"don't have permission to open dev pagemap");
+			return;
 		} else {
-			tst_brkm(TFAIL | TERRNO, NULL,
-				"Open dev pagemap failed");
+			tst_brk(TFAIL | TERRNO, "pen dev pagemap failed");
 		}
 	}
 
-	offset = lseek(pm, index, SEEK_SET);
+	offset = SAFE_LSEEK(pm, index, SEEK_SET);
 	if (offset != index)
-		tst_brkm(TFAIL | TERRNO, NULL, "Reposition offset failed");
+		tst_brk(TFAIL | TERRNO, "Reposition offset failed");
 
 	while (i <= num_pages) {
-		ret = read(pm, &pagemap, sizeof(uint64_t));
-		if (ret < 0)
-			tst_brkm(TFAIL | TERRNO, NULL, "Read pagemap failed");
+		SAFE_READ(1, pm, &pagemap, sizeof(uint64_t));
+
 		/*
 		 * Check if the page is present.
 		 */
 		if (!(pagemap & (1ULL<<63))) {
-			tst_resm(TINFO, "The %dth page addressed at %lX is not "
-					"present", i, vmstart + i * page_sz);
+			tst_res(TINFO, "The %dth page addressed at %lX is not "
+				       "present", i, vmstart + i * page_sz);
 			flag = 1;
 		}
 
@@ -140,36 +99,54 @@
 
 	close(pm);
 
-	if (flag)
-		return 1;
+	if (!flag)
+		tst_res(TINFO, "All pages are present");
+}
 
-	return 0;
+void verify_mmap(void)
+{
+	unsigned int i;
+
+	addr = mmap(NULL, MMAPSIZE, PROT_READ | PROT_WRITE,
+		    MAP_PRIVATE | MAP_POPULATE, fildes, 0);
+
+	if (addr == MAP_FAILED) {
+		tst_res(TFAIL | TERRNO, "mmap of %s failed", TEMPFILE);
+		return;
+	}
+
+	page_check();
+
+	for (i = 0; i < MMAPSIZE; i++) {
+		if (addr[i]) {
+			tst_res(TFAIL, "Non-zero byte at offset %i", i);
+			goto unmap;
+		}
+	}
+
+	tst_res(TPASS, "File mapped properly");
+
+unmap:
+	SAFE_MUNMAP(addr, MMAPSIZE);
 }
 
 static void setup(void)
 {
-	tst_sig(FORK, DEF_HANDLER, cleanup);
+	fildes = SAFE_OPEN(TEMPFILE, O_RDWR | O_CREAT, 0766);
 
-	if ((tst_kvercmp(2, 6, 25)) < 0)
-		tst_brkm(TCONF, NULL,
-			"This test can only run on kernels that are 2.6.25 and "
-			"higher");
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0766);
-	if (fildes < 0)
-		tst_brkm(TFAIL, cleanup, "opening %s failed", TEMPFILE);
-
-	if (ftruncate(fildes, MMAPSIZE) < 0)
-		tst_brkm(TFAIL | TERRNO, cleanup, "ftruncate file failed");
-
+	SAFE_FTRUNCATE(fildes, MMAPSIZE);
 }
 
 static void cleanup(void)
 {
-	close(fildes);
-	tst_rmdir();
+	if (fildes > 0)
+		SAFE_CLOSE(fildes);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_mmap,
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.25",
+};
diff --git a/testcases/kernel/syscalls/mount/Makefile b/testcases/kernel/syscalls/mount/Makefile
index 4c6aa45..5caed98 100644
--- a/testcases/kernel/syscalls/mount/Makefile
+++ b/testcases/kernel/syscalls/mount/Makefile
@@ -27,6 +27,4 @@
 
 CFLAGS			+= -D_GNU_SOURCE
 
-INSTALL_TARGETS		:= test_mount
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mount/mount02.c b/testcases/kernel/syscalls/mount/mount02.c
index 15dad0e..392b4fd 100644
--- a/testcases/kernel/syscalls/mount/mount02.c
+++ b/testcases/kernel/syscalls/mount/mount02.c
@@ -41,6 +41,7 @@
 #include <sys/mount.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 #include <fcntl.h>
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/move_pages/move_pages08.c b/testcases/kernel/syscalls/move_pages/move_pages08.c
index e0705a2..66544eb 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages08.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages08.c
@@ -54,6 +54,7 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <errno.h>
+#include <limits.h>
 #include "test.h"
 #include "move_pages_support.h"
 
diff --git a/testcases/kernel/syscalls/move_pages/move_pages12.c b/testcases/kernel/syscalls/move_pages/move_pages12.c
index dda10d6..4c7d5c2 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages12.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages12.c
@@ -165,9 +165,15 @@
 		tst_brk(TBROK | TERRNO, "mbind() failed");
 	}
 
-	numa_bitmask_free(bm);
+	TEST(mlock(mem, size));
+	if (TEST_RETURN) {
+		SAFE_MUNMAP(mem, size);
+		if (TEST_ERRNO == ENOMEM || TEST_ERRNO == EAGAIN)
+			tst_brk(TCONF, "Cannot lock huge pages");
+		tst_brk(TBROK | TTERRNO, "mlock failed");
+	}
 
-	memset(mem, 0, size);
+	numa_bitmask_free(bm);
 
 	SAFE_MUNMAP(mem, size);
 }
@@ -231,8 +237,8 @@
 		SAFE_FILE_PRINTF(PATH_NR_HUGEPAGES, "%ld", orig_hugepages + 8);
 	}
 
-	alloc_free_huge_on_node(node1, 4 * hpsz);
-	alloc_free_huge_on_node(node2, 4 * hpsz);
+	alloc_free_huge_on_node(node1, 4L * hpsz);
+	alloc_free_huge_on_node(node2, 4L * hpsz);
 }
 
 static void cleanup(void)
@@ -252,7 +258,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "move_pages12",
 	.min_kver = "2.6.32",
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/mprotect/mprotect02.c b/testcases/kernel/syscalls/mprotect/mprotect02.c
index a513493..31455c7 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect02.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect02.c
@@ -59,7 +59,8 @@
 {
 	int lc;
 
-	int bytes_to_write, fd, num_bytes;
+	int bytes_to_write, fd;
+	unsigned int num_bytes;
 	pid_t pid;
 
 	tst_parse_opts(ac, av, NULL, NULL);
@@ -76,10 +77,7 @@
 
 		do {
 
-			if (num_bytes > strlen(buf))
-				bytes_to_write = strlen(buf);
-			else
-				bytes_to_write = num_bytes;
+			bytes_to_write = MIN(strlen(buf), num_bytes);
 
 			num_bytes -=
 			    SAFE_WRITE(cleanup, 1, fd, buf, bytes_to_write);
diff --git a/testcases/kernel/syscalls/mq_notify/Makefile b/testcases/kernel/syscalls/mq_notify/Makefile
index 2e1628e..7b93042 100644
--- a/testcases/kernel/syscalls/mq_notify/Makefile
+++ b/testcases/kernel/syscalls/mq_notify/Makefile
@@ -20,7 +20,7 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-CPPFLAGS		?= -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 LDLIBS			+= -lpthread -lrt
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_notify/mq_notify01.c b/testcases/kernel/syscalls/mq_notify/mq_notify01.c
index 99ec2ed..b4d0c92 100644
--- a/testcases/kernel/syscalls/mq_notify/mq_notify01.c
+++ b/testcases/kernel/syscalls/mq_notify/mq_notify01.c
@@ -1,115 +1,97 @@
 /*
- * Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd
- *          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
- *		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
- *		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
- * Copyright (c) 2016 Linux Test Project
+ * Copyright (c) Crackerjack Project., 2007-2008, Hitachi, Ltd
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
  *
- * 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.
+ * Authors:
+ * Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
+ * Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
+ * Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
  *
- * 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.
+ * 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 would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-#define _XOPEN_SOURCE 600
-#include <sys/types.h>
-#include <sys/stat.h>
+
 #include <limits.h>
 #include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <mqueue.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <fcntl.h>
 
 #include "tst_test.h"
 #include "tst_safe_posix_ipc.h"
 
-#define MAX_MSGSIZE     8192
-#define MSG_SIZE	16
+static int fd, fd_root, fd_nonblock, fd_maxint = INT_MAX - 1, fd_invalid = -1;
+
+#include "mq.h"
+
 #define USER_DATA       0x12345678
-#define QUEUE_NAME	"/test_mqueue"
 
 static char *str_debug;
-static char smsg[MAX_MSGSIZE];
 
 static volatile sig_atomic_t notified, cmp_ok;
 static siginfo_t info;
 
-enum test_type {
-	NORMAL,
-	FD_NONE,
-	FD_NOT_EXIST,
-	FD_FILE,
-	ALREADY_REGISTERED,
-};
-
 struct test_case {
+	int *fd;
+	int already_registered;
 	int notify;
-	int ttype;
-	const char *desc;
 	int ret;
 	int err;
 };
 
-#define TYPE_NAME(x) .ttype = x, .desc = #x
 static struct test_case tcase[] = {
 	{
-		TYPE_NAME(NORMAL),
+		.fd = &fd,
 		.notify = SIGEV_NONE,
 		.ret = 0,
 		.err = 0,
 	},
 	{
-		TYPE_NAME(NORMAL),
+		.fd = &fd,
 		.notify = SIGEV_SIGNAL,
 		.ret = 0,
 		.err = 0,
 	},
 	{
-		TYPE_NAME(NORMAL),
+		.fd = &fd,
 		.notify = SIGEV_THREAD,
 		.ret = 0,
 		.err = 0,
 	},
 	{
-		TYPE_NAME(FD_NONE),
+		.fd = &fd_invalid,
 		.notify = SIGEV_NONE,
 		.ret = -1,
 		.err = EBADF,
 	},
 	{
-		TYPE_NAME(FD_NOT_EXIST),
+		.fd = &fd_maxint,
 		.notify = SIGEV_NONE,
 		.ret = -1,
 		.err = EBADF,
 	},
 	{
-		TYPE_NAME(FD_FILE),
+		.fd = &fd_root,
 		.notify = SIGEV_NONE,
 		.ret = -1,
 		.err = EBADF,
 	},
 	{
-		TYPE_NAME(ALREADY_REGISTERED),
+		.fd = &fd,
 		.notify = SIGEV_NONE,
+		.already_registered = 1,
 		.ret = -1,
 		.err = EBUSY,
 	},
 };
 
-static void setup(void)
-{
-	int i;
-
-	for (i = 0; i < MSG_SIZE; i++)
-		smsg[i] = i;
-}
 static void sigfunc(int signo LTP_ATTRIBUTE_UNUSED, siginfo_t *si,
 	void *data LTP_ATTRIBUTE_UNUSED)
 {
@@ -131,42 +113,12 @@
 
 static void do_test(unsigned int i)
 {
-	int rc, fd = -1;
-	struct sigevent ev;
 	struct sigaction sigact;
-	struct timespec abs_timeout;
 	struct test_case *tc = &tcase[i];
-
-	notified = cmp_ok = 1;
-
-	/* Don't timeout. */
-	abs_timeout.tv_sec = 0;
-	abs_timeout.tv_nsec = 0;
-
-	/*
-	 * When test ended with SIGTERM etc, mq descriptor is left remains.
-	 * So we delete it first.
-	 */
-	mq_unlink(QUEUE_NAME);
-
-	switch (tc->ttype) {
-	case FD_NONE:
-		break;
-	case FD_NOT_EXIST:
-		fd = INT_MAX - 1;
-		break;
-	case FD_FILE:
-		fd = open("/", O_RDONLY);
-		if (fd < 0) {
-			tst_res(TBROK | TERRNO, "can't open \"/\".");
-			goto CLEANUP;
-		}
-		break;
-	default:
-		fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
-	}
+	struct sigevent ev;
 
 	ev.sigev_notify = tc->notify;
+	notified = cmp_ok = 1;
 
 	switch (tc->notify) {
 	case SIGEV_SIGNAL:
@@ -177,7 +129,10 @@
 		memset(&sigact, 0, sizeof(sigact));
 		sigact.sa_sigaction = sigfunc;
 		sigact.sa_flags = SA_SIGINFO;
-		rc = sigaction(SIGUSR1, &sigact, NULL);
+		if (sigaction(SIGUSR1, &sigact, NULL) == -1) {
+			tst_res(TFAIL | TTERRNO, "sigaction failed");
+			return;
+		}
 		break;
 	case SIGEV_THREAD:
 		notified = cmp_ok = 0;
@@ -187,54 +142,72 @@
 		break;
 	}
 
-	if (tc->ttype == ALREADY_REGISTERED) {
-		rc = mq_notify(fd, &ev);
-		if (rc < 0) {
-			tst_res(TBROK | TERRNO, "mq_notify failed");
-			goto CLEANUP;
-		}
+	if (tc->already_registered && mq_notify(*tc->fd, &ev) == -1) {
+		tst_res(TFAIL | TERRNO, "mq_notify(%d, %p) failed", fd, &ev);
+		return;
 	}
 
-	/* test */
-	TEST(mq_notify(fd, &ev));
-	if (TEST_RETURN >= 0) {
-		rc = mq_timedsend(fd, smsg, MSG_SIZE, 0, &abs_timeout);
-		if (rc < 0) {
-			tst_res(TFAIL | TTERRNO, "mq_timedsend failed");
-			goto CLEANUP;
-		}
+	TEST(mq_notify(*tc->fd, &ev));
 
-		while (!notified)
-			usleep(10000);
+	if (TEST_RETURN < 0) {
+		if (tc->err != TEST_ERRNO)
+			tst_res(TFAIL | TTERRNO,
+				"mq_notify failed unexpectedly, expected %s",
+				tst_strerrno(tc->err));
+		else
+			tst_res(TPASS | TTERRNO, "mq_notify failed expectedly");
 
-		if (str_debug && tc->notify == SIGEV_SIGNAL) {
-			tst_res(TINFO, "si_code  E:%d,\tR:%d",
-				info.si_code, SI_MESGQ);
-			tst_res(TINFO, "si_signo E:%d,\tR:%d",
-				info.si_signo, SIGUSR1);
-			tst_res(TINFO, "si_value E:0x%x,\tR:0x%x",
-				info.si_value.sival_int, USER_DATA);
-			tst_res(TINFO, "si_pid   E:%d,\tR:%d",
-				info.si_pid, getpid());
-			tst_res(TINFO, "si_uid   E:%d,\tR:%d",
-				info.si_uid, getuid());
-		}
+		/* unregister notification */
+		if (*tc->fd == fd)
+			mq_notify(*tc->fd, NULL);
+
+		return;
 	}
 
-	if ((TEST_RETURN != 0 && TEST_ERRNO != tc->err) || !cmp_ok) {
-		tst_res(TFAIL | TTERRNO, "%s r/w check returned: %ld, "
-			"expected: %d, expected errno: %s (%d)", tc->desc,
-			TEST_RETURN, tc->ret, tst_strerrno(tc->err), tc->err);
-	} else {
-		tst_res(TPASS | TTERRNO, "%s returned: %ld",
-			tc->desc, TEST_RETURN);
+	TEST(mq_timedsend(*tc->fd, smsg, MSG_LENGTH, 0,
+		&((struct timespec){0})));
+
+	if (*tc->fd == fd)
+		cleanup_queue(fd);
+
+	if (TEST_RETURN < 0) {
+		tst_res(TFAIL | TTERRNO, "mq_timedsend failed");
+		return;
 	}
 
-CLEANUP:
-	if (fd >= 0) {
-		close(fd);
-		mq_unlink(QUEUE_NAME);
+	while (!notified)
+		usleep(10000);
+
+	if (str_debug && tc->notify == SIGEV_SIGNAL) {
+		tst_res(TINFO, "si_code  E:%d,\tR:%d",
+			info.si_code, SI_MESGQ);
+		tst_res(TINFO, "si_signo E:%d,\tR:%d",
+			info.si_signo, SIGUSR1);
+		tst_res(TINFO, "si_value E:0x%x,\tR:0x%x",
+			info.si_value.sival_int, USER_DATA);
+		tst_res(TINFO, "si_pid   E:%d,\tR:%d",
+			info.si_pid, getpid());
+		tst_res(TINFO, "si_uid   E:%d,\tR:%d",
+			info.si_uid, getuid());
 	}
+
+	if (TEST_RETURN < 0) {
+		if (tc->err != TEST_ERRNO)
+			tst_res(TFAIL | TTERRNO,
+				"mq_timedsend failed unexpectedly, expected %s",
+				tst_strerrno(tc->err));
+		else
+			tst_res(TPASS | TTERRNO, "mq_timedsend failed expectedly");
+		return;
+	}
+
+	if (tc->ret != TEST_RETURN) {
+		tst_res(TFAIL, "mq_timedsend returned %ld, expected %d",
+			TEST_RETURN, tc->ret);
+		return;
+	}
+
+	tst_res(TPASS, "mq_notify and mq_timedsend exited expectedly");
 }
 
 static struct tst_option options[] = {
@@ -243,9 +216,9 @@
 };
 
 static struct tst_test test = {
-	.tid = "mq_notify01",
 	.tcnt = ARRAY_SIZE(tcase),
 	.test = do_test,
 	.options = options,
-	.setup = setup,
+	.setup = setup_common,
+	.cleanup = cleanup_common,
 };
diff --git a/testcases/kernel/syscalls/mq_open/mq_open01.c b/testcases/kernel/syscalls/mq_open/mq_open01.c
index 9d2b136..3f4bf7e 100644
--- a/testcases/kernel/syscalls/mq_open/mq_open01.c
+++ b/testcases/kernel/syscalls/mq_open/mq_open01.c
@@ -298,7 +298,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "mq_open01",
 	.tcnt = ARRAY_SIZE(tcase),
 	.test = do_test,
 	.needs_root = 1,
diff --git a/testcases/kernel/syscalls/mq_timedreceive/Makefile b/testcases/kernel/syscalls/mq_timedreceive/Makefile
index 2e1628e..7b93042 100644
--- a/testcases/kernel/syscalls/mq_timedreceive/Makefile
+++ b/testcases/kernel/syscalls/mq_timedreceive/Makefile
@@ -20,7 +20,7 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-CPPFLAGS		?= -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 LDLIBS			+= -lpthread -lrt
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
index 32ab7a1..f3f5295 100644
--- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
+++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
@@ -1,9 +1,11 @@
 /*
- * Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd
- *          Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
- *		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
- *		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
- * Copyright (c) 2016-2017 Linux Test Project
+ * Copyright (c) Crackerjack Project., 2007-2008, Hitachi, Ltd
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * Authors:
+ * Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
+ * Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
+ * Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -16,306 +18,188 @@
  * 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 the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <errno.h>
 #include <limits.h>
-#include <mqueue.h>
 
-#include "tst_test.h"
-#include "tst_sig_proc.h"
-#include "tst_safe_posix_ipc.h"
+static int fd, fd_root, fd_nonblock, fd_maxint = INT_MAX - 1, fd_invalid = -1;
 
-static struct sigaction act;
-static pid_t pid;
-static int fd, fd_root;
-static struct timespec timeout_ts;
-static struct timespec eintr_ts;
+#include "mq_timed.h"
 
-struct test_case {
-	int len;
-	unsigned prio;
-	struct timespec *rq;
-	int fd;
-	int invalid_msg;
-	int send;
-	int ret;
-	int err;
-	void (*setup)(void);
-	void (*cleanup)(void);
-};
+static struct timespec ts;
 
-#define MAX_MSGSIZE     8192
-
-#define QUEUE_NAME	"/test_mqueue"
-
-static void create_queue(void);
-static void create_queue_nonblock(void);
-static void create_queue_sig(void);
-static void create_queue_timeout(void);
-static void open_fd(void);
-static void unlink_queue(void);
-static void unlink_queue_sig(void);
-
-static const struct test_case tcase[] = {
+static struct test_case tcase[] = {
 	{
-		.setup = create_queue,
-		.cleanup = unlink_queue,
-		.send = 1,
+		.fd = &fd,
 		.len = 0,
+		.send = 1,
 		.ret = 0,
 		.err = 0,
 	},
 	{
-		.setup = create_queue,
-		.cleanup = unlink_queue,
-		.send = 1,
+		.fd = &fd,
 		.len = 1,
+		.send = 1,
 		.ret = 0,
 		.err = 0,
 	},
 	{
-		.setup = create_queue,
-		.cleanup = unlink_queue,
-		.send = 1,
+		.fd = &fd,
 		.len = MAX_MSGSIZE,
+		.send = 1,
 		.ret = 0,
 		.err = 0,
 	},
 	{
-		.setup = create_queue,
-		.cleanup = unlink_queue,
-		.send = 1,
+		.fd = &fd,
 		.len = 1,
-		.prio = 32767,	/* max priority */
+		.send = 1,
+		.prio = MQ_PRIO_MAX - 1,
 		.ret = 0,
 		.err = 0,
 	},
 	{
-		.setup = create_queue,
-		.cleanup = unlink_queue,
+		.fd = &fd,
 		.invalid_msg = 1,
-		.send = 1,
 		.len = 0,
+		.send = 1,
 		.ret = -1,
 		.err = EMSGSIZE,
 	},
 	{
+		.fd = &fd_invalid,
 		.len = 0,
-		.fd = -1,
 		.ret = -1,
 		.err = EBADF,
 	},
 	{
+		.fd = &fd_maxint,
 		.len = 0,
-		.fd = INT_MAX - 1,
 		.ret = -1,
 		.err = EBADF,
 	},
 	{
+		.fd = &fd_root,
 		.len = 0,
 		.ret = -1,
 		.err = EBADF,
-		.setup = open_fd,
 	},
 	{
+		.fd = &fd_nonblock,
 		.len = 16,
 		.ret = -1,
 		.err = EAGAIN,
-		.setup = create_queue_nonblock,
-		.cleanup = unlink_queue,
 	},
 	{
+		.fd = &fd,
 		.len = 16,
 		.rq = &(struct timespec) {.tv_sec = -1, .tv_nsec = 0},
 		.ret = -1,
 		.err = EINVAL,
-		.setup = create_queue,
-		.cleanup = unlink_queue,
 	},
 	{
+		.fd = &fd,
 		.len = 16,
 		.rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = -1},
 		.ret = -1,
 		.err = EINVAL,
-		.setup = create_queue,
-		.cleanup = unlink_queue,
 	},
 	{
+		.fd = &fd,
 		.len = 16,
 		.rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = 1000000000},
 		.ret = -1,
 		.err = EINVAL,
-		.setup = create_queue,
-		.cleanup = unlink_queue,
 	},
 	{
+		.fd = &fd,
 		.len = 16,
+		.timeout = 1,
 		.ret = -1,
-		.rq = &timeout_ts,
+		.rq = &ts,
 		.err = ETIMEDOUT,
-		.setup = create_queue_timeout,
-		.cleanup = unlink_queue,
 	},
 	{
+		.fd = &fd,
 		.len = 16,
-		.rq = &eintr_ts,
+		.signal = 1,
+		.rq = &ts,
 		.ret = -1,
 		.err = EINTR,
-		.setup = create_queue_sig,
-		.cleanup = unlink_queue_sig,
 	},
 };
 
-static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
-{
-}
-
-static void setup(void)
-{
-	act.sa_handler = sighandler;
-	sigaction(SIGINT, &act, NULL);
-
-	fd_root = SAFE_OPEN("/", O_RDONLY);
-}
-
-static void cleanup(void)
-{
-	if (fd > 0)
-		SAFE_CLOSE(fd);
-
-	if (fd_root > 0)
-		SAFE_CLOSE(fd_root);
-}
-
-static void create_queue(void)
-{
-	fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
-}
-
-static void create_queue_nonblock(void)
-{
-	fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR | O_NONBLOCK,
-		S_IRWXU, NULL);
-}
-
-static void create_queue_sig(void)
-{
-	clock_gettime(CLOCK_REALTIME, &eintr_ts);
-	eintr_ts.tv_sec += 3;
-
-	create_queue();
-	pid = create_sig_proc(SIGINT, 40, 200000);
-}
-
-static void create_queue_timeout(void)
-{
-	clock_gettime(CLOCK_REALTIME, &timeout_ts);
-	timeout_ts.tv_nsec += 50000000;
-	timeout_ts.tv_sec += timeout_ts.tv_nsec / 1000000000;
-	timeout_ts.tv_nsec %= 1000000000;
-
-	create_queue();
-}
-
-static void open_fd(void)
-{
-	fd = fd_root;
-}
-
-static void send_msg(int fd, int len, int prio)
-{
-	char smsg[MAX_MSGSIZE];
-	int i;
-
-	for (i = 0; i < len; i++)
-		smsg[i] = i;
-
-	if (mq_timedsend(fd, smsg, len, prio,
-		&((struct timespec){0})) < 0)
-		tst_brk(TBROK | TERRNO, "mq_timedsend failed");
-}
-
-static void unlink_queue(void)
-{
-	if (fd > 0)
-		SAFE_CLOSE(fd);
-
-	mq_unlink(QUEUE_NAME);
-}
-
-static void unlink_queue_sig(void)
-{
-	SAFE_KILL(pid, SIGTERM);
-	SAFE_WAIT(NULL);
-
-	unlink_queue();
-}
-
 static void do_test(unsigned int i)
 {
 	const struct test_case *tc = &tcase[i];
-	char rmsg[MAX_MSGSIZE];
-	unsigned prio;
-	size_t msg_len = MAX_MSGSIZE;
+	unsigned int j;
+	unsigned int prio;
+	size_t len = MAX_MSGSIZE;
+	char rmsg[len];
+	pid_t pid = -1;
 
-	/*
-	 * When test ended with SIGTERM etc, mq descriptor is left remains.
-	 * So we delete it first.
-	 */
-	mq_unlink(QUEUE_NAME);
+	if (tc->signal)
+		pid = set_sig(tc->rq);
 
-	if (tc->fd)
-		fd = tc->fd;
-
-	if (tc->setup)
-		tc->setup();
+	if (tc->timeout)
+		set_timeout(tc->rq);
 
 	if (tc->send)
-		send_msg(fd, tc->len, tc->prio);
+		send_msg(*tc->fd, tc->len, tc->prio);
 
 	if (tc->invalid_msg)
-		msg_len -= 1;
+		len -= 1;
 
-	TEST(mq_timedreceive(fd, rmsg, msg_len, &prio, tc->rq));
+	TEST(mq_timedreceive(*tc->fd, rmsg, len, &prio, tc->rq));
 
-	if (tc->cleanup)
-		tc->cleanup();
+	if (pid > 0)
+		kill_pid(pid);
+
+	if (*tc->fd == fd)
+		cleanup_queue(fd);
 
 	if (TEST_RETURN < 0) {
-		if (TEST_ERRNO != tc->err) {
+		if (tc->err != TEST_ERRNO)
 			tst_res(TFAIL | TTERRNO,
 				"mq_timedreceive failed unexpectedly, expected %s",
 				tst_strerrno(tc->err));
-		} else {
+		else
 			tst_res(TPASS | TTERRNO, "mq_timedreceive failed expectedly");
-		}
+
 		return;
 	}
 
-
-	if (TEST_RETURN != tc->len) {
-		tst_res(TFAIL | TTERRNO, "mq_timedreceive wrong msg_len returned %ld, expected %d",
+	if (tc->len != TEST_RETURN) {
+		tst_res(TFAIL, "mq_timedreceive wrong length %ld, expected %zu",
 			TEST_RETURN, tc->len);
 		return;
 	}
 
 	if (tc->prio != prio) {
-		tst_res(TFAIL | TTERRNO, "mq_timedreceive wrong prio returned %d, expected %d",
+		tst_res(TFAIL, "mq_timedreceive wrong prio %d, expected %d",
 			prio, tc->prio);
 		return;
 	}
 
-	tst_res(TPASS, "mq_timedreceive returned %ld prio %u", TEST_RETURN, prio);
+	for (j = 0; j < tc->len; j++) {
+		if (rmsg[j] != smsg[j]) {
+			tst_res(TFAIL,
+				"mq_timedreceive wrong data %d in %u, expected %d",
+				rmsg[j], i, smsg[j]);
+			return;
+		}
+	}
+
+	tst_res(TPASS, "mq_timedreceive returned %ld, priority %u, length: %zu",
+			TEST_RETURN, prio, len);
 }
 
 static struct tst_test test = {
-	.tid = "mq_timedreceive01",
 	.tcnt = ARRAY_SIZE(tcase),
 	.test = do_test,
-	.setup = setup,
-	.cleanup = cleanup,
+	.setup = setup_common,
+	.cleanup = cleanup_common,
 	.forks_child = 1,
 };
diff --git a/testcases/kernel/syscalls/mq_timedsend/Makefile b/testcases/kernel/syscalls/mq_timedsend/Makefile
index 71ebae9..7b93042 100644
--- a/testcases/kernel/syscalls/mq_timedsend/Makefile
+++ b/testcases/kernel/syscalls/mq_timedsend/Makefile
@@ -20,6 +20,7 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 LDLIBS			+= -lpthread -lrt
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
index 77198ce..d54de1d 100644
--- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
+++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
@@ -1,480 +1,229 @@
-/********************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007-2008 ,Hitachi, Ltd			*/
-/*	  Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,		*/
-/*		       Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,		*/
-/*		       Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>		*/
-/*										*/
-/* 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	*/
-/* USA										*/
-/********************************************************************************/
-/************************************************************************/
-/*									*/
-/* File:	mq_timedsend01.c					*/
-/*									*/
-/* Description: This tests the mq_timedsend() syscall			*/
-/*									*/
-/* 									*/
-/*									*/
-/*									*/
-/*									*/
-/*									*/
-/* Usage:  <for command-line>						*/
-/* mq_timedsend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]			*/
-/*      where,  -c n : Run n copies concurrently.			*/
-/*	      -e   : Turn on errno logging.				*/
-/*	      -i n : Execute test n times.				*/
-/*	      -I x : Execute test for x seconds.			*/
-/*	      -P x : Pause for x seconds between iterations.		*/
-/*	      -t   : Turn on syscall timing.				*/
-/*									*/
-/* Total Tests: 1							*/
-/*									*/
-/* Test Name:   mq_timedsend01						*/
-/* History:     Porting from Crackerjack to LTP is done by		*/
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
-/************************************************************************/
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <getopt.h>
-#include <stdlib.h>
+/*
+ * Copyright (c) Crackerjack Project., 2007-2008, Hitachi, Ltd
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * Authors:
+ * Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
+ * Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
+ * Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
+ *
+ * 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 would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <mqueue.h>
-#include <time.h>
-#include <signal.h>
 #include <limits.h>
 
-#include "../utils/include_j_h.h"
-#include "../utils/common_j_h.c"
+static int fd, fd_root, fd_nonblock, fd_maxint = INT_MAX - 1, fd_invalid = -1;
+static struct timespec ts;
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
-
-char *TCID = "mq_timedsend01";
-int testno;
-int TST_TOTAL = 1;
-struct sigaction act;
-
-/*
- * sighandler()
- */
-void sighandler(int sig)
-{
-	if (sig == SIGINT)
-		return;
-	return;
-}
-
-/* Extern Global Functions */
-/******************************************************************************/
-/*									    */
-/* Function:    cleanup						       */
-/*									    */
-/* Description: Performs all one time clean up for this test on successful    */
-/*	      completion,  premature exit or  failure. Closes all temporary */
-/*	      files, removes all temporary directories exits the test with  */
-/*	      appropriate return code by calling tst_exit() function.       */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*	      On success - Exits calling tst_exit(). With '0' return code.  */
-/*									    */
-/******************************************************************************/
-void cleanup(void)
-{
-
-	tst_rmdir();
-}
-
-/* Local  Functions */
-/******************************************************************************/
-/*									    */
-/* Function:    setup							 */
-/*									    */
-/* Description: Performs all one time setup for this test. This function is   */
-/*	      typically used to capture signals, create temporary dirs      */
-/*	      and temporary files that may be used in the course of this    */
-/*	      test.							 */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits by calling cleanup().		      */
-/*	      On success - returns 0.				       */
-/*									    */
-/******************************************************************************/
-void setup(void)
-{
-
-	/* Capture signals if any */
-	act.sa_handler = sighandler;
-	sigfillset(&act.sa_mask);
-
-	sigaction(SIGINT, &act, NULL);
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
-/*
- * Macros
- */
-#define SYSCALL_NAME    "mq_timedsend"
-
-enum test_type {
-	NORMAL,
-	FD_NONE,
-	FD_NOT_EXIST,
-	FD_FILE,
-	FULL_QUEUE,
-	SEND_SIGINT,
-};
-
-/*
- * Data Structure
- */
-struct test_case {
-	int ttype;
-	int non_block;
-	int len;
-	unsigned prio;
-	time_t sec;
-	long nsec;
-	int ret;
-	int err;
-};
-
-#define MAX_MSG	 10
-#define MAX_MSGSIZE     8192
-
-/* Test cases
-*
-*   test status of errors on man page
-*
-*   EAGAIN	     v (would block)
-*   EBADF	      v (not a valid descriptor)
-*   EINTR	      v (interrupted by a signal)
-*   EINVAL	     v (1. invalid 'msg_prio' or
-*			 2. would block but timeout exists)
-*   EMSGSIZE	   v ('msg_len' exceeds the message size of the queue)
-*   ETIMEDOUT	  v (not block and timeout occured)
-*/
+#include "mq_timed.h"
 
 static struct test_case tcase[] = {
-	{			// case00
-	 .ttype = NORMAL,
-	 .len = 0,		// also success when size equals zero
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case01
-	 .ttype = NORMAL,
-	 .len = 1,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case02
-	 .ttype = NORMAL,
-	 .len = MAX_MSGSIZE,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case03
-	 .ttype = NORMAL,
-	 .len = 1,
-	 .prio = 32767,		// max priority
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case04
-	 .ttype = NORMAL,
-	 .len = MAX_MSGSIZE + 1,
-	 .ret = -1,
-	 .err = EMSGSIZE,
-	 },
-	{			// case05
-	 .ttype = FD_NONE,
-	 .len = 0,
-	 .ret = -1,
-	 .err = EBADF,
-	 },
-	{			// case06
-	 .ttype = FD_NOT_EXIST,
-	 .len = 0,
-	 .ret = -1,
-	 .err = EBADF,
-	 },
-	{			// case07
-	 .ttype = FD_FILE,
-	 .len = 0,
-	 .ret = -1,
-	 .err = EBADF,
-	 },
-	{			// case08
-	 .ttype = FULL_QUEUE,
-	 .non_block = 1,
-	 .len = 16,
-	 .ret = -1,
-	 .err = EAGAIN,
-	 },
-	{			// case09
-	 .ttype = NORMAL,
-	 .len = 1,
-	 .prio = 32768,		// max priority + 1
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case10
-	 .ttype = FULL_QUEUE,
-	 .len = 16,
-	 .sec = -1,
-	 .nsec = 0,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case11
-	 .ttype = FULL_QUEUE,
-	 .len = 16,
-	 .sec = 0,
-	 .nsec = -1,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case12
-	 .ttype = FULL_QUEUE,
-	 .len = 16,
-	 .sec = 0,
-	 .nsec = 1000000000,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case13
-	 .ttype = FULL_QUEUE,
-	 .len = 16,
-	 .sec = 0,
-	 .nsec = 999999999,
-	 .ret = -1,
-	 .err = ETIMEDOUT,
-	 },
-	{			// case14
-	 .ttype = SEND_SIGINT,
-	 .len = 16,
-	 .ret = -1,
-	 .sec = 3,
-	 .nsec = 0,
-	 .err = EINTR,
-	 },
+	{
+		.fd = &fd,
+		.len = 0,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.fd = &fd,
+		.len = 1,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.fd = &fd,
+		.len = MAX_MSGSIZE,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.fd = &fd,
+		.len = 1,
+		.prio = MQ_PRIO_MAX - 1,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.fd = &fd,
+		.len = MAX_MSGSIZE + 1,
+		.ret = -1,
+		.err = EMSGSIZE,
+	},
+	{
+		.fd = &fd_invalid,
+		.len = 0,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		.fd = &fd_maxint,
+		.len = 0,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		.fd = &fd_root,
+		.len = 0,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		.fd = &fd_nonblock,
+		.len = 16,
+		.ret = -1,
+		.err = EAGAIN,
+	},
+	{
+		.fd = &fd,
+		.len = 1,
+		.prio = MQ_PRIO_MAX,
+		.ret = -1,
+		.err = EINVAL,
+	},
+	{
+		.fd = &fd,
+		.len = 16,
+		.rq = &(struct timespec) {.tv_sec = -1, .tv_nsec = 0},
+		.send = 1,
+		.ret = -1,
+		.err = EINVAL,
+	},
+	{
+		.fd = &fd,
+		.len = 16,
+		.rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = -1},
+		.send = 1,
+		.ret = -1,
+		.err = EINVAL,
+	},
+	{
+		.fd = &fd,
+		.len = 16,
+		.rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = 1000000000},
+		.send = 1,
+		.ret = -1,
+		.err = EINVAL,
+	},
+	{
+		.fd = &fd,
+		.len = 16,
+		.rq = &ts,
+		.send = 1,
+		.timeout = 1,
+		.ret = -1,
+		.err = ETIMEDOUT,
+	},
+	{
+		.fd = &fd,
+		.len = 16,
+		.send = 1,
+		.signal = 1,
+		.rq = &ts,
+		.ret = -1,
+		.err = EINTR,
+	},
 };
 
-/*
- * do_test()
- *
- *   Input  : TestCase Data
- *   Return : RESULT_OK(0), RESULT_NG(1)
- *
- */
-
-static int do_test(struct test_case *tc)
+static void do_test(unsigned int i)
 {
-	int sys_ret;
-	int sys_errno;
-	int result = RESULT_OK;
-	int oflag;
-	int i, rc, cmp_ok = 1, fd = -1;
-	char smsg[MAX_MSGSIZE], rmsg[MAX_MSGSIZE];
-	struct timespec ts = { 0, 0 };
-	pid_t pid = 0;
-	unsigned prio;
+	const struct test_case *tc = &tcase[i];
+	unsigned int j;
+	unsigned int prio;
+	size_t len = MAX_MSGSIZE;
+	char rmsg[len];
+	pid_t pid = -1;
 
-	/*
-	 * When test ended with SIGTERM etc, mq descriptor is left remains.
-	 * So we delete it first.
-	 */
-	TEST(mq_unlink(QUEUE_NAME));
+	if (tc->signal)
+		pid = set_sig(tc->rq);
 
-	switch (tc->ttype) {
-	case FD_NOT_EXIST:
-		fd = INT_MAX - 1;
-		/* fallthrough */
-	case FD_NONE:
-		break;
-	case FD_FILE:
-		TEST(fd = open("/", O_RDONLY));
-		if (fd < 0) {
-			tst_resm(TFAIL, "can't open \"/\".- errno = %d : %s\n",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			result = 1;
-			goto EXIT;
+	if (tc->timeout)
+		set_timeout(tc->rq);
+
+	if (tc->send) {
+		for (j = 0; j < MSG_LENGTH; j++)
+			send_msg(*tc->fd, tc->len, tc->prio);
+	}
+
+	TEST(mq_timedsend(*tc->fd, smsg, tc->len, tc->prio, tc->rq));
+
+	if (pid > 0)
+		kill_pid(pid);
+
+	if (TEST_RETURN < 0) {
+		if (tc->err != TEST_ERRNO)
+			tst_res(TFAIL | TTERRNO,
+				"mq_timedsend failed unexpectedly, expected %s",
+				tst_strerrno(tc->err));
+		else
+			tst_res(TPASS | TTERRNO, "mq_timedreceive failed expectedly");
+
+		if (*tc->fd == fd)
+			cleanup_queue(fd);
+
+		return;
+	}
+
+	TEST(mq_timedreceive(*tc->fd, rmsg, len, &prio, tc->rq));
+
+	if (*tc->fd == fd)
+		cleanup_queue(fd);
+
+	if (TEST_RETURN < 0) {
+		if (tc->err != TEST_ERRNO) {
+			tst_res(TFAIL | TTERRNO,
+				"mq_timedreceive failed unexpectedly, expected %s",
+				tst_strerrno(tc->err));
+			return;
 		}
-		break;
-	default:
-		/*
-		 * Open message queue
-		 */
-		oflag = O_CREAT | O_EXCL | O_RDWR;
-		if (tc->non_block)
-			oflag |= O_NONBLOCK;
 
-		TEST(fd = mq_open(QUEUE_NAME, oflag, S_IRWXU, NULL));
-		if (TEST_RETURN < 0) {
-			tst_resm(TFAIL, "mq_open failed - errno = %d : %s\n",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			result = 1;
-			goto EXIT;
+		if (tc->ret >= 0) {
+			tst_res(TFAIL | TTERRNO, "mq_timedreceive returned %ld, expected %d",
+					TEST_RETURN, tc->ret);
+			return;
 		}
-		if (tc->ttype == FULL_QUEUE || tc->ttype == SEND_SIGINT) {
-			for (i = 0; i < MAX_MSG; i++) {
-				TEST(rc =
-				     mq_timedsend(fd, smsg, tc->len, 0, &ts));
-				if (rc < 0) {
-					tst_resm(TFAIL,
-						 "mq_timedsend failed - errno = %d : %s\n",
-						 TEST_ERRNO,
-						 strerror(TEST_ERRNO));
-					result = 1;
-					goto EXIT;
-				}
-			}
-			if (tc->ttype == SEND_SIGINT) {
-				pid = create_sig_proc(200000, SIGINT, UINT_MAX);
-				if (pid < 0) {
-					result = 1;
-					goto EXIT;
-				}
-			}
+	}
+
+	if (tc->len != TEST_RETURN) {
+		tst_res(TFAIL, "mq_timedreceive wrong length %ld, expected %d",
+			TEST_RETURN, tc->len);
+		return;
+	}
+
+	if (tc->prio != prio) {
+		tst_res(TFAIL, "mq_timedreceive wrong prio %d, expected %d",
+			prio, tc->prio);
+		return;
+	}
+
+	for (j = 0; j < tc->len; j++) {
+		if (rmsg[j] != smsg[j]) {
+			tst_res(TFAIL,
+				"mq_timedreceive wrong data %d in %u, expected %d",
+				rmsg[j], i, smsg[j]);
+			return;
 		}
-		break;
 	}
 
-	/*
-	 * Prepare send message
-	 */
-	for (i = 0; i < tc->len && i < sizeof(smsg); i++)
-		smsg[i] = i;
-
-	/*
-	 * Set the timeout value
-	 */
-	ts.tv_sec = tc->sec;
-	ts.tv_nsec = tc->nsec;
-	if (tc->sec >= 0 || tc->nsec != 0)
-		ts.tv_sec += time(NULL);
-
-	/*
-	 * Execut test system call
-	 */
-	errno = 0;
-	TEST(sys_ret = mq_timedsend(fd, smsg, tc->len, tc->prio, &ts));
-	sys_errno = errno;
-	if (sys_ret < 0)
-		goto TEST_END;
-
-	/*
-	 * Receive echoed message and compare
-	 */
-	ts.tv_sec = 0;
-	ts.tv_nsec = 0;
-	TEST(rc = mq_timedreceive(fd, rmsg, MAX_MSGSIZE, &prio, &ts));
-	if (rc < 0) {
-		tst_resm(TFAIL, "mq_timedreceive failed - errno = %d : %s\n",
-			 TEST_ERRNO, strerror(TEST_ERRNO));
-		result = 1;
-		goto EXIT;
-	}
-	if (rc != tc->len || tc->prio != prio)
-		cmp_ok = 0;
-	else {
-		for (i = 0; i < tc->len; i++)
-			if (rmsg[i] != smsg[i]) {
-				cmp_ok = 0;
-				break;
-			}
-	}
-TEST_END:
-	/*
-	 * Check results
-	 */
-	result |= (sys_errno != tc->err) || !cmp_ok;
-	PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
-			 cmp_ok);
-
-EXIT:
-	if (fd >= 0) {
-		TEST(close(fd));
-		TEST(mq_unlink(QUEUE_NAME));
-	}
-	if (pid > 0) {
-		int st;
-		kill(pid, SIGTERM);
-		wait(&st);
-	}
-	return result;
+	tst_res(TPASS, "mq_timedreceive returned %ld, priority %u, length: %zu",
+			TEST_RETURN, prio, len);
 }
 
-/*
- * main()
- */
-
-int main(int ac, char **av)
-{
-	int result = RESULT_OK;
-	int i;
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		tst_count = 0;
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-
-			/*
-			 * Execute test
-			 */
-			for (i = 0; i < (int)ARRAY_SIZE(tcase); i++) {
-				int ret;
-				tst_resm(TINFO, "(case%02d) START", i);
-				ret = do_test(&tcase[i]);
-				tst_resm(TINFO, "(case%02d) END => %s", i,
-					 (ret == 0) ? "OK" : "NG");
-				result |= ret;
-			}
-			/*
-			 * Check results
-			 */
-			switch (result) {
-			case RESULT_OK:
-				tst_resm(TPASS, "mq_timedsend call succeeded");
-				break;
-
-			default:
-				tst_brkm(TFAIL | TTERRNO, cleanup,
-					 "mq_timedsend failed");
-			}
-
-		}
-	}
-	cleanup();
-	tst_exit();
-}
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcase),
+	.test = do_test,
+	.setup = setup_common,
+	.cleanup = cleanup_common,
+	.forks_child = 1,
+};
diff --git a/testcases/kernel/syscalls/mq_unlink/Makefile b/testcases/kernel/syscalls/mq_unlink/Makefile
index 2e1628e..71ebae9 100644
--- a/testcases/kernel/syscalls/mq_unlink/Makefile
+++ b/testcases/kernel/syscalls/mq_unlink/Makefile
@@ -20,7 +20,6 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-CPPFLAGS		?= -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
 LDLIBS			+= -lpthread -lrt
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c b/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c
index 40f6db2..6e271c5 100644
--- a/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c
+++ b/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c
@@ -124,7 +124,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "mq_unlink01",
 	.tcnt = ARRAY_SIZE(tcase),
 	.test = do_test,
 	.needs_root = 1,
diff --git a/testcases/kernel/syscalls/msync/msync04.c b/testcases/kernel/syscalls/msync/msync04.c
new file mode 100644
index 0000000..4f70ca1
--- /dev/null
+++ b/testcases/kernel/syscalls/msync/msync04.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Test description: Verify msync() after writing into mmap()-ed file works.
+ *
+ * Write to mapped region and sync the memory back with file. Check the page
+ * is no longer dirty after msync() call.
+ */
+
+#include <errno.h>
+#include "tst_test.h"
+
+static int test_fd;
+static char *mmaped_area;
+static long pagesize;
+
+#define STRING_TO_WRITE	"AAAAAAAAAA"
+
+uint64_t get_dirty_bit(void *data)
+{
+	int pagemap_fd, pageflags_fd;
+	unsigned long addr;
+	uint64_t pagemap_entry, pageflag_entry, pfn, index;
+
+	addr = (unsigned long)data;
+	index = (addr / pagesize) * sizeof(uint64_t);
+	pagemap_fd = SAFE_OPEN("/proc/self/pagemap", O_RDONLY);
+	SAFE_LSEEK(pagemap_fd, index, SEEK_SET);
+	SAFE_READ(1, pagemap_fd, &pagemap_entry, sizeof(pagemap_entry));
+	SAFE_CLOSE(pagemap_fd);
+	pfn = pagemap_entry & ((1ULL << 55) - 1);
+	if (!pfn)
+		return 0;
+	pageflags_fd = SAFE_OPEN("/proc/kpageflags", O_RDONLY);
+	index = pfn * sizeof(uint64_t);
+	SAFE_LSEEK(pageflags_fd, index, SEEK_SET);
+	SAFE_READ(1, pageflags_fd, &pageflag_entry, sizeof(pageflag_entry));
+	SAFE_CLOSE(pageflags_fd);
+	return pageflag_entry & (1ULL << 4);
+}
+
+static void test_msync(void)
+{
+	uint64_t dirty;
+
+	test_fd = SAFE_OPEN("msync04/testfile", O_CREAT | O_TRUNC | O_RDWR);
+	SAFE_WRITE(0, test_fd, STRING_TO_WRITE, sizeof(STRING_TO_WRITE) - 1);
+	mmaped_area = SAFE_MMAP(NULL, pagesize, PROT_READ | PROT_WRITE,
+			MAP_SHARED, test_fd, 0);
+	SAFE_CLOSE(test_fd);
+	mmaped_area[8] = 'B';
+	dirty = get_dirty_bit(mmaped_area);
+	if (!dirty) {
+		tst_res(TFAIL, "Expected dirty bit to be set after writing to"
+				" mmap()-ed area");
+		goto clean;
+	}
+	if (msync(mmaped_area, pagesize, MS_SYNC) < 0) {
+		tst_res(TFAIL | TERRNO, "msync() failed");
+		goto clean;
+	}
+	dirty = get_dirty_bit(mmaped_area);
+	if (dirty)
+		tst_res(TFAIL, "msync() failed to write dirty page despite"
+				" succeeding");
+	else
+		tst_res(TPASS, "msync() working correctly");
+
+clean:
+	SAFE_MUNMAP(mmaped_area, pagesize);
+	mmaped_area = NULL;
+}
+
+static void setup(void)
+{
+	pagesize = (off_t)SAFE_SYSCONF(_SC_PAGESIZE);
+}
+
+static void cleanup(void)
+{
+	if (mmaped_area)
+		SAFE_MUNMAP(mmaped_area, pagesize);
+
+	if (test_fd > 0)
+		SAFE_CLOSE(test_fd);
+}
+
+static struct tst_test test = {
+	.test_all = test_msync,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.mntpoint = "msync04",
+	.mount_device = 1,
+	.min_kver = "2.6.25",
+};
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep01.c b/testcases/kernel/syscalls/nanosleep/nanosleep01.c
index 4d9d083..6d90a60 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep01.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep01.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *  07/2001 Ported by Wayne Boyer
- * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz>
  *
  * 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
@@ -19,56 +19,34 @@
  */
 
 /*
- * Test Name: nanosleep01
- *
  * Test Description:
  *  nanosleep() should return with value 0 and the process should be
  *  suspended for time specified by timespec structure.
  */
 
 #include <errno.h>
-#include "test.h"
 
-char *TCID = "nanosleep01";
-int TST_TOTAL = 1;
+#include "tst_timer_test.h"
 
-static void setup(void);
-
-int main(int ac, char **av)
+int sample_fn(int clk_id, long long usec)
 {
-	int lc;
-	struct timespec timereq = {.tv_sec = 2, .tv_nsec = 9999};
+	struct timespec t = tst_us_to_timespec(usec);
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	tst_timer_start(clk_id);
+	TEST(nanosleep(&t, NULL));
+	tst_timer_stop();
+	tst_timer_sample();
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_timer_start(CLOCK_MONOTONIC);
-		TEST(nanosleep(&timereq, NULL));
-		tst_timer_stop();
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL | TERRNO, "nanosleep() failed");
-			continue;
-		}
-
-		if (tst_timespec_lt(tst_timer_elapsed(), timereq)) {
-			tst_resm(TFAIL,
-			         "nanosleep() suspended for %lli us, expected %lli",
-				 tst_timer_elapsed_us(), tst_timespec_to_us(timereq));
-		} else {
-			tst_resm(TPASS, "nanosleep() suspended for %lli us",
-			         tst_timer_elapsed_us());
-		}
+	if (TEST_RETURN != 0) {
+		tst_res(TFAIL | TERRNO,
+			"nanosleep() returned %li", TEST_RETURN);
+		return 1;
 	}
 
-	tst_exit();
+	return 0;
 }
 
-static void setup(void)
-{
-	tst_sig(FORK, DEF_HANDLER, NULL);
-	tst_timer_check(CLOCK_MONOTONIC);
-	TEST_PAUSE;
-}
+static struct tst_test test = {
+	.tid = "nanosleep()",
+	.sample = sample_fn,
+};
diff --git a/testcases/kernel/syscalls/newuname/newuname01.c b/testcases/kernel/syscalls/newuname/newuname01.c
index 1c5cb48..ebf2fcc 100644
--- a/testcases/kernel/syscalls/newuname/newuname01.c
+++ b/testcases/kernel/syscalls/newuname/newuname01.c
@@ -45,7 +45,7 @@
 #include <stdlib.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "newuname01";
 int testno;
diff --git a/testcases/kernel/syscalls/nice/nice01.c b/testcases/kernel/syscalls/nice/nice01.c
index 26aaa99..fede2c7 100644
--- a/testcases/kernel/syscalls/nice/nice01.c
+++ b/testcases/kernel/syscalls/nice/nice01.c
@@ -66,7 +66,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "nice01",
 	.test_all = verify_nice,
 	.needs_root = 1,
 };
diff --git a/testcases/kernel/syscalls/nice/nice02.c b/testcases/kernel/syscalls/nice/nice02.c
index 4c9ccae..6ae70f8 100644
--- a/testcases/kernel/syscalls/nice/nice02.c
+++ b/testcases/kernel/syscalls/nice/nice02.c
@@ -64,6 +64,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "nice02",
 	.test_all = verify_nice,
 };
diff --git a/testcases/kernel/syscalls/nice/nice03.c b/testcases/kernel/syscalls/nice/nice03.c
index 6b90c2d..7c41e28 100644
--- a/testcases/kernel/syscalls/nice/nice03.c
+++ b/testcases/kernel/syscalls/nice/nice03.c
@@ -71,7 +71,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "nice03",
 	.forks_child = 1,
 	.test_all = verify_nice,
 };
diff --git a/testcases/kernel/syscalls/nice/nice04.c b/testcases/kernel/syscalls/nice/nice04.c
index 3d63f31..07ad21e 100644
--- a/testcases/kernel/syscalls/nice/nice04.c
+++ b/testcases/kernel/syscalls/nice/nice04.c
@@ -56,7 +56,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "nice04",
 	.setup = setup,
 	.test_all = verify_nice,
 	.needs_root = 1,
diff --git a/testcases/kernel/syscalls/open/open01.c b/testcases/kernel/syscalls/open/open01.c
index adb59d4..43305b2 100644
--- a/testcases/kernel/syscalls/open/open01.c
+++ b/testcases/kernel/syscalls/open/open01.c
@@ -1,6 +1,7 @@
 /*
- *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *    07/2001 Ported by Wayne Boyer
+ *    06/2017 Modified by Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  *
  *   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
@@ -18,139 +19,78 @@
  */
 
 /*
- * NAME
- *	open01.c
- *
  * DESCRIPTION
  *	Open a file with oflag = O_CREAT set, does it set the sticky bit off?
- *
- *	Open "/tmp" with O_DIRECTORY, does it set the S_IFDIR bit on?
+ *	Open a dir with O_DIRECTORY, does it set the S_IFDIR bit on?
  *
  * ALGORITHM
  *	1. open a new file with O_CREAT, fstat.st_mode should not have the
  *	   01000 bit on. In Linux, the save text bit is *NOT* cleared.
- *
- *	2. open "/tmp" with O_DIRECTORY.  fstat.st_mode should have the
+ *	2. open a new dir with O_DIRECTORY, fstat.st_mode should have the
  *	   040000 bit on.
- *
- * USAGE:  <for command-line>
- *  open01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS
- *	None
  */
+
 #define _GNU_SOURCE		/* for O_DIRECTORY */
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
-#include "test.h"
+#include "tst_test.h"
 
-char *TCID = "open01";
-int TST_TOTAL = 1;
+#define TEST_FILE	"testfile"
+#define TEST_DIR	"testdir"
 
-static char pfilname[40] = "";
+static int fd;
 
-static void cleanup(void);
-static void setup(void);
+static struct tcase {
+	char *filename;
+	int flag;
+	mode_t mode;
+	unsigned short tst_bit;
+	char *desc;
+} tcases[] = {
+	{TEST_FILE, O_RDWR | O_CREAT, 01444, S_ISVTX, "Sticky bit"},
+	{TEST_DIR, O_DIRECTORY, 0, S_IFDIR, "Directory bit"}
+};
 
-int main(int ac, char **av)
+static void verify_open(unsigned int n)
 {
-	int lc;
+	struct tcase *tc = &tcases[n];
+	struct stat buf;
 
-	struct stat statbuf;
-	int fildes;
-	unsigned short filmode;
-
-	/*
-	 * parse standard command line options
-	 */
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	/*
-	 * check looping state if -i option given on the command line
-	 */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;	/* reset tst_count while looping. */
-
-		/* test #1 */
-		TEST(open(pfilname, O_RDWR | O_CREAT, 01444));
-
-		fildes = TEST_RETURN;
-		if (fildes == -1) {
-			tst_resm(TFAIL, "Cannot open %s", pfilname);
-			continue;
-		}
-
-		fstat(fildes, &statbuf);
-		filmode = statbuf.st_mode;
-		if (!(filmode & S_ISVTX)) {
-			tst_resm(TFAIL, "Save test bit cleared, but "
-				 "should not have been");
-		} else {
-			tst_resm(TPASS, "Save text bit not cleared "
-				 "as expected");
-		}
-
-		/* test #2 */
-		TEST(open("/tmp", O_DIRECTORY));
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "open of /tmp failed, errno: %d",
-				 TEST_ERRNO);
-			continue;
-		}
-
-		fstat(TEST_RETURN, &statbuf);
-		filmode = statbuf.st_mode;
-		if (!(filmode & S_IFDIR)) {
-			tst_resm(TFAIL, "directory bit cleared, but "
-				 "should not have been");
-		} else {
-			tst_resm(TPASS, "directory bit is set "
-				 "as expected");
-		}
-
-		/* clean up things is case we are looping */
-		if (close(fildes) == -1)
-			tst_brkm(TBROK, cleanup, "close #1 failed");
-
-		if (unlink(pfilname) == -1)
-			tst_brkm(TBROK, cleanup, "can't remove file");
-
-		if (close(TEST_RETURN) == -1)
-			tst_brkm(TBROK, cleanup, "close #2 failed");
+	TEST(open(tc->filename, tc->flag, tc->mode));
+	fd = TEST_RETURN;
+	if (fd == -1) {
+		tst_res(TFAIL, "Cannot open a file");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	SAFE_FSTAT(fd, &buf);
+	if (!(buf.st_mode & tc->tst_bit))
+		tst_res(TFAIL, "%s is cleared unexpectedly", tc->desc);
+	else
+		tst_res(TPASS, "%s is set as expected", tc->desc);
+
+	SAFE_CLOSE(fd);
+	if (S_ISREG(buf.st_mode))
+		SAFE_UNLINK(tc->filename);
 }
 
 static void setup(void)
 {
-	umask(0);
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	sprintf(pfilname, "open3.%d", getpid());
+	SAFE_MKDIR(TEST_DIR, 0755);
 }
 
 static void cleanup(void)
 {
-	tst_rmdir();
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_open,
+};
diff --git a/testcases/kernel/syscalls/open/open02.c b/testcases/kernel/syscalls/open/open02.c
index 30f8472..f09bfe0 100644
--- a/testcases/kernel/syscalls/open/open02.c
+++ b/testcases/kernel/syscalls/open/open02.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *	07/2001 Ported by Wayne Boyer
+ *	06/2017 Modified by Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  *
  * 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
@@ -31,91 +32,63 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <pwd.h>
-#include "test.h"
-#include "safe_macros.h"
-#include "lapi/fcntl.h"
+#include "tst_test.h"
 
 #define TEST_FILE	"test_file"
 #define TEST_FILE2	"test_file2"
 
-char *TCID = "open02";
-
-static void cleanup(void);
-static void setup(void);
-
-static struct test_case_t {
+static struct tcase {
 	char *filename;
 	int flag;
 	int exp_errno;
-} test_cases[] = {
+} tcases[] = {
 	{TEST_FILE, O_RDWR, ENOENT},
 	{TEST_FILE2, O_RDONLY | O_NOATIME, EPERM},
 };
 
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-static void open_verify(const struct test_case_t *);
-
-int main(int ac, char **av)
-{
-	int lc;
-	int i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		for (i = 0; i < TST_TOTAL; i++)
-			open_verify(&test_cases[i]);
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
+void setup(void)
 {
 	struct passwd *ltpuser;
 
-	tst_require_root();
+	SAFE_TOUCH(TEST_FILE2, 0644, NULL);
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	ltpuser = SAFE_GETPWNAM("nobody");
 
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	SAFE_TOUCH(cleanup, TEST_FILE2, 0644, NULL);
-
-	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
-
-	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
+	SAFE_SETEUID(ltpuser->pw_uid);
 }
 
-static void open_verify(const struct test_case_t *test)
+static void verify_open(unsigned int n)
 {
-	TEST(open(test->filename, test->flag, 0444));
+	struct tcase *tc = &tcases[n];
+
+	TEST(open(tc->filename, tc->flag, 0444));
 
 	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "open(%s) succeeded unexpectedly",
-			 test->filename);
+		tst_res(TFAIL, "open(%s) succeeded unexpectedly",
+			tc->filename);
 		return;
 	}
 
-	if (TEST_ERRNO != test->exp_errno) {
-		tst_resm(TFAIL | TTERRNO,
-			 "open() failed unexpectedly; expected: %d - %s",
-			 test->exp_errno, strerror(test->exp_errno));
-	} else {
-		tst_resm(TPASS | TTERRNO, "open() failed as expected");
+	if (tc->exp_errno != TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO,
+			"open() should fail with %s",
+			tst_strerrno(tc->exp_errno));
+		return;
 	}
+
+	tst_res(TPASS | TTERRNO, "open() failed as expected");
 }
 
-static void cleanup(void)
+void cleanup(void)
 {
-	if (seteuid(0))
-		tst_resm(TWARN | TERRNO, "seteuid(0) failed");
-
-	tst_rmdir();
+	SAFE_SETEUID(0);
 }
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_open,
+};
diff --git a/testcases/kernel/syscalls/open/open11.c b/testcases/kernel/syscalls/open/open11.c
index 9ae680f..6a3b0b8 100644
--- a/testcases/kernel/syscalls/open/open11.c
+++ b/testcases/kernel/syscalls/open/open11.c
@@ -63,6 +63,7 @@
 #include "config.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/testcases/kernel/syscalls/open/open14.c b/testcases/kernel/syscalls/open/open14.c
index d56792b..0d832cb 100644
--- a/testcases/kernel/syscalls/open/open14.c
+++ b/testcases/kernel/syscalls/open/open14.c
@@ -81,11 +81,11 @@
 	write_file(fd);
 
 	SAFE_FSTAT(cleanup, fd, &st);
-	tst_resm(TINFO, "file size is '%zu'", st.st_size);
+	tst_resm(TINFO, "file size is '%li'", (long)st.st_size);
 
 	if (st.st_size != blocks_num * size) {
-		tst_resm(TFAIL, "not expected size: '%zu' != '%zu'",
-			 st.st_size, blocks_num * size);
+		tst_resm(TFAIL, "not expected size: '%li' != '%zu'",
+			 (long)st.st_size, blocks_num * size);
 		SAFE_CLOSE(cleanup, fd);
 		return;
 	}
diff --git a/testcases/kernel/syscalls/openat/openat.h b/testcases/kernel/syscalls/openat/openat.h
index fce4e3f..9b5568b 100644
--- a/testcases/kernel/syscalls/openat/openat.h
+++ b/testcases/kernel/syscalls/openat/openat.h
@@ -23,7 +23,7 @@
 
 #include <sys/types.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_OPENAT)
 int openat(int dirfd, const char *pathname, int flags, mode_t mode)
diff --git a/testcases/kernel/syscalls/openat/openat03.c b/testcases/kernel/syscalls/openat/openat03.c
index 7857a2e..7e816f2 100644
--- a/testcases/kernel/syscalls/openat/openat03.c
+++ b/testcases/kernel/syscalls/openat/openat03.c
@@ -92,11 +92,11 @@
 	write_file(fd);
 
 	SAFE_FSTAT(cleanup, fd, &st);
-	tst_resm(TINFO, "file size is '%zu'", st.st_size);
+	tst_resm(TINFO, "file size is '%li'", (long)st.st_size);
 
 	if (st.st_size != blocks_num * size) {
-		tst_resm(TFAIL, "not expected size: '%zu' != '%zu'",
-			 st.st_size, blocks_num * size);
+		tst_resm(TFAIL, "not expected size: '%li' != '%zu'",
+			 (long)st.st_size, blocks_num * size);
 		SAFE_CLOSE(cleanup, fd);
 		return;
 	}
diff --git a/testcases/kernel/syscalls/pause/pause01.c b/testcases/kernel/syscalls/pause/pause01.c
index 433161c..1c55855 100644
--- a/testcases/kernel/syscalls/pause/pause01.c
+++ b/testcases/kernel/syscalls/pause/pause01.c
@@ -61,7 +61,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "pause01",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.test_all = do_test,
diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
index 926f84b..5c814b6 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
@@ -43,7 +43,7 @@
 #endif
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 
 char *TCID = "perf_event_open01";
diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
index 6bb6cd0..7d54cbd 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -71,7 +71,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "perf_event_open02";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/syscalls/pipe/pipe01.c b/testcases/kernel/syscalls/pipe/pipe01.c
index f0db2fa..8f71460 100644
--- a/testcases/kernel/syscalls/pipe/pipe01.c
+++ b/testcases/kernel/syscalls/pipe/pipe01.c
@@ -61,6 +61,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "pipe01",
 	.test_all = verify_pipe,
 };
diff --git a/testcases/kernel/syscalls/pipe/pipe02.c b/testcases/kernel/syscalls/pipe/pipe02.c
index 9d7932c..8defa5e 100644
--- a/testcases/kernel/syscalls/pipe/pipe02.c
+++ b/testcases/kernel/syscalls/pipe/pipe02.c
@@ -101,7 +101,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "pipe02",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.test_all = verify_pipe,
diff --git a/testcases/kernel/syscalls/pipe/pipe03.c b/testcases/kernel/syscalls/pipe/pipe03.c
index 2062d19..267cf88 100644
--- a/testcases/kernel/syscalls/pipe/pipe03.c
+++ b/testcases/kernel/syscalls/pipe/pipe03.c
@@ -59,6 +59,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "pipe03",
 	.test_all = verify_pipe,
 };
diff --git a/testcases/kernel/syscalls/pipe2/pipe2_01.c b/testcases/kernel/syscalls/pipe2/pipe2_01.c
index 38d257f..5f3ad8f 100644
--- a/testcases/kernel/syscalls/pipe2/pipe2_01.c
+++ b/testcases/kernel/syscalls/pipe2/pipe2_01.c
@@ -69,7 +69,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "pipe2_01";
 int testno;
diff --git a/testcases/kernel/syscalls/pipe2/pipe2_02.c b/testcases/kernel/syscalls/pipe2/pipe2_02.c
index e130f40..39f02ff 100644
--- a/testcases/kernel/syscalls/pipe2/pipe2_02.c
+++ b/testcases/kernel/syscalls/pipe2/pipe2_02.c
@@ -60,7 +60,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "pipe2_02";
 int testno;
diff --git a/testcases/kernel/syscalls/poll/poll02.c b/testcases/kernel/syscalls/poll/poll02.c
index 66affed..0aa228c 100644
--- a/testcases/kernel/syscalls/poll/poll02.c
+++ b/testcases/kernel/syscalls/poll/poll02.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz>
  *
  * 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
@@ -19,105 +19,53 @@
 /*
  * Check that poll() timeouts correctly.
  */
-#include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/wait.h>
 #include <sys/poll.h>
 
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "poll02";
-int TST_TOTAL = 1;
-
-static char *opt_sleep_ms;
-
-static option_t opts[] = {
-	{"s:", NULL, &opt_sleep_ms},
-	{NULL, NULL, NULL},
-};
-
-static void help(void);
-static void setup(void);
-static void cleanup(void);
+#include "tst_timer_test.h"
 
 static int fds[2];
 
-int main(int ac, char **av)
+int sample_fn(int clk_id, long long usec)
 {
-	int lc, treshold;
-	long long elapsed_ms, sleep_ms = 100;
+	unsigned int sleep_ms = usec / 1000;
 
-	tst_parse_opts(ac, av, opts, help);
+	struct pollfd pfds[] = {
+		{.fd = fds[0], .events = POLLIN}
+	};
 
-	if (opt_sleep_ms) {
-		sleep_ms = atoll(opt_sleep_ms);
+	tst_timer_start(clk_id);
+	TEST(poll(pfds, 1, sleep_ms));
+	tst_timer_stop();
+	tst_timer_sample();
 
-		if (sleep_ms == 0)
-			tst_brkm(TBROK, NULL, "Invalid timeout '%s'", opt_sleep_ms);
+	if (TEST_RETURN != 0) {
+		tst_res(TFAIL | TTERRNO, "poll() returned %li", TEST_RETURN);
+		return 1;
 	}
 
-	treshold = sleep_ms / 100 + 10;
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		struct pollfd pfds[] = {
-			{.fd = fds[0], .events = POLLIN}
-		};
-
-		tst_timer_start(CLOCK_MONOTONIC);
-		TEST(poll(pfds, 1, sleep_ms));
-		tst_timer_stop();
-
-		if (TEST_RETURN != 0) {
-			tst_resm(TFAIL, "poll() haven't timeouted ret=%li",
-				 TEST_RETURN);
-			continue;
-		}
-
-		elapsed_ms = tst_timer_elapsed_ms();
-
-		if (elapsed_ms < sleep_ms) {
-			tst_resm(TFAIL,
-			         "poll() woken up too early %llims, expected %llims",
-				 elapsed_ms, sleep_ms);
-			continue;
-		}
-
-		if (elapsed_ms - sleep_ms > treshold) {
-			tst_resm(TFAIL,
-			         "poll() slept too long %llims, expected %llims, threshold %i",
-				 elapsed_ms, sleep_ms, treshold);
-			continue;
-		}
-
-		tst_resm(TPASS, "poll() slept %llims, expected %llims, treshold %i",
-		         elapsed_ms, sleep_ms, treshold);
-	}
-
-	cleanup();
-	tst_exit();
+	return 0;
 }
 
 static void setup(void)
 {
-	tst_timer_check(CLOCK_MONOTONIC);
-
-	SAFE_PIPE(NULL, fds);
+	SAFE_PIPE(fds);
 }
 
 static void cleanup(void)
 {
-	if (close(fds[0]))
-		tst_resm(TWARN | TERRNO, "close(fds[0]) failed");
+	if (fds[0] > 0)
+		SAFE_CLOSE(fds[0]);
 
-	if (close(fds[1]))
-		tst_resm(TWARN | TERRNO, "close(fds[1]) failed");
+	if (fds[1] > 0)
+		SAFE_CLOSE(fds[1]);
 }
 
-static void help(void)
-{
-	printf("  -s      poll() timeout lenght in ms\n");
-}
+static struct tst_test test = {
+	.tid = "poll()",
+	.sample = sample_fn,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/syscalls/ppoll/ppoll01.c b/testcases/kernel/syscalls/ppoll/ppoll01.c
index 2cb336b..5bfab25 100644
--- a/testcases/kernel/syscalls/ppoll/ppoll01.c
+++ b/testcases/kernel/syscalls/ppoll/ppoll01.c
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "ltp_signal.h"
 #include "tst_sig_proc.h"
 #include "tst_test.h"
@@ -268,7 +268,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "ppoll01",
 	.tcnt = ARRAY_SIZE(tcase),
 	.test = do_test,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/preadv/preadv.h b/testcases/kernel/syscalls/preadv/preadv.h
index f3ac30d..73466a9 100644
--- a/testcases/kernel/syscalls/preadv/preadv.h
+++ b/testcases/kernel/syscalls/preadv/preadv.h
@@ -19,7 +19,7 @@
 
 #include <sys/types.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_PREADV)
 int preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
diff --git a/testcases/kernel/syscalls/preadv/preadv01.c b/testcases/kernel/syscalls/preadv/preadv01.c
index c2ba09e..5ee27fb 100644
--- a/testcases/kernel/syscalls/preadv/preadv01.c
+++ b/testcases/kernel/syscalls/preadv/preadv01.c
@@ -68,7 +68,7 @@
 	}
 
 	if (TEST_RETURN != tc->size) {
-		tst_res(TFAIL, "Preadv(2) read %li bytes, expected %li",
+		tst_res(TFAIL, "Preadv(2) read %li bytes, expected %zi",
 			 TEST_RETURN, tc->size);
 		return;
 	}
@@ -89,7 +89,7 @@
 		return;
 	}
 
-	tst_res(TPASS, "Preadv(2) read %li bytes successfully "
+	tst_res(TPASS, "Preadv(2) read %zi bytes successfully "
 		 "with content '%c' expectedly", tc->size, tc->content);
 }
 
@@ -113,7 +113,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "preadv01",
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/preadv/preadv02.c b/testcases/kernel/syscalls/preadv/preadv02.c
index 26ebfa3..c171d83 100644
--- a/testcases/kernel/syscalls/preadv/preadv02.c
+++ b/testcases/kernel/syscalls/preadv/preadv02.c
@@ -130,7 +130,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "preadv02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/pselect/pselect01.c b/testcases/kernel/syscalls/pselect/pselect01.c
index 4bb1261..a2b5339 100644
--- a/testcases/kernel/syscalls/pselect/pselect01.c
+++ b/testcases/kernel/syscalls/pselect/pselect01.c
@@ -1,155 +1,49 @@
 /*
- * Copyright (c) International Business Machines  Corp., 2005
- * Copyright (c) Wipro Technologies Ltd, 2005.  All Rights Reserved.
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 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 the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * AUTHORS:
- *    Prashant P Yendigeri <prashant.yendigeri@wipro.com>
- *    Robbie Williamson <robbiew@us.ibm.com>
- *
- * DESCRIPTION
- *      This is a Phase I test for the pselect01(2) system call.
- *      It is intended to provide a limited exposure of the system call.
- *
- **********************************************************/
-
-#include <stdio.h>
-#include <fcntl.h>
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
 #include <sys/select.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
 #include <errno.h>
 
-#include "tst_test.h"
-#include "tst_timer.h"
+#include "tst_timer_test.h"
 
-struct tcase {
-	struct timespec tv;
-	unsigned int iterations;
-};
-
-static unsigned int monotonic_resolution;
-
-static struct tcase tcases[] = {
-	{{0, 1000000},  500},
-	{{0, 2000000},  500},
-	{{0, 10000000}, 300},
-	{{0, 100000000},  1},
-	{{1, 0},          1},
-};
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-/*
- * The threshold per one syscall is computed as a sum of:
- *
- *  250 us                 - accomodates for context switches, etc.
- *  2*monotonic_resolution - accomodates for granurality of the CLOCK_MONOTONIC
- *  slack_per_scall        - 0.1% of the sleep capped on 100ms
- *                           which is slack allowed in kernel
- *
- * We also allow for outliners, i.e. add some number to the threshold in case
- * that the number of iteration is small. For large enoung number of iterations
- * outliners are averaged out.
- */
-static int compute_threshold(long long requested_us, unsigned int iterations)
-{
-	unsigned int slack_per_scall = MIN(100000, requested_us / 1000);
-
-	return (250 + 2 * monotonic_resolution + slack_per_scall) * iterations
-		+ (iterations > 1 ? 0 : 1500);
-}
-
-static void verify_pselect(unsigned int n)
+int sample_fn(int clk_id, long long usec)
 {
 	fd_set readfds;
-	struct timespec tv;
-	long long requested_us, slept_us = 0;
-	unsigned int i;
-	int threshold;
-	struct tcase *t = &tcases[n];
+	struct timespec tv = tst_us_to_timespec(usec);
 
-	tst_res(TINFO, "pselect() sleeping for %li secs %li nsec %i iterations",
-			t->tv.tv_sec, t->tv.tv_nsec, t->iterations);
+	FD_ZERO(&readfds);
+	FD_SET(0, &readfds);
 
-	for (i = 0; i < t->iterations; i++) {
-		long long elapsed_us;
+	tst_timer_start(clk_id);
+	TEST(pselect(0, &readfds, NULL, NULL, &tv, NULL));
+	tst_timer_stop();
+	tst_timer_sample();
 
-		FD_ZERO(&readfds);
-		FD_SET(0, &readfds);
-
-		tv = t->tv;
-
-		tst_timer_start(CLOCK_MONOTONIC);
-		pselect(0, &readfds, NULL, NULL, &tv, NULL);
-		tst_timer_stop();
-
-		elapsed_us = tst_timer_elapsed_us();
-
-		if (elapsed_us >= 10 * tst_timespec_to_us(t->tv)
-		    && elapsed_us > 3 * monotonic_resolution) {
-			tst_res(TINFO,
-				"Found outliner took %lli us, expected %lli us",
-				elapsed_us, tst_timespec_to_us(t->tv));
-		}
-
-		slept_us += elapsed_us;
+	if (TEST_RETURN != 0) {
+		tst_res(TFAIL | TTERRNO,
+			"pselect() returned %li on timeout", TEST_RETURN);
+		return 1;
 	}
 
-	requested_us = tst_timespec_to_us(t->tv) * t->iterations;
-	threshold = compute_threshold(tst_timespec_to_us(t->tv), t->iterations);
-
-	if (t->iterations > 1) {
-		tst_res(TINFO, "Mean sleep time %.2f us, expected %lli us, threshold %.2f",
-			1.00 * slept_us / t->iterations,
-			tst_timespec_to_us(t->tv), 1.00 * threshold / t->iterations);
-	}
-
-	if (slept_us < requested_us) {
-		tst_res(TFAIL,
-			"pselect() woken up too early %llius, expected %llius",
-			slept_us, requested_us);
-		return;
-	}
-
-	if (slept_us - requested_us > threshold) {
-		tst_res(TFAIL,
-			"pselect() slept for too long %llius, expected %llius, threshold %i",
-			slept_us, requested_us, threshold);
-		return;
-	}
-
-	tst_res(TPASS, "pselect() slept for %llius, requested %llius, treshold %i",
-		slept_us, requested_us, threshold);
-}
-
-static void setup(void)
-{
-	struct timespec t;
-
-	clock_getres(CLOCK_MONOTONIC, &t);
-
-	tst_res(TINFO, "CLOCK_MONOTONIC resolution %li ns", (long)t.tv_nsec);
-
-	monotonic_resolution = t.tv_nsec / 1000;
+	return 0;
 }
 
 static struct tst_test test = {
-	.tid = "pselect01",
-	.test = verify_pselect,
-	.setup = setup,
-	.tcnt = ARRAY_SIZE(tcases),
+	.tid = "pselect()",
+	.sample = sample_fn,
 };
diff --git a/testcases/kernel/syscalls/pselect/pselect03.c b/testcases/kernel/syscalls/pselect/pselect03.c
index a92531e..4a2b849 100644
--- a/testcases/kernel/syscalls/pselect/pselect03.c
+++ b/testcases/kernel/syscalls/pselect/pselect03.c
@@ -57,7 +57,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "pselect03",
 	.needs_tmpdir = 1,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/pwritev/pwritev.h b/testcases/kernel/syscalls/pwritev/pwritev.h
index 4970036..833160d 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev.h
+++ b/testcases/kernel/syscalls/pwritev/pwritev.h
@@ -19,7 +19,7 @@
 
 #include <sys/types.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_PWRITEV)
 int pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
diff --git a/testcases/kernel/syscalls/pwritev/pwritev01.c b/testcases/kernel/syscalls/pwritev/pwritev01.c
index 88a1756..7c97f72 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev01.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev01.c
@@ -68,7 +68,7 @@
 	}
 
 	if (TEST_RETURN != tc->size) {
-		tst_res(TFAIL, "pwritev() wrote %li bytes, expected %li",
+		tst_res(TFAIL, "pwritev() wrote %li bytes, expected %zi",
 			 TEST_RETURN, tc->size);
 		return;
 	}
@@ -91,7 +91,7 @@
 		return;
 	}
 
-	tst_res(TPASS, "writev() wrote %li bytes successfully "
+	tst_res(TPASS, "writev() wrote %zi bytes successfully "
 		 "with content 'a' expectedly ", tc->size);
 }
 
@@ -109,7 +109,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "pwritev01",
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/pwritev/pwritev02.c b/testcases/kernel/syscalls/pwritev/pwritev02.c
index ec9de20..76b722b 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev02.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev02.c
@@ -121,7 +121,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "pwritev02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index a994e95..0173ed4 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -207,7 +207,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "quotactl01",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_quota,
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index ec5c7a0..9e6408a 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -172,7 +172,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "quotactl02",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_quota,
diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c
index 8c2cde5..64caac3 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl03.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl03.c
@@ -86,7 +86,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "quotactl03",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test_all = verify_quota,
diff --git a/testcases/kernel/syscalls/read/read01.c b/testcases/kernel/syscalls/read/read01.c
index d2ccd0a..855a3a1 100644
--- a/testcases/kernel/syscalls/read/read01.c
+++ b/testcases/kernel/syscalls/read/read01.c
@@ -65,7 +65,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "read01",
 	.test_all = verify_read,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/read/read02.c b/testcases/kernel/syscalls/read/read02.c
index 587b2ae..dae2385 100644
--- a/testcases/kernel/syscalls/read/read02.c
+++ b/testcases/kernel/syscalls/read/read02.c
@@ -1,6 +1,8 @@
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *	07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2017 Fujitsu Ltd.
+ *	04/2017 Modified by Jinhui Huang
  *
  * 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
@@ -42,14 +44,9 @@
 #define _GNU_SOURCE
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "read02";
+#include "tst_test.h"
 
 static int badfd = -1;
 static int fd2, fd3, fd4 = -1;
@@ -58,15 +55,14 @@
 static void *outside_buf = (void *)-1;
 static void *addr4;
 static void *addr5;
-
 static long fs_type;
 
-static struct test_case_t {
+static struct tcase {
 	int *fd;
 	void **buf;
 	size_t count;
 	int exp_error;
-} TC[] = {
+} tcases[] = {
 	{&badfd, &bufaddr, 1, EBADF},
 	{&fd2, &bufaddr, 1, EISDIR},
 #ifndef UCLINUX
@@ -76,97 +72,76 @@
 	{&fd4, &addr5, 4096, EINVAL},
 };
 
-int TST_TOTAL = ARRAY_SIZE(TC);
-static void setup(void);
-static void cleanup(void);
-static void read_verify(const struct test_case_t *);
-
-int main(int ac, char **av)
+static void verify_read(unsigned int n)
 {
-	int i;
-	int lc;
+	struct tcase *tc = &tcases[n];
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		for (i = 0; i < TST_TOTAL; i++)
-			read_verify(&TC[i]);
-	}
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	fd2 = SAFE_OPEN(cleanup, ".", O_DIRECTORY);
-
-	SAFE_FILE_PRINTF(cleanup, "test_file", "A");
-
-	fd3 = SAFE_OPEN(cleanup, "test_file", O_RDWR);
-
-#if !defined(UCLINUX)
-	outside_buf = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
-				MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
-#endif
-
-	addr4 = SAFE_MEMALIGN(cleanup, getpagesize(), (4096 * 10));
-	addr5 = addr4 + 1;
-
-	fs_type = tst_fs_type(cleanup, ".");
-	if (fs_type != TST_TMPFS_MAGIC)
-		fd4 = SAFE_OPEN(cleanup, "test_file", O_RDWR | O_DIRECT);
-}
-
-static void read_verify(const struct test_case_t *test)
-{
-	if (test->fd == &fd4 && *test->fd == -1) {
-		tst_resm(TCONF, "O_DIRECT not supported on %s filesystem",
-		         tst_fs_type_name(fs_type));
+	if (tc->fd == &fd4 && *tc->fd == -1) {
+		tst_res(TCONF, "O_DIRECT not supported on %s filesystem",
+			tst_fs_type_name(fs_type));
 		return;
 	}
 
-	TEST(read(*test->fd, *test->buf, test->count));
+	TEST(read(*tc->fd, *tc->buf, tc->count));
 
-	if (*test->fd == fd4 && TEST_RETURN >= 0) {
-		tst_resm(TPASS,
-			 "O_DIRECT unaligned reads fallbacks to buffered I/O");
+	if (*tc->fd == fd4 && TEST_RETURN >= 0) {
+		tst_res(TPASS,
+			"O_DIRECT unaligned reads fallbacks to buffered I/O");
 		return;
 	}
 
 	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "call succeeded unexpectedly");
+		tst_res(TFAIL, "read() succeeded unexpectedly");
 		return;
 	}
 
-	if (TEST_ERRNO == test->exp_error) {
-		tst_resm(TPASS | TTERRNO, "expected failure");
+	if (TEST_ERRNO == tc->exp_error) {
+		tst_res(TPASS | TTERRNO, "read() failed as expected");
 	} else {
-		tst_resm(TFAIL | TTERRNO, "unexpected error expected %d",
-			 test->exp_error);
+		tst_res(TFAIL | TTERRNO, "read() failed unexpectedly, "
+			"expected %s", tst_strerrno(tc->exp_error));
 	}
 }
 
+static void setup(void)
+{
+	fd2 = SAFE_OPEN(".", O_DIRECTORY);
+
+	SAFE_FILE_PRINTF("test_file", "A");
+
+	fd3 = SAFE_OPEN("test_file", O_RDWR);
+
+#if !defined(UCLINUX)
+	outside_buf = SAFE_MMAP(0, 1, PROT_NONE,
+				MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+#endif
+
+	addr4 = SAFE_MEMALIGN(getpagesize(), (4096 * 10));
+	addr5 = addr4 + 1;
+
+	fs_type = tst_fs_type(".");
+	if (fs_type != TST_TMPFS_MAGIC)
+		fd4 = SAFE_OPEN("test_file", O_RDWR | O_DIRECT);
+}
+
 static void cleanup(void)
 {
 	free(addr4);
 
 	if (fd4 > 0)
-		close(fd4);
+		SAFE_CLOSE(fd4);
 
 	if (fd3 > 0)
-		close(fd3);
+		SAFE_CLOSE(fd3);
 
 	if (fd2 > 0)
-		close(fd2);
-
-	tst_rmdir();
+		SAFE_CLOSE(fd2);
 }
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_read,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/readahead/readahead01.c b/testcases/kernel/syscalls/readahead/readahead01.c
index 5f829bd..f350194 100644
--- a/testcases/kernel/syscalls/readahead/readahead01.c
+++ b/testcases/kernel/syscalls/readahead/readahead01.c
@@ -38,7 +38,7 @@
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "readahead01";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index e2eb8bc..7e51cd3 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -45,7 +45,7 @@
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "readahead02";
 int TST_TOTAL = 1;
@@ -59,7 +59,7 @@
 static char *opt_fsizestr;
 static int pagesize;
 
-#define MIN_SANE_READAHEAD (4 * 1024)
+#define MIN_SANE_READAHEAD (4u * 1024u)
 
 option_t options[] = {
 	{"s:", &opt_fsize, &opt_fsizestr},
@@ -161,7 +161,7 @@
 	char *tmp;
 	size_t i;
 
-	tst_resm(TINFO, "creating test file of size: %ld", testfile_size);
+	tst_resm(TINFO, "creating test file of size: %zu", testfile_size);
 	tmp = SAFE_MALLOC(cleanup, pagesize);
 
 	/* round to page size */
diff --git a/testcases/kernel/syscalls/readdir/readdir21.c b/testcases/kernel/syscalls/readdir/readdir21.c
index ced8fa7..205e071 100644
--- a/testcases/kernel/syscalls/readdir/readdir21.c
+++ b/testcases/kernel/syscalls/readdir/readdir21.c
@@ -40,7 +40,7 @@
 #include <sys/mman.h>
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/readdir.h"
 
 char *TCID = "readdir21";
diff --git a/testcases/kernel/syscalls/readlinkat/readlinkat02.c b/testcases/kernel/syscalls/readlinkat/readlinkat02.c
index cd83bc3..d30c191 100644
--- a/testcases/kernel/syscalls/readlinkat/readlinkat02.c
+++ b/testcases/kernel/syscalls/readlinkat/readlinkat02.c
@@ -35,7 +35,7 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "lapi/readlinkat.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TEST_FILE	"test_file"
 #define SYMLINK_FILE	"symlink_file"
diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg02.c b/testcases/kernel/syscalls/recvmsg/recvmsg02.c
index 9ed520b..c2c6009 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg02.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg02.c
@@ -106,7 +106,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "recvmsg02",
 	.min_kver = "2.6.27",
 	.test_all = verify_recvmsg,
 	.cleanup = cleanup,
diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg03.c b/testcases/kernel/syscalls/recvmsg/recvmsg03.c
index bee9c12..8bbdace 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg03.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg03.c
@@ -90,6 +90,8 @@
 			"sendmsg() failed to send data to server");
 	}
 
+	TST_CHECKPOINT_WAIT(1);
+
 	SAFE_CLOSE(sock_fd1);
 }
 
@@ -137,6 +139,8 @@
 			msg.msg_namelen);
 	}
 
+	TST_CHECKPOINT_WAKE(1);
+
 	SAFE_CLOSE(sock_fd2);
 }
 
@@ -155,7 +159,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "recvmsg03",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/renameat2/renameat2.h b/testcases/kernel/syscalls/renameat2/renameat2.h
index dd0c2f7..b04558d 100644
--- a/testcases/kernel/syscalls/renameat2/renameat2.h
+++ b/testcases/kernel/syscalls/renameat2/renameat2.h
@@ -21,7 +21,7 @@
 
 #include <sys/types.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if !defined(HAVE_RENAMEAT2)
 int renameat2(int olddirfd, const char *oldpath, int newdirfd,
diff --git a/testcases/kernel/syscalls/request_key/request_key01.c b/testcases/kernel/syscalls/request_key/request_key01.c
index 583ecdc..d46bafa 100644
--- a/testcases/kernel/syscalls/request_key/request_key01.c
+++ b/testcases/kernel/syscalls/request_key/request_key01.c
@@ -61,7 +61,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "request_key01",
 	.setup = setup,
 	.test_all = verify_request_key,
 };
diff --git a/testcases/kernel/syscalls/request_key/request_key02.c b/testcases/kernel/syscalls/request_key/request_key02.c
index 17b1560..9bba241 100644
--- a/testcases/kernel/syscalls/request_key/request_key02.c
+++ b/testcases/kernel/syscalls/request_key/request_key02.c
@@ -107,7 +107,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "request_key02",
 	.setup = setup,
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_request_key,
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 5cf89cc..be9e9ab 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -37,7 +37,7 @@
 #include <string.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigaction01";
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
index a1da743..2c4d879 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
@@ -33,7 +33,7 @@
 #include <string.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigaction02";
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
index 175d220..823fbe6 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
@@ -33,7 +33,7 @@
 #include <string.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/rt_sigaction.h"
 
 #define INVAL_SIGSETSIZE -1
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 74e5a61..202e853 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -44,7 +44,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigprocmask01";
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
index cbc4f7e..5c8c36b 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
@@ -56,7 +56,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "ltp_signal.h"
 
 char *TCID = "rt_sigprocmask02";
diff --git a/testcases/kernel/syscalls/rt_sigqueueinfo/rt_sigqueueinfo01.c b/testcases/kernel/syscalls/rt_sigqueueinfo/rt_sigqueueinfo01.c
index 60757dd..9d0cff9 100644
--- a/testcases/kernel/syscalls/rt_sigqueueinfo/rt_sigqueueinfo01.c
+++ b/testcases/kernel/syscalls/rt_sigqueueinfo/rt_sigqueueinfo01.c
@@ -49,7 +49,7 @@
 #include <string.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "rt_sigqueueinfo01";
 int testno;
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 95b5827..19e2eb6 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -28,7 +28,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigsuspend01";
diff --git a/testcases/kernel/syscalls/sbrk/sbrk03.c b/testcases/kernel/syscalls/sbrk/sbrk03.c
index bdc4995..46fb2d1 100644
--- a/testcases/kernel/syscalls/sbrk/sbrk03.c
+++ b/testcases/kernel/syscalls/sbrk/sbrk03.c
@@ -76,6 +76,5 @@
 }
 
 static struct tst_test test = {
-	.tid = "sbrk03",
 	.test_all = sbrk_test,
 };
diff --git a/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c b/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c
index 9d6a81a..7e11465 100644
--- a/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c
+++ b/testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c
@@ -50,7 +50,7 @@
 #include <unistd.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "sched_getaffinity01";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c
index 62faeca..2a2c13a 100644
--- a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c
@@ -26,7 +26,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/sched.h"
 
 char *TCID = "sched_getattr01";
diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
index 5db9942..2d7e15a 100644
--- a/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
+++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -35,7 +35,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "lapi/sched.h"
 
 char *TCID = "sched_getattr02";
diff --git a/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c b/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
index 70fda2c..43f8efc 100644
--- a/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
+++ b/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
@@ -41,7 +41,7 @@
 #include "test.h"
 #include "safe_macros.h"
 #include "sched_setaffinity.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "sched_setaffinity01";
 
diff --git a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
index 8fcb65e..a513106 100644
--- a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
+++ b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
@@ -171,7 +171,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "sched_setscheduler03",
 	.tcnt = ARRAY_SIZE(cases),
 	.test = do_test,
 	.setup = setup,
diff --git a/testcases/kernel/syscalls/select/select04.c b/testcases/kernel/syscalls/select/select04.c
index 76253c4..1431785 100644
--- a/testcases/kernel/syscalls/select/select04.c
+++ b/testcases/kernel/syscalls/select/select04.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz>
  *
  * 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
@@ -25,104 +25,49 @@
 #include <sys/types.h>
 #include <fcntl.h>
 
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "select04";
-int TST_TOTAL = 1;
-
-static char *opt_sleep_us;
-
-static option_t opts[] = {
-	{"s:", NULL, &opt_sleep_us},
-	{NULL, NULL, NULL},
-};
-
-static void help(void);
-static void setup(void);
-static void cleanup(void);
+#include "tst_timer_test.h"
 
 static int fds[2];
 
-int main(int ac, char **av)
+static int sample_fn(int clk_id, long long usec)
 {
-	int lc, treshold;
-	long long elapsed_us, sleep_us = 100000;
-	struct timeval timeout;
+	struct timeval timeout = tst_us_to_timeval(usec);
 	fd_set sfds;
 
-	tst_parse_opts(ac, av, opts, help);
-
-	if (opt_sleep_us) {
-		sleep_us = atoll(opt_sleep_us);
-
-		if (sleep_us == 0) {
-			tst_brkm(TBROK, NULL, "Invalid timeout '%s'",
-			         opt_sleep_us);
-		}
-	}
-
-	treshold = sleep_us / 100 + 20000;
-
-	setup();
-
 	FD_ZERO(&sfds);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		FD_SET(fds[0], &sfds);
-		timeout = tst_us_to_timeval(sleep_us);
+	FD_SET(fds[0], &sfds);
 
-		tst_timer_start(CLOCK_MONOTONIC);
-		TEST(select(1, &sfds, NULL, NULL, &timeout));
-		tst_timer_stop();
+	tst_timer_start(clk_id);
+	TEST(select(1, &sfds, NULL, NULL, &timeout));
+	tst_timer_stop();
+	tst_timer_sample();
 
-		if (TEST_RETURN != 0) {
-			tst_resm(TFAIL, "select() haven't timeouted ret=%li",
-				 TEST_RETURN);
-			continue;
-		}
-
-		elapsed_us = tst_timer_elapsed_us();
-
-		if (elapsed_us < sleep_us) {
-			tst_resm(TFAIL,
-			         "select() woken up too early %llius, expected %llius",
-				 elapsed_us, sleep_us);
-			continue;
-		}
-
-		if (elapsed_us - sleep_us > treshold) {
-			tst_resm(TFAIL,
-			         "select() slept too long %llius, expected %llius, threshold %i",
-				 elapsed_us, sleep_us, treshold);
-			continue;
-		}
-
-		tst_resm(TPASS, "select() slept %llius, expected %llius, treshold %i",
-		         elapsed_us, sleep_us, treshold);
+	if (TEST_RETURN != 0) {
+		tst_res(TFAIL | TTERRNO, "select() returned %li", TEST_RETURN);
+		return 1;
 	}
 
-	cleanup();
-	tst_exit();
+	return 0;
 }
 
 static void setup(void)
 {
-	tst_timer_check(CLOCK_MONOTONIC);
-
-	SAFE_PIPE(NULL, fds);
+	SAFE_PIPE(fds);
 }
 
 static void cleanup(void)
 {
-	if (close(fds[0]))
-		tst_resm(TWARN | TERRNO, "close(fds[0]) failed");
+	if (fds[0] > 0)
+		SAFE_CLOSE(fds[0]);
 
-	if (close(fds[1]))
-		tst_resm(TWARN | TERRNO, "close(fds[1]) failed");
+	if (fds[1] > 0)
+		SAFE_CLOSE(fds[1]);
 }
 
-static void help(void)
-{
-	printf("  -s      select() timeout lenght in us\n");
-}
+static struct tst_test test = {
+	.tid = "select()",
+	.sample = sample_fn,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg02.c b/testcases/kernel/syscalls/sendmsg/sendmsg02.c
index 0285352..aa3c88d 100644
--- a/testcases/kernel/syscalls/sendmsg/sendmsg02.c
+++ b/testcases/kernel/syscalls/sendmsg/sendmsg02.c
@@ -41,6 +41,7 @@
 #include <sys/wait.h>
 #include <errno.h>
 #include <signal.h>
+#include <limits.h>
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/sendto/sendto02.c b/testcases/kernel/syscalls/sendto/sendto02.c
index b7b59fc..c8c2979 100644
--- a/testcases/kernel/syscalls/sendto/sendto02.c
+++ b/testcases/kernel/syscalls/sendto/sendto02.c
@@ -84,7 +84,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "sendto02",
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_sendto,
diff --git a/testcases/kernel/syscalls/set_thread_area/set_thread_area.h b/testcases/kernel/syscalls/set_thread_area/set_thread_area.h
index 8d3f4b1..2bd2469 100644
--- a/testcases/kernel/syscalls/set_thread_area/set_thread_area.h
+++ b/testcases/kernel/syscalls/set_thread_area/set_thread_area.h
@@ -3,7 +3,7 @@
 
 /* Harness Specific Include Files. */
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "config.h"
 
 #if defined HAVE_ASM_LDT_H
diff --git a/testcases/kernel/syscalls/set_tid_address/set_tid_address01.c b/testcases/kernel/syscalls/set_tid_address/set_tid_address01.c
index b7aea1b..20974a9 100644
--- a/testcases/kernel/syscalls/set_tid_address/set_tid_address01.c
+++ b/testcases/kernel/syscalls/set_tid_address/set_tid_address01.c
@@ -42,7 +42,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "set_tid_address01";
 int testno;
diff --git a/testcases/kernel/syscalls/setgroups/setgroups02.c b/testcases/kernel/syscalls/setgroups/setgroups02.c
index d7667b9..de23a4a 100644
--- a/testcases/kernel/syscalls/setgroups/setgroups02.c
+++ b/testcases/kernel/syscalls/setgroups/setgroups02.c
@@ -69,6 +69,7 @@
 #include <errno.h>
 #include <pwd.h>
 #include <grp.h>
+#include <sys/param.h>
 
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/setgroups/setgroups04.c b/testcases/kernel/syscalls/setgroups/setgroups04.c
index 2af410f..971c86b 100644
--- a/testcases/kernel/syscalls/setgroups/setgroups04.c
+++ b/testcases/kernel/syscalls/setgroups/setgroups04.c
@@ -62,6 +62,7 @@
  *
  */
 #include <sys/types.h>
+#include <sys/param.h>
 #include <unistd.h>
 #include <errno.h>
 #include <pwd.h>
diff --git a/testcases/kernel/syscalls/setns/setns01.c b/testcases/kernel/syscalls/setns/setns01.c
index 6409582..5d8a491 100644
--- a/testcases/kernel/syscalls/setns/setns01.c
+++ b/testcases/kernel/syscalls/setns/setns01.c
@@ -34,7 +34,7 @@
 #include <string.h>
 #include "config.h"
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 
 char *TCID = "setns01";
diff --git a/testcases/kernel/syscalls/setns/setns02.c b/testcases/kernel/syscalls/setns/setns02.c
index fc2fc74..58a02a6 100644
--- a/testcases/kernel/syscalls/setns/setns02.c
+++ b/testcases/kernel/syscalls/setns/setns02.c
@@ -42,7 +42,7 @@
 #include <string.h>
 #include "config.h"
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 
 #define CHILD_STACK_SIZE (1024*1024)
diff --git a/testcases/kernel/syscalls/setpriority/Makefile b/testcases/kernel/syscalls/setpriority/Makefile
index bd617d8..5d00984 100644
--- a/testcases/kernel/syscalls/setpriority/Makefile
+++ b/testcases/kernel/syscalls/setpriority/Makefile
@@ -20,4 +20,8 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+ifeq ($(ANDROID), 1)
+FILTER_OUT_MAKE_TARGETS	+= setpriority01
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setpriority/setpriority01.c b/testcases/kernel/syscalls/setpriority/setpriority01.c
index df02bce..d6cc79e 100644
--- a/testcases/kernel/syscalls/setpriority/setpriority01.c
+++ b/testcases/kernel/syscalls/setpriority/setpriority01.c
@@ -138,7 +138,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "setpriority01",
 	.tcnt = ARRAY_SIZE(tcases),
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/setpriority/setpriority02.c b/testcases/kernel/syscalls/setpriority/setpriority02.c
index cf58e02..0f61fca 100644
--- a/testcases/kernel/syscalls/setpriority/setpriority02.c
+++ b/testcases/kernel/syscalls/setpriority/setpriority02.c
@@ -121,7 +121,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "setpriority02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.needs_root = 1,
 	.forks_child = 1,
diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit02.c b/testcases/kernel/syscalls/setrlimit/setrlimit02.c
index 5175e9a..633279c 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit02.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit02.c
@@ -1,150 +1,75 @@
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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
- */
-
-/*
- * NAME
- *	setrlimit02.c
- *
- * DESCRIPTION
- *	Testcase to test the different errnos set by setrlimit(2) system call.
- *
- * USAGE:  <for command-line>
- *  setrlimit02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * HISTORY
+ * Copyright (c) International Business Machines  Corp., 2001
  *	07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
  *
- * RESTRICTIONS
- *	NONE
+ * 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
  */
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <unistd.h>
-#include <errno.h>
+/*
+ * Testcase to test the different errnos set by setrlimit(2) system call.
+ */
 #include <pwd.h>
-#include "test.h"
+#include <errno.h>
+#include "tst_test.h"
 
-char *TCID = "setrlimit02";
+static char nobody_uid[] = "nobody";
+static struct rlimit rlim;
 
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
-
-struct rlimit rlim;
-
-void setup();
-void cleanup();
-
-struct test_case_t {
+static struct tcase {
 	int resource;
 	struct rlimit *rlim;
-	int error;
-} TC[] = {
-#if !defined(UCLINUX)
-	/* rlim points outside the process address space - EFAULT */
-	{
-	RLIMIT_NOFILE, (void *)-1, EFAULT},
-#endif
-	    /* the resource is invalid - EINVAL */
-	{
-	-1, &rlim, EINVAL},
-	    /* a non-root user attemps to increase the rlim_max value - EPERM */
-	{
-	RLIMIT_NOFILE, &rlim, EPERM}
+	int exp_errno;
+} tcases[] = {
+	{-1, &rlim, EINVAL},
+	{RLIMIT_NOFILE, &rlim, EPERM}
 };
 
-int TST_TOTAL = ARRAY_SIZE(TC);
-
-int main(int ac, char **av)
+static void verify_setrlimit(unsigned int n)
 {
-	int lc;
-	int i;
+	struct tcase *tc = &tcases[n];
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(setrlimit(tc->resource, tc->rlim));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/* loop through the test cases */
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			TEST(setrlimit(TC[i].resource, TC[i].rlim));
-
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "call succeeded unexpectedly");
-				continue;
-			}
-
-			if (TEST_ERRNO == TC[i].error) {
-				tst_resm(TPASS, "expected failure - "
-					 "errno = %d : %s", TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TFAIL, "unexpected error - %d : %s - "
-					 "expected %d", TEST_ERRNO,
-					 strerror(TEST_ERRNO), TC[i].error);
-			}
-		}
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "call succeeded unexpectedly");
+		return;
 	}
-	cleanup();
 
-	tst_exit();
+	if (TEST_ERRNO != tc->exp_errno) {
+		tst_res(TFAIL | TTERRNO,
+			"setrlimit() should fail with %s got",
+			tst_strerrno(tc->exp_errno));
+		return;
+	}
 
+	tst_res(TPASS | TTERRNO, "setrlimit() failed as expected");
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
+static void setup(void)
 {
-	tst_require_root();
+	struct passwd *ltpuser = SAFE_GETPWNAM(nobody_uid);
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	SAFE_SETUID(ltpuser->pw_uid);
 
-	TEST_PAUSE;
-
-	/* Switch to nobody user for correct error code collection */
-	ltpuser = getpwnam(nobody_uid);
-	if (setuid(ltpuser->pw_uid) == -1) {
-		tst_resm(TINFO, "setuid failed to "
-			 "to set the effective uid to %d", ltpuser->pw_uid);
-		perror("setuid");
-	}
-
-	/* set an illegal value for a non-root user - test #3 - EPERM */
-	getrlimit(RLIMIT_NOFILE, &rlim);
+	SAFE_GETRLIMIT(RLIMIT_NOFILE, &rlim);
 	rlim.rlim_max++;
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
+static struct tst_test test = {
+	.setup = setup,
+	.test = verify_setrlimit,
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
+};
diff --git a/testcases/kernel/syscalls/setxattr/setxattr02.c b/testcases/kernel/syscalls/setxattr/setxattr02.c
index 73c464c..0ae452b 100644
--- a/testcases/kernel/syscalls/setxattr/setxattr02.c
+++ b/testcases/kernel/syscalls/setxattr/setxattr02.c
@@ -45,6 +45,7 @@
 #include "config.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/testcases/kernel/syscalls/sgetmask/sgetmask01.c b/testcases/kernel/syscalls/sgetmask/sgetmask01.c
index 7114856..2b482f3 100644
--- a/testcases/kernel/syscalls/sgetmask/sgetmask01.c
+++ b/testcases/kernel/syscalls/sgetmask/sgetmask01.c
@@ -53,7 +53,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "sgetmask01";
 int testno;
diff --git a/testcases/kernel/syscalls/signal/signal06.c b/testcases/kernel/syscalls/signal/signal06.c
index 1f1b31c..64f886e 100644
--- a/testcases/kernel/syscalls/signal/signal06.c
+++ b/testcases/kernel/syscalls/signal/signal06.c
@@ -48,7 +48,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "signal06";
 int TST_TOTAL = 5;
diff --git a/testcases/kernel/syscalls/signalfd/signalfd01.c b/testcases/kernel/syscalls/signalfd/signalfd01.c
index 48c9292..9859524 100644
--- a/testcases/kernel/syscalls/signalfd/signalfd01.c
+++ b/testcases/kernel/syscalls/signalfd/signalfd01.c
@@ -83,7 +83,7 @@
 
 #else
 #if defined USE_OWNIMPL
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 int signalfd(int fd, const sigset_t * mask, int flags)
 {
 	/* Taken from GLIBC. */
diff --git a/testcases/kernel/syscalls/signalfd4/signalfd4_01.c b/testcases/kernel/syscalls/signalfd4/signalfd4_01.c
index 4dc60d2..9f85973 100644
--- a/testcases/kernel/syscalls/signalfd4/signalfd4_01.c
+++ b/testcases/kernel/syscalls/signalfd4/signalfd4_01.c
@@ -63,7 +63,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "ltp_signal.h"
 
 #define SFD_CLOEXEC O_CLOEXEC
diff --git a/testcases/kernel/syscalls/signalfd4/signalfd4_02.c b/testcases/kernel/syscalls/signalfd4/signalfd4_02.c
index 800687d..ddf8b8c 100644
--- a/testcases/kernel/syscalls/signalfd4/signalfd4_02.c
+++ b/testcases/kernel/syscalls/signalfd4/signalfd4_02.c
@@ -58,7 +58,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "ltp_signal.h"
 
 #define SFD_NONBLOCK O_NONBLOCK
diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
index 1cc3918..35acd67 100644
--- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -26,7 +26,7 @@
 #include "../utils/include_j_h.h"
 #include "../utils/common_j_h.c"
 #include <limits.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define SUCCEED_OR_DIE(syscall, message, ...)				 \
 	(errno = 0,							 \
diff --git a/testcases/kernel/syscalls/socket/socket01.c b/testcases/kernel/syscalls/socket/socket01.c
index 9592d51..9d2fe4f 100644
--- a/testcases/kernel/syscalls/socket/socket01.c
+++ b/testcases/kernel/syscalls/socket/socket01.c
@@ -98,7 +98,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "socket01",
 	.tcnt = ARRAY_SIZE(tdat),
 	.setup = setup,
 	.test = verify_socket
diff --git a/testcases/kernel/syscalls/socket/socket02.c b/testcases/kernel/syscalls/socket/socket02.c
index ecc5b01..0584163 100644
--- a/testcases/kernel/syscalls/socket/socket02.c
+++ b/testcases/kernel/syscalls/socket/socket02.c
@@ -79,7 +79,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "socket02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_socket,
 	.min_kver = "2.6.27",
diff --git a/testcases/kernel/syscalls/socketcall/socketcall01.c b/testcases/kernel/syscalls/socketcall/socketcall01.c
index 9401964..7fe5cbe 100644
--- a/testcases/kernel/syscalls/socketcall/socketcall01.c
+++ b/testcases/kernel/syscalls/socketcall/socketcall01.c
@@ -61,7 +61,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "socketcall01",
 	.test = verify_socketcall,
 	.tcnt = ARRAY_SIZE(TC),
 	.needs_root = 1,
diff --git a/testcases/kernel/syscalls/socketpair/socketpair01.c b/testcases/kernel/syscalls/socketpair/socketpair01.c
index f7833a4..6729075 100644
--- a/testcases/kernel/syscalls/socketpair/socketpair01.c
+++ b/testcases/kernel/syscalls/socketpair/socketpair01.c
@@ -102,7 +102,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "socketpair01",
 	.tcnt = ARRAY_SIZE(tdat),
 	.setup = setup,
 	.test = verify_socketpair
diff --git a/testcases/kernel/syscalls/socketpair/socketpair02.c b/testcases/kernel/syscalls/socketpair/socketpair02.c
index 6507e31..f8057ce 100644
--- a/testcases/kernel/syscalls/socketpair/socketpair02.c
+++ b/testcases/kernel/syscalls/socketpair/socketpair02.c
@@ -92,7 +92,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "socketpair02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_socketpair,
 	.min_kver = "2.6.27",
diff --git a/testcases/kernel/syscalls/splice/splice.h b/testcases/kernel/syscalls/splice/splice.h
new file mode 100644
index 0000000..16e4c98
--- /dev/null
+++ b/testcases/kernel/syscalls/splice/splice.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017 Xiao Yang <yangx.jy@cn.fujitsu.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPLICE_H__
+#define SPLICE_H__
+
+#include <unistd.h>
+#include "tst_safe_file_ops.h"
+#include "tst_minmax.h"
+
+static inline int get_max_limit(int default_len_data)
+{
+	int pipe_max_unpriv;
+
+	if (!access("/proc/sys/fs/pipe-max-size", F_OK)) {
+		SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d", &pipe_max_unpriv);
+		return MIN(pipe_max_unpriv, default_len_data);
+	}
+
+	if (!access("/proc/sys/fs/pipe-max-pages", F_OK)) {
+		SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-pages", "%d", &pipe_max_unpriv);
+		return MIN(pipe_max_unpriv * getpagesize(), default_len_data);
+	}
+
+	return default_len_data;
+}
+
+#endif  /* SPLICE_H__ */
diff --git a/testcases/kernel/syscalls/splice/splice01.c b/testcases/kernel/syscalls/splice/splice01.c
index 773639e..a975ccb 100644
--- a/testcases/kernel/syscalls/splice/splice01.c
+++ b/testcases/kernel/syscalls/splice/splice01.c
@@ -30,10 +30,8 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <fcntl.h>
-#include <sys/syscall.h>
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/splice.h"
 
 #define TEST_BLOCK_SIZE 1024
@@ -41,37 +39,16 @@
 #define TESTFILE1 "splice_testfile_1"
 #define TESTFILE2 "splice_testfile_2"
 
-static void splice_test(void);
-static void setup(void);
-static void cleanup(void);
 static char buffer[TEST_BLOCK_SIZE];
 static int fd_in, fd_out;
 
-char *TCID = "splice01";
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
-{
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		splice_test();
-
-	cleanup();
-	tst_exit();
-}
-
 static void check_file(void)
 {
 	int i;
 	char splicebuffer[TEST_BLOCK_SIZE];
 
-	fd_out = SAFE_OPEN(cleanup, TESTFILE2, O_RDONLY);
-	SAFE_READ(cleanup, 1, fd_out, splicebuffer, TEST_BLOCK_SIZE);
+	fd_out = SAFE_OPEN(TESTFILE2, O_RDONLY);
+	SAFE_READ(1, fd_out, splicebuffer, TEST_BLOCK_SIZE);
 
 	for (i = 0; i < TEST_BLOCK_SIZE; i++) {
 		if (buffer[i] != splicebuffer[i])
@@ -79,12 +56,11 @@
 	}
 
 	if (i < TEST_BLOCK_SIZE)
-		tst_resm(TFAIL, "Wrong data read from the buffer at %i", i);
+		tst_res(TFAIL, "Wrong data read from the buffer at %i", i);
 	else
-		tst_resm(TPASS, "Written data has been read back correctly");
+		tst_res(TPASS, "Written data has been read back correctly");
 
-	close(fd_out);
-	fd_out = 0;
+	SAFE_CLOSE(fd_out);
 }
 
 static void splice_test(void)
@@ -92,25 +68,22 @@
 	int pipes[2];
 	int ret;
 
-	fd_in = SAFE_OPEN(cleanup, TESTFILE1, O_RDONLY);
-	SAFE_PIPE(cleanup, pipes);
-	fd_out = SAFE_OPEN(cleanup, TESTFILE2, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+	fd_in = SAFE_OPEN(TESTFILE1, O_RDONLY);
+	fd_out = SAFE_OPEN(TESTFILE2, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+	SAFE_PIPE(pipes);
 
 	ret = splice(fd_in, NULL, pipes[1], NULL, TEST_BLOCK_SIZE, 0);
 	if (ret < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "splice(fd_in, pipe) failed");
+		tst_brk(TBROK | TERRNO, "splice(fd_in, pipe) failed");
 
 	ret = splice(pipes[0], NULL, fd_out, NULL, TEST_BLOCK_SIZE, 0);
 	if (ret < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "splice(pipe, fd_out) failed");
+		tst_brk(TBROK | TERRNO, "splice(pipe, fd_out) failed");
 
-	close(fd_in);
-	close(fd_out);
-	close(pipes[0]);
-	close(pipes[1]);
-
-	fd_out = 0;
-	fd_in = 0;
+	SAFE_CLOSE(fd_in);
+	SAFE_CLOSE(fd_out);
+	SAFE_CLOSE(pipes[0]);
+	SAFE_CLOSE(pipes[1]);
 
 	check_file();
 }
@@ -119,39 +92,33 @@
 {
 	int i;
 
-	if ((tst_kvercmp(2, 6, 17)) < 0) {
-		tst_brkm(TCONF, NULL,
-		         "The splice is supported 2.6.17 and newer");
-	}
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC) {
+	if (tst_fs_type(".") == TST_NFS_MAGIC) {
 		if  (tst_kvercmp(2, 6, 32) < 0)
-			tst_brkm(TCONF, cleanup, "Cannot do splice on a file"
+			tst_brk(TCONF, "Cannot do splice on a file"
 				" on NFS filesystem before 2.6.32");
 	}
 
 	for (i = 0; i < TEST_BLOCK_SIZE; i++)
 		buffer[i] = i & 0xff;
 
-	fd_in = SAFE_OPEN(cleanup, TESTFILE1, O_WRONLY | O_CREAT | O_TRUNC, 0777);
-	SAFE_WRITE(cleanup, 1, fd_in, buffer, TEST_BLOCK_SIZE);
-	SAFE_CLOSE(cleanup, fd_in);
-	fd_in = 0;
+	fd_in = SAFE_OPEN(TESTFILE1, O_WRONLY | O_CREAT | O_TRUNC, 0777);
+	SAFE_WRITE(1, fd_in, buffer, TEST_BLOCK_SIZE);
+	SAFE_CLOSE(fd_in);
 }
 
 static void cleanup(void)
 {
-	if (fd_in > 0 && close(fd_in))
-		tst_resm(TWARN, "Failed to close fd_in");
+	if (fd_in > 0)
+		SAFE_CLOSE(fd_in);
 
-	if (fd_out > 0 && close(fd_out))
-		tst_resm(TWARN, "Failed to close fd_out");
-
-	tst_rmdir();
+	if (fd_out > 0)
+		SAFE_CLOSE(fd_out);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = splice_test,
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.17",
+};
diff --git a/testcases/kernel/syscalls/splice/splice02.c b/testcases/kernel/syscalls/splice/splice02.c
index d2f843a..a9ca515 100644
--- a/testcases/kernel/syscalls/splice/splice02.c
+++ b/testcases/kernel/syscalls/splice/splice02.c
@@ -19,17 +19,7 @@
 /*                                                                            */
 /******************************************************************************/
 /******************************************************************************/
-/*                                                                            */
-/* File:        splice02.c                                                    */
-/*                                                                            */
 /* Description: This tests the splice() syscall                               */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* echo "Test splice()" > <outfile>; splice02 <outfile>                       */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   splice02                                                      */
 /******************************************************************************/
 #define _GNU_SOURCE
 
@@ -38,54 +28,30 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/splice.h"
 
-char *TCID = "splice02";
-int TST_TOTAL = 1;
-
-static void cleanup(void)
-{
-	tst_rmdir();
-}
-
-static void setup(void)
-{
-	if ((tst_kvercmp(2, 6, 17)) < 0) {
-		tst_brkm(TCONF, cleanup, "This test can only run on kernels "
-			"that are 2.6.17 or higher");
-	}
-
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
 #define SPLICE_SIZE (64*1024)
 
-int main(int ac, char **av)
+static void splice_test(void)
 {
 	int fd;
 
-	setup();
-
-	if (ac < 2) {
-		tst_brkm(TFAIL, NULL, "%s failed - Usage: %s outfile", TCID,
-			 av[0]);
-	}
-
-	fd = SAFE_OPEN(cleanup, av[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
+	fd = SAFE_OPEN("splice02-temp", O_WRONLY | O_CREAT | O_TRUNC, 0644);
 
 	TEST(splice(STDIN_FILENO, NULL, fd, NULL, SPLICE_SIZE, 0));
 	if (TEST_RETURN < 0) {
-		tst_resm(TFAIL, "splice failed - errno = %d : %s",
-			 TEST_ERRNO, strerror(TEST_ERRNO));
+		tst_res(TFAIL, "splice failed - errno = %d : %s",
+			TEST_ERRNO, strerror(TEST_ERRNO));
 	} else {
-		tst_resm(TPASS, "splice() system call Passed");
+		tst_res(TPASS, "splice() system call Passed");
 	}
 
-	SAFE_CLOSE(cleanup, fd);
-
-	cleanup();
-	tst_exit();
+	SAFE_CLOSE(fd);
 }
+
+static struct tst_test test = {
+	.test_all = splice_test,
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.17",
+};
diff --git a/testcases/kernel/syscalls/splice/splice03.c b/testcases/kernel/syscalls/splice/splice03.c
index b18c52a..86363dd 100644
--- a/testcases/kernel/syscalls/splice/splice03.c
+++ b/testcases/kernel/syscalls/splice/splice03.c
@@ -40,8 +40,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/splice.h"
 
 #define TEST_FILE "testfile"
@@ -58,13 +57,13 @@
 static int pipes[2];
 static loff_t offset;
 
-static struct test_case_t {
+static struct tcase {
 	int *fdin;
 	loff_t *offin;
 	int *fdout;
 	loff_t *offout;
 	int exp_errno;
-} test_cases[] = {
+} tcases[] = {
 	{ &badfd, NULL, &pipes[1], NULL, EBADF },
 	{ &pipes[0], NULL, &badfd, NULL, EBADF },
 	{ &wrfd, NULL, &pipes[1], NULL, EBADF },
@@ -74,96 +73,66 @@
 	{ &rdfd, NULL, &pipes[1], &offset, ESPIPE },
 };
 
-static void setup(void);
-static void cleanup(void);
-static void splice_verify(const struct test_case_t *);
-
-char *TCID = "splice03";
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-int main(int ac, char **av)
+static void setup(void)
 {
-	int i, lc;
+	SAFE_FILE_PRINTF(TEST_FILE, STR);
+	rdfd = SAFE_OPEN(TEST_FILE, O_RDONLY);
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	wrfd = SAFE_OPEN(TEST_FILE2, O_WRONLY | O_CREAT, 0644);
 
-	setup();
+	appendfd = SAFE_OPEN(TEST_FILE3, O_RDWR | O_CREAT | O_APPEND, 0644);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+	SAFE_PIPE(pipes);
 
-		for (i = 0; i < TST_TOTAL; i++)
-			splice_verify(&test_cases[i]);
-	}
-
-	cleanup();
-	tst_exit();
+	SAFE_WRITE(1, pipes[1], STR, sizeof(STR) - 1);
 }
 
-void setup(void)
+static void splice_verify(unsigned int n)
 {
-	if ((tst_kvercmp(2, 6, 17)) < 0) {
-		tst_brkm(TCONF, cleanup, "This test can only run on kernels "
-			"that are 2.6.17 or higher");
-	}
+	struct tcase *tc = &tcases[n];
 
-	TEST_PAUSE;
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	tst_tmpdir();
-
-	SAFE_FILE_PRINTF(cleanup, TEST_FILE, STR);
-	rdfd = SAFE_OPEN(cleanup, TEST_FILE, O_RDONLY);
-
-	wrfd = SAFE_OPEN(cleanup, TEST_FILE2,
-		O_WRONLY | O_CREAT, 0644);
-
-	appendfd = SAFE_OPEN(cleanup, TEST_FILE3,
-		O_RDWR | O_CREAT | O_APPEND, 0644);
-
-	SAFE_PIPE(cleanup, pipes);
-
-	SAFE_WRITE(cleanup, 1, pipes[1], STR, sizeof(STR) - 1);
-}
-
-static void splice_verify(const struct test_case_t *tc)
-{
 	TEST(splice(*(tc->fdin), tc->offin, *(tc->fdout),
 		tc->offout, SPLICE_TEST_LEN, 0));
 
 	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "splice() returned %ld, "
-			"expected -1, errno:%d", TEST_RETURN,
-			tc->exp_errno);
+		tst_res(TFAIL, "splice() returned %ld expected %s",
+			TEST_RETURN, tst_strerrno(tc->exp_errno));
 		return;
 	}
 
-	if (TEST_ERRNO == tc->exp_errno) {
-		tst_resm(TPASS | TTERRNO, "splice() failed as expected");
-	} else {
-		tst_resm(TFAIL | TTERRNO,
+	if (TEST_ERRNO != tc->exp_errno) {
+		tst_res(TFAIL | TTERRNO,
 			"splice() failed unexpectedly; expected: %d - %s",
-			tc->exp_errno, strerror(tc->exp_errno));
+			tc->exp_errno, tst_strerrno(tc->exp_errno));
+		return;
 	}
+
+	tst_res(TPASS | TTERRNO, "splice() failed as expected");
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	if (rdfd && close(rdfd) < 0)
-		tst_resm(TWARN | TERRNO, "close rdfd failed");
+	if (rdfd > 0)
+		SAFE_CLOSE(rdfd);
 
-	if (wrfd && close(wrfd) < 0)
-		tst_resm(TWARN | TERRNO, "close wrfd failed");
+	if (wrfd > 0)
+		SAFE_CLOSE(wrfd);
 
-	if (appendfd && close(appendfd) < 0)
-		tst_resm(TWARN | TERRNO, "close appendfd failed");
+	if (appendfd > 0)
+		SAFE_CLOSE(appendfd);
 
-	if (pipes[0] && close(pipes[0]) < 0)
-		tst_resm(TWARN | TERRNO, "close pipes[0] failed");
+	if (pipes[0] > 0)
+		SAFE_CLOSE(pipes[0]);
 
-	if (pipes[1] && close(pipes[1]) < 0)
-		tst_resm(TWARN | TERRNO, "close pipes[1] failed");
-
-	tst_rmdir();
+	if (pipes[1] > 0)
+		SAFE_CLOSE(pipes[1]);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = splice_verify,
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.17",
+};
diff --git a/testcases/kernel/syscalls/splice/splice04.c b/testcases/kernel/syscalls/splice/splice04.c
new file mode 100644
index 0000000..852dd05
--- /dev/null
+++ b/testcases/kernel/syscalls/splice/splice04.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2017 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Boyang Xue <bxue@redhat.com>
+ */
+
+/*
+ * Functional test for splice(2): pipe to pipe
+ *
+ * This test case tests splice(2) from a pipe to another
+ */
+
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <stdlib.h>
+#include "tst_test.h"
+#include "lapi/splice.h"
+#include "splice.h"
+
+#define PIPE_MAX (64*1024)
+
+static char *str_len_data;
+static int num_len_data = PIPE_MAX;
+static char *arr_in, *arr_out;
+
+static struct tst_option options[] = {
+	{"l:", &str_len_data, "-l <num> Length of test data (in bytes)"},
+	{NULL, NULL, NULL},
+};
+
+static void setup(void)
+{
+	int i, pipe_limit;
+
+	pipe_limit = get_max_limit(num_len_data);
+	num_len_data = pipe_limit;
+
+	if (tst_parse_int(str_len_data, &num_len_data, 1, pipe_limit)) {
+		tst_brk(TBROK, "Invalid length of data: '%s', "
+			"valid value: [1, %d]", str_len_data, pipe_limit);
+	}
+	tst_res(TINFO, "splice size = %d", num_len_data);
+	arr_in = SAFE_MALLOC(num_len_data);
+	arr_out = SAFE_MALLOC(num_len_data);
+	for (i = 0; i < num_len_data; i++)
+		arr_in[i] = i & 0xff;
+}
+
+static void cleanup(void)
+{
+	free(arr_in);
+	free(arr_out);
+}
+
+static void pipe_pipe(void)
+{
+	int pp1[2], pp2[2], i, ret;
+
+	SAFE_PIPE(pp1);
+	SAFE_PIPE(pp2);
+	SAFE_WRITE(1, pp1[1], arr_in, num_len_data);
+	for (i = num_len_data; i > 0; i = i - ret) {
+		ret = splice(pp1[0], NULL, pp2[1], NULL, i, 0);
+		if (ret == -1) {
+			tst_res(TFAIL | TERRNO, "splice error");
+			goto exit;
+		}
+		SAFE_READ(1, pp2[0], arr_out + num_len_data - i, ret);
+	}
+
+	for (i = 0; i < num_len_data; i++) {
+		if (arr_in[i] != arr_out[i]) {
+			tst_res(TFAIL, "wrong data at %d: expected: %d, "
+				"actual: %d", i, arr_in[i], arr_out[i]);
+			goto exit;
+		}
+	}
+	tst_res(TPASS, "splice(2) from pipe to pipe run pass.");
+
+exit:
+	SAFE_CLOSE(pp1[1]);
+	SAFE_CLOSE(pp1[0]);
+	SAFE_CLOSE(pp2[1]);
+	SAFE_CLOSE(pp2[0]);
+}
+
+static struct tst_test test = {
+	.test_all = pipe_pipe,
+	.setup = setup,
+	.cleanup = cleanup,
+	.options = options,
+	.min_kver = "2.6.31"
+};
diff --git a/testcases/kernel/syscalls/splice/splice05.c b/testcases/kernel/syscalls/splice/splice05.c
new file mode 100644
index 0000000..b8ee49c
--- /dev/null
+++ b/testcases/kernel/syscalls/splice/splice05.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2017 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Boyang Xue <bxue@redhat.com>
+ */
+
+/*
+ * Functional test for splice(2): pipe <-> socket
+ *
+ * This test case tests splice(2) from a pipe to a socket and vice versa
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "tst_test.h"
+#include "lapi/splice.h"
+#include "splice.h"
+
+#define PIPE_MAX (64*1024)
+
+static char *str_len_data;
+static int num_len_data = PIPE_MAX;
+static char *arr_in, *arr_out;
+
+static struct tst_option options[] = {
+	{"l:", &str_len_data, "-l <num> Length of test data (in bytes)"},
+	{NULL, NULL, NULL},
+};
+
+static void setup(void)
+{
+	int i, pipe_limit;
+
+	pipe_limit = get_max_limit(num_len_data);
+	num_len_data = pipe_limit;
+
+	if (tst_parse_int(str_len_data, &num_len_data, 1, pipe_limit)) {
+		tst_brk(TBROK, "Invalid length of data: '%s', "
+			"valid value: [1, %d]", str_len_data, pipe_limit);
+	}
+	tst_res(TINFO, "splice size = %d", num_len_data);
+	arr_in = SAFE_MALLOC(num_len_data);
+	arr_out = SAFE_MALLOC(num_len_data);
+	for (i = 0; i < num_len_data; i++)
+		arr_in[i] = i & 0xff;
+
+}
+
+static void cleanup(void)
+{
+	free(arr_in);
+	free(arr_out);
+}
+
+static void pipe_socket(void)
+{
+	int pp1[2], pp2[2], sv[2], i, ret;
+
+	SAFE_PIPE(pp1);
+	SAFE_PIPE(pp2);
+	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv))
+		tst_brk(TBROK | TERRNO, "fail to create socket pair.");
+
+	SAFE_WRITE(1, pp1[1], arr_in, num_len_data);
+	for (i = num_len_data; i > 0; i = i - ret) {
+		ret = splice(pp1[0], NULL, sv[0], 0, i, 0);
+		if (ret == -1) {
+			tst_res(TFAIL | TERRNO, "splice error");
+			goto exit;
+		}
+	}
+	for (i = num_len_data; i > 0; i = i - ret) {
+		ret = splice(sv[1], 0, pp2[1], NULL, i, 0);
+		if (ret == -1) {
+			if (errno == EINVAL) {
+				tst_res(TCONF, "splice does not support "
+					"af_unix sockets");
+			} else {
+				tst_res(TFAIL | TERRNO, "splice error");
+			}
+			goto exit;
+		}
+		SAFE_READ(1, pp2[0], arr_out + num_len_data - i, ret);
+	}
+
+	for (i = 0; i < num_len_data; i++) {
+		if (arr_in[i] != arr_out[i]) {
+			tst_res(TFAIL, "wrong data at %d: expected: %d, "
+				"actual: %d", i, arr_in[i], arr_out[i]);
+			goto exit;
+		}
+	}
+	tst_res(TPASS, "splice(2): pipe <-> socket run pass.");
+exit:
+	for (i = 0; i < 2; i++) {
+		SAFE_CLOSE(pp1[i]);
+		SAFE_CLOSE(pp2[i]);
+		SAFE_CLOSE(sv[i]);
+	}
+}
+
+static struct tst_test test = {
+	.test_all = pipe_socket,
+	.setup = setup,
+	.cleanup = cleanup,
+	.options = options,
+	.min_kver = "2.6.17"
+};
diff --git a/testcases/kernel/syscalls/ssetmask/ssetmask01.c b/testcases/kernel/syscalls/ssetmask/ssetmask01.c
index d024696..336a9be 100644
--- a/testcases/kernel/syscalls/ssetmask/ssetmask01.c
+++ b/testcases/kernel/syscalls/ssetmask/ssetmask01.c
@@ -44,7 +44,7 @@
 #include <signal.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "ssetmask01";
 int testno;
diff --git a/testcases/kernel/syscalls/stat/stat01.c b/testcases/kernel/syscalls/stat/stat01.c
index ee71c56..e041311 100644
--- a/testcases/kernel/syscalls/stat/stat01.c
+++ b/testcases/kernel/syscalls/stat/stat01.c
@@ -72,8 +72,8 @@
 	}
 
 	if (stat_buf.st_size != FILE_SIZE) {
-		tst_resm(TINFO, "stat_buf.st_size = %zu expected %i",
-		         stat_buf.st_size, FILE_SIZE);
+		tst_resm(TINFO, "stat_buf.st_size = %li expected %i",
+		         (long)stat_buf.st_size, FILE_SIZE);
 		fail++;
 	}
 
diff --git a/testcases/kernel/syscalls/swapoff/swapoff01.c b/testcases/kernel/syscalls/swapoff/swapoff01.c
index b612e23..a63e661 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff01.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff01.c
@@ -24,7 +24,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void setup(void);
 static void cleanup(void);
diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c b/testcases/kernel/syscalls/swapoff/swapoff02.c
index 8ad6afc..b5c6312 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff02.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff02.c
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 
 static void setup(void);
diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index 2827699..32538f8 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -23,7 +23,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "libswapon.h"
 
 static void setup(void);
diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
index 50f2f7f..4af5105 100644
--- a/testcases/kernel/syscalls/swapon/swapon02.c
+++ b/testcases/kernel/syscalls/swapon/swapon02.c
@@ -33,7 +33,7 @@
 #include <sys/utsname.h>
 #include <signal.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "safe_macros.h"
 #include "libswapon.h"
 
diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
index 9693bef..d3f73b0 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -37,7 +37,7 @@
 #include <string.h>
 #include <signal.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 #include "swaponoff.h"
 #include "libswapon.h"
 
diff --git a/testcases/kernel/syscalls/switch/endian_switch01.c b/testcases/kernel/syscalls/switch/endian_switch01.c
index 98584ba..86aed89 100644
--- a/testcases/kernel/syscalls/switch/endian_switch01.c
+++ b/testcases/kernel/syscalls/switch/endian_switch01.c
@@ -51,7 +51,7 @@
 #include <fcntl.h>
 #include <sys/utsname.h>
 #include <unistd.h>
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #if defined (__powerpc64__) || (__powerpc__)
 static void setup();
diff --git a/testcases/kernel/syscalls/symlinkat/symlinkat01.c b/testcases/kernel/syscalls/symlinkat/symlinkat01.c
index 14b781e..8c9e148 100644
--- a/testcases/kernel/syscalls/symlinkat/symlinkat01.c
+++ b/testcases/kernel/syscalls/symlinkat/symlinkat01.c
@@ -43,7 +43,7 @@
 #include <signal.h>
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define MYRETCODE -999
 #ifndef AT_FDCWD
diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c
index ea05195..0a9fb8e 100644
--- a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c
+++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c
@@ -92,7 +92,7 @@
 #include <unistd.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #ifndef SYNC_FILE_RANGE_WAIT_BEFORE
 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
diff --git a/testcases/kernel/syscalls/syscall/syscall01.c b/testcases/kernel/syscalls/syscall/syscall01.c
index 1f5b8a3..1173c31 100644
--- a/testcases/kernel/syscalls/syscall/syscall01.c
+++ b/testcases/kernel/syscalls/syscall/syscall01.c
@@ -28,7 +28,7 @@
 #include <sys/types.h>
 
 #include "tst_test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void verify_getpid(void)
 {
@@ -88,7 +88,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "syscall01",
 	.test = verify_syscall,
 	.tcnt = ARRAY_SIZE(tcases),
 };
diff --git a/testcases/kernel/syscalls/sysfs/sysfs01.c b/testcases/kernel/syscalls/sysfs/sysfs01.c
index 9d9a082..85052dc 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs01.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs01.c
@@ -70,7 +70,7 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void setup();
 static void cleanup();
diff --git a/testcases/kernel/syscalls/sysfs/sysfs02.c b/testcases/kernel/syscalls/sysfs/sysfs02.c
index 6c94b1e..e9065dd 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs02.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs02.c
@@ -68,7 +68,7 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void setup();
 static void cleanup();
diff --git a/testcases/kernel/syscalls/sysfs/sysfs03.c b/testcases/kernel/syscalls/sysfs/sysfs03.c
index b49b99e..98bd5c6 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs03.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs03.c
@@ -68,7 +68,7 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void setup();
 static void cleanup();
diff --git a/testcases/kernel/syscalls/sysfs/sysfs04.c b/testcases/kernel/syscalls/sysfs/sysfs04.c
index b1131e4..6356a89 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs04.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs04.c
@@ -71,7 +71,7 @@
 #include <errno.h>
 #include  <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define INVALID_OPTION 100
 static void setup();
diff --git a/testcases/kernel/syscalls/sysfs/sysfs05.c b/testcases/kernel/syscalls/sysfs/sysfs05.c
index 36bc786..8f8bb35 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs05.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs05.c
@@ -72,7 +72,7 @@
 #include <errno.h>
 #include <sys/syscall.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void setup();
 static void cleanup();
diff --git a/testcases/kernel/syscalls/sysfs/sysfs06.c b/testcases/kernel/syscalls/sysfs/sysfs06.c
index e169462..d9a8cd5 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs06.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs06.c
@@ -73,7 +73,7 @@
 #include <sys/syscall.h>
 #include <sys/mman.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 static void setup();
 static void cleanup();
diff --git a/testcases/kernel/syscalls/tee/tee01.c b/testcases/kernel/syscalls/tee/tee01.c
index 6e1f46f..7e64779 100644
--- a/testcases/kernel/syscalls/tee/tee01.c
+++ b/testcases/kernel/syscalls/tee/tee01.c
@@ -31,19 +31,12 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <fcntl.h>
-#include <sys/syscall.h>
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/fcntl.h"
 #include "lapi/tee.h"
 #include "lapi/splice.h"
 
-static void tee_test(void);
-static void setup(void);
-static void cleanup(void);
-
 #define TEST_BLOCK_SIZE 1024
 
 #define TESTFILE1 "tee_test_file_1"
@@ -52,31 +45,13 @@
 static int fd_in, fd_out;
 static char buffer[TEST_BLOCK_SIZE];
 
-char *TCID = "tee01";
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
-{
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		tee_test();
-
-	cleanup();
-	tst_exit();
-}
-
 static void check_file(void)
 {
 	int i;
 	char teebuffer[TEST_BLOCK_SIZE];
 
-	fd_out = SAFE_OPEN(cleanup, TESTFILE2, O_RDONLY);
-	SAFE_READ(cleanup, 1, fd_out, teebuffer, TEST_BLOCK_SIZE);
+	fd_out = SAFE_OPEN(TESTFILE2, O_RDONLY);
+	SAFE_READ(1, fd_out, teebuffer, TEST_BLOCK_SIZE);
 
 	for (i = 0; i < TEST_BLOCK_SIZE; i++) {
 		if (buffer[i] != teebuffer[i])
@@ -84,12 +59,11 @@
 	}
 
 	if (i < TEST_BLOCK_SIZE)
-		tst_resm(TFAIL, "Wrong data read from the buffer at %i", i);
+		tst_res(TFAIL, "Wrong data read from the buffer at %i", i);
 	else
-		tst_resm(TPASS, "Written data has been read back correctly");
+		tst_res(TPASS, "Written data has been read back correctly");
 
-	close(fd_out);
-	fd_out = 0;
+	SAFE_CLOSE(fd_out);
 }
 
 static void tee_test(void)
@@ -98,33 +72,30 @@
 	int pipe2[2];
 	int ret = 0;
 
-	fd_in = SAFE_OPEN(cleanup, TESTFILE1, O_RDONLY);
-	fd_out = SAFE_OPEN(cleanup, TESTFILE2, O_WRONLY | O_CREAT | O_TRUNC, 0777);
+	fd_in = SAFE_OPEN(TESTFILE1, O_RDONLY);
+	fd_out = SAFE_OPEN(TESTFILE2, O_WRONLY | O_CREAT | O_TRUNC, 0777);
 
-	SAFE_PIPE(cleanup, pipe1);
-	SAFE_PIPE(cleanup, pipe2);
+	SAFE_PIPE(pipe1);
+	SAFE_PIPE(pipe2);
 
 	ret = splice(fd_in, NULL, pipe1[1], NULL, TEST_BLOCK_SIZE, 0);
 	if (ret < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "splice(fd_in, pipe1) failed");
+		tst_brk(TBROK | TERRNO, "splice(fd_in, pipe1) failed");
 
 	ret = tee(pipe1[0], pipe2[1], TEST_BLOCK_SIZE, SPLICE_F_NONBLOCK);
 	if (ret < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "tee() failed");
+		tst_brk(TBROK | TERRNO, "tee() failed");
 
 	ret = splice(pipe2[0], NULL, fd_out, NULL, TEST_BLOCK_SIZE, 0);
 	if (ret < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "splice(pipe2, fd_out) failed");
+		tst_brk(TBROK | TERRNO, "splice(pipe2, fd_out) failed");
 
-	close(pipe2[0]);
-	close(pipe2[1]);
-	close(pipe1[0]);
-	close(pipe1[1]);
-	close(fd_out);
-	close(fd_in);
-
-	fd_out = 0;
-	fd_in = 0;
+	SAFE_CLOSE(pipe2[0]);
+	SAFE_CLOSE(pipe2[1]);
+	SAFE_CLOSE(pipe1[0]);
+	SAFE_CLOSE(pipe1[1]);
+	SAFE_CLOSE(fd_out);
+	SAFE_CLOSE(fd_in);
 
 	check_file();
 }
@@ -133,39 +104,33 @@
 {
 	int i;
 
-	if ((tst_kvercmp(2, 6, 17)) < 0) {
-		tst_brkm(TCONF, cleanup, "This test can only run on kernels "
-			"that are 2.6.17 or higher");
-	}
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC) {
+	if (tst_fs_type(".") == TST_NFS_MAGIC) {
 		if ((tst_kvercmp(2, 6, 32)) < 0)
-			tst_brkm(TCONF, cleanup, "Cannot do tee on a file"
+			tst_brk(TCONF, "Cannot do tee on a file"
 				" on NFS filesystem before 2.6.32");
 	}
 
 	for (i = 0; i < TEST_BLOCK_SIZE; i++)
 		buffer[i] = i & 0xff;
 
-	fd_in = SAFE_OPEN(cleanup, TESTFILE1, O_WRONLY | O_CREAT | O_TRUNC, 0777);
-	SAFE_WRITE(cleanup, 1, fd_in, buffer, TEST_BLOCK_SIZE);
-	SAFE_CLOSE(cleanup, fd_in);
-	fd_in = 0;
+	fd_in = SAFE_OPEN(TESTFILE1, O_WRONLY | O_CREAT | O_TRUNC, 0777);
+	SAFE_WRITE(1, fd_in, buffer, TEST_BLOCK_SIZE);
+	SAFE_CLOSE(fd_in);
 }
 
 static void cleanup(void)
 {
-	if (fd_in > 0 && close(fd_in))
-		tst_resm(TWARN, "Failed to close fd_in");
+	if (fd_in > 0)
+		SAFE_CLOSE(fd_in);
 
-	if (fd_out > 0 && close(fd_out))
-		tst_resm(TWARN, "Failed to close fd_out");
-
-	tst_rmdir();
+	if (fd_out > 0)
+		SAFE_CLOSE(fd_out);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = tee_test,
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.17",
+};
diff --git a/testcases/kernel/syscalls/tee/tee02.c b/testcases/kernel/syscalls/tee/tee02.c
index 2173cd2..d454f4a 100644
--- a/testcases/kernel/syscalls/tee/tee02.c
+++ b/testcases/kernel/syscalls/tee/tee02.c
@@ -32,8 +32,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/tee.h"
 
 #define TEST_FILE "testfile"
@@ -44,91 +43,63 @@
 static int fd;
 static int pipes[2];
 
-static struct test_case_t {
+static struct tcase {
 	int *fdin;
 	int *fdout;
 	int exp_errno;
-} test_cases[] = {
+} tcases[] = {
 	{ &fd, &pipes[1], EINVAL },
 	{ &pipes[0], &fd, EINVAL },
 	{ &pipes[0], &pipes[1], EINVAL },
 };
 
-static void setup(void);
-static void cleanup(void);
-static void tee_verify(const struct test_case_t *);
-
-char *TCID = "tee02";
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-int main(int ac, char **av)
-{
-	int i, lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++)
-			tee_verify(&test_cases[i]);
-	}
-
-	cleanup();
-	tst_exit();
-}
-
 static void setup(void)
 {
-	if ((tst_kvercmp(2, 6, 17)) < 0) {
-		tst_brkm(TCONF, cleanup, "This test can only run on kernels "
-			"that are 2.6.17 or higher");
-	}
-
-	TEST_PAUSE;
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	tst_tmpdir();
-
-	fd = SAFE_OPEN(cleanup, TEST_FILE, O_RDWR | O_CREAT);
-
-	SAFE_PIPE(cleanup, pipes);
-	SAFE_WRITE(cleanup, 1, pipes[1], STR, sizeof(STR) - 1);
+	fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT);
+	SAFE_PIPE(pipes);
+	SAFE_WRITE(1, pipes[1], STR, sizeof(STR) - 1);
 }
 
-static void tee_verify(const struct test_case_t *tc)
+static void tee_verify(unsigned int n)
 {
+	struct tcase *tc = &tcases[n];
+
 	TEST(tee(*(tc->fdin), *(tc->fdout), TEE_TEST_LEN, 0));
 
 	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "tee() returned %ld, "
+		tst_res(TFAIL, "tee() returned %ld, "
 			"expected -1, errno:%d", TEST_RETURN,
 			tc->exp_errno);
 		return;
 	}
 
-	if (TEST_ERRNO == tc->exp_errno) {
-		tst_resm(TPASS | TTERRNO, "tee() failed as expected");
-	} else {
-		tst_resm(TFAIL | TTERRNO,
+	if (TEST_ERRNO != tc->exp_errno) {
+		tst_res(TFAIL | TTERRNO,
 			"tee() failed unexpectedly; expected: %d - %s",
-			tc->exp_errno, strerror(tc->exp_errno));
+			tc->exp_errno, tst_strerrno(tc->exp_errno));
+		return;
 	}
+
+	tst_res(TPASS | TTERRNO, "tee() failed as expected");
 }
 
 static void cleanup(void)
 {
-	if (fd && close(fd) < 0)
-		tst_resm(TWARN | TERRNO, "close fd failed");
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 
-	if (pipes[0] && close(pipes[0]) < 0)
-		tst_resm(TWARN | TERRNO, "close pipes[0] failed");
+	if (pipes[0] > 0)
+		SAFE_CLOSE(pipes[0]);
 
-	if (pipes[1] && close(pipes[1]) < 0)
-		tst_resm(TWARN | TERRNO, "close pipes[1] failed");
-
-	tst_rmdir();
+	if (pipes[1] > 0)
+		SAFE_CLOSE(pipes[1]);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = tee_verify,
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.17",
+};
diff --git a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
index a017f9d..2bb38ea 100644
--- a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
+++ b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
@@ -27,7 +27,7 @@
 #include <sys/syscall.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "timer_getoverrun01";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
index 57d23fc..1c75f1c 100644
--- a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
+++ b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
@@ -27,7 +27,7 @@
 #include <errno.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "timer_gettime01";
 int TST_TOTAL = 3;
diff --git a/testcases/kernel/syscalls/timerfd/timerfd01.c b/testcases/kernel/syscalls/timerfd/timerfd01.c
index 4a3cf2f..868fbe2 100644
--- a/testcases/kernel/syscalls/timerfd/timerfd01.c
+++ b/testcases/kernel/syscalls/timerfd/timerfd01.c
@@ -43,7 +43,7 @@
 #include <time.h>
 #include <errno.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define cleanup tst_exit
 
diff --git a/testcases/kernel/syscalls/timerfd/timerfd02.c b/testcases/kernel/syscalls/timerfd/timerfd02.c
index 006ef16..c544406 100644
--- a/testcases/kernel/syscalls/timerfd/timerfd02.c
+++ b/testcases/kernel/syscalls/timerfd/timerfd02.c
@@ -63,7 +63,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TFD_CLOEXEC O_CLOEXEC
 
diff --git a/testcases/kernel/syscalls/timerfd/timerfd03.c b/testcases/kernel/syscalls/timerfd/timerfd03.c
index dc8efd4..e288251 100644
--- a/testcases/kernel/syscalls/timerfd/timerfd03.c
+++ b/testcases/kernel/syscalls/timerfd/timerfd03.c
@@ -59,7 +59,7 @@
 
 #include "test.h"
 #include "lapi/fcntl.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TFD_NONBLOCK O_NONBLOCK
 
diff --git a/testcases/kernel/syscalls/times/times03.c b/testcases/kernel/syscalls/times/times03.c
index 0db8215..78d72d2 100644
--- a/testcases/kernel/syscalls/times/times03.c
+++ b/testcases/kernel/syscalls/times/times03.c
@@ -207,7 +207,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "times03",
 	.setup = setup,
 	.forks_child = 1,
 	.test_all = do_test,
diff --git a/testcases/kernel/syscalls/tkill/tkill01.c b/testcases/kernel/syscalls/tkill/tkill01.c
index d4100dc..20c28f1 100644
--- a/testcases/kernel/syscalls/tkill/tkill01.c
+++ b/testcases/kernel/syscalls/tkill/tkill01.c
@@ -49,7 +49,7 @@
 #include <sys/types.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "tkill01";
 int testno;
diff --git a/testcases/kernel/syscalls/tkill/tkill02.c b/testcases/kernel/syscalls/tkill/tkill02.c
index cc0d4f5..4843175 100644
--- a/testcases/kernel/syscalls/tkill/tkill02.c
+++ b/testcases/kernel/syscalls/tkill/tkill02.c
@@ -33,7 +33,7 @@
 #include <sys/syscall.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "tkill02";
 int testno;
diff --git a/testcases/kernel/syscalls/umask/umask01.c b/testcases/kernel/syscalls/umask/umask01.c
index 8ee03df..ee80624 100644
--- a/testcases/kernel/syscalls/umask/umask01.c
+++ b/testcases/kernel/syscalls/umask/umask01.c
@@ -71,7 +71,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "umask01",
 	.test_all = verify_umask,
 	.needs_tmpdir = 1,
 };
diff --git a/testcases/kernel/syscalls/umount/umount01.c b/testcases/kernel/syscalls/umount/umount01.c
index 3b5aeb9..80a80c9 100644
--- a/testcases/kernel/syscalls/umount/umount01.c
+++ b/testcases/kernel/syscalls/umount/umount01.c
@@ -65,7 +65,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "umount01",
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.format_device = 1,
diff --git a/testcases/kernel/syscalls/umount/umount02.c b/testcases/kernel/syscalls/umount/umount02.c
index 690ba5f..5bcd17d 100644
--- a/testcases/kernel/syscalls/umount/umount02.c
+++ b/testcases/kernel/syscalls/umount/umount02.c
@@ -93,7 +93,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "umount02",
 	.tcnt = ARRAY_SIZE(tcases),
 	.needs_root = 1,
 	.needs_tmpdir = 1,
diff --git a/testcases/kernel/syscalls/umount/umount03.c b/testcases/kernel/syscalls/umount/umount03.c
index c1bcb05..abff0ce 100644
--- a/testcases/kernel/syscalls/umount/umount03.c
+++ b/testcases/kernel/syscalls/umount/umount03.c
@@ -70,7 +70,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "umount03",
 	.needs_root = 1,
 	.needs_tmpdir = 1,
 	.format_device = 1,
diff --git a/testcases/kernel/syscalls/unlinkat/unlinkat01.c b/testcases/kernel/syscalls/unlinkat/unlinkat01.c
index cfc9c4d..76566e8 100644
--- a/testcases/kernel/syscalls/unlinkat/unlinkat01.c
+++ b/testcases/kernel/syscalls/unlinkat/unlinkat01.c
@@ -35,7 +35,7 @@
 #include <signal.h>
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define TEST_CASES 7
 #ifndef AT_FDCWD
diff --git a/testcases/kernel/syscalls/utils/compat_16.h b/testcases/kernel/syscalls/utils/compat_16.h
index df045b2..f0bc326 100644
--- a/testcases/kernel/syscalls/utils/compat_16.h
+++ b/testcases/kernel/syscalls/utils/compat_16.h
@@ -32,7 +32,7 @@
 
 #include "compat_gid.h"
 #include "compat_uid.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
diff --git a/testcases/kernel/syscalls/utils/mq.h b/testcases/kernel/syscalls/utils/mq.h
new file mode 100644
index 0000000..0bdac97
--- /dev/null
+++ b/testcases/kernel/syscalls/utils/mq.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * 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 would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MQ_H
+#define MQ_H
+
+#include "tst_test.h"
+#include "tst_sig_proc.h"
+#include "tst_safe_posix_ipc.h"
+
+#define MAX_MSGSIZE	8192
+#define MSG_LENGTH	10
+#define QUEUE_NAME	"/test_mqueue"
+#define QUEUE_NAME_NONBLOCK	"/test_mqueue_nonblock"
+
+static char smsg[MAX_MSGSIZE];
+static struct sigaction act;
+
+static void cleanup_common(void)
+{
+	if (fd_root > 0)
+		SAFE_CLOSE(fd_root);
+
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+
+	if (fd_nonblock > 0)
+		SAFE_CLOSE(fd_nonblock);
+
+	mq_unlink(QUEUE_NAME);
+	mq_unlink(QUEUE_NAME_NONBLOCK);
+}
+
+static void sighandler(int sig LTP_ATTRIBUTE_UNUSED) { }
+
+static void setup_common(void)
+{
+	int i;
+
+	act.sa_handler = sighandler;
+	sigaction(SIGINT, &act, NULL);
+
+	cleanup_common();
+
+	fd_root = SAFE_OPEN("/", O_RDONLY);
+	fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, 0700, NULL);
+	fd_nonblock = SAFE_MQ_OPEN(QUEUE_NAME_NONBLOCK, O_CREAT | O_EXCL | O_RDWR |
+		O_NONBLOCK, 0700, NULL);
+
+	for (i = 0; i < MAX_MSGSIZE; i++)
+		smsg[i] = i;
+}
+
+static void cleanup_queue(mqd_t fd)
+{
+	int i;
+	struct mq_attr mqstat;
+	unsigned int prio;
+	char rmsg[MAX_MSGSIZE];
+
+	memset(&mqstat, 0, sizeof(mqstat));
+	if (mq_getattr(fd, &mqstat) == -1) {
+		tst_brk(TWARN, "mq_getattr() failed");
+		return;
+	}
+
+	for (i = 0; i < mqstat.mq_curmsgs; i++) {
+		tst_res(TINFO, "receive %d/%ld message", i + 1, mqstat.mq_curmsgs);
+		mq_receive(fd, rmsg, MAX_MSGSIZE, &prio);
+	}
+}
+
+#endif /* MQ_H */
diff --git a/testcases/kernel/syscalls/utils/mq_timed.h b/testcases/kernel/syscalls/utils/mq_timed.h
new file mode 100644
index 0000000..a163ddc
--- /dev/null
+++ b/testcases/kernel/syscalls/utils/mq_timed.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * 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 would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MQ_TIMED_H
+#define MQ_TIMED_H
+
+#include "mq.h"
+
+struct test_case {
+	int *fd;
+	unsigned int len;
+	unsigned int prio;
+	struct timespec *rq;
+	int invalid_msg;
+	int send;
+	int signal;
+	int timeout;
+	int ret;
+	int err;
+};
+
+static pid_t set_sig(struct timespec *ts)
+{
+	clock_gettime(CLOCK_REALTIME, ts);
+	ts->tv_sec += 3;
+
+	return create_sig_proc(SIGINT, 40, 200000);
+}
+
+static void set_timeout(struct timespec *ts)
+{
+	clock_gettime(CLOCK_REALTIME, ts);
+	ts->tv_nsec += 50000000;
+	ts->tv_sec += ts->tv_nsec / 1000000000;
+	ts->tv_nsec %= 1000000000;
+}
+
+static void send_msg(int fd, int len, int prio)
+{
+	if (mq_timedsend(fd, smsg, len, prio,
+		&((struct timespec){0})) < 0)
+		tst_brk(TBROK | TERRNO, "mq_timedsend failed");
+}
+
+static void kill_pid(pid_t pid)
+{
+	SAFE_KILL(pid, SIGTERM);
+	SAFE_WAIT(NULL);
+}
+
+#endif /* MQ_TIMED_H */
diff --git a/testcases/kernel/syscalls/utimensat/utimensat01.c b/testcases/kernel/syscalls/utimensat/utimensat01.c
index 3ff9483..264ca1e 100644
--- a/testcases/kernel/syscalls/utimensat/utimensat01.c
+++ b/testcases/kernel/syscalls/utimensat/utimensat01.c
@@ -40,7 +40,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "utimensat01";
 int TST_TOTAL = 0;
diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
index 3cc1707..46a0cc6 100755
--- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
+++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
@@ -32,7 +32,11 @@
 
 # Starting with 4.8.0 operations on immutable files return EPERM instead of
 # EACCES.
-if tst_kvcmp -lt "4.8.0"; then
+# This patch has also been merged to stable 4.4 with
+# b3b4283 ("vfs: move permission checking into notify_change() for utimes(NULL)")
+if tst_kvcmp -ge "4.4.27" -a -lt "4.5.0"; then
+	imaccess=EPERM
+elif tst_kvcmp -lt "4.4.27"; then
 	imaccess=EACCES
 else
 	imaccess=EPERM
@@ -47,7 +51,7 @@
 TEST_PROG=utimensat01
 
 if [ ! -f $LTPROOT/testcases/bin/$TEST_PROG ]; then
-	tst_brkm TWARN "$LTPROOT/testcases/bin/$TEST_PROG is missing (please check install)"
+	tst_brkm TBROK "$LTPROOT/testcases/bin/$TEST_PROG is missing (please check install)"
 fi
 
 # Summary counters of all test results
diff --git a/testcases/kernel/syscalls/utimes/utimes01.c b/testcases/kernel/syscalls/utimes/utimes01.c
index 6cade0e..b2450d2 100644
--- a/testcases/kernel/syscalls/utimes/utimes01.c
+++ b/testcases/kernel/syscalls/utimes/utimes01.c
@@ -50,7 +50,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #define MNTPOINT "mntpoint"
 #define TESTFILE1 "testfile1"
diff --git a/testcases/kernel/syscalls/vmsplice/vmsplice01.c b/testcases/kernel/syscalls/vmsplice/vmsplice01.c
index 1519efc..882e198 100644
--- a/testcases/kernel/syscalls/vmsplice/vmsplice01.c
+++ b/testcases/kernel/syscalls/vmsplice/vmsplice01.c
@@ -33,49 +33,25 @@
 #include <fcntl.h>
 #include <sys/poll.h>
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/fcntl.h"
 #include "lapi/splice.h"
 #include "lapi/vmsplice.h"
 
 #define TEST_BLOCK_SIZE (1<<17)	/* 128K */
 
-static void vmsplice_test(void);
-static void setup(void);
-static void cleanup(void);
-
 #define TESTFILE "vmsplice_test_file"
 
 static int fd_out;
 static char buffer[TEST_BLOCK_SIZE];
 
-char *TCID = "vmsplice01";
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
-{
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		vmsplice_test();
-
-	cleanup();
-	tst_exit();
-}
-
 static void check_file(void)
 {
 	int i;
 	char vmsplicebuffer[TEST_BLOCK_SIZE];
 
-	fd_out = SAFE_OPEN(cleanup, TESTFILE, O_RDONLY);
-	SAFE_READ(cleanup, 1, fd_out, vmsplicebuffer, TEST_BLOCK_SIZE);
+	fd_out = SAFE_OPEN(TESTFILE, O_RDONLY);
+	SAFE_READ(1, fd_out, vmsplicebuffer, TEST_BLOCK_SIZE);
 
 	for (i = 0; i < TEST_BLOCK_SIZE; i++) {
 		if (buffer[i] != vmsplicebuffer[i])
@@ -83,12 +59,11 @@
 	}
 
 	if (i < TEST_BLOCK_SIZE)
-		tst_resm(TFAIL, "Wrong data read from the buffer at %i", i);
+		tst_res(TFAIL, "Wrong data read from the buffer at %i", i);
 	else
-		tst_resm(TPASS, "Written data has been read back correctly");
+		tst_res(TPASS, "Written data has been read back correctly");
 
-	close(fd_out);
-	fd_out = 0;
+	SAFE_CLOSE(fd_out);
 }
 
 static void vmsplice_test(void)
@@ -103,8 +78,8 @@
 	v.iov_base = buffer;
 	v.iov_len = TEST_BLOCK_SIZE;
 
-	SAFE_PIPE(cleanup, pipes);
-	fd_out = SAFE_OPEN(cleanup, TESTFILE, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+	fd_out = SAFE_OPEN(TESTFILE, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+	SAFE_PIPE(pipes);
 
 	struct pollfd pfd = {.fd = pipes[1], .events = POLLOUT};
 	offset = 0;
@@ -116,11 +91,11 @@
 		 * not using the free time for anything interesting.
 		 */
 		if (poll(&pfd, 1, -1) < 0)
-			tst_brkm(TBROK | TERRNO, cleanup, "poll() failed");
+			tst_brk(TBROK | TERRNO, "poll() failed");
 
 		written = vmsplice(pipes[1], &v, 1, 0);
 		if (written < 0) {
-			tst_brkm(TBROK | TERRNO, cleanup, "vmsplice() failed");
+			tst_brk(TBROK | TERRNO, "vmsplice() failed");
 		} else {
 			if (written == 0) {
 				break;
@@ -132,14 +107,13 @@
 
 		ret = splice(pipes[0], NULL, fd_out, &offset, written, 0);
 		if (ret < 0)
-			tst_brkm(TBROK | TERRNO, cleanup, "splice() failed");
+			tst_brk(TBROK | TERRNO, "splice() failed");
 		//printf("offset = %lld\n", (long long)offset);
 	}
 
-	close(pipes[0]);
-	close(pipes[1]);
-	close(fd_out);
-	fd_out = 0;
+	SAFE_CLOSE(pipes[0]);
+	SAFE_CLOSE(pipes[1]);
+	SAFE_CLOSE(fd_out);
 
 	check_file();
 }
@@ -148,30 +122,25 @@
 {
 	int i;
 
-	if ((tst_kvercmp(2, 6, 17)) < 0) {
-		tst_brkm(TCONF, NULL,
-		         "The vmsplice is supported 2.6.17 and newer");
-	}
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	tst_tmpdir();
-
-	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC) {
-		tst_brkm(TCONF, cleanup, "Cannot do splice() "
+	if (tst_fs_type(".") == TST_NFS_MAGIC) {
+		tst_brk(TCONF, "Cannot do splice() "
 			 "on a file located on an NFS filesystem");
 	}
 
 	for (i = 0; i < TEST_BLOCK_SIZE; i++)
 		buffer[i] = i & 0xff;
-
-	TEST_PAUSE;
 }
 
 static void cleanup(void)
 {
-	if (fd_out > 0 && close(fd_out))
-		tst_resm(TWARN, "Failed to close fd_out");
-
-	tst_rmdir();
+	if (fd_out > 0)
+		SAFE_CLOSE(fd_out);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = vmsplice_test,
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.17",
+};
diff --git a/testcases/kernel/syscalls/vmsplice/vmsplice02.c b/testcases/kernel/syscalls/vmsplice/vmsplice02.c
index 1f0dea5..a5ebea0 100644
--- a/testcases/kernel/syscalls/vmsplice/vmsplice02.c
+++ b/testcases/kernel/syscalls/vmsplice/vmsplice02.c
@@ -33,10 +33,10 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/uio.h>
+#include <limits.h>
 
-#include "test.h"
-#include "safe_macros.h"
-#include "linux_syscall_numbers.h"
+#include "tst_test.h"
+#include "lapi/syscalls.h"
 #include "lapi/fcntl.h"
 #include "lapi/vmsplice.h"
 
@@ -52,100 +52,72 @@
 static int pipes[2];
 static struct iovec ivc;
 
-static struct test_case_t {
+static struct tcase {
 	int *fd;
 	const struct iovec *iov;
 	unsigned long nr_segs;
 	int exp_errno;
-} test_cases[] = {
+} tcases[] = {
 	{ &notvalidfd, &ivc, 1, EBADF },
 	{ &filefd, &ivc, 1, EBADF },
 	{ &pipes[1], &ivc, IOV_MAX + 1, EINVAL },
 };
 
-static void setup(void);
-static void cleanup(void);
-static void vmsplice_verify(const struct test_case_t *);
-
-char *TCID = "vmsplice02";
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-int main(int ac, char **av)
-{
-	int i, lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++)
-			vmsplice_verify(&test_cases[i]);
-	}
-
-	cleanup();
-	tst_exit();
-}
-
 static void setup(void)
 {
-	if ((tst_kvercmp(2, 6, 17)) < 0) {
-		tst_brkm(TCONF, cleanup, "This test can only run on "
-			"kernels that are 2.6.17 or higher");
-	}
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	if (tst_fs_type(cleanup, ".") == TST_NFS_MAGIC) {
-		tst_brkm(TCONF, cleanup, "Cannot do splice() "
+	if (tst_fs_type(".") == TST_NFS_MAGIC) {
+		tst_brk(TCONF, "Cannot do splice() "
 			"on a file located on an NFS filesystem");
 	}
 
-	filefd = SAFE_OPEN(cleanup, TESTFILE,
-				O_WRONLY | O_CREAT, 0644);
+	filefd = SAFE_OPEN(TESTFILE, O_WRONLY | O_CREAT, 0644);
 
-	SAFE_PIPE(cleanup, pipes);
+	SAFE_PIPE(pipes);
 
 	ivc.iov_base = buffer;
 	ivc.iov_len = TEST_BLOCK_SIZE;
 }
 
-static void vmsplice_verify(const struct test_case_t *tc)
+static void vmsplice_verify(unsigned int n)
 {
+	struct tcase *tc = &tcases[n];
+
 	TEST(vmsplice(*(tc->fd), tc->iov, tc->nr_segs, 0));
 
 	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "vmsplice() returned %ld, "
+		tst_res(TFAIL, "vmsplice() returned %ld, "
 			"expected -1, errno:%d", TEST_RETURN,
 			tc->exp_errno);
 		return;
 	}
 
-	if (TEST_ERRNO == tc->exp_errno) {
-		tst_resm(TPASS | TTERRNO, "vmsplice() failed as expected");
-	} else {
-		tst_resm(TFAIL | TTERRNO,
+	if (TEST_ERRNO != tc->exp_errno) {
+		tst_res(TFAIL | TTERRNO,
 			"vmsplice() failed unexpectedly; expected: %d - %s",
-			tc->exp_errno, strerror(tc->exp_errno));
+			tc->exp_errno, tst_strerrno(tc->exp_errno));
+		return;
 	}
+
+	tst_res(TPASS | TTERRNO, "vmsplice() failed as expected");
 }
 
 static void cleanup(void)
 {
-	if (filefd && close(filefd) < 0)
-		tst_resm(TWARN | TERRNO, "close filefd failed");
+	if (filefd > 0)
+		SAFE_CLOSE(filefd);
 
-	if (pipes[0] && close(pipes[0]) < 0)
-		tst_resm(TWARN | TERRNO, "close pipes[0] failed");
+	if (pipes[0] > 0)
+		SAFE_CLOSE(pipes[0]);
 
-	if (pipes[1] && close(pipes[1]) < 0)
-		tst_resm(TWARN | TERRNO, "close pipes[1] failed");
-
-	tst_rmdir();
+	if (pipes[1] > 0)
+		SAFE_CLOSE(pipes[1]);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = vmsplice_verify,
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+	.min_kver = "2.6.17",
+};
diff --git a/testcases/kernel/syscalls/waitid/waitid02.c b/testcases/kernel/syscalls/waitid/waitid02.c
index db7e883..431e910 100644
--- a/testcases/kernel/syscalls/waitid/waitid02.c
+++ b/testcases/kernel/syscalls/waitid/waitid02.c
@@ -48,7 +48,7 @@
 #include <sys/stat.h>
 
 #include "test.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 struct testcase_t {
 	const char *msg;
diff --git a/testcases/kernel/syscalls/waitpid/waitpid06.c b/testcases/kernel/syscalls/waitpid/waitpid06.c
index 20c30e1..3b8c5e5 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid06.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid06.c
@@ -55,7 +55,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid06",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = waitpid_setup,
diff --git a/testcases/kernel/syscalls/waitpid/waitpid07.c b/testcases/kernel/syscalls/waitpid/waitpid07.c
index 9166fbe..d9056ea 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid07.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid07.c
@@ -60,7 +60,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid07",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = waitpid_setup,
diff --git a/testcases/kernel/syscalls/waitpid/waitpid08.c b/testcases/kernel/syscalls/waitpid/waitpid08.c
index f6efb9d..9e9f12c 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid08.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid08.c
@@ -63,7 +63,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid08",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = waitpid_setup,
diff --git a/testcases/kernel/syscalls/waitpid/waitpid09.c b/testcases/kernel/syscalls/waitpid/waitpid09.c
index 43beeff..7811937 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid09.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid09.c
@@ -170,7 +170,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid09",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.test = waitpid09_test,
diff --git a/testcases/kernel/syscalls/waitpid/waitpid10.c b/testcases/kernel/syscalls/waitpid/waitpid10.c
index 90b3800..8b324f7 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid10.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid10.c
@@ -112,7 +112,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid10",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = waitpid_setup,
diff --git a/testcases/kernel/syscalls/waitpid/waitpid11.c b/testcases/kernel/syscalls/waitpid/waitpid11.c
index 41186fb..72a6a32 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid11.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid11.c
@@ -61,7 +61,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid11",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = waitpid_setup,
diff --git a/testcases/kernel/syscalls/waitpid/waitpid12.c b/testcases/kernel/syscalls/waitpid/waitpid12.c
index b2db49d..2339c09 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid12.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid12.c
@@ -71,7 +71,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid12",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = waitpid_setup,
diff --git a/testcases/kernel/syscalls/waitpid/waitpid13.c b/testcases/kernel/syscalls/waitpid/waitpid13.c
index 79a99eb..13d8f2e 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid13.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid13.c
@@ -71,7 +71,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "waitpid13",
 	.forks_child = 1,
 	.needs_checkpoints = 1,
 	.setup = waitpid_setup,
diff --git a/testcases/kernel/syscalls/write/write01.c b/testcases/kernel/syscalls/write/write01.c
index b53f907..c6c8fa8 100644
--- a/testcases/kernel/syscalls/write/write01.c
+++ b/testcases/kernel/syscalls/write/write01.c
@@ -20,17 +20,10 @@
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
  */
 
+#include <stdio.h>
+#include <string.h>
 #include <errno.h>
 #include "tst_test.h"
 
@@ -38,17 +31,36 @@
 
 static void verify_write(void)
 {
-	TEST(write(fd, "w", 1));
+	int i, badcount = 0;
+	char buf[BUFSIZ];
 
-	if (TEST_RETURN == -1)
-		tst_res(TFAIL | TTERRNO, "write(2) failed");
+	memset(buf, 'w', BUFSIZ);
+
+	SAFE_LSEEK(fd, 0, SEEK_SET);
+
+	for (i = BUFSIZ; i > 0; i--) {
+		TEST(write(fd, buf, i));
+		if (TEST_RETURN == -1) {
+			tst_res(TFAIL | TTERRNO, "write failed");
+			return;
+		}
+
+		if (TEST_RETURN != i) {
+			badcount++;
+			tst_res(TINFO, "write() returned %ld, expected %d",
+				TEST_RETURN, i);
+		}
+	}
+
+	if (badcount != 0)
+		tst_res(TFAIL, "write() failed to return proper count");
 	else
-		tst_res(TPASS, "write(2) returned %ld", TEST_RETURN);
+		tst_res(TPASS, "write() passed");
 }
 
 static void setup(void)
 {
-	fd = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0700);
+	fd = SAFE_OPEN("test_file", O_RDWR | O_CREAT, 0700);
 }
 
 static void cleanup(void)
@@ -58,9 +70,8 @@
 }
 
 static struct tst_test test = {
-	.tid = "write01",
-	.test_all = verify_write,
 	.setup = setup,
 	.cleanup = cleanup,
+	.test_all = verify_write,
 	.needs_tmpdir = 1,
 };
diff --git a/testcases/kernel/syscalls/write/write02.c b/testcases/kernel/syscalls/write/write02.c
deleted file mode 100644
index 4924422..0000000
--- a/testcases/kernel/syscalls/write/write02.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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
- */
-
-/*
- * NAME
- *	write02.c
- *
- * DESCRIPTION
- *	Basic functionality test: does the return from write match the count
- *	of the number of bytes written.
- *
- *
- * ALGORITHM
- *	Create a file and write some bytes out to it.
- *	Check the return count against the number returned.
- *
- * USAGE:  <for command-line>
- *      write02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *      where,  -c n : Run n copies concurrently.
- *              -e   : Turn on errno logging.
- *              -i n : Execute test n times.
- *              -I x : Execute test for x seconds.
- *              -P x : Pause for x seconds between iterations.
- *              -t   : Turn on syscall timing.
- *
- * History
- *	07/2001 John George
- *		-Ported
- *
- * Restrictions
- *	None
- */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-#include "test.h"
-
-char *TCID = "write02";
-int TST_TOTAL = 1;
-
-void cleanup(void);
-void setup(void);
-
-char pfiln[40] = "";
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	int cwrite;
-	int fild;
-	int iws;
-	int badcount = 0;
-	char pwbuf[BUFSIZ + 1];
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();		/* global setup for test */
-
-	/* The following loop checks looping state if -i option given */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-//block1:
-		tst_resm(TINFO, "Block 1: test to see write() returns proper "
-			 "write count");
-
-		for (iws = 0; iws < BUFSIZ; iws++) {
-			pwbuf[iws] = 'A' + (iws % 26);
-		}
-		pwbuf[BUFSIZ] = '\n';
-
-		if ((fild = creat(pfiln, 0777)) == -1) {
-			tst_brkm(TBROK, cleanup, "Can't creat Xwrit");
-		}
-		for (iws = BUFSIZ; iws > 0; iws--) {
-			if ((cwrite = write(fild, pwbuf, iws)) != iws) {
-				badcount++;
-				tst_resm(TINFO, "bad write count");
-			}
-		}
-		if (badcount != 0) {
-			tst_resm(TFAIL, "write() FAILED to return proper cnt");
-		} else {
-			tst_resm(TPASS, "write() PASSED");
-		}
-		tst_resm(TINFO, "block 1 passed");
-		close(fild);
-	}
-	cleanup();
-	tst_exit();
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test
- */
-void setup(void)
-{
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	umask(0);
-
-	/* Pause if that option was specified
-	 * TEST_PAUSE contains the code to fork the test with the -i option.
-	 * You want to make sure you do this before you create your temporary
-	 * directory.
-	 */
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	sprintf(pfiln, "write1.%d", getpid());
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at completion or
- * premature exit.
- */
-void cleanup(void)
-{
-
-	unlink(pfiln);
-
-	tst_rmdir();
-}
diff --git a/testcases/kernel/syscalls/write/write03.c b/testcases/kernel/syscalls/write/write03.c
index 63ef35a..7e3ec98 100644
--- a/testcases/kernel/syscalls/write/write03.c
+++ b/testcases/kernel/syscalls/write/write03.c
@@ -1,6 +1,8 @@
 /*
- *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *	07/2001 Ported by John George
+ *   Copyright (c) 2017 Fujitsu Ltd.
+ *	04/2017 Modified by Jinhui Huang
  *
  *   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
@@ -18,9 +20,6 @@
  */
 
 /*
- * NAME
- *	write03.c
- *
  * DESCRIPTION
  *	Testcase to check that write(2) doesn't corrupt a file when it fails
  *
@@ -29,154 +28,61 @@
  *	fail with some erroneous parameter, close the fd. Then reopen the
  *	file in RDONLY mode, and read the contents of the file. Compare the
  *	buffers, to see whether they are same.
- *
- * USAGE:  <for command-line>
- *      write03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *      where,  -c n : Run n copies concurrently.
- *              -e   : Turn on errno logging.
- *              -i n : Execute test n times.
- *              -I x : Execute test for x seconds.
- *              -P x : Pause for x seconds between iterations.
- *              -t   : Turn on syscall timing.
- *
- * History
- *	07/2001 John George
- *		-Ported
- *
- * Restrictions
- *	NONE
  */
 
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
+#include <stdio.h>
 #include <errno.h>
-#include "test.h"
-#include <sys/mman.h>
+#include "tst_test.h"
 
-char *TCID = "write03";
-int TST_TOTAL = 1;
+static char *bad_addr;
+static char wbuf[BUFSIZ], rbuf[BUFSIZ];
+static int fd;
 
-char *bad_addr = 0;
-
-void setup(void);
-void cleanup(void);
-
-char filename[100];
-
-#if !defined(UCLINUX)
-
-int main(int argc, char **argv)
+static void verify_write(void)
 {
-	int lc;
+	fd = SAFE_CREAT("testfile", 0644);
 
-	char wbuf[BUFSIZ], rbuf[BUFSIZ];
-	int fd;
+	SAFE_WRITE(1, fd, wbuf, 100);
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	/* global setup */
-	setup();
-
-	/* The following loop checks looping state if -i option given */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-//block1:
-		tst_resm(TINFO, "Enter Block 1: test to check if write "
-			 "corrupts the file when write fails");
-
-		fd = creat(filename, 0644);
-		if (fd < 0) {
-			tst_resm(TBROK, "creating a new file failed");
-			cleanup();
-		}
-
-		(void)memset(wbuf, '0', 100);
-
-		if (write(fd, wbuf, 100) == -1) {
-			tst_resm(TFAIL, "failed to write to %s", filename);
-			cleanup();
-		}
-
-		if (write(fd, bad_addr, 100) != -1) {
-			tst_resm(TFAIL, "write(2) failed to fail");
-			cleanup();
-		}
-		close(fd);
-
-		if ((fd = open(filename, O_RDONLY)) == -1) {
-			tst_resm(TBROK, "open(2) failed, errno: %d", errno);
-			cleanup();
-		}
-
-		if (read(fd, rbuf, 100) == -1) {
-			tst_resm(TBROK, "read(2) failed, errno: %d", errno);
-			cleanup();
-		}
-
-		if (memcmp(wbuf, rbuf, 100) == 0) {
-			tst_resm(TPASS, "failure of write(2) didnot corrupt "
-				 "the file");
-		} else {
-			tst_resm(TFAIL, "failure of write(2) corrupted the "
-				 "file");
-		}
-		tst_resm(TINFO, "Exit block 1");
-		close(fd);
-	}
-	cleanup();
-	tst_exit();
-}
-
-#else
-
-int main(void)
-{
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
-}
-
-#endif /* if !defined(UCLINUX) */
-
-/*
- * setup() - performs all ONE TIME setup for this test
- */
-void setup(void)
-{
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	/* Pause if that option was specified
-	 * TEST_PAUSE contains the code to fork the test with the -i option.
-	 * You want to make sure you do this before you create your temporary
-	 * directory.
-	 */
-	TEST_PAUSE;
-
-	/* Create a unique temporary directory and chdir() to it. */
-	tst_tmpdir();
-
-	sprintf(filename, "./write03.%d", getpid());
-
-	bad_addr = mmap(0, 1, PROT_NONE,
-			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
-	if (bad_addr == MAP_FAILED) {
-		printf("mmap failed\n");
+	if (write(fd, bad_addr, 100) != -1) {
+		tst_res(TFAIL, "write() failed to fail");
+		SAFE_CLOSE(fd);
+		return;
 	}
 
+	SAFE_CLOSE(fd);
+
+	fd = SAFE_OPEN("testfile", O_RDONLY);
+
+	memset(rbuf, 0, BUFSIZ);
+
+	SAFE_READ(0, fd, rbuf, 100);
+
+	if (memcmp(wbuf, rbuf, 100) == 0)
+		tst_res(TPASS, "failure of write() did not corrupt the file");
+	else
+		tst_res(TFAIL, "failure of write() corrupted the file");
+
+	SAFE_CLOSE(fd);
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit
- */
-void cleanup(void)
+static void setup(void)
 {
+	bad_addr = SAFE_MMAP(0, 1, PROT_NONE,
+			MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
 
-	unlink(filename);
-	tst_rmdir();
-
+	memset(wbuf, '0', 100);
 }
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = verify_write,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/writev/writev01.c b/testcases/kernel/syscalls/writev/writev01.c
index b02abba..7753db4 100644
--- a/testcases/kernel/syscalls/writev/writev01.c
+++ b/testcases/kernel/syscalls/writev/writev01.c
@@ -145,7 +145,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "writev01",
 	.needs_tmpdir = 1,
 	.setup = setup,
 	.test = test_writev,
diff --git a/testcases/kernel/syscalls/writev/writev07.c b/testcases/kernel/syscalls/writev/writev07.c
index 20a5590..7322189 100644
--- a/testcases/kernel/syscalls/writev/writev07.c
+++ b/testcases/kernel/syscalls/writev/writev07.c
@@ -144,7 +144,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "writev07",
 	.needs_tmpdir = 1,
 	.setup = setup,
 	.test_all = test_writev,
diff --git a/testcases/kernel/timers/include/common_timers.h b/testcases/kernel/timers/include/common_timers.h
index 30d2dca..313cd41 100644
--- a/testcases/kernel/timers/include/common_timers.h
+++ b/testcases/kernel/timers/include/common_timers.h
@@ -9,7 +9,7 @@
 
 #define CLEANUP cleanup
 #include "config.h"
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #ifndef NSEC_PER_SEC
 #define NSEC_PER_SEC (1000000000L)
@@ -59,7 +59,7 @@
 	}
 }
 
-#include "linux_syscall_numbers.h"
+#include "lapi/syscalls.h"
 
 #include <time.h>
 #include <unistd.h>
diff --git a/testcases/kernel/tracing/dynamic_debug/Makefile b/testcases/kernel/tracing/dynamic_debug/Makefile
new file mode 100644
index 0000000..d38138e
--- /dev/null
+++ b/testcases/kernel/tracing/dynamic_debug/Makefile
@@ -0,0 +1,27 @@
+#
+#    tracing/dynamic_debug test suite Makefile.
+#
+#    Copyright (C) 2017 Red Hat, Inc.
+#
+#    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, see <http://www.gnu.org/licenses/>.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
diff --git a/testcases/kernel/tracing/dynamic_debug/dynamic_debug01.sh b/testcases/kernel/tracing/dynamic_debug/dynamic_debug01.sh
new file mode 100755
index 0000000..ec58c69
--- /dev/null
+++ b/testcases/kernel/tracing/dynamic_debug/dynamic_debug01.sh
@@ -0,0 +1,171 @@
+#!/bin/sh
+
+# Copyright (C) 2017 Red Hat, Inc.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+#
+#
+# Test description: Test functionality of dynamic debug feature by enabling
+#                   and disabling traces with available flags. Check that these
+#                   settings don't cause issues by searching dmesg.
+#
+#                   This test handles changes of dynamic debug interface from
+#                   commits 5ca7d2a6 (dynamic_debug: describe_flags with
+#                   '=[pmflt_]*') and 8ba6ebf5 (Dynamic debug: Add more flags)
+#
+# Usage
+# ./dynamic_debug01.sh
+
+TST_TESTFUNC=ddebug_test
+TST_NEEDS_CMDS="awk /bin/echo"
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_ROOT=1
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+
+. tst_test.sh
+
+
+DEBUGFS_WAS_MOUNTED=0
+DEBUGFS_PATH=""
+DEBUGFS_CONTROL=""
+DYNDEBUG_STATEMENTS="./debug_statements"
+EMPTY_FLAG="-"
+NEW_INTERFACE=0
+
+
+mount_debugfs()
+{
+	if grep -q debugfs /proc/mounts ; then
+		DEBUGFS_WAS_MOUNTED=1
+		DEBUGFS_PATH=$(awk '/debugfs/{print $2}' /proc/mounts)
+		tst_res TINFO "debugfs already mounted at $DEBUGFS_PATH"
+	else
+		if ! grep -q debugfs /proc/filesystems ; then
+			tst_res TCONF "debugfs not supported"
+		fi
+		DEBUGFS_PATH="./tst_debug"
+		mkdir "$DEBUGFS_PATH"
+		if mount -t debugfs xxx "$DEBUGFS_PATH" ; then
+			tst_res TINFO "debugfs mounted at $DEBUGFS_PATH"
+		else
+			tst_res TFAIL "Unable to mount debugfs"
+		fi
+	fi
+}
+
+setup()
+{
+	if tst_kvcmp -lt 2.6.30 ; then
+		tst_brk TCONF "Dynamic debug is available since version 2.6.30"
+	fi
+
+	mount_debugfs
+	if [ ! -d "$DEBUGFS_PATH/dynamic_debug" ] ; then
+		tst_brk TBROK "Unable to find $DEBUGFS_PATH/dynamic_debug"
+	fi
+	DEBUGFS_CONTROL="$DEBUGFS_PATH/dynamic_debug/control"
+	if [ ! -e "$DEBUGFS_CONTROL" ] ; then
+		tst_brk TBROK "Unable to find $DEBUGFS_CONTROL"
+	fi
+
+	# Both patches with changes were backported to RHEL6 kernel 2.6.32-547
+	if tst_kvcmp -ge '3.4 RHEL6:2.6.32-547' ; then
+		NEW_INTERFACE=1
+		EMPTY_FLAG="=_"
+	fi
+
+	grep -v "^#" "$DEBUGFS_CONTROL" > "$DYNDEBUG_STATEMENTS"
+}
+
+do_flag()
+{
+	local FLAG="$1"
+	local OPTION_TO_SET="$2"
+	local OPTION_VALUE="$3"
+
+	if ! echo "$OPTION_TO_SET $OPTION_VALUE $FLAG" > \
+		"$DEBUGFS_CONTROL" ; then
+		tst_res TFAIL "Setting '$OPTION_TO_SET $OPTION_VALUE " \
+			"$FLAG' failed with $?!"
+	fi
+}
+
+do_all_flags()
+{
+	OPTION="$1"
+	ALL_INPUTS="$2"
+
+	for INPUT_LINE in $ALL_INPUTS; do
+		do_flag "+p" "$OPTION" "$INPUT_LINE"
+		if tst_kvcmp -ge 3.2 || [ $NEW_INTERFACE -eq 1 ] ; then
+			do_flag "+flmt" "$OPTION" "$INPUT_LINE"
+			do_flag "-flmt" "$OPTION" "$INPUT_LINE"
+		fi
+		do_flag "-p" "$OPTION" "$INPUT_LINE"
+	done
+
+	if awk -v emp="$EMPTY_FLAG" '$3 != emp' "$DEBUGFS_CONTROL" \
+		| grep -v -q "^#" ; then
+		tst_res TFAIL "Failed to remove all set flags"
+	fi
+}
+
+ddebug_test()
+{
+	dmesg > ./dmesg.old
+
+	DD_FUNCS=$(awk -F " |]" '{print $3}' "$DYNDEBUG_STATEMENTS" \
+		| sort | uniq)
+	DD_FILES=$(awk -F " |:" '{print $1}' "$DYNDEBUG_STATEMENTS" \
+		| sort | uniq)
+	DD_LINES=$(awk -F " |:" '{print $2}' "$DYNDEBUG_STATEMENTS" \
+		| sort | uniq)
+	DD_MODULES=$(awk -F [][] '{print $2}' "$DYNDEBUG_STATEMENTS" \
+		| sort | uniq)
+
+	do_all_flags "func" "$DD_FUNCS"
+	do_all_flags "file" "$DD_FILES"
+	do_all_flags "line" "$DD_LINES"
+	do_all_flags "module" "$DD_MODULES"
+
+	dmesg > ./dmesg.new
+	sed -i -e 1,`wc -l < ./dmesg.old`d ./dmesg.new
+	if grep -q -e "Kernel panic" -e "Oops" -e "general protection fault" \
+		-e "general protection handler: wrong gs" -e "\(XEN\) Panic" \
+		-e "fault" -e "warn" -e "BUG" ./dmesg.new ; then
+		tst_res TFAIL "Issues found in dmesg!"
+	else
+		tst_res TPASS "Dynamic debug OK"
+	fi
+}
+
+cleanup()
+{
+	FLAGS_SET=$(awk -v emp="$EMPTY_FLAG" '$3 != emp' $DYNDEBUG_STATEMENTS)
+	if [ "$FLAGS_SET" ] ; then
+		FLAG_PREFIX=$([ $NEW_INTERFACE -eq 1 ] && echo "" || echo "+")
+		/bin/echo "$FLAGS_SET" | while read -r FLAG_LINE ; do
+			/bin/echo -n "$FLAG_LINE" \
+				| awk -v prf="$FLAG_PREFIX" -F " |:" \
+				'{print "file "$1" line "$2" "prf $4}' \
+				> "$DEBUGFS_CONTROL"
+		done
+	fi
+	if [ $DEBUGFS_WAS_MOUNTED -eq 0 ] ; then
+		tst_umount "$DEBUGFS_PATH"
+	fi
+}
+
+tst_run
diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index 920817c..f36ed99 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -1,6 +1,9 @@
-tst_sleep
-tst_random
-tst_checkpoint
-tst_rod
-tst_kvcmp
-tst_device
+/tst_sleep
+/tst_random
+/tst_checkpoint
+/tst_rod
+/tst_kvcmp
+/tst_device
+/tst_net_iface_prefix
+/tst_net_ip_prefix
+/tst_net_vars
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index 1127a59..398150a 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -27,6 +27,6 @@
 INSTALL_TARGETS		:= *.sh
 
 MAKE_TARGETS		:= tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
-			   tst_device
+			   tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index 2e4d868..d16444e 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -103,11 +103,11 @@
 
 tst_exit()
 {
-	if [ -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
+	if [ -n "${TST_CLEANUP:-}" -a -z "${TST_NO_CLEANUP:-}" ]; then
 		$TST_CLEANUP
 	fi
 
-	if [ -n "$LTP_IPC_PATH" -a -f "$LTP_IPC_PATH" ]; then
+	if [ -n "${LTP_IPC_PATH:-}" -a -f "${LTP_IPC_PATH:-}" ]; then
 		rm -f "$LTP_IPC_PATH"
 	fi
 
@@ -132,8 +132,10 @@
 
 tst_rmdir()
 {
-	cd "$LTPROOT"
-	rm -r "$TST_TMPDIR"
+	if [ -n "$TST_TMPDIR" ]; then
+		cd "$LTPROOT"
+		rm -r "$TST_TMPDIR"
+	fi
 }
 
 #
diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 0849355..a1d68ce 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2014-2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) 2016-2017 Petr Vorel <pvorel@suse.cz>
 #
 # This program is free software; you can redistribute it and/or
@@ -23,18 +23,26 @@
 
 init_ltp_netspace()
 {
+	local pid=
+
 	if [ ! -f /var/run/netns/ltp_ns ]; then
-		ROD ip net add ltp_ns
 		ROD ip li add name ltp_ns_veth1 type veth peer name ltp_ns_veth2
-		ROD ip li set dev ltp_ns_veth1 netns ltp_ns
-		ROD ip netns exec ltp_ns ip li set lo up
+		pid="$(ROD ns_create net,mnt)"
+		mkdir -p /var/run/netns
+		ROD ln -s /proc/$pid/ns/net /var/run/netns/ltp_ns
+		ROD ns_exec $pid net,mnt mount --make-rprivate /sys
+		ROD ns_exec $pid net,mnt mount -t sysfs none /sys
+		ROD ns_ifmove ltp_ns_veth1 $pid
+		ROD ns_exec $pid net,mnt ip li set lo up
 	fi
 
 	LHOST_IFACES="${LHOST_IFACES:-ltp_ns_veth2}"
 	RHOST_IFACES="${RHOST_IFACES:-ltp_ns_veth1}"
 
 	export TST_INIT_NETNS="no"
-	export LTP_NETNS="${LTP_NETNS:-ip netns exec ltp_ns}"
+
+	pid="$(echo $(readlink /var/run/netns/ltp_ns) | cut -f3 -d'/')"
+	export LTP_NETNS="${LTP_NETNS:-ns_exec $pid net,mnt}"
 
 	tst_restore_ipaddr
 	tst_restore_ipaddr rhost
@@ -83,7 +91,7 @@
 
 	local output=
 	local ret=0
-	if [ -n "$TST_USE_SSH" ]; then
+	if [ -n "${TST_USE_SSH:-}" ]; then
 		output=`ssh -n -q $user@$RHOST "sh -c \
 			'$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'`
 	elif [ -n "$TST_USE_NETNS" ]; then
@@ -105,6 +113,26 @@
 	return $ret
 }
 
+EXPECT_RHOST_PASS()
+{
+	tst_rhost_run -c "$*" > /dev/null
+	if [ $? -eq 0 ]; then
+		tst_resm TPASS "$* passed as expected"
+	else
+		tst_resm TFAIL "$* failed unexpectedly"
+	fi
+}
+
+EXPECT_RHOST_FAIL()
+{
+	tst_rhost_run -c "$* 2> /dev/null"
+	if [ $? -ne 0 ]; then
+		tst_resm TPASS "$* failed as expected"
+	else
+		tst_resm TFAIL "$* passed unexpectedly"
+	fi
+}
+
 # Get test interface names for local/remote host.
 # tst_get_ifaces [TYPE]
 # TYPE: { lhost | rhost }; Default value is 'lhost'.
@@ -190,22 +218,77 @@
 tst_ipaddr()
 {
 	local type="${1:-lhost}"
-	local ipv="${TST_IPV6:-4}"
-	local tst_host=
-
-	if [ "$type" = "lhost" ]; then
-		eval "tst_host=\$LHOST_IPV${ipv}_HOST"
-	else
-		eval "tst_host=\$RHOST_IPV${ipv}_HOST"
-	fi
-
 	if [ "$TST_IPV6" ]; then
-		echo "${IPV6_NETWORK}:${tst_host}"
+		[ "$type" = "lhost" ] && echo "$IPV6_LHOST" || echo "$IPV6_RHOST"
 	else
-		echo "${IPV4_NETWORK}.${tst_host}"
+		[ "$type" = "lhost" ] && echo "$IPV4_LHOST" || echo "$IPV4_RHOST"
 	fi
 }
 
+# Get IP address of unused network, specified either by type and counter
+# or by net and host.
+# tst_ipaddr_un [-cCOUNTER] [TYPE]
+# tst_ipaddr_un NET_ID [HOST_ID]
+# TYPE: { lhost | rhost }; Default value is 'lhost'.
+# COUNTER: Integer value for counting HOST_ID and NET_ID. Default is 1.
+# NET_ID: Integer or hex value of net. For IPv4 is 3rd octet, for IPv6
+# is 3rd hextet.
+# HOST_ID: Integer or hex value of host. For IPv4 is 4th octet, for
+# IPv6 is the last hextet. Default value is 0.
+tst_ipaddr_un()
+{
+	local counter host_id net_id max_host_id max_net_id tmp type
+	local OPTIND
+
+	while getopts "c:" opt; do
+		case $opt in
+			c) counter="$OPTARG";;
+		esac
+	done
+	shift $(($OPTIND - 1))
+
+	[ "$TST_IPV6" ] && max_net_id=65535 || max_net_id=255
+
+	if [ $# -eq 0 -o "$1" = "lhost" -o "$1" = "rhost" ]; then
+		[ -z "$counter" ] && counter=1
+		[ $counter -lt 1 ] && counter=1
+		type="${1:-lhost}"
+		max_host_id=$((max_net_id - 1))
+		tmp=$((counter * 2))
+		[ "$type" = "rhost" ] && tmp=$((tmp - 1))
+
+		host_id=$((tmp % max_host_id))
+		net_id=$((tmp / max_host_id))
+
+		if [ $host_id -eq 0 ]; then
+			host_id=$max_host_id
+			net_id=$((net_id - 1))
+		fi
+	else
+		net_id="$1"
+		host_id="${2:-0}"
+		if [ "$TST_IPV6" ]; then
+			net_id=$(printf %d $net_id)
+			host_id=$(printf %d $host_id)
+		fi
+		[ $net_id -lt 0 ] && net_id=0
+		[ $host_id -lt 0 ] && host_id=1
+	fi
+
+	net_id=$((net_id % max_net_id))
+	host_id=$((host_id % max_net_id))
+
+	if [ -z "$TST_IPV6" ]; then
+		echo "${IPV4_NET16_UNUSED}.${net_id}.${host_id}"
+		return
+	fi
+
+	[ $host_id -gt 0 ] && host_id="$(printf %x $host_id)" || host_id=
+	[ $net_id -gt 0 ] && net_id="$(printf %x $net_id)" || net_id=
+	[ "$net_id" ] && net_id=":$net_id"
+	echo "${IPV6_NET32_UNUSED}${net_id}::${host_id}"
+}
+
 # tst_init_iface [TYPE] [LINK]
 # TYPE: { lhost | rhost }; Default value is 'lhost'.
 # LINK: link number starting from 0. Default value is '0'.
@@ -241,9 +324,13 @@
 {
 	local type="${1:-lhost}"
 	local link_num="${2:-0}"
+	local mask
 
-	local mask=24
-	[ "$TST_IPV6" ] && mask=64
+	if [ "$TST_IPV6" ]; then
+		[ "$type" = "lhost" ] && mask=$IPV6_LPREFIX || mask=$IPV6_RPREFIX
+	else
+		[ "$type" = "lhost" ] && mask=$IPV4_LPREFIX || mask=$IPV4_RPREFIX
+	fi
 
 	local iface=$(tst_iface $type $link_num)
 
@@ -307,7 +394,7 @@
 	local rfile="tst_netload.res"
 	local expect_res="pass"
 	local ret=0
-
+	local type=
 	# common options for client and server
 	local cs_opts=
 
@@ -320,7 +407,7 @@
 	local s_opts=
 
 	OPTIND=0
-	while getopts :a:H:d:n:N:r:R:b:t:Ufe: opt; do
+	while getopts :a:H:d:n:N:r:R:b:t:T:fe:m: opt; do
 		case "$opt" in
 		a) c_num="$OPTARG" ;;
 		H) c_opts="${c_opts}-H $OPTARG " ;;
@@ -331,9 +418,10 @@
 		R) s_replies="$OPTARG" ;;
 		b) cs_opts="${cs_opts}-b $OPTARG " ;;
 		t) cs_opts="${cs_opts}-t $OPTARG " ;;
-		U) cs_opts="${cs_opts}-U " ;;
+		T) cs_opts="${cs_opts}-T $OPTARG "
+		   type="$OPTARG" ;;
+		m) cs_opts="${cs_opts}-m $OPTARG " ;;
 		f) cs_opts="${cs_opts}-f " ;;
-
 		e) expect_res="$OPTARG" ;;
 		*) tst_brkm TBROK "tst_netload: unknown option: $OPTARG" ;;
 		esac
@@ -356,10 +444,18 @@
 
 	tst_resm TINFO "check that server port in 'LISTEN' state"
 	local sec_waited=
-	for sec_waited in $(seq 1 600); do
-		tst_rhost_run -c "ss -lutn | grep -q $port" && break
-		if [ $sec_waited -eq 600 ]; then
-			tst_rhost_run -c "ss -utnp | grep $port"
+
+	local sock_cmd=
+	if [ "$type" = "sctp" ]; then
+		sock_cmd="netstat -naS | grep $port | grep -q LISTEN"
+	else
+		sock_cmd="ss -ldutn | grep -q $port"
+	fi
+
+	for sec_waited in $(seq 1 1200); do
+		tst_rhost_run -c "$sock_cmd" && break
+		if [ $sec_waited -eq 1200 ]; then
+			tst_rhost_run -c "ss -dutnp | grep $port"
 			tst_brkm TFAIL "server not in LISTEN state"
 		fi
 		tst_sleep 100ms
@@ -400,6 +496,7 @@
 	local src_iface="${1:-$(tst_iface)}"
 	local dst_addr="${2:-$(tst_ipaddr rhost)}"; shift $(( $# >= 2 ? 2 : 0 ))
 	local msg_sizes="$*"
+	local msg="tst_ping IPv${TST_IPV6:-4} iface $src_iface, msg_size"
 	local ret=0
 
 	# ping cmd use 56 as default message size
@@ -408,9 +505,9 @@
 			-s $size -i 0 > /dev/null 2>&1
 		ret=$?
 		if [ $ret -eq 0 ]; then
-			tst_resm TINFO "tst_ping IPv${TST_IPV6:-4} msg_size $size pass"
+			tst_resm TPASS "$msg $size: pass"
 		else
-			tst_resm TINFO "tst_ping IPv${TST_IPV6:-4} msg_size $size fail"
+			tst_resm TFAIL "$msg $size: fail"
 			break
 		fi
 	done
@@ -488,24 +585,55 @@
 export LTP_RSH="${LTP_RSH:-rsh -n}"
 
 # Test Links
-# Set first three octets of the network address, default is '10.0.0'
-export IPV4_NETWORK="${IPV4_NETWORK:-10.0.0}"
-# Set local host last octet, default is '2'
-export LHOST_IPV4_HOST="${LHOST_IPV4_HOST:-2}"
-# Set remote host last octet, default is '1'
-export RHOST_IPV4_HOST="${RHOST_IPV4_HOST:-1}"
-# Set the reverse of IPV4_NETWORK
-export IPV4_NET_REV="${IPV4_NET_REV:-0.0.10}"
-# Set first three octets of the network address, default is 'fd00:1:1:1'
-export IPV6_NETWORK="${IPV6_NETWORK:-fd00:1:1:1}"
-# Set local host last octet, default is '2'
-export LHOST_IPV6_HOST="${LHOST_IPV6_HOST:-:2}"
-# Set remote host last octet, default is '1'
-export RHOST_IPV6_HOST="${RHOST_IPV6_HOST:-:1}"
+# IPV{4,6}_{L,R}HOST can be set with or without prefix (e.g. IP or IP/prefix),
+# but if you use IP/prefix form, /prefix will be removed by tst_net_vars.
+IPV4_LHOST="${IPV4_LHOST:-10.0.0.2/24}"
+IPV4_RHOST="${IPV4_RHOST:-10.0.0.1/24}"
+IPV6_LHOST="${IPV6_LHOST:-fd00:1:1:1::2/64}"
+IPV6_RHOST="${IPV6_RHOST:-fd00:1:1:1::1/64}"
 
-# Networks that aren't reachable through the test links
-export IPV4_NET16_UNUSED="${IPV4_NET16_UNUSED:-10.23}"
-export IPV6_NET32_UNUSED="${IPV6_NET32_UNUSED:-fd00:23}"
+# tst_net_ip_prefix
+# Strip prefix from IP address and save both If no prefix found sets
+# default prefix.
+#
+# tst_net_iface_prefix reads prefix and interface from rtnetlink.
+# If nothing found sets default prefix value.
+#
+# tst_net_vars exports environment variables related to test links and
+# networks that aren't reachable through the test links.
+#
+# For full list of exported environment variables see:
+# tst_net_ip_prefix -h
+# tst_net_iface_prefix -h
+# tst_net_vars -h
+if [ -z "$TST_PARSE_VARIABLES" ]; then
+	eval $(tst_net_ip_prefix $IPV4_LHOST || echo "exit $?")
+	eval $(tst_net_ip_prefix -r $IPV4_RHOST || echo "exit $?")
+	eval $(tst_net_ip_prefix $IPV6_LHOST || echo "exit $?")
+	eval $(tst_net_ip_prefix -r $IPV6_RHOST || echo "exit $?")
+fi
+
+[ -n "$TST_USE_NETNS" -a "$TST_INIT_NETNS" != "no" ] && init_ltp_netspace
+
+if [ -z "$TST_PARSE_VARIABLES" ]; then
+	eval $(tst_net_iface_prefix $IPV4_LHOST || echo "exit $?")
+	eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV4_RHOST \
+		|| echo "exit $?")
+	eval $(tst_net_iface_prefix $IPV6_LHOST || echo "exit $?")
+	eval $(tst_rhost_run -c 'tst_net_iface_prefix -r '$IPV6_RHOST \
+		|| echo "exit $?")
+
+	eval $(tst_net_vars $IPV4_LHOST/$IPV4_LPREFIX \
+		$IPV4_RHOST/$IPV4_RPREFIX || echo "exit $?")
+	eval $(tst_net_vars $IPV6_LHOST/$IPV6_LPREFIX \
+		$IPV6_RHOST/$IPV6_RPREFIX || echo "exit $?")
+
+	tst_resm TINFO "Network config (local -- remote):"
+	tst_resm TINFO "$LHOST_IFACES -- $RHOST_IFACES"
+	tst_resm TINFO "$IPV4_LHOST/$IPV4_LPREFIX -- $IPV4_RHOST/$IPV4_RPREFIX"
+	tst_resm TINFO "$IPV6_LHOST/$IPV6_LPREFIX -- $IPV6_RHOST/$IPV6_RPREFIX"
+	export TST_PARSE_VARIABLES="yes"
+fi
 
 export HTTP_DOWNLOAD_DIR="${HTTP_DOWNLOAD_DIR:-/var/www/html}"
 export FTP_DOWNLOAD_DIR="${FTP_DOWNLOAD_DIR:-/var/ftp}"
@@ -513,27 +641,28 @@
 export FTP_UPLOAD_URLDIR="${FTP_UPLOAD_URLDIR:-pub}"
 
 # network/stress tests require additional parameters
-export NS_DURATION="${NS_DURATION:-3600}"
-export NS_TIMES="${NS_TIMES:-10000}"
+export NS_DURATION="${NS_DURATION:-720}"
+export NS_TIMES="${NS_TIMES:-2000}"
 export CONNECTION_TOTAL="${CONNECTION_TOTAL:-4000}"
-export IP_TOTAL="${IP_TOTAL:-10000}"
+export IP_TOTAL="${IP_TOTAL:-2000}"
 export IP_TOTAL_FOR_TCPIP="${IP_TOTAL_FOR_TCPIP:-100}"
-export ROUTE_TOTAL="${ROUTE_TOTAL:-10000}"
+export ROUTE_TOTAL="${ROUTE_TOTAL:-2000}"
 export MTU_CHANGE_TIMES="${MTU_CHANGE_TIMES:-1000}"
-export IF_UPDOWN_TIMES="${IF_UPDOWN_TIMES:-10000}"
+export IF_UPDOWN_TIMES="${IF_UPDOWN_TIMES:-2000}"
 export DOWNLOAD_BIGFILESIZE="${DOWNLOAD_BIGFILESIZE:-2147483647}"
 export DOWNLOAD_REGFILESIZE="${DOWNLOAD_REGFILESIZE:-1048576}"
 export UPLOAD_BIGFILESIZE="${UPLOAD_BIGFILESIZE:-2147483647}"
 export UPLOAD_REGFILESIZE="${UPLOAD_REGFILESIZE:-1024}"
 export MCASTNUM_NORMAL="${MCASTNUM_NORMAL:-20}"
-export MCASTNUM_HEAVY="${MCASTNUM_HEAVY:-40000}"
-
-[ -n "$TST_USE_NETNS" -a "$TST_INIT_NETNS" != "no" ] && init_ltp_netspace
+export MCASTNUM_HEAVY="${MCASTNUM_HEAVY:-4000}"
 
 # Warning: make sure to set valid interface names and IP addresses below.
 # Set names for test interfaces, e.g. "eth0 eth1"
+# This is fallback for LHOST_IFACES in case tst_net_vars finds nothing or we
+# want to use more ifaces.
 export LHOST_IFACES="${LHOST_IFACES:-eth0}"
 export RHOST_IFACES="${RHOST_IFACES:-eth0}"
+
 # Set corresponding HW addresses, e.g. "00:00:00:00:00:01 00:00:00:00:00:02"
 export LHOST_HWADDRS="${LHOST_HWADDRS:-$(tst_get_hwaddrs lhost)}"
 export RHOST_HWADDRS="${RHOST_HWADDRS:-$(tst_get_hwaddrs rhost)}"
diff --git a/testcases/lib/tst_net_iface_prefix.c b/testcases/lib/tst_net_iface_prefix.c
new file mode 100644
index 0000000..803f1e7
--- /dev/null
+++ b/testcases/lib/tst_net_iface_prefix.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/socket.h>
+#include <linux/rtnetlink.h>
+#include <net/if.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+#include "tst_net.h"
+
+static char *iface;
+static int prefix;
+
+static void usage(const char *cmd)
+{
+	fprintf(stderr, "USAGE:\n"
+		"%s IP_LHOST[/PREFIX]\n"
+		"%s -r IP_RHOST[/PREFIX]\n"
+		"%s -h\n\n"
+		"Set prefix and interface name for given IP.\n"
+		"Prefix and interface are found from kernel exported info (rtnetlink).\n\n"
+		"EXPORTED VARIABLES:\n"
+		"Export one of the following variables:\n"
+		"IPV4_LPREFIX: IPv4 prefix for IPV4_LNETWORK\n"
+		"IPV4_RPREFIX: IPv4 prefix for IPV4_RNETWORK\n"
+		"IPV6_LPREFIX: IPv6 prefix for IPV6_LNETWORK\n"
+		"IPV6_RPREFIX: IPv6 prefix for IPV6_RNETWORK\n"
+		"Export one of the following variables (if found):\n"
+		"LHOST_IFACES: iface name of the local host\n"
+		"RHOST_IFACES: iface name of the remote host\n\n"
+		"PARAMS:\n"
+		"-h this help\n"
+		"-r export remote environment variables\n",
+		cmd, cmd, cmd);
+}
+
+static int read_iface_prefix(const char *ip_str, int is_ipv6)
+{
+	uint8_t family = is_ipv6 ? AF_INET6 : AF_INET;
+
+	char buf[16384];
+	int len;
+
+	struct {
+		struct nlmsghdr nlhdr;
+		struct ifaddrmsg addrmsg;
+	} msg;
+
+	struct nlmsghdr *retmsg;
+
+	int sock = SAFE_SOCKET(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+
+	memset(&msg, 0, sizeof(msg));
+	msg.nlhdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
+	msg.nlhdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT;
+	msg.nlhdr.nlmsg_type = RTM_GETADDR;
+	msg.addrmsg.ifa_family = family;
+
+	SAFE_SEND(1, sock, &msg, msg.nlhdr.nlmsg_len, 0);
+	len = recv(sock, buf, sizeof(buf), 0);
+	retmsg = (struct nlmsghdr *)buf;
+
+	while NLMSG_OK(retmsg, len) {
+		char ifname[IFNAMSIZ];
+		struct ifaddrmsg *retaddr;
+		struct rtattr *retrta;
+		char pradd[128];
+		int attlen;
+
+		retaddr = (struct ifaddrmsg *)NLMSG_DATA(retmsg);
+		retrta = (struct rtattr *)IFA_RTA(retaddr);
+		attlen = IFA_PAYLOAD(retmsg);
+
+		while RTA_OK(retrta, attlen) {
+			if (retrta->rta_type == IFA_ADDRESS) {
+				inet_ntop(family, RTA_DATA(retrta), pradd,
+					  sizeof(pradd));
+
+				if_indextoname(retaddr->ifa_index, ifname);
+
+				if (!strcmp(pradd, ip_str)) {
+					prefix = retaddr->ifa_prefixlen;
+					iface = strdup(ifname);
+					return 0;
+				}
+			}
+			retrta = RTA_NEXT(retrta, attlen);
+		}
+		retmsg = NLMSG_NEXT(retmsg, len);
+	}
+
+	return -1;
+}
+
+static void print_ivar(const char *name, unsigned int val)
+{
+	printf("export %s=%d\n", name, val);
+}
+
+int main(int argc, char *argv[])
+{
+	char *ip_str = NULL, *prefix_str = NULL;
+	int is_ipv6, is_rhost = 0;
+	struct in_addr ip;
+	struct in6_addr ip6;
+
+	int is_usage = argc > 1 && (!strcmp(argv[1], "-h") ||
+		!strcmp(argv[1], "--help"));
+	if (argc < 2 || is_usage) {
+		usage(argv[0]);
+		exit(is_usage ? EXIT_SUCCESS : EXIT_FAILURE);
+	}
+	if (!strcmp(argv[1], "-r"))
+		is_rhost = 1;
+
+	ip_str = argv[is_rhost ? 2 : 1];
+	is_ipv6 = !!strchr(ip_str, ':');
+
+	prefix_str = strchr(ip_str, '/');
+	if (prefix_str) {
+		prefix = get_prefix(ip_str, is_ipv6);
+		tst_res_comment(TINFO,
+			"IP address '%s' contains prefix %d, using it and don't search for iface.\n",
+			ip_str, prefix);
+	} else if (read_iface_prefix(ip_str, is_ipv6)) {
+		tst_res_comment(TINFO,
+			"prefix and interface not found for '%s'.\n", ip_str);
+		exit(EXIT_SUCCESS);
+	}
+
+	/* checks for validity of IP string */
+	if (is_ipv6)
+		get_in6_addr(ip_str, &ip6);
+	else
+		get_in_addr(ip_str, &ip);
+
+	if (is_ipv6) {
+		print_svar_change("LHOST_IFACES", iface);
+		print_ivar(is_rhost ? "IPV6_RPREFIX" : "IPV6_LPREFIX", prefix);
+	} else {
+		print_svar_change("RHOST_IFACES", iface);
+		print_ivar(is_rhost ? "IPV4_RPREFIX" : "IPV4_LPREFIX", prefix);
+	}
+
+	exit(EXIT_SUCCESS);
+}
diff --git a/testcases/lib/tst_net_ip_prefix.c b/testcases/lib/tst_net_ip_prefix.c
new file mode 100644
index 0000000..92f80e0
--- /dev/null
+++ b/testcases/lib/tst_net_ip_prefix.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+#include "tst_net.h"
+
+#define DEFAULT_IPV4_PREFIX 24
+#define DEFAULT_IPV6_PREFIX 64
+
+static void usage(const char *cmd)
+{
+	fprintf(stderr, "USAGE:\n"
+		"%s IP_LHOST[/PREFIX]\n"
+		"%s -r IP_RHOST[/PREFIX]\n"
+		"%s -h\n\n"
+		"Set IP variables without prefix and prefix for given IP.\n"
+		"EXPORTED VARIABLES:\n"
+		"Export one of the following variables without /prefix:\n"
+		"IPV4_LHOST: IPv4 address of the local host\n"
+		"IPV4_RHOST: IPv4 address of the remote host\n"
+		"IPV6_LHOST: IPv6 address of the local host\n"
+		"IPV6_RHOST: IPv6 address of the remote host\n"
+		"Export one of the following variables:\n"
+		"IPV4_LPREFIX: IPv4 prefix for IPV4_LNETWORK\n"
+		"IPV4_RPREFIX: IPv4 prefix for IPV4_RNETWORK\n"
+		"IPV6_LPREFIX: IPv6 prefix for IPV6_LNETWORK\n"
+		"IPV6_RPREFIX: IPv6 prefix for IPV6_RNETWORK\n"
+		"Default IPv4 prefix: %d.\n"
+		"Default IPv6 prefix: %d.\n\n"
+		"PARAMS:\n"
+		"-h this help\n"
+		"-r export remote environment variables\n",
+		cmd, cmd, cmd, DEFAULT_IPV4_PREFIX, DEFAULT_IPV6_PREFIX);
+}
+
+static void print_ivar(const char *name, unsigned int val)
+{
+	printf("export %s=%d\n", name, val);
+}
+
+int main(int argc, char *argv[])
+{
+	char *ip_str = NULL, *prefix_str = NULL;
+	int is_ipv6, is_rhost = 0, prefix;
+	struct in_addr ip;
+	struct in6_addr ip6;
+
+	int is_usage = argc > 1 && (!strcmp(argv[1], "-h") ||
+		!strcmp(argv[1], "--help"));
+	if (argc < 2 || is_usage) {
+		usage(argv[0]);
+		exit(is_usage ? EXIT_SUCCESS : EXIT_FAILURE);
+	}
+	if (!strcmp(argv[1], "-r"))
+		is_rhost = 1;
+
+	ip_str = argv[is_rhost ? 2 : 1];
+	is_ipv6 = !!strchr(ip_str, ':');
+
+	prefix_str = strchr(ip_str, '/');
+
+	if (prefix_str)
+		prefix = get_prefix(ip_str, is_ipv6);
+	else
+		prefix = is_ipv6 ? DEFAULT_IPV6_PREFIX : DEFAULT_IPV4_PREFIX;
+
+	/* checks for validity of IP string */
+	if (is_ipv6)
+		get_in6_addr(ip_str, &ip6);
+	else
+		get_in_addr(ip_str, &ip);
+
+	if (is_ipv6) {
+		print_ivar(is_rhost ? "IPV6_RPREFIX" : "IPV6_LPREFIX", prefix);
+		print_svar(is_rhost ? "IPV6_RHOST" : "IPV6_LHOST", ip_str);
+	} else {
+		print_ivar(is_rhost ? "IPV4_RPREFIX" : "IPV4_LPREFIX", prefix);
+		print_svar(is_rhost ? "IPV4_RHOST" : "IPV4_LHOST", ip_str);
+	}
+
+	exit(EXIT_SUCCESS);
+}
diff --git a/testcases/lib/tst_net_vars.c b/testcases/lib/tst_net_vars.c
new file mode 100644
index 0000000..fc63f13
--- /dev/null
+++ b/testcases/lib/tst_net_vars.c
@@ -0,0 +1,638 @@
+/*
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+ * Copyright (c) 1997-2015 Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2011-2013 Rich Felker, et al.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#include <assert.h>
+#include <errno.h>
+#include <linux/rtnetlink.h>
+#include <net/if.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <stdarg.h>
+
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+#include "tst_net.h"
+
+#define BASE_IPV4_PREFIX 8
+#define BASE_IPV6_PREFIX 16
+
+#define MAX_IPV4_PREFIX 32
+#define MAX_IPV6_PREFIX 128
+
+#define DEFAULT_IPV4_UNUSED_PART1 10
+#define DEFAULT_IPV6_UNUSED_PART1 0xfd
+
+#define DEFAULT_IPV4_UNUSED_PART2 23
+#define DEFAULT_IPV6_UNUSED_PART2 0x23
+
+struct ltp_net_variables {
+	char *ipv4_lbroadcast;
+	char *ipv4_rbroadcast;
+	char *ipv4_lnetmask;
+	char *ipv4_rnetmask;
+	char *ipv4_lnetwork;
+	char *ipv4_rnetwork;
+	char *lhost_ipv4_host;
+	char *rhost_ipv4_host;
+	char *ipv6_lnetmask;
+	char *ipv6_rnetmask;
+	char *ipv6_lnetwork;
+	char *ipv6_rnetwork;
+	char *lhost_ipv6_host;
+	char *rhost_ipv6_host;
+	char *ipv4_net16_unused;
+	char *ipv6_net32_unused;
+};
+static struct ltp_net_variables vars;
+
+static void usage(const char *cmd)
+{
+	fprintf(stderr, "USAGE:\n"
+		"%s IP_LHOST[/PREFIX] IP_RHOST[/PREFIX]\n"
+		"%s -h\n\n"
+		"Exported variables:\n"
+		"IPV4_LBROADCAST: IPv4 broadcast of the local host\n"
+		"IPV4_RBROADCAST: IPv4 broadcast of the remote host\n"
+		"IPV4_LNETMASK: IPv4 netmask of the local host\n"
+		"IPV4_RNETMASK: IPv4 netmask of the remote host\n"
+		"IPV4_LNETWORK: IPv4 network part of IPV4_LHOST\n"
+		"IPV4_RNETWORK: IPv4 network part of IPV4_RHOST\n"
+		"LHOST_IPV4_HOST IPv4 host part of IPV4_LHOST\n"
+		"RHOST_IPV4_HOST IPv4 host part of IPV4_RHOST\n"
+		"IPV4_NET16_UNUSED: IPv4 16 bit unused subnet\n"
+		"IPV6_LNETMASK: IPv6 netmask of the local host\n"
+		"IPV6_RNETMASK: IPv6 netmask of the remote host\n"
+		"IPV6_LNETWORK: IPv6 network part of IPV6_LHOST\n"
+		"IPV6_RNETWORK: IPv6 network part of IPV6_LHOST\n"
+		"LHOST_IPV6_HOST: IPv6 unique part of IPV6_LHOST\n"
+		"RHOST_IPV6_HOST: IPv6 unique part of IPV6_RHOST\n"
+		"IPV6_NET32_UNUSED: IPv6 32 bit unused subnet\n\n"
+		"NOTE: Prefixes, ifaces and lhosts are expected to be set by tst_net_iface_prefix.\n"
+		"OPTIONS:\n"
+		"-h this help\n",
+		cmd, cmd);
+}
+
+/*
+ * Function prefix2mask is from ipcalc project, ipcalc.c.
+ */
+static struct in_addr prefix2mask(unsigned int prefix)
+{
+	struct in_addr mask;
+
+	memset(&mask, 0x0, sizeof(mask));
+
+	if (prefix)
+		mask.s_addr = htonl(~((1 << (32 - prefix)) - 1));
+	else
+		mask.s_addr = htonl(0);
+
+	return mask;
+}
+
+/*
+ * Function calc_network is based on ipcalc project,
+ * calc_network/ipcalc.c.
+ */
+static struct in_addr calc_network(const struct in_addr *ip,
+	struct in_addr *mask)
+{
+	struct in_addr network;
+
+	memset(&network, 0, sizeof(network));
+
+	network.s_addr = ip->s_addr & mask->s_addr;
+	return network;
+}
+
+static int is_in_subnet_ipv4(const struct in_addr *network,
+	const struct in_addr *mask, const struct in_addr *ip)
+{
+	return (ip->s_addr & mask->s_addr) ==
+		(network->s_addr & mask->s_addr);
+}
+
+static int is_in_subnet_ipv6(const struct in6_addr *network,
+	const struct in6_addr *mask, const struct in6_addr *ip6)
+{
+	unsigned int i;
+
+	for (i = 0; i < sizeof(struct in6_addr) / sizeof(int); i++) {
+		if (((((int *) ip6)[i] & ((int *) mask)[i])) !=
+			(((int *) network)[i] & ((int *) mask)[i]))
+			return 0;
+	}
+	return 1;
+}
+
+/*
+ * Function get_ipv4_netmask uses code from calc_network, which is from
+ * ipcalc project, ipcalc.c.
+ */
+static char *get_ipv4_netmask(unsigned int prefix)
+{
+	char buf[INET_ADDRSTRLEN + 1];
+	struct in_addr mask = prefix2mask(prefix);
+
+	if (prefix > MAX_IPV4_PREFIX)
+		return NULL;
+
+	if (!inet_ntop(AF_INET, &mask, buf, sizeof(buf)))
+		tst_brk_comment("error calculating IPv4 address");
+
+	return strdup(buf);
+}
+
+/*
+ * Function get_ipv4_netmask uses code from ipv6_prefix_to_mask and
+ * ipv6_mask_to_str, which are from ipcalc project, ipcalc.c.
+ */
+static char *get_ipv6_netmask(unsigned int prefix)
+{
+	struct in6_addr in6;
+	char buf[128];
+	int i, j;
+
+	if (prefix > MAX_IPV6_PREFIX)
+		return NULL;
+
+	memset(&in6, 0x0, sizeof(in6));
+	for (i = prefix, j = 0; i > 0; i -= 8, j++) {
+		if (i >= 8)
+			in6.s6_addr[j] = 0xff;
+		else
+			in6.s6_addr[j] = (unsigned long)(0xffU << (8 - i));
+	}
+
+	if (!inet_ntop(AF_INET6, &in6, buf, sizeof(buf)))
+		tst_brk_comment("error calculating IPv6 address");
+
+	return strdup(buf);
+}
+
+/*
+ * Function get_ipv4_broadcast uses code from calc_broadcast, which is from
+ * ipcalc project, ipcalc.c.
+ */
+static char *get_ipv4_broadcast(struct in_addr ip, unsigned int prefix)
+{
+	struct in_addr mask = prefix2mask(prefix);
+	struct in_addr broadcast;
+	char buf[INET_ADDRSTRLEN + 1];
+
+	memset(&broadcast, 0, sizeof(broadcast));
+	broadcast.s_addr = (ip.s_addr & mask.s_addr) | ~mask.s_addr;
+
+	if (!inet_ntop(AF_INET, &broadcast, buf, sizeof(buf)))
+		tst_brk_comment("error calculating IPv4 address");
+
+	return strdup(buf);
+}
+
+/*
+ * For unused network we use
+ * DEFAULT_IPV4_UNUSED_PART1:DEFAULT_IPV4_UNUSED_PART2 or
+ * {DEFAULT_IPV4_UNUSED_PART1}.XY, when there is a collision with IP.
+ */
+static char *get_ipv4_net16_unused(const struct in_addr *ip,
+	unsigned int prefix)
+{
+	struct in_addr mask, network;
+	char buf[128], net_unused[128];
+
+	mask = prefix2mask(prefix);
+	network = calc_network(ip, &mask);
+
+	sprintf(net_unused, "%d.%d", DEFAULT_IPV4_UNUSED_PART1,
+			DEFAULT_IPV4_UNUSED_PART2);
+	sprintf(buf, "%s.0.0", net_unused);
+
+	get_in_addr(buf, &network);
+
+	if (!is_in_subnet_ipv4(ip, &mask, &network))
+		return strdup(net_unused);
+
+	srand(time(NULL));
+
+	/* try to randomize second group */
+	sprintf(net_unused, "%d.%d", DEFAULT_IPV4_UNUSED_PART1,
+		(rand() % 128) + (((ip->s_addr >> 8) & 0xff) < 128 ? 128 : 0));
+	sprintf(buf, "%s.0.0", net_unused);
+
+	get_in_addr(buf, &network);
+
+	if (!is_in_subnet_ipv4(ip, &mask, &network))
+		return strdup(net_unused);
+
+	/* try to randomize first group */
+	sprintf(net_unused, "%d.%d", (rand() % 128) + (((ip->s_addr) & 0xff)
+			< 128 ? 128 : 0), DEFAULT_IPV4_UNUSED_PART2);
+	sprintf(buf, "%s.0.0", net_unused);
+
+	get_in_addr(buf, &network);
+
+	if (!is_in_subnet_ipv4(ip, &mask, &network))
+		return strdup(net_unused);
+
+	return NULL;
+}
+
+/*
+ * Function get_ipv6_net32_unused is inspired by ipcalc project,
+ * get_ipv6_info/ipcalc.c.
+ *
+ * For unused network we use DEFAULT_IPV6_UNUSED_PART1:DEFAULT_IPV6_UNUSED_PART2
+ * if no collision with existing IP range.
+ * Otherwise we try to use
+ * {DEFAULT_IPV6_UNUSED_PART1}XY:DEFAULT_IPV6_UNUSED_PART2 or
+ * XY:DEFAULT_IPV6_UNUSED_PART2.
+ */
+static char *get_ipv6_net32_unused(const struct in6_addr *ip6,
+	unsigned int prefix)
+{
+	int i, j;
+	struct in6_addr mask, network;
+	char buf[128], net_unused[128];
+
+	memset(&mask, 0x0, sizeof(mask));
+
+	if (prefix > 128)
+		return NULL;
+
+
+	for (i = prefix, j = 0; i > 0; i -= 8, j++) {
+		if (i >= 8)
+			mask.s6_addr[j] = 0xff;
+		else
+			mask.s6_addr[j] = (unsigned long)(0xffU << (8 - i));
+	}
+
+	sprintf(net_unused, "%x:%x", 256 * DEFAULT_IPV6_UNUSED_PART1,
+			DEFAULT_IPV6_UNUSED_PART2);
+	sprintf(buf, "%s::", net_unused);
+
+	get_in6_addr(buf, &network);
+
+	if (!is_in_subnet_ipv6(ip6, &mask, &network))
+		return strdup(net_unused);
+
+	srand(time(NULL));
+
+	/* try to randomize second group */
+	sprintf(net_unused, "%x:%x", 256 * DEFAULT_IPV6_UNUSED_PART1 +
+			(rand() % 128) + (ip6->s6_addr[1] < 128 ? 128 : 0),
+			DEFAULT_IPV6_UNUSED_PART2);
+	sprintf(buf, "%s::", net_unused);
+
+	get_in6_addr(buf, &network);
+
+	if (!is_in_subnet_ipv6(ip6, &mask, &network))
+		return strdup(net_unused);
+
+	/* try to randomize first group */
+	sprintf(net_unused, "%x:%x",
+			256 * (rand() % 128) + (256 * ip6->s6_addr[0] < 128 ?
+			128 : 0), DEFAULT_IPV6_UNUSED_PART2);
+	sprintf(buf, "%s::", net_unused);
+
+	get_in6_addr(buf, &network);
+
+	if (!is_in_subnet_ipv6(ip6, &mask, &network))
+		return strdup(net_unused);
+
+	return NULL;
+}
+
+/*
+ * Function get_ipv6_network is based on musl libc project,
+ * inet_ntop/inet_ntop.c.
+ */
+static char *get_ipv6_network(const unsigned char *a0, unsigned int prefix)
+{
+	const unsigned char *a = a0;
+	unsigned int i, j, max, best, border = 0;
+	char buf[100];
+	char ret[100];
+	char tmp[100];
+	char *p_ret = ret;
+	char *p_tmp = tmp;
+	size_t offset;
+
+	if (prefix > MAX_IPV6_PREFIX)
+		return NULL;
+
+	if (prefix == MAX_IPV6_PREFIX)
+		return strdup("\0");
+
+	snprintf(buf, sizeof(buf),
+		"%x:%x:%x:%x:%x:%x:%x:%x",
+		256 * a[0] + a[1], 256 * a[2] + a[3],
+		256 * a[4] + a[5], 256 * a[6] + a[7],
+		256 * a[8] + a[9], 256 * a[10] + a[11],
+		256 * a[12] + a[13], 256 * a[14] + a[15]);
+
+	for (i = 0; i < 8; i++) {
+		if (i < prefix >> 4) {
+			border += sprintf(p_tmp, "%x", 256 * a[2 * i] +
+				a[2 * i + 1]);
+			if (i > 0)
+				border++;
+		}
+
+		if (i >= prefix >> 4)
+			break;
+
+		/* ':' only if no leading in host or ending in net */
+		if (i > 0)
+			*p_ret++ = ':';
+
+		offset = sprintf(p_ret, "%x", 256 * a[2 * i] + a[2 * i + 1]);
+		p_ret += offset;
+	}
+
+	*p_ret = '\0';
+
+	/* Find longest /(^0|:)[:0]{2,}/ */
+	for (i = best = 0, max = 2; buf[i]; i++) {
+		if (i && buf[i] != ':')
+			continue;
+		j = strspn(buf + i, ":0");
+
+		if (j > max)
+			best = i, max = j;
+	}
+
+	size_t length = strlen(ret);
+	size_t best_end = best + max - 1;
+
+	if (max > 2 && best < border) {
+		p_ret = ret;
+		/* Replace longest /(^0|:)[:0]{2,}/ with "::" */
+		if (best == 0 && best_end >= border) {
+			/* zeros in whole net part or continue to host */
+			ret[0] = ':';
+			ret[1] = '\0';
+		} else if (best == 0 && best_end < border) {
+			/* zeros on beginning, not whole part */
+			ret[0] = ':';
+			memmove(p_ret + 1, p_ret + best_end, border - best_end
+				+ 1);
+		} else if (best > 0 && best_end >= border) {
+			/*
+			 * zeros not from beginning to border or continue to
+			 * host
+			 */
+			ret[best] = ':';
+			ret[best + 1] = '\0';
+		} else {
+			/* zeros somewhere in the middle */
+			ret[best] = ':';
+			memmove(p_ret + best + 1, p_ret + best_end,
+					border - best + 1);
+		}
+	}
+
+	if (length < INET6_ADDRSTRLEN)
+		return strdup(ret);
+
+	return NULL;
+}
+
+/*
+ * Strip host part from ip address.
+ */
+static char *get_host_from_ip(const char *ip, const char *net)
+{
+	if (ip == NULL || net == NULL)
+		return NULL;
+
+	char *result = strstr(ip, net);
+
+	if (!result || result != ip)
+		return NULL;
+
+	char *buf = strdup(ip);
+	unsigned int index = strlen(net);
+	int len;
+
+	/* prefix < 8 (IPv4) or 128 (IPv6) */
+	if (index == strlen(ip))
+		return strdup("\0");
+
+	/* prefix > 0 && prefix < 32 (IPv4) or 128 (IPv6) */
+	if (index > 0 && index < strlen(ip)) {
+		len = strlen(ip) - index - 1;
+		assert(ip[index] == ':' || ip[index] == '.');
+		memmove(buf, buf + index + 1, len);
+		buf[len] = '\0';
+	}
+
+	return buf;
+}
+
+static void check_prefix_range(unsigned int prefix, int is_ipv6, int is_lhost)
+{
+	unsigned int base_prefix = is_ipv6 ? BASE_IPV6_PREFIX :
+		BASE_IPV4_PREFIX;
+	unsigned int max_prefix = is_ipv6 ? MAX_IPV6_PREFIX : MAX_IPV4_PREFIX;
+
+	if (prefix < base_prefix || (is_ipv6 && prefix == 128) ||
+		(!is_ipv6 && prefix == 32))
+		tst_res_comment(TWARN,
+			"prefix %d for %s will be unsuitable for some stress tests which need %s variable. To avoid this use prefix >= %d and prefix < %d.",
+			prefix, is_ipv6 ?  "IPv6" : "IPv4",
+			is_ipv6 ?
+				(is_lhost ? "IPV6_LNETWORK" : "IPV6_RNETWORK") :
+				(is_lhost ? "IPV4_LNETWORK" : "IPV4_RNETWORK"),
+			base_prefix, max_prefix);
+}
+
+static char *get_ipv4_network(int ip, unsigned int prefix)
+{
+	char buf[INET_ADDRSTRLEN + 1];
+	char *p_buf = buf;
+	unsigned char byte;
+	unsigned int i;
+
+	if (prefix > MAX_IPV4_PREFIX)
+		return NULL;
+
+	if (prefix == MAX_IPV4_PREFIX)
+		return strdup("\0");
+
+	prefix &= 0x18;
+
+	for (i = 0; i < MAX_IPV4_PREFIX && (prefix == 0 || i < prefix);
+	     i += 8) {
+		if (i == 0) {
+			byte = ip & 0xff;
+			sprintf(p_buf, "%d", byte);
+		} else {
+			byte = (ip >> i) & 0xff;
+			sprintf(p_buf, ".%d", byte);
+		}
+		p_buf += strlen(p_buf);
+	}
+
+	return strdup(buf);
+}
+
+/*
+ * Round down prefix.
+ */
+static int round_down_prefix(unsigned int prefix, int is_ipv6)
+{
+	unsigned int base_prefix = is_ipv6 ? BASE_IPV6_PREFIX :
+		BASE_IPV4_PREFIX;
+
+	return prefix / base_prefix * base_prefix;
+}
+
+static void get_ipv4_info(const char *lip_str, const char *rip_str, int lprefix,
+	int rprefix)
+{
+	struct in_addr lip, rip;
+	int lprefix_round, rprefix_round;
+
+	lprefix_round = round_down_prefix(lprefix, 0);
+	rprefix_round = round_down_prefix(rprefix, 0);
+
+	get_in_addr(lip_str, &lip);
+	get_in_addr(rip_str, &rip);
+
+	vars.ipv4_lbroadcast = get_ipv4_broadcast(lip, lprefix);
+	vars.ipv4_rbroadcast = get_ipv4_broadcast(rip, rprefix);
+
+	vars.ipv4_lnetmask = get_ipv4_netmask(lprefix);
+	vars.ipv4_rnetmask = get_ipv4_netmask(rprefix);
+
+	vars.ipv4_lnetwork = get_ipv4_network(lip.s_addr, lprefix_round);
+	vars.ipv4_rnetwork = get_ipv4_network(rip.s_addr, rprefix_round);
+
+	vars.lhost_ipv4_host = get_host_from_ip(lip_str, vars.ipv4_lnetwork);
+	vars.rhost_ipv4_host = get_host_from_ip(rip_str, vars.ipv4_rnetwork);
+
+	vars.ipv4_net16_unused = get_ipv4_net16_unused(&lip, lprefix_round);
+}
+
+static void get_ipv6_info(const char *lip_str, const char *rip_str,
+	int lprefix, int rprefix)
+{
+	struct in6_addr lip, rip;
+	int lprefix_round, rprefix_round;
+
+	lprefix_round = round_down_prefix(lprefix, 1);
+	rprefix_round = round_down_prefix(rprefix, 1);
+
+	get_in6_addr(lip_str, &lip);
+	get_in6_addr(rip_str, &rip);
+
+	vars.ipv6_lnetmask = get_ipv6_netmask(lprefix);
+	vars.ipv6_rnetmask = get_ipv6_netmask(rprefix);
+
+	vars.ipv6_lnetwork = get_ipv6_network(lip.s6_addr, lprefix_round);
+	vars.ipv6_rnetwork = get_ipv6_network(rip.s6_addr, rprefix_round);
+
+	vars.lhost_ipv6_host = get_host_from_ip(lip_str, vars.ipv6_lnetwork);
+	vars.rhost_ipv6_host = get_host_from_ip(rip_str, vars.ipv6_rnetwork);
+
+	vars.ipv6_net32_unused = get_ipv6_net32_unused(&lip, lprefix_round);
+}
+
+static void print_vars(int is_ipv6)
+{
+	if (is_ipv6) {
+		print_svar("IPV6_LNETMASK", vars.ipv6_lnetmask);
+		print_svar_change("IPV6_RNETMASK", vars.ipv6_rnetmask);
+		print_svar("IPV6_LNETWORK", vars.ipv6_lnetwork);
+		print_svar("IPV6_RNETWORK", vars.ipv6_rnetwork);
+		print_svar("LHOST_IPV6_HOST", vars.lhost_ipv6_host);
+		print_svar("RHOST_IPV6_HOST", vars.rhost_ipv6_host);
+		print_svar("IPV6_NET32_UNUSED", vars.ipv6_net32_unused);
+	} else {
+		print_svar("IPV4_LBROADCAST", vars.ipv4_lbroadcast);
+		print_svar_change("IPV4_RBROADCAST", vars.ipv4_rbroadcast);
+		print_svar("IPV4_LNETMASK", vars.ipv4_lnetmask);
+		print_svar_change("IPV4_RNETMASK", vars.ipv4_rnetmask);
+		print_svar("IPV4_LNETWORK", vars.ipv4_lnetwork);
+		print_svar("IPV4_RNETWORK", vars.ipv4_rnetwork);
+		print_svar("LHOST_IPV4_HOST", vars.lhost_ipv4_host);
+		print_svar("RHOST_IPV4_HOST", vars.rhost_ipv4_host);
+		print_svar("IPV4_NET16_UNUSED", vars.ipv4_net16_unused);
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	char *lip_str = NULL, *rip_str = NULL;
+	int is_ipv6, lprefix, rprefix, tmp;
+	struct in_addr ip;
+	struct in6_addr ip6;
+
+	int is_usage = argc > 1 && (!strcmp(argv[1], "-h") ||
+		!strcmp(argv[1], "--help"));
+	if (argc < 3 || is_usage) {
+		usage(argv[0]);
+		exit(is_usage ? EXIT_SUCCESS : EXIT_FAILURE);
+	}
+
+	lip_str = argv[1];
+	rip_str = argv[2];
+
+	is_ipv6 = !!strchr(lip_str, ':');
+	lprefix = get_prefix(lip_str, is_ipv6);
+	rprefix = get_prefix(rip_str, is_ipv6);
+
+	if (is_ipv6)
+		get_in6_addr(lip_str, &ip6);
+	else
+		get_in_addr(lip_str, &ip);
+
+	tmp = !!strchr(rip_str, ':');
+	if (tmp)
+		get_in6_addr(rip_str, &ip6);
+	else
+		get_in_addr(rip_str, &ip);
+
+	if (is_ipv6 != tmp)
+		tst_brk_comment("mixed IPv4 and IPv6 addresses ('%s', '%s')",
+				lip_str, rip_str);
+
+	check_prefix_range(lprefix, is_ipv6, 1);
+	check_prefix_range(rprefix, is_ipv6, 0);
+
+	if (!strcmp(lip_str, rip_str))
+		tst_brk_comment("IP addresses cannot be the same ('%s', '%s')",
+				lip_str, rip_str);
+
+	if (is_ipv6)
+		get_ipv6_info(lip_str, rip_str, lprefix, rprefix);
+	else
+		get_ipv4_info(lip_str, rip_str, lprefix, rprefix);
+
+	print_vars(is_ipv6);
+
+	exit(EXIT_SUCCESS);
+}
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 087adda..9453759 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -374,7 +374,8 @@
 fi
 
 if [ -z "$TST_ID" ]; then
-	tst_brk TBROK "TST_ID is not defined"
+	filename=$(basename $0)
+	TST_ID=${filename%%.*}
 fi
 export TST_ID="$TST_ID"
 
diff --git a/testcases/network/busy_poll/busy_poll03.sh b/testcases/network/busy_poll/busy_poll03.sh
index 4ab93dc..628b1b4 100755
--- a/testcases/network/busy_poll/busy_poll03.sh
+++ b/testcases/network/busy_poll/busy_poll03.sh
@@ -49,7 +49,7 @@
 for x in 50 0; do
 	tst_resm TINFO "set low latency busy poll to $x per socket"
 	set_busy_poll $x
-	tst_netload -H $(tst_ipaddr rhost) -d res_$x -b $x -U
+	tst_netload -H $(tst_ipaddr rhost) -d res_$x -b $x -T udp
 done
 
 poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
diff --git a/testcases/network/can/filter-tests/can_rcv_own_msgs.c b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
index 2f9cbf2..8ad51d2 100644
--- a/testcases/network/can/filter-tests/can_rcv_own_msgs.c
+++ b/testcases/network/can/filter-tests/can_rcv_own_msgs.c
@@ -53,14 +53,13 @@
 #include <net/if.h>
 #include "config.h"
 #include "tst_res_flags.h"
+#include "tst_minmax.h"
 
 #ifdef HAVE_LINUX_CAN_H
 
 #include <linux/can.h>
 #include <linux/can/raw.h>
 
-#define max(a, b) ((a) > (b) ? (a) : (b))
-
 struct rxs {
 	int s;
 	int t;
@@ -70,7 +69,7 @@
 {
 	fd_set rdfs;
 	struct timeval tv;
-	int m = max(s, t) + 1;
+	int m = MAX(s, t) + 1;
 	int have_rx = 1;
 	struct can_frame frame;
 	struct rxs rx;
diff --git a/testcases/network/dccp/Makefile b/testcases/network/dccp/Makefile
new file mode 100644
index 0000000..23b7772
--- /dev/null
+++ b/testcases/network/dccp/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= dccp01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/dccp/dccp01.sh b/testcases/network/dccp/dccp01.sh
new file mode 100755
index 0000000..2337d98
--- /dev/null
+++ b/testcases/network/dccp/dccp01.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+
+TCID=dccp01
+TST_TOTAL=3
+TST_CLEANUP="cleanup"
+
+. test_net.sh
+
+cleanup()
+{
+	tst_rmdir
+}
+
+setup()
+{
+	tst_require_root
+	tst_tmpdir
+}
+
+test_run()
+{
+	tst_resm TINFO "compare UDP/DCCP performance"
+
+	tst_netload -H $(tst_ipaddr rhost) -T udp
+	local res0="$(cat tst_netload.res)"
+
+	tst_netload -H $(tst_ipaddr rhost) -T dccp
+	local res1="$(cat tst_netload.res)"
+
+	local per=$(( $res0 * 100 / $res1 - 100 ))
+
+	if [ "$per" -gt "100" -o "$per" -lt "-100" ]; then
+		tst_resm TFAIL "dccp performance $per %"
+	else
+		tst_resm TPASS "dccp performance $per % in range -100 ... 100 %"
+	fi
+}
+
+setup
+test_run
+
+tst_exit
diff --git a/testcases/network/dhcp/dhcp_lib.sh b/testcases/network/dhcp/dhcp_lib.sh
index 85f9b88..5001232 100755
--- a/testcases/network/dhcp/dhcp_lib.sh
+++ b/testcases/network/dhcp/dhcp_lib.sh
@@ -40,8 +40,7 @@
 	tst_require_root
 	tst_check_cmds cat $dhcp_name awk ip pgrep pkill dhclient
 
-	veth_loaded=
-	lsmod | grep -q '^veth ' && veth_loaded=1
+	lsmod | grep -q '^veth ' && veth_loaded=yes || veth_loaded=no
 
 	tst_resm TINFO "create veth interfaces"
 	ip li add $iface0 type veth peer name $iface1 || \
@@ -68,6 +67,8 @@
 
 cleanup()
 {
+	[ -z "$veth_loaded" ] && return
+
 	stop_dhcp
 
 	pkill -f "dhclient -$ipv $iface1"
@@ -81,9 +82,7 @@
 
 	[ $veth_added ] && ip li del $iface0
 
-	if [ -z $veth_loaded ]; then
-		lsmod | grep -q '^veth ' && rmmod veth
-	fi
+	[ "$veth_loaded" = "no" ] && lsmod | grep -q '^veth ' && rmmod veth
 
 	tst_rmdir
 }
diff --git a/testcases/network/lib6/asapi_01.c b/testcases/network/lib6/asapi_01.c
index ff310ea..a34b8ae 100644
--- a/testcases/network/lib6/asapi_01.c
+++ b/testcases/network/lib6/asapi_01.c
@@ -373,10 +373,6 @@
 	fd[1] = connect_fd;
 }
 
-#ifndef MAX
-#define MAX(a, b) ((a) >= (b) ? (a) : (b))
-#endif /* MAX */
-
 static void csum_test(void)
 {
 	fd_set rset, rset_save;
diff --git a/testcases/network/lib6/getaddrinfo_01.c b/testcases/network/lib6/getaddrinfo_01.c
index bbf8f77..db252a9 100644
--- a/testcases/network/lib6/getaddrinfo_01.c
+++ b/testcases/network/lib6/getaddrinfo_01.c
@@ -24,6 +24,7 @@
 #include <sys/socket.h>
 #include <netdb.h>
 #include <arpa/inet.h>
+#include <sys/param.h>
 
 #include "test.h"
 
diff --git a/testcases/network/lib6/in6_01.c b/testcases/network/lib6/in6_01.c
index f7186b4..dc14617 100644
--- a/testcases/network/lib6/in6_01.c
+++ b/testcases/network/lib6/in6_01.c
@@ -1,36 +1,34 @@
 /*
+ * Copyright (c) International Business Machines Corp., 2001
+ * Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
  *
- *   Copyright (c) International Business Machines  Corp., 2001
- *   Author: David L Stevens
+ * 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 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 would 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.
  *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  *
- *   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
+ * Author: David L Stevens
  */
+
 /*
- *   Description:
- *     Verify that in6 and sockaddr fields are present. Most of these are
- *     "PASS" if they just compile.
+ * Description: Verify that in6 and sockaddr fields are present.
  */
 
-#include <stdio.h>
-#include <unistd.h>
 #include <errno.h>
-
-#include <netinet/in.h>
 #include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
 
-#include "test.h"
+#include "tst_test.h"
+#include "tst_safe_macros.h"
 
 static struct {
 	char *addr;
@@ -40,12 +38,10 @@
 	{ "::ffff:10.0.0.1", 1 },
 	{ "::fffe:10.0.0.1", 0 },
 	{ "::7fff:10.0.0.1", 0 },
-	{ "0:0:0:0:0:0:ffff:0a001", 0 },
-	{ "0:0:1:0:0:0:ffff:0a001", 0 },
+	{ "0:0:0:0:0:0:ffff:a001", 0 },
+	{ "0:0:1:0:0:0:ffff:a001", 0 },
 };
 
-#define MAPSIZE (sizeof(maptab)/sizeof(maptab[0]))
-
 static struct {
 	char *addr;
 } sstab[] = {
@@ -56,9 +52,6 @@
 	{ "::" },
 };
 
-#define SSSIZE (sizeof(sstab)/sizeof(sstab[0]))
-
-static void setup(void);
 static void test_in6_addr(void);
 static void test_sockaddr_in6(void);
 static void test_global_in6_def(void);
@@ -69,33 +62,6 @@
 	test_sockaddr_in6, test_global_in6_def,
 	test_in6_is_addr_v4mapped, test_sockaddr_storage };
 
-char *TCID = "in6_01";
-int TST_TOTAL = ARRAY_SIZE(testfunc);
-
-int main(int argc, char *argv[])
-{
-	int lc;
-	int i;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++)
-			(*testfunc[i])();
-	}
-
-	tst_exit();
-}
-
-static void setup(void)
-{
-	TEST_PAUSE;
-}
-
 /* struct in6_addr tests */
 static void test_in6_addr(void)
 {
@@ -103,11 +69,11 @@
 	struct in6_addr in6;
 
 	in6.s6_addr[0] = ui8;
-	tst_resm(TINFO, "type of in6.s6_addr[0] is uint8_t");
+	tst_res(TINFO, "type of in6.s6_addr[0] is uint8_t");
 	if (sizeof(in6.s6_addr) != 16)
-		tst_resm(TFAIL, "sizeof(in6.s6_addr) != 16");
+		tst_res(TFAIL, "sizeof(in6.s6_addr) != 16");
 	else
-		tst_resm(TPASS, "sizeof(in6.s6_addr) == 16");
+		tst_res(TPASS, "sizeof(in6.s6_addr) == 16");
 }
 
 /* struct sockaddr_in6 tests */
@@ -118,6 +84,7 @@
 	uint32_t ui32 = 3;
 	struct in6_addr in6;
 	struct sockaddr_in6 sin6;
+	int sd;
 
 	in6.s6_addr[0] = ui8;
 	sin6.sin6_family = AF_INET6;
@@ -125,7 +92,12 @@
 	sin6.sin6_flowinfo = ui32;
 	sin6.sin6_addr = in6;
 	sin6.sin6_scope_id = ui32;
-	tst_resm(TPASS, "all sockaddr_in6 fields present and correct");
+
+	sd = SAFE_SOCKET(AF_INET6, SOCK_STREAM, 0);
+	bind(sd, (struct sockaddr *)&sin6, sizeof(sin6));
+	SAFE_CLOSE(sd);
+
+	tst_res(TPASS, "all sockaddr_in6 fields present and correct");
 }
 
 /* initializers and global in6 definitions tests */
@@ -134,31 +106,33 @@
 	struct in6_addr ina6 = IN6ADDR_ANY_INIT;
 	struct in6_addr inl6 = IN6ADDR_LOOPBACK_INIT;
 
-	tst_resm(TINFO, "IN6ADDR_ANY_INIT present");
-	if (memcmp(&ina6, &in6addr_any, sizeof(ina6)) == 0) {
-		tst_resm(TINFO, "in6addr_any present and correct");
-	} else {
-		tst_resm(TFAIL, "in6addr_any incorrect value");
+	tst_res(TINFO, "IN6ADDR_ANY_INIT present");
+	if (memcmp(&ina6, &in6addr_any, sizeof(ina6)) == 0)
+		tst_res(TINFO, "in6addr_any present and correct");
+	else {
+		tst_res(TFAIL, "in6addr_any incorrect value");
 		return;
 	}
 
-	tst_resm(TINFO, "IN6ADDR_LOOPBACK_INIT present");
-	if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0) {
-		tst_resm(TINFO, "in6addr_loopback present and correct");
-	} else {
-		tst_resm(TFAIL, "in6addr_loopback incorrect value");
+	tst_res(TINFO, "IN6ADDR_LOOPBACK_INIT present");
+	if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0)
+		tst_res(TINFO, "in6addr_loopback present and correct");
+	else {
+		tst_res(TFAIL, "in6addr_loopback incorrect value");
 		return;
 	}
+
 	if (inet_pton(AF_INET6, "::1", &inl6) <= 0)
-		tst_brkm(TBROK | TERRNO, NULL, "inet_pton(\"::1\")");
-	if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0) {
-		tst_resm(TINFO, "in6addr_loopback in network byte order");
-	} else {
-		tst_resm(TFAIL, "in6addr_loopback has wrong byte order");
+		tst_brk(TBROK | TERRNO, "inet_pton(\"::1\")");
+
+	if (memcmp(&inl6, &in6addr_loopback, sizeof(inl6)) == 0)
+		tst_res(TINFO, "in6addr_loopback in network byte order");
+	else {
+		tst_res(TFAIL, "in6addr_loopback has wrong byte order");
 		return;
 	}
 
-	tst_resm(TPASS, "global in6 definitions tests succeed");
+	tst_res(TPASS, "global in6 definitions tests succeed");
 }
 
 /* IN6_IS_ADDR_V4MAPPED tests */
@@ -167,24 +141,23 @@
 	unsigned int i;
 	struct in6_addr in6;
 
-	for (i = 0; i < MAPSIZE; ++i) {
-		if (inet_pton(AF_INET6, maptab[i].addr, &in6) <= 0) {
-			tst_brkm(TBROK | TERRNO, NULL,
+	for (i = 0; i < ARRAY_SIZE(maptab); ++i) {
+		if (inet_pton(AF_INET6, maptab[i].addr, &in6) <= 0)
+			tst_brk(TBROK | TERRNO,
 				"\"%s\" is not a valid IPv6 address",
 				maptab[i].addr);
-		}
 		TEST(IN6_IS_ADDR_V4MAPPED(in6.s6_addr));
-		if (TEST_RETURN == maptab[i].ismap) {
-			tst_resm(TINFO, "IN6_IS_ADDR_V4MAPPED(\"%s\") %ld",
+		if (maptab[i].ismap == TEST_RETURN)
+			tst_res(TINFO, "IN6_IS_ADDR_V4MAPPED(\"%s\") %ld",
 				maptab[i].addr, TEST_RETURN);
-		} else {
-			tst_resm(TFAIL, "IN6_IS_ADDR_V4MAPPED(\"%s\") %ld",
+		else {
+			tst_res(TFAIL, "IN6_IS_ADDR_V4MAPPED(\"%s\") %ld",
 				maptab[i].addr, TEST_RETURN);
 			return;
 		}
 	}
 
-	tst_resm(TPASS, "IN6_IS_ADDR_V4MAPPED tests succeed");
+	tst_res(TPASS, "IN6_IS_ADDR_V4MAPPED tests succeed");
 }
 
 /* sockaddr_storage tests */
@@ -195,9 +168,9 @@
 
 	if (sizeof(ss) <= sizeof(struct sockaddr_in) ||
 		sizeof(ss) <= sizeof(struct sockaddr_in6))
-		tst_brkm(TBROK, NULL, "sockaddr_storage too small");
+		tst_brk(TBROK, "sockaddr_storage too small");
 
-	for (i = 0; i < SSSIZE; ++i) {
+	for (i = 0; i < ARRAY_SIZE(sstab); ++i) {
 		struct sockaddr_in *psin = (struct sockaddr_in *)&ss;
 		struct sockaddr_in6 *psin6 = (struct sockaddr_in6 *)&ss;
 		int rv;
@@ -210,18 +183,26 @@
 			rv = inet_pton(AF_INET6, sstab[i].addr,
 				&psin6->sin6_addr);
 		}
-		if (rv <= 0) {
-			tst_brkm(TBROK, NULL,
+		if (rv <= 0)
+			tst_brk(TBROK,
 				"\"%s\" is not a valid address", sstab[i].addr);
-		}
-		if (ss.ss_family == af) {
-			tst_resm(TINFO, "\"%s\" is AF_INET%s",
+		if (ss.ss_family == af)
+			tst_res(TINFO, "\"%s\" is AF_INET%s",
 				sstab[i].addr, af == AF_INET ? "" : "6");
-		} else {
-			tst_resm(TFAIL, "\"%s\" ss_family (%d) != AF_INET%s",
+		else
+			tst_res(TFAIL, "\"%s\" ss_family (%d) != AF_INET%s",
 				sstab[i].addr, af, af == AF_INET ? "" : "6");
-		}
 	}
 
-	tst_resm(TPASS, "sockaddr_storage tests succeed");
+	tst_res(TPASS, "sockaddr_storage tests succeed");
 }
+
+static void do_test(unsigned int i)
+{
+	testfunc[i]();
+}
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(testfunc),
+	.test = do_test,
+};
diff --git a/testcases/network/multicast/mc_cmds/mc_cmds b/testcases/network/multicast/mc_cmds/mc_cmds
index 8077b1f..00e0166 100755
--- a/testcases/network/multicast/mc_cmds/mc_cmds
+++ b/testcases/network/multicast/mc_cmds/mc_cmds
@@ -46,13 +46,19 @@
 
 do_test()
 {
+	local ip_fixed_version=170220
+
 	ip addr show $(tst_iface) | grep -q 'MULTICAST' || \
 		tst_brkm TFAIL "Multicast not listed for $(tst_iface)"
 
 	ip maddr show $(tst_iface) | grep -q '224.0.0.1'
 	if [ $? -ne 0 ]; then
-		tst_resm TWARN "'ip maddr show $(tst_iface)' failed," \
-			       " parsing 'ip maddr show'"
+		[ `ip -V | cut -d's' -f3` -lt $ip_fixed_version ] && \
+			tst_resm TINFO "'ip maddr show $(tst_iface)' failed"\
+					"(caused by old ip version, fixed in"\
+					"$ip_fixed_version)" || \
+			tst_resm TWARN "'ip maddr show $(tst_iface)' failed"
+		tst_resm TINFO "parsing 'ip maddr show' command"
 		ip maddr show | sed -ne "/\s$(tst_iface)/,/^[0-9]/p" | \
 			grep -q 224.0.0.1 || \
 			tst_brkm TFAIL "$(tst_iface) not joined 224.0.0.1"
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 8184716..4b211aa 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -38,6 +38,19 @@
 
 static const int max_msg_len = (1 << 16) - 1;
 
+#ifndef SOCK_DCCP
+#define SOCK_DCCP		6
+#endif
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP		33
+#endif
+#ifndef SOL_DCCP
+#define SOL_DCCP		269
+#endif
+#ifndef DCCP_SOCKOPT_SERVICE
+#define DCCP_SOCKOPT_SERVICE	2
+#endif
+
 /* TCP server requiers */
 #ifndef TCP_FASTOPEN
 #define TCP_FASTOPEN	23
@@ -92,7 +105,21 @@
 static char *tcp_port		= "61000";
 static char *server_addr	= "localhost";
 static int busy_poll		= -1;
-static char *use_udp;
+
+enum {
+	TYPE_TCP = 0,
+	TYPE_UDP,
+	TYPE_DCCP,
+	TYPE_SCTP
+};
+static uint proto_type;
+static char *type;
+static int sock_type = SOCK_STREAM;
+static int protocol;
+static int family = AF_INET6;
+
+static uint32_t service_code = 0xffff;
+
 /* server socket */
 static int sfd;
 
@@ -129,6 +156,11 @@
 		SAFE_SETSOCKOPT(sd, SOL_SOCKET, SO_BUSY_POLL,
 			&busy_poll, sizeof(busy_poll));
 	}
+
+	if (proto_type == TYPE_DCCP) {
+		SAFE_SETSOCKOPT(sd, SOL_DCCP, DCCP_SOCKOPT_SERVICE,
+				&service_code, sizeof(uint32_t));
+	}
 }
 
 static void do_cleanup(void)
@@ -226,8 +258,7 @@
 
 static int client_connect_send(const char *msg, int size)
 {
-	int cfd = SAFE_SOCKET(remote_addrinfo->ai_family,
-			 remote_addrinfo->ai_socktype, 0);
+	int cfd = SAFE_SOCKET(family, sock_type, protocol);
 
 	init_socket_opts(cfd);
 
@@ -264,7 +295,7 @@
 	}
 
 	for (i = 1; i < client_max_requests; ++i) {
-		if (use_udp)
+		if (proto_type == TYPE_UDP)
 			goto send;
 
 		if (cfd == -1) {
@@ -355,7 +386,7 @@
 	struct addrinfo hints;
 	memset(&hints, 0, sizeof(struct addrinfo));
 	hints.ai_family = AF_UNSPEC;
-	hints.ai_socktype = (use_udp) ? SOCK_DGRAM : SOCK_STREAM;
+	hints.ai_socktype = sock_type;
 	hints.ai_flags = 0;
 	hints.ai_protocol = 0;
 
@@ -368,6 +399,8 @@
 	tst_res(TINFO, "Running the test over IPv%s",
 		(remote_addrinfo->ai_family == AF_INET6) ? "6" : "4");
 
+	family = remote_addrinfo->ai_family;
+
 	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_client_start);
 	int i;
 	for (i = 0; i < clients_num; ++i)
@@ -482,13 +515,23 @@
 		 * It will tell client that server is going
 		 * to close this connection.
 		 */
-		if (!use_udp && ++num_requests >= server_max_requests)
+		if (sock_type == SOCK_STREAM &&
+		    ++num_requests >= server_max_requests)
 			send_msg[0] = start_fin_byte;
 
-		SAFE_SENDTO(1, client_fd, send_msg, send_msg_size, MSG_NOSIGNAL,
-			(struct sockaddr *)&remote_addr, remote_addr_len);
+		switch (proto_type) {
+		case TYPE_SCTP:
+			SAFE_SEND(1, client_fd, send_msg, send_msg_size,
+				MSG_NOSIGNAL);
+		break;
+		default:
+			SAFE_SENDTO(1, client_fd, send_msg, send_msg_size,
+				MSG_NOSIGNAL, (struct sockaddr *)&remote_addr,
+				remote_addr_len);
+		}
 
-		if (!use_udp && num_requests >= server_max_requests) {
+		if (sock_type == SOCK_STREAM &&
+		    num_requests >= server_max_requests) {
 			/* max reqs, close socket */
 			shutdown(client_fd, SHUT_WR);
 			break;
@@ -514,9 +557,10 @@
 static void server_init(void)
 {
 	struct addrinfo hints;
+
 	memset(&hints, 0, sizeof(struct addrinfo));
 	hints.ai_family = AF_INET6;
-	hints.ai_socktype = (use_udp) ? SOCK_DGRAM : SOCK_STREAM;
+	hints.ai_socktype = sock_type;
 	hints.ai_flags = AI_PASSIVE;
 
 	int err = getaddrinfo(NULL, tcp_port, &hints, &local_addrinfo);
@@ -528,7 +572,7 @@
 		tst_brk(TBROK, "failed to get the address");
 
 	/* IPv6 socket is also able to access IPv4 protocol stack */
-	sfd = SAFE_SOCKET(AF_INET6, local_addrinfo->ai_socktype, 0);
+	sfd = SAFE_SOCKET(family, sock_type, protocol);
 	const int flag = 1;
 	SAFE_SETSOCKOPT(sfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
 
@@ -537,7 +581,7 @@
 
 	freeaddrinfo(local_addrinfo);
 
-	if (use_udp)
+	if (proto_type == TYPE_UDP)
 		return;
 
 	init_socket_opts(sfd);
@@ -656,6 +700,18 @@
 	tst_res(TINFO, "set '%s' to '1'", tcp_tw_reuse);
 }
 
+static void set_protocol_type(void)
+{
+	if (!type || !strcmp(type, "tcp"))
+		proto_type = TYPE_TCP;
+	else if (!strcmp(type, "udp"))
+		proto_type = TYPE_UDP;
+	else if (!strcmp(type, "dccp"))
+		proto_type = TYPE_DCCP;
+	else if (!strcmp(type, "sctp"))
+		proto_type = TYPE_SCTP;
+}
+
 static void setup(void)
 {
 	if (tst_parse_int(aarg, &clients_num, 1, INT_MAX))
@@ -687,6 +743,8 @@
 	if (busy_poll >= 0 && tst_kvercmp(3, 11, 0) < 0)
 		tst_brk(TCONF, "Test must be run with kernel 3.11 or newer");
 
+	set_protocol_type();
+
 	if (client_mode) {
 		tst_res(TINFO, "connection: addr '%s', port '%s'",
 			server_addr, tcp_port);
@@ -703,21 +761,46 @@
 		tst_res(TINFO, "max requests '%d'",
 			server_max_requests);
 		net.init	= server_init;
-		net.run		= (use_udp) ? server_run_udp : server_run;
-		net.cleanup	= (use_udp) ? NULL : server_cleanup;
+		switch (proto_type) {
+		case TYPE_TCP:
+		case TYPE_DCCP:
+		case TYPE_SCTP:
+			net.run		= server_run;
+			net.cleanup	= server_cleanup;
+		break;
+		case TYPE_UDP:
+			net.run		= server_run_udp;
+			net.cleanup	= NULL;
+		break;
+		}
 	}
 
 	remote_addr_len = sizeof(struct sockaddr_storage);
 
-	if (use_udp) {
-		tst_res(TINFO, "using UDP");
-		fastopen_api = NULL;
-	} else {
+	switch (proto_type) {
+	case TYPE_TCP:
 		tst_res(TINFO, "TCP %s is using %s TCP API.",
 			(client_mode) ? "client" : "server",
 			(fastopen_api) ? "Fastopen" : "old");
-
 		check_tfo_value();
+	break;
+	case TYPE_UDP:
+		tst_res(TINFO, "using UDP");
+		fastopen_api = NULL;
+		sock_type = SOCK_DGRAM;
+	break;
+	case TYPE_DCCP:
+		tst_res(TINFO, "DCCP %s", (client_mode) ? "client" : "server");
+		fastopen_api = NULL;
+		sock_type = SOCK_DCCP;
+		protocol = IPPROTO_DCCP;
+		service_code = htonl(service_code);
+	break;
+	case TYPE_SCTP:
+		tst_res(TINFO, "SCTP %s", (client_mode) ? "client" : "server");
+		fastopen_api = NULL;
+		protocol = IPPROTO_SCTP;
+	break;
 	}
 
 	net.init();
@@ -735,7 +818,7 @@
 
 	{"g:", &tcp_port, "-g x     x - server port"},
 	{"b:", &barg, "-b x     x - low latency busy poll timeout"},
-	{"U", &use_udp, "-U       Use UDP\n"},
+	{"T:", &type, "-T x     tcp (default), udp, dccp, sctp\n"},
 
 	{"H:", &server_addr, "Client:\n-H x     Server name or IP address"},
 	{"l", &client_mode, "-l       Become client, default is server"},
@@ -743,7 +826,7 @@
 	{"r:", &rarg, "-r x     Number of client requests"},
 	{"n:", &narg, "-n x     Client message size"},
 	{"N:", &Narg, "-N x     Server message size"},
-	{"T:", &Targ, "-T x     Reply timeout in microsec."},
+	{"m:", &Targ, "-m x     Reply timeout in microsec."},
 	{"d:", &rpath, "-d x     x is a path to file where result is saved\n"},
 
 	{"R:", &Rarg, "Server:\n-R x     x requests after which conn.closed"},
@@ -752,7 +835,6 @@
 };
 
 static struct tst_test test = {
-	.tid = "netstress",
 	.test_all = do_test,
 	.setup = setup,
 	.cleanup = cleanup,
diff --git a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
index 6b2c98f..c4cbd05 100644
--- a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
+++ b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
@@ -226,7 +226,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "nfs05_make_tree",
 	.options = opts,
 	.test_all = do_test,
 	.setup = setup,
diff --git a/testcases/network/nfsv4/locks/locktests.c b/testcases/network/nfsv4/locks/locktests.c
index dd6899c..961354e 100644
--- a/testcases/network/nfsv4/locks/locktests.c
+++ b/testcases/network/nfsv4/locks/locktests.c
@@ -32,15 +32,15 @@
 int MAXLEN = 64;
 int MAXTEST = 10;
 extern int maxClients;
-extern int fdServeur;
+extern int fdServer;
 
 char message[M_SIZE];
-int esclaveLecteur;
-int maitreLecteur;
-int esclaveEcrivain;
+int slaveReader;
+int masterReader;
+int slaveWriter;
 
 /* Which lock will be applied by the master process on test startup */
-int LISTE_LOCKS[] = { READLOCK, WRITELOCK,
+int LIST_LOCKS[] = { READLOCK, WRITELOCK,
 	READLOCK, WRITELOCK,
 	READLOCK, WRITELOCK,
 	READLOCK, WRITELOCK,
@@ -48,7 +48,7 @@
 };
 
 /* The operations the slave processes will try to perform */
-int LISTE_TESTS[] = { WRONLY, WRONLY,
+int LIST_TESTS[] = { WRONLY, WRONLY,
 	RDONLY, RDONLY,
 	READLOCK, WRITELOCK,
 	WRITELOCK, READLOCK,
@@ -56,7 +56,7 @@
 };
 
 /* List of test names */
-char *LISTE_NOMS_TESTS[] = { "WRITE ON A READ  LOCK",
+char *LIST_NAMES_TESTS[] = { "WRITE ON A READ  LOCK",
 	"WRITE ON A WRITE LOCK",
 	"READ  ON A READ  LOCK",
 	"READ  ON A WRITE LOCK",
@@ -69,7 +69,7 @@
 };
 
 /* List of expected test results, when slaves are processes */
-int LISTE_RESULTATS_PROCESS[] = { SUCCES, SUCCES,
+int LIST_RESULTS_PROCESS[] = { SUCCES, SUCCES,
 	SUCCES, SUCCES,
 	SUCCES, ECHEC,
 	ECHEC, ECHEC,
@@ -77,49 +77,49 @@
 };
 
 /* List of expected test results, when slaves are threads */
-int LISTE_RESULTATS_THREADS[] = { SUCCES, SUCCES,
+int LIST_RESULTS_THREADS[] = { SUCCES, SUCCES,
 	SUCCES, SUCCES,
 	SUCCES, SUCCES,
 	SUCCES, SUCCES,
 	ECHEC, ECHEC
 };
 
-int *LISTE_RESULTATS = NULL;
+int *LIST_RESULTS = NULL;
 char *eType = NULL;
 
-int TOTAL_RESULTAT_OK[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+int TOTAL_RESULT_OK[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
-void *esclave(void *donnees);
-int (*terminer) (int a);
+void *slave(void *data);
+int (*finish) (int a);
 
-int terminerProcess(int a)
+int finishProcess(int a)
 {
 	exit(a);
 }
 
 int (*load) (void);
 
-struct donneesPub dp;
+struct dataPub dp;
 
 /* Functions to access tests/tests names/tests results*/
 int testSuiv(int n)
 {
-	return LISTE_TESTS[n];
+	return LIST_TESTS[n];
 }
 
 int resAttSuiv(int n)
 {
-	return LISTE_RESULTATS[n];
+	return LIST_RESULTS[n];
 }
 
 char *nomTestSuiv(int n)
 {
-	return LISTE_NOMS_TESTS[n];
+	return LIST_NAMES_TESTS[n];
 }
 
 int lockSuiv(int n)
 {
-	return LISTE_LOCKS[n];
+	return LIST_LOCKS[n];
 }
 
 /* Verify the test result is the expected one */
@@ -127,33 +127,33 @@
 {
 
 	P("r=%d\n", r);
-	if (r == LISTE_RESULTATS[n])
+	if (r == LIST_RESULTS[n])
 		return 1;
 	else
 		return 0;
 }
 
 /* Increments the number of process which have successfully passed the test */
-void compteur(int r, int n)
+void counter(int r, int n)
 {
-	TOTAL_RESULTAT_OK[n] += matchResult(r, n);
+	TOTAL_RESULT_OK[n] += matchResult(r, n);
 }
 
 /* Special case for test 'lock file byte byte by byte'.
  * We ensure each byte is correctly locked.
  */
-void validationResultats(int n)
+void validationResults(int n)
 {
 	int i, u, l, fsize;
 	struct flock request;
 
 	fsize = dp.nclnt * (maxClients + 1);
-	TOTAL_RESULTAT_OK[n] = 0;
+	TOTAL_RESULT_OK[n] = 0;
 	l = FALSE;
 	u = TRUE;
 
 	/* If the expected operation result is a success, we will have to increase the number of correct results */
-	if (LISTE_RESULTATS[n]) {
+	if (LIST_RESULTS[n]) {
 		l = TRUE;
 		u = FALSE;
 	}
@@ -166,33 +166,33 @@
 		fcntl(dp.fd, F_GETLK, &request);
 		/* Ensure the lock is correctly set */
 		if (request.l_type != F_UNLCK)
-			TOTAL_RESULTAT_OK[n] += l;
+			TOTAL_RESULT_OK[n] += l;
 		else
-			TOTAL_RESULTAT_OK[n] += u;
+			TOTAL_RESULT_OK[n] += u;
 	}
 }
 
 int initTest(void)
 {
 
-	P("Maitre ouvre %s\n", dp.fname);
+	P("Master opens %s\n", dp.fname);
 	dp.fd = open(dp.fname, OPENFLAGS, MANDMODES);
 	if (dp.fd < 0) {
 		perror("lock test : can't open test file :");
-		terminer(1);
+		finish(1);
 	}
 	P("fd=%d\n", dp.fd);
 	return 0;
 }
 
-struct donneesFils *initClientFork(int i)
+struct dataChild *initClientFork(int i)
 {
-	struct donneesPriv *dpr;
-	struct donneesFils *df;
+	struct dataPriv *dpr;
+	struct dataChild *df;
 
 	/* Initialize private data fields */
-	dpr = malloc(sizeof(struct donneesPriv));
-	df = malloc(sizeof(struct donneesFils));
+	dpr = malloc(sizeof(struct dataPriv));
+	df = malloc(sizeof(struct dataChild));
 	dpr->whoami = i;
 	df->dp = &dp;
 	df->dpr = dpr;
@@ -207,7 +207,7 @@
 	return df;
 }
 
-int initialise(int clnt)
+int initialize(int clnt)
 {
 
 	/* Initialize private data fields */
@@ -217,7 +217,7 @@
 	dp.lthreads = malloc(sizeof(pthread_t) * clnt);
 
 	/* Initialize client to master pipe */
-	if (pipe(dp.maitre) < 0) {
+	if (pipe(dp.master) < 0) {
 		perror("Master pipe creation error\n");
 		exit(1);
 	}
@@ -228,7 +228,7 @@
 	return 0;
 }
 
-void cleanClient(struct donneesFils *df)
+void cleanClient(struct dataChild *df)
 {
 	int i;
 	i = df->dpr->whoami;
@@ -246,13 +246,13 @@
 int loadProcess(void)
 {
 	int i;
-	struct donneesFils *df;
+	struct dataChild *df;
 	for (i = 0; i < dp.nclnt; i++) {
 		df = initClientFork(i);
 		if (!fork()) {
 			P("Running slave num: %d\n", df->dpr->whoami);
 			write(0, ".", 1);
-			esclave((void *)df);
+			slave((void *)df);
 			cleanClient(df);
 			exit(0);
 		}
@@ -278,8 +278,9 @@
 }
 
 /* Final test report */
-void rapport(int clnt)
+int report(int clnt)
 {
+	int rc = 0;
 	int i;
 	int totalClients;
 	totalClients = clnt * (maxClients + 1);
@@ -287,11 +288,15 @@
 	    ("\n%s number : %d - Remote clients: %d local client 1 - Total client %d - Total concurent tests: %d\n",
 	     eType, clnt, maxClients, maxClients + 1, totalClients);
 	printf("%s number running test successfully :\n", eType);
-	for (i = 0; i < MAXTEST; i++)
-		printf("%d %s of %d successfully ran test : %s\n",
-		       TOTAL_RESULTAT_OK[i], eType, totalClients,
-		       LISTE_NOMS_TESTS[i]);
+	for (i = 0; i < MAXTEST; i++) {
+		if (TOTAL_RESULT_OK[i] != totalClients)
+			rc = 1;
 
+		printf("%d %s of %d successfully ran test : %s\n",
+		       TOTAL_RESULT_OK[i], eType, totalClients,
+		       LIST_NAMES_TESTS[i]);
+    }
+    return rc;
 }
 
 int serverSendLocal(void)
@@ -326,19 +331,19 @@
 {
 	int i;
 	for (i = 0; i < dp.nclnt; i++)
-		read(maitreLecteur, message, M_SIZE);
+		read(masterReader, message, M_SIZE);
 	return 0;
 }
 
 int clientReceiveLocal(void)
 {
-	read(esclaveLecteur, message, M_SIZE);
+	read(slaveReader, message, M_SIZE);
 	return 0;
 }
 
 int clientSend(void)
 {
-	write(esclaveEcrivain, message, M_SIZE);
+	write(slaveWriter, message, M_SIZE);
 	return 0;
 }
 
@@ -359,7 +364,7 @@
 /* binary structure <-> ASCII functions used to ensure data will be correctly used over
  * the network, especially when multiples clients do not use the same hardware architecture.
  */
-int serialiseTLock(struct s_test *tLock)
+int serializeTLock(struct s_test *tLock)
 {
 	memset(message, 0, M_SIZE);
 	sprintf(message, "T:%d:%d:%d::", tLock->test, tLock->type,
@@ -367,7 +372,7 @@
 	return 0;
 }
 
-void unSerialiseTLock(struct s_test *tLock)
+void unSerializeTLock(struct s_test *tLock)
 {
 	sscanf(message, "T:%d:%d:%d::", &(tLock->test), &(tLock->type),
 	       &(tLock->resAtt));
@@ -375,7 +380,7 @@
 
 }
 
-void serialiseFLock(struct flock *request)
+void serializeFLock(struct flock *request)
 {
 	int len, pid, start;
 	memset(message, 0, M_SIZE);
@@ -387,19 +392,19 @@
 		request->l_type, request->l_whence, start, len, pid);
 }
 
-void serialiseResult(int resultat)
+void serializeResult(int result)
 {
 	memset(message, 0, M_SIZE);
-	sprintf(message, "R:%d::", resultat);
+	sprintf(message, "R:%d::", result);
 
 }
 
-void unSerialiseResult(int *resultat)
+void unSerializeResult(int *result)
 {
-	sscanf(message, "R:%d::", resultat);
+	sscanf(message, "R:%d::", result);
 }
 
-void unSerialiseFLock(struct flock *request)
+void unSerializeFLock(struct flock *request)
 {
 	int len, pid, start;
 	sscanf(message, "L:%hd:%hd:%d:%d:%d::",
@@ -411,27 +416,27 @@
 
 int serverSendLockClient(struct flock *request, int client)
 {
-	serialiseFLock(request);
+	serializeFLock(request);
 	return serverSendClient(client);
 }
 
-int serverSendLockLocal(struct flock *request, int esclave)
+int serverSendLockLocal(struct flock *request, int slave)
 {
-	serialiseFLock(request);
-	return write(dp.lclnt[esclave][1], message, M_SIZE);
+	serializeFLock(request);
+	return write(dp.lclnt[slave][1], message, M_SIZE);
 }
 
 int getLockSection(struct flock *request)
 {
 	memset(message, 0, M_SIZE);
 	clientReceiveLocal();
-	unSerialiseFLock(request);
+	unSerializeFLock(request);
 	return 0;
 }
 
 int sendLockTest(struct s_test *tLock)
 {
-	serialiseTLock(tLock);
+	serializeTLock(tLock);
 	serverSend();
 	return 0;
 }
@@ -439,13 +444,13 @@
 int getLockTest(struct s_test *tLock)
 {
 	clientReceiveLocal();
-	unSerialiseTLock(tLock);
+	unSerializeTLock(tLock);
 	return 0;
 }
 
-int sendResult(int resultat)
+int sendResult(int result)
 {
-	serialiseResult(resultat);
+	serializeResult(result);
 	clientSend();
 	return 0;
 }
@@ -453,21 +458,21 @@
 int getResults(int ntest)
 {
 	int i, c;
-	int resultat = 0;
+	int result = 0;
 	/* Add remote test results */
 	for (c = 0; c < maxClients; c++) {
 		for (i = 0; i < dp.nclnt; i++) {
 			serverReceiveClient(c);
-			unSerialiseResult(&resultat);
-			compteur(resultat, ntest);
+			unSerializeResult(&result);
+			counter(result, ntest);
 
 		}
 	}
 	/* Add local test results */
 	for (i = 0; i < dp.nclnt; i++) {
-		read(maitreLecteur, message, M_SIZE);
-		unSerialiseResult(&resultat);
-		compteur(resultat, ntest);
+		read(masterReader, message, M_SIZE);
+		unSerializeResult(&result);
+		counter(result, ntest);
 	}
 
 	return 0;
@@ -480,7 +485,7 @@
 /* In the case of a network use, the master of the client application si only
  * a 'repeater' of information. It resends server-master instructions to its own slaves.
  */
-void maitreClient(void)
+void masterClient(void)
 {
 	fd_set fdread;
 	struct timeval tv;
@@ -491,17 +496,17 @@
 	struct flock lock;
 	int t;
 
-	maitreLecteur = dp.maitre[0];
+	masterReader = dp.master[0];
 	FD_ZERO(&fdread);
 	tv.tv_sec = 50;
 	tv.tv_usec = 0;
-	n = fdServeur > maitreLecteur ? fdServeur : maitreLecteur;
-	printf("Maitre CLient - fdServeur=%d\n", fdServeur);
+	n = fdServer > masterReader ? fdServer : masterReader;
+	printf("Master Client - fdServer=%d\n", fdServer);
 	while (1) {
 		/* Add slave and server pipe file descriptors */
 		FD_ZERO(&fdread);
-		FD_SET(fdServeur, &fdread);
-		FD_SET(maitreLecteur, &fdread);
+		FD_SET(fdServer, &fdread);
+		FD_SET(masterReader, &fdread);
 		r = select(n + 1, &fdread, NULL, NULL, &tv);
 		if (r < 0) {
 			perror("select:\n");
@@ -511,7 +516,7 @@
 			exit(0);
 		}
 
-		if (FD_ISSET(fdServeur, &fdread)) {
+		if (FD_ISSET(fdServer, &fdread)) {
 			/* We just have received information from the server.
 			 * We repeat it to slaves.
 			 */
@@ -520,20 +525,20 @@
 			switch (t) {
 			case 'L':
 				/* Lock instruction. We need to send a different section to lock to each process */
-				unSerialiseFLock(&lock);
+				unSerializeFLock(&lock);
 				start = lock.l_start;
 				for (i = 0; i < dp.nclnt; i++) {
 					lock.l_start = start + i;
-					serialiseFLock(&lock);
+					serializeFLock(&lock);
 					write(dp.lclnt[i][1], message, M_SIZE);
 				}
 				printf("\n");
 				continue;
 			case 'T':
-				/* Test instruction. Ensure server is not sending the FIN(ish) instruction to end tests */
+				/* Test instruction. Ensure server is not sending the END(ish) instruction to end tests */
 				/* To be rewritten asap */
 				m = atoi(&(message[2]));
-				if (m == FIN)
+				if (m == END)
 					break;
 				if (m == CLEAN)
 					printf("\n");
@@ -545,8 +550,8 @@
 		} else {
 			/* Else, we read information from slaves and repeat them to the server */
 			for (i = 0; i < dp.nclnt; i++) {
-				r = read(maitreLecteur, message, M_SIZE);
-				r = write(fdServeur, message, M_SIZE);
+				r = read(masterReader, message, M_SIZE);
+				r = write(fdServer, message, M_SIZE);
 				if (r < 0)
 					perror("write : ");
 
@@ -555,10 +560,10 @@
 		}
 	}
 
-	/* Receive the FIN(ish) instruction */
+	/* Receive the END(ish) instruction */
 
 	/* Repeat it to the slaves */
-	printf("Fin du programme en cours...\n");
+	printf("Exitting...\n");
 	serverSendLocal();
 
 	/* Ok, we can quit */
@@ -566,7 +571,7 @@
 
 }
 
-void maitre(void)
+int master(void)
 {
 	int i, n, bl;
 	int clnt;
@@ -576,35 +581,35 @@
 #endif
 	struct flock request;
 	struct s_test tLock;
-	enum etat_t etat;
+	enum state_t state;
 	int offset;
 	/* A test sentence written in the file */
 	char phraseTest[] =
 	    "Ceci est une phrase test ecrite par le maitre dans le fichier";
 	bl = -1;
 	clnt = dp.nclnt;
-	maitreLecteur = dp.maitre[0];
-	etat = SELECT;
+	masterReader = dp.master[0];
+	state = SELECT;
 	/* Start with the first test ;) */
 	n = 0;
 	printf("\n--------------------------------------\n");
 	while (1) {
-		switch (etat) {
+		switch (state) {
 		case SELECT:
 			/* Select the test to perform   */
 			printf("\n");
-			E("Maitre: SELECT");
+			E("Master: SELECT");
 			selectTest(n, &tLock);
-			etat = tLock.type;
+			state = tLock.type;
 			bl = 0;
 			if (n < MAXTEST) {
 				memset(tmp, 0, MAXLEN);
 				sprintf(tmp, "TEST : TRY TO %s:",
-					LISTE_NOMS_TESTS[n]);
+					LIST_NAMES_TESTS[n]);
 				write(0, tmp, strlen(tmp));
 			} else
-				etat = FIN;
-			P("etat=%d\n", etat);
+				state = END;
+			P("state=%d\n", state);
 			n += 1;
 			continue;
 
@@ -612,20 +617,20 @@
 		case WRONLY:
 
 		case READLOCK:
-			P("Read lock :%d\n", etat);
+			P("Read lock :%d\n", state);
 			request.l_type = F_RDLCK;
-			etat = LOCK;
+			state = LOCK;
 			continue;
 
 		case WRITELOCK:
-			P("Write lock :%d\n", etat);
+			P("Write lock :%d\n", state);
 			request.l_type = F_WRLCK;
-			etat = LOCK;
+			state = LOCK;
 			continue;
 
 		case LOCK:
 			/* Apply the wanted lock */
-			E("Maitre: LOCK");
+			E("Master: LOCK");
 			write(dp.fd, phraseTest, strlen(phraseTest));
 			lockWholeFile(&request);
 			if (fcntl(dp.fd, F_SETLK, &request) < 0) {
@@ -633,20 +638,20 @@
 				perror("Echec\n");
 				exit(0);
 			}
-			E("Maitre");
-			etat = SYNC;
+			E("Master");
+			state = SYNC;
 			continue;
 
 		case BYTELOCK_READ:
 			bl = 1;
 			request.l_type = F_RDLCK;
-			etat = SYNC;
+			state = SYNC;
 			continue;
 
 		case BYTELOCK_WRITE:
 			bl = 1;
 			request.l_type = F_WRLCK;
-			etat = SYNC;
+			state = SYNC;
 			continue;
 
 		case BYTELOCK:
@@ -659,7 +664,7 @@
 			 */
 
 			/* Create a string to record in the test file. Length is exactly the number of sub process */
-			P("Maitre: BYTELOCK: %d\n", etat);
+			P("Master: BYTELOCK: %d\n", state);
 			buf = malloc(clnt * (maxClients + 1));
 			memset(buf, '*', clnt);
 			write(dp.fd, buf, clnt);
@@ -683,34 +688,34 @@
 				request.l_start = i;
 				serverSendLockLocal(&request, i);
 			}
-			etat = RESULTAT;
+			state = RESULT;
 			continue;
 
 		case SYNC:
 			sendLockTest(&tLock);
 			if (bl) {
-				etat = BYTELOCK;
+				state = BYTELOCK;
 				continue;
 			}
 
 			if (n < MAXTEST + 1)
-				etat = RESULTAT;
+				state = RESULT;
 			else
-				etat = FIN;
+				state = END;
 			continue;
 
-		case RESULTAT:
+		case RESULT:
 			/* Read results by one */
 			getResults(n - 1);
 			if (bl)
-				validationResultats(n - 1);
-			etat = CLEAN;
+				validationResults(n - 1);
+			state = CLEAN;
 			continue;
 
 		case CLEAN:
 			/* Ask the clients to stop testing ... */
 			tLock.test = CLEAN;
-			serialiseTLock(&tLock);
+			serializeTLock(&tLock);
 			serverSend();
 			/* ... and wait for an ack before closing */
 			serverReceive();
@@ -719,11 +724,11 @@
 			/* close and open file */
 			close(dp.fd);
 			initTest();
-			etat = SELECT;
+			state = SELECT;
 			continue;
-		case FIN:
-			tLock.test = FIN;
-			serialiseTLock(&tLock);
+		case END:
+			tLock.test = END;
+			serializeTLock(&tLock);
 			serverSend();
 			sleep(2);
 			break;
@@ -735,15 +740,15 @@
 		break;
 	}
 
-	rapport(clnt);
+	return report(clnt);
 }
 
 /* Slave process/thread */
 
-void *esclave(void *donnees)
+void *slave(void *data)
 {
-	struct donneesFils *df;
-	int i, a, resultat, ftest;
+	struct dataChild *df;
+	int i, a, result, ftest;
 	struct s_test tLock;
 	struct flock request;
 	char tmp[16];
@@ -752,34 +757,34 @@
 #endif
 	char *phraseTest = "L'ecriture a reussi";
 	int len;
-	enum etat_t etat;
+	enum state_t state;
 
-	resultat = -1;
+	result = -1;
 	ftest = -1;
 	len = strlen(phraseTest);
-	df = (struct donneesFils *)donnees;
+	df = (struct dataChild *)data;
 	i = df->dpr->whoami;
-	P("Esclave n=%d\n", i);
-	esclaveLecteur = dp.lclnt[i][0];
-	esclaveEcrivain = dp.maitre[1];
-	etat = SYNC;
+	P("Slave n=%d\n", i);
+	slaveReader = dp.lclnt[i][0];
+	slaveWriter = dp.master[1];
+	state = SYNC;
 	errno = 0;
 	memset(tmp, 0, 16);
 	while (1) {
-		switch (etat) {
+		switch (state) {
 		case SELECT:
 		case SYNC:
 			getLockTest(&tLock);
-			etat = tLock.test;
-			P("Esclave Etat=%d\n", etat);
+			state = tLock.test;
+			P("Slave State=%d\n", state);
 
 			continue;
 		case RDONLY:
 			/* Try to read a file */
 			P("TEST READ ONLY %d\n", RDONLY);
 			if ((ftest = open(dp.fname, O_RDONLY | O_NONBLOCK)) < 0) {
-				resultat = ECHEC;
-				etat = RESULTAT;
+				result = ECHEC;
+				state = RESULT;
 				if (dp.verbose)
 					perror("Open:");
 				continue;
@@ -787,28 +792,28 @@
 			P("fd=%d\n", ftest);
 			a = read(ftest, tmp, 16);
 			if (a < 16)
-				resultat = ECHEC;
+				result = ECHEC;
 			else
-				resultat = SUCCES;
-			etat = RESULTAT;
+				result = SUCCES;
+			state = RESULT;
 			continue;
 
 		case WRONLY:
 			/* Try to write a file */
 			P("TEST WRITE ONLY %d\n", WRONLY);
 			if ((ftest = open(dp.fname, O_WRONLY | O_NONBLOCK)) < 0) {
-				resultat = ECHEC;
-				etat = RESULTAT;
+				result = ECHEC;
+				state = RESULT;
 				if (dp.verbose)
 					perror("Open read only:");
 				continue;
 			}
 			P("fd=%d\n", ftest);
 			if (write(ftest, phraseTest, len) < len)
-				resultat = ECHEC;
+				result = ECHEC;
 			else
-				resultat = SUCCES;
-			etat = RESULTAT;
+				result = SUCCES;
+			state = RESULT;
 			continue;
 
 		case LOCK:
@@ -817,8 +822,8 @@
 			/* Try to read a read-locked section */
 			P("READ LOCK %d\n", F_RDLCK);
 			if ((ftest = open(dp.fname, O_RDONLY | O_NONBLOCK)) < 0) {
-				resultat = ECHEC;
-				etat = RESULTAT;
+				result = ECHEC;
+				state = RESULT;
 				if (dp.verbose)
 					perror("Open read-write:");
 				continue;
@@ -834,18 +839,18 @@
 			if (fcntl(ftest, F_SETLK, &request) < 0) {
 				if (dp.verbose || errno != EAGAIN)
 					perror("RDONLY: fcntl");
-				resultat = ECHEC;
+				result = ECHEC;
 			} else
-				resultat = SUCCES;
-			etat = RESULTAT;
+				result = SUCCES;
+			state = RESULT;
 			continue;
 
 		case WRITELOCK:
 			/* Try to write a file */
 			P("WRITE LOCK %d\n", F_WRLCK);
 			if ((ftest = open(dp.fname, O_WRONLY | O_NONBLOCK)) < 0) {
-				resultat = ECHEC;
-				etat = RESULTAT;
+				result = ECHEC;
+				state = RESULT;
 				if (dp.verbose)
 					perror("\nOpen:");
 				continue;
@@ -860,29 +865,29 @@
 			if (fcntl(ftest, F_SETLK, &request) < 0) {
 				if (dp.verbose || errno != EAGAIN)
 					perror("\nWRONLY: fcntl");
-				resultat = ECHEC;
+				result = ECHEC;
 			} else
-				resultat = SUCCES;
-			etat = RESULTAT;
+				result = SUCCES;
+			state = RESULT;
 			continue;
 
 		case BYTELOCK_READ:
-			P("BYTE LOCK READ: %d\n", etat);
-			etat = BYTELOCK;
+			P("BYTE LOCK READ: %d\n", state);
+			state = BYTELOCK;
 			continue;
 
 		case BYTELOCK_WRITE:
-			P("BYTE LOCK WRITE: %d\n", etat);
-			etat = BYTELOCK;
+			P("BYTE LOCK WRITE: %d\n", state);
+			state = BYTELOCK;
 			continue;
 
 		case BYTELOCK:
 			/* Wait for the exact section to lock. The whole file is sent by the master */
-			P("BYTE LOCK %d\n", etat);
+			P("BYTE LOCK %d\n", state);
 			getLockSection(&request);
 			if ((ftest = open(dp.fname, O_RDWR | O_NONBLOCK)) < 0) {
-				resultat = ECHEC;
-				etat = RESULTAT;
+				result = ECHEC;
+				state = RESULT;
 				if (dp.verbose)
 					perror("\nOpen:");
 				continue;
@@ -891,39 +896,39 @@
 			if (fcntl(ftest, F_SETLK, &request) < 0) {
 				if (dp.verbose || errno != EAGAIN)
 					perror("\nBTLOCK: fcntl");
-				resultat = ECHEC;
-				etat = RESULTAT;
+				result = ECHEC;
+				state = RESULT;
 				continue;
 			}
 			/* Change the character at the given position for an easier verification */
 			a = lseek(ftest, request.l_start, SEEK_SET);
 			write(ftest, "=", 1);
-			resultat = SUCCES;
-			etat = RESULTAT;
+			result = SUCCES;
+			state = RESULT;
 			continue;
 
-		case RESULTAT:
-			if (resultat == SUCCES)
+		case RESULT:
+			if (result == SUCCES)
 				write(0, "=", 1);
 			else
 				write(0, "x", 1);
-			P("RESULTAT: %d\n", resultat);
-			sendResult(resultat);
-			etat = SYNC;
+			P("RESULT: %d\n", result);
+			sendResult(result);
+			state = SYNC;
 			continue;
 
 		case CLEAN:
 			close(ftest);
 			/* Send CLEAN Ack */
-			sendResult(resultat);
-			etat = SYNC;
+			sendResult(result);
+			state = SYNC;
 			continue;
 
-		case FIN:
+		case END:
 			E("(End)\n");
-			terminer(0);
+			finish(0);
 			printf("Unknown command\n");
-			terminer(1);
+			finish(1);
 
 		}
 	}
@@ -943,14 +948,13 @@
 {
 	printf("locktest -n <number of process> -f <test file> [-T]\n");
 	printf("Number of child process must be higher than 1\n");
-	printf("\n");
-	printf("Send bugs to vincent.roqueta@ext.bull.net\n");
 	exit(0);
 	return 0;
 }
 
 int main(int argc, char **argv)
 {
+	int rc = 0;
 	int i, nThread = 0;
 	char *tmp;
 	int type = 0;
@@ -958,7 +962,7 @@
 	type = PROCESS;
 	dp.fname = NULL;
 	dp.verbose = 0;
-	int serveur = 1;
+	int server = 1;
 	char *host;
 
 	host = NULL;
@@ -991,17 +995,17 @@
 		if (!strcmp("--server", argv[i])) {
 			if (!(host = nextArg(argc, argv, &i)))
 				usage();
-			serveur = 0;
+			server = 0;
 			continue;
 		}
 		printf("Ignoring unknown option: %s\n", argv[i]);
 	}
 
-	if (serveur) {
+	if (server) {
 		if (!(dp.fname && nThread))
 			usage();
 		if (clients > 0) {
-			configureServeur(clients);
+			configureServer(clients);
 			setupClients(type, dp.fname, nThread);
 		}
 	} else {
@@ -1015,17 +1019,16 @@
 		printf("By process.\n");
 	load = loadProcess;
 	eType = "process";
-	terminer = terminerProcess;
-	LISTE_RESULTATS = LISTE_RESULTATS_PROCESS;
-	initialise(nThread);
-	if (serveur) {
-		maitre();
-
+	finish = finishProcess;
+	LIST_RESULTS = LIST_RESULTS_PROCESS;
+	initialize(nThread);
+	if (server) {
+		rc = master();
 	} else {
-		maitreClient();
+		masterClient();
 		free(dp.fname);
 	}
 	clean();
 
-	return 0;
+	return rc;
 }
diff --git a/testcases/network/nfsv4/locks/locktests.h b/testcases/network/nfsv4/locks/locktests.h
index eba856a..e26c730 100644
--- a/testcases/network/nfsv4/locks/locktests.h
+++ b/testcases/network/nfsv4/locks/locktests.h
@@ -102,15 +102,15 @@
 int serverSendClient(int n);
 
 
-enum etat_t     {
+enum state_t     {
                 CLEAN,
                 RDONLY,
-                RESULTAT,
+                RESULT,
                 WRONLY,
                 SELECT,
                 LOCK,
                 SYNC,
-                FIN,
+                END,
                 READLOCK,
                 WRITELOCK,
                 BYTELOCK,
@@ -119,13 +119,13 @@
 };
 
 /* Public data */
-struct donneesPub {
+struct dataPub {
     /* Number of clients */
     int nclnt;
     /* List of master to slave pipes */
     int **lclnt;
     /* Slave to master pipe */
-    int maitre[2];
+    int master[2];
     /* Thread list */
     pthread_t *lthreads;
     /* test file name */
@@ -137,14 +137,14 @@
 };
 
 /* private data */
-struct donneesPriv {
+struct dataPriv {
     /* thread number */
     int whoami;
 };
 
-struct donneesFils{
-    struct donneesPub *dp;
-    struct donneesPriv *dpr;
+struct dataChild{
+    struct dataPub *dp;
+    struct dataPriv *dpr;
 };
 
 
@@ -159,7 +159,7 @@
 
 
 
-int configureServeur(int  max);
+int configureServer(int  max);
 int configureClient(char *s);
 
 #endif
diff --git a/testcases/network/nfsv4/locks/netsync.c b/testcases/network/nfsv4/locks/netsync.c
index f53b347..b40c002 100644
--- a/testcases/network/nfsv4/locks/netsync.c
+++ b/testcases/network/nfsv4/locks/netsync.c
@@ -7,8 +7,8 @@
 
 int maxClients;
 int *fdClient;
-char *serveur;
-int fdServeur;
+char *server_name;
+int fdServer;
 extern char message[M_SIZE];
 
 int serverReceiveClient(int c)
@@ -41,7 +41,7 @@
 	return 0;
 }
 
-int setupConnectionServeur(void)
+int setupConnectionServer(void)
 {
 	struct sockaddr_in local;
 	int c;
@@ -119,12 +119,12 @@
 	return 0;
 }
 
-int configureServeur(int max)
+int configureServer(int max)
 {
 	maxClients = max;
 	fdClient = malloc(sizeof(int) * max);
 
-	setupConnectionServeur();
+	setupConnectionServer();
 
 	return 0;
 }
@@ -135,13 +135,13 @@
 	struct hostent *server;
 	struct sockaddr_in serv_addr;
 
-	if (!(server = gethostbyname(serveur))) {
+	if (!(server = gethostbyname(server_name))) {
 		printf("erreur DNS\n");
 		return 1;
 	}
 
-	fdServeur = socket(AF_INET, SOCK_STREAM, 0);
-	if (fdServeur < 0) {
+	fdServer = socket(AF_INET, SOCK_STREAM, 0);
+	if (fdServer < 0) {
 		perror("socket");
 		return 1;
 	}
@@ -149,7 +149,7 @@
 	serv_addr.sin_addr = *(struct in_addr *)server->h_addr;
 	serv_addr.sin_port = htons(PORT);
 	serv_addr.sin_family = AF_INET;
-	if (connect(fdServeur, (struct sockaddr *)&serv_addr, sizeof(serv_addr))
+	if (connect(fdServer, (struct sockaddr *)&serv_addr, sizeof(serv_addr))
 	    < 0) {
 		perror("connect");
 		return 1;
@@ -167,7 +167,7 @@
 	r = 0;
 	s = 0;
 	while (s < M_SIZE) {
-		r = read(fdServeur, tmp, M_SIZE - s);
+		r = read(fdServer, tmp, M_SIZE - s);
 		/* Loop until we have a complete message */
 		strncpy(message + s, tmp, r);
 		s += r;
@@ -195,7 +195,7 @@
 
 int configureClient(char *s)
 {
-	serveur = s;
+	server_name = s;
 	setupConnectionClient();
 	return 0;
 }
diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc01 b/testcases/network/rpc/basic_tests/rpc01/rpc01
index 8ed69b0..fd8915a 100755
--- a/testcases/network/rpc/basic_tests/rpc01/rpc01
+++ b/testcases/network/rpc/basic_tests/rpc01/rpc01
@@ -1,132 +1,62 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# 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 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 would 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.
 #
-#   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             : rpc01
-#
-#  TEST DESCRIPTION : Test rpc using file transfers between a client & server
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-this_file=${0##*/}
-TC=${TC:=rpc01}
-TCbin=${TCbin:=$LTPROOT/testcases/bin}
-TCdat=${TCdat:=$LTPROOT/testcases/data/rpc01}
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+TCID="rpc01"
+TST_TOTAL=6
+TST_CLEANUP=do_cleanup
+
+. test_net.sh
+
 NUMLOOPS=${NUMLOOPS:=3}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
 DATAFILES=${DATAFILES:="file.1 file.2"}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
 
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-do_test()
-{
-    $trace_logic
-
-    # Start server process
-    rsh -n $RHOST $TCbin/rpc_server
-    PID1=`rsh -n $RHOST ps -ewf | grep rpc_server | grep -v grep | awk '{print $2 }'`
-    echo "The rpc_server PID is $PID1"
-    # Start client process
-    echo "Starting $TC"
-    COUNT=1
-    while [ $COUNT -le $NUMLOOPS ]
-    do
-      for FILE in $DATAFILES
-      do
-	rpc1 -s $RHOST -f $TCdat/$FILE
-	[ $? -eq 0 ] || end_testcase "Fail on using $FILE"
-      done
-      COUNT=`expr $COUNT + 1`
-    done
-}
-
-
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
 do_cleanup()
 {
-    $trace_logic
-
-    if [ "$CLEANUP" = "ON" ]; then
-	if [ -f $TMPDIR/core ]; then
-	   echo "Core file is saved in /tmp"
-	   mv $TMPDIR/core /tmp
-	fi
-
-	# Kill server
-        rsh -n $RHOST kill -9 $PID1
-    fi
+	pkill -9 rpc_server > /dev/null 2>&1
 }
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
+do_setup()
 {
-   $trace_logic
-   echo "$this_file: doing $0."
+	tst_resm TINFO "start rpc_server"
+	rpc_server
 
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+	tst_resm TINFO "wait for server to be registered"
+	for i in $(seq 1 30); do
+		rpcinfo -T udp $(tst_ipaddr) 2000333 10 >/dev/null 2>&1 && break
+		[ "$i" -eq 30 ] && tst_brkm TBROK "server not registered"
+		tst_sleep 100ms
+	done
 }
 
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
+do_test()
+{
+	local thost="$(tst_ipaddr)"
 
+	tst_resm TINFO "starting client process"
+	local cnt=1
+	while [ $cnt -le $NUMLOOPS ]; do
+		for f in $DATAFILES; do
+			EXPECT_RHOST_PASS rpc1 -s $thost -f $LTP_DATAROOT/$f
+		done
+		cnt=$(($cnt + 1))
+	done
+}
+
+do_setup
 do_test
-do_cleanup
-end_testcase
 
+tst_exit
diff --git a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01 b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01
index cb063d8..6fe3639 100755
--- a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01
+++ b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01
@@ -1,289 +1,80 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
+# 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.
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# This program is distributed in the hope that it would 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.
 #
-#   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             : rpcinfo
-#
-#  TEST DESCRIPTION : Basic test for the `rpcinfo` command.
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/20/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#    11/20/08 Aime Le Rouzic (aime.lerouzic@bull.net)
-#      - Adapt to rpcbind
-#
-# CMD      FLAG      ARGS
-# rpcinfo   -p
-# rpcinfo   -p       rem_host
-# rpcinfo   -b
-# rpcinfo   -d       prog_num   ver_num
-# rpcinfo   -t       rem_host   prog_num
-# rpcinfo   -t       rem_host   prog_num     ver_num
-# rpcinfo   -t       rem_host   prog_name
-# rpcinfo   -t       rem_host   prog_name    ver_num
-# rpcinfo   -u       rem_host   prog_num
-# rpcinfo   -u       rem_host   prog_num     ver_num
-# rpcinfo   -u       rem_host   prog_name
-# rpcinfo   -u       rem_host   prog_name    ver_num
-# rpcinfo
-# rpcinfo   -bogus_flag
-# rpcinfo   -u         rem_host
-# rpcinfo   -u         rem_host   bogus_prog   ver_num
-# rpcinfo   -u         rem_host   prog_num     bogus_num
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-$trace_logic
-this_file=${0##*/}
-TC=rpcinfo01
-TCtmp=${TCtmp:=`pwd`}
-TCbin=${TCbin:=`pwd`}
-TCsrc=${TCsrc:=$TCbin}
-LUSER=${LUSER:=root}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
-PID=0
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
+TCID="rpcinfo01"
+TST_TOTAL=16
+TST_CLEANUP=tst_rmdir
 
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
+. test_net.sh
+
+do_setup()
+{
+	tst_resm TINFO "Checking for portmap or rpcbind"
+
+	if pgrep portmap > /dev/null; then
+		PORTMAPPER="portmap"
+	else
+		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
+			tst_brkm TCONF "portmap or rpcbind is not running"
+	fi
+
+	tst_tmpdir
+
+	# Create file with 1 tcp and 1 udp line. Use for variable assignments.
+	rpcinfo -p $(tst_ipaddr) | grep tcp | sed -n 2p > rpc_out
+	rpcinfo -p $(tst_ipaddr) | grep udp | sed -n 2p >> rpc_out
+
+	wc -l rpc_out | grep "2" > /dev/null || \
+		tst_brkm TBROK "Not enough programs registered on $(tst_ipaddr)"
+
+	# Using "rpc_out" file created above, assign variables for rpcinfo opts
+	TPNUM=`grep tcp rpc_out | awk '{print $1}'`
+	TVNUM=`grep tcp rpc_out | awk '{print $2}'`
+	TCPNAME=`grep tcp rpc_out | awk '{print $5}'`
+	UPNUM=`grep udp rpc_out | awk '{print $1}'`
+	UVNUM=`grep udp rpc_out | awk '{print $2}'`
+	UDPNAME=`grep udp rpc_out | awk '{print $5}'`
+}
+
 do_test()
 {
-$trace_logic
+	local thost="$(tst_ipaddr)"
 
-echo "Checking for portmap or rpcbind daemon on `hostname` and $RHOST"
-ps -ewf | grep portmap | grep -v grep > /dev/null
-if [ $? -eq 0 ]
-then
-	PORTMAPPER="portmap"
-else
-	ps -ewf | grep rpcbind | grep -v grep > /dev/null
-	if [ $? -eq 0 ]
-	then
-		PORTMAPPER="rpcbind"
-	else
-		echo "The portmap or rpcbind daemon is NOT running"
-	fi
-fi
+	EXPECT_RHOST_PASS rpcinfo -p $thost | grep -q portmapper
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM $TVNUM
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME $TVNUM
+	EXPECT_RHOST_PASS rpcinfo -u $thost 100000
+	EXPECT_RHOST_PASS rpcinfo -u $thost 100000 2
+	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper
+	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper 2
 
-rsh -n $RHOST "ps -ewf" | grep portmap | grep -v grep > /dev/null
-[ $? -eq 0 ] || rsh -n $RHOST "ps -ewf" | grep rpcbind | grep -v grep > /dev/null
-[ $? -eq 0 ] || end_testcase "The portmap or rpcbind daemon is NOT running on $RHOST"
-
-echo "Test rpcinfo with default options"
-echo "rpcinfo -p"
-rpcinfo -p $RHOST | grep portmapper
-[ $? -eq 0 ] || end_testcase "rpcinfo -p failed"
-
-echo "Test rpcinfo with options"
-
-
-# Create file with 1 tcp and 1 udp line. Use for variable assignments.
-rpcinfo -p $RHOST | grep tcp | sed -n 2p > $TCtmp/rpc_out
-rpcinfo -p $RHOST | grep udp | sed -n 2p >> $TCtmp/rpc_out
-
-wc -l $TCtmp/rpc_out | grep "2" > /dev/null
-[ $? -eq 0 ] || end_testcase "Not enough programs registered on $RHOST for test"
-
-# Using "rpc_out" file created above, assign variables for rpcinfo options.
-TPNUM=`grep tcp $TCtmp/rpc_out | awk '{print $1}'`
-TVNUM=`grep tcp $TCtmp/rpc_out | awk '{print $2}'`
-TCPNAME=`grep tcp $TCtmp/rpc_out | awk '{print $5}'`
-UPNUM=`grep udp $TCtmp/rpc_out | awk '{print $1}'`
-UVNUM=`grep udp $TCtmp/rpc_out | awk '{print $2}'`
-UDPNAME=`grep udp $TCtmp/rpc_out | awk '{print $5}'`
-
-# Go through the matrix of remaining rpcinfo options
-
-# -b option
-echo "rpcinfo -b <prog num> <ver num>"
-rpcinfo -b $UPNUM $UVNUM &
-sleep 5
-[ $? -eq 0 ] || end_testcase "rpcinfo -b <prog num> <ver num> - failed"
-PID=$!
-kill -9 $PID > /dev/null 2>&1
-PID=0
-
-# -d option
-ps -ewf | grep rusersd | grep -v grep
-if [ $? = 1 ]; then
-  /usr/sbin/rpc.rusersd
-  if [ $? = 0 ]; then
-    rpcinfo -p | grep 100002
-    echo "rpcinfo -d <prog num> <ver num>"
-    rpcinfo -d 100002 3
-    rpcinfo -p | grep 100002
-    rpcinfo -p | grep 100002 | wc -l | grep "1" > /dev/null
-    [ $? = 0 ] || end_testcase "rpcinfo -d <prog num> <ver num> - failed"
-    RUSERSD_PID=`ps -ewf | grep rusersd | grep -v grep | awk '{print $2}'`
-    kill -9 $RUSERSD_PID > /dev/null 2>&1
-  else
-    echo "Could not start rusersd daemon...skipping -d option test"
-  fi
-else
-  echo "rusersd is currently running, so may be used...skipping -d option test"
-fi
-
-# -t options
-echo "rpcinfo -t <hostname> <tcp prog num>"
-rpcinfo -t $RHOST $TPNUM
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog num> - failed"
-
-echo "rpcinfo -t <hostname> <tcp prog num> <ver num>"
-rpcinfo -t $RHOST $TPNUM $TVNUM
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog num> <ver num> - failed"
-
-echo "rpcinfo -t <hostname> <tcp prog name>"
-rpcinfo -t $RHOST $TCPNAME
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog name> -  failed"
-
-echo "rpcinfo -t <hostname> <tcp prog name> <ver num>"
-rpcinfo -t $RHOST $TCPNAME $TVNUM
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog name> <ver num> - failed"
-
-# -u options
-echo "rpcinfo -u <hostname> <udp prog num>"
-rpcinfo -u $RHOST 100000
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog num> - failed"
-
-echo "rpcinfo -u <hostname> <udp prog num> <ver num>"
-rpcinfo -u $RHOST 100000 2
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog num> <ver num> - failed"
-
-echo "rpcinfo -u <hostname> <udp prog name>"
-rpcinfo -u $RHOST portmapper
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog name> - failed"
-
-echo "rpcinfo -u <hostname> <udp prog name> <ver num>"
-rpcinfo -u $RHOST portmapper 2
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog name> <ver num> - failed"
-
-echo "Test rpcinfo with missing or bad options"
-
-# Check the following: noflag, bogushost, bogusflag, no prog for -u or -t,
-# bogusprog, 99999 as versnum.
-
-echo "rpcinfo <no flags>"
-case $PORTMAPPER in
-	portmap)
-		rpcinfo
-		[ $? -eq 1 ] || end_testcase "rpcinfo <no flags> should fail"
-		;;
-	rpcbind)
-		rpcinfo
-		[ $? -eq 0 ]|| end_testcase "rpcinfo <no flags> should not fail"
-		;;
-	*)
-		echo " portmap or rpcbind not running"
-		exit 1
-		;;
-esac
-
-echo "rpcinfo -p <bad hostname>"
-rpcinfo -p bogushost
-[ $? -eq 1 ] || end_testcase "rpcinfo <bad hostname> should fail"
-
-echo "rpcinfo <bad flag>"
-rpcinfo -bogusflag
-[ $? -eq 1 ] || end_testcase "rpcinfo <bad flag> should fail"
-
-echo "rpcinfo -t <hostname> <no prognum>"
-rpcinfo -t $RHOST
-[ $? -eq 1 ] || end_testcase "rpcinfo -t <hostname> <no prognum> should fail"
-
-echo "rpcinfo -u <hostname> <no prognum>"
-rpcinfo -u $RHOST
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> <no prognum> should fail"
-
-echo "rpcinfo -u <hostname> <bad prog name>"
-rpcinfo -u $RHOST bogusprog
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> <invalid program name> should fail"
-
-echo "rpcinfo -u <hostname> <bad prog num>"
-rpcinfo -u $RHOST 11579
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> 11579 should fail"
-
-echo "rpcinfo -u <hostname> <prog num> <bad ver num>"
-rpcinfo -u $RHOST 100000 5
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> <prog num> <bad ver num> should fail"
+	tst_resm TINFO "Test rpcinfo with missing or bad options"
+	EXPECT_RHOST_FAIL rpcinfo -p bogushost
+	EXPECT_RHOST_FAIL rpcinfo -bogusflag
+	EXPECT_RHOST_FAIL rpcinfo -t $thost
+	EXPECT_RHOST_FAIL rpcinfo -u $thost
+	EXPECT_RHOST_FAIL rpcinfo -u $thost bogusprog
+	EXPECT_RHOST_FAIL rpcinfo -u $thost 11579
+	EXPECT_RHOST_FAIL rpcinfo -u $thost 100000 5
 }
 
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_cleanup()
-{
-    $trace_logic
-
-    if [ "$PID" != 0 ]; then
-      kill -9 $PID
-    fi
-    rm -f $TCtmp/rpc_out
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-   if [ "$CLEANUP" = "ON" ]; then
-     do_cleanup
-   fi
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
-}
-
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
+do_setup
 do_test
-end_testcase
+
+tst_exit
diff --git a/testcases/network/rpc/basic_tests/rup/rup01 b/testcases/network/rpc/basic_tests/rup/rup01
index 99916d4..2340dea 100755
--- a/testcases/network/rpc/basic_tests/rup/rup01
+++ b/testcases/network/rpc/basic_tests/rup/rup01
@@ -1,174 +1,49 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
+# 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.
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# This program is distributed in the hope that it would 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.
 #
-#   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             : rup
-#
-#  TEST DESCRIPTION : Basic test for the `rup` command.
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-# CMD      FLAG      ARGS
-# rup
-# rup                rem_host
-# rup	    -d
-# rup       -h
-# rup       -t
-# rup       -l
-# rup                bogus_host
-# rup      -bogus_flag
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-$trace_logic
-this_file=${0##*/}
-TC=rup01
-TCtmp=${TCtmp:=`pwd`}
-TCbin=${TCbin:=`pwd`}
-TCsrc=${TCsrc:=$TCbin}
-LUSER=${LUSER:=root}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
-PID=0
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
+TCID="rup01"
+TST_TOTAL=7
 
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
+. test_net.sh
+
+do_setup()
+{
+	tst_resm TINFO "Checking for rstatd on $(tst_ipaddr)"
+	rpcinfo -u $(tst_ipaddr) rstatd 3 > /dev/null 2>&1 || \
+		tst_brkm TCONF "rstatd is inactive on $(tst_ipaddr)"
+}
+
 do_test()
 {
-$trace_logic
+	tst_resm TINFO "Test rup with options set"
 
-echo "Checking for rstatd on $RHOST"
+	EXPECT_RHOST_PASS rup $(tst_ipaddr)
 
-rpcinfo -u $RHOST rstatd 3 > /dev/null 2>&1
-if [ $? -ne 0 ]; then
-  echo "Attempting to start rstatd on $RHOST"
-  rsh -n -l root $RHOST "/usr/sbin/rpc.rstatd &"
-  [ $? -eq 0 ] || end_testcase "rstatd is inactive on $RHOST"
-  PID=`rsh -n $RHOST ps -ewf | grep rstatd | awk '{print $2 }'`
-  echo "rstatd started on $RHOST"
-fi
+	local opts="-d -h -l -t"
+	for opt in $opts; do
+		EXPECT_RHOST_PASS rup $opt $(tst_ipaddr)
+	done
 
-echo "Test rup with defaults....please be patient"
-# rusers with no options broadcasts over the net and reports
-# responses as it receives them. Time-out for responses is approx. 2 minutes.
-
-echo "rup"
-rup
-[ $? -eq 0 ] || end_testcase "rup with defaults - failed"
-
-echo "Test rusers with options set...please be patient"
-# Go through matrix of rup options:
-
-echo "rup $RHOST"
-rup $RHOST | grep $RHOST
-[ $? -eq 0 ] || end_testcase "rup $RHOST - failed"
-
-echo "rup -d"
-rup -d
-[ $? -eq 0 ] || end_testcase "rup -d - failed"
-
-echo "rup -h"
-rup -h
-[ $? -eq 0 ] || end_testcase "rup -h - failed"
-
-echo "rup -l"
-rup -l
-[ $? -eq 0 ] || end_testcase "rup -l - failed"
-
-echo "rup -t"
-rup -t
-[ $? -eq 0 ] || end_testcase "rup -t - failed"
-
-echo "Test rusers with bad options"
-echo "rup <invalid hostname>"
-rup bogushost > /dev/null 2>&1
-[ $? -ne 0 ] || end_testcase "rup <invalid hostname> should fail"
-
-echo "rup -<invalid flag>"
-rup -bogusflag > /dev/null 2>&1
-[ $? -eq 1 ] || end_testcase "rup -<invalid flag> should fail"
+	tst_resm TINFO "Test rup with bad options"
+	EXPECT_RHOST_FAIL rup bogushost
+	EXPECT_RHOST_FAIL rup -bogusflag $(tst_ipaddr)
 }
 
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_cleanup()
-{
-    $trace_logic
-
-    if [ "$PID" != 0 ]; then
-        # Kill rup on remote machine
-        rsh -n $RHOST kill -15 $PID
-        echo "rstatd daemon stopped on $RHOST"
-    fi
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-   if [ "$CLEANUP" = "ON" ]; then
-     do_cleanup
-   fi
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
-}
-
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
+do_setup
 do_test
-end_testcase
+
+tst_exit
diff --git a/testcases/network/rpc/basic_tests/rusers/rusers01 b/testcases/network/rpc/basic_tests/rusers/rusers01
index 0b28c9e..9f20a85 100755
--- a/testcases/network/rpc/basic_tests/rusers/rusers01
+++ b/testcases/network/rpc/basic_tests/rusers/rusers01
@@ -1,168 +1,49 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
+# 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.
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# This program is distributed in the hope that it would 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.
 #
-#   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             : rusers
-#
-#  TEST DESCRIPTION : Basic test for the `rusers` command.
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-# CMD      FLAG      ARGS
-# rusers
-# rusers             RHOST
-# rusers    -a
-# rusers    -a       RHOST
-# rusers    -l
-# rusers    -l       RHOST
-# rusers             bogus_host
-# rusers   -bogus_flag
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-$trace_logic
-this_file=${0##*/}
+TCID="rusers01"
+TST_TOTAL=5
 
-TC=rusers
-TCtmp=${TCtmp:=`pwd`}
-TCbin=${TCbin:=`pwd`}
-TCsrc=${TCsrc:=$TCbin}
-LUSER=${LUSER:=root}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
-PID=0
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
+. test_net.sh
 
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
+do_setup()
+{
+	tst_resm TINFO "Checking for rusersd on $(tst_ipaddr)"
+	rpcinfo -u $(tst_ipaddr) rusersd > /dev/null 2>&1 || \
+		tst_brkm TCONF "rusersd is inactive on $(tst_ipaddr)"
+}
+
 do_test()
 {
-$trace_logic
+	tst_resm TINFO "Test rusers with options set"
 
-echo "Checking for rusersd on $RHOST"
+	EXPECT_RHOST_PASS rusers $(tst_ipaddr)
 
-rpcinfo -u $RHOST rusersd > /dev/null 2>&1
-if [ $? -ne 0 ]; then
-  echo "Attempting to start rusersd on $RHOST"
-  rsh -n -l root $RHOST "/usr/sbin/rpc.rusersd &"
-  [ $? -eq 0 ] || end_testcase "rusersd is inactive on $RHOST"
-  PID=`rsh -n $RHOST ps -ewf | grep rusersd | awk '{print $2 }'`
-  echo "ruserd started on $RHOST"
-fi
+	local opts="-a -l"
+	for opt in $opts; do
+		EXPECT_RHOST_PASS rusers $opt $(tst_ipaddr)
+	done
 
-#RHOST=`echo $RHOST | cut -d. -f1`   //The use is depriciated as it fails when RHOST is set to an IP address
-#                                    //Pointed out by "Ambar Seksena" <ambar.seksena@calsoftinc.com>
-
-echo "Test rusers with defaults...please be patient"
-# rusers with no options broadcasts over the net and reports
-# responses as it receives them. Time-out for responses is approx. 2 minutes.
-
-rusers > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers with defaults - failed"
-
-echo "Test rusers with options set...please be patient"
-# Go through matrix of rusers options:
-
-rusers $RHOST > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers $RHOST - failed"
-
-rusers -a $RHOST > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers -a $RHOST - failed"
-
-rusers -l > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers -l - failed"
-
-rusers -l $RHOST > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers -l $RHOST - failed"
-
-echo "Test rusers with bad options"
-
-rusers bogushost > /dev/null 2>&1
-[ $? -eq 1 ] || end_testcase "rusers <invalid hostname> should fail"
-
-rusers -bogusflag > /dev/null 2>&1
-[ $? -eq 1 ] || end_testcase "rusers -<invalid flag> should fail"
+	tst_resm TINFO "Test rusers with bad options"
+	EXPECT_RHOST_FAIL rusers bogushost
+	EXPECT_RHOST_FAIL rusers -bogusflag $(tst_ipaddr)
 }
 
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_cleanup()
-{
-    $trace_logic
-
-    if [ "$PID" != 0 ]; then
-        # Kill rusersd on remote machine
-        rsh -n $RHOST kill -9 $PID
-        echo "rusersd daemon stopped on $RHOST"
-    fi
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-   if [ "$CLEANUP" = "ON" ]; then
-     do_cleanup
-   fi
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
-}
-
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
+do_setup
 do_test
-end_testcase
+
+tst_exit
diff --git a/testcases/network/rpc/rpc-tirpc/rpc_test.sh b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
index e265725..54ea4fd 100755
--- a/testcases/network/rpc/rpc-tirpc/rpc_test.sh
+++ b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
@@ -26,7 +26,6 @@
 CLEANER=""
 # Program number to register the services to rpcbind
 PROGNUMNOSVC=536875000
-SERVER_STARTUP_SLEEP=1
 
 cleanup()
 {
@@ -57,7 +56,7 @@
 
 while getopts s:c:e:h arg; do
 	case $arg in
-		s) SERVER="$LTPROOT/testcases/bin/$OPTARG" ;;
+		s) SERVER="$OPTARG" ;;
 		c) CLIENT="$OPTARG" ;;
 		e) CLIENT_EXTRA_OPTS="$OPTARG" ;;
 		h) usage ;;
@@ -66,9 +65,9 @@
 
 if [ ! -z "$SERVER" ]; then
 	if `echo "$SERVER" | grep -e '^tirpc'`; then
-		CLEANER="$LTPROOT/testcases/bin/tirpc_cleaner"
+		CLEANER="tirpc_cleaner"
 	else
-		CLEANER="$LTPROOT/testcases/bin/rpc_cleaner"
+		CLEANER="rpc_cleaner"
 	fi
 fi
 
@@ -87,11 +86,14 @@
 
 if [ ! -z "$SERVER" ]; then
 	$SERVER $PROGNUMNOSVC &
-	sleep "$SERVER_STARTUP_SLEEP"
+
+	for i in $(seq 1 10); do
+		rpcinfo -p localhost | grep -q $PROGNUMNOSVC && break
+		[ "$i" -eq 30 ] && tst_brkm TBROK "server not registered"
+		tst_sleep 100ms
+	done
 fi
 
-tst_rhost_run -sc "$CLIENT $(tst_ipaddr) $PROGNUMNOSVC $CLIENT_EXTRA_OPTS"
-
-tst_resm TPASS "Test passed"
+EXPECT_RHOST_PASS $CLIENT $(tst_ipaddr) $PROGNUMNOSVC $CLIENT_EXTRA_OPTS
 
 tst_exit
diff --git a/testcases/network/sctp/Makefile b/testcases/network/sctp/Makefile
new file mode 100644
index 0000000..914e389
--- /dev/null
+++ b/testcases/network/sctp/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= sctp01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/sctp/sctp01.sh b/testcases/network/sctp/sctp01.sh
new file mode 100755
index 0000000..1d9bcb8
--- /dev/null
+++ b/testcases/network/sctp/sctp01.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+
+TCID=sctp01
+TST_TOTAL=3
+TST_CLEANUP="cleanup"
+
+. test_net.sh
+
+cleanup()
+{
+	tst_rmdir
+}
+
+setup()
+{
+	tst_require_root
+	tst_tmpdir
+}
+
+test_run()
+{
+	tst_resm TINFO "compare TCP/SCTP performance"
+
+	tst_netload -H $(tst_ipaddr rhost) -a 3 -R 3 -T tcp
+	local res0="$(cat tst_netload.res)"
+
+	tst_netload -H $(tst_ipaddr rhost) -a 3 -R 3 -T sctp
+	local res1="$(cat tst_netload.res)"
+
+	local per=$(( $res0 * 100 / $res1 - 100 ))
+
+	if [ "$per" -gt "100" -o "$per" -lt "-100" ]; then
+		tst_resm TFAIL "sctp performance $per %"
+	else
+		tst_resm TPASS "sctp performance $per % in range -100 ... 100 %"
+	fi
+}
+
+setup
+test_run
+
+tst_exit
diff --git a/testcases/network/stress/README b/testcases/network/stress/README
index fbfbc1c..c0d0ad3 100644
--- a/testcases/network/stress/README
+++ b/testcases/network/stress/README
@@ -23,7 +23,7 @@
 
 Test Links are the place where the stress tests run. For example, test packets
 flow those links. The number of test links must be at least 1. The setting of
-the interfaces connectted to the test links would be changed by the tests.
+the interfaces connected to the test links would be changed by the tests.
 Therefore, each test link should not belong to any external network. It is
 recommended to connect each pair of interfaces with the ether cross cables.
 
@@ -136,13 +136,13 @@
 
  o LHOST_HWADDRS
    The blank-separated hardware address list of the interfaces which are
-   connectted to a test link at the local host.
+   connected to a test link at the local host.
    This value have to have at least one address. The sequence of the hardware
    address have to be same to the test link sequence.
 
  o RHOST_HWADDRS
    The blank-separated hardware address list of the interfaces which are
-   connectted to a test link at the remote host.
+   connected to a test link at the remote host.
    This value have to have at least one address. The sequence of the hardware
    address have to be same to the test link sequence.
 
diff --git a/testcases/network/stress/broken_ip/broken_ip4-checksum b/testcases/network/stress/broken_ip/broken_ip4-checksum
index 33667ba..ff30fbf 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-checksum
+++ b/testcases/network/stress/broken_ip/broken_ip4-checksum
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -c
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip4-dstaddr b/testcases/network/stress/broken_ip/broken_ip4-dstaddr
index b4b676e..eb236f2 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-dstaddr
+++ b/testcases/network/stress/broken_ip/broken_ip4-dstaddr
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -i
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip4-fragment b/testcases/network/stress/broken_ip/broken_ip4-fragment
index dbef193..8f2aca9 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-fragment
+++ b/testcases/network/stress/broken_ip/broken_ip4-fragment
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -f
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip4-ihl b/testcases/network/stress/broken_ip/broken_ip4-ihl
index 48deb3b..2e136a5 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-ihl
+++ b/testcases/network/stress/broken_ip/broken_ip4-ihl
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -l
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip4-protcol b/testcases/network/stress/broken_ip/broken_ip4-protcol
index b4b767c..a57ce61 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-protcol
+++ b/testcases/network/stress/broken_ip/broken_ip4-protcol
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -p
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip4-totlen b/testcases/network/stress/broken_ip/broken_ip4-totlen
index 051d969..4466487 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-totlen
+++ b/testcases/network/stress/broken_ip/broken_ip4-totlen
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -L
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip4-version b/testcases/network/stress/broken_ip/broken_ip4-version
index c3ccf7f..83cf568 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-version
+++ b/testcases/network/stress/broken_ip/broken_ip4-version
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -v
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip6-dstaddr b/testcases/network/stress/broken_ip/broken_ip6-dstaddr
index 5da38ab..ea7d66d 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-dstaddr
+++ b/testcases/network/stress/broken_ip/broken_ip6-dstaddr
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -i
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip6-nexthdr b/testcases/network/stress/broken_ip/broken_ip6-nexthdr
index bb1bdcb..ebbef5e 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-nexthdr
+++ b/testcases/network/stress/broken_ip/broken_ip6-nexthdr
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -n
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip6-plen b/testcases/network/stress/broken_ip/broken_ip6-plen
index 8eacbf4..e93cdcc 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-plen
+++ b/testcases/network/stress/broken_ip/broken_ip6-plen
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -L
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip6-version b/testcases/network/stress/broken_ip/broken_ip6-version
index cdce71f..3eff2d7 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-version
+++ b/testcases/network/stress/broken_ip/broken_ip6-version
@@ -27,6 +27,6 @@
 
 tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -v
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/icmp/icmp-uni-basic.sh b/testcases/network/stress/icmp/icmp-uni-basic.sh
index 2aae945..78017ee 100755
--- a/testcases/network/stress/icmp/icmp-uni-basic.sh
+++ b/testcases/network/stress/icmp/icmp-uni-basic.sh
@@ -27,7 +27,6 @@
 
 LINK_NUM=${LINK_NUM:-0}
 DO_IPSEC=${DO_IPSEC:-false}
-IPSEC_SIZE_ARRAY="${IPSEC_SIZE_ARRAY:-10 100 1000 10000 65507}"
 [ -n "$IPSEC_MODE" -a -n "$IPSEC_PROTO" ] && DO_IPSEC=true || DO_IPSEC=false
 
 # Test description
@@ -56,11 +55,8 @@
 	tst_ipsec rhost $rhost_addr $lhost_addr
 fi
 
+PING_MAX="$IPSEC_REQUESTS"
+
 tst_ping $lhost_ifname $rhost_addr $IPSEC_SIZE_ARRAY
-if [ $? -ne 0 ]; then
-	tst_resm TFAIL "Checked IPv${TST_IPV6:-4} $IPSEC_PROTO $IPSEC_MODE"
-else
-	tst_resm TPASS "Checked IPv${TST_IPV6:-4} $IPSEC_PROTO $IPSEC_MODE"
-fi
 
 tst_exit
diff --git a/testcases/network/stress/icmp/icmp-uni-vti.sh b/testcases/network/stress/icmp/icmp-uni-vti.sh
index a87ca55..7fa211d 100755
--- a/testcases/network/stress/icmp/icmp-uni-vti.sh
+++ b/testcases/network/stress/icmp/icmp-uni-vti.sh
@@ -22,50 +22,16 @@
 
 . ipsec_lib.sh
 
-do_setup()
-{
-	IPSEC_SIZE_ARRAY="${IPSEC_SIZE_ARRAY:-10 100 1000 10000 65507}"
-
-	if_loc=$(tst_iface)
-	if_rmt=$(tst_iface rhost)
-
-	ip_loc=$(tst_ipaddr)
-	ip_rmt=$(tst_ipaddr rhost)
-
-	tst_vti="ltp_vti0"
-
-	tst_resm TINFO "Test vti$TST_IPV6 + IPsec[$IPSEC_PROTO/$IPSEC_MODE]"
-
-	tst_ipsec_vti lhost $ip_loc $ip_rmt $tst_vti
-	tst_ipsec_vti rhost $ip_rmt $ip_loc $tst_vti
-
-	local mask=
-	if [ "$TST_IPV6" ]; then
-		ip_loc_tun="${IPV6_NET32_UNUSED}::1";
-		ip_rmt_tun="${IPV6_NET32_UNUSED}::2";
-		mask=64
-		ROD ip -6 route add ${IPV6_NET32_UNUSED}::/$mask dev $tst_vti
-	else
-		ip_loc_tun="${IPV4_NET16_UNUSED}.1.1";
-		ip_rmt_tun="${IPV4_NET16_UNUSED}.1.2";
-		mask=30
-		ROD ip route add ${IPV4_NET16_UNUSED}.1.0/$mask dev $tst_vti
-	fi
-
-	tst_resm TINFO "Add IPs to vti tunnel, " \
-		       "loc: $ip_loc_tun/$mask, rmt: $ip_rmt_tun/$mask"
-
-	ROD ip a add $ip_loc_tun/$mask dev $tst_vti
-	tst_rhost_run -s -c "ip a add $ip_rmt_tun/$mask dev $tst_vti"
-}
-
 do_test()
 {
+	PING_MAX="$IPSEC_REQUESTS"
+
 	tst_resm TINFO "Sending ICMP messages..."
-	EXPECT_PASS tst_ping $tst_vti $ip_rmt_tun $IPSEC_SIZE_ARRAY
+	tst_ping $tst_vti $ip_rmt_tun $IPSEC_SIZE_ARRAY
 }
 
-do_setup
+tst_ipsec_setup_vti
+
 do_test
 
 tst_exit
diff --git a/testcases/network/stress/icmp/multi-diffip/icmp4-multi-diffip01 b/testcases/network/stress/icmp/multi-diffip/icmp4-multi-diffip01
index ad2da16..fe70f00 100644
--- a/testcases/network/stress/icmp/multi-diffip/icmp4-multi-diffip01
+++ b/testcases/network/stress/icmp/multi-diffip/icmp4-multi-diffip01
@@ -177,7 +177,7 @@
     x=`expr $ipaddr_pair_num \/ 255 % 255`
     y=`expr $ipaddr_pair_num % 255`
     if [ $x -ge 255 ]; then
-	tst_info TINFO "This script cannot add more than $ipaddr_pair_num addresses"
+	tst_resm TINFO "This script cannot add more than $ipaddr_pair_num addresses"
 	break
     fi
 
diff --git a/testcases/network/stress/interface/if-addr-adddel b/testcases/network/stress/interface/if-addr-adddel
index dcc018a..4a0501e 100644
--- a/testcases/network/stress/interface/if-addr-adddel
+++ b/testcases/network/stress/interface/if-addr-adddel
@@ -18,21 +18,14 @@
 # Author: Mitsuru Chinen <mitch@jp.ibm.com>
 
 TST_TOTAL=2
-TCID=if-addr-adddel
 
-. if-lib.sh
+TST_CLEANUP="netstress_cleanup"
 
-TST_CLEANUP="do_cleanup"
+. test_net_stress.sh
 
 # The interval of the check interface activity
 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
 
-do_cleanup()
-{
-	cleanup
-	restore_ipaddr
-}
-
 test_body()
 {
 	local cmd_type=$1
@@ -60,10 +53,9 @@
 		return
 	fi
 
-	make_background_tcp_traffic
-
 	local cnt=1
 	while [ $cnt -le $NS_TIMES ]; do
+		make_background_tcp_traffic
 
 		case $cmd_type in
 		if_cmd)
@@ -88,13 +80,10 @@
 			return
 		fi
 
-		check_connectivity $cnt || return
+		check_connectivity_interval $cnt || return
 
 		cnt=$(($cnt + 1))
 
-		# Check the background TCP traffic
-		pgrep -x netstress > /dev/null || make_background_tcp_traffic
-
 		case $cmd_type in
 		if_cmd)
 			if [ "$TST_IPV6" ]; then
@@ -122,7 +111,7 @@
 	tst_resm TPASS "Test is finished correctly"
 }
 
-setup
+netstress_setup
 
 tst_check_cmds ifconfig
 
diff --git a/testcases/network/stress/interface/if-addr-addlarge b/testcases/network/stress/interface/if-addr-addlarge
index 9e55006..a81cf61 100644
--- a/testcases/network/stress/interface/if-addr-addlarge
+++ b/testcases/network/stress/interface/if-addr-addlarge
@@ -18,21 +18,14 @@
 # Author: Mitsuru Chinen <mitch@jp.ibm.com>
 
 TST_TOTAL=2
-TCID=if-addr-addlarge
 
-. if-lib.sh
+TST_CLEANUP="netstress_cleanup"
 
-TST_CLEANUP="do_cleanup"
+. test_net_stress.sh
 
 # The interval of the check interface activity
 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IP_TOTAL / 20))}
 
-do_cleanup()
-{
-	cleanup
-	restore_ipaddr
-}
-
 test_body()
 {
 	local cmd_type=$1
@@ -54,8 +47,6 @@
 		return
 	fi
 
-	make_background_tcp_traffic
-
 	local x=1
 	local y=1
 	local cnt=1
@@ -68,6 +59,7 @@
 	fi
 
 	while [ $cnt -le $IP_TOTAL ]; do
+		make_background_tcp_traffic
 
 		if [ "$TST_IPV6" ]; then
 			local hex_x=$(printf '%x' $x)
@@ -100,11 +92,7 @@
 			return
 		fi
 
-		# Check the connectivity
-		check_connectivity $cnt || return
-
-		# Check the background TCP traffic
-		pgrep -x netstress > /dev/null || make_background_tcp_traffic
+		check_connectivity_interval $cnt || return
 
 		case $cmd_type in
 		if_cmd)
@@ -143,7 +131,7 @@
 	tst_resm TPASS "Test is finished correctly"
 }
 
-setup
+netstress_setup
 
 tst_check_cmds ifconfig
 
diff --git a/testcases/network/stress/interface/if-lib.sh b/testcases/network/stress/interface/if-lib.sh
deleted file mode 100644
index 4168dd0..0000000
--- a/testcases/network/stress/interface/if-lib.sh
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/sh
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
-#
-# 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 would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
-
-TST_CLEANUP="cleanup"
-
-. test_net.sh
-
-ipver=${TST_IPV6:-4}
-
-IPV4_NET16_UNUSED=${IPV4_NET16_UNUSED:-"10.23"}
-IPV6_NET32_UNUSED=${IPV6_NET32_UNUSED:-"fd00:23"}
-
-setup()
-{
-	tst_require_root
-	tst_check_cmds ip pgrep pkill
-	trap "tst_brkm TBROK 'test interrupted'" INT
-}
-
-cleanup()
-{
-	# Stop the background TCP traffic
-	pkill -13 -x netstress
-	tst_rhost_run -c "pkill -13 -x netstress"
-}
-
-make_background_tcp_traffic()
-{
-	port=$(tst_get_unused_port ipv${ipver} stream)
-	netstress -R 3 -g $port > /dev/null 2>&1 &
-	tst_rhost_run -b -c "netstress -l -H $(tst_ipaddr) -g $port"
-}
-
-check_connectivity()
-{
-	local cnt="$1"
-	local restore="$2"
-
-	[ $CHECK_INTERVAL -eq 0 ] && return
-	[ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && return
-
-	tst_resm TINFO "check connectivity through $(tst_iface) on step $cnt"
-
-	[ -n "$restore" ] && restore_ipaddr
-
-	tst_ping
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "$(tst_iface) is broken"
-		return 1
-	fi
-	return 0
-}
-
-restore_ipaddr()
-{
-	tst_restore_ipaddr || return $?
-	tst_wait_ipv6_dad
-}
diff --git a/testcases/network/stress/interface/if-mtu-change b/testcases/network/stress/interface/if-mtu-change
index 637fa63..15293c4 100644
--- a/testcases/network/stress/interface/if-mtu-change
+++ b/testcases/network/stress/interface/if-mtu-change
@@ -18,14 +18,14 @@
 # Author: Mitsuru Chinen <mitch@jp.ibm.com>
 
 TST_TOTAL=2
-TCID=if-mtu-change
-
-. if-lib.sh
 
 TST_CLEANUP="do_cleanup"
 
+. test_net_stress.sh
+
 # The interval of the mtu change [second]
 CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
+
 # The array of the value which MTU is changed into sequentially
 # 552 - net.ipv4.route.min_pmtu
 CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500"
@@ -35,7 +35,7 @@
 
 do_cleanup()
 {
-	cleanup
+	netstress_cleanup
 	if [ "$saved_mtu" ]; then
 		ip li set $(tst_iface) mtu $saved_mtu
 		tst_rhost_run -c "ip li set $(tst_iface rhost) mtu $saved_mtu"
@@ -59,11 +59,9 @@
 	local iface_rmt=$(tst_iface rhost)
 	[ "$TST_IPV6" ] && local netmask=64 || local netmask=16
 
-	tst_resm TINFO "'$cmd_name changes MTU $MTU_CHANGE_TIMES times " \
+	tst_resm TINFO "'$cmd_name changes MTU $MTU_CHANGE_TIMES times" \
 	               "every $CHANGE_INTERVAL seconds"
 
-	make_background_tcp_traffic
-
 	mtu_array_len=$(echo $CHANGE_VALUES | wc -w)
 	local cnt=0
 	while [ $cnt -lt $MTU_CHANGE_TIMES ]; do
@@ -73,6 +71,8 @@
 		mtu=$(echo $CHANGE_VALUES | cut -d ' ' -f $field)
 		[ $cnt -eq $MTU_CHANGE_TIMES ] && mtu="$saved_mtu"
 
+		make_background_tcp_traffic
+
 		tst_resm TINFO "set MTU to $mtu $cnt/$MTU_CHANGE_TIMES"
 		local ret=0
 		case $cmd_type in
@@ -91,14 +91,11 @@
 
 		tst_sleep $CHANGE_INTERVAL
 
-		EXPECT_PASS tst_ping $(tst_ipaddr) $(tst_ipaddr rhost) "1 1000 65507"
-
-		# Check the background TCP traffic
-		pgrep -x netstress > /dev/null || make_background_tcp_traffic
+		tst_ping $(tst_ipaddr) $(tst_ipaddr rhost) "1 1000 65507"
 	done
 }
 
-setup
+netstress_setup
 
 tst_check_cmds ifconfig
 
diff --git a/testcases/network/stress/interface/if-route-adddel b/testcases/network/stress/interface/if-route-adddel
index 4516741..8c1dfee 100644
--- a/testcases/network/stress/interface/if-route-adddel
+++ b/testcases/network/stress/interface/if-route-adddel
@@ -18,20 +18,13 @@
 # Author: Mitsuru Chinen <mitch@jp.ibm.com>
 
 TST_TOTAL=2
-TCID=if-route-adddel
 
-. if-lib.sh
+TST_CLEANUP="netstress_cleanup"
 
-TST_CLEANUP="do_cleanup"
+. test_net_stress.sh
 
 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
 
-do_cleanup()
-{
-	cleanup
-	restore_ipaddr
-}
-
 test_body()
 {
 	local cmd_type=$1
@@ -47,10 +40,10 @@
 	local new_rt=
 	local opt_rt=
 	if [ "$TST_IPV6" ]; then
-		new_rt=${IPV6_NET32_UNUSED}::
+		new_rt="$(TST_IPV6=6 tst_ipaddr_un 0)"
 		opt_rt="/64"
 	else
-		new_rt="${IPV4_NET16_UNUSED}.23.0"
+		new_rt="$(tst_ipaddr_un 23)"
 		case $cmd_type in
 		rt_cmd) ;;
 		ip_cmd) opt_rt='/24' ;;
@@ -64,10 +57,10 @@
 		return
 	fi
 
-	make_background_tcp_traffic
-
 	local cnt=1
 	while [ $cnt -le $NS_TIMES ]; do
+		make_background_tcp_traffic
+
 		case $cmd_type in
 		rt_cmd) route -A $inet add ${new_rt}${opt_rt} dev $iface ;;
 		ip_cmd) ip route add ${new_rt}${opt_rt} dev $iface ;;
@@ -86,10 +79,7 @@
 			return
 		fi
 
-		check_connectivity $cnt || return
-
-		# Check the background TCP traffic
-		pgrep -x netstress > /dev/null || make_background_tcp_traffic
+		check_connectivity_interval $cnt || return
 
 		cnt=$(($cnt + 1))
 	done
@@ -97,7 +87,7 @@
 	tst_resm TPASS "Test is finished correctly"
 }
 
-setup
+netstress_setup
 
 tst_check_cmds route
 
diff --git a/testcases/network/stress/interface/if-route-addlarge b/testcases/network/stress/interface/if-route-addlarge
index e83cf60..eee0959 100644
--- a/testcases/network/stress/interface/if-route-addlarge
+++ b/testcases/network/stress/interface/if-route-addlarge
@@ -18,20 +18,13 @@
 # Author: Mitsuru Chinen <mitch@jp.ibm.com>
 
 TST_TOTAL=2
-TCID=if-route-addlarge
 
-. if-lib.sh
+TST_CLEANUP="netstress_cleanup"
 
-TST_CLEANUP="do_cleanup"
+. test_net_stress.sh
 
 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 20))}
 
-do_cleanup()
-{
-	cleanup
-	restore_ipaddr
-}
-
 test_body()
 {
 	local cmd_type=$1
@@ -61,8 +54,6 @@
 		return
 	fi
 
-	make_background_tcp_traffic
-
 	local x=1
 	local y=1
 	local cnt=1
@@ -75,6 +66,7 @@
 	fi
 
 	while [ $cnt -le $ROUTE_TOTAL ]; do
+		make_background_tcp_traffic
 
 		if [ "$TST_IPV6" ]; then
 			local hex_x=$(printf '%x' $x)
@@ -93,10 +85,7 @@
 			return
 		fi
 
-		check_connectivity $cnt || return
-
-		# Check the background TCP traffic
-		pgrep -x netstress > /dev/null || make_background_tcp_traffic
+		check_connectivity_interval $cnt || return
 
 		cnt=$(($cnt + 1))
 		y=$(($y + 1))
@@ -112,7 +101,7 @@
 	tst_resm TPASS "Test is finished correctly"
 }
 
-setup
+netstress_setup
 
 tst_check_cmds route
 
diff --git a/testcases/network/stress/interface/if-updown b/testcases/network/stress/interface/if-updown
index deefef6..264331a 100644
--- a/testcases/network/stress/interface/if-updown
+++ b/testcases/network/stress/interface/if-updown
@@ -18,9 +18,10 @@
 # Author: Mitsuru Chinen <mitch@jp.ibm.com>
 
 TST_TOTAL=2
-TCID=if-updown
 
-. if-lib.sh
+TST_CLEANUP="netstress_cleanup"
+
+. test_net_stress.sh
 
 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 20))}
 
@@ -59,7 +60,7 @@
 			return
 		fi
 
-		check_connectivity $cnt restore_ip || return
+		check_connectivity_interval $cnt restore_ip || return
 
 		cnt=$(($cnt + 1))
 	done
@@ -67,7 +68,7 @@
 	tst_resm TPASS "Test is finished correctly"
 }
 
-setup
+netstress_setup
 
 tst_check_cmds ifconfig
 
diff --git a/testcases/network/stress/interface/if4-addr-change b/testcases/network/stress/interface/if4-addr-change
index 54b8fd5..a665b85 100644
--- a/testcases/network/stress/interface/if4-addr-change
+++ b/testcases/network/stress/interface/if4-addr-change
@@ -21,12 +21,12 @@
 TCID=if4-addr-change
 TST_CLEANUP="do_cleanup"
 
-. test_net.sh
-
 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
 # Maximum host portion of the IPv4 address on the local host
 LHOST_IPV4_HOST_MAX="254"
 
+. test_net.sh
+
 do_cleanup()
 {
 	tst_restore_ipaddr
@@ -48,12 +48,19 @@
 
 	[ $num -eq $RHOST_IPV4_HOST ] && continue
 
-	# Change IPv4 address
-	lhost_ipv4addr="${IPV4_NETWORK}.${num}"
+	# check prefix and fix values for prefix != 24
+	add_to_net=
+	if [ $IPV4_LPREFIX -lt 8 -o $IPV4_LPREFIX -ge 32 ] ; then
+		tst_brkm TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)"
+	elif [ $IPV4_LPREFIX -lt 16 ]; then # N.x.x.num
+		add_to_net=".0.1"
+	elif [ $IPV4_LPREFIX -lt 24 ]; then # N.N.x.num
+		add_to_net=".1"
+	fi
 
-	ifconfig $(tst_iface) $lhost_ipv4addr netmask 255.255.255.0 \
-		broadcast 255.255.255.255 || \
-		tst_brkm TFAIL "Failed to change into ${lhost_ipv4addr}"
+	# Change IPv4 address
+	ROD ifconfig $(tst_iface) ${IPV4_LNETWORK}${add_to_net}.${num} netmask \
+		$IPV4_LNETMASK broadcast $IPV4_LBROADCAST
 
 	cnt=$(($cnt + 1))
 
@@ -61,9 +68,9 @@
 	[ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue
 
 	tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES"
-	EXPECT_PASS tst_ping
+	tst_ping
 done
 
-EXPECT_PASS tst_ping
+tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
index 5cb8483..e05edee 100644
--- a/testcases/network/stress/ipsec/ipsec_lib.sh
+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
@@ -30,7 +30,10 @@
 # Compression algorithm
 CALGO="deflate"
 
-while getopts "hl:m:p:s:S:k:A:e:a:c:6" opt; do
+IPSEC_REQUESTS="500"
+IPSEC_SIZE_ARRAY="${IPSEC_SIZE_ARRAY:-10 100 1000 2000 10000 65000}"
+
+while getopts "hl:m:p:s:S:k:A:e:a:c:r:6" opt; do
 	case "$opt" in
 	h)
 		echo "Usage:"
@@ -45,6 +48,7 @@
 		echo "e x      Encryption algorithm"
 		echo "a x      Authentication algorithm"
 		echo "c x      Compression algorithm"
+		echo "r x      Num of requests, PING_MAX or netstress' '-r' opt"
 		echo "6        run over IPv6"
 		exit 0
 	;;
@@ -58,6 +62,7 @@
 	e) EALGO=$OPTARG ;;
 	a) AALGO=$OPTARG ;;
 	c) CALGO=$OPTARG ;;
+	r) IPSEC_REQUESTS="$OPTARG" ;;
 	6) # skip, test_net library already processed it
 	;;
 	*) tst_brkm TBROK "unknown option: $opt" ;;
@@ -153,6 +158,18 @@
 	esac
 }
 
+ipsec_try()
+{
+	local output="$($@ 2>&1 || echo 'TERR')"
+
+	if echo "$output" | grep -q "TERR"; then
+		echo "$output" | grep -q \
+			'RTNETLINK answers: Function not implemented' && \
+			tst_brkm TCONF "'$@': not implemented"
+		tst_brkm TBROK "$@ failed: $output"
+	fi
+}
+
 # tst_ipsec target src_addr dst_addr: config ipsec
 #
 # target: target of the configuration host ( lhost / rhost )
@@ -176,7 +193,7 @@
 	if [ $target = lhost ]; then
 		local spi_1="0x$SPI"
 		local spi_2="0x$(( $SPI + 1 ))"
-		ROD ip xfrm state add src $src dst $dst spi $spi_1 \
+		ipsec_try ip xfrm state add src $src dst $dst spi $spi_1 \
 			$p $ALG mode $mode sel src $src dst $dst
 		ROD ip xfrm state add src $dst dst $src spi $spi_2 \
 			$p $ALG mode $mode sel src $dst dst $src
@@ -241,7 +258,7 @@
 
 		local spi_1="spi 0x$SPI"
 		local spi_2="spi 0x$(( $SPI + 1 ))"
-		ROD $ipx st add $o_dir $p $spi_1 $ALG $m
+		ipsec_try $ipx st add $o_dir $p $spi_1 $ALG $m
 		ROD $ipx st add $i_dir $p $spi_2 $ALG $m
 		ROD $ipx po add dir out tmpl $o_dir $p $m $mrk
 		ROD $ipx po add dir in tmpl $i_dir $p $m $mrk
@@ -258,3 +275,43 @@
 		tst_rhost_run -s -c "$ipx po add dir in tmpl $i_dir $p $m $mrk"
 	fi
 }
+
+# Setup vti/vti6 interface for IPsec tunneling
+# The function sets variables:
+#  * tst_vti - vti interface name,
+#  * ip_loc_tun - local IP address on vti interface
+#  * ip_rmt_tun - remote IP address
+tst_ipsec_setup_vti()
+{
+	if_loc=$(tst_iface)
+	if_rmt=$(tst_iface rhost)
+
+	ip_loc=$(tst_ipaddr)
+	ip_rmt=$(tst_ipaddr rhost)
+
+	tst_vti="ltp_vti0"
+
+	tst_resm TINFO "Test vti$TST_IPV6 + IPsec[$IPSEC_PROTO/$IPSEC_MODE]"
+
+	tst_ipsec_vti lhost $ip_loc $ip_rmt $tst_vti
+	tst_ipsec_vti rhost $ip_rmt $ip_loc $tst_vti
+
+	local mask=
+	if [ "$TST_IPV6" ]; then
+		ip_loc_tun="${IPV6_NET32_UNUSED}::1";
+		ip_rmt_tun="${IPV6_NET32_UNUSED}::2";
+		mask=64
+		ROD ip -6 route add ${IPV6_NET32_UNUSED}::/$mask dev $tst_vti
+	else
+		ip_loc_tun="${IPV4_NET16_UNUSED}.1.1";
+		ip_rmt_tun="${IPV4_NET16_UNUSED}.1.2";
+		mask=30
+		ROD ip route add ${IPV4_NET16_UNUSED}.1.0/$mask dev $tst_vti
+	fi
+
+	tst_resm TINFO "Add IPs to vti tunnel, " \
+		       "loc: $ip_loc_tun/$mask, rmt: $ip_rmt_tun/$mask"
+
+	ROD ip a add $ip_loc_tun/$mask dev $tst_vti nodad
+	tst_rhost_run -s -c "ip a add $ip_rmt_tun/$mask dev $tst_vti"
+}
diff --git a/testcases/network/stress/multicast/grp-operation/00_Descriptions.txt b/testcases/network/stress/multicast/grp-operation/00_Descriptions.txt
index 9d73372..22177fd 100644
--- a/testcases/network/stress/multicast/grp-operation/00_Descriptions.txt
+++ b/testcases/network/stress/multicast/grp-operation/00_Descriptions.txt
@@ -1,33 +1,33 @@
-mcast4-grpope01
+mcast4-group-single-socket
 	Verify that the kernel is not crashed when joining lots of IPv4
 	multicast groups on a single socket
 
-mcast4-grpope02
+mcast4-group-multiple-socket
 	Verify that the kernel is not crashed when joining lots of IPv4
 	multicast groups on lots of sockets
 
-mcast4-grpope03
+mcast4-group-same-group
 	Verify that the kernel is not crashed when joining and leaving the same
 	IPv4 multicast group on multiple sockets lots of times
 
-mcast4-grpope04
+mcast4-group-source-filter
 	Verify that the kernel is not crashed when joining and leaving the same
 	IPv4 multicast group with the different source filter on multiple
 	sockets lots of times
 
-mcast6-grpope01
+mcast6-group-single-socket
 	Verify that the kernel is not crashed when joining lots of IPv6
 	multicast groups on a single socket
 
-mcast6-grpope02
+mcast6-group-multiple-socket
 	Verify that the kernel is not crashed when joining lots of IPv6
 	multicast groups on lots of sockets
 
-mcast6-grpope03
+mcast6-group-same-group
 	Verify that the kernel is not crashed when joining and leaving the same
 	IPv6 multicast group on multiple sockets lots of times
 
-mcast6-grpope04
+mcast6-group-source-filter
 	Verify that the kernel is not crashed when joining and leaving the same
 	IPv6 multicast group with the different source filter on multiple
 	sockets lots of times
diff --git a/testcases/network/stress/multicast/grp-operation/mcast-group-multiple-socket b/testcases/network/stress/multicast/grp-operation/mcast-group-multiple-socket
new file mode 100644
index 0000000..84700a5
--- /dev/null
+++ b/testcases/network/stress/multicast/grp-operation/mcast-group-multiple-socket
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (c) International Business Machines  Corp., 2006
+# Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Setup: testcases/network/stress/README
+#
+# Author: Mitsuru Chinen <mitch@jp.ibm.com>
+
+. mcast-lib.sh
+
+tst_resm TINFO "joining $MCASTNUM_HEAVY IPv$ipver multicast groups on multiple sockets"
+
+do_setup()
+{
+	# Increase the maximum number of open file descriptors
+	if [ $(ulimit -n) -lt $MCASTNUM_HEAVY ]; then
+		ulimit -n $MCASTNUM_HEAVY || tst_brkm TCONF \
+			"Failed to set the maximum number of open file descriptors to $MCASTNUM_HEAVY"
+	fi
+
+	mcast_setup $MCASTNUM_HEAVY
+}
+
+do_setup
+do_multicast_test_multiple_join $MCASTNUM_HEAVY true
+tst_exit
diff --git a/testcases/network/stress/multicast/grp-operation/mcast-group-same-group b/testcases/network/stress/multicast/grp-operation/mcast-group-same-group
new file mode 100644
index 0000000..876c395
--- /dev/null
+++ b/testcases/network/stress/multicast/grp-operation/mcast-group-same-group
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (c) International Business Machines  Corp., 2006
+# Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Setup: testcases/network/stress/README
+#
+# Author: Mitsuru Chinen <mitch@jp.ibm.com>
+
+. mcast-lib.sh
+
+tst_resm TINFO "joining and leaving the same IPv$ipver multicast group on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
+
+mcast_setup $MCASTNUM_NORMAL
+do_multicast_test_join_leave $MCASTNUM_NORMAL
+tst_exit
diff --git a/testcases/network/stress/multicast/grp-operation/mcast-group-single-socket b/testcases/network/stress/multicast/grp-operation/mcast-group-single-socket
new file mode 100644
index 0000000..d6b3363
--- /dev/null
+++ b/testcases/network/stress/multicast/grp-operation/mcast-group-single-socket
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (c) International Business Machines  Corp., 2006
+# Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Setup: testcases/network/stress/README
+#
+# Author: Mitsuru Chinen <mitch@jp.ibm.com>
+
+. mcast-lib.sh
+
+tst_resm TINFO "joining $MCASTNUM_HEAVY IPv$ipver multicast groups on a single socket"
+
+mcast_setup $MCASTNUM_HEAVY
+do_multicast_test_multiple_join $MCASTNUM_HEAVY
+tst_exit
diff --git a/testcases/network/stress/multicast/grp-operation/mcast-group-source-filter b/testcases/network/stress/multicast/grp-operation/mcast-group-source-filter
new file mode 100644
index 0000000..34ed143
--- /dev/null
+++ b/testcases/network/stress/multicast/grp-operation/mcast-group-source-filter
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (c) International Business Machines  Corp., 2006
+# Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Setup: testcases/network/stress/README
+#
+# Author: Mitsuru Chinen <mitch@jp.ibm.com>
+
+. mcast-lib.sh
+
+tst_resm TINFO "joining and leaving the same IPv$ipver multicast group with a different source filters on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
+
+mcast_setup $MCASTNUM_NORMAL
+do_multicast_test_join_leave $MCASTNUM_NORMAL true
+tst_exit
diff --git a/testcases/network/stress/multicast/grp-operation/mcast-lib.sh b/testcases/network/stress/multicast/grp-operation/mcast-lib.sh
new file mode 100644
index 0000000..6cc2922
--- /dev/null
+++ b/testcases/network/stress/multicast/grp-operation/mcast-lib.sh
@@ -0,0 +1,154 @@
+#!/bin/sh
+# Copyright (c) International Business Machines  Corp., 2006
+# Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Petr Vorel <pvorel@suse.cz>
+#
+# Setup script for multicast stress tests.
+
+TST_TOTAL=1
+TST_CLEANUP="mcast_cleanup"
+
+. test_net_stress.sh
+
+MCAST_LCMD="ns-mcast_join -f $ipver -I $(tst_iface)"
+
+MCAST_RCMD="ns-igmp_querier"
+[ "$TST_IPV6" ] && MCAST_RCMD="ns-icmpv6_sender"
+MCAST_RCMD="$MCAST_RCMD -I $(tst_iface rhost)"
+
+mcast_setup4()
+{
+	local igmp_max_memberships="$1"
+
+	SYSFS_IGMP_MAX_MEMBERSHIPS=$(sysctl -b net.ipv4.igmp_max_memberships)
+	SYSFS_IGMP_MAX_MSF=$(sysctl -b net.ipv4.igmp_max_msf)
+	SYSFS_FORCE_IGMP_VERSION=$(sysctl -b net.ipv4.conf.$(tst_iface).force_igmp_version)
+	SYSFS_ALL_FORCE_IGMP_VERSION=$(sysctl -b net.ipv4.conf.all.force_igmp_version)
+
+	[ "$igmp_max_memberships" -gt 5459 ] && tst_resm TWARN \
+		"\$1 shouldn't be set higher than 5459 as it's used to set /proc/sys/net/ipv4/igmp_max_memberships"
+
+	ROD sysctl -qw net.ipv4.igmp_max_memberships=$igmp_max_memberships
+	ROD sysctl -qw net.ipv4.igmp_max_msf=10
+	ROD sysctl -qw net.ipv4.conf.$(tst_iface).force_igmp_version=0
+	ROD sysctl -qw net.ipv4.conf.all.force_igmp_version=0
+}
+
+mcast_setup6()
+{
+	local default_mld_max_msf=64
+	tst_kvcmp -lt '2.6.15' && default_mld_max_msf=10
+
+	SYSCTL_ALL_FORCE_MLD_VERSION=$(sysctl -b net.ipv6.conf.all.force_mld_version)
+	SYSCTL_FORCE_MLD_VERSION=$(sysctl -b net.ipv6.conf.$(tst_iface).force_mld_version)
+	SYSCTL_MLD_MAX_MSF=$(sysctl -b net.ipv6.mld_max_msf)
+
+	ROD sysctl -qw net.ipv6.conf.all.force_mld_version=0
+	ROD sysctl -qw net.ipv6.conf.$(tst_iface).force_mld_version=0
+	ROD sysctl -qw net.ipv6.mld_max_msf=$default_mld_max_msf
+}
+
+mcast_setup()
+{
+	local max="$1"
+
+	netstress_setup
+	tst_tmpdir
+
+	[ "$TST_IPV6" ] && mcast_setup6 || mcast_setup4 $max
+}
+
+mcast_cleanup4()
+{
+	[ -n "$SYSFS_IGMP_MAX_MEMBERSHIPS" ] && sysctl -qw net.ipv4.igmp_max_memberships=$SYSFS_IGMP_MAX_MEMBERSHIPS
+	[ -n "$SYSFS_IGMP_MAX_MSF" ] && sysctl -qw net.ipv4.igmp_max_msf=$SYSFS_IGMP_MAX_MSF
+	[ -n "$SYSFS_FORCE_IGMP_VERSION" ] && sysctl -qw net.ipv4.conf.$(tst_iface).force_igmp_version=$SYSFS_FORCE_IGMP_VERSION
+	[ -n "$SYSFS_ALL_FORCE_IGMP_VERSION" ] && sysctl -qw net.ipv4.conf.all.force_igmp_version=$SYSFS_ALL_FORCE_IGMP_VERSION
+}
+
+mcast_cleanup6()
+{
+	[ -n "$SYSCTL_ALL_FORCE_MLD_VERSION" ] && sysctl -qw net.ipv6.conf.all.force_mld_version=$SYSCTL_ALL_FORCE_MLD_VERSION
+	[ -n "$SYSCTL_FORCE_MLD_VERSION" ] && sysctl -qw net.ipv6.conf.$(tst_iface).force_mld_version=$SYSCTL_FORCE_MLD_VERSION
+	[ -n "$SYSCTL_MLD_MAX_MSF" ] && sysctl -qw net.ipv6.mld_max_msf=$SYSCTL_MLD_MAX_MSF
+}
+
+mcast_cleanup()
+{
+	[ "$TST_IPV6" ] && mcast_cleanup6 || mcast_cleanup4
+
+	pkill -SIGHUP -f "$MCAST_LCMD"
+	tst_sleep 10ms
+	pkill -9 -f "$MCAST_LCMD"
+
+	tst_rhost_run -c "pkill -SIGHUP -f '$MCAST_RCMD'"
+}
+
+do_multicast_test_multiple_join()
+{
+	local num="$1"
+	local mprefix="$MCAST_IPV4_ADDR_PREFIX"
+	local param_multi_socket ret tmpfile
+
+	[ "${2:-}" = true ] && param_multi_socket="-m"
+	[ "$TST_IPV6" ] && mprefix="$MCAST_IPV6_ADDR_PREFIX"
+
+	# Run a multicast join tool
+	tmpfile=$$
+	EXPECT_PASS $MCAST_LCMD $param_multi_socket -n $num -p $mprefix \> $tmpfile
+	tst_resm TINFO "joined $(grep groups $tmpfile)"
+
+	# Send MLD / IGMP General Query from the remote host
+	if [ "$TST_IPV6" ]; then
+		EXPECT_RHOST_PASS $MCAST_RCMD -S $(tst_ipaddr) -m -o
+	else
+		EXPECT_RHOST_PASS $MCAST_RCMD -o -r 1 -m $MCAST_IPV4_ADDR
+	fi
+}
+
+do_multicast_test_join_leave()
+{
+	local cnt define_src_addr filter params ret
+	local max="$1"
+	local maddr="$MCAST_IPV4_ADDR"
+	[ "$TST_IPV6" ] && maddr="$MCAST_IPV6_ADDR"
+
+	[ "$2" = true ] && define_src_addr=true
+
+	# Send MLD / IGMP General Query from the remote host
+	if [ "$TST_IPV6" ]; then
+		tst_rhost_run -s -c "$MCAST_RCMD -S $(tst_ipaddr) -m -w 1000000000 -r 1000 -b"
+	else
+		tst_rhost_run -s -c "$MCAST_RCMD -i 1000000000 -r 1 -b"
+	fi
+
+	# Run a multicast join tool
+	cnt=0
+	while [ $cnt -lt $max ]; do
+		if [ "$define_src_addr" ]; then
+			[ $((cnt % 5)) -ne 2 ] && filter="include" || filter="exclude"
+			params="-F $filter -s $(tst_ipaddr_un -c$cnt)"
+		fi
+
+		$MCAST_LCMD -l $NS_TIMES -a $maddr $params &
+		cnt=$((cnt + 1))
+	done
+
+	wait
+
+	tst_resm TPASS "test is finished successfully"
+}
diff --git a/testcases/network/stress/multicast/grp-operation/mcast4-grpope01 b/testcases/network/stress/multicast/grp-operation/mcast4-grpope01
deleted file mode 100644
index b03ff62..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast4-grpope01
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast4-grpope01
-#
-# Description:
-#   Verify that the kernel is not crashed when joining lots of IPv4 multicast
-#   groups on a single socket
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 1 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast4-grpope01
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the group
-MCASTNUM_HEAVY=${MCASTNUM_HEAVY:-40000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv4 address
-NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of the IPv4 network
-NETWORK_MASK=24
-
-# Host portion of the IPv4 address
-LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
-RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
-
-# Prefix of the Multicast Address
-MCAST_ADDR_PREFIX=224.10
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv4_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv4.igmp_max_memberships=$MCASTNUM_HEAVY >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
-    sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
-    sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_HEAVY IPv4 multicast groups on a single socket"
-
-do_setup
-
-# Run a multicast join tool
-tmpfile=$TMPDIR/ns-mcast_join.$$
-ns-mcast_join -f 4 -I $lhost_ifname -n $MCASTNUM_HEAVY -p $MCAST_ADDR_PREFIX > $tmpfile
-if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-    rm -f $tmpfile
-    exit 1
-fi
-msg=`cat $tmpfile | grep groups`
-tst_resm TINFO "Joined $msg"
-rm -f $tmpfile
-
-# Send IGMP General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -o -r 1' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start IGMP querier"
-    exit 1
-fi
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-while true ; do
-    ps auxw | grep -v grep | grep ns-mcast_join > /dev/null
-    if [ $? -ne 0 ] ; then
-  	break
-    fi
-done
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/multicast/grp-operation/mcast4-grpope02 b/testcases/network/stress/multicast/grp-operation/mcast4-grpope02
deleted file mode 100644
index 67efac7..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast4-grpope02
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast4-grpope02
-#
-# Description:
-#   Verify that the kernel is not crashed when joining lots of IPv4 multicast
-#   groups on lots of sockets
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 1 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast4-grpope02
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the group
-MCASTNUM_HEAVY=${MCASTNUM_HEAVY:-40000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv4 address
-NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of the IPv4 network
-NETWORK_MASK=24
-
-# Host portion of the IPv4 address
-LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
-RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
-
-# Prefix of the Multicast Address
-MCAST_ADDR_PREFIX=224.10
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # Increase the maximum number of open file descriptors
-    fd_num=`ulimit -n`
-    if [ $fd_num -lt $MCASTNUM_HEAVY ]; then
-	ulimit -n $MCASTNUM_HEAVY
-	if [ $? -ne 0 ]; then
-	    tst_resm TBROK "$MCASTNUM_HEAVY is too many for the file descriptor"
-	fi
-    fi
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv4_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv4.igmp_max_memberships=$MCASTNUM_HEAVY >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
-    sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
-    sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_HEAVY IPv4 multicast groups on separate sockets"
-
-do_setup
-
-# Run a multicast join tool
-tmpfile=$TMPDIR/ns-mcast_join.$$
-ns-mcast_join -m -f 4 -I $lhost_ifname -n $MCASTNUM_HEAVY -p $MCAST_ADDR_PREFIX > $tmpfile
-if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-    rm -f $tmpfile
-    exit 1
-fi
-msg=`cat $tmpfile | grep groups`
-tst_resm TINFO "Joined $msg"
-rm -f $tmpfile
-
-# Send IGMP General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -o -r 1' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start IGMP querier"
-    exit 1
-fi
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-while true ; do
-    ps auxw | grep -v grep | grep ns-mcast_join > /dev/null
-    if [ $? -ne 0 ] ; then
-	break
-    fi
-done
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/multicast/grp-operation/mcast4-grpope03 b/testcases/network/stress/multicast/grp-operation/mcast4-grpope03
deleted file mode 100644
index c44ec21..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast4-grpope03
+++ /dev/null
@@ -1,207 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast4-grpope03
-#
-# Description:
-#   Verify that the kernel is not crashed when joining and leaving the same
-#   IPv4 multicast group on multiple sockets lots of times
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 2 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast4-grpope03
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the socket
-MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
-
-# The number of the join/leave groups
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv4 address
-NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of the IPv4 network
-NETWORK_MASK=24
-
-# Host portion of the IPv4 address
-LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
-RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
-
-# Multicast Address
-MCAST_ADDR=224.10.10.1
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv4_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv4.igmp_max_memberships=$MCASTNUM_NORMAL >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
-    sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
-    sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining and leaving the same IPv4 multicast group on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
-
-do_setup
-
-# Send IGMP General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -i 1000000000 -r 1 -b' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start IGMP querier"
-    exit 1
-fi
-
-# Run a multicast join tool
-num=0
-while [ $num -lt $MCASTNUM_NORMAL ]; do
-    ns-mcast_join -f 4 -I $lhost_ifname -l $NS_TIMES -a $MCAST_ADDR &
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-	exit 1
-    fi
-    num=`expr $num + 1`
-done
-
-wait
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/multicast/grp-operation/mcast4-grpope04 b/testcases/network/stress/multicast/grp-operation/mcast4-grpope04
deleted file mode 100644
index 8783928..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast4-grpope04
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast4-grpope04
-#
-# Description:
-#   Verify that the kernel is not crashed when joining and leaving the same
-#   IPv4 multicast group with the different source filter on multiple sockets
-#   lots of times
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 2 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast4-grpope04
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the socket
-MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
-
-# The number of the join/leave groups
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv4 address
-NETWORK_PART=${IPV4_NETWORK:-"10.0.0"}
-
-# Netmask of the IPv4 network
-NETWORK_MASK=24
-
-# Host portion of the IPv4 address
-LHOST_HOST_PART=${LHOST_IPV4_HOST:-"2"}     # local host
-RHOST_HOST_PART=${RHOST_IPV4_HOST:-"1"}     # remote host
-
-# Multicast Address
-MCAST_ADDR=224.10.10.1
-
-# Prefix of the filter souce adddress
-SOURCE_ADDR_PREFIX="10.10"	# 10.10.x.y
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-igmp_querier >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${NETWORK_PART}.${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}.${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv4_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv4.igmp_max_memberships=$MCASTNUM_NORMAL >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv4.igmp_max_msf=10 >/dev/null
-    sysctl -w net.ipv4.conf.${lhost_ifname}.force_igmp_version=0 >/dev/null
-    sysctl -w net.ipv4.conf.all.force_igmp_version=0 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining and leaving ame IPv4 multicast group with different source filters on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
-
-do_setup
-
-# Send IGMP General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-igmp_querier -I $rhost_ifname -i 1000000000 -r 1 -b' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start IGMP querier"
-    exit 1
-fi
-
-# Run a multicast join tool
-num=0
-while [ $num -lt $MCASTNUM_NORMAL ]; do
-    # Define the source address
-    x=`expr $num \/ 254`
-    y=`expr $num % 254 + 1`
-    if [ $x -gt 254 ]; then
-	tst_resm TINFO "The number of the connection is less than $num"
-	break
-    fi
-    source_addr="${SOURCE_ADDR_PREFIX}.${x}.${y}"
-
-    if [ `expr $num % 5` -ne 2 ]; then
-	filter="include"
-    else
-	filter="exclude"
-    fi
-
-    ns-mcast_join -f 4 -I $lhost_ifname -l $NS_TIMES -a $MCAST_ADDR -F $filter -s $source_addr &
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-	exit 1
-    fi
-    num=`expr $num + 1`
-done
-
-wait
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/multicast/grp-operation/mcast6-grpope01 b/testcases/network/stress/multicast/grp-operation/mcast6-grpope01
deleted file mode 100644
index e739516..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast6-grpope01
+++ /dev/null
@@ -1,208 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast6-grpope01
-#
-# Description:
-#   Verify that the kernel is not crashed when joining lots of IPv6 multicast
-#   groups on a single socket
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 6 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast6-grpope01
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the group
-MCASTNUM_HEAVY=${MCASTNUM_HEAVY:-40000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv6 address
-NETWORK_PART="fec0:1:1:1"
-
-# Host portion of the IPv6 address
-LHOST_HOST_PART=":2"	# local host
-RHOST_HOST_PART=":1"	# remote host
-
-# Prefix of the Multicast Address
-MCAST_ADDR_PREFIX=ff0e::1111
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-icmpv6_sender >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv6 addresses to the interfaces
-    add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv6 address of the local/remote host
-    lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
-    rhost_linklocal="fe80:${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv6_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv6 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
-    sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_HEAVY IPv6 multicast groups on a single socket"
-
-do_setup
-
-# Run a multicast join tool
-tmpfile=$TMPDIR/ns-mcast_join.$$
-ns-mcast_join -f 6 -I $lhost_ifname -n $MCASTNUM_HEAVY -p $MCAST_ADDR_PREFIX > $tmpfile
-if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-    rm -f $tmpfile
-    exit 1
-fi
-msg=`cat $tmpfile | grep groups`
-tst_resm TINFO "Joined $msg"
-rm -f $tmpfile
-
-# Send MLD General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-icmpv6_sender -I $rhost_ifname -S $rhost_linklocal -m -o' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start MLD querier"
-    exit 1
-fi
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-while true ; do
-    ps auxw | grep -v grep | grep ns-mcast_join > /dev/null
-    if [ $? -ne 0 ] ; then
-	break
-    fi
-done
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/multicast/grp-operation/mcast6-grpope02 b/testcases/network/stress/multicast/grp-operation/mcast6-grpope02
deleted file mode 100644
index d8b5d63..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast6-grpope02
+++ /dev/null
@@ -1,217 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast6-grpope02
-#
-# Description:
-#   Verify that the kernel is not crashed when joining lots of IPv6 multicast
-#   groups on lots of sockets
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 6 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast6-grpope02
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the group
-MCASTNUM_HEAVY=${MCASTNUM_HEAVY:-40000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv6 address
-NETWORK_PART="fec0:1:1:1"
-
-# Host portion of the IPv6 address
-LHOST_HOST_PART=":2"     # local host
-RHOST_HOST_PART=":1"     # remote host
-
-# Prefix of the Multicast Address
-MCAST_ADDR_PREFIX=ff0e::1111
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-icmpv6_sender >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # Increase the maximum number of open file descriptors
-    fd_num=`ulimit -n`
-    if [ $fd_num -lt $MCASTNUM_HEAVY ]; then
-	ulimit -n $MCASTNUM_HEAVY
-	if [ $? -ne 0 ]; then
-	    tst_resm TBROK "$MCASTNUM_HEAVY is too many for the file descriptor"
-	fi
-    fi
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv6 addresses to the interfaces
-    add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv6 address of the local/remote host
-    lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
-    rhost_linklocal="fe80:${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv6_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv6 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
-    sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining $MCASTNUM_HEAVY IPv6 multicast groups on separate sockets"
-
-do_setup
-
-# Run a multicast join tool
-tmpfile=$TMPDIR/ns-mcast_join.$$
-ns-mcast_join -m -f 6 -I $lhost_ifname -n $MCASTNUM_HEAVY -p $MCAST_ADDR_PREFIX > $tmpfile
-if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-    rm -f $tmpfile
-    exit 1
-fi
-msg=`cat $tmpfile | grep groups`
-tst_resm TINFO "Joined $msg"
-rm -f $tmpfile
-
-# Send MLD General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-icmpv6_sender -I $rhost_ifname -S $rhost_linklocal -m -o' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start MLD querier"
-    exit 1
-fi
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-while true ; do
-    ps auxw | grep -v grep | grep ns-mcast_join > /dev/null
-    if [ $? -ne 0 ] ; then
-	break
-    fi
-done
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/multicast/grp-operation/mcast6-grpope03 b/testcases/network/stress/multicast/grp-operation/mcast6-grpope03
deleted file mode 100644
index 51c6e46..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast6-grpope03
+++ /dev/null
@@ -1,204 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast6-grpope03
-#
-# Description:
-#   Verify that the kernel is not crashed when joining and leaving the same
-#   IPv6 multicast group on multiple sockets lots of times
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 6 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast6-grpope03
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the socket
-MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
-
-# The number of the join/leave groups
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv6 address
-NETWORK_PART="fec0:1:1:1"
-
-# Host portion of the IPv6 address
-LHOST_HOST_PART=":2"     # local host
-RHOST_HOST_PART=":1"     # remote host
-
-# Multicast Address
-MCAST_ADDR=ff0e::1111:1
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-icmpv6_sender >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv6 addresses to the interfaces
-    add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv6 address of the local/remote host
-    lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
-    rhost_linklocal="fe80:${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv6_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv6 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
-    sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining and leaving the same IPv6 multicast group on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
-
-do_setup
-
-# Send MLD General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-icmpv6_sender -I $rhost_ifname -S $rhost_linklocal -m -w 1000000000 -r 1000 -b' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start MLD querier"
-    exit 1
-fi
-
-# Run a multicast join tool
-num=0
-while [ $num -lt $MCASTNUM_NORMAL ]; do
-    ns-mcast_join -f 6 -I $lhost_ifname -l $NS_TIMES -a $MCAST_ADDR &
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-	exit 1
-    fi
-    num=`expr $num + 1`
-done
-
-wait
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/multicast/grp-operation/mcast6-grpope04 b/testcases/network/stress/multicast/grp-operation/mcast6-grpope04
deleted file mode 100644
index 7d864e9..0000000
--- a/testcases/network/stress/multicast/grp-operation/mcast6-grpope04
+++ /dev/null
@@ -1,222 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2006                 ##
-##                                                                            ##
-## 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:
-#   mcast6-grpope04
-#
-# Description:
-#   Verify that the kernel is not crashed when joining and leaving the same
-#   IPv6 multicast group with the different source filter on multiple sockets
-#   lots of times
-#
-# Setup:
-#   See ltp-yyyymmdd/testcases/network/stress/README
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# History:
-#	May 6 2006 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# The test case ID, the test case count and the total number of test case
-TCID=mcast6-grpope04
-TST_TOTAL=1
-TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
-# Number of the socket
-MCASTNUM_NORMAL=${MCASTNUM_NORMAL:-20}
-
-# The number of the join/leave groups
-NS_TIMES=${NS_TIMES:-10000}
-
-# The number of the test link where tests run
-LINK_NUM=${LINK_NUM:-0}
-
-# Network portion of the IPv6 address
-NETWORK_PART="fec0:1:1:1"
-
-# Host portion of the IPv6 address
-LHOST_HOST_PART=":2"	# local host
-RHOST_HOST_PART=":1"	# remote host
-
-# Multicast Address
-MCAST_ADDR=ff0e::1111:1
-
-# Prefix of the filter souce adddress
-SOURCE_ADDR_PREFIX="fec0:100:100:100"
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_cleanup
-#
-# Description:
-#   Recover the system configuration
-#
-#-----------------------------------------------------------------------
-do_cleanup()
-{
-    # Make sure to kill the multicast receiver and sender
-    killall -SIGHUP ns-mcast_join >/dev/null 2>&1
-    $LTP_RSH $RHOST killall -SIGHUP ns-icmpv6_sender >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: do_setup
-#
-# Description:
-#   Configure the ssystem for the test
-#
-#-----------------------------------------------------------------------
-do_setup()
-{
-    # Initialize the system configuration
-    do_cleanup
-
-    # Call do_cleanup function before exit
-    trap do_cleanup 0
-
-    # name of interface of the local/remote host
-    lhost_ifname=`get_ifname lhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the local host"
-	exit $TST_TOTAL
-    fi
-
-    rhost_ifname=`get_ifname rhost $LINK_NUM`
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to get the interface name at the remote host"
-	exit $TST_TOTAL
-    fi
-
-    # Set IPv6 addresses to the interfaces
-    add_ipv6addr lhost $LINK_NUM $NETWORK_PART $LHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    add_ipv6addr rhost $LINK_NUM $NETWORK_PART $RHOST_HOST_PART
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv6 address of the local/remote host
-    lhost_addr="${NETWORK_PART}:${LHOST_HOST_PART}"
-    rhost_addr="${NETWORK_PART}:${RHOST_HOST_PART}"
-    rhost_linklocal="fe80:${RHOST_HOST_PART}"
-
-    # Make sure the connectvity
-    check_icmpv6_connectivity $lhost_ifname $rhost_addr
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "There is no IPv6 connectivity."
-	exit 1
-    fi
-
-    # Make sure the sysctl values
-    sysctl -w net.ipv6.conf.all.force_mld_version=0 >/dev/null
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to set the sysctl value regarding multicast"
-	exit $TST_TOTAL
-    fi
-
-    sysctl -w net.ipv6.conf.${lhost_ifname}.force_mld_version=0 >/dev/null
-    sysctl -w net.ipv6.mld_max_msf=10 >/dev/null
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Main
-#
-#
-
-# Test description
-tst_resm TINFO "Verify that the kernel is not crashed when joining and leaving ame IPv6 multicast group with different source filters on $MCASTNUM_NORMAL sockets in $NS_TIMES times"
-
-do_setup
-
-# Send MLD General Query from the remote host
-ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-icmpv6_sender -I $rhost_ifname -S $rhost_linklocal -m -w 1000000000 -r 1000 -b' ; echo $?'`
-if [ $ret -ne 0 ]; then
-    tst_resm TBROK "Failed to start MLD querier"
-    exit 1
-fi
-
-# Run a multicast join tool
-num=0
-while [ $num -lt $MCASTNUM_NORMAL ]; do
-    # Define the source address
-    if [ $num -gt 65535 ]; then
-	tst_resm TINFO "The number of the connection is less than 65535"
-	break
-    fi
-    num_hex=`printf "%x" $num`
-    source_addr="${SOURCE_ADDR_PREFIX}::${num_hex}"
-
-    if [ `expr $num % 5` -ne 2 ]; then
-	filter="include"
-    else
-	filter="exclude"
-    fi
-
-    ns-mcast_join -f 6 -I $lhost_ifname -l $NS_TIMES -a $MCAST_ADDR -F $filter -s $source_addr &
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to start multicast joining tool Please check the environment"
-	exit 1
-    fi
-    num=`expr $num + 1`
-done
-
-wait
-
-#-----------------------------------------------------------------------
-#
-# Clean up
-#
-
-tst_resm TPASS "Test is finished successfully."
-
-exit 0
diff --git a/testcases/network/stress/ns-tools/00_Descriptions.txt b/testcases/network/stress/ns-tools/00_Descriptions.txt
index 85f69ad..ab9c3ce 100644
--- a/testcases/network/stress/ns-tools/00_Descriptions.txt
+++ b/testcases/network/stress/ns-tools/00_Descriptions.txt
@@ -37,9 +37,6 @@
 find_portbundle
 	Find a bundle of consecutive ports
 
-bg_tcp_traffic
-	Control the background TCP traffic
-
 killall_icmp_traffic
 	Kill all of the icmp traffic utilities (ping or ping6)
 
diff --git a/testcases/network/stress/ns-tools/Makefile b/testcases/network/stress/ns-tools/Makefile
index df9ba42..1c186b2 100644
--- a/testcases/network/stress/ns-tools/Makefile
+++ b/testcases/network/stress/ns-tools/Makefile
@@ -25,11 +25,11 @@
 include $(top_srcdir)/include/mk/env_pre.mk
 
 INSTALL_TARGETS		:= check_envval get_ifname initialize_if set_ipv4addr \
-		   	   add_ipv6addr check_icmpv4_connectivity \
+			   add_ipv6addr check_icmpv4_connectivity \
 			   check_icmpv6_connectivity check_netem check_setkey \
-			   create_file find_portbundle bg_tcp_traffic \
-			   killall_icmp_traffic killall_tcp_traffic \
-			   killall_udp_traffic output_ipsec_conf ns-echoclient
+			   create_file find_portbundle killall_icmp_traffic \
+			   killall_tcp_traffic killall_udp_traffic output_ipsec_conf \
+			   ns-echoclient test_net_stress.sh
 
 FILTER_OUT_MAKE_TARGETS	:= ns-common
 
diff --git a/testcases/network/stress/ns-tools/bg_tcp_traffic b/testcases/network/stress/ns-tools/bg_tcp_traffic
deleted file mode 100644
index 630378c..0000000
--- a/testcases/network/stress/ns-tools/bg_tcp_traffic
+++ /dev/null
@@ -1,275 +0,0 @@
-#!/bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2005                 ##
-##                                                                            ##
-## 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:
-#   bg_tcp_traffic
-#
-# Description:
-#   Control the background TCP traffic
-#
-# Author:
-#   Mitsuru Chinen <mitch@jp.ibm.com>
-#
-# Arguments:
-#   $1: command (make/check/kill/killall)
-#   $2: IP address when the command is make
-#       Process ID when the command is check or kill
-#
-# Outputs:
-#   Process ID of the TCP traffic server when the command is make
-#
-# Exit Value:
-#    0: Exit normally
-#   >0: Exit abnormally
-#
-# History:
-#   Oct 19 2005 - Created (Mitsuru Chinen)
-#
-#-----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-# Make sure the value of LTPROOT
-LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
-export LTPROOT
-
-# Check the environmanet variable for the test
-. check_envval || exit 1
-
-# Timeout till client starts up [sec]
-CLIENT_TIMEOUT=10
-
-
-#-----------------------------------------------------------------------
-#
-# Function: usage
-#
-# Description:
-#   Print the usage of this script, then exit
-#
-#-----------------------------------------------------------------------
-usage(){
-    cat << EOD >&2
-bg_tcp_traffic command [argument]
-  command:  make / check / kill / killall
-  argument: IP address of the server (if command is make)
-            Process ID (if command is check/kill)
-            (none)  (if command is killall)
-EOD
-
-    exit 1
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: make_traffic
-#
-# Description:
-#   Make a background tcp traffic.
-#   The local host will be a server, and the remote host will be a client
-#
-# Arguments:
-#   $1: IP address of the server
-#
-# Exit Value:
-#   0: Success
-#   1: Fail
-#
-#-----------------------------------------------------------------------
-make_traffic() {
-    server_ipaddr=$1
-
-    # Identify the family is ipv4 or ipv6
-    family=0
-    echo $server_ipaddr | fgrep "." >/dev/null 2>&1
-    if [ $? -eq 0 ]; then
-	family=4
-    else
-	echo $server_ipaddr | fgrep ":" >/dev/null 2>&1
-	if [ $? -eq 0 ]; then
-	    family=6
-	fi
-    fi
-
-    if [ $family -eq 0 ]; then
-	echo "The IP address of the server is something wrong." >&2
-	exit 1
-    fi
-
-    # Find the available consecutive ports
-    server_port=`find_portbundle tcp 1025 1`
-    if [ $? -ne 0 ]; then
-	echo "No port is available." >&2
-	exit 1
-    fi
-
-    # Start up a server
-    infofile=`mktemp -p $TMPDIR`
-    ns-tcpserver -b -f $family -p ${server_port} -o $infofile
-
-    while true ; do	# Wait till ns-tcpserver outputs the information
-	if [ -s $infofile ]; then
-	    break
-	fi
-    done
-
-    server_pid=`fgrep PID: $infofile | awk '{ print $2 }'`
-
-    rm -f $infofile
-
-    if [ x$server_pid = x ]; then
-	echo "TCP traffic server does not run" >&2
-	exit 1
-    fi
-
-    # Start up a client
-    $LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-tcpclient -b -S $server_ipaddr -f $family -p $server_port"
-
-    count=0
-    while true ; do
-	$LTP_RSH $RHOST "ps auxw | fgrep -v grep | fgrep -l ns-tcpclient >/dev/null 2>&1"
-	if [ $? -ne 0 ]; then
-	    if [ $count -lt $CLIENT_TIMEOUT ]; then
-		count=`expr $count + 1`
-		sleep 1
-		continue
-	    else
-		echo "TCP traffic client does not run" >&2
-		kill -SIGHUP $server_pid
-		exit 1
-	    fi
-	else
-	    # Output the process ID of the server, the finished
-	    echo $server_pid
-	    exit 0
-	fi
-    done
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: check_traffic
-#
-# Description:
-#   Check the TCP traffic exists
-#
-# Arguments:
-#   $1: Process ID of the TCP traffic server
-#
-# Exit Value:
-#   0: The connectivity is good.
-#   1: The connectivity is something wrong.
-#
-#-----------------------------------------------------------------------
-check_traffic()
-{
-    server_pid=$1
-
-    if [ ! -d /proc/$server_pid ]; then
-	echo "TCP traffic server has gone." >&2
-	exit 1
-    fi
-    exit 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: kill_traffic
-#
-# Description:
-#   Kill the TCP traffic
-#
-# Arguments:
-#   $1: Process ID of the TCP traffic server
-#
-# Exit Value:
-#   Always 0
-#
-#-----------------------------------------------------------------------
-kill_traffic()
-{
-    server_pid=$1
-
-    kill -SIGHUP $server_pid >/dev/null 2>&1
-    exit 0
-}
-
-
-#-----------------------------------------------------------------------
-#
-# Function: killall_traffic
-#
-# Description:
-#   Kill all of the TCP traffic
-#
-# Exit Value:
-#   Always 0
-#
-#-----------------------------------------------------------------------
-killall_traffic()
-{
-    killall_tcp_traffic
-}
-
-#
-# Main
-#
-command=$1
-
-case $command in
-    make)
-    if [ $# -ne 2 ]; then
-	usage
-    fi
-    make_traffic $2
-    ;;
-
-    check)
-    if [ $# -ne 2 ]; then
-	usage
-    fi
-    check_traffic $2
-    ;;
-
-    kill)
-    if [ $# -ne 2 ]; then
-	usage
-    fi
-    kill_traffic $2
-    ;;
-
-    killall)
-    if [ $# -ne 1 ]; then
-	usage
-    fi
-    killall_traffic $2
-    ;;
-
-    *)
-    usage
-    ;;
-esac
diff --git a/testcases/network/stress/ns-tools/ns-tcpserver.c b/testcases/network/stress/ns-tools/ns-tcpserver.c
index 4ac51a9..bfbcc0d 100644
--- a/testcases/network/stress/ns-tools/ns-tcpserver.c
+++ b/testcases/network/stress/ns-tools/ns-tcpserver.c
@@ -276,7 +276,7 @@
  * Function: communicate_client()
  *
  * Descripton:
- *  Communicate with the connectted client.
+ *  Communicate with the connected client.
  *  Currently, this function sends tcp segment in the specified second
  *  or recevie SIGHUP
  *
diff --git a/testcases/network/stress/ns-tools/test_net_stress.sh b/testcases/network/stress/ns-tools/test_net_stress.sh
new file mode 100644
index 0000000..77f5797
--- /dev/null
+++ b/testcases/network/stress/ns-tools/test_net_stress.sh
@@ -0,0 +1,126 @@
+#!/bin/sh
+# Copyright (c) International Business Machines  Corp., 2006
+# Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Petr Vorel <pvorel@suse.cz>
+# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+#
+# Library for all network/stress/ tests.
+# NOTE: More information about network variables can be found
+# in test_net.sh and testcases/network/stress/README.
+
+export TCID="${TCID:-$(basename $0)}"
+
+. test_net.sh
+
+ipver=${TST_IPV6:-4}
+
+# Netmask of for the tested network
+IPV4_NETMASK="255.255.255.0"
+IPV4_NETMASK_NUM=24
+
+# Multicast address and it's prefix
+MCAST_IPV4_ADDR_PREFIX="224.10"
+MCAST_IPV4_ADDR="${MCAST_IPV4_ADDR_PREFIX}.10.1"
+MCAST_IPV6_ADDR_PREFIX="ff0e::1111"
+MCAST_IPV6_ADDR="${MCAST_IPV6_ADDR_PREFIX}:1"
+
+# Setup for tests using netstress.
+netstress_setup()
+{
+	tst_require_root
+	tst_check_cmds ip pgrep pkill
+	trap "tst_brkm TBROK 'test interrupted'" INT
+}
+
+# Cleanup for tests using netstress.
+netstress_cleanup()
+{
+	# Stop the background TCP traffic
+	pkill -13 -x netstress
+	tst_rhost_run -c "pkill -13 -x netstress"
+}
+
+# restore_ipaddr [TYPE] [LINK] [LOCAL_IFACE] [REMOTE_IFACE]
+# TYPE: { lhost | rhost }; Default value is 'lhost'.
+# LINK: link number starting from 0. Default value is '0'.
+# LOCAL_IFACE: local iface name.
+# REMOTE_IFACE: local iface name.
+restore_ipaddr()
+{
+	local type="${1:-lhost}"
+	local link_num="${2:-0}"
+	local iface_loc=${3:-$(tst_iface lhost $link_num)}
+	local iface_rmt=${4:-$(tst_iface rhost $link_num)}
+
+	tst_restore_ipaddr $type $link_num || return $?
+	[ $type = "lhost" ] && tst_wait_ipv6_dad $iface_loc $iface_rmt
+}
+
+# Check connectivity with tst_ping.
+# check_connectivity SRC_IFACE DST_ADDR [CNT]
+# SRC_IFACE: source interface name.
+# DST_ADDR: destination IPv4 or IPv6 address.
+# CNT: loop step.
+check_connectivity()
+{
+	local src_iface="${1}"
+	local dst_addr="${2}"
+	local cnt="${3:-}"
+	local cnt_msg
+
+	[ -n "$cnt" ] && cnt_msg=" (step $cnt)"
+
+	tst_resm TINFO "ping through $src_iface iface to ${dst_addr}$cnt_msg"
+
+	tst_ping $src_iface $dst_addr
+}
+
+# check_connectivity_interval CNT [RESTORE] [SRC_IFACE] [DST_ADDR]
+# CNT: loop step.
+# RESTORE: whether restore ip addr.
+# SRC_IFACE: source interface name.
+# DST_ADDR: destination IPv4 or IPv6 address.
+check_connectivity_interval()
+{
+	local cnt="$1"
+	local restore="${2:-false}"
+	local src_iface="${3:-$(tst_iface)}"
+	local dst_addr="${4:-$(tst_ipaddr rhost)}"
+
+	[ $CHECK_INTERVAL -eq 0 ] && return
+
+	[ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && return
+
+	[ "$restore" != "false" ] && restore_ipaddr
+
+	check_connectivity $src_iface $dst_addr $cnt
+}
+
+# Run netstress process on both lhost and rhost.
+# make_background_tcp_traffic [IP]
+# IP: server IP; Default value is $(tst_ipaddr).
+make_background_tcp_traffic()
+{
+	pgrep -x netstress > /dev/null && return
+
+	local ip="${1:-$(tst_ipaddr)}"
+	local port=$(tst_get_unused_port ipv${ipver} stream)
+
+	netstress -R 3 -g $port > /dev/null 2>&1 &
+	tst_rhost_run -b -c "netstress -l -H $ip -g $port"
+}
diff --git a/testcases/network/stress/route/route4-rmmod b/testcases/network/stress/route/route4-rmmod
index 11c9711..36c8c97 100644
--- a/testcases/network/stress/route/route4-rmmod
+++ b/testcases/network/stress/route/route4-rmmod
@@ -121,7 +121,7 @@
     # Check the local host has ethtool utility
     which ethtool >/dev/null
     if [ $? -ne 0 ]; then
-	tst_info TBROK "This test case requires ethtool utility"
+	tst_resm TBROK "This test case requires ethtool utility"
 	exit $TST_TOTAL
     fi
 
diff --git a/testcases/network/stress/route/route6-rmmod b/testcases/network/stress/route/route6-rmmod
index 164cf26..640cc06 100644
--- a/testcases/network/stress/route/route6-rmmod
+++ b/testcases/network/stress/route/route6-rmmod
@@ -117,7 +117,7 @@
     # Check the local host has ethtool utility
     which ethtool >/dev/null
     if [ $? -ne 0 ]; then
-	tst_info TBROK "This test case requires ethtool utility"
+	tst_resm TBROK "This test case requires ethtool utility"
 	exit $TST_TOTAL
     fi
 
diff --git a/testcases/network/stress/ssh/ssh-stress03-rmt b/testcases/network/stress/ssh/ssh-stress03-rmt
index 44077ec..da1abeb 100644
--- a/testcases/network/stress/ssh/ssh-stress03-rmt
+++ b/testcases/network/stress/ssh/ssh-stress03-rmt
@@ -51,7 +51,7 @@
 ;;
 6)
 	localhost="::1"
-	ssh -6 -f -N -L $lport/[$server_ipaddr]/$rport \
+	ssh -6 -f -N -L $lport:[$server_ipaddr]:$rport \
 		root@$server_ipaddr -F $ssh_config
 ;;
 esac
diff --git a/testcases/network/stress/tcp/Makefile b/testcases/network/stress/tcp/Makefile
index 8caf2c0..a2511fc 100644
--- a/testcases/network/stress/tcp/Makefile
+++ b/testcases/network/stress/tcp/Makefile
@@ -24,6 +24,7 @@
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= tcp_ipsec.sh
+INSTALL_TARGETS		:= tcp_ipsec.sh \
+			   tcp_ipsec_vti.sh
 
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01 b/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01
index 8b9652c..9995977 100644
--- a/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01
+++ b/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01
@@ -205,7 +205,7 @@
     x=`expr $ipaddr_pair_num \/ 255 % 255`
     y=`expr $ipaddr_pair_num % 255`
     if [ $x -ge 255 ]; then
-	tst_info TINFO "This script cannot add more than $ipaddr_pair_num addresses"
+	tst_resm TINFO "This script cannot add more than $ipaddr_pair_num addresses"
 	break
     fi
 
diff --git a/testcases/network/stress/tcp/tcp_ipsec.sh b/testcases/network/stress/tcp/tcp_ipsec.sh
index ebcd1d5..e75f672 100755
--- a/testcases/network/stress/tcp/tcp_ipsec.sh
+++ b/testcases/network/stress/tcp/tcp_ipsec.sh
@@ -20,7 +20,6 @@
 TST_TOTAL=3
 TST_CLEANUP="tst_ipsec_cleanup"
 
-client_requests=10000
 max_requests=10
 
 . ipsec_lib.sh
@@ -36,11 +35,9 @@
 
 do_test()
 {
-	IPSEC_SIZE_ARRAY="${IPSEC_SIZE_ARRAY:-100 1000 65000}"
-
 	for p in $IPSEC_SIZE_ARRAY; do
 		tst_netload -H $(tst_ipaddr rhost) -n $p -N $p \
-			-r $client_requests -R $max_requests
+			-r $IPSEC_REQUESTS -R $max_requests
 	done
 }
 
diff --git a/testcases/network/stress/tcp/tcp_ipsec_vti.sh b/testcases/network/stress/tcp/tcp_ipsec_vti.sh
new file mode 100755
index 0000000..4ed520b
--- /dev/null
+++ b/testcases/network/stress/tcp/tcp_ipsec_vti.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+
+TCID=tcp_ipsec_vti
+TST_TOTAL=3
+TST_CLEANUP="tst_ipsec_cleanup"
+
+max_requests=10
+
+. ipsec_lib.sh
+
+do_test()
+{
+	for p in $IPSEC_SIZE_ARRAY; do
+		tst_netload -H $ip_rmt_tun -n $p -N $p \
+			-r $IPSEC_REQUESTS -R $max_requests
+	done
+}
+
+tst_ipsec_setup_vti
+
+do_test
+
+tst_exit
diff --git a/testcases/network/stress/udp/Makefile b/testcases/network/stress/udp/Makefile
index 2489b0a..5aa62fa 100644
--- a/testcases/network/stress/udp/Makefile
+++ b/testcases/network/stress/udp/Makefile
@@ -24,6 +24,7 @@
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= udp_ipsec.sh
+INSTALL_TARGETS		:= udp_ipsec.sh \
+			   udp_ipsec_vti.sh
 
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/udp/multi-diffip/udp4-multi-diffip01 b/testcases/network/stress/udp/multi-diffip/udp4-multi-diffip01
index 33d2265..63783d1 100644
--- a/testcases/network/stress/udp/multi-diffip/udp4-multi-diffip01
+++ b/testcases/network/stress/udp/multi-diffip/udp4-multi-diffip01
@@ -171,7 +171,7 @@
     x=`expr $ipaddr_pair_num \/ 255 % 255`
     y=`expr $ipaddr_pair_num % 255`
     if [ $x -ge 255 ]; then
-	tst_info TINFO "This script cannot add more than $ipaddr_pair_num addresses"
+	tst_resm TINFO "This script cannot add more than $ipaddr_pair_num addresses"
 	break
     fi
 
diff --git a/testcases/network/stress/udp/udp_ipsec.sh b/testcases/network/stress/udp/udp_ipsec.sh
index 8e047a4..2debaef 100755
--- a/testcases/network/stress/udp/udp_ipsec.sh
+++ b/testcases/network/stress/udp/udp_ipsec.sh
@@ -20,8 +20,6 @@
 TST_TOTAL=3
 TST_CLEANUP="tst_ipsec_cleanup"
 
-client_requests=10000
-
 . ipsec_lib.sh
 
 do_setup()
@@ -35,11 +33,9 @@
 
 do_test()
 {
-	IPSEC_SIZE_ARRAY="${IPSEC_SIZE_ARRAY:-100 1000 65000}"
-
 	for p in $IPSEC_SIZE_ARRAY; do
-		tst_netload -H $(tst_ipaddr rhost) -U -n $p -N $p \
-			-r $client_requests
+		tst_netload -H $(tst_ipaddr rhost) -T udp -n $p -N $p \
+			-r $IPSEC_REQUESTS
 	done
 }
 
diff --git a/testcases/network/stress/udp/udp_ipsec_vti.sh b/testcases/network/stress/udp/udp_ipsec_vti.sh
new file mode 100755
index 0000000..39bf94f
--- /dev/null
+++ b/testcases/network/stress/udp/udp_ipsec_vti.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+#
+# 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 would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+
+TCID=udp_ipsec_vti
+TST_TOTAL=3
+TST_CLEANUP="tst_ipsec_cleanup"
+
+. ipsec_lib.sh
+
+do_test()
+{
+	for p in $IPSEC_SIZE_ARRAY; do
+		tst_netload -H $ip_rmt_tun -T udp -n $p -N $p \
+			-r $IPSEC_REQUESTS
+	done
+}
+
+tst_ipsec_setup_vti
+
+do_test
+
+tst_exit
diff --git a/testcases/network/traceroute/traceroute01.sh b/testcases/network/traceroute/traceroute01.sh
index 1e01a1c..0475969 100755
--- a/testcases/network/traceroute/traceroute01.sh
+++ b/testcases/network/traceroute/traceroute01.sh
@@ -28,6 +28,9 @@
 
 setup()
 {
+	tst_resm TINFO "traceroute version:"
+	tst_resm TINFO $(traceroute --version 2>&1)
+
 	tst_check_cmds traceroute
 	tst_tmpdir
 }
diff --git a/testscripts/ltpstress.sh b/testscripts/ltpstress.sh
index a487db5..cd041b1 100755
--- a/testscripts/ltpstress.sh
+++ b/testscripts/ltpstress.sh
@@ -271,9 +271,6 @@
   genload --vm 1 --vm-bytes $(($leftover_memsize * 1024)) >/dev/null 2>&1 &
 fi
 
-if [ $NO_NETWORK -eq 0 ];then
- netpipe.sh >/dev/null 2>/dev/null &
-fi
 sort -R ${LTPROOT}/runtest/stress.part1 -o ${TMP}/stress.part1
 sort -R ${LTPROOT}/runtest/stress.part2 -o ${TMP}/stress.part2
 sort -R ${LTPROOT}/runtest/stress.part3 -o ${TMP}/stress.part3
@@ -325,7 +322,6 @@
 killall -9 ltp-pan >/dev/null 2>&1
 killall -9 genload >/dev/null 2>&1
 if [ $NO_NETWORK -eq 0 ];then
-  killall -9 netpipe.sh >/dev/null 2>&1
   killall -9 NPtcp >/dev/null 2>&1
 fi
 if [ $Iostat -eq 1 ];then
diff --git a/testscripts/network.sh b/testscripts/network.sh
index a656bc2..3d09d09 100755
--- a/testscripts/network.sh
+++ b/testscripts/network.sh
@@ -12,6 +12,9 @@
 mkdir -p $TMPDIR
 CMDFILE=${TMPDIR}/network.tests
 VERBOSE="no"
+NO_KMSG=
+QUIET_MODE=
+TEST_CASES=
 
 export PATH="${PATH}:${LTPROOT}/testcases/bin"
 
@@ -36,13 +39,14 @@
 	echo "  -M    multicast stress tests"
 	echo "  -F    network features tests (TFO, vxlan, etc.)"
 	echo "  -f x  where x is a runtest file"
+	echo "  -q    quiet mode (this implies not logging start of test"
+	echo "        in kernel log)"
+	echo "  -Q    don't log start of test in kernel log"
 	echo "  -V|v  verbose"
 	echo "  -h    print this help"
 }
 
-TEST_CASES=
-
-while getopts 6mnrstaebcdiTURMFf:Vvh OPTION
+while getopts 6mnrstaebcdiTURMFf:qQVvh OPTION
 do
 	case $OPTION in
 	6) TEST_CASES="$TEST_CASES net.ipv6 net.ipv6_lib";;
@@ -63,6 +67,8 @@
 	M) TEST_CASES="$TEST_CASES net_stress.multicast";;
 	F) TEST_CASES="$TEST_CASES net.features";;
 	f) TEST_CASES=${OPTARG};;
+	q) QUIET_MODE="-q";;
+	Q) NO_KMSG="-Q";;
 	V|v) VERBOSE="yes";;
 	h) usage; exit 0;;
 	*) echo "Error: invalid option..."; usage; exit 1;;
@@ -93,6 +99,8 @@
 
 cd $TMPDIR
 
+cmd="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE"
+
 if [ ${VERBOSE} = "yes" ]; then
 	echo "Network parameters:"
 	echo " - ${LHOST_IFACES} local interface (MAC address: ${LHOST_HWADDRS})"
@@ -101,10 +109,10 @@
 	cat $CMDFILE
 	${LTPROOT}/ver_linux
 	echo ""
-	echo ${LTPROOT}/bin/ltp-pan -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE
+	echo $cmd
 fi
 
-${LTPROOT}/bin/ltp-pan -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE
+$cmd
 
 if [ $? -eq "0" ]; then
 	echo ltp-pan reported PASS
diff --git a/testscripts/runEALtests.sh b/testscripts/runEALtests.sh
index a70bfad..810dc47 100755
--- a/testscripts/runEALtests.sh
+++ b/testscripts/runEALtests.sh
@@ -81,7 +81,7 @@
   exit
 fi
 
-while getopts cd:f:hi:l:m:Nnpqr:t:x arg
+while getopts cd:f:hi:l:m:Npqr:t:x arg
 do  case $arg in
     c)
             $LTPROOT/../testcases/bin/genload --cpu 1 >/dev/null 2>&1 &
@@ -130,9 +130,6 @@
 
     N)	    run_netest=1;;
 
-    n)	    $LTPROOT/../testcases/bin/netpipe.sh
-	    NetPipe=1;;
-
     p)      pretty_prt=" -p ";;
 
     q)      quiet_mode=" -q ";;
diff --git a/utils/ffsb-6.0-rc2/parser.c b/utils/ffsb-6.0-rc2/parser.c
index 64c89e1..7ec3d73 100644
--- a/utils/ffsb-6.0-rc2/parser.c
+++ b/utils/ffsb-6.0-rc2/parser.c
@@ -116,7 +116,7 @@
 	goto do_multiplier;
 
 try_single:
-	memcpy(unit, "\0", 3);
+	memset(unit, 0, sizeof(unit));
 	strcpy(unit, buf + (buf_size - 1));
 	if (isdigit(unit[0])) {
 		unit[0] = 0;
diff --git a/ver_linux b/ver_linux
index a403b4e..dc49a4c 100755
--- a/ver_linux
+++ b/ver_linux
@@ -63,7 +63,10 @@
 'NR==1{print "Net-tools             ", $NF}'
 
 ip -V 2>&1 | awk \
-'NR==1{print "iproute2             ", $NF}'
+'NR==1{print "iproute2              ", $NF}'
+
+ping -V 2>&1 | awk \
+'NR==1{print "iputils               ", $NF}'
 
 # Kbd needs 'loadkeys -h',
 loadkeys -h 2>&1 | awk \